mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
Guncode Agony 4.4: Armor as an argument (#88143)
## About The Pull Request Lil cleanup/tweak I couldn't do in the main PR because it conflicted before and i forgot after. Yes this works with overrides that don't have the arg, yes I tested it. ## Why It's Good For The Game Don't run armor code thrice please thank you ## Changelog 🆑 code: Projectile impacts no longer fetch mobs' armor values thrice /🆑
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#define COMSIG_ATOM_EMP_ACT "atom_emp_act"
|
||||
///from base of atom/fire_act(): (exposed_temperature, exposed_volume)
|
||||
#define COMSIG_ATOM_FIRE_ACT "atom_fire_act"
|
||||
///from base of atom/bullet_act(): (/obj/projectile, def_zone)
|
||||
///from base of atom/bullet_act(): (/obj/proj, def_zone, piercing_hit, blocked)
|
||||
#define COMSIG_ATOM_PRE_BULLET_ACT "pre_atom_bullet_act"
|
||||
/// All this does is prevent default bullet on_hit from being called, [BULLET_ACT_HIT] being return is implied
|
||||
#define COMPONENT_BULLET_ACTED (1<<0)
|
||||
@@ -22,7 +22,7 @@
|
||||
#define COMPONENT_BULLET_BLOCKED (1<<1)
|
||||
/// Forces bullet act to return [BULLET_ACT_FORCE_PIERCE], takes priority over above
|
||||
#define COMPONENT_BULLET_PIERCED (1<<2)
|
||||
///from base of atom/bullet_act(): (/obj/projectile, def_zone)
|
||||
///from base of atom/bullet_act(): (/obj/proj, def_zone, piercing_hit, blocked)
|
||||
#define COMSIG_ATOM_BULLET_ACT "atom_bullet_act"
|
||||
///from base of atom/CheckParts(): (list/parts_list, datum/crafting_recipe/R)
|
||||
#define COMSIG_ATOM_CHECKPARTS "atom_checkparts"
|
||||
|
||||
@@ -76,17 +76,32 @@
|
||||
return protection // Pass the protection value collected here upwards
|
||||
|
||||
/**
|
||||
* React to a hit by a projectile object
|
||||
* Wrapper for bullet_act used for atom-specific calculations, i.e. armor
|
||||
*
|
||||
* @params
|
||||
* * hitting_projectile - projectile
|
||||
* * def_zone - zone hit
|
||||
* * piercing_hit - is this hit piercing or normal?
|
||||
*/
|
||||
/atom/proc/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit = FALSE)
|
||||
|
||||
/atom/proc/projectile_hit(obj/projectile/hitting_projectile, def_zone, piercing_hit = FALSE, blocked = null)
|
||||
if (isnull(blocked))
|
||||
blocked = check_projectile_armor(def_zone, hitting_projectile)
|
||||
return bullet_act(hitting_projectile, def_zone, piercing_hit, blocked)
|
||||
|
||||
/**
|
||||
* React to a hit by a projectile object
|
||||
*
|
||||
* @params
|
||||
* * hitting_projectile - projectile
|
||||
* * def_zone - zone hit
|
||||
* * piercing_hit - is this hit piercing or normal?
|
||||
* * blocked - total armor value to apply to this hit
|
||||
*/
|
||||
/atom/proc/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit = FALSE, blocked = 0)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
|
||||
var/sigreturn = SEND_SIGNAL(src, COMSIG_ATOM_PRE_BULLET_ACT, hitting_projectile, def_zone)
|
||||
var/sigreturn = SEND_SIGNAL(src, COMSIG_ATOM_PRE_BULLET_ACT, hitting_projectile, def_zone, piercing_hit, blocked)
|
||||
if(sigreturn & COMPONENT_BULLET_PIERCED)
|
||||
return BULLET_ACT_FORCE_PIERCE
|
||||
if(sigreturn & COMPONENT_BULLET_BLOCKED)
|
||||
@@ -94,7 +109,7 @@
|
||||
if(sigreturn & COMPONENT_BULLET_ACTED)
|
||||
return BULLET_ACT_HIT
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_BULLET_ACT, hitting_projectile, def_zone)
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_BULLET_ACT, hitting_projectile, def_zone, piercing_hit, blocked)
|
||||
if(QDELETED(hitting_projectile)) // Signal deleted it?
|
||||
return BULLET_ACT_BLOCK
|
||||
|
||||
@@ -102,7 +117,7 @@
|
||||
target = src,
|
||||
// This armor check only matters for the visuals and messages in on_hit(), it's not actually used to reduce damage since
|
||||
// only living mobs use armor to reduce damage, but on_hit() is going to need the value no matter what is shot.
|
||||
blocked = check_projectile_armor(def_zone, hitting_projectile),
|
||||
blocked = blocked,
|
||||
pierce_hit = piercing_hit,
|
||||
)
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@
|
||||
mutate()
|
||||
return BULLET_ACT_HIT
|
||||
if(istype(proj, /obj/projectile/energy/flora/yield))
|
||||
return myseed.bullet_act(proj)
|
||||
return myseed.projectile_hit(proj)
|
||||
if(istype(proj, /obj/projectile/energy/flora/evolution))
|
||||
if(myseed)
|
||||
if(LAZYLEN(myseed.mutatelist))
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
var/hits = ((max_hits - min_hits) * severity + min_hits)
|
||||
|
||||
for(var/i in 1 to hits)
|
||||
body.bullet_act(projectile, def_zone = pick(GLOB.all_body_zones), piercing_hit = TRUE)
|
||||
body.projectile_hit(projectile, def_zone = pick(GLOB.all_body_zones), piercing_hit = TRUE)
|
||||
|
||||
/datum/corpse_damage/cause_of_death/projectile/laser
|
||||
projectile = /obj/projectile/beam/laser
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
playsound(src, held_item.block_sound, BLOCK_SOUND_VOLUME, TRUE)
|
||||
// Find a turf near or on the original location to bounce to
|
||||
if(!isturf(loc)) //Open canopy mech (ripley) check. if we're inside something and still got hit
|
||||
return loc.bullet_act(bullet, def_zone, piercing_hit)
|
||||
return loc.projectile_hit(bullet, def_zone, piercing_hit)
|
||||
bullet.reflect(src)
|
||||
return BULLET_ACT_FORCE_PIERCE // complete projectile permutation
|
||||
|
||||
|
||||
@@ -91,12 +91,11 @@
|
||||
/mob/living/proc/is_ears_covered()
|
||||
return null
|
||||
|
||||
/mob/living/bullet_act(obj/projectile/proj, def_zone, piercing_hit = FALSE)
|
||||
/mob/living/bullet_act(obj/projectile/proj, def_zone, piercing_hit = FALSE, blocked = 0)
|
||||
. = ..()
|
||||
if (. != BULLET_ACT_HIT)
|
||||
return .
|
||||
|
||||
var/blocked = check_projectile_armor(def_zone, proj, is_silent = TRUE)
|
||||
if(blocked >= 100)
|
||||
if(proj.is_hostile_projectile())
|
||||
apply_projectile_effects(proj, def_zone, blocked)
|
||||
|
||||
@@ -187,6 +187,6 @@
|
||||
// "Burn" damage is equally strong against internal components and exterior casing
|
||||
// "Brute" damage mostly damages the casing.
|
||||
/obj/machinery/modular_computer/bullet_act(obj/projectile/proj)
|
||||
return cpu?.bullet_act(proj) || ..()
|
||||
return cpu?.projectile_hit(proj) || ..()
|
||||
|
||||
#undef CPU_INTERACTABLE
|
||||
|
||||
@@ -533,7 +533,7 @@
|
||||
pierces += 1
|
||||
|
||||
// Targets should handle their impact logic on our own and if they decide that we hit them, they call our on_hit
|
||||
var/result = target.bullet_act(src, def_zone, mode == PROJECTILE_PIERCE_HIT)
|
||||
var/result = target.projectile_hit(src, def_zone, mode == PROJECTILE_PIERCE_HIT)
|
||||
if (result != BULLET_ACT_FORCE_PIERCE && max_pierces && pierces >= max_pierces)
|
||||
return PROJECTILE_IMPACT_SUCCESSFUL
|
||||
|
||||
|
||||
@@ -107,14 +107,13 @@
|
||||
organ_owner.update_sight()
|
||||
UnregisterSignal(organ_owner, COMSIG_ATOM_BULLET_ACT)
|
||||
|
||||
/obj/item/organ/eyes/proc/on_bullet_act(mob/living/carbon/source, obj/projectile/proj, def_zone)
|
||||
/obj/item/organ/eyes/proc/on_bullet_act(mob/living/carbon/source, obj/projectile/proj, def_zone, piercing_hit, blocked)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
// Once-a-dozen-rounds level of rare
|
||||
if (def_zone != BODY_ZONE_HEAD || !prob(proj.damage * 0.1) || !(proj.damage_type == BRUTE || proj.damage_type == BURN))
|
||||
return
|
||||
|
||||
var/blocked = source.check_projectile_armor(def_zone, proj, is_silent = TRUE)
|
||||
if (blocked && source.is_eyes_covered())
|
||||
if (!proj.armour_penetration || prob(blocked - proj.armour_penetration))
|
||||
return
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
if(prob(50) || !LAZYLEN(buckled_mobs))
|
||||
return ..()
|
||||
for(var/mob/buckled_mob as anything in buckled_mobs)
|
||||
return buckled_mob.bullet_act(proj)
|
||||
return buckled_mob.projectile_hit(proj)
|
||||
return ..()
|
||||
|
||||
/obj/vehicle/ridden/atv/atom_destruction()
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
//Redirects projectiles to the shield if defense_check decides they should be blocked and returns true.
|
||||
/obj/vehicle/sealed/mecha/durand/bullet_act(obj/projectile/source, def_zone, mode)
|
||||
if(defense_check(source.loc) && shield)
|
||||
return shield.bullet_act(source, def_zone, mode)
|
||||
return shield.projectile_hit(source, def_zone, mode)
|
||||
return ..()
|
||||
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
&& !(mecha_flags & SILICON_PILOT) \
|
||||
&& (def_zone == BODY_ZONE_HEAD || def_zone == BODY_ZONE_CHEST))
|
||||
var/mob/living/hitmob = pick(occupants)
|
||||
return hitmob.bullet_act(hitting_projectile, def_zone, piercing_hit) //If the sides are open, the occupant can be hit
|
||||
return hitmob.projectile_hit(hitting_projectile, def_zone, piercing_hit) //If the sides are open, the occupant can be hit
|
||||
|
||||
. = ..()
|
||||
|
||||
|
||||
@@ -101,5 +101,5 @@
|
||||
if(!buckled_mobs || prob(40))
|
||||
return ..()
|
||||
for(var/mob/rider as anything in buckled_mobs)
|
||||
return rider.bullet_act(proj)
|
||||
return rider.projectile_hit(proj)
|
||||
return ..()
|
||||
|
||||
Reference in New Issue
Block a user