diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 5a4e7c0380..668d343a6f 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -233,6 +233,7 @@ #define COMSIG_ITEM_PRE_ATTACK "item_pre_attack" //from base of obj/item/pre_attack(): (atom/target, mob/user, params) #define COMPONENT_NO_ATTACK 1 #define COMSIG_ITEM_AFTERATTACK "item_afterattack" //from base of obj/item/afterattack(): (atom/target, mob/user, params) +#define COMSIG_ITEM_ALT_AFTERATTACK "item_alt_afterattack" //from base of obj/item/altafterattack(): (atom/target, mob/user, proximity, params) #define COMSIG_ITEM_EQUIPPED "item_equip" //from base of obj/item/equipped(): (/mob/equipper, slot) #define COMSIG_ITEM_DROPPED "item_drop" //from base of obj/item/dropped(): (mob/user) #define COMSIG_ITEM_PICKUP "item_pickup" //from base of obj/item/pickup(): (/mob/taker) diff --git a/code/datums/elements/sword_point.dm b/code/datums/elements/sword_point.dm new file mode 100644 index 0000000000..5eaa9eaa70 --- /dev/null +++ b/code/datums/elements/sword_point.dm @@ -0,0 +1,18 @@ +/datum/element/sword_point + element_flags = ELEMENT_DETACH + +/datum/element/sword_point/Attach(datum/target) + . = ..() + if(. == ELEMENT_INCOMPATIBLE) + return + if(!istype(target)) + return ELEMENT_INCOMPATIBLE + RegisterSignal(target, COMSIG_ITEM_ALT_AFTERATTACK, .proc/point) + +/datum/element/sword_point/Detach(datum/source) + . = ..() + UnregisterSignal(source, COMSIG_ITEM_ALT_AFTERATTACK) + +/datum/element/sword_point/proc/point(datum/source, atom/target, mob/user, proximity_flag, params) + if(!proximity_flag && ismob(target)) + user.visible_message("[user] points the tip of [src] at [target].", "You point the tip of [src] at [target].") diff --git a/code/game/objects/items/melee/energy.dm b/code/game/objects/items/melee/energy.dm index 405e3737d0..aba07c9120 100644 --- a/code/game/objects/items/melee/energy.dm +++ b/code/game/objects/items/melee/energy.dm @@ -7,7 +7,6 @@ var/brightness_on = 3 total_mass = 0.4 //Survival flashlights typically weigh around 5 ounces. - /obj/item/melee/transforming/energy/Initialize() . = ..() total_mass_on = (total_mass_on ? total_mass_on : (w_class_on * 0.75)) @@ -107,8 +106,12 @@ /obj/item/melee/transforming/energy/sword/transform_weapon(mob/living/user, supress_message_text) . = ..() - if(. && active && item_color) - icon_state = "sword[item_color]" + if(active) + if(. && item_color) + icon_state = "sword[item_color]" + AddElement(/datum/element/sword_point) + else + RemoveElement(/datum/element/sword_point) /obj/item/melee/transforming/energy/sword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) if(active) @@ -267,11 +270,6 @@ altafterattack(A, user, TRUE, params) return TRUE -/obj/item/melee/transforming/energy/sword/cx/altafterattack(atom/target, mob/living/carbon/user, proximity_flag, click_parameters) //does right click memes - if(istype(user)) - user.visible_message("[user] points the tip of [src] at [target].", "You point the tip of [src] at [target].") - return TRUE - /obj/item/melee/transforming/energy/sword/cx/transform_weapon(mob/living/user, supress_message_text) active = !active //I'd use a ..() here but it'd inherit from the regular esword's proc instead, so SPAGHETTI CODE if(active) //also I'd need to rip out the iconstate changing bits diff --git a/code/game/objects/items/melee/misc.dm b/code/game/objects/items/melee/misc.dm index 9c544a34ef..bad140df9e 100644 --- a/code/game/objects/items/melee/misc.dm +++ b/code/game/objects/items/melee/misc.dm @@ -73,6 +73,7 @@ /obj/item/melee/sabre/Initialize() . = ..() AddComponent(/datum/component/butchering, 30, 95, 5) //fast and effective, but as a sword, it might damage the results. + AddElement(/datum/element/sword_point) /obj/item/melee/sabre/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) if(attack_type == PROJECTILE_ATTACK) diff --git a/code/game/objects/items/toys.dm b/code/game/objects/items/toys.dm index 1a5f97c4e0..8f683b8c1c 100644 --- a/code/game/objects/items/toys.dm +++ b/code/game/objects/items/toys.dm @@ -228,26 +228,39 @@ var/hacked = FALSE total_mass = 0.4 var/total_mass_on = TOTAL_MASS_TOY_SWORD + var/activation_sound = 'sound/weapons/saberon.ogg' + var/deactivation_sound = 'sound/weapons/saberoff.ogg' + var/activation_message = "You extend the plastic blade with a quick flick of your wrist." + var/deactivation_message = "You push the plastic blade back down into the handle." + var/transform_volume = 20 /obj/item/toy/sword/attack_self(mob/user) - active = !( active ) + active = !active if (active) - to_chat(user, "You extend the plastic blade with a quick flick of your wrist.") - playsound(user, 'sound/weapons/saberon.ogg', 20, 1) + to_chat(user, "[activation_message]") + playsound(user, activation_sound, transform_volume, 1) + w_class = WEIGHT_CLASS_BULKY + AddElement(/datum/element/sword_point) + else + to_chat(user, "[deactivation_message]") + playsound(user, deactivation_sound, transform_volume, 1) + w_class = WEIGHT_CLASS_SMALL + RemoveElement(/datum/element/sword_point) + + update_icon() + add_fingerprint(user) + +/obj/item/toy/sword/update_icon_state() + if(active) if(hacked) icon_state = "swordrainbow" item_state = "swordrainbow" else icon_state = "swordblue" item_state = "swordblue" - w_class = WEIGHT_CLASS_BULKY else - to_chat(user, "You push the plastic blade back down into the handle.") - playsound(user, 'sound/weapons/saberoff.ogg', 20, 1) icon_state = "sword0" item_state = "sword0" - w_class = WEIGHT_CLASS_SMALL - add_fingerprint(user) // Copied from /obj/item/melee/transforming/energy/sword/attackby /obj/item/toy/sword/attackby(obj/item/W, mob/living/user, params) @@ -270,7 +283,7 @@ to_chat(user, "RNBW_ENGAGE") if(active) - icon_state = "swordrainbow" + update_icon() user.update_inv_hands() else to_chat(user, "It's already fabulous!") @@ -290,38 +303,24 @@ w_class = WEIGHT_CLASS_SMALL attack_verb = list("poked", "jabbed", "hit") light_color = "#37FFF7" + activation_sound = 'sound/weapons/nebon.ogg' + deactivation_sound = 'sound/weapons/neboff.ogg' + transform_volume = 50 + activation_message = "You activate the holographic blade with a press of a button." + deactivation_message = "You deactivate the holographic blade with a press of a button." var/light_brightness = 3 actions_types = list() -/obj/item/toy/sword/cx/alt_pre_attack(atom/A, mob/living/user, params) //checks if it can do right click memes - altafterattack(A, user, TRUE, params) - return TRUE - -/obj/item/toy/sword/cx/altafterattack(atom/target, mob/living/carbon/user, proximity_flag, click_parameters) //does right click memes - if(istype(user)) - user.visible_message("[user] points the tip of [src] at [target].", "You point the tip of [src] at [target].") - return TRUE +/obj/item/toy/sword/cx/ComponentInitialize() + . = ..() + AddElement(/datum/element/update_icon_updates_onmob) /obj/item/toy/sword/cx/attack_self(mob/user) - active = !( active ) + . = ..() + set_light(active ? light_brightness : 0) - if (active) - to_chat(user, "You activate the holographic blade with a press of a button.") - playsound(user, 'sound/weapons/nebon.ogg', 50, 1) - w_class = WEIGHT_CLASS_BULKY - attack_verb = list("slashed", "stabbed", "ravaged") - set_light(light_brightness) - update_icon() - - else - to_chat(user, "You deactivate the holographic blade with a press of a button.") - playsound(user, 'sound/weapons/neboff.ogg', 50, 1) - w_class = WEIGHT_CLASS_SMALL - attack_verb = list("poked", "jabbed", "hit") - set_light(0) - update_icon() - - add_fingerprint(user) +/obj/item/toy/sword/cx/update_icon_state() + return /obj/item/toy/sword/cx/update_overlays() . = ..() diff --git a/code/game/objects/items/twohanded.dm b/code/game/objects/items/twohanded.dm index 23bd6ed359..11a06e149d 100644 --- a/code/game/objects/items/twohanded.dm +++ b/code/game/objects/items/twohanded.dm @@ -396,6 +396,7 @@ hitsound = 'sound/weapons/blade1.ogg' START_PROCESSING(SSobj, src) set_light(brightness_on) + AddElement(/datum/element/sword_point) /obj/item/twohanded/dualsaber/unwield() //Specific unwield () to switch hitsounds. sharpness = initial(sharpness) @@ -405,6 +406,7 @@ hitsound = "swing_hit" STOP_PROCESSING(SSobj, src) set_light(0) + RemoveElement(/datum/element/sword_point) /obj/item/twohanded/dualsaber/process() if(wielded) @@ -493,15 +495,6 @@ . = ..() AddElement(/datum/element/update_icon_updates_onmob) -/obj/item/twohanded/dualsaber/hypereutactic/alt_pre_attack(atom/A, mob/living/user, params) //checks if it can do right click memes - altafterattack(A, user, TRUE, params) - return TRUE - -/obj/item/twohanded/dualsaber/hypereutactic/altafterattack(atom/target, mob/living/user, proximity_flag, click_parameters) //does right click memes - if(istype(user)) - user.visible_message("[user] points the tip of [src] at [target].", "You point the tip of [src] at [target].") - return TRUE - /obj/item/twohanded/dualsaber/hypereutactic/update_icon_state() return @@ -605,6 +598,8 @@ /obj/item/twohanded/spear/Initialize() . = ..() AddComponent(/datum/component/butchering, 100, 70) //decent in a pinch, but pretty bad. + AddComponent(/datum/component/jousting) + AddElement(/datum/element/sword_point) /obj/item/twohanded/spear/attack_self(mob/user) if(explosive) @@ -630,10 +625,6 @@ return BRUTELOSS return BRUTELOSS -/obj/item/twohanded/spear/Initialize() - . = ..() - AddComponent(/datum/component/jousting) - /obj/item/twohanded/spear/examine(mob/user) . = ..() if(explosive) @@ -818,6 +809,9 @@ armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 30) resistance_flags = FIRE_PROOF +/obj/item/twohanded/pitchfork/Initialize(mapload) + AddElement(/datum/element/sword_point) + /obj/item/twohanded/pitchfork/demonic name = "demonic pitchfork" desc = "A red pitchfork, it looks like the work of the devil." @@ -901,6 +895,7 @@ /obj/item/twohanded/vibro_weapon/Initialize() . = ..() AddComponent(/datum/component/butchering, 20, 105) + AddElement(/datum/element/sword_point) /obj/item/twohanded/vibro_weapon/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) if(wielded) diff --git a/code/game/objects/items/weaponry.dm b/code/game/objects/items/weaponry.dm index 7499d9de09..7c3a2734b1 100644 --- a/code/game/objects/items/weaponry.dm +++ b/code/game/objects/items/weaponry.dm @@ -74,6 +74,7 @@ for further reading, please see: https://github.com/tgstation/tgstation/pull/301 /obj/item/claymore/Initialize() . = ..() AddComponent(/datum/component/butchering, 40, 105) + AddElement(/datum/element/sword_point) /obj/item/claymore/suicide_act(mob/user) user.visible_message("[user] is falling on [src]! It looks like [user.p_theyre()] trying to commit suicide!") diff --git a/code/modules/antagonists/cult/cult_items.dm b/code/modules/antagonists/cult/cult_items.dm index f14aeede9a..743d3cfc9a 100644 --- a/code/modules/antagonists/cult/cult_items.dm +++ b/code/modules/antagonists/cult/cult_items.dm @@ -46,6 +46,7 @@ /obj/item/melee/cultblade/Initialize() . = ..() AddComponent(/datum/component/butchering, 40, 100) + AddElement(/datum/element/sword_point) /obj/item/melee/cultblade/attack(mob/living/target, mob/living/carbon/human/user) if(!iscultist(user)) diff --git a/modular_citadel/code/_onclick/item_attack.dm b/modular_citadel/code/_onclick/item_attack.dm index d87b2be661..bba3b14e2e 100644 --- a/modular_citadel/code/_onclick/item_attack.dm +++ b/modular_citadel/code/_onclick/item_attack.dm @@ -16,4 +16,5 @@ return FALSE /obj/item/proc/altafterattack(atom/target, mob/user, proximity_flag, click_parameters) + SEND_SIGNAL(src, COMSIG_ITEM_ALT_AFTERATTACK, target, user, proximity_flag, click_parameters) return FALSE diff --git a/tgstation.dme b/tgstation.dme index 13b3380025..7f139d2ae9 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -502,6 +502,7 @@ #include "code\datums\elements\ghost_role_eligibility.dm" #include "code\datums\elements\mob_holder.dm" #include "code\datums\elements\swimming.dm" +#include "code\datums\elements\sword_point.dm" #include "code\datums\elements\update_icon_blocker.dm" #include "code\datums\elements\update_icon_updates_onmob.dm" #include "code\datums\elements\wuv.dm"