mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Moves everything on a 15+ layer to a plane. So now you get screen catcher (-99, was already on a plane), lighting (15), effects that ignore lighting (16), fullscreen UI effects (18), screen objects used to build the UI (19), actual equipment in the UI slots (20), and everything else (0). Also created a file to contain plane and layer defines for hopeful eventual use. Hopefully this doesn't change anything now but does enable some nifty new features in the future.
378 lines
8.2 KiB
Plaintext
378 lines
8.2 KiB
Plaintext
#define AB_CHECK_RESTRAINED 1
|
|
#define AB_CHECK_STUNNED 2
|
|
#define AB_CHECK_LYING 4
|
|
#define AB_CHECK_CONSCIOUS 8
|
|
|
|
|
|
/datum/action
|
|
var/name = "Generic Action"
|
|
var/obj/target = null
|
|
var/check_flags = 0
|
|
var/processing = 0
|
|
var/obj/screen/movable/action_button/button = null
|
|
var/button_icon = 'icons/mob/actions.dmi'
|
|
var/button_icon_state = "default"
|
|
var/background_icon_state = "bg_default"
|
|
var/mob/living/owner
|
|
|
|
/datum/action/New(Target)
|
|
target = Target
|
|
button = new
|
|
button.linked_action = src
|
|
button.name = name
|
|
|
|
/datum/action/Destroy()
|
|
if(owner)
|
|
Remove(owner)
|
|
target = null
|
|
qdel(button)
|
|
button = null
|
|
return ..()
|
|
|
|
/datum/action/proc/Grant(mob/living/L)
|
|
if(owner)
|
|
if(owner == L)
|
|
return
|
|
Remove(owner)
|
|
owner = L
|
|
L.actions += src
|
|
if(L.client)
|
|
L.client.screen += button
|
|
L.update_action_buttons()
|
|
|
|
/datum/action/proc/Remove(mob/living/L)
|
|
if(L.client)
|
|
L.client.screen -= button
|
|
button.moved = FALSE //so the button appears in its normal position when given to another owner.
|
|
L.actions -= src
|
|
L.update_action_buttons()
|
|
owner = null
|
|
|
|
/datum/action/proc/Trigger()
|
|
if(!IsAvailable())
|
|
return 0
|
|
return 1
|
|
|
|
/datum/action/proc/Process()
|
|
return
|
|
|
|
/datum/action/proc/IsAvailable()
|
|
if(!owner)
|
|
return 0
|
|
if(check_flags & AB_CHECK_RESTRAINED)
|
|
if(owner.restrained())
|
|
return 0
|
|
if(check_flags & AB_CHECK_STUNNED)
|
|
if(owner.stunned || owner.weakened)
|
|
return 0
|
|
if(check_flags & AB_CHECK_LYING)
|
|
if(owner.lying)
|
|
return 0
|
|
if(check_flags & AB_CHECK_CONSCIOUS)
|
|
if(owner.stat)
|
|
return 0
|
|
return 1
|
|
|
|
/datum/action/proc/UpdateButtonIcon()
|
|
if(button)
|
|
button.icon = button_icon
|
|
button.icon_state = background_icon_state
|
|
|
|
ApplyIcon(button)
|
|
|
|
if(!IsAvailable())
|
|
button.color = rgb(128,0,0,128)
|
|
else
|
|
button.color = rgb(255,255,255,255)
|
|
return 1
|
|
|
|
/datum/action/proc/ApplyIcon(obj/screen/movable/action_button/current_button)
|
|
current_button.overlays.Cut()
|
|
if(button_icon && button_icon_state)
|
|
var/image/img = image(button_icon, current_button, button_icon_state)
|
|
img.plane = current_button.plane
|
|
img.pixel_x = 0
|
|
img.pixel_y = 0
|
|
current_button.overlays += img
|
|
|
|
|
|
|
|
//Presets for item actions
|
|
/datum/action/item_action
|
|
check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_CONSCIOUS
|
|
button_icon_state = null
|
|
// If you want to override the normal icon being the item
|
|
// then change this to an icon state
|
|
|
|
/datum/action/item_action/New(Target)
|
|
..()
|
|
var/obj/item/I = target
|
|
I.actions += src
|
|
|
|
/datum/action/item_action/Destroy()
|
|
var/obj/item/I = target
|
|
I.actions -= src
|
|
return ..()
|
|
|
|
/datum/action/item_action/Trigger()
|
|
if(!..())
|
|
return 0
|
|
if(target)
|
|
var/obj/item/I = target
|
|
I.ui_action_click(owner, src.type)
|
|
return 1
|
|
|
|
/datum/action/item_action/ApplyIcon(obj/screen/movable/action_button/current_button)
|
|
current_button.overlays.Cut()
|
|
|
|
if(button_icon && button_icon_state)
|
|
// If set, use the custom icon that we set instead
|
|
// of the item appereance
|
|
..(current_button)
|
|
else if(target)
|
|
var/obj/item/I = target
|
|
var/old = I.plane
|
|
I.plane = current_button.plane
|
|
current_button.overlays += I
|
|
I.plane = old
|
|
|
|
/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/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_state = "bg_default_on"
|
|
|
|
/datum/action/item_action/toggle_mister
|
|
name = "Toggle Mister"
|
|
|
|
/datum/action/item_action/activate_injector
|
|
name = "Activate Injector"
|
|
|
|
/datum/action/item_action/toggle_helmet_light
|
|
name = "Toggle Helmet Light"
|
|
|
|
/datum/action/item_action/toggle_helmet_flashlight
|
|
name = "Toggle Helmet Flashlight"
|
|
|
|
/datum/action/item_action/toggle_helmet_mode
|
|
name = "Toggle Helmet Mode"
|
|
|
|
/datum/action/item_action/toggle
|
|
|
|
/datum/action/item_action/toggle/New(Target)
|
|
..()
|
|
name = "Toggle [target.name]"
|
|
button.name = name
|
|
|
|
/datum/action/item_action/halt
|
|
name = "HALT!"
|
|
|
|
/datum/action/item_action/toggle_voice_box
|
|
name = "Toggle Voice Box"
|
|
|
|
/datum/action/item_action/change
|
|
name = "Change"
|
|
|
|
/datum/action/item_action/adjust
|
|
|
|
/datum/action/item_action/adjust/New(Target)
|
|
..()
|
|
name = "Adjust [target.name]"
|
|
button.name = name
|
|
|
|
/datum/action/item_action/switch_hud
|
|
name = "Switch HUD"
|
|
|
|
/datum/action/item_action/toggle_wings
|
|
name = "Toggle Wings"
|
|
|
|
/datum/action/item_action/toggle_human_head
|
|
name = "Toggle Human Head"
|
|
|
|
/datum/action/item_action/toggle_helmet
|
|
name = "Toggle Helmet"
|
|
|
|
/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/weapon/tank/jetpack/J = target
|
|
if(!istype(J) || !J.on)
|
|
return 0
|
|
return ..()
|
|
|
|
/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/shift_nerves
|
|
name = "Shift Nerves"
|
|
|
|
|
|
/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
|
|
owner << "<span class='notice'>Research analyzer is now [owner.research_scanner ? "active" : "deactivated"].</span>"
|
|
return 1
|
|
|
|
/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)
|
|
if(button_icon && button_icon_state)
|
|
var/image/img = image(button_icon, current_button, "scan_mode")
|
|
current_button.overlays += img
|
|
|
|
/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 0
|
|
return ..()
|
|
|
|
/datum/action/item_action/organ_action/toggle
|
|
|
|
/datum/action/item_action/organ_action/toggle/New(Target)
|
|
..()
|
|
name = "Toggle [target.name]"
|
|
button.name = name
|
|
|
|
|
|
|
|
|
|
//Preset for spells
|
|
/datum/action/spell_action
|
|
check_flags = 0
|
|
background_icon_state = "bg_spell"
|
|
|
|
/datum/action/spell_action/New(Target)
|
|
..()
|
|
var/obj/effect/proc_holder/spell/S = target
|
|
S.action = src
|
|
name = S.name
|
|
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 0
|
|
if(target)
|
|
var/obj/effect/proc_holder/spell = target
|
|
spell.Click()
|
|
return 1
|
|
|
|
/datum/action/spell_action/IsAvailable()
|
|
if(!target)
|
|
return 0
|
|
var/obj/effect/proc_holder/spell/spell = target
|
|
|
|
if(usr)
|
|
return spell.can_cast(usr)
|
|
else
|
|
if(owner)
|
|
return spell.can_cast(owner)
|
|
return 1
|
|
|
|
|
|
/datum/action/spell_action/alien
|
|
|
|
/datum/action/spell_action/alien/IsAvailable()
|
|
if(!target)
|
|
return 0
|
|
var/obj/effect/proc_holder/alien/ab = target
|
|
|
|
if(usr)
|
|
return ab.cost_check(ab.check_turf,usr,1)
|
|
else
|
|
if(owner)
|
|
return ab.cost_check(ab.check_turf,owner,1)
|
|
return 1
|
|
|
|
|
|
|
|
//Preset for general and toggled actions
|
|
/datum/action/innate
|
|
check_flags = 0
|
|
var/active = 0
|
|
|
|
/datum/action/innate/Trigger()
|
|
if(!..())
|
|
return 0
|
|
if(!active)
|
|
Activate()
|
|
else
|
|
Deactivate()
|
|
return 1
|
|
|
|
/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 0
|
|
if(target && procname)
|
|
call(target, procname)(usr)
|
|
return 1
|