Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melee attacks no longer lock inputs #16082

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
32 changes: 13 additions & 19 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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(.)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -275,9 +271,6 @@
return FALSE
return FALSE




///////////////
///RIGHT CLICK CODE FROM HERE
///
Expand Down Expand Up @@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions code/datums/elements/directional_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
19 changes: 13 additions & 6 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading