Files
Bubberstation/code/game/objects/items/shooting_range.dm
SkyratBot b6da56408e [MIRROR] A comprehensive refactor / cleanup of bullet_hit and on_hit to cut out a single bad species / mob proc [MDB IGNORE] (#24430)
* A comprehensive refactor / cleanup of `bullet_hit` and `on_hit` to cut out a single bad species / mob proc (#79024)

## About The Pull Request

- Refactored `bullet_act`. Adds `should_call_parent` and refactors
associated children to support that.
   - Fixes silicons sparking off when hit by disabler fire.
- Desnowflakes firing range target integrity and cleans up its
bullet-hole code a bit.
- Cleans up changeling tentacle code a fair bit and fixes it not taking
off throw mode if you fail to catch something.
   - The Sleeping Carp deflection is now signalized
- Nightmare projectile dodging is now signalized and sourced from the
Nightmare's brain rather than species
- Refactored how cardboard cutouts get knocked over to be less
snowflaked / use integrity
- Also adds projectile `on_hit` `should_call_parent` and cleans up a bit
of that, particularly their arguments.
- On hit arguments were passed wrong this entire time, it's a good thing
nothing relied on that.

## Why It's Good For The Game

This is cringe.

1863eb2cd8/code/modules/mob/living/carbon/human/_species.dm (L1430-L1442)

Bullets should overall act more consistent across mob types and objects.

## Changelog

🆑 Melbert
fix: Silicons don't spark when shot by disablers
fix: Changelings who fail to catch something with a tencacle will have
throw mode disabled automatically
fix: Fixes occasions where you can reflect with Sleeping Carp when you
shouldn't be able to
fix: Fixes some projectiles causing like 20x less eye blur than they
should be
refactor: Refactored bullet-mob interactions
refactor: Nightmare "shadow dodge" projectile ability is now sourced
from their brain
/🆑

* A comprehensive refactor / cleanup of `bullet_hit` and `on_hit` to cut out a single bad species / mob proc

* Modular changes

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
2023-10-19 22:18:41 -04:00

88 lines
3.0 KiB
Plaintext

/obj/item/target
name = "shooting target"
desc = "A shooting target."
icon = 'icons/obj/structures.dmi'
icon_state = "target_h"
density = FALSE
max_integrity = 1800
item_flags = CAN_BE_HIT
/// Lazylist to keep track of bullet-hole overlays.
var/list/bullethole_overlays
/obj/item/target/welder_act(mob/living/user, obj/item/tool)
if(tool.use_tool(src, user, 0 SECONDS, volume = 40))
LAZYNULL(bullethole_overlays)
balloon_alert(user, "target repaired")
update_appearance(UPDATE_OVERLAYS)
return TRUE
/obj/item/target/update_overlays()
. = ..()
. |= bullethole_overlays
/obj/item/target/bullet_act(obj/projectile/hitting_projectile, def_zone, piercing_hit = FALSE)
if(prob(25))
return ..() // RNG change to just not leave a mark, like walls
if(length(overlays) > 35)
return ..() // Too many bullets, we're done here
// Projectiles which do not deal damage will not leave dent / scorch mark graphics.
// However we snowflake some projectiles to leave them anyway, because they're appropriate.
var/static/list/always_leave_marks
if(isnull(always_leave_marks))
always_leave_marks = typecacheof(list(
/obj/projectile/beam/practice,
/obj/projectile/beam/laser/carbine/practice,
))
var/is_invalid_damage = hitting_projectile.damage_type != BRUTE && hitting_projectile.damage_type != BURN
var/is_safe = !hitting_projectile.is_hostile_projectile()
var/is_generic_projectile = !is_type_in_typecache(hitting_projectile, always_leave_marks)
if(is_generic_projectile && (is_invalid_damage || is_safe))
return ..() // Don't bother unless it's real shit
var/p_x = hitting_projectile.p_x + pick(0, 0, 0, 0, 0, -1, 1) // really ugly way of coding "sometimes offset p_x!"
var/p_y = hitting_projectile.p_y + pick(0, 0, 0, 0, 0, -1, 1)
var/icon/our_icon = icon(icon, icon_state)
if(!our_icon.GetPixel(p_x, p_y) || hitting_projectile.original != src)
return BULLET_ACT_FORCE_PIERCE // We, "missed", I guess?
. = ..()
if(. != BULLET_ACT_HIT)
return
var/image/bullet_hole = image('icons/effects/effects.dmi', "dent", OBJ_LAYER + 0.5)
bullet_hole.pixel_x = p_x - 1 //offset correction
bullet_hole.pixel_y = p_y - 1
if(hitting_projectile.damage_type != BRUTE)
bullet_hole.setDir(pick(GLOB.cardinals))// random scorch design
if(hitting_projectile.damage < 20 && is_generic_projectile)
bullet_hole.icon_state = "light_scorch"
else
bullet_hole.icon_state = "scorch"
LAZYADD(bullethole_overlays, bullet_hole)
update_appearance(UPDATE_OVERLAYS)
/obj/item/target/syndicate
icon_state = "target_s"
desc = "A shooting target that looks like syndicate scum."
max_integrity = 2600
/obj/item/target/alien
icon_state = "target_q"
desc = "A shooting target that looks like a xenomorphic alien."
max_integrity = 2350
/obj/item/target/alien/anchored
anchored = TRUE
/obj/item/target/clown
icon_state = "target_c"
desc = "A shooting target that looks like a useless clown."
max_integrity = 2000
/obj/item/target/clown/bullet_act(obj/projectile/P)
. = ..()
playsound(src, 'sound/items/bikehorn.ogg', 50, TRUE)