virtual protected void RegisterHostileAction(IMyPlayer Player, TimeSpan TruceDelay) { try { #region Sanity checks if (Player == null) { Grid.DebugWrite("RegisterHostileAction", "Error: Damager is null."); return; } ; if (OwnerFaction == null) { OwnerFaction = Grid.GetOwnerFaction(); } if (OwnerFaction == null || !OwnerFaction.IsNPC()) { Grid.DebugWrite("RegisterHostileAction", $"Error: {(OwnerFaction == null ? "can't find own faction" : "own faction isn't recognized as NPC.")}"); return; } #endregion IMyFaction HostileFaction = Player.GetFaction(); if (HostileFaction == null) { Grid.DebugWrite("RegisterHostileAction", "Error: can't find damager's faction"); return; } else if (HostileFaction == OwnerFaction) { OwnerFaction.Kick(Player); return; } AISessionCore.DeclareWar(OwnerFaction, HostileFaction, TruceDelay); if (OwnerFaction.IsLawful()) { AISessionCore.DeclareWar(Diplomacy.Police, HostileFaction, TruceDelay); AISessionCore.DeclareWar(Diplomacy.Army, HostileFaction, TruceDelay); } } catch (Exception Scrap) { LogError("RegisterHostileAction", Scrap); } }