From 910869d6bf99683a3a3bc0fb6e89a0eaf8126e0f Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Sat, 18 Jul 2020 19:44:12 -0700 Subject: [PATCH] more --- code/_onclick/click.dm | 13 ++++----- code/_onclick/hud/action_button.dm | 3 -- code/_onclick/hud/screen_objects.dm | 12 +------- code/_onclick/item_attack.dm | 9 ++---- code/game/machinery/wishgranter.dm | 6 ++-- .../clothing/glasses/disablerglasses.dm | 6 ++-- code/modules/clothing/gloves/miscellaneous.dm | 4 +-- code/modules/mob/clickdelay.dm | 28 +++++++++++-------- .../simple_animal/guardian/types/standard.dm | 2 +- .../reagents/reagent_containers/spray.dm | 4 ++- code/modules/spells/spell.dm | 5 ---- code/modules/station_goals/dna_vault.dm | 2 +- modular_citadel/code/_onclick/click.dm | 4 +-- 13 files changed, 41 insertions(+), 57 deletions(-) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index ec5cc09717..7ea0098661 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -33,7 +33,7 @@ * item/afterattack(atom,user,adjacent,params) - used both ranged and adjacent * mob/RangedAttack(atom,params) - used only ranged, only used for tk and laser eyes but could be changed */ -/mob/proc/ClickOn( atom/A, params ) +/mob/proc/ClickOn( atom/A, params) if(check_click_intercept(params,A)) return @@ -83,7 +83,7 @@ return M.click_action(A,src,params) if(restrained()) - changeNext_move(CLICK_CD_HANDCUFFED) //Doing shit in cuffs shall be vey slow + DelayNextAction(CLICK_CD_HANDCUFFED) RestrainedClickOn(A) return @@ -104,9 +104,7 @@ if(W) W.melee_attack_chain(src, A, params) else - if(ismob(A) && !CheckActionCooldown(CLICK_CD_MELEE)) - return - DelayNextAction() + DelayNextAction(ismob(A)? 8 : 0) UnarmedAttack(A) return @@ -119,9 +117,8 @@ if(W) W.melee_attack_chain(src, A, params) else - if(ismob(A) && !CheckActionCooldown(CLICK_CD_MELEE)) - return - DelayNextAction() + DelayNextAction(ismob(A)? 8 : 0) + DelayNextAction(ismob(A)? 8 : 0) UnarmedAttack(A, 1) else if(W) diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm index 0ed3a9cf26..8a66374029 100644 --- a/code/_onclick/hud/action_button.dm +++ b/code/_onclick/hud/action_button.dm @@ -56,9 +56,6 @@ if(id && usr.client) //try to (un)remember position usr.client.prefs.action_buttons_screen_locs["[name]_[id]"] = locked ? moved : null return TRUE - if(usr.next_click > world.time) - return - usr.next_click = world.time + 1 linked_action.Trigger() return TRUE diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 0088dde15a..9d810cdc07 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -47,17 +47,7 @@ name = "swap hand" /obj/screen/swap_hand/Click() - // At this point in client Click() code we have passed the 1/10 sec check and little else - // We don't even know if it's a middle click - if(world.time <= usr.next_move) - return 1 - - if(usr.incapacitated()) - return 1 - - if(ismob(usr)) - var/mob/M = usr - M.swap_hand() + usr.swap_hand() return 1 /obj/screen/craft diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index c26b35616f..8bbefff9a2 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -21,7 +21,6 @@ return if(QDELETED(src) || QDELETED(target)) return - PostattackClickdelaySet(user, target) afterattack(target, user, TRUE, params) /// Like melee_attack_chain but for ranged. @@ -81,6 +80,7 @@ user.do_attack_animation(M) M.attacked_by(src, user, attackchain_flags, damage_multiplier) + PostattackClickdelaySet(user, M) log_combat(user, M, "attacked", src.name, "(INTENT: [uppertext(user.a_intent)]) (DAMTYPE: [uppertext(damtype)])") add_fingerprint(user) @@ -96,8 +96,8 @@ if(item_flags & NOBLUDGEON) return user.do_attack_animation(O) - if(!O.attacked_by(src, user)) - user.changeNext_move(click_delay) + O.attacked_by(src, user) + PostattackClickdelaySet(user, O) var/weight = getweight(user, STAM_COST_ATTACK_OBJ_MULT) if(weight) user.adjustStaminaLossBuffered(weight)//CIT CHANGE - makes attacking things cause stamina loss @@ -110,12 +110,9 @@ var/bad_trait var/stamloss = user.getStaminaLoss() - var/next_move_mult = 1 if(stamloss > STAMINA_NEAR_SOFTCRIT) //The more tired you are, the less damage you do. var/penalty = (stamloss - STAMINA_NEAR_SOFTCRIT)/(STAMINA_NEAR_CRIT - STAMINA_NEAR_SOFTCRIT)*STAM_CRIT_ITEM_ATTACK_PENALTY totitemdamage *= 1 - penalty - next_move_mult += penalty*STAM_CRIT_ITEM_ATTACK_DELAY - user.changeNext_move(I.click_delay*next_move_mult) if(SEND_SIGNAL(user, COMSIG_COMBAT_MODE_CHECK, COMBAT_MODE_INACTIVE)) bad_trait = SKILL_COMBAT_MODE //blacklist combat skills. diff --git a/code/game/machinery/wishgranter.dm b/code/game/machinery/wishgranter.dm index a8446fd14a..10b56b3945 100644 --- a/code/game/machinery/wishgranter.dm +++ b/code/game/machinery/wishgranter.dm @@ -31,8 +31,7 @@ user.dna.add_mutation(XRAY) user.dna.add_mutation(SPACEMUT) user.dna.add_mutation(TK) - user.last_action_mult *= 0.5 - user.next_action_mult *= 0.5 + user.action_cooldown_mod = 0.5 to_chat(user, "Things around you feel slower!") charges-- insisting = FALSE @@ -102,8 +101,7 @@ to_chat(user, "[killreward] materializes into your hands!") else to_chat(user, "[killreward] materializes onto the floor.") - user.last_action_mult *= 0.8 //20% less delay between attacks! - user.next_action_mult *= 0.8 + user.action_cooldown_mod = 0.5 to_chat(user, "Things around you feel slightly slower!") var/mob/living/simple_animal/hostile/venus_human_trap/killwish = new /mob/living/simple_animal/hostile/venus_human_trap(loc) killwish.maxHealth = 1500 diff --git a/code/modules/clothing/glasses/disablerglasses.dm b/code/modules/clothing/glasses/disablerglasses.dm index a46e4c8339..51fb1cec87 100644 --- a/code/modules/clothing/glasses/disablerglasses.dm +++ b/code/modules/clothing/glasses/disablerglasses.dm @@ -4,7 +4,9 @@ var/beamtype = /obj/item/projectile/beam/disabler //change for adminbus /obj/item/clothing/glasses/hud/security/sunglasses/disablers/ranged_attack(mob/living/carbon/human/user,atom/A, params) - user.changeNext_move(CLICK_CD_RANGE) + if(!user.CheckActionCooldown(CLICK_CD_RANGE)) + return + user.last_action = world.time var/obj/item/projectile/beam/disabler/LE = new beamtype( loc ) playsound(usr.loc, 'sound/weapons/taser2.ogg', 75, 1) LE.firer = src @@ -12,4 +14,4 @@ LE.preparePixelProjectile(A, src, params) LE.fire() return TRUE - //shamelessly copied \ No newline at end of file + //shamelessly copied diff --git a/code/modules/clothing/gloves/miscellaneous.dm b/code/modules/clothing/gloves/miscellaneous.dm index a8017631bd..f6706eb3de 100644 --- a/code/modules/clothing/gloves/miscellaneous.dm +++ b/code/modules/clothing/gloves/miscellaneous.dm @@ -105,7 +105,7 @@ return var/mob/living/M = loc - M.changeNext_move(CLICK_CD_RAPID) + M.SetNextAction(CLICK_CD_RAPID) if(warcry) M.say("[warcry]", ignore_spam = TRUE, forced = TRUE) @@ -135,7 +135,7 @@ if(target.stat != CONSCIOUS) //Can't hug people who are dying/dead return FALSE else - M.changeNext_move(CLICK_CD_RAPID) + M.SetNextAction(CLICK_CD_RAPID) return FALSE diff --git a/code/modules/mob/clickdelay.dm b/code/modules/mob/clickdelay.dm index b83f8c8405..7c2c639b5a 100644 --- a/code/modules/mob/clickdelay.dm +++ b/code/modules/mob/clickdelay.dm @@ -12,14 +12,12 @@ var/last_action = 0 /// Generic clickdelay variable. Next world.time we should be able to do something that respects generic clickdelay. This should be set using [DelayNextAction()] This should only be checked using [CheckActionCooldown()]. var/next_action = 0 - /// Simple modification variable added to next action on adjust. This should only be manually modified via addition. - var/next_action_adjust = 0 - /// Simple modification variable multiplied to next action modifier on adjust. This should only be manually modified using multipliers. - var/next_action_mult = 1 - /// Simple modification variable added to amount when checking time since last action using [CheckActionCooldown()]. This should only be manually modified via addition. - var/last_action_adjust = 0 - /// Simple modification variable multiplied to amount when checking time since last action using [CheckActionCooldown()]. This should only be manually modified using multipliers. - var/last_action_mult = 1 + /// Simple modification variable multiplied to next action modifier on adjust and on checking time since last action using [CheckActionCooldown()]. + /// This should only be manually modified using multipliers. + var/action_cooldown_mod = 0.5 + /// Simple modification variable added to amounton adjust and on checking time since last action using [CheckActionCooldown()]. + /// This should only be manually modified via addition. + var/action_cooldown_adjust = 0 /// Special clickdelay variable for resisting. Last time we did a special action like resisting. This should be directly set. This should only be checked using [CheckResistCooldown()]. var/last_resist = 0 @@ -37,7 +35,15 @@ /mob/proc/DelayNextAction(amount = 0, ignore_mod = FALSE, considered_action = TRUE) if(considered_action) last_action = world.time - next_action = max(next_action, world.time + (ignore_mod? amount : (amount * next_action_mult + next_action_adjust))) + next_action = max(next_action, world.time + (ignore_mod? amount : (amount * action_cooldown_mod + action_cooldown_adjust))) + +/** + * Sets our next action to. The difference is DelayNextAction cannot reduce next_action under any circumstances while this can. + */ +/mob/proc/SetNextAction(amount = 0, ignore_mod = FALSE, considered_action = TRUE) + if(considered_action) + last_action = world.time + next_action = world.time + (ignore_mod? amount : (amount * action_cooldown_mod + action_cooldown_adjust)) /** * Checks if we can do another action. @@ -50,7 +56,7 @@ * * ignore_next_action - Defaults to FALSE. Ignore next_action and only care about cooldown param and everything else. Generally unused. */ /mob/proc/CheckActionCooldown(cooldown = 0.5, from_next_action = FALSE, ignore_mod = FALSE, ignore_next_action = FALSE) - return (ignore_next_action || (world.time >= next_action)) && (world.time >= ((from_next_action? next_action : last_action) + max(0, ignore_mod? cooldown : (cooldown * last_action_mult + last_action_adjust)))) + return (ignore_next_action || (world.time >= next_action)) && (world.time >= ((from_next_action? next_action : last_action) + max(0, ignore_mod? cooldown : (cooldown * action_cooldown_mod + action_cooldown_adjust)))) /** * Checks if we can resist again. @@ -93,7 +99,7 @@ */ /obj/item/proc/PreattackClickdelaySet(mob/user, atom/target) if(clickdelay_set_on_pre_attack) - user.DelayNextAction(0, FALSe, TRUE) + user.DelayNextAction(0, FALSE, TRUE) /** * Called after a successful attack to set a mob's clickdelay. diff --git a/code/modules/mob/living/simple_animal/guardian/types/standard.dm b/code/modules/mob/living/simple_animal/guardian/types/standard.dm index 2285167df5..d7970daa29 100644 --- a/code/modules/mob/living/simple_animal/guardian/types/standard.dm +++ b/code/modules/mob/living/simple_animal/guardian/types/standard.dm @@ -3,7 +3,7 @@ melee_damage_lower = 20 melee_damage_upper = 20 obj_damage = 80 - next_move_modifier = 0.5 //attacks 50% faster + action_cooldown_mod = 0.5 //attacks 50% faster environment_smash = ENVIRONMENT_SMASH_WALLS playstyle_string = "As a standard type you have no special abilities, but take half damage and have powerful attack capable of smashing through walls." magic_fluff_string = "..And draw the Assistant, faceless and generic, but never to be underestimated." diff --git a/code/modules/reagents/reagent_containers/spray.dm b/code/modules/reagents/reagent_containers/spray.dm index 7fea8250d9..9b25a80680 100644 --- a/code/modules/reagents/reagent_containers/spray.dm +++ b/code/modules/reagents/reagent_containers/spray.dm @@ -27,6 +27,8 @@ /obj/item/reagent_containers/spray/afterattack(atom/A, mob/user) . = ..() + if(!user.CheckActionCooldown(CLICK_CD_MELEE)) + return if(istype(A, /obj/structure/sink) || istype(A, /obj/structure/janitorialcart) || istype(A, /obj/machinery/hydroponics)) return @@ -50,7 +52,7 @@ spray(A) playsound(src.loc, 'sound/effects/spray2.ogg', 50, 1, -6) - user.changeNext_move(CLICK_CD_RANGE*2) + user.last_action = world.time user.newtonian_move(get_dir(A, user)) var/turf/T = get_turf(src) if(reagents.has_reagent(/datum/reagent/toxin/acid)) diff --git a/code/modules/spells/spell.dm b/code/modules/spells/spell.dm index 21552f7e87..57502e2cd5 100644 --- a/code/modules/spells/spell.dm +++ b/code/modules/spells/spell.dm @@ -56,11 +56,6 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th to_chat(caller, "[caller.ranged_ability.name] has been disabled.") caller.ranged_ability.remove_ranged_ability() return TRUE //TRUE for failed, FALSE for passed. - if(ranged_clickcd_override >= 0) - ranged_ability_user.next_click = world.time + ranged_clickcd_override - else - ranged_ability_user.next_click = world.time + CLICK_CD_CLICK_ABILITY - ranged_ability_user.face_atom(A) return FALSE /obj/effect/proc_holder/proc/add_ranged_ability(mob/living/user, msg, forced) diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm index 6c21456e63..64a1de8857 100644 --- a/code/modules/station_goals/dna_vault.dm +++ b/code/modules/station_goals/dna_vault.dm @@ -279,5 +279,5 @@ H.add_movespeed_modifier(/datum/movespeed_modifier/dna_vault_speedup) if(VAULT_QUICK) to_chat(H, "Your arms move as fast as lightning.") - H.next_move_modifier = 0.5 + H.action_cooldown_mod = 0.5 power_lottery[H] = list() diff --git a/modular_citadel/code/_onclick/click.dm b/modular_citadel/code/_onclick/click.dm index 004cc2fe80..b6e0afa8b6 100644 --- a/modular_citadel/code/_onclick/click.dm +++ b/modular_citadel/code/_onclick/click.dm @@ -5,7 +5,7 @@ face_atom(A) - if(next_move > world.time) // in the year 2000... + if(!CheckActionCooldown()) return if(!modifiers["catcher"] && A.IsObscured()) @@ -16,7 +16,7 @@ return M.click_action(A,src,params) if(restrained()) - changeNext_move(CLICK_CD_HANDCUFFED) //Doing shit in cuffs shall be vey slow + DelayNextAction(CLICK_CD_HANDCUFFED) RestrainedClickOn(A) return