mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 12:08:55 +01:00
Afterattack is dead, long live Afterattack (#83818)
## About The Pull Request - Afterattack is a very simple proc now: All it does is this, and all it's used for is for having a convenient place to put effects an item does after a successful attack (IE, the attack was not blocked)  - An overwhelming majority of afterattack implementations have been moved to `interact_with_atom` or the new `ranged_interact_with_atom` I have manually tested many of the refactored procs but there was 200+ so it's kinda hard ## Why It's Good For The Game Afterattack is one of the worst parts of the attack chain, as it simultaneously serves as a way of doing random interactions NOT AT ALL related to attacks (despite the name) while ALSO serving as the defacto way to do a ranged interaction with an item This means careless coders (most of them) may throw stuff in afterattack without realizing how wide reaching it is, which causes bugs. By making two well defined, separate procs for handing adjacent vs ranged interactions, it becomes WAY WAY WAY more easy to develop for. If you want to do something when you click on something else and you're adjacent, use `interact_with_atom` If you want to do something when you click on something else and you're not adjacent, use 'ranged_interact_with_atom` This does result in some instances of boilerplate as shown here:  But I think it's acceptable, feel free to oppose if you don't I'm sure we can think of another solution ~~Additionally it makes it easier to implement swing combat. That's a bonus I guess~~ ## Changelog 🆑 Melbert refactor: Over 200 item interactions have been refactored to use a newer, easier-to-use system. Report any oddities with using items on other objects you may see (such as surgery, reagent containers like cups and spray bottles, or construction devices), especially using something at range (such as guns or chisels) refactor: Item-On-Modsuit interactions have changed slightly. While on combat mode, you will attempt to "use" the item on the suit instead of inserting it into the suit's storage. This means being on combat mode while the suit's panel is open will block you from inserting items entirely via click (but other methods such as hotkey, clicking on the storage boxes, and mousedrop will still work). refactor: The detective's scanner will now be inserted into storage items if clicked normally, and will scan the storage item if on combat mode /🆑
This commit is contained in:
@@ -248,30 +248,66 @@
|
||||
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
|
||||
/obj/item/gun/afterattack_secondary(mob/living/victim, mob/living/user, proximity_flag, click_parameters)
|
||||
if(!isliving(victim) || !IN_GIVEN_RANGE(user, victim, GUNPOINT_SHOOTER_STRAY_RANGE))
|
||||
return ..() //if they're out of range, just shootem.
|
||||
if(!can_hold_up)
|
||||
return ..()
|
||||
/obj/item/gun/pre_attack(atom/A, mob/living/user, params)
|
||||
. = ..()
|
||||
if(.)
|
||||
return .
|
||||
if(isnull(bayonet) || !user.combat_mode)
|
||||
return .
|
||||
return bayonet.melee_attack_chain(user, A, params)
|
||||
|
||||
/obj/item/gun/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
|
||||
if(user.combat_mode)
|
||||
return NONE
|
||||
|
||||
if(istype(tool, /obj/item/knife))
|
||||
var/obj/item/knife/new_stabber = tool
|
||||
if(!can_bayonet || !new_stabber.bayonet || !isnull(bayonet)) //ensure the gun has an attachment point available, and that the knife is compatible with it.
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
if(!user.transferItemToLoc(new_stabber, src))
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
to_chat(user, span_notice("You attach [new_stabber] to [src]'s bayonet lug."))
|
||||
bayonet = new_stabber
|
||||
update_appearance()
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
|
||||
return NONE
|
||||
|
||||
/obj/item/gun/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(user.combat_mode && isliving(interacting_with))
|
||||
return ITEM_INTERACT_SKIP_TO_ATTACK // Gun bash / bayonet attack
|
||||
if(try_fire_gun(interacting_with, user, list2params(modifiers)))
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
return NONE
|
||||
|
||||
/obj/item/gun/interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(!can_hold_up || !isliving(interacting_with))
|
||||
return interact_with_atom(interacting_with, user, modifiers)
|
||||
|
||||
var/datum/component/gunpoint/gunpoint_component = user.GetComponent(/datum/component/gunpoint)
|
||||
if (gunpoint_component)
|
||||
if(gunpoint_component.target == victim)
|
||||
balloon_alert(user, "already holding them up!")
|
||||
else
|
||||
balloon_alert(user, "already holding someone up!")
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
if (user == victim)
|
||||
balloon_alert(user, "already holding [gunpoint_component.target == interacting_with ? "them" : "someone"] up!")
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
if (user == interacting_with)
|
||||
balloon_alert(user, "can't hold yourself up!")
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
|
||||
if(do_after(user, 0.5 SECONDS, victim))
|
||||
user.AddComponent(/datum/component/gunpoint, victim, src)
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
if(do_after(user, 0.5 SECONDS, interacting_with))
|
||||
user.AddComponent(/datum/component/gunpoint, interacting_with, src)
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
|
||||
/obj/item/gun/afterattack(atom/target, mob/living/user, flag, params)
|
||||
..()
|
||||
fire_gun(target, user, flag, params)
|
||||
return AFTERATTACK_PROCESSED_ITEM
|
||||
/obj/item/gun/ranged_interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(try_fire_gun(interacting_with, user, list2params(modifiers)))
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
|
||||
/obj/item/gun/ranged_interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(IN_GIVEN_RANGE(user, interacting_with, GUNPOINT_SHOOTER_STRAY_RANGE))
|
||||
return interact_with_atom_secondary(interacting_with, user, modifiers)
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/proc/try_fire_gun(atom/target, mob/living/user, params)
|
||||
return fire_gun(target, user, user.Adjacent(target), params)
|
||||
|
||||
/obj/item/gun/proc/fire_gun(atom/target, mob/living/user, flag, params)
|
||||
if(QDELETED(target))
|
||||
@@ -466,39 +502,6 @@
|
||||
/obj/item/gun/proc/reset_semicd()
|
||||
semicd = FALSE
|
||||
|
||||
/obj/item/gun/attack(mob/M, mob/living/user)
|
||||
if(user.combat_mode) //Flogging
|
||||
if(bayonet)
|
||||
M.attackby(bayonet, user)
|
||||
return
|
||||
else
|
||||
return ..()
|
||||
return
|
||||
|
||||
/obj/item/gun/attack_atom(obj/O, mob/living/user, params)
|
||||
if(user.combat_mode)
|
||||
if(bayonet)
|
||||
O.attackby(bayonet, user)
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/attackby(obj/item/I, mob/living/user, params)
|
||||
if(user.combat_mode)
|
||||
return ..()
|
||||
|
||||
else if(istype(I, /obj/item/knife))
|
||||
var/obj/item/knife/K = I
|
||||
if(!can_bayonet || !K.bayonet || bayonet) //ensure the gun has an attachment point available, and that the knife is compatible with it.
|
||||
return ..()
|
||||
if(!user.transferItemToLoc(I, src))
|
||||
return
|
||||
to_chat(user, span_notice("You attach [K] to [src]'s bayonet lug."))
|
||||
bayonet = K
|
||||
update_appearance()
|
||||
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/screwdriver_act(mob/living/user, obj/item/I)
|
||||
. = ..()
|
||||
if(.)
|
||||
|
||||
@@ -159,17 +159,18 @@
|
||||
underbarrel = new /obj/item/gun/ballistic/revolver/grenadelauncher/unrestricted(src)
|
||||
update_appearance()
|
||||
|
||||
/obj/item/gun/ballistic/automatic/m90/afterattack_secondary(atom/target, mob/living/user, proximity_flag, click_parameters)
|
||||
underbarrel.afterattack(target, user, proximity_flag, click_parameters)
|
||||
return SECONDARY_ATTACK_CONTINUE_CHAIN
|
||||
/obj/item/gun/ballistic/automatic/m90/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(LAZYACCESS(params2list(params), RIGHT_CLICK))
|
||||
return underbarrel.try_fire_gun(target, user, params)
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/ballistic/automatic/m90/attackby(obj/item/A, mob/user, params)
|
||||
if(isammocasing(A))
|
||||
if(istype(A, underbarrel.magazine.ammo_type))
|
||||
/obj/item/gun/ballistic/automatic/m90/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
|
||||
if(isammocasing(tool))
|
||||
if(istype(tool, underbarrel.magazine.ammo_type))
|
||||
underbarrel.attack_self(user)
|
||||
underbarrel.attackby(A, user, params)
|
||||
else
|
||||
..()
|
||||
underbarrel.attackby(tool, user, list2params(modifiers))
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/ballistic/automatic/tommygun
|
||||
name = "\improper Thompson SMG"
|
||||
@@ -276,15 +277,15 @@
|
||||
. += "l6_door_[cover_open ? "open" : "closed"]"
|
||||
|
||||
|
||||
/obj/item/gun/ballistic/automatic/l6_saw/afterattack(atom/target as mob|obj|turf, mob/living/user as mob|obj, flag, params)
|
||||
. |= AFTERATTACK_PROCESSED_ITEM
|
||||
|
||||
/obj/item/gun/ballistic/automatic/l6_saw/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(cover_open)
|
||||
balloon_alert(user, "close the cover!")
|
||||
return
|
||||
else
|
||||
. |= ..()
|
||||
return FALSE
|
||||
|
||||
. = ..()
|
||||
if(.)
|
||||
update_appearance()
|
||||
return .
|
||||
|
||||
//ATTACK HAND IGNORING PARENT RETURN VALUE
|
||||
/obj/item/gun/ballistic/automatic/l6_saw/attack_hand(mob/user, list/modifiers)
|
||||
|
||||
@@ -63,14 +63,13 @@
|
||||
playsound(src, 'sound/weapons/gun/bow/bow_draw.ogg', 25, TRUE)
|
||||
update_appearance()
|
||||
|
||||
/obj/item/gun/ballistic/bow/afterattack(atom/target, mob/living/user, flag, params, passthrough = FALSE)
|
||||
. |= AFTERATTACK_PROCESSED_ITEM
|
||||
/obj/item/gun/ballistic/bow/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(!chambered)
|
||||
return
|
||||
return FALSE
|
||||
if(!drawn)
|
||||
to_chat(user, span_warning("Without drawing the bow, the arrow uselessly falls to the ground."))
|
||||
drop_arrow()
|
||||
return
|
||||
return FALSE
|
||||
return ..() //fires, removing the arrow
|
||||
|
||||
/obj/item/gun/ballistic/bow/equipped(mob/user, slot, initial)
|
||||
|
||||
@@ -89,8 +89,10 @@
|
||||
This one has been fitted with a special backblast diverter to prevent 'friendly' fire 'accidents' during use."
|
||||
backblast = FALSE
|
||||
|
||||
/obj/item/gun/ballistic/rocketlauncher/afterattack()
|
||||
/obj/item/gun/ballistic/rocketlauncher/try_fire_gun(atom/target, mob/living/user, params)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
magazine.get_round(FALSE) //Hack to clear the mag after it's fired
|
||||
|
||||
/obj/item/gun/ballistic/rocketlauncher/attack_self_tk(mob/user)
|
||||
|
||||
@@ -85,21 +85,20 @@
|
||||
QDEL_NULL(underbarrel)
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/ballistic/automatic/pistol/clandestine/fisher/afterattack_secondary(atom/target, mob/living/user, proximity_flag, click_parameters)
|
||||
underbarrel.afterattack(target, user, proximity_flag, click_parameters)
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
/obj/item/gun/ballistic/automatic/pistol/clandestine/fisher/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(LAZYACCESS(params2list(params), RIGHT_CLICK))
|
||||
return underbarrel.try_fire_gun(target, user, params)
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/ballistic/automatic/pistol/clandestine/fisher/afterattack(atom/target, mob/living/user, flag, params)
|
||||
// mirrors what the standalone fisher does when you hit people with it
|
||||
. = ..()
|
||||
if(user.Adjacent(target))
|
||||
var/obj/projectile/energy/fisher/melee/simulated_hit = new
|
||||
simulated_hit.firer = user
|
||||
simulated_hit.on_hit(target)
|
||||
/obj/item/gun/ballistic/automatic/pistol/clandestine/fisher/afterattack(atom/target, mob/user, click_parameters)
|
||||
var/obj/projectile/energy/fisher/melee/simulated_hit = new
|
||||
simulated_hit.firer = user
|
||||
simulated_hit.on_hit(target)
|
||||
|
||||
/obj/item/gun/ballistic/automatic/pistol/clandestine/fisher/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
|
||||
// as above comment, mirrors what the standalone fisher does when you hit people with it
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
var/obj/projectile/energy/fisher/melee/simulated_hit = new
|
||||
simulated_hit.firer = throwingdatum.get_thrower()
|
||||
simulated_hit.on_hit(hit_atom)
|
||||
|
||||
@@ -218,26 +218,24 @@
|
||||
toggle_magazine()
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
|
||||
/obj/item/gun/ballistic/shotgun/bulldog/afterattack_secondary(mob/living/victim, mob/living/user, proximity_flag, click_parameters)
|
||||
/obj/item/gun/ballistic/shotgun/bulldog/ranged_interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(secondary_magazine)
|
||||
toggle_magazine()
|
||||
return SECONDARY_ATTACK_CALL_NORMAL
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/ballistic/shotgun/bulldog/attackby_secondary(obj/item/weapon, mob/user, params)
|
||||
if(!istype(weapon, secondary_magazine_type))
|
||||
balloon_alert(user, "[weapon.name] doesn't fit!")
|
||||
return SECONDARY_ATTACK_CALL_NORMAL
|
||||
if(!user.transferItemToLoc(weapon, src))
|
||||
to_chat(user, span_warning("You cannot seem to get [src] out of your hands!"))
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
/obj/item/gun/ballistic/shotgun/bulldog/item_interaction_secondary(mob/living/user, obj/item/tool, list/modifiers)
|
||||
if(!istype(tool, secondary_magazine_type))
|
||||
return ..()
|
||||
if(!user.transferItemToLoc(tool, src))
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
var/obj/item/ammo_box/magazine/old_mag = secondary_magazine
|
||||
secondary_magazine = weapon
|
||||
secondary_magazine = tool
|
||||
if(old_mag)
|
||||
user.put_in_hands(old_mag)
|
||||
balloon_alert(user, "secondary [magazine_wording] loaded")
|
||||
playsound(src, load_empty_sound, load_sound_volume, load_sound_vary)
|
||||
update_appearance()
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
|
||||
/obj/item/gun/ballistic/shotgun/bulldog/click_alt_secondary(mob/user)
|
||||
if(secondary_magazine)
|
||||
@@ -338,6 +336,7 @@
|
||||
. = ..()
|
||||
. += span_notice("Right-click to shoot the hook.")
|
||||
|
||||
/obj/item/gun/ballistic/shotgun/hook/afterattack_secondary(atom/target, mob/user, proximity_flag, click_parameters)
|
||||
hook.afterattack(target, user, proximity_flag, click_parameters)
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
/obj/item/gun/ballistic/shotgun/hook/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(LAZYACCESS(params2list(params), RIGHT_CLICK))
|
||||
return hook.try_fire_gun(target, user, params)
|
||||
return ..()
|
||||
|
||||
@@ -328,26 +328,27 @@
|
||||
sync_ammo()
|
||||
var/atom/target = source.mouse_object_ref?.resolve()
|
||||
if(target)
|
||||
INVOKE_ASYNC(src, PROC_REF(afterattack), target, source.mob, FALSE, source.mouseParams, passthrough = TRUE)
|
||||
INVOKE_ASYNC(src, PROC_REF(try_fire_gun), target, source.mob, source.mouseParams, TRUE)
|
||||
stop_aiming()
|
||||
QDEL_LIST(current_tracers)
|
||||
|
||||
/obj/item/gun/energy/beam_rifle/afterattack(atom/target, mob/living/user, flag, params, passthrough = FALSE)
|
||||
. |= AFTERATTACK_PROCESSED_ITEM
|
||||
if(flag) //It's adjacent, is the user, or is on the user's person
|
||||
/obj/item/gun/energy/beam_rifle/try_fire_gun(atom/target, mob/living/user, params, passthrough = FALSE)
|
||||
if(user.Adjacent(target)) //It's adjacent, is the user, or is on the user's person
|
||||
if(target in user.contents) //can't shoot stuff inside us.
|
||||
return
|
||||
return FALSE
|
||||
if(!ismob(target) || user.combat_mode) //melee attack
|
||||
return
|
||||
return FALSE
|
||||
if(target == user && user.zone_selected != BODY_ZONE_PRECISE_MOUTH) //so we can't shoot ourselves (unless mouth selected)
|
||||
return
|
||||
return FALSE
|
||||
if(!passthrough && (aiming_time > aiming_time_fire_threshold))
|
||||
return
|
||||
return FALSE
|
||||
if(lastfire > world.time + delay)
|
||||
return
|
||||
return FALSE
|
||||
if(!..())
|
||||
return FALSE
|
||||
lastfire = world.time
|
||||
. = ..()
|
||||
stop_aiming()
|
||||
return TRUE
|
||||
|
||||
/obj/item/gun/energy/beam_rifle/proc/sync_ammo()
|
||||
for(var/obj/item/ammo_casing/energy/beam_rifle/AC in contents)
|
||||
|
||||
@@ -149,10 +149,11 @@
|
||||
cell.give(transferred)
|
||||
|
||||
|
||||
/obj/item/gun/energy/minigun/afterattack(atom/target, mob/living/user, flag, params)
|
||||
/obj/item/gun/energy/minigun/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(!ammo_pack || ammo_pack.loc != user)
|
||||
to_chat(user, span_warning("You need the backpack power source to fire the gun!"))
|
||||
. = ..()
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
/obj/item/stock_parts/cell/minigun
|
||||
name = "gatling gun fusion core"
|
||||
|
||||
@@ -156,13 +156,13 @@
|
||||
While some would argue that this is a really terrible design choice, others argue that it is very funny to be able to shoot at light sources.<br>\
|
||||
Caveat emptor.")
|
||||
|
||||
/obj/item/gun/energy/recharge/fisher/afterattack(atom/target, mob/living/user, flag, params)
|
||||
// you should just shoot them, but in case you can't/wont
|
||||
/obj/item/gun/energy/recharge/fisher/attack(mob/living/target_mob, mob/living/user, params)
|
||||
. = ..()
|
||||
if(user.Adjacent(target))
|
||||
var/obj/projectile/energy/fisher/melee/simulated_hit = new
|
||||
simulated_hit.firer = user
|
||||
simulated_hit.on_hit(target)
|
||||
if(.)
|
||||
return
|
||||
var/obj/projectile/energy/fisher/melee/simulated_hit = new
|
||||
simulated_hit.firer = user
|
||||
simulated_hit.on_hit(target_mob)
|
||||
|
||||
/obj/item/gun/energy/recharge/fisher/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
|
||||
// ...you reeeeeally just shoot them, but in case you can't/won't
|
||||
|
||||
@@ -231,17 +231,15 @@
|
||||
if(istype(WH))
|
||||
WH.gun = WEAKREF(src)
|
||||
|
||||
/obj/item/gun/energy/wormhole_projector/afterattack(atom/target, mob/living/user, flag, params)
|
||||
if(select == AMMO_SELECT_ORANGE) //Last fired in right click mode. Switch to blue wormhole (left click).
|
||||
select_fire()
|
||||
/obj/item/gun/energy/wormhole_projector/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(LAZYACCESS(params2list(params), RIGHT_CLICK))
|
||||
if(select == AMMO_SELECT_BLUE) //Last fired in left click mode. Switch to orange wormhole (right click).
|
||||
select_fire()
|
||||
else
|
||||
if(select == AMMO_SELECT_ORANGE) //Last fired in right click mode. Switch to blue wormhole (left click).
|
||||
select_fire()
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/energy/wormhole_projector/afterattack_secondary(atom/target, mob/living/user, flag, params)
|
||||
if(select == AMMO_SELECT_BLUE) //Last fired in left click mode. Switch to orange wormhole (right click).
|
||||
select_fire()
|
||||
fire_gun(target, user, flag, params)
|
||||
return SECONDARY_ATTACK_CONTINUE_CHAIN
|
||||
|
||||
/obj/item/gun/energy/wormhole_projector/proc/on_portal_destroy(obj/effect/portal/P)
|
||||
SIGNAL_HANDLER
|
||||
if(P == p_blue)
|
||||
@@ -408,13 +406,15 @@
|
||||
coin_count++
|
||||
COOLDOWN_START(src, coin_regen_cd, coin_regen_rate)
|
||||
|
||||
/obj/item/gun/energy/marksman_revolver/afterattack_secondary(atom/target, mob/living/user, params)
|
||||
if(!CAN_THEY_SEE(target, user))
|
||||
/obj/item/gun/energy/marksman_revolver/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(!LAZYACCESS(params2list(params), RIGHT_CLICK))
|
||||
return ..()
|
||||
if(!CAN_THEY_SEE(target, user))
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
|
||||
if(max_coins && coin_count <= 0)
|
||||
to_chat(user, span_warning("You don't have any coins right now!"))
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
|
||||
if(max_coins)
|
||||
START_PROCESSING(SSobj, src)
|
||||
@@ -426,5 +426,4 @@
|
||||
var/obj/projectile/bullet/coin/new_coin = new(get_turf(user), target_turf, user)
|
||||
new_coin.preparePixelProjectile(target_turf, user)
|
||||
new_coin.fire()
|
||||
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
|
||||
@@ -33,24 +33,23 @@
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/item/gun/magic/wand/afterattack(atom/target, mob/living/user)
|
||||
. |= AFTERATTACK_PROCESSED_ITEM
|
||||
/obj/item/gun/magic/wand/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if(!charges)
|
||||
shoot_with_empty_chamber(user)
|
||||
return
|
||||
return FALSE
|
||||
if(target == user)
|
||||
if(no_den_usage)
|
||||
var/area/A = get_area(user)
|
||||
if(istype(A, /area/centcom/wizard_station))
|
||||
to_chat(user, span_warning("You know better than to violate the security of The Den, best wait until you leave to use [src]."))
|
||||
return
|
||||
else
|
||||
no_den_usage = 0
|
||||
if(no_den_usage && istype(get_area(user), /area/centcom/wizard_station))
|
||||
to_chat(user, span_warning("You know better than to violate the security of The Den, best wait until you leave to use [src]."))
|
||||
return FALSE
|
||||
zap_self(user)
|
||||
else
|
||||
. |= ..()
|
||||
update_appearance()
|
||||
. = TRUE
|
||||
|
||||
else
|
||||
. = ..()
|
||||
|
||||
if(.)
|
||||
update_appearance()
|
||||
return .
|
||||
|
||||
/obj/item/gun/magic/wand/proc/zap_self(mob/living/user)
|
||||
user.visible_message(span_danger("[user] zaps [user.p_them()]self with [src]."))
|
||||
|
||||
@@ -110,10 +110,8 @@
|
||||
update_appearance()
|
||||
return TRUE
|
||||
|
||||
/obj/item/gun/blastcannon/afterattack(atom/target, mob/user, flag, params)
|
||||
. |= AFTERATTACK_PROCESSED_ITEM
|
||||
|
||||
if((!bomb && bombcheck) || !target || (get_dist(get_turf(target), get_turf(user)) <= 2))
|
||||
/obj/item/gun/blastcannon/try_fire_gun(atom/target, mob/living/user, params)
|
||||
if((!bomb && bombcheck) || isnull(target) || (get_dist(get_turf(target), get_turf(user)) <= 2))
|
||||
return ..()
|
||||
|
||||
cached_target = WEAKREF(target)
|
||||
@@ -123,12 +121,12 @@
|
||||
span_danger("[user] points [src] at [target]!"),
|
||||
span_danger("You point [src] at [target]!")
|
||||
)
|
||||
return
|
||||
return FALSE
|
||||
|
||||
cached_firer = WEAKREF(user)
|
||||
if(!bomb)
|
||||
fire_debug(target, user, flag, params)
|
||||
return
|
||||
fire_debug(target, user, params)
|
||||
return TRUE
|
||||
|
||||
playsound(src, dry_fire_sound, 30, TRUE) // *click
|
||||
user.visible_message(
|
||||
@@ -141,8 +139,7 @@
|
||||
user.log_message("opened blastcannon transfer valve at [AREACOORD(current_turf)] while aiming at [AREACOORD(target_turf)] (target).", LOG_GAME)
|
||||
bomb.toggle_valve()
|
||||
update_appearance()
|
||||
return
|
||||
|
||||
return TRUE
|
||||
|
||||
/**
|
||||
* Channels an internal explosion into a blastwave projectile.
|
||||
|
||||
@@ -37,29 +37,36 @@
|
||||
balloon_alert(user, "not enough gold")
|
||||
|
||||
// Siphon gold from a victim, recharging our gun & removing their Midas Blight debuff in the process.
|
||||
/obj/item/gun/magic/midas_hand/afterattack_secondary(mob/living/victim, mob/living/user, proximity_flag, click_parameters)
|
||||
if(!isliving(victim) || !IN_GIVEN_RANGE(user, victim, gold_suck_range))
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
if(victim == user)
|
||||
balloon_alert(user, "can't siphon from self")
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
if(!victim.reagents)
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
/obj/item/gun/magic/midas_hand/ranged_interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(!isliving(interacting_with) || !IN_GIVEN_RANGE(user, interacting_with, gold_suck_range))
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
if(interacting_with == user)
|
||||
balloon_alert(user, "can't siphon from self!")
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
if(!interacting_with.reagents)
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
|
||||
var/gold_amount = victim.reagents.get_reagent_amount(/datum/reagent/gold, type_check = REAGENT_SUB_TYPE)
|
||||
var/gold_amount = interacting_with.reagents.get_reagent_amount(/datum/reagent/gold, type_check = REAGENT_SUB_TYPE)
|
||||
if(!gold_amount)
|
||||
balloon_alert(user, "no gold in bloodstream")
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
var/gold_beam = user.Beam(victim, icon_state="drain_gold")
|
||||
if(!do_after(user = user, delay = 1 SECONDS, target = victim, timed_action_flags = (IGNORE_USER_LOC_CHANGE | IGNORE_TARGET_LOC_CHANGE), extra_checks = CALLBACK(src, PROC_REF(check_gold_range), user, victim)))
|
||||
balloon_alert(user, "no gold in bloodstream!")
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
var/mob/living/victim = interacting_with
|
||||
var/gold_beam = user.Beam(victim, icon_state = "drain_gold")
|
||||
if(!do_after(
|
||||
user = user,
|
||||
delay = 1 SECONDS,
|
||||
target = victim,
|
||||
timed_action_flags = (IGNORE_USER_LOC_CHANGE | IGNORE_TARGET_LOC_CHANGE),
|
||||
extra_checks = CALLBACK(src, PROC_REF(check_gold_range), user, victim),
|
||||
))
|
||||
qdel(gold_beam)
|
||||
balloon_alert(user, "link broken")
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
balloon_alert(user, "link broken!")
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
handle_gold_charges(user, gold_amount)
|
||||
victim.reagents.remove_reagent(/datum/reagent/gold, gold_amount, include_subtypes = TRUE)
|
||||
victim.remove_status_effect(/datum/status_effect/midas_blight)
|
||||
qdel(gold_beam)
|
||||
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
|
||||
// If we botch a shot, we have to start over again by inserting gold coins into the gun. Can only be done if it has no charges or gold.
|
||||
/obj/item/gun/magic/midas_hand/attackby(obj/item/I, mob/living/user, params)
|
||||
|
||||
@@ -77,23 +77,23 @@
|
||||
|
||||
return TRUE
|
||||
|
||||
/obj/item/gun/syringe/attackby(obj/item/A, mob/user, params, show_msg = TRUE)
|
||||
if(istype(A, /obj/item/reagent_containers/syringe/bluespace))
|
||||
balloon_alert(user, "[A.name] is too big!")
|
||||
return TRUE
|
||||
if(istype(A, /obj/item/reagent_containers/syringe))
|
||||
/obj/item/gun/syringe/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
|
||||
if(istype(tool, /obj/item/reagent_containers/syringe/bluespace))
|
||||
balloon_alert(user, "[tool.name] is too big!")
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
if(istype(tool, /obj/item/reagent_containers/syringe))
|
||||
if(syringes.len < max_syringes)
|
||||
if(!user.transferItemToLoc(A, src))
|
||||
return FALSE
|
||||
balloon_alert(user, "[A.name] loaded")
|
||||
syringes += A
|
||||
if(!user.transferItemToLoc(tool, src))
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
balloon_alert(user, "[tool.name] loaded")
|
||||
syringes += tool
|
||||
recharge_newshot()
|
||||
update_appearance()
|
||||
playsound(loc, load_sound, 40)
|
||||
return TRUE
|
||||
else
|
||||
balloon_alert(user, "it's already full!")
|
||||
return FALSE
|
||||
playsound(src, load_sound, 40)
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
balloon_alert(user, "it's full!")
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
return NONE
|
||||
|
||||
/obj/item/gun/syringe/update_overlays()
|
||||
. = ..()
|
||||
@@ -158,24 +158,24 @@
|
||||
. = ..()
|
||||
chambered = new /obj/item/ammo_casing/dnainjector(src)
|
||||
|
||||
/obj/item/gun/syringe/dna/attackby(obj/item/A, mob/user, params, show_msg = TRUE)
|
||||
if(istype(A, /obj/item/dnainjector))
|
||||
var/obj/item/dnainjector/D = A
|
||||
/obj/item/gun/syringe/dna/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
|
||||
if(istype(tool, /obj/item/dnainjector))
|
||||
var/obj/item/dnainjector/D = tool
|
||||
if(D.used)
|
||||
balloon_alert(user, "[D.name] is used up!")
|
||||
return
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
if(syringes.len < max_syringes)
|
||||
if(!user.transferItemToLoc(D, src))
|
||||
return FALSE
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
balloon_alert(user, "[D.name] loaded")
|
||||
syringes += D
|
||||
recharge_newshot()
|
||||
update_appearance()
|
||||
playsound(loc, load_sound, 40)
|
||||
return TRUE
|
||||
else
|
||||
balloon_alert(user, "it's already full!")
|
||||
return FALSE
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
balloon_alert(user, "it's already full!")
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
return NONE
|
||||
|
||||
/obj/item/gun/syringe/blowgun
|
||||
name = "blowgun"
|
||||
|
||||
@@ -25,32 +25,31 @@
|
||||
if(isgun(newloc))
|
||||
gun = newloc
|
||||
|
||||
/obj/item/firing_pin/afterattack(atom/target, mob/user, proximity_flag)
|
||||
. = ..()
|
||||
if(proximity_flag)
|
||||
if(isgun(target))
|
||||
. |= AFTERATTACK_PROCESSED_ITEM
|
||||
var/obj/item/gun/targeted_gun = target
|
||||
var/obj/item/firing_pin/old_pin = targeted_gun.pin
|
||||
if(old_pin?.pin_removable && (force_replace || old_pin.pin_hot_swappable))
|
||||
if(Adjacent(user))
|
||||
user.put_in_hands(old_pin)
|
||||
else
|
||||
old_pin.forceMove(targeted_gun.drop_location())
|
||||
old_pin.gun_remove(user)
|
||||
/obj/item/firing_pin/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(!isgun(interacting_with))
|
||||
return NONE
|
||||
|
||||
if(!targeted_gun.pin)
|
||||
if(!user.temporarilyRemoveItemFromInventory(src))
|
||||
return .
|
||||
if(gun_insert(user, targeted_gun))
|
||||
if(old_pin)
|
||||
balloon_alert(user, "swapped firing pin")
|
||||
else
|
||||
balloon_alert(user, "inserted firing pin")
|
||||
else
|
||||
to_chat(user, span_notice("This firearm already has a firing pin installed."))
|
||||
var/obj/item/gun/targeted_gun = interacting_with
|
||||
var/obj/item/firing_pin/old_pin = targeted_gun.pin
|
||||
if(old_pin?.pin_removable && (force_replace || old_pin.pin_hot_swappable))
|
||||
if(Adjacent(user))
|
||||
user.put_in_hands(old_pin)
|
||||
else
|
||||
old_pin.forceMove(targeted_gun.drop_location())
|
||||
old_pin.gun_remove(user)
|
||||
|
||||
if(!targeted_gun.pin)
|
||||
if(!user.temporarilyRemoveItemFromInventory(src))
|
||||
return .
|
||||
if(gun_insert(user, targeted_gun))
|
||||
if(old_pin)
|
||||
balloon_alert(user, "swapped firing pin")
|
||||
else
|
||||
balloon_alert(user, "inserted firing pin")
|
||||
else
|
||||
to_chat(user, span_notice("This firearm already has a firing pin installed."))
|
||||
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
|
||||
/obj/item/firing_pin/emag_act(mob/user, obj/item/card/emag/emag_card)
|
||||
if(obj_flags & EMAGGED)
|
||||
@@ -190,13 +189,15 @@
|
||||
fail_message = "dna check failed!"
|
||||
var/unique_enzymes = null
|
||||
|
||||
/obj/item/firing_pin/dna/afterattack(atom/target, mob/user, proximity_flag)
|
||||
. = ..()
|
||||
if(proximity_flag && iscarbon(target))
|
||||
var/mob/living/carbon/M = target
|
||||
/obj/item/firing_pin/dna/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
|
||||
if(iscarbon(interacting_with))
|
||||
var/mob/living/carbon/M = interacting_with
|
||||
if(M.dna && M.dna.unique_enzymes)
|
||||
unique_enzymes = M.dna.unique_enzymes
|
||||
balloon_alert(user, "dna lock set")
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
return ..()
|
||||
|
||||
/obj/item/firing_pin/dna/pin_auth(mob/living/carbon/user)
|
||||
if(user && user.dna && user.dna.unique_enzymes)
|
||||
|
||||
Reference in New Issue
Block a user