[MIRROR] RangedAttack now takes modifiers. (#3706)

* RangedAttack now takes modifiers. (#57214)

* RangedAttack now takes modifiers.

Co-authored-by: Gurkenglas <gurkenglas@hotmail.de>
This commit is contained in:
SkyratBot
2021-02-28 13:25:00 +01:00
committed by GitHub
parent 81b023df61
commit 7b226dd6e1
7 changed files with 17 additions and 18 deletions

View File

@@ -1079,7 +1079,7 @@
#define COMSIG_MOB_ITEM_AFTERATTACK "mob_item_afterattack" #define COMSIG_MOB_ITEM_AFTERATTACK "mob_item_afterattack"
///from base of obj/item/attack_qdeleted(): (atom/target, mob/user, proxiumity_flag, click_parameters) ///from base of obj/item/attack_qdeleted(): (atom/target, mob/user, proxiumity_flag, click_parameters)
#define COMSIG_MOB_ITEM_ATTACK_QDELETED "mob_item_attack_qdeleted" #define COMSIG_MOB_ITEM_ATTACK_QDELETED "mob_item_attack_qdeleted"
///from base of mob/RangedAttack(): (atom/A, params) ///from base of mob/RangedAttack(): (atom/A, modifiers)
#define COMSIG_MOB_ATTACK_RANGED "mob_attack_ranged" #define COMSIG_MOB_ATTACK_RANGED "mob_attack_ranged"
///From base of atom/ctrl_click(): (atom/A) ///From base of atom/ctrl_click(): (atom/A)
#define COMSIG_MOB_CTRL_CLICKED "mob_ctrl_clicked" #define COMSIG_MOB_CTRL_CLICKED "mob_ctrl_clicked"

View File

@@ -62,7 +62,7 @@
* * [mob/proc/UnarmedAttack] (atom,adjacent) - used here only when adjacent, with no item in hand; in the case of humans, checks gloves * * [mob/proc/UnarmedAttack] (atom,adjacent) - used here only when adjacent, with no item in hand; in the case of humans, checks gloves
* * [atom/proc/attackby] (item,user) - used only when adjacent * * [atom/proc/attackby] (item,user) - used only when adjacent
* * [obj/item/proc/afterattack] (atom,user,adjacent,params) - used both ranged and adjacent * * [obj/item/proc/afterattack] (atom,user,adjacent,params) - used both ranged and adjacent
* * [mob/proc/RangedAttack] (atom,params) - used only ranged, only used for tk and laser eyes but could be changed * * [mob/proc/RangedAttack] (atom,modifiers) - 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(world.time <= next_click) if(world.time <= next_click)
@@ -163,7 +163,7 @@
else else
W.afterattack(A,src,0,params) W.afterattack(A,src,0,params)
else else
RangedAttack(A,params) RangedAttack(A,modifiers)
/// Is the atom obscured by a PREVENT_CLICK_UNDER_1 object above it /// Is the atom obscured by a PREVENT_CLICK_UNDER_1 object above it
/atom/proc/IsObscured() /atom/proc/IsObscured()
@@ -285,8 +285,8 @@
* for things like ranged glove touches, spitting alien acid/neurotoxin, * for things like ranged glove touches, spitting alien acid/neurotoxin,
* animals lunging, etc. * animals lunging, etc.
*/ */
/mob/proc/RangedAttack(atom/A, params) /mob/proc/RangedAttack(atom/A, modifiers)
if(SEND_SIGNAL(src, COMSIG_MOB_ATTACK_RANGED, A, params) & COMPONENT_CANCEL_ATTACK_CHAIN) if(SEND_SIGNAL(src, COMSIG_MOB_ATTACK_RANGED, A, modifiers) & COMPONENT_CANCEL_ATTACK_CHAIN)
return TRUE return TRUE

View File

@@ -98,13 +98,13 @@
return FALSE return FALSE
/mob/living/carbon/human/RangedAttack(atom/A, mouseparams) /mob/living/carbon/human/RangedAttack(atom/A, modifiers)
. = ..() . = ..()
if(.) if(.)
return return
if(gloves) if(gloves)
var/obj/item/clothing/gloves/G = gloves var/obj/item/clothing/gloves/G = gloves
if(istype(G) && G.Touch(A,0,mouseparams)) // for magic gloves if(istype(G) && G.Touch(A,0,modifiers)) // for magic gloves
return TRUE return TRUE
if(isturf(A) && get_dist(src,A) <= 1) if(isturf(A) && get_dist(src,A) <= 1)

View File

@@ -99,7 +99,7 @@
return visual_indicators[type][1] return visual_indicators[type][1]
///Triggers on COMSIG_MOB_ATTACK_RANGED. Does the projectile shooting. ///Triggers on COMSIG_MOB_ATTACK_RANGED. Does the projectile shooting.
/datum/mutation/human/laser_eyes/proc/on_ranged_attack(mob/living/carbon/human/source, atom/target, mouseparams) /datum/mutation/human/laser_eyes/proc/on_ranged_attack(mob/living/carbon/human/source, atom/target, modifiers)
SIGNAL_HANDLER SIGNAL_HANDLER
if(!source.combat_mode) if(!source.combat_mode)
@@ -110,7 +110,7 @@
var/obj/projectile/beam/laser_eyes/LE = new(source.loc) var/obj/projectile/beam/laser_eyes/LE = new(source.loc)
LE.firer = source LE.firer = source
LE.def_zone = ran_zone(source.zone_selected) LE.def_zone = ran_zone(source.zone_selected)
LE.preparePixelProjectile(target, source, mouseparams) LE.preparePixelProjectile(target, source, modifiers)
INVOKE_ASYNC(LE, /obj/projectile.proc/fire) INVOKE_ASYNC(LE, /obj/projectile.proc/fire)
playsound(source, 'sound/weapons/taser2.ogg', 75, TRUE) playsound(source, 'sound/weapons/taser2.ogg', 75, TRUE)

View File

@@ -509,7 +509,7 @@
return 1 return 1
/mob/living/simple_animal/hostile/RangedAttack(atom/A, params) //Player firing /mob/living/simple_animal/hostile/RangedAttack(atom/A, modifiers) //Player firing
if(ranged && ranged_cooldown <= world.time) if(ranged && ranged_cooldown <= world.time)
target = A target = A
OpenFire(A) OpenFire(A)

View File

@@ -32,8 +32,8 @@
var/door_hack_counter = 0 var/door_hack_counter = 0
/obj/item/clothing/gloves/space_ninja/Touch(atom/A,proximity,mouseparams) /obj/item/clothing/gloves/space_ninja/Touch(atom/A,proximity,modifiers)
if(!LAZYACCESS(mouseparams, RIGHT_CLICK) || draining) if(!LAZYACCESS(modifiers, RIGHT_CLICK) || draining)
return FALSE return FALSE
if(!ishuman(loc)) if(!ishuman(loc))
return FALSE //Only works while worn return FALSE //Only works while worn

View File

@@ -849,7 +849,7 @@
homing_offset_y = -homing_offset_y homing_offset_y = -homing_offset_y
//Spread is FORCED! //Spread is FORCED!
/obj/projectile/proc/preparePixelProjectile(atom/target, atom/source, params, spread = 0) /obj/projectile/proc/preparePixelProjectile(atom/target, atom/source, modifiers, spread = 0)
var/turf/curloc = get_turf(source) var/turf/curloc = get_turf(source)
var/turf/targloc = get_turf(target) var/turf/targloc = get_turf(target)
trajectory_ignore_forcemove = TRUE trajectory_ignore_forcemove = TRUE
@@ -857,13 +857,13 @@
trajectory_ignore_forcemove = FALSE trajectory_ignore_forcemove = FALSE
starting = get_turf(source) starting = get_turf(source)
original = target original = target
if(targloc || !params) if(targloc || !length(modifiers))
yo = targloc.y - curloc.y yo = targloc.y - curloc.y
xo = targloc.x - curloc.x xo = targloc.x - curloc.x
set_angle(Get_Angle(src, targloc) + spread) set_angle(Get_Angle(src, targloc) + spread)
if(isliving(source) && params) if(isliving(source) && length(modifiers))
var/list/calculated = calculate_projectile_angle_and_pixel_offsets(source, params) var/list/calculated = calculate_projectile_angle_and_pixel_offsets(source, modifiers)
p_x = calculated[2] p_x = calculated[2]
p_y = calculated[3] p_y = calculated[3]
@@ -876,8 +876,7 @@
stack_trace("WARNING: Projectile [type] fired without either mouse parameters, or a target atom to aim at!") stack_trace("WARNING: Projectile [type] fired without either mouse parameters, or a target atom to aim at!")
qdel(src) qdel(src)
/proc/calculate_projectile_angle_and_pixel_offsets(mob/user, params) /proc/calculate_projectile_angle_and_pixel_offsets(mob/user, modifiers)
var/list/modifiers = params2list(params)
var/p_x = 0 var/p_x = 0
var/p_y = 0 var/p_y = 0
var/angle = 0 var/angle = 0