diff --git a/code/datums/components/tactical.dm b/code/datums/components/tactical.dm index 4f9f00c0668..5267782b23c 100644 --- a/code/datums/components/tactical.dm +++ b/code/datums/components/tactical.dm @@ -1,46 +1,38 @@ ///A simple component that replacess the user's appearance with that of the parent item when equipped. /datum/component/tactical - ///The allowed slot(s) for the effect. - var/allowed_slot + ///The allowed slots for the effect. + var/allowed_slots ///A cached of where the item is currently equipped. var/current_slot -/datum/component/tactical/Initialize(allowed_slot) +/datum/component/tactical/Initialize(allowed_slots) if(!isitem(parent)) return COMPONENT_INCOMPATIBLE - src.allowed_slot = allowed_slot + src.allowed_slots = allowed_slots + +/datum/component/tactical/Destroy() + unmodify() + return ..() /datum/component/tactical/RegisterWithParent() RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(modify)) - var/obj/item/item = parent - if(ismob(item.loc)) - var/mob/holder = item.loc - modify(item, holder, holder.get_slot_by_item(item)) + RegisterSignal(parent, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(tactical_update)) /datum/component/tactical/UnregisterFromParent() UnregisterSignal(parent, list( COMSIG_ITEM_EQUIPPED, + COMSIG_MOVABLE_Z_CHANGED, )) - unmodify() - -/datum/component/tactical/Destroy() - unmodify() - return ..() /datum/component/tactical/proc/modify(obj/item/source, mob/user, slot) SIGNAL_HANDLER - if(allowed_slot && !(slot & allowed_slot)) + if(allowed_slots && !(slot & allowed_slots)) if(current_slot) unmodify(source, user) return - RegisterSignal(parent, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(tactical_update)) - RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(unmodify)) - RegisterSignal(parent, COMSIG_ATOM_UPDATED_ICON, PROC_REF(tactical_update)) - RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) - current_slot = slot var/obj/item/master = parent @@ -51,6 +43,9 @@ image.plane = FLOAT_PLANE source.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/everyone, "sneaking_mission[REF(src)]", image) + RegisterSignal(source, COMSIG_ITEM_DROPPED, PROC_REF(unmodify)) + RegisterSignal(source, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) + /datum/component/tactical/proc/unmodify(obj/item/source, mob/user) SIGNAL_HANDLER if(!source) @@ -60,10 +55,14 @@ if(!istype(user)) return - user.remove_alt_appearance("sneaking_mission[REF(src)]") + UnregisterSignal(source, list( + COMSIG_ITEM_DROPPED, + COMSIG_MOVABLE_MOVED, + )) current_slot = null - UnregisterSignal(parent, list(COMSIG_MOVABLE_Z_CHANGED, COMSIG_ITEM_DROPPED, COMSIG_ATOM_UPDATED_ICON, COMSIG_MOVABLE_MOVED)) + user.remove_alt_appearance("sneaking_mission[REF(src)]") +///Checks if a mob is holding us, and if so we will modify our appearance to properly match w/ the mob. /datum/component/tactical/proc/tactical_update(obj/item/source) SIGNAL_HANDLER if(!ismob(source.loc)) diff --git a/code/datums/components/twohanded.dm b/code/datums/components/twohanded.dm index 464f1a58a07..45ee6697e53 100644 --- a/code/datums/components/twohanded.dm +++ b/code/datums/components/twohanded.dm @@ -2,21 +2,32 @@ * Two Handed Component * * When applied to an item it will make it two handed - * + * Only one of the component can exist on an item. */ /datum/component/two_handed - dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS // Only one of the component can exist on an item - var/wielded = FALSE /// Are we holding the two handed item properly - var/force_multiplier = 0 /// The multiplier applied to force when wielded, does not work with force_wielded, and force_unwielded - var/force_wielded = 0 /// The force of the item when weilded - var/force_unwielded = 0 /// The force of the item when unweilded - var/wieldsound = FALSE /// Play sound when wielded - var/unwieldsound = FALSE /// Play sound when unwielded - var/attacksound = FALSE /// Play sound on attack when wielded - var/require_twohands = FALSE /// Does it have to be held in both hands - var/icon_wielded = FALSE /// The icon that will be used when wielded - var/obj/item/offhand/offhand_item = null /// Reference to the offhand created for the item - var/sharpened_increase = 0 /// The amount of increase recived from sharpening the item + dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS + /// Are we holding the two handed item properly + var/wielded = FALSE + /// The multiplier applied to force when wielded, does not work with force_wielded, and force_unwielded + var/force_multiplier = 0 + /// The force of the item when weilded + var/force_wielded = 0 + /// The force of the item when unweilded + var/force_unwielded = 0 + /// Boolean whether to play sound when wielded + var/wieldsound = FALSE + /// Boolean whether to play sound when unwielded + var/unwieldsound = FALSE + /// Boolean whether to play sound on attack, if wielded + var/attacksound = FALSE + /// Boolean on whether it has to be held in both hands + var/require_twohands = FALSE + /// The icon that will be used when wielded + var/icon_wielded = FALSE + /// Reference to the offhand created for the item + var/obj/item/offhand/offhand_item = null + /// The amount of increase recived from sharpening the item + var/sharpened_increase = 0 /// A callback on the parent to be called when the item is wielded var/datum/callback/wield_callback /// A callback on the parent to be called when the item is unwielded @@ -36,9 +47,18 @@ * * force_unwielded (optional) The force setting when the item is unwielded, do not use with force_multiplier * * icon_wielded (optional) The icon to be used when wielded */ -/datum/component/two_handed/Initialize(require_twohands=FALSE, wieldsound=FALSE, unwieldsound=FALSE, attacksound=FALSE, \ - force_multiplier=0, force_wielded=0, force_unwielded=0, icon_wielded=FALSE, \ - datum/callback/wield_callback, datum/callback/unwield_callback) +/datum/component/two_handed/Initialize( + require_twohands = FALSE, + wieldsound = FALSE, + unwieldsound = FALSE, + attacksound = FALSE, + force_multiplier = 0, + force_wielded = 0, + force_unwielded = 0, + icon_wielded = FALSE, + datum/callback/wield_callback, + datum/callback/unwield_callback, +) if(!isitem(parent)) return COMPONENT_INCOMPATIBLE @@ -63,9 +83,20 @@ return ..() // Inherit the new values passed to the component -/datum/component/two_handed/InheritComponent(datum/component/two_handed/new_comp, original, require_twohands, wieldsound, unwieldsound, attacksound, \ - force_multiplier, force_wielded, force_unwielded, icon_wielded, \ - datum/callback/wield_callback, datum/callback/unwield_callback) +/datum/component/two_handed/InheritComponent( + datum/component/two_handed/new_comp, + original, + require_twohands, + wieldsound, + unwieldsound, + attacksound, + force_multiplier, + force_wielded, + force_unwielded, + icon_wielded, + datum/callback/wield_callback, + datum/callback/unwield_callback, +) if(!original) return if(require_twohands) @@ -101,32 +132,19 @@ RegisterSignal(parent, COMSIG_ITEM_APPLY_FANTASY_BONUSES, PROC_REF(apply_fantasy_bonuses)) RegisterSignal(parent, COMSIG_ITEM_REMOVE_FANTASY_BONUSES, PROC_REF(remove_fantasy_bonuses)) -/datum/component/two_handed/proc/apply_fantasy_bonuses(obj/item/source, bonus) - SIGNAL_HANDLER - force_wielded = source.modify_fantasy_variable("force_wielded", force_wielded, bonus) - force_unwielded = source.modify_fantasy_variable("force_unwielded", force_unwielded, bonus) - if(wielded && ismob(source.loc)) - unwield(source.loc) - if(force_multiplier) - force_multiplier = source.modify_fantasy_variable("force_multiplier", force_multiplier, bonus/10, minimum = 1) - -/datum/component/two_handed/proc/remove_fantasy_bonuses(obj/item/source, bonus) - SIGNAL_HANDLER - force_wielded = source.reset_fantasy_variable("force_wielded", force_wielded) - force_unwielded = source.reset_fantasy_variable("force_unwielded", force_unwielded) - if(wielded && ismob(source.loc)) - unwield(source.loc) - force_multiplier = source.reset_fantasy_variable("force_multiplier", force_multiplier) - // Remove all siginals registered to the parent item /datum/component/two_handed/UnregisterFromParent() - UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, - COMSIG_ITEM_DROPPED, - COMSIG_ITEM_ATTACK_SELF, - COMSIG_ITEM_ATTACK, - COMSIG_ATOM_UPDATE_ICON, - COMSIG_MOVABLE_MOVED, - COMSIG_ITEM_SHARPEN_ACT)) + UnregisterSignal(parent, list( + COMSIG_ITEM_EQUIPPED, + COMSIG_ITEM_DROPPED, + COMSIG_ITEM_ATTACK_SELF, + COMSIG_ITEM_ATTACK, + COMSIG_ATOM_UPDATE_ICON, + COMSIG_MOVABLE_MOVED, + COMSIG_ITEM_SHARPEN_ACT, + COMSIG_ITEM_APPLY_FANTASY_BONUSES, + COMSIG_ITEM_REMOVE_FANTASY_BONUSES, + )) /// Triggered on equip of the item containing the component /datum/component/two_handed/proc/on_equip(datum/source, mob/user, slot) @@ -365,9 +383,25 @@ sharpened_increase = min(amount, (max_amount - wielded_val)) return COMPONENT_BLOCK_SHARPEN_APPLIED +/datum/component/two_handed/proc/apply_fantasy_bonuses(obj/item/source, bonus) + SIGNAL_HANDLER + force_wielded = source.modify_fantasy_variable("force_wielded", force_wielded, bonus) + force_unwielded = source.modify_fantasy_variable("force_unwielded", force_unwielded, bonus) + if(wielded && ismob(source.loc)) + unwield(source.loc) + if(force_multiplier) + force_multiplier = source.modify_fantasy_variable("force_multiplier", force_multiplier, bonus/10, minimum = 1) + +/datum/component/two_handed/proc/remove_fantasy_bonuses(obj/item/source, bonus) + SIGNAL_HANDLER + force_wielded = source.reset_fantasy_variable("force_wielded", force_wielded) + force_unwielded = source.reset_fantasy_variable("force_unwielded", force_unwielded) + if(wielded && ismob(source.loc)) + unwield(source.loc) + force_multiplier = source.reset_fantasy_variable("force_multiplier", force_multiplier) + /** * The offhand dummy item for two handed items - * */ /obj/item/offhand name = "offhand"