/
nurse.dm
248 lines (188 loc) · 7.29 KB
/
nurse.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Nurses, they create webs and eggs.
// They're fragile but their attacks can cause horrifying consequences.
/mob/living/simple_animal/hostile/giant_spider/nurse
desc = "Furry and beige, it makes you shudder to look at it. This one has brilliant green eyes."
icon_state = "nurse"
icon_living = "nurse"
icon_dead = "nurse_dead"
maxHealth = 40
health = 40
movement_cooldown = 3 // A bit faster so that they can inject the eggs easier.
poison_per_bite = 5
poison_type = /datum/reagent/soporific
natural_weapon = /obj/item/natural_weapon/bite/spider/nurse
ai_holder = /datum/ai_holder/simple_animal/melee/nurse_spider
var/fed = 0 // Counter for how many egg laying 'charges' the spider has.
var/laying_eggs = FALSE // Only allow one set of eggs to be laid at once.
var/egg_inject_chance = 25 // One in four chance to get eggs.
var/egg_type = /obj/spider/eggcluster
var/web_type = /obj/spider/stickyweb/dark
var/mob/living/simple_animal/hostile/giant_spider/guard/paired_guard
/// The next time the spider can lay. This is set to a random time between the minimum and maximum times.
var/next_egg_time = 0
/// The minimum amount of time the spider must wait before laying eggs again.
var/minimum_disturbed_time = 5 MINUTES
/// The maximum amount of time the spider can wait before laying eggs again.
var/maximum_disturbed_time = 10 MINUTES
/obj/item/natural_weapon/bite/spider/nurse
force = 10
/datum/ai_holder/simple_animal/melee/nurse_spider
mauling = TRUE // The nurse puts mobs into webs by attacking, so it needs to attack in crit
handle_corpse = TRUE // Lets the nurse wrap dead things
/mob/living/simple_animal/hostile/giant_spider/nurse/Initialize(mapload, atom/parent)
. = ..()
next_egg_time = world.time + (rand(3, 8) MINUTES)
/mob/living/simple_animal/hostile/giant_spider/nurse/inject_poison(mob/living/L, target_zone)
..() // Inject the stoxin here.
if(ishuman(L) && prob(egg_inject_chance))
var/mob/living/carbon/human/H = L
var/obj/item/organ/external/O = H.get_organ(target_zone)
if(O)
var/eggcount = 0
for(var/obj/spider/eggcluster/small/E in O.implants)
eggcount++
if(!eggcount)
var/eggs = new egg_type(O, src)
O.implants += eggs
to_chat(H, SPAN_CLASS("critical", "\The [src] injects something into your [O.name]!")) // Oh god its laying eggs in me!
// Webs target in a web if able to.
/mob/living/simple_animal/hostile/giant_spider/nurse/attack_target(atom/A)
if(isturf(A))
if(fed)
if(!laying_eggs)
return lay_eggs(A)
return web_tile(A)
if(isliving(A))
var/mob/living/L = A
next_egg_time = world.time + rand(minimum_disturbed_time, maximum_disturbed_time)
if(!L.stat)
return ..()
if(!istype(A, /atom/movable))
return
var/atom/movable/AM = A
if(AM.anchored)
return ..()
return spin_cocoon(AM)
/mob/living/simple_animal/hostile/giant_spider/nurse/proc/spin_cocoon(atom/movable/AM)
if(!istype(AM) || istype(AM, /obj/item))
return FALSE // We can't cocoon walls sadly.
if (AM in contents)
return
visible_message(SPAN_NOTICE("\The [src] begins to secrete a sticky substance around \the [AM].") )
// Get our AI to stay still.
set_AI_busy(TRUE)
if(!do_after(src, 5 SECONDS, AM, DO_DEFAULT | DO_USER_UNIQUE_ACT | DO_PUBLIC_PROGRESS))
set_AI_busy(FALSE)
return FALSE
set_AI_busy(FALSE)
if(!AM || !isturf(AM.loc) || !Adjacent(AM))
return FALSE
// Finally done with the checks.
var/obj/spider/cocoon/C = new(AM.loc)
var/large_cocoon = FALSE
for(var/mob/living/L in C.contents)
if(istype(L, /mob/living/simple_animal/hostile/giant_spider)) // Cannibalism is bad.
continue
fed++
visible_message(SPAN_WARNING("\The [src] sticks a proboscis into \the [L], and sucks a viscous substance out."))
large_cocoon = TRUE
break
if(large_cocoon)
C.icon_state = pick("cocoon_large1","cocoon_large2","cocoon_large3")
ai_holder.target = null
return TRUE
/mob/living/simple_animal/hostile/giant_spider/nurse/handle_special()
set waitfor = FALSE
if (get_AI_stance() == STANCE_IDLE && !is_AI_busy() && isturf(loc))
if (fed || next_egg_time < world.time)
lay_eggs(loc)
else
web_tile(loc)
/mob/living/simple_animal/hostile/giant_spider/nurse/proc/web_tile(turf/T)
if(!istype(T))
return FALSE
var/obj/spider/stickyweb/W = locate() in T
if(W)
return FALSE // Already got webs here.
visible_message(SPAN_NOTICE("\The [src] begins to secrete a sticky substance."))
// Get our AI to stay still.
set_AI_busy(TRUE)
if(!do_after(src, 5 SECONDS, T, DO_DEFAULT | DO_USER_UNIQUE_ACT | DO_PUBLIC_PROGRESS))
set_AI_busy(FALSE)
return FALSE
W = locate() in T
if(W)
return FALSE // Spamclick protection.
set_AI_busy(FALSE)
new web_type(T)
return TRUE
/mob/living/simple_animal/hostile/giant_spider/nurse/proc/lay_eggs(turf/T)
if(!istype(T))
return FALSE
if (GLOB.SPIDER_COUNT >= GLOB.MAX_SPIDER_COUNT)
next_egg_time = world.time + rand(minimum_disturbed_time, maximum_disturbed_time)
return FALSE
var/obj/spider/eggcluster/E = locate() in T
if(E)
return FALSE // Already got eggs here.
visible_message(SPAN_NOTICE("\The [src] begins to lay a cluster of eggs."))
// Get our AI to stay still.
set_AI_busy(TRUE)
// Stop players from spamming eggs.
laying_eggs = TRUE
if(!do_after(src, 5 SECONDS, T, DO_DEFAULT | DO_USER_UNIQUE_ACT | DO_PUBLIC_PROGRESS))
set_AI_busy(FALSE)
return FALSE
E = locate() in T
if(E)
return FALSE // Spamclick protection.
set_AI_busy(FALSE)
new egg_type(T)
fed--
if (fed < 0)
fed = 0
next_egg_time = world.time + rand(minimum_disturbed_time, maximum_disturbed_time)
laying_eggs = FALSE
return TRUE
/mob/living/simple_animal/hostile/giant_spider/nurse/proc/divorce()
if(paired_guard)
if(paired_guard.paired_nurse)
paired_guard.paired_nurse = null
paired_guard = null
// Variant that 'blocks' light (by being a negative light source).
// This is done to make webbed rooms scary and allow for spiders on the other side of webs to see prey.
/obj/spider/stickyweb/dark
name = "dense web"
desc = "It's sticky, and blocks a lot of light."
/obj/spider/stickyweb/dark/Initialize()
. = ..()
set_light(1, -1, l_color = "#ffffff")
// The AI for nurse spiders. Wraps things in webs by 'attacking' them.
/datum/ai_holder/simple_animal/melee/nurse_spider
wander = TRUE
base_wander_delay = 8
cooperative = FALSE // So we don't ask our spider friends to attack things we're webbing. This might also make them stay at the base if their friends find tasty explorers.
returns_home = TRUE
// Get us unachored objects as an option as well.
/datum/ai_holder/simple_animal/melee/nurse_spider/list_targets()
. = ..()
var/static/alternative_targets = typecacheof(list(/obj/structure))
for(var/AT in typecache_filter_list(range(vision_range, holder), alternative_targets))
var/obj/O = AT
if(can_see(holder, O, vision_range) && !O.anchored)
. += O
// Select an obj if no mobs are around.
/datum/ai_holder/simple_animal/melee/nurse_spider/pick_target(list/targets)
var/mobs_only = locate(/mob/living) in targets // If a mob is in the list of targets, then ignore objects.
if(mobs_only)
for(var/A in targets)
if(!isliving(A))
targets -= A
return ..(targets)
/datum/ai_holder/simple_animal/melee/nurse_spider/can_attack(atom/movable/the_target, vision_required = TRUE)
. = ..()
if (!.) // Parent returned FALSE.
if (istype(the_target, /obj))
var/obj/O = the_target
if (!O.anchored)
return TRUE