From 67b518bf42d2ee7707c2da67337ddde106b93354 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Mon, 27 Jul 2020 13:09:54 -0700 Subject: [PATCH] experimental --- code/__DEFINES/_flags/return_values.dm | 20 ++++++++----------- code/_onclick/item_attack.dm | 15 +++++++------- code/_onclick/other_mobs.dm | 14 ++++++------- code/modules/clothing/gloves/miscellaneous.dm | 4 ++-- .../mob/living/carbon/carbon_defense.dm | 2 +- .../mob/living/carbon/human/human_defines.dm | 2 +- .../mob/living/carbon/human/species.dm | 12 +++++------ .../modules/mob/living/living_active_parry.dm | 2 +- code/modules/mob/living/living_defense.dm | 4 ++-- .../hostile/megafauna/blood_drunk_miner.dm | 10 +++++----- 10 files changed, 41 insertions(+), 44 deletions(-) diff --git a/code/__DEFINES/_flags/return_values.dm b/code/__DEFINES/_flags/return_values.dm index 80908fdc8e..28606265b3 100644 --- a/code/__DEFINES/_flags/return_values.dm +++ b/code/__DEFINES/_flags/return_values.dm @@ -1,8 +1,6 @@ -// melee_attack_chain() attackchain_flags -/// The attack is from a parry counterattack. -#define ATTACKCHAIN_PARRY_COUNTERATTACK (1<<0) - +/////////// ATTACKCHAIN_FLAGS //////////// // melee_attack_chain(), attackby(), pre_attack(), afterattack(), and tool_act(), attack() and **anything that is called by ClickOn()** return values. +// These are all passed down through the attack chain and are binary OR'd into each other! /// 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. @@ -12,14 +10,12 @@ #define NO_AUTO_CLICKDELAY_HANDLING (1<<2) /// Only used with UnarmedAttack(). Interrupts unarmed attack from progressing. #define INTERRUPT_UNARMED_ATTACK (1<<3) -/// Attack hand should not set next action even if the atom wants it to be an action -#define ATTACK_HAND_IGNORE_ACTION (1<<4) -/// Attack hand should not at all check last_action/attack_hand_speed even if the atom wants to -#define ATTACK_HAND_IGNORE_CLICKDELAY (1<<5) - -// UnarmedAttack() flags -/// Attack is from a parry counterattack -#define UNARMED_ATTACK_PARRY (1<<0) +/// Attack should not set next action even if the atom wants it to be an action +#define ATTACK_IGNORE_ACTION (1<<4) +/// Attack should not at all check last_action/attack_hand_speed even if the atom wants to +#define ATTACK_IGNORE_CLICKDELAY (1<<5) +/// This attack is from a parry counterattack +#define ATTACK_IS_PARRY_COUNTERATTACK (1<<6) // obj/item/dropped() /// dropped() relocated this item, return FALSE for doUnEquip. diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 95f3fa5f1e..a669f9024f 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -7,17 +7,18 @@ *and lastly *afterattack. The return value does not matter. */ -/obj/item/proc/melee_attack_chain(mob/user, atom/target, params, flags, damage_multiplier = 1) +/obj/item/proc/melee_attack_chain(mob/user, atom/target, params, attackchain_flags, damage_multiplier = 1) if(isliving(user)) var/mob/living/L = user - if(!CHECK_MOBILITY(L, MOBILITY_USE) && !(flags & ATTACKCHAIN_PARRY_COUNTERATTACK)) + if(!CHECK_MOBILITY(L, MOBILITY_USE) && !(attackchain_flags & ATTACK_IS_PARRY_COUNTERATTACK)) to_chat(L, "You are unable to swing [src] right now!") return + . = attackchain_flags if(tool_behaviour && ((. = target.tool_act(user, src, tool_behaviour)) & STOP_ATTACK_PROC_CHAIN)) return - if((. |= pre_attack(target, user, params)) & STOP_ATTACK_PROC_CHAIN) + if((. |= pre_attack(target, user, params, ., damage_multiplier)) & STOP_ATTACK_PROC_CHAIN) return - if((. |= target.attackby(src, user, params, flags, damage_multiplier)) & STOP_ATTACK_PROC_CHAIN) + if((. |= target.attackby(src, user, params, ., damage_multiplier)) & STOP_ATTACK_PROC_CHAIN) return if(QDELETED(src) || QDELETED(target)) return @@ -38,10 +39,10 @@ return interact(user) -/obj/item/proc/pre_attack(atom/A, mob/living/user, params) //do stuff before attackby! +/obj/item/proc/pre_attack(atom/A, mob/living/user, params, attackchain_flags, damage_multiplier) //do stuff before attackby! if(SEND_SIGNAL(src, COMSIG_ITEM_PRE_ATTACK, A, user, params) & COMPONENT_NO_ATTACK) return STOP_ATTACK_PROC_CHAIN - if(!CheckAttackCooldown(user, A)) + if(!(attackchain_flags & ATTACK_IGNORE_CLICKDELAY) && !CheckAttackCooldown(user, A)) return STOP_ATTACK_PROC_CHAIN // No comment @@ -148,7 +149,7 @@ /mob/living/attacked_by(obj/item/I, mob/living/user, attackchain_flags = NONE, damage_multiplier = 1) var/list/block_return = list() var/totitemdamage = pre_attacked_by(I, user) * damage_multiplier - if((user != src) && mob_run_block(I, totitemdamage, "the [I.name]", ((attackchain_flags & ATTACKCHAIN_PARRY_COUNTERATTACK)? ATTACK_TYPE_PARRY_COUNTERATTACK : NONE) | ATTACK_TYPE_MELEE, I.armour_penetration, user, null, block_return) & BLOCK_SUCCESS) + if((user != src) && mob_run_block(I, totitemdamage, "the [I.name]", ((attackchain_flags & ATTACK_IS_PARRY_COUNTERATTACK)? ATTACK_IS_PARRY_COUNTERATTACK : NONE) | ATTACK_TYPE_MELEE, I.armour_penetration, user, null, block_return) & BLOCK_SUCCESS) return FALSE totitemdamage = block_calculate_resultant_damage(totitemdamage, block_return) send_item_attack_message(I, user, null, totitemdamage) diff --git a/code/_onclick/other_mobs.dm b/code/_onclick/other_mobs.dm index 6cbcd4dbb0..0c950bf327 100644 --- a/code/_onclick/other_mobs.dm +++ b/code/_onclick/other_mobs.dm @@ -16,7 +16,7 @@ to_chat(src, "The damage in your [check_arm.name] is preventing you from using it! Get it fixed, or at least splinted!") return - . = NONE + . = flags // Special glove functions: // If the gloves do anything, have them return 1 to stop @@ -28,27 +28,27 @@ return for(var/datum/mutation/human/HM in dna.mutations) - . |= HM.on_attack_hand(A, proximity, intent, flags) + . |= HM.on_attack_hand(A, proximity, intent, .) if(. & INTERRUPT_UNARMED_ATTACK) return SEND_SIGNAL(src, COMSIG_HUMAN_MELEE_UNARMED_ATTACK, A) - return . | A.attack_hand(src, intent, flags, .) + return . | A.attack_hand(src, intent, .) -/atom/proc/attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags, clickchain_flags) +/atom/proc/attack_hand(mob/user, act_intent = user.a_intent, flags) SHOULD_NOT_SLEEP(TRUE) if(!(interaction_flags_atom & INTERACT_ATOM_NO_FINGERPRINT_ATTACK_HAND)) add_fingerprint(user) if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_HAND, user) & COMPONENT_NO_ATTACK_HAND) return - if(attack_hand_speed && !(clickchain_flags & ATTACK_HAND_IGNORE_CLICKDELAY)) + if(attack_hand_speed && !(. & ATTACK_IGNORE_CLICKDELAY)) if(!user.CheckActionCooldown(attack_hand_speed)) return if(interaction_flags_atom & INTERACT_ATOM_ATTACK_HAND) . = _try_interact(user) - INVOKE_ASYNC(src, .proc/on_attack_hand, user, act_intent, unarmed_attack_flags) - if(!(clickchain_flags & ATTACK_HAND_IGNORE_ACTION)) + INVOKE_ASYNC(src, .proc/on_attack_hand, user, act_intent, .) + if(!(. & ATTACK_IGNORE_ACTION)) if(attack_hand_unwieldlyness) user.DelayNextAction(attack_hand_unwieldlyness, considered_action = attack_hand_is_action) else if(attack_hand_is_action) diff --git a/code/modules/clothing/gloves/miscellaneous.dm b/code/modules/clothing/gloves/miscellaneous.dm index df74f8e49e..5f5f228b00 100644 --- a/code/modules/clothing/gloves/miscellaneous.dm +++ b/code/modules/clothing/gloves/miscellaneous.dm @@ -109,7 +109,7 @@ if(warcry) M.say("[warcry]", ignore_spam = TRUE, forced = TRUE) - return NO_AUTO_CLICKDELAY_HANDLING | ATTACK_HAND_IGNORE_ACTION + return NO_AUTO_CLICKDELAY_HANDLING | ATTACK_IGNORE_ACTION /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 NO_AUTO_CLICKDELAY_HANDLING | ATTACK_HAND_IGNORE_ACTION + return NO_AUTO_CLICKDELAY_HANDLING | ATTACK_IGNORE_ACTION /obj/item/clothing/gloves/botanic_leather name = "botanist's leather gloves" diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 1b0aee04e4..ac261e6d5b 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -69,7 +69,7 @@ var/totitemdamage = pre_attacked_by(I, user) * damage_multiplier var/impacting_zone = (user == src)? check_zone(user.zone_selected) : ran_zone(user.zone_selected) var/list/block_return = list() - if((user != src) && (mob_run_block(I, totitemdamage, "the [I]", ((attackchain_flags & ATTACKCHAIN_PARRY_COUNTERATTACK)? ATTACK_TYPE_PARRY_COUNTERATTACK : NONE) | ATTACK_TYPE_MELEE, I.armour_penetration, user, impacting_zone, block_return) & BLOCK_SUCCESS)) + if((user != src) && (mob_run_block(I, totitemdamage, "the [I]", ((attackchain_flags & ATTACK_IS_PARRY_COUNTERATTACK)? ATTACK_TYPE_PARRY_COUNTERATTACK : NONE) | ATTACK_TYPE_MELEE, I.armour_penetration, user, impacting_zone, block_return) & BLOCK_SUCCESS)) return FALSE totitemdamage = block_calculate_resultant_damage(totitemdamage, block_return) var/obj/item/bodypart/affecting = get_bodypart(impacting_zone) diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index aea4ee2ead..a04fa1cbfe 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -110,7 +110,7 @@ return ..() visible_message("[src] strikes back perfectly at [attacker], staggering them!") if(D.parry_data["HUMAN_PARRY_PUNCH"]) - UnarmedAttack(attacker, TRUE, INTENT_HARM, UNARMED_ATTACK_PARRY) + UnarmedAttack(attacker, TRUE, INTENT_HARM, ATTACK_IS_PARRY_COUNTERATTACK | ATTACK_IGNORE_ACTION | ATTACK_IGNORE_CLICKDELAY | NO_AUTO_CLICKDELAY_HANDLING) var/mob/living/L = attacker if(istype(L)) L.Stagger(D.parry_data["HUMAN_PARRY_STAGGER"]) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index a2e2fb0a51..9ed191a4cf 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1445,7 +1445,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) target.grabbedby(user) return 1 -/datum/species/proc/harm(mob/living/carbon/human/user, mob/living/carbon/human/target, datum/martial_art/attacker_style, unarmed_attack_flags = NONE) +/datum/species/proc/harm(mob/living/carbon/human/user, mob/living/carbon/human/target, datum/martial_art/attacker_style, attackchain_flags = NONE) if(!attacker_style && HAS_TRAIT(user, TRAIT_PACIFISM)) to_chat(user, "You don't want to harm [target]!") return FALSE @@ -1457,7 +1457,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) target_message = "[target] blocks your attack!") return FALSE - if(!(unarmed_attack_flags & UNARMED_ATTACK_PARRY)) + if(!(attackchain_flags & ATTACK_IS_PARRY_COUNTERATTACK)) if(HAS_TRAIT(user, TRAIT_PUGILIST))//CITADEL CHANGE - makes punching cause staminaloss but funny martial artist types get a discount user.adjustStaminaLossBuffered(1.5) else @@ -1499,7 +1499,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) var/obj/item/bodypart/affecting = target.get_bodypart(ran_zone(user.zone_selected)) var/miss_chance = 100//calculate the odds that a punch misses entirely. considers stamina and brute damage of the puncher. punches miss by default to prevent weird cases - if(unarmed_attack_flags & UNARMED_ATTACK_PARRY) + if(attackchain_flags & ATTACK_IS_PARRY_COUNTERATTACK) miss_chance = 0 else if(user.dna.species.punchdamagelow) @@ -1686,7 +1686,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) /datum/species/proc/spec_hitby(atom/movable/AM, mob/living/carbon/human/H) return -/datum/species/proc/spec_attack_hand(mob/living/carbon/human/M, mob/living/carbon/human/H, datum/martial_art/attacker_style, act_intent, unarmed_attack_flags) +/datum/species/proc/spec_attack_hand(mob/living/carbon/human/M, mob/living/carbon/human/H, datum/martial_art/attacker_style, act_intent, attackchain_flags) if(!istype(M)) return CHECK_DNA_AND_SPECIES(M) @@ -1706,7 +1706,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) grab(M, H, attacker_style) if("harm") - harm(M, H, attacker_style, unarmed_attack_flags) + harm(M, H, attacker_style, attackchain_flags) if("disarm") disarm(M, H, attacker_style) @@ -1716,7 +1716,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) // Allows you to put in item-specific reactions based on species if(user != H) var/list/block_return = list() - if(H.mob_run_block(I, totitemdamage, "the [I.name]", ((attackchain_flags & ATTACKCHAIN_PARRY_COUNTERATTACK)? ATTACK_TYPE_PARRY_COUNTERATTACK : NONE) | ATTACK_TYPE_MELEE, I.armour_penetration, user, affecting.body_zone, block_return) & BLOCK_SUCCESS) + if(H.mob_run_block(I, totitemdamage, "the [I.name]", ((attackchain_flags & ATTACK_IS_PARRY_COUNTERATTACK)? ATTACK_TYPE_PARRY_COUNTERATTACK : NONE) | ATTACK_TYPE_MELEE, I.armour_penetration, user, affecting.body_zone, block_return) & BLOCK_SUCCESS) return 0 totitemdamage = block_calculate_resultant_damage(totitemdamage, block_return) if(H.check_martial_melee_block()) diff --git a/code/modules/mob/living/living_active_parry.dm b/code/modules/mob/living/living_active_parry.dm index c19fefbe8a..243e811205 100644 --- a/code/modules/mob/living/living_active_parry.dm +++ b/code/modules/mob/living/living_active_parry.dm @@ -277,7 +277,7 @@ if(data.parry_data[PARRY_COUNTERATTACK_MELEE_ATTACK_CHAIN]) switch(parrying) if(ITEM_PARRY) - active_parry_item.melee_attack_chain(src, attacker, null, ATTACKCHAIN_PARRY_COUNTERATTACK, data.parry_data[PARRY_COUNTERATTACK_MELEE_ATTACK_CHAIN]) + active_parry_item.melee_attack_chain(src, attacker, null, ATTACK_IS_PARRY_COUNTERATTACK | ATTACK_IGNORE_CLICKDELAY | ATTACK_IGNORE_ACTION | NO_AUTO_CLICKDELAY_HANDLING, data.parry_data[PARRY_COUNTERATTACK_MELEE_ATTACK_CHAIN]) effect_text += "reflexively counterattacking with [active_parry_item]" if(UNARMED_PARRY) // WARNING: If you are using these two, the attackchain parry counterattack flags and damage multipliers are unimplemented. Be careful with how you handle this. UnarmedAttack(attacker) diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 216670a7d3..c59727fb83 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -270,10 +270,10 @@ user.set_pull_offsets(src, grab_state) return 1 -/mob/living/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags) +/mob/living/on_attack_hand(mob/user, act_intent = user.a_intent, attackchain_flags) ..() //Ignoring parent return value here. SEND_SIGNAL(src, COMSIG_MOB_ATTACK_HAND, user) - if((user != src) && act_intent != INTENT_HELP && (mob_run_block(user, 0, user.name, ATTACK_TYPE_UNARMED | ATTACK_TYPE_MELEE | ((unarmed_attack_flags & UNARMED_ATTACK_PARRY)? ATTACK_TYPE_PARRY_COUNTERATTACK : NONE), null, user, check_zone(user.zone_selected), null) & BLOCK_SUCCESS)) + if((user != src) && act_intent != INTENT_HELP && (mob_run_block(user, 0, user.name, ATTACK_TYPE_UNARMED | ATTACK_TYPE_MELEE | ((attackchain_flags & ATTACK_IS_PARRY_COUNTERATTACK)? ATTACK_TYPE_PARRY_COUNTERATTACK : NONE), null, user, check_zone(user.zone_selected), null) & BLOCK_SUCCESS)) log_combat(user, src, "attempted to touch") visible_message("[user] attempted to touch [src]!", "[user] attempted to touch you!", target = user, diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm index 9b1cc3b355..12bd4f2828 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm @@ -87,7 +87,7 @@ Difficulty: Medium /mob/living/simple_animal/hostile/megafauna/blood_drunk_miner/adjustHealth(amount, updating_health = TRUE, forced = FALSE) var/adjustment_amount = amount * 0.1 if(world.time + adjustment_amount > next_action) - DelayNextAction(adjustment_amount) //attacking it interrupts it attacking, but only briefly + DelayNextAction(adjustment_amount, flush = TRUE) //attacking it interrupts it attacking, but only briefly . = ..() /mob/living/simple_animal/hostile/megafauna/blood_drunk_miner/death() @@ -125,8 +125,8 @@ Difficulty: Medium adjustHealth(-(L.maxHealth * 0.5)) L.gib() return TRUE - DelayNextAction(CLICK_CD_MELEE) - miner_saw.melee_attack_chain(src, target) + DelayNextAction(CLICK_CD_MELEE, flush = TRUE) + miner_saw.melee_attack_chain(src, target, null, ATTACK_IGNORE_CLICKDELAY) if(guidance) adjustHealth(-2) transform_weapon() @@ -161,7 +161,7 @@ Difficulty: Medium face_atom(target) new /obj/effect/temp_visual/dir_setting/firing_effect(loc, dir) Shoot(target) - DelayNextAction(CLICK_CD_RANGE) + DelayNextAction(CLICK_CD_RANGE, flush = TRUE) //I'm still of the belief that this entire proc needs to be wiped from existence. // do not take my touching of it to be endorsement of it. ~mso @@ -173,7 +173,7 @@ Difficulty: Medium return if(dashing || !CheckActionCooldown() || !Adjacent(target)) if(dashing && next_action <= world.time) - SetNextAction(1, considered_action = FALSE, immediate = FALSE) + SetNextAction(1, considered_action = FALSE, immediate = FALSE, flush = TRUE) INVOKE_ASYNC(src, .proc/quick_attack_loop) //lets try that again. return AttackingTarget()