Merge pull request #10755 from kevinz000/attack_chain
small refactor to melee_attack_chain
This commit is contained in:
@@ -1,19 +1,22 @@
|
|||||||
|
/**
|
||||||
|
*This is the proc that handles the order of an item_attack.
|
||||||
|
*The order of procs called is:
|
||||||
|
*tool_act on the target. If it returns TRUE, the chain will be stopped.
|
||||||
|
*pre_attack() on src. If this returns TRUE, the chain will be stopped.
|
||||||
|
*attackby on the target. If it returns TRUE, the chain will be stopped.
|
||||||
|
*and lastly
|
||||||
|
*afterattack. The return value does not matter.
|
||||||
|
*/
|
||||||
/obj/item/proc/melee_attack_chain(mob/user, atom/target, params)
|
/obj/item/proc/melee_attack_chain(mob/user, atom/target, params)
|
||||||
if(!tool_attack_chain(user, target) && pre_attack(target, user, params))
|
if(tool_behaviour && target.tool_act(user, src, tool_behaviour))
|
||||||
// Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example)
|
return
|
||||||
var/resolved = target.attackby(src, user, params)
|
if(pre_attack(target, user, params))
|
||||||
if(!resolved && target && !QDELETED(src))
|
return
|
||||||
afterattack(target, user, 1, params) // 1: clicking something Adjacent
|
if(target.attackby(src,user, params))
|
||||||
|
return
|
||||||
|
if(QDELETED(src) || QDELETED(target))
|
||||||
//Checks if the item can work as a tool, calling the appropriate tool behavior on the target
|
return
|
||||||
/obj/item/proc/tool_attack_chain(mob/user, atom/target)
|
afterattack(target, user, TRUE, params)
|
||||||
if(!tool_behaviour)
|
|
||||||
return FALSE
|
|
||||||
|
|
||||||
return target.tool_act(user, src, tool_behaviour)
|
|
||||||
|
|
||||||
|
|
||||||
// Called when the item is in the active hand, and clicked; alternately, there is an 'activate held object' verb or you can hit pagedown.
|
// 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)
|
/obj/item/proc/attack_self(mob/user)
|
||||||
@@ -23,8 +26,8 @@
|
|||||||
|
|
||||||
/obj/item/proc/pre_attack(atom/A, mob/living/user, params) //do stuff before attackby!
|
/obj/item/proc/pre_attack(atom/A, mob/living/user, params) //do stuff before attackby!
|
||||||
if(SEND_SIGNAL(src, COMSIG_ITEM_PRE_ATTACK, A, user, params) & COMPONENT_NO_ATTACK)
|
if(SEND_SIGNAL(src, COMSIG_ITEM_PRE_ATTACK, A, user, params) & COMPONENT_NO_ATTACK)
|
||||||
return FALSE
|
return TRUE
|
||||||
return TRUE //return FALSE to avoid calling attackby after this proc does stuff
|
return FALSE //return TRUE to avoid calling attackby after this proc does stuff
|
||||||
|
|
||||||
// No comment
|
// No comment
|
||||||
/atom/proc/attackby(obj/item/W, mob/user, params)
|
/atom/proc/attackby(obj/item/W, mob/user, params)
|
||||||
@@ -112,7 +115,7 @@
|
|||||||
send_item_attack_message(I, user)
|
send_item_attack_message(I, user)
|
||||||
if(I.force)
|
if(I.force)
|
||||||
apply_damage(totitemdamage, I.damtype) //CIT CHANGE - replaces I.force with totitemdamage
|
apply_damage(totitemdamage, I.damtype) //CIT CHANGE - replaces I.force with totitemdamage
|
||||||
if(I.damtype == BRUTE && !HAS_TRAIT(src, TRAIT_NOMARROW))
|
if(I.damtype == BRUTE && !HAS_TRAIT(src, TRAIT_NOMARROW))
|
||||||
if(prob(33))
|
if(prob(33))
|
||||||
I.add_mob_blood(src)
|
I.add_mob_blood(src)
|
||||||
var/turf/location = get_turf(src)
|
var/turf/location = get_turf(src)
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
|
|||||||
A = get_turf(A)
|
A = get_turf(A)
|
||||||
var/can_make_pipe = (isturf(A) || is_type_in_typecache(A, make_pipe_whitelist))
|
var/can_make_pipe = (isturf(A) || is_type_in_typecache(A, make_pipe_whitelist))
|
||||||
|
|
||||||
. = FALSE
|
. = TRUE
|
||||||
|
|
||||||
if((mode & DESTROY_MODE) && istype(A, /obj/item/pipe) || istype(A, /obj/structure/disposalconstruct) || istype(A, /obj/structure/c_transit_tube) || istype(A, /obj/structure/c_transit_tube_pod) || istype(A, /obj/item/pipe_meter))
|
if((mode & DESTROY_MODE) && istype(A, /obj/item/pipe) || istype(A, /obj/structure/disposalconstruct) || istype(A, /obj/structure/c_transit_tube) || istype(A, /obj/structure/c_transit_tube_pod) || istype(A, /obj/item/pipe_meter))
|
||||||
to_chat(user, "<span class='notice'>You start destroying a pipe...</span>")
|
to_chat(user, "<span class='notice'>You start destroying a pipe...</span>")
|
||||||
|
|||||||
@@ -138,7 +138,7 @@
|
|||||||
|
|
||||||
/obj/item/hand_tele/pre_attack(atom/target, mob/user, params)
|
/obj/item/hand_tele/pre_attack(atom/target, mob/user, params)
|
||||||
if(try_dispel_portal(target, user))
|
if(try_dispel_portal(target, user))
|
||||||
return FALSE
|
return TRUE
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/obj/item/hand_tele/proc/try_dispel_portal(atom/target, mob/user)
|
/obj/item/hand_tele/proc/try_dispel_portal(atom/target, mob/user)
|
||||||
|
|||||||
@@ -68,8 +68,8 @@
|
|||||||
|
|
||||||
/obj/item/clockwork/replica_fabricator/pre_attack(atom/target, mob/living/user, params)
|
/obj/item/clockwork/replica_fabricator/pre_attack(atom/target, mob/living/user, params)
|
||||||
if(!target || !user || !is_servant_of_ratvar(user) || istype(target, /obj/item/storage))
|
if(!target || !user || !is_servant_of_ratvar(user) || istype(target, /obj/item/storage))
|
||||||
return TRUE
|
return ..()
|
||||||
return fabricate(target, user)
|
return !fabricate(target, user)
|
||||||
|
|
||||||
//A note here; return values are for if we CAN BE PUT ON A TABLE, not IF WE ARE SUCCESSFUL, unless no_table_check is TRUE
|
//A note here; return values are for if we CAN BE PUT ON A TABLE, not IF WE ARE SUCCESSFUL, unless no_table_check is TRUE
|
||||||
/obj/item/clockwork/replica_fabricator/proc/fabricate(atom/target, mob/living/user, silent, no_table_check)
|
/obj/item/clockwork/replica_fabricator/proc/fabricate(atom/target, mob/living/user, silent, no_table_check)
|
||||||
|
|||||||
@@ -470,7 +470,7 @@
|
|||||||
|
|
||||||
/obj/item/claymore/ctf/pre_attack(atom/target, mob/user, params)
|
/obj/item/claymore/ctf/pre_attack(atom/target, mob/user, params)
|
||||||
if(!is_ctf_target(target))
|
if(!is_ctf_target(target))
|
||||||
return FALSE
|
return TRUE
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/obj/item/claymore/ctf/dropped()
|
/obj/item/claymore/ctf/dropped()
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
/obj/item/resonator/pre_attack(atom/target, mob/user, params)
|
/obj/item/resonator/pre_attack(atom/target, mob/user, params)
|
||||||
if(check_allowed_items(target, 1))
|
if(check_allowed_items(target, 1))
|
||||||
CreateResonance(target, user)
|
CreateResonance(target, user)
|
||||||
return TRUE
|
return ..()
|
||||||
|
|
||||||
//resonance field, crushes rock, damages mobs
|
//resonance field, crushes rock, damages mobs
|
||||||
/obj/effect/temp_visual/resonance
|
/obj/effect/temp_visual/resonance
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ If you create T5+ please take a pass at gene_modder.dm [L40]. Max_values MUST fi
|
|||||||
if(works_from_distance)
|
if(works_from_distance)
|
||||||
user.Beam(T, icon_state = "rped_upgrade", time = 5)
|
user.Beam(T, icon_state = "rped_upgrade", time = 5)
|
||||||
T.exchange_parts(user, src)
|
T.exchange_parts(user, src)
|
||||||
return FALSE
|
return TRUE
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/obj/item/storage/part_replacer/afterattack(obj/machinery/T, mob/living/user, adjacent, params)
|
/obj/item/storage/part_replacer/afterattack(obj/machinery/T, mob/living/user, adjacent, params)
|
||||||
|
|||||||
Reference in New Issue
Block a user