diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 154ce017c8f6e..265fb605d0a49 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -52,7 +52,7 @@ /proc/get_playable_species() return GLOB.roundstart_species -//some additional checks as a callback for for do_afters that want to break on losing health or on the mob taking action +///some additional checks as a callback for for do_afters that want to break on losing health or on the mob taking action /mob/proc/break_do_after_checks(list/checked_health, check_clicks, selected_zone_check) if(check_clicks && next_move > world.time) return FALSE diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index a596bc18f3af5..86e3d613b8da1 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -2,12 +2,11 @@ * Delays the mob's next click/action by num deciseconds * eg: 10 - 3 = 7 deciseconds of delay * eg: 10 * 0.5 = 5 deciseconds of delay - * DOES NOT EFFECT THE BASE 1 DECISECOND DELAY OF NEXT_CLICK + * DOES NOT EFFECT THE BASE 1 DECISECOND DELAY OF next_click */ /mob/proc/changeNext_move(num) next_move = world.time + ((num + next_move_adjust) * next_move_modifier) - /* Before anything else, defer these calls to a per-mobtype handler. This allows us to remove istype() spaghetti code, but requires the addition of other handler procs to simplify it. @@ -47,7 +46,6 @@ * * mob/RangedAttack(atom, params) - used only ranged, only used for tk and laser eyes but could be changed */ /mob/proc/ClickOn(atom/A, location, params) - if(world.time <= next_click) return next_click = world.time + 1 diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index f888c5cdeca1d..05586df3f4934 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -14,11 +14,11 @@ return afterattack(target, user, TRUE, params) // TRUE: clicking something Adjacent -//Called before any other attack proc. +///Called before any other attack proc. /obj/item/proc/preattack(atom/target, mob/user, params) return FALSE -//Checks if the item can work as a tool, calling the appropriate tool behavior on the target +///Checks if the item can work as a tool, calling the appropriate tool behavior on the target /obj/item/proc/tool_attack_chain(mob/user, atom/target) switch(tool_behaviour) if(TOOL_CROWBAR) @@ -40,7 +40,6 @@ if(TOOL_FULTON) return target.fulton_act(user, src) - ///Called when the item is in the active hand, and clicked; alternately, there is an 'activate held object' verb or you can hit pagedown. /obj/item/proc/attack_self(mob/user) SEND_SIGNAL(src, COMSIG_ITEM_ATTACK_SELF, user) @@ -57,6 +56,8 @@ /atom/proc/attackby(obj/item/attacking_item, mob/user, params) SIGNAL_HANDLER_DOES_SLEEP + if(user.next_attack > world.time) + return TRUE add_fingerprint(user, "attackby", attacking_item) if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACKBY, attacking_item, user, params) & COMPONENT_NO_AFTERATTACK) return TRUE @@ -87,11 +88,9 @@ user.do_attack_animation(O, used_item = src) return O.attacked_by(src, user) - /atom/movable/proc/attacked_by(obj/item/attacking_item, mob/living/user, def_zone) return FALSE - /obj/attacked_by(obj/item/attacking_item, mob/living/user, def_zone) user.visible_message(span_warning("[user] hits [src] with [attacking_item]!"), span_warning("You hit [src] with [attacking_item]!"), visible_message_flags = COMBAT_MESSAGE) @@ -100,7 +99,6 @@ take_damage(power, attacking_item.damtype, MELEE, blame_mob = user) return TRUE - /obj/attack_powerloader(mob/living/user, obj/item/powerloader_clamp/attached_clamp) . = ..() if(.) @@ -125,7 +123,6 @@ span_notice("You grab [attached_clamp.loaded] with [attached_clamp].")) /mob/living/attacked_by(obj/item/attacking_item, mob/living/user, def_zone) - var/message_verb = "attacked" if(LAZYLEN(attacking_item.attack_verb)) message_verb = pick(attacking_item.attack_verb) @@ -166,23 +163,22 @@ return TRUE - /mob/living/attackby(obj/item/I, mob/living/user, params) . = ..() if(.) return TRUE - user.changeNext_move(I.attack_speed) + user.next_attack = world.time + I.attack_speed return I.attack(src, user) - -// has_proximity is TRUE 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. +/** + * has_proximity is TRUE 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. +*/ /obj/item/proc/afterattack(atom/target, mob/user, has_proximity, click_parameters) SEND_SIGNAL(src, COMSIG_ITEM_AFTERATTACK, target, user, has_proximity, click_parameters) SEND_SIGNAL(user, COMSIG_MOB_ITEM_AFTERATTACK, target, user, has_proximity, click_parameters) return - /obj/item/proc/attack(mob/living/M, mob/living/user) if(SEND_SIGNAL(src, COMSIG_ITEM_ATTACK, M, user) & COMPONENT_ITEM_NO_ATTACK) return FALSE @@ -275,9 +271,6 @@ return FALSE return FALSE - - - /////////////// ///RIGHT CLICK CODE FROM HERE /// @@ -311,14 +304,15 @@ user.changeNext_move(attacking_item.attack_speed_alternate) return attacking_item.attack_alternate(src, user) -// has_proximity is TRUE 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. +/** + * has_proximity is TRUE 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. +*/ /obj/item/proc/afterattack_alternate(atom/target, mob/user, has_proximity, click_parameters) SEND_SIGNAL(src, COMSIG_ITEM_AFTERATTACK_ALTERNATE, target, user, has_proximity, click_parameters) SEND_SIGNAL(user, COMSIG_MOB_ITEM_AFTERATTACK_ALTERNATE, target, user, has_proximity, click_parameters) return - /** * attack_alternate * diff --git a/code/datums/elements/directional_attack.dm b/code/datums/elements/directional_attack.dm index 4b130aa2962c3..700deac01662f 100644 --- a/code/datums/elements/directional_attack.dm +++ b/code/datums/elements/directional_attack.dm @@ -33,11 +33,11 @@ var/turf/turf_to_check = get_step(source, angle_to_dir(Get_Angle(source, clicked_atom))) if(!turf_to_check || !source.Adjacent(turf_to_check)) return - + var/mob/target_mob = locate() in turf_to_check if(!target_mob || source.faction == target_mob.faction) return - + //This is here to undo the +1 the click on the distant turf adds so we can click the mob near us source.next_click = world.time - 1 INVOKE_ASYNC(source, TYPE_PROC_REF(/mob, ClickOn), target_mob, turf_to_check, click_params) diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 7af9d6117437e..a697fbe4e14f3 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -34,20 +34,27 @@ var/feet_blood_color var/datum/skills/skills + //Clicking vars + ///integer, stores the time at which you can click again + var/next_click = 0 + ///integer, stores the time of whenever changeNext_move() gets ran + var/next_move = 0 + ///integer, stores world.time + attack_speed whenever attack is ran + var/next_attack = 0 + ///Amount to adjust action/click delays by, + or - + var/next_move_adjust = 0 + //Value to multiply action/click delays by + var/next_move_modifier = 1 + //Movement ///List of movement speed modifiers applying to this mob. Lazy list, see mob_movespeed.dm var/list/movespeed_modification ///The calculated mob speed slowdown based on the modifiers list. var/cached_multiplicative_slowdown - var/next_click = 0 - var/next_move = 0 ///Amount added during the next movement_delay(), then is reset. var/next_move_slowdown = 0 - ///Amount to adjust action/click delays by, + or - - var/next_move_adjust = 0 - //Value to multiply action/click delays by - var/next_move_modifier = 1 + var/last_move_intent var/area/lastarea var/inertia_dir = 0