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

[MIRROR] Gunpoint now blocks bumps, adds examine text and can be broken by shoving #607

Merged
merged 1 commit into from
Nov 13, 2023
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
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
#define COMSIG_LIVING_EARLY_UNARMED_ATTACK "human_pre_attack_hand"
/// from mob/living/*/UnarmedAttack(): (mob/living/source, atom/target, proximity, modifiers)
#define COMSIG_LIVING_UNARMED_ATTACK "living_unarmed_attack"
///From base of mob/living/MobBump(): (mob/bumped, mob/living/bumper)
#define COMSIG_LIVING_PRE_MOB_BUMP "movable_pre_bump"
#define COMPONENT_LIVING_BLOCK_PRE_MOB_BUMP (1<<0)
///From base of mob/living/MobBump() (mob/living)
#define COMSIG_LIVING_MOB_BUMP "living_mob_bump"
///From base of mob/living/Bump() (turf/closed)
Expand Down
41 changes: 40 additions & 1 deletion code/datums/components/gunpoint.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@
target = targ
weapon = wep

RegisterSignals(targ, list(COMSIG_MOB_ATTACK_HAND, COMSIG_MOB_ITEM_ATTACK, COMSIG_MOVABLE_MOVED, COMSIG_MOB_FIRED_GUN), PROC_REF(trigger_reaction))
RegisterSignals(targ, list(
COMSIG_MOB_ATTACK_HAND,
COMSIG_MOB_ITEM_ATTACK,
COMSIG_MOVABLE_MOVED,
COMSIG_MOB_FIRED_GUN,
COMSIG_MOVABLE_SET_GRAB_STATE,
COMSIG_LIVING_START_PULL), PROC_REF(trigger_reaction))
RegisterSignal(targ, COMSIG_ATOM_EXAMINE, PROC_REF(examine_target))
RegisterSignal(targ, COMSIG_LIVING_PRE_MOB_BUMP, PROC_REF(block_bumps_target))
RegisterSignals(targ, list(COMSIG_HUMAN_DISARM_HIT, COMSIG_LIVING_GET_PULLED), PROC_REF(cancel))
RegisterSignals(weapon, list(COMSIG_ITEM_DROPPED, COMSIG_ITEM_EQUIPPED), PROC_REF(cancel))

var/distance = min(get_dist(shooter, target), 1) // treat 0 distance as adjacent
Expand Down Expand Up @@ -77,13 +86,19 @@
RegisterSignal(parent, COMSIG_MOB_ATTACK_HAND, PROC_REF(check_shove))
RegisterSignal(parent, COMSIG_MOB_UPDATE_SIGHT, PROC_REF(check_deescalate))
RegisterSignals(parent, list(COMSIG_LIVING_START_PULL, COMSIG_MOVABLE_BUMP), PROC_REF(check_bump))
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(examine))
RegisterSignal(parent, COMSIG_LIVING_PRE_MOB_BUMP, PROC_REF(block_bumps_parent))
RegisterSignal(parent, COMSIG_HUMAN_DISARM_HIT, PROC_REF(cancel))

/datum/component/gunpoint/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_MOVABLE_MOVED)
UnregisterSignal(parent, COMSIG_MOB_APPLY_DAMAGE)
UnregisterSignal(parent, COMSIG_MOB_UPDATE_SIGHT)
UnregisterSignal(parent, COMSIG_MOB_ATTACK_HAND)
UnregisterSignal(parent, list(COMSIG_LIVING_START_PULL, COMSIG_MOVABLE_BUMP))
UnregisterSignal(parent, COMSIG_ATOM_EXAMINE)
UnregisterSignal(parent, COMSIG_LIVING_PRE_MOB_BUMP)
UnregisterSignal(parent, COMSIG_HUMAN_DISARM_HIT)

///If the shooter bumps the target, cancel the holdup to avoid cheesing and forcing the charged shot
/datum/component/gunpoint/proc/check_bump(atom/B, atom/A)
Expand Down Expand Up @@ -195,6 +210,30 @@
)
INVOKE_ASYNC(src, PROC_REF(trigger_reaction))

///Shows if the parent is holding someone at gunpoint
/datum/component/gunpoint/proc/examine(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER
if(user in viewers(target))
examine_list += span_boldwarning("[parent] [parent.p_are()] holding [target] at gunpoint with [weapon]!")

///Shows if the examine target is being held at gunpoint
/datum/component/gunpoint/proc/examine_target(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER
if(user in viewers(parent))
examine_list += span_boldwarning("[target] [target.p_are()] being held at gunpoint by [parent]!")

///Prevents bumping the shooter to break gunpoint since shove does that
/datum/component/gunpoint/proc/block_bumps_parent(mob/bumped, mob/living/bumper)
SIGNAL_HANDLER
to_chat(bumper, span_warning("[bumped] [bumped.p_are()] holding [target] at gunpoint, you cannot push past."))
return COMPONENT_LIVING_BLOCK_PRE_MOB_BUMP

///Prevents bumping the target by an ally to cheese and force the charged shot
/datum/component/gunpoint/proc/block_bumps_target(mob/bumped, mob/living/bumper)
SIGNAL_HANDLER
to_chat(bumper, span_warning("[bumped] [bumped.p_are()] being held at gunpoint, it's not wise to push [bumped.p_them()]!"))
return COMPONENT_LIVING_BLOCK_PRE_MOB_BUMP

#undef GUNPOINT_DELAY_STAGE_2
#undef GUNPOINT_DELAY_STAGE_3
#undef GUNPOINT_BASE_WOUND_BONUS
Expand Down
9 changes: 8 additions & 1 deletion code/datums/status_effects/neutral.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,16 @@

/atom/movable/screen/alert/status_effect/holdup
name = "Holding Up"
desc = "You're currently pointing a gun at someone."
desc = "You're currently pointing a gun at someone. Click to cancel."
icon_state = "aimed"

/atom/movable/screen/alert/status_effect/holdup/Click(location, control, params)
. = ..()
if(!.)
return
var/datum/component/gunpoint/gunpoint = owner.GetComponent(/datum/component/gunpoint)
gunpoint?.cancel()

// this status effect is used to negotiate the high-fiving capabilities of all concerned parties
/datum/status_effect/offering
id = "offering"
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
if(move_intent == MOVE_INTENT_WALK)
return TRUE

if(SEND_SIGNAL(M, COMSIG_LIVING_PRE_MOB_BUMP, src) & COMPONENT_LIVING_BLOCK_PRE_MOB_BUMP)
return TRUE

SEND_SIGNAL(src, COMSIG_LIVING_MOB_BUMP, M)
//Even if we don't push/swap places, we "touched" them, so spread fire
spreadFire(M)
Expand Down
Loading