Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add/refactor: сentcomm rapier #5924

Merged
merged 20 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions code/__DEFINES/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@

//Attack types for checking shields/hit reactions

#define MELEE_ATTACK 1
#define UNARMED_ATTACK 2
#define PROJECTILE_ATTACK 3
#define THROWN_PROJECTILE_ATTACK 4
#define LEAP_ATTACK 5
#define ITEM_ATTACK (1 << 0)
#define UNARMED_ATTACK (1 << 1)
#define PROJECTILE_ATTACK (1 << 2)
#define THROWN_PROJECTILE_ATTACK (1 << 3)
#define LEAP_ATTACK (1 << 4)
#define MELEE_ATTACKS (ITEM_ATTACK | THROWN_PROJECTILE_ATTACK | UNARMED_ATTACK | LEAP_ATTACK)

//attack visual effects
#define ATTACK_EFFECT_PUNCH "punch"
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,11 @@
/// Return COMPONENT_NO_DEFAULT_MESSAGE to prevent the transforming component from displaying the default transform message / sound.
#define COMPONENT_NO_DEFAULT_MESSAGE (1<<0)

///from base of /datum/element/after_attack/Attach(): (datum/sender, proc_ref)
#define COMSIG_ITEM_REGISTER_AFTERATTACK "register_item_afterattack"
///from base of /datum/element/after_attack/Detach(): (proc_ref)
#define COMSIG_ITEM_UNREGISTER_AFTERATTACK "unregister_item_afterattack"


///From base of datum/controller/subsystem/Initialize
#define COMSIG_SUBSYSTEM_POST_INITIALIZE "subsystem_post_initialize"
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#define MECHA_EQUIPMENT_TRAIT "mecha-equip"
#define HIS_GRACE_TRAIT "his-grace"
#define CHAINSAW_TRAIT "chainsaw-wield"
#define CENTCOMM_RAPIER_TRAIT "centcomm_rapier"
#define PYRO_CLAWS_TRAIT "pyro-claws"
#define CONTRACTOR_BATON_TRAIT "contractor-baton"
#define MUZZLE_TRAIT "muzzle"
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
mark_target(target)
return .

afterattack(target, user, TRUE, params)
afterattack(target, user, TRUE, params, .)
mark_target(target)

/// Used to mark a target for the demo system during a melee attack chain, call this before return
Expand Down
4 changes: 4 additions & 0 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@
var/obj/item/clothing/shoes/magboots/gravity/G = target
G.dash(usr)

/datum/action/item_action/toggle_rapier_nodrop
name = "Toggle Anti-Drop"
desc = "Activates/deactivates CentComm rapier Anti-Drop."

///prset for organ actions
/datum/action/item_action/organ_action
check_flags = AB_CHECK_CONSCIOUS
Expand Down
43 changes: 43 additions & 0 deletions code/datums/components/after_attacks_hub.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/datum/component/after_attacks_hub
dupe_mode = COMPONENT_DUPE_UNIQUE
/// List of after-attack effects for various items
var/list/after_attacks

/datum/component/after_attacks_hub/Initialize(...)
. = ..()
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE


/datum/component/after_attacks_hub/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ITEM_AFTERATTACK, PROC_REF(on_after_attack))
RegisterSignal(parent, COMSIG_ITEM_REGISTER_AFTERATTACK, PROC_REF(on_register_after_attack))
RegisterSignal(parent, COMSIG_ITEM_UNREGISTER_AFTERATTACK, PROC_REF(on_unregister_after_attack))


/datum/component/after_attacks_hub/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, list(
COMSIG_ITEM_AFTERATTACK,
COMSIG_ITEM_REGISTER_AFTERATTACK,
COMSIG_ITEM_UNREGISTER_AFTERATTACK
))


