Add logging for mobs being bumped into grille/suppermatter (#37563)

* Add logging for mobs being bumped into grille/suppermatter

* rust

* Fixes things + weakrefs
This commit is contained in:
ShiftyRail
2025-05-19 14:38:01 +01:00
committed by GitHub
parent 19e45d47dc
commit bc43ed4bbb
5 changed files with 47 additions and 9 deletions

View File

@@ -1369,6 +1369,8 @@ Thanks.
var/mob/M = AM
INVOKE_EVENT(src, /event/before_move)
step(M, t)
M.last_bumped_by = makeweakref(src)
M.last_bumped_by_timestamp = world.time
INVOKE_EVENT(src, /event/after_move)
else
step(AM, t)
@@ -1535,11 +1537,14 @@ Thanks.
var/start_T_descriptor = "<font color='#6b5d00'>tile at [start_T.x], [start_T.y], [start_T.z] in area [get_area(start_T)]</font>"
var/end_T_descriptor = "<font color='#6b4400'>tile at [end_T.x], [end_T.y], [end_T.z] in area [get_area(end_T)]</font>"
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been thrown by [usr.name] ([usr.ckey]) from [start_T_descriptor] with the target [end_T_descriptor]</font>")
usr.attack_log += text("\[[time_stamp()]\] <font color='red'>Has thrown [M.name] ([M.ckey]) from [start_T_descriptor] with the target [end_T_descriptor]</font>")
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been thrown by [src.name] ([src.ckey]) from [start_T_descriptor] with the target [end_T_descriptor]</font>")
src.attack_log += text("\[[time_stamp()]\] <font color='red'>Has thrown [M.name] ([M.ckey]) from [start_T_descriptor] with the target [end_T_descriptor]</font>")
log_attack("<font color='red'>[usr.name] ([usr.ckey]) Has thrown [M.name] ([M.ckey]) from [start_T_descriptor] with the target [end_T_descriptor]</font>")
M.assaulted_by(usr)
M.last_thrown_by = makeweakref(src)
M.last_thrown_by_timestamp = world.time
log_attack("<font color='red'>[src.name] ([src.ckey]) Has thrown [M.name] ([M.ckey]) from [start_T_descriptor] with the target [end_T_descriptor]</font>")
M.assaulted_by(src)
qdel(G)
if(!item)
return FAILED_THROW //Grab processing has a chance of returning null

View File

@@ -72,6 +72,9 @@
if (ticker && ticker.mode)
ticker.mode.mob_destroyed(src)
QDEL_NULL(last_thrown_by)
QDEL_NULL(last_bumped_by)
QDEL_NULL(lastassailant)
..()
/mob/projectile_check()
@@ -1877,7 +1880,17 @@ Use this proc preferably at the end of an equipment loadout
if(SS)
SS.supermatter_act(source)
else
if (client)
if(pulledby) // If we have a client, we add attack logs
add_logs(pulledby, src, "pulled into a suppermatter object", TRUE, source, get_coordinates_string(source))
else if(last_bumped_by_timestamp - 0.1 SECONDS <= world.time <= last_bumped_by_timestamp + 0.1 SECONDS) // If got bumped into a supermatter
var/mob/hostile = last_bumped_by.get()
add_logs(hostile, src, "bumped into a supermatter object", TRUE, source, get_coordinates_string(source))
else if(last_thrown_by_timestamp - 0.1 SECONDS <= world.time <= last_thrown_by_timestamp + 2 SECONDS) // If got thrown into a supermatter
var/mob/hostile = last_thrown_by.get()
add_logs(hostile, src, "thrown into a supermatter object", TRUE, source, get_coordinates_string(source))
else
attack_log += "\[[time_stamp()]\]: walked into supermatter (no bumper/no pusher)"
if(severity == SUPERMATTER_DUST)
dust()
return 1

View File

@@ -296,4 +296,11 @@
var/list/huds = list() // List of active huds on a mob
var/is_dexterous = FALSE //allows mobs to be made dextrous, mostly for monkeys
var/is_dexterous = FALSE //allows mobs to be made dextrous, mostly for monkeys
// Log things.
var/datum/weakref/last_bumped_by = null // weakrefs
var/last_bumped_by_timestamp = -INFINITY
var/datum/weakref/last_thrown_by = null // weakrefs
var/last_thrown_by_timestamp = -INFINITY