-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathspiderbot.dm
272 lines (240 loc) · 8.76 KB
/
spiderbot.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
271
272
/mob/living/simple_animal/spiderbot
name = "Spider bot"
desc = "Unlike drones, spiderbots are actually smart and make good friends!"
icon = 'icons/mob/robots.dmi'
icon_state = "spiderbot-chassis"
icon_living = "spiderbot-chassis"
icon_dead = "spiderbot-smashed"
initial_language_holder = /datum/language_holder/spiderbot
atmos_requirements = list("min_oxy" = 0, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 1, "min_co2" = 0, "max_co2" = 0, "min_n2" = 0, "max_n2" = 0)
minbodytemp = 0
maxbodytemp = 500
wander = FALSE
health = 10
maxHealth = 10
attacktext = "shocks"
melee_damage_type = BURN
melee_damage_lower = 2
melee_damage_upper = 2
response_help = "pets"
response_disarm = "shoos"
response_harm = "stomps on"
density = FALSE
speed = -1 //Spiderbots gotta go fast.
pass_flags = PASSTABLE | PASSGRILLE | PASSMOB
ventcrawler = VENTCRAWLER_ALWAYS
mob_size = MOB_SIZE_TINY
speak_emote = list("beeps","clicks","chirps")
var/obj/item/radio/borg/radio = null
var/obj/machinery/camera/camera = null
var/obj/item/mmi/mmi = null
var/req_access = ACCESS_ROBO_CONTROL //Access needed to pop out the brain.
var/emagged = FALSE
var/obj/item/held_item = null //Storage for single item they can hold.
/mob/living/simple_animal/spiderbot/attackby(obj/item/O, mob/user)
if(istype(O, /obj/item/mmi))
var/obj/item/mmi/M = O
if(mmi) //There's already a brain in it.
to_chat(user, span_warning("There's already a brain in [src]!"))
return
if(!M.brainmob)
to_chat(user, span_warning("Sticking an empty MMI into the frame would sort of defeat the purpose."))
return
var/mob/living/brain/BM = M.brainmob
if(!BM.key || !BM.mind)
to_chat(user, span_warning("The MMI indicates that their mind is completely unresponsive; there's no point!"))
return
if(!BM.client) //braindead
to_chat(user, span_warning("The MMI indicates that their mind is currently inactive; it might change!"))
return
if(BM.stat == DEAD || BM.suiciding || (M.brain && (M.brain.brain_death || M.brain.suicided)))
to_chat(user, span_warning("Sticking a dead brain into the frame would sort of defeat the purpose!"))
return
if(is_banned_from(BM.ckey, "Cyborg") || QDELETED(src) || QDELETED(BM) || QDELETED(user) || QDELETED(M) || !Adjacent(user))
if(!QDELETED(M))
to_chat(user, span_warning("This [M.name] does not seem to fit!"))
return
if(!user.temporarilyRemoveItemFromInventory(M))
return
to_chat(user, span_notice("You install [M] in [src]!"))
mmi = M
transfer_personality(M)
update_appearance(UPDATE_ICON)
return 1
else if(O.tool_behaviour == TOOL_WELDER && (!user.combat_mode || user == src)) ///Removed needless self repair part
user.changeNext_move(CLICK_CD_MELEE)
if (!getBruteLoss())
to_chat(user, span_warning("[src] is already in good condition!"))
return
if (!O.tool_start_check(user, amount=0))
return
adjustBruteLoss(-10)
updatehealth()
add_fingerprint(user)
visible_message(span_notice("[user] has fixed some of the dents on [src]."))
return
else if(istype(O, /obj/item/card/id) || istype(O, /obj/item/modular_computer))
if (!mmi)
to_chat(user, span_warning("There's no reason to swipe your ID - the spiderbot has no brain to remove."))
return 0
var/obj/item/card/id/id_card
if(istype(O, /obj/item/card/id))
id_card = O
else
var/obj/item/modular_computer/pda = O
id_card = pda.GetID()
if(req_access in id_card.GetAccess())
to_chat(user, span_notice("You swipe your access card and pop the brain out of [src]."))
eject_brain()
if(held_item)
held_item.loc = src.loc
held_item = null
return 1
else
to_chat(user, span_warning("You swipe your card, with no effect."))
return 0
return ..()
/mob/living/simple_animal/spiderbot/proc/transfer_personality(obj/item/mmi/M)
M.brainmob.mind.transfer_to(src)
M.forceMove(src)
job = "Spider Bot"
/mob/living/simple_animal/spiderbot/emag_act(mob/user, obj/item/card/emag/emag_card)
if(emagged)
to_chat(user, span_warning("[src] is already overloaded - better run."))
return FALSE
emagged = 1
to_chat(user, span_notice("You short out the security protocols and overload [src]'s cell, priming it to explode in a short time."))
addtimer(CALLBACK(src, PROC_REF(finish_emag_act), 1), 10 SECONDS)
return TRUE
/mob/living/simple_animal/spiderbot/proc/finish_emag_act(progress)
if(QDELETED(src))
return
if(progress)
switch(progress)
if(1)
to_chat(src, span_warning("Your cell seems to be outputting a lot of power..."))
addtimer(CALLBACK(src, PROC_REF(finish_emag_act), 2), 10 SECONDS)
if(2)
to_chat(src, span_warning("Internal heat sensors are spiking! Something is badly wrong with your cell!"))
addtimer(CALLBACK(src, PROC_REF(finish_emag_act), 3), 10 SECONDS)
if(3)
explode()
/mob/living/simple_animal/spiderbot/proc/explode() //When emagged.
visible_message(span_warning("[src] makes an odd warbling noise, fizzles, and explodes."))
explosion(get_turf(src), -1, 0, 2, 3, 0, flame_range = 2) ///Explodes like a fireball
if(!QDELETED(src) && stat != DEAD)
death()
/mob/living/simple_animal/spiderbot/update_icon_state()
. = ..()
if(mmi)
if(istype(mmi, /obj/item/mmi/posibrain))
icon_state = "spiderbot-chassis-posi"
icon_living = "spiderbot-chassis-posi"
else
icon_state = "spiderbot-chassis-mmi"
icon_living = "spiderbot-chassis-mmi"
return
icon_state = "spiderbot-chassis"
icon_living = "spiderbot-chassis"
/mob/living/simple_animal/spiderbot/proc/eject_brain()
if(mmi)
if(mind)
mind.transfer_to(mmi.brainmob)
else if(key)
mmi.brainmob.key = key
mmi.forceMove(loc)
mmi.update_appearance(UPDATE_ICON)
mmi = null
name = initial(name)
update_appearance(UPDATE_ICON)
/mob/living/simple_animal/spiderbot/gib(no_brain, no_organs, no_bodyparts, no_items)
eject_brain()
new /obj/effect/decal/remains/robot(loc)
qdel(src)
/mob/living/simple_animal/spiderbot/Destroy()
eject_brain()
return ..()
/mob/living/simple_animal/spiderbot/Initialize(mapload)
. = ..()
radio = new /obj/item/radio/borg(src)
camera = new /obj/machinery/camera(src)
camera.c_tag = name
add_verb(src, list(/mob/living/simple_animal/spiderbot/proc/hide, \
/mob/living/simple_animal/spiderbot/proc/drop_held_item, \
/mob/living/simple_animal/spiderbot/proc/get_item))
RegisterSignal(src, COMSIG_GLOB_MOB_DEATH, PROC_REF(on_death))
/mob/living/simple_animal/spiderbot/proc/on_death()
UnregisterSignal(src, COMSIG_GLOB_MOB_DEATH)
gib()
/mob/living/simple_animal/spiderbot/Destroy()
if(radio)
qdel(radio)
radio = null
if(camera)
qdel(camera)
camera = null
if(held_item)
held_item.forceMove(loc)
held_item = null
if(mmi)
mmi.forceMove(loc)
mmi = null
UnregisterSignal(src, COMSIG_GLOB_MOB_DEATH)
. = ..()
/mob/living/simple_animal/spiderbot/proc/hide()
set name = "Hide"
set desc = "Allows to hide beneath tables or certain items. Toggled on or off."
set category = "Spiderbot"
if(stat != CONSCIOUS)
return
if (layer != ABOVE_NORMAL_TURF_LAYER)
layer = ABOVE_NORMAL_TURF_LAYER
to_chat(src, span_notice("You are now hiding."))
else
layer = MOB_LAYER
to_chat(src, span_notice("You have stopped hiding."))
/mob/living/simple_animal/spiderbot/proc/drop_held_item()
set name = "Drop held item"
set category = "Spiderbot"
set desc = "Drop the item you're holding."
if(stat != CONSCIOUS)
return
if(!held_item)
to_chat(usr, span_warning(">You have nothing to drop!"))
return 0
visible_message(span_notice("[src] drops \the [held_item]!"), span_notice("You drop \the [held_item]!"), span_hear("You hear a skittering noise and a soft thump."))
held_item.forceMove(loc)
held_item = null
return
/mob/living/simple_animal/spiderbot/proc/get_item()
set name = "Pick up item"
set category = "Spiderbot"
set desc = "Allows you to take a nearby small item."
if(stat != CONSCIOUS)
return
if(held_item)
to_chat(src, span_warning("You are already holding \the [held_item]"))
return
var/list/items = list()
for(var/obj/item/I in view(1,src))
//Make sure we're not already holding it and it's small enough
if(I.loc != src && I.w_class <= WEIGHT_CLASS_SMALL)
items |= I
var/obj/selection = input("Select an item.", "Pickup") in items
if(selection)
for(var/obj/item/I in view(1, src))
if(selection == I)
held_item = selection
selection.loc = src
visible_message(span_notice("[src] scoops up \the [held_item]!"), span_notice("You grab \the [held_item]!"), span_hear("You hear a skittering noise and a clink."))
return held_item
to_chat(src, span_warning("\The [selection] is too far away."))
return 0
to_chat(src, span_warning("There is nothing of interest to take."))
return 0
/mob/living/simple_animal/spiderbot/examine(mob/user)
. = ..()
if(health < maxHealth)
. += "This [src] looks a bit dented"
if(src.held_item)
to_chat(user, "It is carrying \a [src.held_item] [icon2html(src.held_item, src)].")