/datum/component/after_attacks_hub/proc/on_after_attack(datum/source, mob/living/target, mob/living/user, proximity, params, status)
SIGNAL_HANDLER
for(var/after_attack in after_attacks)
INVOKE_ASYNC(after_attack, TYPE_PROC_REF(/datum/element/after_attack, on_attack), source, target, user, proximity, params, status)


/datum/component/after_attacks_hub/proc/on_register_after_attack(datum/source, datum/sender)
SIGNAL_HANDLER
LAZYADD(after_attacks, sender)


/datum/component/after_attacks_hub/proc/on_unregister_after_attack(datum/source, datum/sender)
SIGNAL_HANDLER
LAZYREMOVE(after_attacks, sender)
if(!after_attacks)
qdel(src)
39 changes: 39 additions & 0 deletions code/datums/elements/after_attack/_after_attack.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Ancestor class for various post-attack effects. Requires /datum/component/after_attacks_hub for on_attack proc work
*/

/datum/element/after_attack
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY|ELEMENT_BESPOKE
id_arg_index = 2
/// Does the effect differ between a block and a successful attack
var/has_block_different_effect = TRUE


/datum/element/after_attack/Attach(datum/target)
. = ..()
target.AddComponent(/datum/component/after_attacks_hub)
SEND_SIGNAL(target, COMSIG_ITEM_REGISTER_AFTERATTACK, src)

/datum/element/after_attack/Detach(datum/source, force)
SEND_SIGNAL(source, COMSIG_ITEM_UNREGISTER_AFTERATTACK, src)
. = ..()

/datum/element/after_attack/proc/on_attack(datum/source, mob/living/target, mob/living/user, proximity, params, status)
SIGNAL_HANDLER

if(!status)
return

if(!has_block_different_effect || ATTACK_CHAIN_SUCCESS_CHECK(status))
on_success(source, target, user, proximity, params)
return

on_block(source, target, user, proximity, params)


/datum/element/after_attack/proc/on_success(datum/source, mob/living/target, mob/living/user, proximity, params)
return


/datum/element/after_attack/proc/on_block(datum/source, mob/living/target, mob/living/user, proximity, params)
return
28 changes: 28 additions & 0 deletions code/datums/elements/after_attack/attack_effect_sleep.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/datum/element/after_attack/attack_effect_sleep
/// How much stamina damage we deal on a successful hit against a living, non-cyborg mob.
var/stamina_damage
/// How long will the victim sleep.
var/sleep_time


/datum/element/after_attack/attack_effect_sleep/Attach(datum/target, stamina_damage, sleep_time)
. = ..()
src.stamina_damage = stamina_damage
src.sleep_time = sleep_time



/datum/element/after_attack/attack_effect_sleep/on_success(datum/source, mob/living/target, mob/living/user, proximity, params)
..()

if(!target || !user || !istype(target))
return

if(target.incapacitated(INC_IGNORE_RESTRAINED|INC_IGNORE_GRABBED))
target.visible_message(
span_danger("[user] puts [target] to sleep with [source]!"),
span_userdanger("You suddenly feel very drowsy!"),
)
target.Sleeping(sleep_time)
add_attack_logs(user, target, "put to sleep with [source]")
target.apply_damage(stamina_damage, STAMINA)
3 changes: 2 additions & 1 deletion code/datums/outfits/outfit_admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@

