From 32b95445e3810b8d78fb58c10d14cd30bcc7b333 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Sun, 28 Jun 2015 23:07:58 -0400 Subject: [PATCH] Gives changeNextMove() a better name, default define --- code/__defines/mobs.dm | 3 +++ code/_onclick/click.dm | 12 ++++++------ code/_onclick/item_attack.dm | 2 +- code/_onclick/observer.dm | 2 +- code/_onclick/rig.dm | 2 +- code/game/gamemodes/blob/theblob.dm | 2 +- code/game/machinery/camera/camera.dm | 2 +- code/game/machinery/deployable.dm | 2 +- code/game/machinery/doors/door.dm | 2 +- code/game/machinery/doors/windowdoor.dm | 2 +- code/game/machinery/portable_turret.dm | 2 +- code/game/mecha/mecha.dm | 6 +++--- code/game/objects/effects/aliens.dm | 6 +++--- .../objects/structures/crates_lockers/closets.dm | 2 +- code/game/objects/structures/grille.dm | 4 ++-- code/game/objects/structures/window.dm | 6 +++--- code/game/turfs/simulated/wall_attacks.dm | 6 +++--- code/modules/hydroponics/spreading/spreading.dm | 2 +- code/modules/hydroponics/trays/tray.dm | 2 +- code/modules/mob/living/carbon/human/human.dm | 2 +- code/modules/mob/living/carbon/resist.dm | 6 +++--- code/modules/mob/living/living.dm | 2 +- .../mob/living/simple_animal/simple_animal.dm | 2 +- code/modules/mob/mob.dm | 2 +- code/modules/mob/mob_grab.dm | 2 +- code/modules/projectiles/gun.dm | 4 ++-- code/modules/reagents/reagent_containers/spray.dm | 2 +- 27 files changed, 46 insertions(+), 43 deletions(-) diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index d7874d2b04..bcecfa7d86 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -79,6 +79,9 @@ #define APPEARANCE_ALL_HAIR (APPEARANCE_HAIR|APPEARANCE_HAIR_COLOR|APPEARANCE_FACIAL_HAIR|APPEARANCE_FACIAL_HAIR_COLOR) #define APPEARANCE_ALL 511 +// Click cooldown +#define DEFAULT_ATTACK_COOLDOWN 8 //Default timeout for aggressive actions + #define MIN_SUPPLIED_LAW_NUMBER 15 #define MAX_SUPPLIED_LAW_NUMBER 50 \ No newline at end of file diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 3218212dda..a250b12e43 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -78,7 +78,7 @@ return M.click_action(A, src) if(restrained()) - changeNextMove(10) + setClickCooldown(10) RestrainedClickOn(A) return @@ -108,7 +108,7 @@ W.afterattack(A, src, 1, params) // 1 indicates adjacency else if(ismob(A)) // No instant mob attacking - changeNextMove(8) + setClickCooldown(DEFAULT_ATTACK_COOLDOWN) UnarmedAttack(A, 1) return @@ -126,7 +126,7 @@ W.afterattack(A, src, 1, params) // 1: clicking something Adjacent else if(ismob(A)) // No instant mob attacking - changeNextMove(8) + setClickCooldown(DEFAULT_ATTACK_COOLDOWN) UnarmedAttack(A, 1) return else // non-adjacent click @@ -137,8 +137,8 @@ return -/mob/proc/changeNextMove(var/num) - next_move = world.time + num +/mob/proc/setClickCooldown(var/timeout) + next_move = max(world.time + timeout, next_move) /mob/proc/canClick() if(config.no_click_cooldown || next_move <= world.time) @@ -285,7 +285,7 @@ return /mob/living/LaserEyes(atom/A) - changeNextMove(4) + setClickCooldown(4) var/turf/T = get_turf(src) var/turf/U = get_turf(A) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 977b4d2334..0cca5569c2 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -12,7 +12,7 @@ visible_message("[src] has been hit by [user] with [W].") /mob/living/attackby(obj/item/I, mob/user) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(istype(I) && ismob(user)) I.attack(src, user) diff --git a/code/_onclick/observer.dm b/code/_onclick/observer.dm index 4323747496..324dcc234d 100644 --- a/code/_onclick/observer.dm +++ b/code/_onclick/observer.dm @@ -33,7 +33,7 @@ build_click(src, client.buildmode, params, A) return if(!canClick()) return - changeNextMove(4) + setClickCooldown(4) // You are responsible for checking config.ghost_interaction when you override this function // Not all of them require checking, see below A.attack_ghost(src) diff --git a/code/_onclick/rig.dm b/code/_onclick/rig.dm index 6087cf2c29..600d8c5619 100644 --- a/code/_onclick/rig.dm +++ b/code/_onclick/rig.dm @@ -55,7 +55,7 @@ if(istype(rig) && rig.selected_module) rig.selected_module.engage(A) if(ismob(A)) // No instant mob attacking - though modules have their own cooldowns - changeNextMove(8) + setClickCooldown(DEFAULT_ATTACK_COOLDOWN) return 1 return 0 diff --git a/code/game/gamemodes/blob/theblob.dm b/code/game/gamemodes/blob/theblob.dm index 2d8891bb0b..123bb97a3f 100644 --- a/code/game/gamemodes/blob/theblob.dm +++ b/code/game/gamemodes/blob/theblob.dm @@ -157,7 +157,7 @@ attackby(var/obj/item/weapon/W, var/mob/user) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) playsound(src.loc, 'sound/effects/attackblob.ogg', 50, 1) src.visible_message("The [src.name] has been attacked with \the [W][(user ? " by [user]." : ".")]") var/damage = 0 diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 649a11b60d..a96e94eb0c 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -190,7 +190,7 @@ src.bugged = 1 else if(W.damtype == BRUTE || W.damtype == BURN) //bashing cameras - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if (W.force >= src.toughness) user.do_attack_animation(src) visible_message("[src] has been [pick(W.attack_verb)] with [W] by [user]!") diff --git a/code/game/machinery/deployable.dm b/code/game/machinery/deployable.dm index cb77a513a4..bce1ac5b57 100644 --- a/code/game/machinery/deployable.dm +++ b/code/game/machinery/deployable.dm @@ -97,7 +97,7 @@ for reference: return return else - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) switch(W.damtype) if("fire") src.health -= W.force * 1 diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 4a246a9327..077bd4ff9b 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -260,7 +260,7 @@ //psa to whoever coded this, there are plenty of objects that need to call attack() on doors without bludgeoning them. if(src.density && istype(I, /obj/item/weapon) && user.a_intent == I_HURT && !istype(I, /obj/item/weapon/card)) var/obj/item/weapon/W = I - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(W.damtype == BRUTE || W.damtype == BURN) user.do_attack_animation(src) if(W.force < min_force) diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm index 8b7094b772..e50af2bcf0 100644 --- a/code/game/machinery/doors/windowdoor.dm +++ b/code/game/machinery/doors/windowdoor.dm @@ -229,7 +229,7 @@ //If it's a weapon, smash windoor. Unless it's an id card, agent card, ect.. then ignore it (Cards really shouldnt damage a door anyway) if(src.density && istype(I, /obj/item/weapon) && !istype(I, /obj/item/weapon/card)) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) var/aforce = I.force playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1) visible_message("[src] was hit by [I].") diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index 655108cc3c..04b4dffe3c 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -322,7 +322,7 @@ else //if the turret was attacked with the intention of harming it: - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) take_damage(I.force * 0.5) if(I.force * 0.5 > 1) //if the force of impact dealt at least 1 damage, the turret gets pissed off if(!attacked && !emagged) diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index e1c898da18..573ede3fb0 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -505,7 +505,7 @@ return /obj/mecha/attack_hand(mob/user as mob) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) src.log_message("Attack by hand/paw. Attacker - [user].",1) if(istype(user,/mob/living/carbon/human)) @@ -665,7 +665,7 @@ return /obj/mecha/proc/dynattackby(obj/item/weapon/W as obj, mob/user as mob) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) src.log_message("Attacked by [W]. Attacker - [user]") if(prob(src.deflect_chance)) user << "\The [W] bounces off [src.name]." @@ -1685,7 +1685,7 @@ /obj/mecha/attack_generic(var/mob/user, var/damage, var/attack_message) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(!damage) return 0 diff --git a/code/game/objects/effects/aliens.dm b/code/game/objects/effects/aliens.dm index 58ac1ee3a6..27d29b3cd6 100644 --- a/code/game/objects/effects/aliens.dm +++ b/code/game/objects/effects/aliens.dm @@ -98,7 +98,7 @@ return /obj/effect/alien/resin/attack_hand() - usr.changeNextMove(8) + usr.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if (HULK in usr.mutations) usr << "You easily destroy the [name]." for(var/mob/O in oviewers(src)) @@ -125,7 +125,7 @@ /obj/effect/alien/resin/attackby(obj/item/weapon/W as obj, mob/user as mob) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) var/aforce = W.force health = max(0, health - aforce) playsound(loc, 'sound/effects/attackblob.ogg', 100, 1) @@ -233,7 +233,7 @@ Alien plants should do something if theres a lot of poison return /obj/effect/alien/weeds/attackby(var/obj/item/weapon/W, var/mob/user) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(W.attack_verb.len) visible_message("\The [src] have been [pick(W.attack_verb)] with \the [W][(user ? " by [user]." : ".")]") else diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index 84224bff4b..891f280520 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -349,7 +349,7 @@ if(!escapee.canClick()) return - escapee.changeNextMove(100) + escapee.setClickCooldown(100) //okay, so the closet is either welded or locked... resist!!! escapee << "You lean on the back of \the [src] and start pushing the door open. (this will take about [breakout_time] minutes)" diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 126aa6eac2..ff540c46ba 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -30,7 +30,7 @@ /obj/structure/grille/attack_hand(mob/user as mob) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) playsound(loc, 'sound/effects/grillehit.ogg', 80, 1) user.do_attack_animation(src) @@ -156,7 +156,7 @@ //window placing end else if(!(W.flags & CONDUCT) || !shock(user, 70)) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) user.do_attack_animation(src) playsound(loc, 'sound/effects/grillehit.ogg', 80, 1) switch(W.damtype) diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 6a82e64f37..8574054263 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -171,7 +171,7 @@ playsound(loc, 'sound/effects/Glasshit.ogg', 50, 1) /obj/structure/window/attack_hand(mob/user as mob) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(HULK in user.mutations) user.say(pick(";RAAAAAAAARGH!", ";HNNNNNNNNNGGGGGGH!", ";GWAAAAAAAARRRHHH!", "NNNNNNNNGGGGGGGGHH!", ";AAAAAAARRRGH!")) user.visible_message("[user] smashes through [src]!") @@ -199,7 +199,7 @@ return /obj/structure/window/attack_generic(var/mob/user, var/damage) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(!damage) return if(damage >= 10) @@ -269,7 +269,7 @@ new glasstype(loc) qdel(src) else - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(W.damtype == BRUTE || W.damtype == BURN) user.do_attack_animation(src) hit(W.force) diff --git a/code/game/turfs/simulated/wall_attacks.dm b/code/game/turfs/simulated/wall_attacks.dm index 9ebd9cee87..dc56061218 100644 --- a/code/game/turfs/simulated/wall_attacks.dm +++ b/code/game/turfs/simulated/wall_attacks.dm @@ -56,7 +56,7 @@ radiate() add_fingerprint(user) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) var/rotting = (locate(/obj/effect/overlay/wallrot) in src) if (HULK in user.mutations) if (rotting || !prob(material.hardness)) @@ -70,7 +70,7 @@ /turf/simulated/wall/attack_generic(var/mob/user, var/damage, var/attack_message, var/wallbreaker) radiate() - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) var/rotting = (locate(/obj/effect/overlay/wallrot) in src) if(!damage || !wallbreaker) try_touch(user, rotting) @@ -88,7 +88,7 @@ /turf/simulated/wall/attackby(obj/item/weapon/W as obj, mob/user as mob) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if (!user.) user << "You don't have the dexterity to do this!" return diff --git a/code/modules/hydroponics/spreading/spreading.dm b/code/modules/hydroponics/spreading/spreading.dm index b50ac8c1f1..d9b477ba28 100644 --- a/code/modules/hydroponics/spreading/spreading.dm +++ b/code/modules/hydroponics/spreading/spreading.dm @@ -234,7 +234,7 @@ /obj/effect/plant/attackby(var/obj/item/weapon/W, var/mob/user) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) plant_controller.add_plant(src) if(istype(W, /obj/item/weapon/wirecutters) || istype(W, /obj/item/weapon/scalpel)) diff --git a/code/modules/hydroponics/trays/tray.dm b/code/modules/hydroponics/trays/tray.dm index 7bfe605b45..b8a92cdff9 100644 --- a/code/modules/hydroponics/trays/tray.dm +++ b/code/modules/hydroponics/trays/tray.dm @@ -545,7 +545,7 @@ A.hydrotray_type = src.type qdel(src) else if(O.force && seed) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) user.visible_message("\The [seed.display_name] has been attacked by [user] with \the [O]!") if(!dead) health -= O.force diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 658e7d3284..8bc4558839 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1308,7 +1308,7 @@ if(!isliving(usr) || !usr.canClick()) return - usr.changeNextMove(20) + usr.setClickCooldown(20) if(usr.stat > 0) usr << "You are unconcious and cannot do that!" diff --git a/code/modules/mob/living/carbon/resist.dm b/code/modules/mob/living/carbon/resist.dm index 0b43a98058..a5ad3f5845 100644 --- a/code/modules/mob/living/carbon/resist.dm +++ b/code/modules/mob/living/carbon/resist.dm @@ -31,7 +31,7 @@ //These two lines represent a significant buff to grabs... if(!canClick()) return - changeNextMove(100) + setClickCooldown(100) if(can_break_cuffs()) //Don't want to do a lot of logic gating here. break_handcuffs() @@ -65,7 +65,7 @@ if(!canClick()) return - changeNextMove(100) + setClickCooldown(100) if(can_break_cuffs()) //Don't want to do a lot of logic gating here. break_legcuffs() @@ -153,7 +153,7 @@ if(!canClick()) return - changeNextMove(100) + setClickCooldown(100) if(!buckled) return if(!restrained()) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index fb85edd73b..f8b199cb9d 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -575,7 +575,7 @@ default behaviour is: set category = "IC" if(can_resist()) - changeNextMove(20) + setClickCooldown(20) process_resist() /mob/living/proc/can_resist() diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index c5035eb447..875bb4c1ce 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -290,7 +290,7 @@ //TODO: refactor mob attackby(), attacked_by(), and friends. /mob/living/simple_animal/proc/attacked_with_item(var/obj/item/O, var/mob/user) - user.changeNextMove(8) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) if(!O.force) visible_message("[user] gently taps [src] with \the [O].") return diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 3acd11ae69..f722bc31ed 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -843,7 +843,7 @@ mob/proc/yank_out_object() if(!isliving(usr) || !usr.canClick()) return - usr.changeNextMove(20) + usr.setClickCooldown(20) if(usr.stat == 1) usr << "You are unconcious and cannot do that!" diff --git a/code/modules/mob/mob_grab.dm b/code/modules/mob/mob_grab.dm index d25cd59925..b5ba0a0c4f 100644 --- a/code/modules/mob/mob_grab.dm +++ b/code/modules/mob/mob_grab.dm @@ -259,7 +259,7 @@ assailant.attack_log += "\[[time_stamp()]\] Strangled (kill intent) [affecting.name] ([affecting.ckey])" msg_admin_attack("[key_name(assailant)] strangled (kill intent) [key_name(affecting)]") - affecting.changeNextMove(10) + affecting.setClickCooldown(10) affecting.losebreath += 1 affecting.set_dir(WEST) adjust_position() diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 7de74612f2..3c3af1f19d 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -169,7 +169,7 @@ var/_move_delay = firemode.move_delay var/shoot_time = (_burst - 1)*_burst_delay - user.changeNextMove(shoot_time) + user.setClickCooldown(shoot_time) if(user.client) user.client.move_delay = world.time + shoot_time //no moving while shooting either next_fire_time = world.time + shoot_time @@ -202,7 +202,7 @@ update_held_icon() //update timing - user.changeNextMove(4) + user.setClickCooldown(4) if(user.client) user.client.move_delay = world.time + _move_delay next_fire_time = world.time + _fire_delay diff --git a/code/modules/reagents/reagent_containers/spray.dm b/code/modules/reagents/reagent_containers/spray.dm index 8d9e8b9869..b4dee5f366 100644 --- a/code/modules/reagents/reagent_containers/spray.dm +++ b/code/modules/reagents/reagent_containers/spray.dm @@ -39,7 +39,7 @@ playsound(src.loc, 'sound/effects/spray2.ogg', 50, 1, -6) - user.changeNextMove(4) + user.setClickCooldown(4) if(reagents.has_reagent("sacid")) message_admins("[key_name_admin(user)] fired sulphuric acid from \a [src].")