mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 20:11:56 +00:00
Makes the code compatible with 515.1594+
Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword
And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.
@tgstation/commit-access Since the .proc/stuff is pretty big change.
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
73 lines
2.6 KiB
Plaintext
73 lines
2.6 KiB
Plaintext
/**
|
|
* Add an auto attack on bump behaviour to item
|
|
* valid_inventory_slot: the inventory slot the item could be held in while still bumpattacking with it
|
|
* proxy_weapon: the weapon that will gain this behaviour
|
|
*/
|
|
#define COOLDOWN_BUMP_ATTACK "bump_attack_cooldown"
|
|
|
|
/datum/component/bumpattack
|
|
dupe_mode = COMPONENT_DUPE_UNIQUE
|
|
///inventory slot that the item could be stored while still being able to attack with it. DO SLOT_HANDS|SLOT_BACK instead of a list for multiple slots
|
|
var/valid_inventory_slot
|
|
///whether or not the behaviour would be active on the item
|
|
var/active = FALSE
|
|
///the mob handling the item
|
|
var/mob/living/wearer
|
|
///the item that will gain this behaviour
|
|
var/obj/item/proxy_weapon
|
|
///cool down between each hit
|
|
var/attack_cooldown = CLICK_CD_MELEE
|
|
|
|
/datum/component/bumpattack/Initialize(valid_inventory_slot, obj/item/proxy_weapon)
|
|
if(!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
src.valid_inventory_slot = valid_inventory_slot
|
|
src.proxy_weapon = proxy_weapon
|
|
|
|
return ..()
|
|
|
|
/datum/component/bumpattack/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(check_equip))
|
|
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(check_drop))
|
|
|
|
/datum/component/bumpattack/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
|
|
|
|
/datum/component/bumpattack/proc/check_equip(obj/item/source, mob/living/user, slot)
|
|
SIGNAL_HANDLER
|
|
if(!user) // iunno, thoroughness
|
|
return
|
|
if(slot & valid_inventory_slot)
|
|
activate(user)
|
|
else
|
|
deactivate()
|
|
|
|
/datum/component/bumpattack/proc/check_drop(datum/source, mob/living/dropper)
|
|
SIGNAL_HANDLER
|
|
deactivate()
|
|
|
|
/datum/component/bumpattack/proc/activate(mob/living/user)
|
|
if(!istype(user))
|
|
return
|
|
active = TRUE
|
|
wearer = user
|
|
RegisterSignal(user, COMSIG_LIVING_MOB_BUMP, PROC_REF(check_bump))
|
|
|
|
/datum/component/bumpattack/proc/deactivate()
|
|
active = FALSE
|
|
if(wearer)
|
|
UnregisterSignal(wearer, COMSIG_LIVING_MOB_BUMP)
|
|
wearer = null
|
|
|
|
/datum/component/bumpattack/proc/check_bump(mob/living/bumper, mob/living/target)
|
|
SIGNAL_HANDLER
|
|
var/obj/item/our_weapon = proxy_weapon || parent
|
|
if(!istype(our_weapon))
|
|
CRASH("[our_weapon] somehow failed istype")
|
|
if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_BUMP_ATTACK))
|
|
TIMER_COOLDOWN_START(src, COOLDOWN_BUMP_ATTACK, attack_cooldown)
|
|
INVOKE_ASYNC(target, TYPE_PROC_REF(/atom, attackby), our_weapon, bumper)
|
|
bumper.visible_message(span_danger("[bumper] charges into [target], attacking with [our_weapon]!"), span_danger("You charge into [target], attacking with [our_weapon]!"), vision_distance = COMBAT_MESSAGE_RANGE)
|
|
|
|
#undef COOLDOWN_BUMP_ATTACK
|