Skip to content

Commit

Permalink
Fixes radiation runtime and firebot GC (#2364)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Fixes a spurious runtime on checks related to anomalies and radiation,
and makes firebots not hang onto references to targets.

## Why It's Good For The Game

I will fix these test fails one at a time just you watch me

## Changelog

:cl:
tweak: Firebots now extinguish turf fires.
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
MarkSuckerberg authored Sep 25, 2023
1 parent 980c320 commit 10850cb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
2 changes: 0 additions & 2 deletions code/__DEFINES/statpanel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ GLOBAL_LIST_INIT(client_verbs_required, list(
/client/verb/forum,
/client/verb/github,
/client/verb/joindiscord,
// Admin help
/client/verb/adminhelp,
))
2 changes: 1 addition & 1 deletion code/datums/map_zones.dm
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
unlink(dir)
parent_level.virtual_levels -= src
parent_level = null
SSidlenpcpool.idle_mobs_by_virtual_level["[id]"] = null
LAZYREMOVE(SSidlenpcpool.idle_mobs_by_virtual_level, "[id]")
SSmapping.virtual_z_translation -= "[id]"
parent_map_zone.remove_virtual_level(src)
if(up_linkage)
Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/effects/anomalies/anomalies_heartbeat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

COOLDOWN_START(src, pulse_secondary_cooldown, pulse_delay*4)
var/turf/spot = locate(rand(src.x-effectrange, src.x+effectrange), rand(src.y-effectrange, src.y+effectrange), src.z)
if(!spot)
return

playsound(spot, 'sound/health/slowbeat2.ogg', 100)
radiation_pulse(spot, 200, effectrange)
for(var/mob/living/carbon/nearby in range(effectrange, spot))
Expand Down
64 changes: 36 additions & 28 deletions code/modules/mob/living/simple_animal/bot/firebot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
window_name = "Mobile Fire Extinguisher v1.0"
path_image_color = "#FFA500"

var/atom/target_fire
var/atom/old_target_fire
var/datum/weakref/target_fire_ref
var/datum/weakref/old_target_fire_ref

var/obj/item/extinguisher/internal_ext

Expand Down Expand Up @@ -106,15 +106,15 @@

/mob/living/simple_animal/bot/firebot/bot_reset()
..()
target_fire = null
old_target_fire = null
target_fire_ref = null
old_target_fire_ref = null
ignore_list = list()
anchored = FALSE
update_appearance()

/mob/living/simple_animal/bot/firebot/proc/soft_reset()
path = list()
target_fire = null
target_fire_ref = null
mode = BOT_IDLE
last_found = world.time
update_appearance()
Expand Down Expand Up @@ -149,7 +149,7 @@
audible_message("<span class='danger'>[src] buzzes oddly!</span>")
playsound(src, "sparks", 75, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
if(user)
old_target_fire = user
old_target_fire_ref = WEAKREF(user)
extinguish_fires = FALSE
extinguish_people = TRUE

Expand Down Expand Up @@ -184,7 +184,7 @@

else if(isturf(target))
var/turf/open/T = target
if(T.active_hotspot)
if(T.active_hotspot || T.turf_fire)
return TRUE

return FALSE
Expand All @@ -194,12 +194,12 @@
return

if(IsStun() || IsParalyzed())
old_target_fire = target_fire
target_fire = null
old_target_fire_ref = target_fire_ref
target_fire_ref = null
mode = BOT_IDLE
return

if(prob(1) && target_fire == null)
if(prob(1) && !target_fire_ref)
var/list/messagevoice = list("No fires detected." = 'sound/voice/firebot/nofires.ogg',
"Only you can prevent station fires." = 'sound/voice/firebot/onlyyou.ogg',
"Temperature nominal." = 'sound/voice/firebot/tempnominal.ogg',
Expand All @@ -210,24 +210,39 @@

// Couldn't reach the target, reset and try again ignoring the old one
if(frustration > 8)
old_target_fire = target_fire
old_target_fire_ref = target_fire_ref
soft_reset()

var/atom/target_fire = target_fire_ref?.resolve()

// We extinguished our target or it was deleted
if(QDELETED(target_fire) || !is_burning(target_fire) || isdead(target_fire))
target_fire = null
target_fire_ref = null
var/scan_range = (stationary_mode ? 1 : DEFAULT_SCAN_RANGE)
var/old_target_fire = old_target_fire_ref?.resolve()

if(extinguish_people)
target_fire = scan(/mob/living, old_target_fire, scan_range) // Scan for burning humans first
target_fire_ref = WEAKREF(target_fire)

if(target_fire == null && extinguish_fires)
if(!target_fire && extinguish_fires)
target_fire = scan(/turf/open, old_target_fire, scan_range) // Scan for burning turfs second
target_fire_ref = WEAKREF(target_fire)

old_target_fire = target_fire
old_target_fire_ref = target_fire_ref

if(!target_fire)
if(auto_patrol)
if(mode == BOT_IDLE || mode == BOT_START_PATROL)
start_patrol()

if(mode == BOT_PATROL)
bot_patrol()
return

// Target reached ENGAGE WATER CANNON
if(target_fire && (get_dist(src, target_fire) <= (emagged == 2 ? 1 : 2))) // Make the bot spray water from afar when not emagged
if(get_dist(src, target_fire) <= (emagged == 2 ? 1 : 2)) // Make the bot spray water from afar when not emagged
if((speech_cooldown + SPEECH_INTERVAL) < world.time)
if(ishuman(target_fire))
speak("Stop, drop and roll!")
Expand All @@ -243,39 +258,32 @@
soft_reset()

// Target ran away
else if(target_fire && path.len && (get_dist(target_fire,path[path.len]) > 2))
else if(length(path) && (get_dist(target_fire, path[length(path)]) > 2))
path = list()
mode = BOT_IDLE
last_found = world.time

else if(target_fire && stationary_mode)
else if(stationary_mode)
soft_reset()
return

if(target_fire && (get_dist(src, target_fire) > 2))
if(get_dist(src, target_fire) > 2)

path = get_path_to(src, get_turf(target_fire), /turf/proc/Distance_cardinal, 0, 30, 1, id=access_card)
mode = BOT_MOVING
if(!path.len)
if(!length(path))
soft_reset()

if(path.len > 0 && target_fire)
if(length(path))
if(!bot_move(path[path.len]))
old_target_fire = target_fire
old_target_fire_ref = target_fire_ref
soft_reset()
return

// We got a target but it's too far away from us
if(path.len > 8 && target_fire)
if(length(path) > 8)
frustration++

if(auto_patrol && !target_fire)
if(mode == BOT_IDLE || mode == BOT_START_PATROL)
start_patrol()

if(mode == BOT_PATROL)
bot_patrol()


//Look for burning people or turfs around the bot
/mob/living/simple_animal/bot/firebot/process_scan(atom/scan_target)
Expand Down

0 comments on commit 10850cb

Please sign in to comment.