Skip to content

Commit

Permalink
Rework miasma in vehicles
Browse files Browse the repository at this point in the history
Add 6 second buffer timer before miasma deals damage
Add automatic cause_data creation in smoke initialize
  • Loading branch information
Drulikar committed Jun 6, 2024
1 parent c0a981c commit a50f945
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion code/game/gamemodes/colonialmarines/colonialmarines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
///Returns a list of non-dense turfs using the given block arguments ignoring the provided structure types
/datum/game_mode/colonialmarines/proc/get_valid_sentry_turfs(left, bottom, z, width, height, list/structures_to_ignore)
var/valid_turfs = list()
for(var/turf/turf in block(left, bottom, z, left+width-1, bottom+height-1))
for(var/turf/turf as anything in block(left, bottom, z, left+width-1, bottom+height-1))
if(turf.density)
continue
var/structure_blocking = FALSE
Expand Down
39 changes: 28 additions & 11 deletions code/game/objects/effects/effect_system/smoke.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@
pixel_x = -32
pixel_y = -32

/obj/effect/particle_effect/smoke/Initialize(mapload, oldamount, new_cause_data)
/obj/effect/particle_effect/smoke/Initialize(mapload, oldamount, datum/cause_data/new_cause_data)
. = ..()
if(oldamount)
amount = oldamount - 1
if(!istype(new_cause_data))
if(new_cause_data)
new_cause_data = create_cause_data(new_cause_data)
else
new_cause_data = create_cause_data(name)
cause_data = new_cause_data
time_to_live += rand(-1,1)
START_PROCESSING(SSeffects, src)
Expand Down Expand Up @@ -166,26 +171,37 @@
opacity = FALSE
alpha = 75
color = "#301934"
/// How much damage to deal per affect()
var/burn_damage = 4
/// Multiplier to burn_damage for xenos and yautja
var/xeno_yautja_multiplier = 3
/// Time required for damage to actually apply
var/active_time

/obj/effect/particle_effect/smoke/miasma/Initialize(mapload, oldamount, new_cause_data)
/obj/effect/particle_effect/smoke/miasma/Initialize(mapload, oldamount, datum/cause_data/new_cause_data)
. = ..()
// Mimic dispersal without actually doing spread logic
alpha = 0
active_time = world.time + 6 SECONDS
addtimer(VARSET_CALLBACK(src, alpha, initial(alpha)), rand(1, 6) SECONDS)

/obj/effect/particle_effect/smoke/miasma/process()
. = ..()
var/turf/turf = get_turf(src)
for(var/obj/structure/closet/container in turf)
/obj/effect/particle_effect/smoke/miasma/apply_smoke_effect(turf/cur_turf)
..()
// coffins
for(var/obj/structure/closet/container in cur_turf)
for(var/mob/living/carbon/mob in container)
affect(mob)
var/obj/vehicle/multitile/car = locate() in turf

// vehicles
var/obj/vehicle/multitile/car = locate() in cur_turf
var/datum/interior/car_interior = car?.interior
var/list/passengers = car_interior?.get_passengers()
for(var/mob/living/mob as anything in passengers)
affect(mob)
if(car_interior)
var/list/bounds = car_interior.get_bound_turfs()
for(var/turf/car_turf as anything in block(bounds[1], bounds[2]))
var/obj/effect/particle_effect/smoke/miasma/smoke = locate() in car_turf
if(!smoke)
smoke = new(car_turf)
smoke.time_to_live = rand(7, 12)

/obj/effect/particle_effect/smoke/miasma/affect(mob/living/carbon/affected_mob)
. = ..()
Expand All @@ -194,7 +210,8 @@
if(affected_mob.stat == DEAD)
return FALSE

var/damage = burn_damage
var/active = world.time > active_time
var/damage = active ? burn_damage : 0 // A little buffer time to get out of it
if(isxeno(affected_mob))
damage *= xeno_yautja_multiplier
else if(isyautja(affected_mob))
Expand Down

0 comments on commit a50f945

Please sign in to comment.