Files
SmArtKar f58b8511f0 Refactors effect_system (#94999)
## About The Pull Request

This PR refactors ``effect_system``s to be a bit easier to use by
getting rid of ``set_up``, allowing ``attach()`` to be chained into
``start()`` and refactoring most direct system usages in our code to use
helper procs.

``set_up`` was unnecessary and only existed to allow ``New``'s behavior
to be fully overriden, which is not required if we split
sparks/lightning/steam into a new ``/datum/effect_system/basic`` subtype
which houses the effect spreading behavior. This allows us to roll all
logic from ``set_up`` into ``New`` and cut down on code complexity.
Chaining setup as ``system.attach(src).start()`` also helps a bit in
case no helper method exists

I've added ``do_chem_smoke`` and ``do_foam`` helpers, which respectively
allow chemical smoke or foam to be spawned easily without having to
manually create effect datums and reagent holders.

Also turns out we've had some nonfunctional effect systems which either
never set themselves up, or never started, so I fixed those while I was
at it (mostly by moving them to aforementioned helper procs)

## Why It's Good For The Game

Cleaner code, makes it significantly easier for users to work with. Also
most of our effect system usage was copypasta which was passing booleans
as numbers, while perfectly fine helper procs existed in our code.

## Changelog
🆑
refactor: Refactored sparks, foam, smoke, and other miscellaneous effect
systems.
refactor: Vapes now have consistent rigging with cigs using the new
system.
fix: Fixed some effects never working.
/🆑
2026-02-03 22:23:09 -05:00

127 lines
3.6 KiB
Plaintext

/obj/vehicle/ridden/atv
name = "all-terrain vehicle"
desc = "An all-terrain vehicle built for traversing rough terrain with ease. One of the few old-Earth technologies that are still relevant on most planet-bound outposts."
icon_state = "atv"
max_integrity = 150
armor_type = /datum/armor/ridden_atv
key_type = /obj/item/key/atv
integrity_failure = 0.5
var/static/mutable_appearance/atvcover
/datum/armor/ridden_atv
melee = 50
bullet = 25
laser = 20
bomb = 50
fire = 60
acid = 60
/obj/vehicle/ridden/atv/Initialize(mapload)
. = ..()
AddElement(/datum/element/ridable, /datum/component/riding/vehicle/atv)
if(!atvcover)
atvcover = mutable_appearance(icon, "atvcover", MOB_LAYER + 0.1)
/obj/vehicle/ridden/atv/post_buckle_mob(mob/living/M)
add_overlay(atvcover)
return ..()
/obj/vehicle/ridden/atv/post_unbuckle_mob(mob/living/M)
if(!has_buckled_mobs())
cut_overlay(atvcover)
return ..()
//TURRETS!
/obj/vehicle/ridden/atv/turret
var/obj/machinery/porta_turret/syndicate/vehicle_turret/turret = null
/obj/machinery/porta_turret/syndicate/vehicle_turret
name = "mounted turret"
scan_range = 7
density = FALSE
/obj/vehicle/ridden/atv/turret/Initialize(mapload)
. = ..()
turret = new(loc)
turret.base = src
/obj/vehicle/ridden/atv/turret/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE)
. = ..()
if(!turret)
return
var/turf/our_turf = get_turf(src)
if(!our_turf)
return
turret.forceMove(our_turf)
switch(dir)
if(NORTH)
turret.pixel_x = base_pixel_x
turret.pixel_y = base_pixel_y + 4
turret.layer = ABOVE_MOB_LAYER
if(EAST)
turret.pixel_x = base_pixel_x - 12
turret.pixel_y = base_pixel_y + 4
turret.layer = OBJ_LAYER
if(SOUTH)
turret.pixel_x = base_pixel_x
turret.pixel_y = base_pixel_y + 4
turret.layer = OBJ_LAYER
if(WEST)
turret.pixel_x = base_pixel_x + 12
turret.pixel_y = base_pixel_y + 4
turret.layer = OBJ_LAYER
/obj/vehicle/ridden/atv/welder_act(mob/living/user, obj/item/W)
if(user.combat_mode)
return
. = TRUE
if(DOING_INTERACTION(user, src))
balloon_alert(user, "you're already repairing it!")
return
if(atom_integrity >= max_integrity)
balloon_alert(user, "it's not damaged!")
return
if(!W.tool_start_check(user, amount=1, heat_required = HIGH_TEMPERATURE_REQUIRED))
return
user.balloon_alert_to_viewers("started welding [src]", "started repairing [src]")
audible_message(span_hear("You hear welding."))
var/did_the_thing
while(atom_integrity < max_integrity)
if(W.use_tool(src, user, 2.5 SECONDS, volume=50))
did_the_thing = TRUE
atom_integrity += min(10, (max_integrity - atom_integrity))
audible_message(span_hear("You hear welding."))
else
break
if(did_the_thing)
user.balloon_alert_to_viewers("[(atom_integrity >= max_integrity) ? "fully" : "partially"] repaired [src]")
else
user.balloon_alert_to_viewers("stopped welding [src]", "interrupted the repair!")
/obj/vehicle/ridden/atv/atom_break()
START_PROCESSING(SSobj, src)
return ..()
/obj/vehicle/ridden/atv/process(seconds_per_tick)
if(atom_integrity >= integrity_failure * max_integrity)
return PROCESS_KILL
if(SPT_PROB(10, seconds_per_tick))
return
do_smoke(0, src, src)
/obj/vehicle/ridden/atv/projectile_hit(obj/projectile/hitting_projectile, def_zone, piercing_hit, blocked)
if(prob(50) || !LAZYLEN(buckled_mobs))
return ..()
for(var/mob/buckled_mob as anything in buckled_mobs)
return buckled_mob.projectile_hit(hitting_projectile)
return ..()
/obj/vehicle/ridden/atv/atom_destruction()
explosion(src, devastation_range = -1, light_impact_range = 2, flame_range = 3, flash_range = 4)
return ..()
/obj/vehicle/ridden/atv/Destroy()
STOP_PROCESSING(SSobj,src)
return ..()