uniform = /obj/item/clothing/under/rank/centcom/captain
back = /obj/item/storage/backpack/satchel
belt = /obj/item/gun/energy/pulse/pistol
belt = /obj/item/storage/belt/rapier/centcomm
gloves = /obj/item/clothing/gloves/color/white
shoes = /obj/item/clothing/shoes/centcom
head = /obj/item/clothing/head/beret/centcom/captain
Expand All @@ -281,6 +281,7 @@
pda = /obj/item/pda/centcom
backpack_contents = list(
/obj/item/storage/box/centcomofficer = 1,
/obj/item/gun/energy/pulse/pistol = 1,
/obj/item/implanter/death_alarm = 1
)
implants = list(
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/cult/cult_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
* If they are blocked, and the shield has an illusion charge, an illusion will be spawned at src.
* The illusion has a 60% chance to be hostile and attack non-cultists, and a 40% chance to just run away from the user.
*/
/obj/item/shield/mirror/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/shield/mirror/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if(iscultist(owner)) // Cultist holding the shield

// Hit by a projectile
Expand Down Expand Up @@ -673,7 +673,7 @@
playsound(T, 'sound/effects/glassbr3.ogg', 100)
qdel(src)

/obj/item/twohanded/cult_spear/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/twohanded/cult_spear/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if(wielded)
final_block_chance *= 2
if(prob(final_block_chance))
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/miniantags/abduction/abduction_gear.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
M.name_override = null
M.regenerate_icons()

/obj/item/clothing/suit/armor/abductor/vest/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/clothing/suit/armor/abductor/vest/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
DeactivateStealth()

/obj/item/clothing/suit/armor/abductor/vest/IsReflect()
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/steal_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ GLOBAL_LIST_INIT(ungibbable_items_types, get_ungibbable_items_types())
/datum/theft_objective/highrisk/captains_rapier
id = "cap_rapier"
name = "the captain's rapier"
typepath = /obj/item/melee/rapier
typepath = /obj/item/melee/rapier/captain
protected_jobs = list(JOB_TITLE_CAPTAIN)

/datum/theft_objective/highrisk/hoslaser
Expand Down
1 change: 1 addition & 0 deletions code/game/jobs/job/central.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
jobtype = /datum/job/ntspecops/supreme

suit = /obj/item/clothing/suit/space/deathsquad/officer/supreme
belt = /obj/item/storage/belt/rapier/centcomm
head = /obj/item/clothing/head/helmet/space/deathsquad/beret/supreme
shoes = /obj/item/clothing/shoes/cowboy/white
gloves = /obj/item/clothing/gloves/color/white
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/HolodeckControl.dm
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@
..()
item_color = "red"

/obj/item/holo/esword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/holo/esword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if(active)
return ..()
return 0
Expand Down
9 changes: 6 additions & 3 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/g
var/breakouttime = 0

var/block_chance = 0
var/block_type = ALL
var/hit_reaction_chance = 0 //If you want to have something unrelated to blocking/armour piercing etc. Maybe not needed, but trying to think ahead/allow more freedom

// Needs to be in /obj/item because corgis can wear a lot of
Expand Down Expand Up @@ -339,8 +340,8 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/g
..()


/obj/item/proc/afterattack(atom/target, mob/user, proximity, params)
SEND_SIGNAL(src, COMSIG_ITEM_AFTERATTACK, target, user, proximity, params)
/obj/item/proc/afterattack(atom/target, mob/user, proximity, params, status)
SEND_SIGNAL(src, COMSIG_ITEM_AFTERATTACK, target, user, proximity, params, status)


/obj/item/attack_hand(mob/user, pickupfireoverride = FALSE)
Expand Down Expand Up @@ -504,7 +505,9 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/g
return ..()


/obj/item/proc/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/proc/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if (!block_type || !(block_type & attack_type))
final_block_chance = 0
var/signal_result = (SEND_SIGNAL(src, COMSIG_ITEM_HIT_REACT, owner, hitby, damage, attack_type) & COMPONENT_BLOCK_SUCCESSFUL) + prob(final_block_chance)
if(signal_result != 0)
owner.visible_message(span_danger("[owner] blocks [attack_text] with [src]!"))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/handheld_defib.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
if(istype(I, /obj/item/clothing/suit/space) && !shield_ignore)
if(istype(I, /obj/item/clothing/suit/space/hardsuit))
var/obj/item/clothing/suit/space/hardsuit/hardsuit = I
blocked = hardsuit.hit_reaction(user, src, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
blocked = hardsuit.hit_reaction(user, src, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if(cooldown)
to_chat(user, span_warning("[src] is still charging!"))
return .
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
if(used)
. += span_warning("Something sinister is strapped to this card. It looks like it was once masked with some sort of cloaking field, which is now nonfunctional.")

/obj/item/syndicate_reverse_card/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/syndicate_reverse_card/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if(attack_type != PROJECTILE_ATTACK)
return FALSE //this means the attack goes through
if(istype(hitby, /obj/item/projectile))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/robot/robot_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/obj/item/borg/stun/attack(mob/living/carbon/human/target, mob/living/silicon/robot/user, params, def_zone, skip_attack_anim = FALSE)
. = ATTACK_CHAIN_PROCEED
if(ishuman(target) && target.check_shields(src, 0, "[target]'s [name]", MELEE_ATTACK))
if(ishuman(target) && target.check_shields(src, 0, "[target]'s [name]", ITEM_ATTACK))
playsound(target, 'sound/weapons/genhit.ogg', 50, TRUE)
return .

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/toys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
sharp_when_wielded = FALSE // It's a toy
needs_permit = FALSE

/obj/item/twohanded/dualsaber/toy/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/twohanded/dualsaber/toy/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
return 0

/obj/item/twohanded/dualsaber/toy/IsReflect()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/batons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

if(ishuman(target))
var/mob/living/carbon/human/human_target = target
if(human_target.check_shields(src, 0, "[user]'s [name]", MELEE_ATTACK))
if(human_target.check_shields(src, 0, "[user]'s [name]", ITEM_ATTACK))
return BATON_ATTACK_DONE
if(check_martial_counter(target, user))
return BATON_ATTACK_DONE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/flamethrower.dm
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
create_with_tank = TRUE


/obj/item/flamethrower/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/flamethrower/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
var/obj/item/projectile/P = hitby
if(ptank && damage && attack_type == PROJECTILE_ATTACK && P.damage_type != STAMINA && prob(15))
owner.visible_message("<span class='danger'>[attack_text] hits the fueltank on [owner]'s [src], rupturing it! What a shot!</span>")
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/grenades/chem_grenade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
addtimer(CALLBACK(src, PROC_REF(prime), user), det_time)


/obj/item/grenade/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/grenade/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
var/obj/item/projectile/P = hitby
if(damage && attack_type == PROJECTILE_ATTACK && P.damage_type != STAMINA && prob(15))
owner.visible_message("<span class='danger'>[attack_text] hits [owner]'s [src], setting it off! What a shot!</span>")
Expand Down
6 changes: 1 addition & 5 deletions code/game/objects/items/weapons/holy_weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,13 @@
w_class = WEIGHT_CLASS_BULKY
slot_flags = ITEM_SLOT_BELT|ITEM_SLOT_BACK
block_chance = 30
block_type = MELEE_ATTACKS
sharp = TRUE
embed_chance = 20
embedded_ignore_throwspeed_threshold = TRUE
hitsound = 'sound/weapons/bladeslice.ogg'
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")

/obj/item/nullrod/claymore/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)
final_block_chance = 0 //Don't bring a sword to a gunfight
return ..()

/obj/item/nullrod/claymore/darkblade
name = "dark blade"
icon_state = "cultblade"
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/weapons/melee/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
if(item_color == null)
item_color = pick("red", "blue", "green", "purple", "yellow", "pink", "darkblue", "orange")

/obj/item/melee/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)
/obj/item/melee/energy/sword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if(active)
return ..()
return 0
Expand Down Expand Up @@ -173,7 +173,7 @@
..()
item_color = null

/obj/item/melee/energy/sword/cyborg/saw/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/melee/energy/sword/cyborg/saw/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
return 0

/obj/item/melee/energy/sword/saber
Expand Down Expand Up @@ -241,7 +241,7 @@
update_icon(UPDATE_ICON_STATE)


/obj/item/melee/energy/sword/saber/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
/obj/item/melee/energy/sword/saber/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = ITEM_ATTACK)
if(!active)
return FALSE
. = ..()
Expand Down
Loading