[MIRROR] Unarmed Attack Fixes (#10111)

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-02-08 16:04:03 -07:00
committed by GitHub
parent 626aa639b6
commit 2894f64c83
6 changed files with 55 additions and 40 deletions

View File

@@ -79,19 +79,24 @@
var/obj/mecha/M = loc
return M.click_action(A, src, params)
/// So, this entire restrained check pretty much tells the rest of the code below you are restrained.
/// Primarily, this is just so you can do unarmed attacks while restrained (bites)
/// However, if you wanted to add some special interaction to objects or anything OTHER than mobs, use 'RestrainedClickOn' instead
/// If you want some interesting restrained interaction HERE, add it here.
var/currently_restrained = FALSE
if(restrained())
setClickCooldown(10)
RestrainedClickOn(A)
return 1
currently_restrained = TRUE
if(in_throw_mode && (isturf(A) || isturf(A.loc)) && throw_item(A))
if(!currently_restrained && in_throw_mode && (isturf(A) || isturf(A.loc)) && throw_item(A))
trigger_aiming(TARGET_CAN_CLICK)
throw_mode_off()
return TRUE
var/obj/item/W = get_active_hand()
if(W == A) // Handle attack_self
if(!currently_restrained && W == A) // Handle attack_self
W.attack_self(src)
trigger_aiming(TARGET_CAN_CLICK)
update_inv_active_hand(0)
@@ -100,7 +105,7 @@
//Atoms on your person
// A is your location but is not a turf; or is on you (backpack); or is on something on you (box in backpack); sdepth is needed here because contents depth does not equate inventory storage depth.
var/sdepth = A.storage_depth(src)
if((!isturf(A) && A == loc) || (sdepth <= MAX_STORAGE_REACH)) // CHOMPedit: Boxes can be interacted with inside of larger inventories.
if(!currently_restrained && ((!isturf(A) && A == loc) || (sdepth <= MAX_STORAGE_REACH))) // CHOMPedit: Boxes can be interacted with inside of larger inventories.
if(W)
var/resolved = W.resolve_attackby(A, src, click_parameters = params)
if(!resolved && A && W)
@@ -114,7 +119,7 @@
return 1
// VOREStation Addition Start: inbelly item interaction
if(isbelly(loc) && (loc == A.loc))
if(!currently_restrained && isbelly(loc) && (loc == A.loc))
if(W)
var/resolved = W.resolve_attackby(A,src)
if(!resolved && A && W)
@@ -133,25 +138,32 @@
// A is a turf or is on a turf, or in something on a turf (pen in a box); but not something in something on a turf (pen in a box in a backpack)
sdepth = A.storage_depth_turf()
if(isturf(A) || isturf(A.loc) || (sdepth <= MAX_STORAGE_REACH)) // CHOMPedit: Storage reach depth.
if(A.Adjacent(src) || (W && W.attack_can_reach(src, A, W.reach)) ) // see adjacent.dm
if(W)
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
var/resolved = W.resolve_attackby(A,src, click_parameters = params)
if(!resolved && A && W)
W.afterattack(A, src, 1, params) // 1: clicking something Adjacent
else
if(ismob(A)) // No instant mob attacking
setClickCooldown(get_attack_speed())
if(currently_restrained)
if(ismob(A) && A.Adjacent(src)) //We are RESTRAINED (handcuffed or otherwise) and ADJACENT
setClickCooldown(get_attack_speed())
UnarmedAttack(A, 1)
trigger_aiming(TARGET_CAN_CLICK)
return
else // non-adjacent click
if(W)
W.afterattack(A, src, 0, params) // 0: not Adjacent
else
RangedAttack(A, params)
trigger_aiming(TARGET_CAN_CLICK)
return
else
if(!currently_restrained && A.Adjacent(src) || (W && W.attack_can_reach(src, A, W.reach)) ) // see adjacent.dm
if(W && !restrained())
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
var/resolved = W.resolve_attackby(A,src, click_parameters = params)
if(!resolved && A && W)
W.afterattack(A, src, 1, params) // 1: clicking something Adjacent
else
if(ismob(A)) // No instant mob attacking
setClickCooldown(get_attack_speed())
UnarmedAttack(A, 1)
trigger_aiming(TARGET_CAN_CLICK)
return
else // non-adjacent click
if(W)
W.afterattack(A, src, 0, params) // 0: not Adjacent
else
RangedAttack(A, params)
trigger_aiming(TARGET_CAN_CLICK)
trigger_aiming(TARGET_CAN_CLICK)
return 1
/mob/proc/setClickCooldown(var/timeout)

View File

@@ -148,6 +148,7 @@
/datum/unarmed_attack/holopugilism
sparring_variant_type = /datum/unarmed_attack/holopugilism
is_punch = TRUE
/datum/unarmed_attack/holopugilism/unarmed_override(var/mob/living/carbon/human/user,var/mob/living/carbon/human/target,var/zone)
user.do_attack_animation(src)

View File

@@ -267,7 +267,7 @@
var/real_damage = rand_damage
var/hit_dam_type = attack.damage_type
real_damage += attack.get_unarmed_damage(H)
if(H.gloves)
if(H.gloves && attack.is_punch)
if(istype(H.gloves, /obj/item/clothing/gloves))
var/obj/item/clothing/gloves/G = H.gloves
real_damage += G.punch_force

View File

@@ -12,6 +12,7 @@
attack_noun = list("tendril")
eye_attack_text = "a tendril"
eye_attack_text_victim = "a tendril"
is_punch = TRUE
/datum/unarmed_attack/claws
attack_name = "claws"

View File

@@ -1,4 +1,5 @@
/datum/unarmed_attack/bite/sharp/numbing //Is using this against someone you are truly trying to fight a bad idea? Yes. Yes it is.
attack_name = "numbing bite"
attack_verb = list("bit")
attack_noun = list("fangs")
attack_sound = 'sound/weapons/bite.ogg'

View File

@@ -8,11 +8,12 @@ var/global/list/sparring_attack_cache = list()
var/damage = 0 // Extra empty hand attack damage.
var/attack_sound = "punch"
var/miss_sound = 'sound/weapons/punchmiss.ogg'
var/shredding = 0 // Calls the old attack_alien() behavior on objects/mobs when on harm intent.
var/shredding = FALSE // Calls the old attack_alien() behavior on objects/mobs when on harm intent.
var/sharp = FALSE
var/edge = FALSE
var/damage_type = BRUTE
var/is_punch = FALSE //If the attack benefits from the damage increase things being on your hands give.
var/sparring_variant_type = /datum/unarmed_attack/light_strike
var/eye_attack_text
@@ -113,20 +114,21 @@ var/global/list/sparring_attack_cache = list()
attack_name = "bite"
attack_verb = list("bit")
attack_sound = 'sound/weapons/bite.ogg'
shredding = 0
damage = 0
sharp = FALSE
edge = FALSE
//sharp = TRUE //Enable if you want bites to make people bleed.
//germ_increase = 10 //Amount of germs each bite will give to the person.
/datum/unarmed_attack/bite/event1
/datum/unarmed_attack/bite/is_usable(var/mob/living/carbon/human/user, var/mob/living/carbon/human/target, var/zone)
if (user.is_muzzled())
return 0
if (user == target && (zone == BP_HEAD || zone == O_EYES || zone == O_MOUTH))
return 0
return TRUE
if (user.is_muzzled() || user.buckled)
return FALSE
if (user == target && ((zone == BP_GROIN && (prob(98)) || (zone == BP_HEAD || zone == O_EYES || zone == O_MOUTH)))) //biting your own groin is hard. 2% hit chance.
return FALSE
for(var/obj/item/organ/external/head/user_head in user.organs) //We have a head!
if(!user_head.dislocated && !(user_head.status & ORGAN_BROKEN)) //And it's not dislocated
return TRUE
return FALSE
/datum/unarmed_attack/punch
attack_name = "punch"
@@ -135,6 +137,7 @@ var/global/list/sparring_attack_cache = list()
eye_attack_text = "fingers"
eye_attack_text_victim = "digits"
damage = 0
is_punch = TRUE
/datum/unarmed_attack/punch/event1
@@ -149,7 +152,7 @@ var/global/list/sparring_attack_cache = list()
if(target == user)
user.visible_message(span_danger("[user] [pick(attack_verb)] [TU.himself] in the [organ]!"))
return 0
return FALSE
if(!target.lying)
switch(zone)
@@ -193,7 +196,7 @@ var/global/list/sparring_attack_cache = list()
/datum/unarmed_attack/kick/event1
/datum/unarmed_attack/kick/is_usable(var/mob/living/carbon/human/user, var/mob/living/carbon/human/target, var/zone)
if (user.legcuffed)
if(user.legcuffed || user.buckled)
return FALSE
if(!(zone in list("l_leg", "r_leg", "l_foot", "r_foot", BP_GROIN)))
@@ -238,7 +241,7 @@ var/global/list/sparring_attack_cache = list()
/datum/unarmed_attack/stomp/is_usable(var/mob/living/carbon/human/user, var/mob/living/carbon/human/target, var/zone)
if (user.legcuffed)
if (user.legcuffed || user.buckled)
return FALSE
if(!istype(target))
@@ -279,7 +282,4 @@ var/global/list/sparring_attack_cache = list()
attack_verb = list("tapped", "lightly struck")
damage = 3
damage_type = HALLOSS
shredding = 0
damage = 0
sharp = FALSE
edge = FALSE
is_punch = TRUE