This commit is contained in:
silicons
2020-07-24 20:19:18 -07:00
parent 64de8f16a9
commit 33d5ba788b
7 changed files with 58 additions and 16 deletions
+6 -1
View File
@@ -2,11 +2,16 @@
/// The attack is from a parry counterattack.
#define ATTACKCHAIN_PARRY_COUNTERATTACK (1<<0)
// melee_attack_chain(), attackby(), pre_attack(), afterattack(), and tool_act() return values.
// melee_attack_chain(), attackby(), pre_attack(), afterattack(), and tool_act(), attack() and **anything that is called by ClickOn()** return values.
/// Stop the attack chain if still in melee_attack_chain()
#define STOP_ATTACK_PROC_CHAIN (1<<0)
/// This attack should discard last_action instead of flushing (storing) it). You should probably know what you're doing if you use this considering this is how clickdelay is enforced.
#define DISCARD_LAST_ACTION (1<<1)
/// There are a number of "safety nets" intended to default-handle clickdelay. Return this flag to bypass ALL of them. Be sure
/// you know EXACTLY what you are doing!
#define NO_AUTO_CLICKDELAY_HANDLING (1<<2)
/// Only used with UnarmedAttack(). Interrupts unarmed attack from progressing.
#define INTERRUPT_UNARMED_ATTACK (1<<3)
// UnarmedAttack() flags
/// Attack is from a parry counterattack
+7 -1
View File
@@ -107,6 +107,9 @@
. = W.melee_attack_chain(src, A, params)
return !(. & DISCARD_LAST_ACTION)
else
. = UnarmedAttack(A)
if(!(. & NO_AUTO_CLICKDELAY_HANDLING))
DelayNextAction(CLICK_CD_MELEE)
return UnarmedAttack(A)? TRUE : FALSE
//Can't reach anything else in lockers or other weirdness
@@ -119,7 +122,10 @@
. = W.melee_attack_chain(src, A, params)
return !(. & DISCARD_LAST_ACTION)
else
return UnarmedAttack(A, 1)? TRUE : FALSE
. = UnarmedAttack(A)
if(!(. & NO_AUTO_CLICKDELAY_HANDLING))
DelayNextAction(CLICK_CD_MELEE)
return UnarmedAttack(A)? TRUE : FALSE
else
if(W)
W.ranged_attack_chain(src, A, params)
+27 -5
View File
@@ -59,7 +59,20 @@
if(. & STOP_ATTACK_PROC_CHAIN)
return
. |= I.attack(src, user, attackchain_flags, damage_multiplier)
if(!(. & NO_AUTO_CLICKDELAY_HANDLING)) // SAFETY NET - unless the proc tells us we should not handle this, give them the basic melee cooldown!
I.ApplyAttackCooldown(user, src)
/**
* Called when someone uses us to attack a mob in melee combat.
*
* This proc respects CheckAttackCooldown() default clickdelay handling.
*
* @params
* * mob/living/M - target
* * mob/living/user - attacker
* * attackchain_Flags - see [code/__DEFINES/_flags/return_values.dm]
* * damage_multiplier - what to multiply the damage by
*/
/obj/item/proc/attack(mob/living/M, mob/living/user, attackchain_flags = NONE, damage_multiplier = 1)
if(SEND_SIGNAL(src, COMSIG_ITEM_ATTACK, M, user) & COMPONENT_ITEM_NO_ATTACK)
return
@@ -80,7 +93,6 @@
user.do_attack_animation(M)
M.attacked_by(src, user, attackchain_flags, damage_multiplier)
ApplyAttackCooldown(user, M)
log_combat(user, M, "attacked", src.name, "(INTENT: [uppertext(user.a_intent)]) (DAMTYPE: [uppertext(damtype)])")
add_fingerprint(user)
@@ -97,7 +109,6 @@
return
user.do_attack_animation(O)
O.attacked_by(src, user)
ApplyAttackCooldown(user, O)
var/weight = getweight(user, STAM_COST_ATTACK_OBJ_MULT)
if(weight)
user.adjustStaminaLossBuffered(weight)//CIT CHANGE - makes attacking things cause stamina loss
@@ -124,7 +135,7 @@
if(!(SKILL_TRAIN_ATTACK_OBJ in I.used_skills[skill]))
continue
user.mind.auto_gain_experience(skill, I.skill_gain)
I.ApplyAttackCooldown(user, src)
if(totitemdamage)
visible_message("<span class='danger'>[user] has hit [src] with [I]!</span>", null, null, COMBAT_MESSAGE_RANGE)
//only witnesses close by and the victim see a hit message.
@@ -190,9 +201,20 @@
var/datum/skill/S = GLOB.skill_datums[skill]
user.mind.auto_gain_experience(skill, I.skill_gain*S.item_skill_gain_multi)
// Proximity_flag is 1 if this afterattack was called on something adjacent, in your square, or on your person.
// Click parameters is the params string from byond Click() code, see that documentation.
/**
* Called after attacking something if the melee attack chain isn't interrupted before.
* Also called when clicking on something with an item without being in melee range
*
* WARNING: This does not automatically check clickdelay if not in a melee attack! Be sure to account for this!
*
* @params
* * target - The thing we clicked
* * user - mob of person clicking
* * proximity_flag - are we in melee range/doing it in a melee attack
* * click_parameters - mouse control parameters, check BYOND ref.
*/
/obj/item/proc/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
SHOULD_CALL_PARENT(TRUE)
SEND_SIGNAL(src, COMSIG_ITEM_AFTERATTACK, target, user, proximity_flag, click_parameters)
SEND_SIGNAL(user, COMSIG_MOB_ITEM_AFTERATTACK, target, user, proximity_flag, click_parameters)
+7 -5
View File
@@ -20,15 +20,17 @@
// If the gloves do anything, have them return 1 to stop
// normal attack_hand() here.
var/obj/item/clothing/gloves/G = gloves // not typecast specifically enough in defines
if(proximity && istype(G) && (. = G.Touch(A,1)))
return
if(proximity && istype(G))
. |= G.Touch(A, TRUE)
if(. & INTERRUPT_UNARMED_ATTACK)
return
var/override = 0
. = NONE
for(var/datum/mutation/human/HM in dna.mutations)
override += HM.on_attack_hand(A, proximity, intent, flags)
. |= HM.on_attack_hand(A, proximity, intent, flags)
if(override)
if(. & INTERRUPT_UNARMED_ATTACK)
return
SEND_SIGNAL(src, COMSIG_HUMAN_MELEE_UNARMED_ATTACK, A)
+8 -2
View File
@@ -40,7 +40,10 @@
return !(. & DISCARD_LAST_ACTION)
else
if(!AltUnarmedAttack(A))
return UnarmedAttack(A, 1)? TRUE : FALSE
. = UnarmedAttack(A)
if(!(. & NO_AUTO_CLICKDELAY_HANDLING))
DelayNextAction(CLICK_CD_MELEE)
return UnarmedAttack(A)? TRUE : FALSE
//Can't reach anything else in lockers or other weirdness
if(!loc.AllowClick())
@@ -53,7 +56,10 @@
return !(. & DISCARD_LAST_ACTION)
else
if(!AltUnarmedAttack(A,1))
return UnarmedAttack(A, 1)? TRUE : FALSE
. = UnarmedAttack(A)
if(!(. & NO_AUTO_CLICKDELAY_HANDLING))
DelayNextAction(CLICK_CD_MELEE)
return UnarmedAttack(A)? TRUE : FALSE
else
if(W)
if(!W.altafterattack(A, src, FALSE, params))
@@ -109,7 +109,7 @@
if(warcry)
M.say("[warcry]", ignore_spam = TRUE, forced = TRUE)
return FALSE
return NO_AUTO_CLICKDELAY_HANDLING
/obj/item/clothing/gloves/fingerless/pugilist/rapid/AltClick(mob/user)
var/input = stripped_input(user,"What do you want your battlecry to be? Max length of 6 characters.", ,"", 7)
@@ -137,7 +137,7 @@
else
M.SetNextAction(CLICK_CD_RAPID)
return FALSE
return NO_AUTO_CLICKDELAY_HANDLING
/obj/item/clothing/gloves/botanic_leather
name = "botanist's leather gloves"
+1
View File
@@ -67,6 +67,7 @@
to_chat(H, "<span class='notice'>Gained <B>[DisplayEnergy(.)]</B> of energy from [A].</span>")
else
to_chat(H, "<span class='danger'>\The [A] has run dry of energy, you must find another source!</span>")
. = INTERRUPT_UNARMED_ATTACK
else
. = FALSE //as to not cancel attack_hand()