-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathmecha_actions.dm
290 lines (246 loc) · 10 KB
/
mecha_actions.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
//////////////////////////////////////// Action Buttons ///////////////////////////////////////////////
/obj/mecha/proc/GrantActions(mob/living/user, human_occupant = 0)
if(human_occupant)
eject_action.Grant(user, src)
if(enclosed)
internals_action.Grant(user, src)
cycle_action.Grant(user, src)
lights_action.Grant(user, src)
stats_action.Grant(user, src)
strafing_action.Grant(user, src)
for(var/obj/item/mecha_parts/mecha_equipment/E as anything in equipment)
E.grant_actions(user)
/obj/mecha/proc/RemoveActions(mob/living/user, human_occupant = 0)
if(human_occupant)
eject_action.Remove(user)
internals_action.Remove(user)
cycle_action.Remove(user)
lights_action.Remove(user)
stats_action.Remove(user)
strafing_action.Remove(user)
for(var/obj/item/mecha_parts/mecha_equipment/E as anything in equipment)
E.remove_actions(user)
/datum/action/innate/mecha
check_flags = AB_CHECK_HANDS_BLOCKED | AB_CHECK_IMMOBILE | AB_CHECK_CONSCIOUS
button_icon = 'icons/mob/actions/actions_mecha.dmi'
var/obj/mecha/chassis
/datum/action/innate/mecha/Grant(mob/living/L, obj/mecha/M)
if(M)
chassis = M
..()
/datum/action/innate/mecha/Destroy()
chassis = null
return ..()
/datum/action/innate/mecha/mech_eject
name = "Eject From Mech"
button_icon_state = "mech_eject"
/datum/action/innate/mecha/mech_eject/Activate()
if(!owner)
return
if(!chassis || chassis.occupant != owner)
return
chassis.container_resist(chassis.occupant)
/datum/action/innate/mecha/mech_toggle_internals
name = "Toggle Internal Airtank Usage"
button_icon_state = "mech_internals_off"
/datum/action/innate/mecha/mech_toggle_internals/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
chassis.use_internal_tank = !chassis.use_internal_tank
button_icon_state = "mech_internals_[chassis.use_internal_tank ? "on" : "off"]"
chassis.occupant_message("Now taking air from [chassis.use_internal_tank?"internal airtank":"environment"].")
chassis.log_message("Now taking air from [chassis.use_internal_tank?"internal airtank":"environment"].", LOG_MECHA)
build_all_button_icons()
/datum/action/innate/mecha/mech_cycle_equip
name = "Cycle Equipment. Can also be cycled with throwmode."
button_icon_state = "mech_cycle_equip_off"
/datum/action/innate/mecha/mech_cycle_equip/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
var/list/available_equipment = list()
for(var/obj/item/mecha_parts/mecha_equipment/M in chassis.equipment)
if(M.selectable)
available_equipment += M
if(available_equipment.len == 0)
chassis.occupant_message("No equipment available.")
return
if(!chassis.selected)
chassis.selected = available_equipment[1]
chassis.selected.on_select()
chassis.occupant_message("You select [chassis.selected]")
send_byjax(chassis.occupant,"exosuit.browser","eq_list",chassis.get_equipment_list())
button_icon_state = "mech_cycle_equip_on"
build_all_button_icons()
return
var/number = 0
for(var/A in available_equipment)
number++
if(A == chassis.selected) //Swapping to no equipment from something
if(available_equipment.len == number)
chassis.selected.on_deselect()
chassis.selected = null
chassis.occupant_message("You switch to no equipment")
button_icon_state = "mech_cycle_equip_off"
else
if(chassis.selected) //If we're swapping off of an equipment, remove effects
chassis.selected.on_deselect()
chassis.selected = available_equipment[number+1]
chassis.selected.on_select()
chassis.occupant_message("You switch to [chassis.selected]")
button_icon_state = "mech_cycle_equip_on"
send_byjax(chassis.occupant,"exosuit.browser","eq_list",chassis.get_equipment_list())
build_all_button_icons()
return
/datum/action/innate/mecha/mech_toggle_lights
name = "Toggle Lights"
button_icon_state = "mech_lights_off"
/datum/action/innate/mecha/mech_toggle_lights/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
chassis.lights = !chassis.lights
if(chassis.lights)
button_icon_state = "mech_lights_on"
else
button_icon_state = "mech_lights_off"
chassis.set_light_on(chassis.lights)
chassis.occupant_message("Toggled lights [chassis.lights?"on":"off"].")
chassis.log_message("Toggled lights [chassis.lights?"on":"off"].", LOG_MECHA)
build_all_button_icons()
/datum/action/innate/mecha/mech_view_stats
name = "View Stats"
button_icon_state = "mech_view_stats"
/datum/action/innate/mecha/mech_view_stats/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
chassis.occupant << browse(chassis.get_stats_html(), "window=exosuit")
/datum/action/innate/mecha/strafe
name = "Toggle Strafing. Disabled when Alt is held."
button_icon_state = "strafe_off"
/datum/action/innate/mecha/strafe/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
chassis.toggle_strafe()
/obj/mecha/AltClick(mob/living/user)
if((user == occupant) && user.canUseTopic(src))
toggle_strafe()
/obj/mecha/proc/toggle_strafe()
strafe = !strafe
occupant_message("Toggled strafing mode [strafe?"on":"off"].")
log_message("Toggled strafing mode [strafe?"on":"off"].", LOG_MECHA)
strafing_action.button_icon_state = "strafe_[strafe?"on":"off"]"
strafing_action.build_all_button_icons()
//////////////////////////////////////// Specific Ability Actions ///////////////////////////////////////////////
//Need to be granted by the mech type, Not default abilities.
/datum/action/innate/mecha/mech_defence_mode
name = "Toggle Defense Mode"
button_icon_state = "mech_defense_mode_off"
/datum/action/innate/mecha/mech_defence_mode/Activate(forced_state = null)
if(!owner || !chassis || chassis.occupant != owner)
return
if(!isnull(forced_state))
chassis.defence_mode = forced_state
else
chassis.defence_mode = !chassis.defence_mode
button_icon_state = "mech_defense_mode_[chassis.defence_mode ? "on" : "off"]"
if(chassis.defence_mode)
chassis.deflect_chance += chassis.defence_mode_deflect_chance
chassis.occupant_message(span_notice("You enable [chassis] defense mode."))
else
chassis.deflect_chance -= chassis.defence_mode_deflect_chance
chassis.occupant_message(span_danger("You disable [chassis] defense mode."))
chassis.log_message("Toggled defense mode.", LOG_MECHA)
build_all_button_icons()
/datum/action/innate/mecha/mech_overload_mode
name = "Toggle leg actuators overload"
button_icon_state = "mech_overload_off"
/datum/action/innate/mecha/mech_overload_mode/Activate(forced_state = null)
if(chassis?.equipment_disabled) // If a EMP or something has messed a mech up return instead of activating -- Moogle
return
if(!owner || !chassis || chassis.occupant != owner)
return
if(!isnull(forced_state))
chassis.leg_overload_mode = forced_state
else
chassis.leg_overload_mode = !chassis.leg_overload_mode
button_icon_state = "mech_overload_[chassis.leg_overload_mode ? "on" : "off"]"
chassis.log_message("Toggled leg actuators overload.", LOG_MECHA)
if(chassis.leg_overload_mode)
chassis.leg_overload_mode = 1
chassis.bumpsmash = 1
chassis.occupant_message(span_danger("You enable leg actuators overload."))
else
chassis.leg_overload_mode = 0
chassis.bumpsmash = initial(chassis.bumpsmash)
chassis.occupant_message(span_notice("You disable leg actuators overload."))
build_all_button_icons()
/datum/action/innate/mecha/mech_smoke
name = "Smoke"
button_icon_state = "mech_smoke"
/datum/action/innate/mecha/mech_smoke/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
if(chassis.smoke_ready && chassis.smoke>0)
chassis.smoke_system.start()
chassis.smoke--
chassis.smoke_ready = 0
spawn(chassis.smoke_cooldown)
chassis.smoke_ready = 1
/datum/action/innate/mecha/mech_zoom
name = "Zoom"
button_icon_state = "mech_zoom_off"
/datum/action/innate/mecha/mech_zoom/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
if(owner.client)
chassis.zoom_mode = !chassis.zoom_mode
button_icon_state = "mech_zoom_[chassis.zoom_mode ? "on" : "off"]"
chassis.log_message("Toggled zoom mode.", LOG_MECHA)
chassis.occupant_message("<font color='[chassis.zoom_mode?"blue":"red"]'>Zoom mode [chassis.zoom_mode?"en":"dis"]abled.</font>")
if(chassis.zoom_mode)
owner.client.view_size.setTo(4.5)
SEND_SOUND(owner, sound('sound/mecha/imag_enh.ogg',volume=50))
else
owner.client.view_size.resetToDefault() //Let's not let this stack shall we?
build_all_button_icons()
/datum/action/innate/mecha/mech_switch_damtype
name = "Reconfigure arm microtool arrays"
button_icon_state = "mech_damtype_brute"
/datum/action/innate/mecha/mech_switch_damtype/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
var/new_damtype
switch(chassis.damtype)
if(TOX)
new_damtype = BRUTE
chassis.occupant_message("Your exosuit's hands form into fists.")
if(BRUTE)
new_damtype = BURN
chassis.occupant_message("A torch tip extends from your exosuit's hand, glowing red.")
if(BURN)
new_damtype = TOX
chassis.occupant_message("A bone-chillingly thick plasteel needle protracts from the exosuit's palm.")
chassis.damtype = new_damtype
button_icon_state = "mech_damtype_[new_damtype]"
playsound(src, 'sound/mecha/mechmove01.ogg', 50, 1)
build_all_button_icons()
/datum/action/innate/mecha/mech_toggle_phasing
name = "Toggle Phasing"
button_icon_state = "mech_phasing_off"
/datum/action/innate/mecha/mech_toggle_phasing/Activate()
if(!owner || !chassis || chassis.occupant != owner)
return
chassis.phasing = !chassis.phasing
button_icon_state = "mech_phasing_[chassis.phasing ? "on" : "off"]"
chassis.occupant_message("<font color=\"[chassis.phasing?"#00f\">En":"#f00\">Dis"]abled phasing.</font>")
build_all_button_icons()
//////////////////////////////////////// Equipment Actions ///////////////////////////////////////////////
//Equipment-based actions like RCD mode selection
/datum/action/innate/mecha/equipment
var/obj/item/mecha_parts/mecha_equipment/equipment
/datum/action/innate/mecha/equipment/Grant(mob/living/L, obj/mecha/M, obj/item/mecha_parts/mecha_equipment/E)
if(E)
equipment = E
return ..()
/datum/action/innate/mecha/equipment/Destroy()
equipment = null
return ..()