Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -9,7 +9,7 @@ namespace Server.Gumps
public class ReportMurdererGump : Gump
{
private int m_Idx;
private List<Mobile> m_Killers;
private readonly List<Mobile> m_Killers;
private Mobile m_Victum;
public static void Initialize()
@ -20,11 +20,11 @@ namespace Server.Gumps
public static void EventSink_PlayerDeath(Mobile m)
{
List<Mobile> killers = new List<Mobile>();
List<Mobile> toGive = new List<Mobile>();
List<Mobile> toGive = new List<Mobile>();
foreach ( AggressorInfo ai in m.Aggressors )
foreach (AggressorInfo ai in m.Aggressors)
{
if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported )
if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported)
if (!Core.SE || !((PlayerMobile)m).RecentlyReported.Contains(ai.Attacker))
{
killers.Add(ai.Attacker);
@ -32,17 +32,17 @@ namespace Server.Gumps
ai.CanReportMurder = false;
}
if ( ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
toGive.Add( ai.Attacker );
if (ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Attacker))
toGive.Add(ai.Attacker);
}
foreach ( AggressorInfo ai in m.Aggressed )
if ( ai.Defender.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
toGive.Add( ai.Defender );
foreach (AggressorInfo ai in m.Aggressed)
if (ai.Defender.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Defender))
toGive.Add(ai.Defender);
foreach ( Mobile g in toGive )
foreach (Mobile g in toGive)
{
int n = Notoriety.Compute( g, m );
int n = Notoriety.Compute(g, m);
int ourKarma = g.Karma;
bool innocent = n == Notoriety.Innocent;
@ -51,28 +51,28 @@ namespace Server.Gumps
int fameAward = m.Fame / 200;
int karmaAward = 0;
if ( innocent )
if (innocent)
karmaAward = ourKarma > -2500 ? -850 : -110 - m.Karma / 100;
else if ( criminal )
else if (criminal)
karmaAward = 50;
Titles.AwardFame( g, fameAward, false );
Titles.AwardKarma( g, karmaAward, true );
Titles.AwardFame(g, fameAward, false);
Titles.AwardKarma(g, karmaAward, true);
}
if ( m is PlayerMobile mobile && mobile.NpcGuild == NpcGuild.ThievesGuild )
if (m is PlayerMobile mobile && mobile.NpcGuild == NpcGuild.ThievesGuild)
return;
if ( killers.Count > 0 )
new GumpTimer( m, killers ).Start();
if (killers.Count > 0)
new GumpTimer(m, killers).Start();
}
private class GumpTimer : Timer
{
private Mobile m_Victim;
private List<Mobile> m_Killers;
private readonly Mobile m_Victim;
private readonly List<Mobile> m_Killers;
public GumpTimer( Mobile victim, List<Mobile> killers ) : base( TimeSpan.FromSeconds( 4.0 ) )
public GumpTimer(Mobile victim, List<Mobile> killers) : base(TimeSpan.FromSeconds(4.0))
{
m_Victim = victim;
m_Killers = killers;
@ -80,11 +80,11 @@ namespace Server.Gumps
protected override void OnTick()
{
m_Victim.SendGump( new ReportMurdererGump( m_Victim, m_Killers ) );
m_Victim.SendGump(new ReportMurdererGump(m_Victim, m_Killers));
}
}
private ReportMurdererGump(Mobile victum, List<Mobile> killers, int idx = 0) : base( 0, 0 )
private ReportMurdererGump(Mobile victum, List<Mobile> killers, int idx = 0) : base(0, 0)
{
m_Killers = killers;
m_Victum = victum;
@ -94,80 +94,80 @@ namespace Server.Gumps
private void BuildGump()
{
AddBackground( 265, 205, 320, 290, 5054 );
AddBackground(265, 205, 320, 290, 5054);
Closable = false;
Resizable = false;
AddPage( 0 );
AddPage(0);
AddImageTiled( 225, 175, 50, 45, 0xCE ); //Top left corner
AddImageTiled( 267, 175, 315, 44, 0xC9 ); //Top bar
AddImageTiled( 582, 175, 43, 45, 0xCF ); //Top right corner
AddImageTiled( 225, 219, 44, 270, 0xCA ); //Left side
AddImageTiled( 582, 219, 44, 270, 0xCB ); //Right side
AddImageTiled( 225, 489, 44, 43, 0xCC ); //Lower left corner
AddImageTiled( 267, 489, 315, 43, 0xE9 ); //Lower Bar
AddImageTiled( 582, 489, 43, 43, 0xCD ); //Lower right corner
AddImageTiled(225, 175, 50, 45, 0xCE); // Top left corner
AddImageTiled(267, 175, 315, 44, 0xC9); // Top bar
AddImageTiled(582, 175, 43, 45, 0xCF); // Top right corner
AddImageTiled(225, 219, 44, 270, 0xCA); // Left side
AddImageTiled(582, 219, 44, 270, 0xCB); // Right side
AddImageTiled(225, 489, 44, 43, 0xCC); // Lower left corner
AddImageTiled(267, 489, 315, 43, 0xE9); // Lower Bar
AddImageTiled(582, 489, 43, 43, 0xCD); // Lower right corner
AddPage( 1 );
AddPage(1);
AddHtml( 260, 234, 300, 140, m_Killers[m_Idx].Name ); // Player's Name
AddHtmlLocalized( 260, 254, 300, 140, 1049066 ); // Would you like to report...
AddHtml(260, 234, 300, 140, m_Killers[m_Idx].Name); // Player's Name
AddHtmlLocalized(260, 254, 300, 140, 1049066); // Would you like to report...
AddButton( 260, 300, 0xFA5, 0xFA7, 1 );
AddHtmlLocalized( 300, 300, 300, 50, 1046362 ); // Yes
AddButton(260, 300, 0xFA5, 0xFA7, 1);
AddHtmlLocalized(300, 300, 300, 50, 1046362); // Yes
AddButton( 360, 300, 0xFA5, 0xFA7, 2 );
AddHtmlLocalized( 400, 300, 300, 50, 1046363 ); // No
AddButton(360, 300, 0xFA5, 0xFA7, 2);
AddHtmlLocalized(400, 300, 300, 50, 1046363); // No
}
public static void ReportedListExpiry_Callback( PlayerMobile from, Mobile killer )
public static void ReportedListExpiry_Callback(PlayerMobile from, Mobile killer)
{
if (from.RecentlyReported.Contains(killer))
from.RecentlyReported.Remove(killer);
}
public override void OnResponse( NetState state, RelayInfo info )
public override void OnResponse(NetState state, RelayInfo info)
{
PlayerMobile from = (PlayerMobile)state.Mobile;
switch ( info.ButtonID )
switch (info.ButtonID)
{
case 1:
{
Mobile killer = m_Killers[m_Idx];
if (killer?.Deleted == false)
{
killer.Kills++;
killer.ShortTermMurders++;
if (Core.SE)
Mobile killer = m_Killers[m_Idx];
if (killer?.Deleted == false)
{
from.RecentlyReported.Add(killer);
Timer.DelayCall(TimeSpan.FromMinutes(10), () => ReportedListExpiry_Callback(from, killer));
}
killer.Kills++;
killer.ShortTermMurders++;
if (killer is PlayerMobile pk)
{
pk.ResetKillTime();
pk.SendLocalizedMessage(1049067);//You have been reported for murder!
if (Core.SE)
{
from.RecentlyReported.Add(killer);
Timer.DelayCall(TimeSpan.FromMinutes(10), () => ReportedListExpiry_Callback(from, killer));
}
if (pk.Kills == 5)
pk.SendLocalizedMessage(502134);//You are now known as a murderer!
else if (SkillHandlers.Stealing.SuspendOnMurder && pk.Kills == 1 && pk.NpcGuild == NpcGuild.ThievesGuild) pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild.
if (killer is PlayerMobile pk)
{
pk.ResetKillTime();
pk.SendLocalizedMessage(1049067);// You have been reported for murder!
if (pk.Kills == 5)
pk.SendLocalizedMessage(502134);// You are now known as a murderer!
else if (SkillHandlers.Stealing.SuspendOnMurder && pk.Kills == 1 && pk.NpcGuild == NpcGuild.ThievesGuild) pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild.
}
}
break;
}
break;
}
case 2:
{
break;
}
{
break;
}
}
m_Idx++;
if ( m_Idx < m_Killers.Count )
from.SendGump( new ReportMurdererGump( from, m_Killers, m_Idx ) );
if (m_Idx < m_Killers.Count)
from.SendGump(new ReportMurdererGump(from, m_Killers, m_Idx));
}
}
}