-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
giant_spider.dm
270 lines (241 loc) · 8.53 KB
/
giant_spider.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#define SPINNING_WEB 1
#define LAYING_EGGS 2
#define MOVING_TO_TARGET 3
#define SPINNING_COCOON 4
/mob/living/simple_animal/hostile/poison
var/poison_per_bite = 5
var/poison_type = "spidertoxin"
/mob/living/simple_animal/hostile/poison/AttackingTarget()
..()
if(isliving(target))
var/mob/living/L = target
if(L.reagents)
L.reagents.add_reagent("spidertoxin", poison_per_bite)
if(prob(poison_per_bite))
L << "<span class='danger'>You feel a tiny prick.</span>"
L.reagents.add_reagent(poison_type, poison_per_bite)
//basic spider mob, these generally guard nests
/mob/living/simple_animal/hostile/poison/giant_spider
name = "giant spider"
desc = "Furry and black, it makes you shudder to look at it. This one has deep red eyes."
icon_state = "guard"
var/butcher_state = 8 // Icon state for dead spider icons
icon_living = "guard"
icon_dead = "guard_dead"
speak_emote = list("chitters")
emote_hear = list("chitters")
speak_chance = 5
turns_per_move = 5
see_in_dark = 10
meat_type = /obj/item/weapon/reagent_containers/food/snacks/spidermeat
meat_amount = 2
response_help = "pets"
response_disarm = "gently pushes aside"
response_harm = "hits"
maxHealth = 200
health = 200
melee_damage_lower = 15
melee_damage_upper = 20
heat_damage_per_tick = 20 //amount of damage applied if animal's body temperature is higher than maxbodytemp
cold_damage_per_tick = 20 //same as heat_damage_per_tick, only if the bodytemperature it's lower than minbodytemp
faction = list("spiders")
var/busy = 0
pass_flags = PASSTABLE
move_to_delay = 6
attacktext = "bites"
attack_sound = 'sound/weapons/bite.ogg'
//nursemaids - these create webs and eggs
/mob/living/simple_animal/hostile/poison/giant_spider/nurse
desc = "Furry and black, it makes you shudder to look at it. This one has brilliant green eyes."
icon_state = "nurse"
icon_living = "nurse"
icon_dead = "nurse_dead"
meat_type = /obj/item/weapon/reagent_containers/food/snacks/spidereggs
meat_amount = 4
maxHealth = 40
health = 40
melee_damage_lower = 5
melee_damage_upper = 10
poison_per_bite = 10
var/atom/cocoon_target
poison_type = "ether"
var/fed = 0
//hunters have the most poison and move the fastest, so they can find prey
/mob/living/simple_animal/hostile/poison/giant_spider/hunter
desc = "Furry and black, it makes you shudder to look at it. This one has sparkling purple eyes."
icon_state = "hunter"
icon_living = "hunter"
icon_dead = "hunter_dead"
maxHealth = 120
health = 120
melee_damage_lower = 10
melee_damage_upper = 20
poison_per_bite = 5
move_to_delay = 5
/mob/living/simple_animal/hostile/poison/giant_spider/hunter/handle_automated_action()
if(!stat)
if(stance == HOSTILE_STANCE_IDLE)
//1% chance to skitter madly away
if(!busy && prob(1))
/*var/list/move_targets = list()
for(var/turf/T in orange(20, src))
move_targets.Add(T)*/
stop_automated_movement = 1
Goto(pick(orange(20, src)), move_to_delay)
spawn(50)
stop_automated_movement = 0
walk(src,0)
// Chops off each leg with a 50/50 chance of harvesting one, until finally calling
// default harvest action
/mob/living/simple_animal/hostile/poison/giant_spider/harvest()
if(butcher_state > 0)
butcher_state--
icon_state = icon_dead + "[butcher_state]"
if(prob(50))
new /obj/item/weapon/reagent_containers/food/snacks/spiderleg(src.loc)
return
else
return ..()
/mob/living/simple_animal/hostile/poison/giant_spider/nurse/proc/GiveUp(var/C)
spawn(100)
if(busy == MOVING_TO_TARGET)
if(cocoon_target == C && get_dist(src,cocoon_target) > 1)
cocoon_target = null
busy = 0
stop_automated_movement = 0
/mob/living/simple_animal/hostile/poison/giant_spider/nurse/handle_automated_action()
if(!stat && !ckey)
if(stance == HOSTILE_STANCE_IDLE)
var/list/can_see = view(src, 10)
//30% chance to stop wandering and do something
if(!busy && prob(30))
//first, check for potential food nearby to cocoon
for(var/mob/living/C in can_see)
if(C.stat && !istype(C,/mob/living/simple_animal/hostile/poison/giant_spider))
cocoon_target = C
busy = MOVING_TO_TARGET
Goto(C, move_to_delay)
//give up if we can't reach them after 10 seconds
GiveUp(C)
return
//second, spin a sticky spiderweb on this tile
var/obj/effect/spider/stickyweb/W = locate() in get_turf(src)
if(!W)
Web()
else
//third, lay an egg cluster there
if(fed)
LayEggs()
else
//fourthly, cocoon any nearby items so those pesky pinkskins can't use them
for(var/obj/O in can_see)
if(O.anchored)
continue
if(istype(O, /obj/item) || istype(O, /obj/structure) || istype(O, /obj/machinery))
cocoon_target = O
busy = MOVING_TO_TARGET
stop_automated_movement = 1
Goto(O, move_to_delay)
//give up if we can't reach them after 10 seconds
GiveUp(O)
else if(busy == MOVING_TO_TARGET && cocoon_target)
if(get_dist(src, cocoon_target) <= 1)
Wrap()
else
busy = 0
stop_automated_movement = 0
/mob/living/simple_animal/hostile/poison/giant_spider/verb/Web()
set name = "Lay Web"
set category = "Spider"
set desc = "Spread a sticky web to slow down prey."
var/T = src.loc
if(busy != SPINNING_WEB)
busy = SPINNING_WEB
src.visible_message("<span class='notice'>\the [src] begins to secrete a sticky substance.</span>")
stop_automated_movement = 1
spawn(40)
if(busy == SPINNING_WEB && src.loc == T)
new /obj/effect/spider/stickyweb(T)
busy = 0
stop_automated_movement = 0
/mob/living/simple_animal/hostile/poison/giant_spider/nurse/verb/Wrap()
set name = "Wrap"
set category = "Spider"
set desc = "Wrap up prey to feast upon and objects for safe keeping."
if(!cocoon_target)
var/list/choices = list()
for(var/mob/living/L in view(1,src))
if(L == src)
continue
if(Adjacent(L))
choices += L
for(var/obj/O in src.loc)
if(Adjacent(O))
choices += O
cocoon_target = input(src,"What do you wish to cocoon?") in null|choices
if(cocoon_target && busy != SPINNING_COCOON)
busy = SPINNING_COCOON
src.visible_message("<span class='notice'>\the [src] begins to secrete a sticky substance around \the [cocoon_target].</span>")
stop_automated_movement = 1
walk(src,0)
spawn(50)
if(busy == SPINNING_COCOON)
if(cocoon_target && istype(cocoon_target.loc, /turf) && get_dist(src,cocoon_target) <= 1)
var/obj/effect/spider/cocoon/C = new(cocoon_target.loc)
var/large_cocoon = 0
C.pixel_x = cocoon_target.pixel_x
C.pixel_y = cocoon_target.pixel_y
for(var/obj/item/I in C.loc)
I.loc = C
for(var/obj/structure/S in C.loc)
if(!S.anchored)
S.loc = C
large_cocoon = 1
for(var/obj/machinery/M in C.loc)
if(!M.anchored)
M.loc = C
large_cocoon = 1
for(var/mob/living/L in C.loc)
if(istype(L, /mob/living/simple_animal/hostile/poison/giant_spider))
continue
large_cocoon = 1
L.loc = C
C.pixel_x = L.pixel_x
C.pixel_y = L.pixel_y
fed++
visible_message("<span class='danger'>\the [src] sticks a proboscis into \the [L] and sucks a viscous substance out.</span>")
break
if(large_cocoon)
C.icon_state = pick("cocoon_large1","cocoon_large2","cocoon_large3")
cocoon_target = null
busy = 0
stop_automated_movement = 0
/mob/living/simple_animal/hostile/poison/giant_spider/nurse/verb/LayEggs()
set name = "Lay Eggs"
set category = "Spider"
set desc = "Lay a clutch of eggs, but you must wrap a creature for feeding first."
var/obj/effect/spider/eggcluster/E = locate() in get_turf(src)
if(E)
src << "<span class='notice'>There is already a cluster of eggs here!</span>"
else if(!fed)
src << "<span class='warning'>You are too hungry to do this!</span>"
else if(busy != LAYING_EGGS)
busy = LAYING_EGGS
src.visible_message("<span class='notice'>\the [src] begins to lay a cluster of eggs.</span>")
stop_automated_movement = 1
spawn(50)
if(busy == LAYING_EGGS)
E = locate() in get_turf(src)
if(!E)
var/obj/effect/spider/eggcluster/C = new /obj/effect/spider/eggcluster(src.loc)
C.faction = faction
C.master_commander = master_commander
if(ckey)
C.player_spiders = 1
fed--
busy = 0
stop_automated_movement = 0
#undef SPINNING_WEB
#undef LAYING_EGGS
#undef MOVING_TO_TARGET
#undef SPINNING_COCOON