-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathstealth_box.dm
56 lines (50 loc) · 2.08 KB
/
stealth_box.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
///MGS BOX!
/datum/action/item_action/agent_box
name = "Deploy Box"
desc = "Find inner peace, here, in the box."
check_flags = AB_CHECK_INCAPACITATED|AB_CHECK_HANDS_BLOCKED|AB_CHECK_IMMOBILE|AB_CHECK_CONSCIOUS
background_icon_state = "bg_agent"
overlay_icon_state = "bg_agent_border"
button_icon = 'icons/mob/actions/actions_items.dmi'
button_icon_state = "deploy_box"
///The type of closet this action spawns.
var/boxtype = /obj/structure/closet/cardboard/agent
COOLDOWN_DECLARE(box_cooldown)
///Handles opening and closing the box.
/datum/action/item_action/agent_box/Trigger(trigger_flags)
. = ..()
if(!.)
return FALSE
if(istype(owner.loc, /obj/structure/closet/cardboard/agent))
var/obj/structure/closet/cardboard/agent/box = owner.loc
if(box.open())
owner.playsound_local(box, 'sound/misc/box_deploy.ogg', 50, TRUE)
return
//Box closing from here on out.
if(!isturf(owner.loc)) //Don't let the player use this to escape mechs/welded closets.
to_chat(owner, span_warning("You need more space to activate this implant!"))
return
if(!COOLDOWN_FINISHED(src, box_cooldown))
return
COOLDOWN_START(src, box_cooldown, 10 SECONDS)
var/box = new boxtype(owner.drop_location())
owner.forceMove(box)
owner.playsound_local(box, 'sound/misc/box_deploy.ogg', 50, TRUE)
/datum/action/item_action/agent_box/Grant(mob/grant_to)
. = ..()
if(owner)
RegisterSignal(owner, COMSIG_HUMAN_SUICIDE_ACT, PROC_REF(suicide_act))
/datum/action/item_action/agent_box/Remove(mob/M)
if(owner)
UnregisterSignal(owner, COMSIG_HUMAN_SUICIDE_ACT)
return ..()
/datum/action/item_action/agent_box/proc/suicide_act(datum/source)
SIGNAL_HANDLER
if(!istype(owner.loc, /obj/structure/closet/cardboard/agent))
return
var/obj/structure/closet/cardboard/agent/box = owner.loc
owner.playsound_local(box, 'sound/misc/box_deploy.ogg', 50, TRUE)
INVOKE_ASYNC(box, TYPE_PROC_REF(/obj/structure/closet/, open))
owner.visible_message(span_suicide("[owner] falls out of [box]! It looks like [owner.p_they()] committed suicide!"))
INVOKE_ASYNC(owner, TYPE_PROC_REF(/atom/movable/, throw_at), get_turf(owner))
return OXYLOSS