mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
Process procs now properly utilize deltatime when implementing rates, timers and probabilities (#52981)
* Process procs now properly use deltatime when implementing rates, timers and probabilities * Review fixes * Geiger counters cleanup Made hardsuit geiger code more similar to geiger counter code Geiger counters are more responsive now * Moved SS*_DT defines to subsystems.dm * Rebase fix * Redefined the SS*_DT defines to use the subsystem wait vars * Implemented suggested changes by @AnturK * Commented /datum/proc/process about the deltatime stuff * Send delta_time as a process parameter instead of the defines Also DTfied acid_processing * Dtfied new acid component
This commit is contained in:
@@ -270,6 +270,7 @@
|
||||
inhand_icon_state = "flare"
|
||||
worn_icon_state = "flare"
|
||||
actions_types = list()
|
||||
/// How many seconds of fuel we have left
|
||||
var/fuel = 0
|
||||
var/on_damage = 7
|
||||
var/produce_heat = 1500
|
||||
@@ -279,12 +280,12 @@
|
||||
|
||||
/obj/item/flashlight/flare/Initialize()
|
||||
. = ..()
|
||||
fuel = rand(800, 1000) // Sorry for changing this so much but I keep under-estimating how long X number of ticks last in seconds.
|
||||
fuel = rand(1600, 2000)
|
||||
|
||||
/obj/item/flashlight/flare/process()
|
||||
/obj/item/flashlight/flare/process(delta_time)
|
||||
open_flame(heat)
|
||||
fuel = max(fuel - 1, 0)
|
||||
if(!fuel || !on)
|
||||
fuel = max(fuel -= delta_time, 0)
|
||||
if(fuel <= 0 || !on)
|
||||
turn_off()
|
||||
if(!fuel)
|
||||
icon_state = "[initial(icon_state)]-empty"
|
||||
@@ -313,7 +314,7 @@
|
||||
/obj/item/flashlight/flare/attack_self(mob/user)
|
||||
|
||||
// Usual checks
|
||||
if(!fuel)
|
||||
if(fuel <= 0)
|
||||
to_chat(user, "<span class='warning'>[src] is out of fuel!</span>")
|
||||
return
|
||||
if(on)
|
||||
@@ -386,7 +387,9 @@
|
||||
/obj/item/flashlight/emp
|
||||
var/emp_max_charges = 4
|
||||
var/emp_cur_charges = 4
|
||||
var/charge_tick = 0
|
||||
var/charge_timer = 0
|
||||
/// How many seconds between each recharge
|
||||
var/charge_delay = 20
|
||||
|
||||
/obj/item/flashlight/emp/New()
|
||||
..()
|
||||
@@ -396,11 +399,11 @@
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
. = ..()
|
||||
|
||||
/obj/item/flashlight/emp/process()
|
||||
charge_tick++
|
||||
if(charge_tick < 10)
|
||||
/obj/item/flashlight/emp/process(delta_time)
|
||||
charge_timer += delta_time
|
||||
if(charge_timer < charge_delay)
|
||||
return FALSE
|
||||
charge_tick = 0
|
||||
charge_timer -= charge_delay
|
||||
emp_cur_charges = min(emp_cur_charges+1, emp_max_charges)
|
||||
return TRUE
|
||||
|
||||
@@ -448,11 +451,12 @@
|
||||
inhand_icon_state = "glowstick"
|
||||
worn_icon_state = "lightstick"
|
||||
grind_results = list(/datum/reagent/phenol = 15, /datum/reagent/hydrogen = 10, /datum/reagent/oxygen = 5) //Meth-in-a-stick
|
||||
/// How many seconds of fuel we have left
|
||||
var/fuel = 0
|
||||
|
||||
|
||||
/obj/item/flashlight/glowstick/Initialize()
|
||||
fuel = rand(1600, 2000)
|
||||
fuel = rand(3200, 4000)
|
||||
set_light_color(color)
|
||||
return ..()
|
||||
|
||||
@@ -462,9 +466,9 @@
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/flashlight/glowstick/process()
|
||||
fuel = max(fuel - 1, 0)
|
||||
if(!fuel)
|
||||
/obj/item/flashlight/glowstick/process(delta_time)
|
||||
fuel = max(fuel - delta_time, 0)
|
||||
if(fuel <= 0)
|
||||
turn_off()
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
update_icon()
|
||||
@@ -476,7 +480,7 @@
|
||||
/obj/item/flashlight/glowstick/update_icon()
|
||||
inhand_icon_state = "glowstick"
|
||||
cut_overlays()
|
||||
if(!fuel)
|
||||
if(fuel <= 0)
|
||||
icon_state = "glowstick-empty"
|
||||
cut_overlays()
|
||||
set_light_on(FALSE)
|
||||
@@ -491,7 +495,7 @@
|
||||
cut_overlays()
|
||||
|
||||
/obj/item/flashlight/glowstick/attack_self(mob/user)
|
||||
if(!fuel)
|
||||
if(fuel <= 0)
|
||||
to_chat(user, "<span class='notice'>[src] is spent.</span>")
|
||||
return
|
||||
if(on)
|
||||
|
||||
@@ -68,11 +68,11 @@
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/forcefield_projector/process()
|
||||
/obj/item/forcefield_projector/process(delta_time)
|
||||
if(!LAZYLEN(current_fields))
|
||||
shield_integrity = min(shield_integrity + 4, max_shield_integrity)
|
||||
shield_integrity = min(shield_integrity + delta_time * 2, max_shield_integrity)
|
||||
else
|
||||
shield_integrity = max(shield_integrity - LAZYLEN(current_fields), 0) //fields degrade slowly over time
|
||||
shield_integrity = max(shield_integrity - LAZYLEN(current_fields) * delta_time * 0.5, 0) //fields degrade slowly over time
|
||||
for(var/obj/structure/projected_forcefield/F in current_fields)
|
||||
if(shield_integrity <= 0 || get_dist(F,src) > field_distance_limit)
|
||||
qdel(F)
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#define RAD_LEVEL_VERY_HIGH 800
|
||||
#define RAD_LEVEL_CRITICAL 1500
|
||||
|
||||
#define RAD_MEASURE_SMOOTHING 5
|
||||
|
||||
#define RAD_GRACE_PERIOD 2
|
||||
|
||||
/obj/item/geiger_counter //DISCLAIMER: I know nothing about how real-life Geiger counters work. This will not be realistic. ~Xhuis
|
||||
name = "\improper Geiger counter"
|
||||
desc = "A handheld device used for detecting and measuring radiation pulses."
|
||||
@@ -21,7 +17,7 @@
|
||||
item_flags = NOBLUDGEON
|
||||
custom_materials = list(/datum/material/iron = 150, /datum/material/glass = 150)
|
||||
|
||||
var/grace = RAD_GRACE_PERIOD
|
||||
var/grace = RAD_GEIGER_GRACE_PERIOD
|
||||
var/datum/looping_sound/geiger/soundloop
|
||||
|
||||
var/scanning = FALSE
|
||||
@@ -41,28 +37,24 @@
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/geiger_counter/process()
|
||||
update_icon()
|
||||
update_sound()
|
||||
/obj/item/geiger_counter/process(delta_time)
|
||||
if(scanning)
|
||||
radiation_count = LPFILTER(radiation_count, current_tick_amount, delta_time, RAD_GEIGER_RC)
|
||||
|
||||
if(!scanning)
|
||||
current_tick_amount = 0
|
||||
return
|
||||
if(current_tick_amount)
|
||||
grace = RAD_GEIGER_GRACE_PERIOD
|
||||
last_tick_amount = current_tick_amount
|
||||
|
||||
radiation_count -= radiation_count/RAD_MEASURE_SMOOTHING
|
||||
radiation_count += current_tick_amount/RAD_MEASURE_SMOOTHING
|
||||
|
||||
if(current_tick_amount)
|
||||
grace = RAD_GRACE_PERIOD
|
||||
last_tick_amount = current_tick_amount
|
||||
|
||||
else if(!(obj_flags & EMAGGED))
|
||||
grace--
|
||||
if(grace <= 0)
|
||||
radiation_count = 0
|
||||
else if(!(obj_flags & EMAGGED))
|
||||
grace -= delta_time
|
||||
if(grace <= 0)
|
||||
radiation_count = 0
|
||||
|
||||
current_tick_amount = 0
|
||||
|
||||
update_icon()
|
||||
update_sound()
|
||||
|
||||
/obj/item/geiger_counter/examine(mob/user)
|
||||
. = ..()
|
||||
if(!scanning)
|
||||
|
||||
@@ -187,11 +187,11 @@
|
||||
flick_overlay_view(I, targloc, 10)
|
||||
icon_state = "pointer"
|
||||
|
||||
/obj/item/laser_pointer/process()
|
||||
/obj/item/laser_pointer/process(delta_time)
|
||||
if(!diode)
|
||||
recharging = FALSE
|
||||
return PROCESS_KILL
|
||||
if(prob(20 + diode.rating*20 - recharge_locked*2)) //t1 is 20, 2 40
|
||||
if(DT_PROB(10 + diode.rating*10 - recharge_locked*1, delta_time)) //t1 is 20, 2 40
|
||||
energy += 1
|
||||
if(energy >= max_energy)
|
||||
energy = max_energy
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
STOP_PROCESSING(SSprocessing, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/reverse_bear_trap/process()
|
||||
/obj/item/reverse_bear_trap/process(delta_time)
|
||||
if(!ticking)
|
||||
return
|
||||
time_left--
|
||||
time_left -= delta_time
|
||||
soundloop2.mid_length = max(0.5, time_left - 5) //beepbeepbeepbeepbeep
|
||||
if(!time_left || !isliving(loc))
|
||||
if(time_left <= 0 || !isliving(loc))
|
||||
playsound(src, 'sound/machines/microwave/microwave-end.ogg', 100, FALSE)
|
||||
soundloop.stop()
|
||||
soundloop2.stop()
|
||||
|
||||
@@ -232,7 +232,7 @@ effective or pretty fucking useless.
|
||||
if(user && user.get_item_by_slot(ITEM_SLOT_BELT) != src)
|
||||
Deactivate()
|
||||
|
||||
/obj/item/shadowcloak/process()
|
||||
/obj/item/shadowcloak/process(delta_time)
|
||||
if(user.get_item_by_slot(ITEM_SLOT_BELT) != src)
|
||||
Deactivate()
|
||||
return
|
||||
@@ -240,9 +240,9 @@ effective or pretty fucking useless.
|
||||
if(on)
|
||||
var/lumcount = T.get_lumcount()
|
||||
if(lumcount > 0.3)
|
||||
charge = max(0,charge - 25)//Quick decrease in light
|
||||
charge = max(0, charge - 12.5 * delta_time)//Quick decrease in light
|
||||
else
|
||||
charge = min(max_charge,charge + 50) //Charge in the dark
|
||||
charge = min(max_charge, charge + 25 * delta_time) //Charge in the dark
|
||||
animate(user,alpha = clamp(255 - charge,0,255),time = 10)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user