forked from ParadiseSS13/Paradise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.dm
605 lines (483 loc) · 15.3 KB
/
action.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#define AB_CHECK_RESTRAINED 1
#define AB_CHECK_STUNNED 2
#define AB_CHECK_LYING 4
#define AB_CHECK_CONSCIOUS 8
#define AB_CHECK_TURF 16
/datum/action
var/name = "Generic Action"
var/desc = null
var/obj/target = null
var/check_flags = 0
var/obj/screen/movable/action_button/button = null
var/button_icon = 'icons/mob/actions/actions.dmi'
var/background_icon_state = "bg_default"
var/buttontooltipstyle = ""
var/icon_icon = 'icons/mob/actions/actions.dmi'
var/button_icon_state = "default"
var/mob/owner
/datum/action/New(Target)
target = Target
button = new
button.linked_action = src
button.name = name
button.actiontooltipstyle = buttontooltipstyle
if(desc)
button.desc = desc
/datum/action/Destroy()
if(owner)
Remove(owner)
if(target)
target = null
QDEL_NULL(button)
return ..()
/datum/action/proc/Grant(mob/M)
if(owner)
if(owner == M)
return
Remove(owner)
owner = M
M.actions += src
if(M.client)
M.client.screen += button
button.locked = TRUE
M.update_action_buttons()
/datum/action/proc/Remove(mob/M)
owner = null
if(!M)
return
if(M.client)
M.client.screen -= button
button.moved = FALSE //so the button appears in its normal position when given to another owner.
button.locked = FALSE
M.actions -= src
M.update_action_buttons()
/datum/action/proc/Trigger()
if(!IsAvailable())
return FALSE
return TRUE
/datum/action/proc/Process()
return
/datum/action/proc/override_location() // Override to set coordinates manually
return
/datum/action/proc/IsAvailable()// returns 1 if all checks pass
if(!owner)
return FALSE
if(check_flags & AB_CHECK_RESTRAINED)
if(owner.restrained())
return FALSE
if(check_flags & AB_CHECK_STUNNED)
if(owner.stunned || owner.IsWeakened())
return FALSE
if(check_flags & AB_CHECK_LYING)
if(owner.lying)
return FALSE
if(check_flags & AB_CHECK_CONSCIOUS)
if(owner.stat)
return FALSE
if(check_flags & AB_CHECK_TURF)
if(!isturf(owner.loc))
return FALSE
return TRUE
/datum/action/proc/UpdateButtonIcon()
if(button)
if(owner && owner.client && background_icon_state == "bg_default") // If it's a default action background, apply the custom HUD style
button.alpha = owner.client.prefs.UI_style_alpha
button.color = owner.client.prefs.UI_style_color
button.icon = ui_style2icon(owner.client.prefs.UI_style)
button.icon_state = "template"
else
button.icon = button_icon
button.icon_state = background_icon_state
button.desc = desc
ApplyIcon(button)
// If the action isn't available, darken the button
if(!IsAvailable())
apply_unavailable_effect()
else
return TRUE
/datum/action/proc/apply_unavailable_effect()
var/image/img = image('icons/mob/screen_white.dmi', icon_state = "template")
img.alpha = 200
img.appearance_flags = RESET_COLOR | RESET_ALPHA
img.color = "#000000"
img.plane = FLOAT_PLANE + 1
button.add_overlay(img)
/datum/action/proc/ApplyIcon(obj/screen/movable/action_button/current_button)
current_button.cut_overlays()
if(icon_icon && button_icon_state)
var/image/img = image(icon_icon, current_button, button_icon_state)
img.appearance_flags = RESET_COLOR | RESET_ALPHA
img.pixel_x = 0
img.pixel_y = 0
current_button.add_overlay(img)
//Presets for item actions
/datum/action/item_action
check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_CONSCIOUS
var/use_itemicon = TRUE
/datum/action/item_action/New(Target, custom_icon, custom_icon_state)
..()
var/obj/item/I = target
I.actions += src
if(custom_icon && custom_icon_state)
use_itemicon = FALSE
icon_icon = custom_icon
button_icon_state = custom_icon_state
/datum/action/item_action/Destroy()
var/obj/item/I = target
I.actions -= src
return ..()
/datum/action/item_action/Trigger(attack_self = TRUE) //Maybe we don't want to click the thing itself
if(!..())
return FALSE
if(target && attack_self)
var/obj/item/I = target
I.ui_action_click(owner, type)
return TRUE
/datum/action/item_action/ApplyIcon(obj/screen/movable/action_button/current_button)
if(use_itemicon)
if(target)
var/obj/item/I = target
var/old_layer = I.layer
var/old_plane = I.plane
var/old_appearance_flags = I.appearance_flags
I.layer = FLOAT_LAYER //AAAH
I.plane = FLOAT_PLANE //^ what that guy said
I.appearance_flags |= RESET_COLOR | RESET_ALPHA
current_button.cut_overlays()
current_button.add_overlay(I)
I.layer = old_layer
I.plane = old_plane
I.appearance_flags = old_appearance_flags
else
..()
/datum/action/item_action/toggle_light
name = "Toggle Light"
/datum/action/item_action/toggle_hood
name = "Toggle Hood"
/datum/action/item_action/toggle_firemode
name = "Toggle Firemode"
/datum/action/item_action/startchainsaw
name = "Pull The Starting Cord"
/datum/action/item_action/print_report
name = "Print Report"
/datum/action/item_action/print_forensic_report
name = "Print Report"
button_icon_state = "scanner_print"
use_itemicon = FALSE
/datum/action/item_action/clear_records
name = "Clear Scanner Records"
/datum/action/item_action/toggle_gunlight
name = "Toggle Gunlight"
/datum/action/item_action/toggle_mode
name = "Toggle Mode"
/datum/action/item_action/toggle_barrier_spread
name = "Toggle Barrier Spread"
/datum/action/item_action/equip_unequip_TED_Gun
name = "Equip/Unequip TED Gun"
/datum/action/item_action/toggle_paddles
name = "Toggle Paddles"
/datum/action/item_action/set_internals
name = "Set Internals"
/datum/action/item_action/set_internals/UpdateButtonIcon()
if(..()) //button available
if(iscarbon(owner))
var/mob/living/carbon/C = owner
if(target == C.internal)
button.icon = 'icons/mob/actions/actions.dmi'
button.icon_state = "bg_default_on"
/datum/action/item_action/toggle_mister
name = "Toggle Mister"
/datum/action/item_action/toggle_helmet_light
name = "Toggle Helmet Light"
/datum/action/item_action/toggle_welding_screen/plasmaman
name = "Toggle Welding Screen"
/datum/action/item_action/toggle_welding_screen/plasmaman/Trigger()
var/obj/item/clothing/head/helmet/space/plasmaman/H = target
if(istype(H))
H.toggle_welding_screen(owner)
/datum/action/item_action/toggle_helmet_mode
name = "Toggle Helmet Mode"
/datum/action/item_action/toggle_hardsuit_mode
name = "Toggle Hardsuit Mode"
/datum/action/item_action/toggle_unfriendly_fire
name = "Toggle Friendly Fire \[ON\]"
desc = "Toggles if the club's blasts cause friendly fire."
button_icon_state = "vortex_ff_on"
/datum/action/item_action/toggle_unfriendly_fire/Trigger()
if(..())
UpdateButtonIcon()
/datum/action/item_action/toggle_unfriendly_fire/UpdateButtonIcon()
if(istype(target, /obj/item/hierophant_club))
var/obj/item/hierophant_club/H = target
if(H.friendly_fire_check)
button_icon_state = "vortex_ff_off"
name = "Toggle Friendly Fire \[OFF\]"
button.name = name
else
button_icon_state = "vortex_ff_on"
name = "Toggle Friendly Fire \[ON\]"
button.name = name
..()
/datum/action/item_action/vortex_recall
name = "Vortex Recall"
desc = "Recall yourself, and anyone nearby, to an attuned hierophant beacon at any time.<br>If the beacon is still attached, will detach it."
button_icon_state = "vortex_recall"
/datum/action/item_action/vortex_recall/IsAvailable()
if(istype(target, /obj/item/hierophant_club))
var/obj/item/hierophant_club/H = target
if(H.teleporting)
return FALSE
return ..()
/datum/action/item_action/change_headphones_song
name = "Change Headphones Song"
/datum/action/item_action/toggle
/datum/action/item_action/toggle/New(Target)
..()
name = "Toggle [target.name]"
button.name = name
/datum/action/item_action/openclose
/datum/action/item_action/openclose/New(Target)
..()
name = "Open/Close [target.name]"
button.name = name
/datum/action/item_action/button
/datum/action/item_action/button/New(Target)
..()
name = "Button/Unbutton [target.name]"
button.name = name
/datum/action/item_action/zipper
/datum/action/item_action/zipper/New(Target)
..()
name = "Zip/Unzip [target.name]"
button.name = name
/datum/action/item_action/halt
name = "HALT!"
/datum/action/item_action/selectphrase
name = "Change Phrase"
/datum/action/item_action/hoot
name = "Hoot"
/datum/action/item_action/caw
name = "Caw"
/datum/action/item_action/toggle_voice_box
name = "Toggle Voice Box"
/datum/action/item_action/change
name = "Change"
/datum/action/item_action/noir
name = "Noir"
/datum/action/item_action/YEEEAAAAAHHHHHHHHHHHHH
name = "YEAH!"
/datum/action/item_action/adjust
/datum/action/item_action/adjust/New(Target)
..()
name = "Adjust [target.name]"
button.name = name
/datum/action/item_action/pontificate
name = "Pontificate Evilly"
/datum/action/item_action/tip_fedora
name = "Tip Fedora"
/datum/action/item_action/flip_cap
name = "Flip Cap"
/datum/action/item_action/switch_hud
name = "Switch HUD"
/datum/action/item_action/toggle_wings
name = "Toggle Wings"
/datum/action/item_action/toggle_helmet
name = "Toggle Helmet"
/datum/action/item_action/remove_tape
name = "Remove Duct Tape"
/datum/action/item_action/remove_tape/Trigger(attack_self = FALSE)
if(..())
var/datum/component/ducttape/DT = target.GetComponent(/datum/component/ducttape)
DT.remove_tape(target, usr)
/datum/action/item_action/toggle_jetpack
name = "Toggle Jetpack"
/datum/action/item_action/jetpack_stabilization
name = "Toggle Jetpack Stabilization"
/datum/action/item_action/jetpack_stabilization/IsAvailable()
var/obj/item/tank/jetpack/J = target
if(!istype(J) || !J.on)
return FALSE
return ..()
/datum/action/item_action/toggle_geiger_counter
name = "Toggle Geiger Counter"
/datum/action/item_action/toggle_geiger_counter/Trigger()
var/obj/item/clothing/head/helmet/space/hardsuit/H = target
if(istype(H))
H.toggle_geiger_counter()
/datum/action/item_action/hands_free
check_flags = AB_CHECK_CONSCIOUS
/datum/action/item_action/hands_free/activate
name = "Activate"
/datum/action/item_action/hands_free/activate/always
check_flags = null
/datum/action/item_action/toggle_research_scanner
name = "Toggle Research Scanner"
button_icon_state = "scan_mode"
/datum/action/item_action/toggle_research_scanner/Trigger()
if(IsAvailable())
owner.research_scanner = !owner.research_scanner
to_chat(owner, "<span class='notice'>Research analyzer is now [owner.research_scanner ? "active" : "deactivated"].</span>")
return TRUE
/datum/action/item_action/toggle_research_scanner/Remove(mob/living/L)
if(owner)
owner.research_scanner = 0
..()
/datum/action/item_action/toggle_research_scanner/ApplyIcon(obj/screen/movable/action_button/current_button)
current_button.cut_overlays()
if(button_icon && button_icon_state)
var/image/img = image(button_icon, current_button, "scan_mode")
img.appearance_flags = RESET_COLOR | RESET_ALPHA
current_button.overlays += img
/datum/action/item_action/instrument
name = "Use Instrument"
desc = "Use the instrument specified"
/datum/action/item_action/instrument/Trigger()
if(istype(target, /obj/item/instrument))
var/obj/item/instrument/I = target
I.interact(usr)
return
return ..()
/datum/action/item_action/remove_badge
name = "Remove Holobadge"
// Clown Acrobat Shoes
/datum/action/item_action/slipping
name = "Tactical Slip"
desc = "Activates the clown shoes' ankle-stimulating module, allowing the user to do a short slip forward going under anyone."
button_icon_state = "clown"
// Jump boots
/datum/action/item_action/bhop
name = "Activate Jump Boots"
desc = "Activates the jump boot's internal propulsion system, allowing the user to dash over 4-wide gaps."
icon_icon = 'icons/mob/actions/actions.dmi'
button_icon_state = "jetboot"
use_itemicon = FALSE
///prset for organ actions
/datum/action/item_action/organ_action
check_flags = AB_CHECK_CONSCIOUS
/datum/action/item_action/organ_action/IsAvailable()
var/obj/item/organ/internal/I = target
if(!I.owner)
return FALSE
return ..()
/datum/action/item_action/organ_action/toggle
/datum/action/item_action/organ_action/toggle/New(Target)
..()
name = "Toggle [target.name]"
button.name = name
/datum/action/item_action/organ_action/use/New(Target)
..()
name = "Use [target.name]"
button.name = name
/datum/action/item_action/voice_changer/toggle
name = "Toggle Voice Changer"
/datum/action/item_action/voice_changer/voice
name = "Set Voice"
/datum/action/item_action/voice_changer/voice/Trigger()
if(!IsAvailable())
return FALSE
var/obj/item/voice_changer/V = target
V.set_voice(usr)
// for clothing accessories like holsters
/datum/action/item_action/accessory
check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_CONSCIOUS
/datum/action/item_action/accessory/IsAvailable()
. = ..()
if(!.)
return FALSE
if(target.loc == owner)
return TRUE
if(istype(target.loc, /obj/item/clothing/under) && target.loc.loc == owner)
return TRUE
return FALSE
/datum/action/item_action/accessory/holster
name = "Holster"
/datum/action/item_action/accessory/storage
name = "View Storage"
//Preset for spells
/datum/action/spell_action
check_flags = 0
background_icon_state = "bg_spell"
var/recharge_text_color = "#FFFFFF"
/datum/action/spell_action/New(Target)
..()
var/obj/effect/proc_holder/spell/S = target
S.action = src
name = S.name
desc = S.desc
button_icon = S.action_icon
button_icon_state = S.action_icon_state
background_icon_state = S.action_background_icon_state
button.name = name
/datum/action/spell_action/Destroy()
var/obj/effect/proc_holder/spell/S = target
S.action = null
return ..()
/datum/action/spell_action/Trigger()
if(!..())
return FALSE
if(target)
var/obj/effect/proc_holder/spell = target
spell.Click()
return TRUE
/datum/action/spell_action/IsAvailable()
if(!target)
return FALSE
var/obj/effect/proc_holder/spell/spell = target
if(owner)
return spell.can_cast(owner)
return FALSE
/datum/action/spell_action/apply_unavailable_effect()
var/obj/effect/proc_holder/spell/S = target
if(!istype(S))
return ..()
var/progress = S.get_availability_percentage()
if(progress == 1)
return ..() // This means that the spell is charged but unavailable due to something else
var/alpha = 220 - 140 * progress
var/image/img = image('icons/mob/screen_white.dmi', icon_state = "template")
img.alpha = alpha
img.appearance_flags = RESET_COLOR | RESET_ALPHA
img.color = "#000000"
img.plane = FLOAT_PLANE + 1
button.add_overlay(img)
// Make a holder for the charge text
var/image/count_down_holder = image('icons/effects/effects.dmi', icon_state = "nothing")
count_down_holder.plane = FLOAT_PLANE + 1.1
count_down_holder.maptext = "<div style=\"font-size:6pt;color:[recharge_text_color];font:'Small Fonts';text-align:center;\" valign=\"bottom\">[round_down(progress * 100)]%</div>"
button.add_overlay(count_down_holder)
/*
/datum/action/spell_action/alien
/datum/action/spell_action/alien/IsAvailable()
if(!target)
return 0
var/obj/effect/proc_holder/alien/ab = target
if(owner)
return ab.cost_check(ab.check_turf, owner, 1)
return 0
*/
//Preset for general and toggled actions
/datum/action/innate
check_flags = 0
var/active = FALSE
/datum/action/innate/Trigger()
if(!..())
return FALSE
if(!active)
Activate()
else
Deactivate()
return TRUE
/datum/action/innate/proc/Activate()
return
/datum/action/innate/proc/Deactivate()
return
//Preset for action that call specific procs (consider innate)
/datum/action/generic
check_flags = 0
var/procname
/datum/action/generic/Trigger()
if(!..())
return FALSE
if(target && procname)
call(target,procname)(usr)
return TRUE