1717using Content . Shared . _Shitmed . Body . Components ;
1818using Content . Shared . _Shitmed . Damage ;
1919using Content . Shared . _Shitmed . Targeting ;
20+ using Content . Shared . Administration . Logs ;
2021using Content . Shared . Damage ;
2122using Content . Shared . Damage . Components ;
23+ using Content . Shared . Database ;
2224using Content . Shared . Hands ;
2325using Content . Shared . Humanoid ;
2426using Content . Shared . Interaction . Events ;
3739
3840namespace Content . Goobstation . Server . HisGrace ;
3941
40- public sealed partial class HisGraceSystem : SharedHisGraceSystem
42+ public sealed class HisGraceSystem : SharedHisGraceSystem
4143{
4244 [ Dependency ] private readonly DamageableSystem _damageable = null ! ;
4345 [ Dependency ] private readonly PopupSystem _popup = null ! ;
@@ -53,6 +55,7 @@ public sealed partial class HisGraceSystem : SharedHisGraceSystem
5355 [ Dependency ] private readonly MovementSpeedModifierSystem _speedModifier = null ! ;
5456 [ Dependency ] private readonly ChatSystem _chat = null ! ;
5557 [ Dependency ] private readonly MobThresholdSystem _threshold = null ! ;
58+ [ Dependency ] private readonly ISharedAdminLogManager _adminLog = null ! ;
5659
5760 public override void Initialize ( )
5861 {
@@ -148,6 +151,10 @@ private void OnUse(Entity<HisGraceComponent> hisGrace, ref UseInHandEvent args)
148151 var popUp = Loc . GetString ( "hisgrace-use-start" ) ;
149152 _popup . PopupEntity ( popUp , args . User , args . User , PopupType . MediumCaution ) ;
150153
154+ // Log activation with actor and tool format
155+ _adminLog . Add ( LogType . AdminMessage , LogImpact . Extreme ,
156+ $ "HIS GRACE ACTIVATED: { ToPrettyString ( args . User ) : actor} activated { ToPrettyString ( hisGrace ) : tool} at { Transform ( hisGrace ) . Coordinates } ") ;
157+
151158 ChangeState ( hisGrace , HisGraceState . Peckish ) ;
152159 SetUnremovable ( hisGrace , true ) ;
153160 }
@@ -157,7 +164,14 @@ private void OnEntityConsumed(Entity<HisGraceComponent> hisGrace, ref HisGraceEn
157164 hisGrace . Comp . EntitiesAbsorbed ++ ;
158165
159166 if ( hisGrace . Comp . EntitiesAbsorbed >= hisGrace . Comp . AscensionThreshold )
167+ {
168+ var user = hisGrace . Comp . User ?? hisGrace . Owner ;
169+ _adminLog . Add ( LogType . AdminMessage , LogImpact . Extreme ,
170+ $ "HIS GRACE ASCENSION: { ToPrettyString ( user ) : actor} reached ascension with { ToPrettyString ( hisGrace ) : tool} . " +
171+ $ "Total entities consumed: { hisGrace . Comp . EntitiesAbsorbed } ") ;
172+
160173 ChangeState ( hisGrace , HisGraceState . Ascended ) ;
174+ }
161175
162176 if ( ! TryComp < MeleeWeaponComponent > ( hisGrace , out var melee ) )
163177 return ;
@@ -254,6 +268,10 @@ private void HandleDeathState(Entity<HisGraceComponent> hisGrace, EntityUid user
254268 origin : hisGrace ,
255269 ignoreResistances : true ) ;
256270
271+ // Log the death state activation
272+ _adminLog . Add ( LogType . AdminMessage , LogImpact . High ,
273+ $ "HIS GRACE DEATH: { ToPrettyString ( user ) : actor} was killed by { ToPrettyString ( hisGrace ) : tool} due to hunger") ;
274+
257275 var popup = Loc . GetString ( "hisgrace-death" , ( "target" , Name ( user ) ) ) ;
258276 _popup . PopupEntity ( popup , user , user , PopupType . LargeCaution ) ;
259277
@@ -336,11 +354,15 @@ private void HandleGroundAttacks(Entity<HisGraceComponent> hisGrace, MeleeWeapon
336354 var nearbyEnts = _lookup . GetEntitiesInRange ( hisGrace , 1f ) ;
337355
338356 // dont attack if the entity is the user, and dont if the entity is in a container (e.g, already devoured)
339- foreach ( var entity in nearbyEnts . Where ( entity => HasComp < MobStateComponent > ( entity ) // malicious foreach loop
357+ foreach ( var entity in nearbyEnts . Where ( entity => HasComp < MobStateComponent > ( entity )
340358 & & entity != hisGrace . Comp . User
341359 && ! _containerSystem . IsEntityOrParentInContainer ( entity ) ) )
342360 {
343- /// get co-ordinates for animation
361+ // Log ground attack
362+ _adminLog . Add ( LogType . AdminMessage , LogImpact . Medium ,
363+ $ "HIS GRACE GROUND ATTACK: { ToPrettyString ( hisGrace ) : tool} attacked { ToPrettyString ( entity ) : target} at { Transform ( hisGrace ) . Coordinates } ") ;
364+
365+ // get co-ordinates for animation
344366 var coordinates = _transform . GetMapCoordinates ( hisGrace ) ;
345367 var angle = _transform . GetRelativePosition ( xform , entity , GetEntityQuery < TransformComponent > ( ) ) . ToAngle ( ) ;
346368
@@ -387,40 +409,59 @@ private void ProcessHungerTick(Entity<HisGraceComponent> hisGrace, EntityUid use
387409
388410 #region Helpers
389411
390- private void DoAscension ( HisGraceComponent comp )
412+ private void DoAscension ( Entity < HisGraceComponent > hisGrace )
391413 {
392- if ( comp . User is not { } user
414+ if ( hisGrace . Comp . User is not { } user
393415 || TerminatingOrDeleted ( user ) )
394416 return ;
395417
396418 var ascensionPopup = Loc . GetString ( "hisgrace-ascension" ) ;
397419 _popup . PopupEntity ( ascensionPopup , user , user , PopupType . Large ) ;
398420
421+ // Log ascension with all relevant details
422+ _adminLog . Add ( LogType . AdminMessage , LogImpact . Extreme ,
423+ $ "HIS GRACE ASCENSION ACHIEVED: { ToPrettyString ( user ) : actor} achieved ascension with { ToPrettyString ( hisGrace ) : tool} at { Transform ( hisGrace ) . Coordinates } . " +
424+ $ "Total entities consumed: { hisGrace . Comp . EntitiesAbsorbed } ") ;
425+
426+ // Apply ascension effects
399427 EnsureComp < ThermalVisionComponent > ( user ) ;
400428 EnsureComp < PressureImmunityComponent > ( user ) ;
401429 EnsureComp < BreathingImmunityComponent > ( user ) ;
402430
403- UpdateSpeedMultiplier ( comp , comp . SpeedAddition * comp . SpeedIncrementMultiplier * comp . SpeedIncrementMultiplier ) ;
431+ UpdateSpeedMultiplier ( hisGrace , hisGrace . Comp . SpeedAddition * hisGrace . Comp . SpeedIncrementMultiplier * hisGrace . Comp . SpeedIncrementMultiplier ) ;
404432
405433 // le funny ascension
406- _chat . DispatchGlobalAnnouncement ( Loc . GetString ( "hisgrace-ascension-announcement" ) , Name ( user ) , true , comp . AscendSound , Color . PaleGoldenrod ) ;
434+ _chat . DispatchGlobalAnnouncement ( Loc . GetString ( "hisgrace-ascension-announcement" ) , Name ( user ) , true , hisGrace . Comp . AscendSound , Color . PaleGoldenrod ) ;
407435 }
408436
409437 private void ChangeState ( Entity < HisGraceComponent > hisGrace , HisGraceState newState )
410438 {
411- // self explanatory
439+ // Store the old state before changing it
412440 var oldState = hisGrace . Comp . CurrentState ;
413441 hisGrace . Comp . CurrentState = newState ;
414442
415443 var ev = new HisGraceStateChangedEvent ( newState , oldState ) ;
416444 RaiseLocalEvent ( hisGrace , ref ev ) ;
417445 }
418-
419446 private bool TryDevour ( Entity < HisGraceComponent > hisGrace , EntityUid target )
420447 {
421- if ( ! _state . IsIncapacitated ( target )
422- || ! _containerSystem . Insert ( target , hisGrace . Comp . Stomach ) )
448+ if ( ! _state . IsIncapacitated ( target ) )
449+ {
450+ _adminLog . Add ( LogType . AdminMessage , LogImpact . Medium ,
451+ $ "HIS GRACE DEVOUR FAILED: { ToPrettyString ( hisGrace . Comp . User ?? hisGrace . Owner ) : actor} failed to devour { ToPrettyString ( target ) : target} with { ToPrettyString ( hisGrace ) : tool} - Target not incapacitated") ;
423452 return false ;
453+ }
454+
455+ if ( ! _containerSystem . Insert ( target , hisGrace . Comp . Stomach ) )
456+ {
457+ _adminLog . Add ( LogType . AdminMessage , LogImpact . Medium ,
458+ $ "HIS GRACE DEVOUR FAILED: { ToPrettyString ( hisGrace . Comp . User ?? hisGrace . Owner ) : actor} failed to devour { ToPrettyString ( target ) : target} with { ToPrettyString ( hisGrace ) : tool} - Container insertion failed") ;
459+ return false ;
460+ }
461+
462+ // Log successful devour attempt
463+ _adminLog . Add ( LogType . AdminMessage , LogImpact . High ,
464+ $ "HIS GRACE DEVOUR: { ToPrettyString ( hisGrace . Comp . User ?? hisGrace . Owner ) : actor} devoured { ToPrettyString ( target ) : target} with { ToPrettyString ( hisGrace ) : tool} ") ;
424465
425466 // Hunger gained from eating an entity is 20% of their crit state.
426467 hisGrace . Comp . Hunger -= GetHungerValue ( target , hisGrace ) . Value ;
@@ -429,13 +470,18 @@ private bool TryDevour(Entity<HisGraceComponent> hisGrace, EntityUid target)
429470 _audio . PlayPvs ( hisGrace . Comp . SoundDevour , target ) ;
430471 _popup . PopupEntity ( devourPopup , target , PopupType . LargeCaution ) ;
431472
432- // don't apply bonuses for enities consumed that don't have minds or aren't human (no farming sentient mice)
473+ // don't apply bonuses for entities consumed that don't have minds or aren't human (no farming sentient mice)
433474 if ( _mind . TryGetMind ( target , out _ , out _ )
434475 && HasComp < HumanoidAppearanceComponent > ( target ) )
435476 {
436477 var ev = new HisGraceEntityConsumedEvent ( ) ;
437478 RaiseLocalEvent ( hisGrace , ref ev ) ;
438479 }
480+ else
481+ {
482+ _adminLog . Add ( LogType . AdminMessage , LogImpact . Low ,
483+ $ "HIS GRACE NON-HUMANOID: { ToPrettyString ( hisGrace . Comp . User ?? hisGrace . Owner ) : actor} consumed non-humanoid { ToPrettyString ( target ) : target} with { ToPrettyString ( hisGrace ) : tool} ") ;
484+ }
439485
440486 return true ;
441487 }
0 commit comments