Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -1,289 +1,290 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.ConPVP
|
||||
{
|
||||
public class ArenasMoongate : Item
|
||||
{
|
||||
public override string DefaultName => "arena moongate";
|
||||
public class ArenasMoongate : Item
|
||||
{
|
||||
[Constructible]
|
||||
public ArenasMoongate() : base(0x1FD4)
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public ArenasMoongate() : base( 0x1FD4 )
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
public ArenasMoongate(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public ArenasMoongate( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override string DefaultName => "arena moongate";
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
}
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
int version = reader.ReadInt();
|
||||
Light = LightType.Circle300;
|
||||
}
|
||||
|
||||
public bool UseGate( Mobile from )
|
||||
{
|
||||
if ( DuelContext.CheckCombat( from ) )
|
||||
{
|
||||
from.SendMessage( 0x22, "You have recently been in combat with another player and cannot use this moongate." );
|
||||
return false;
|
||||
}
|
||||
public bool UseGate(Mobile from)
|
||||
{
|
||||
if (DuelContext.CheckCombat(from))
|
||||
{
|
||||
from.SendMessage(0x22, "You have recently been in combat with another player and cannot use this moongate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( from.Spell != null )
|
||||
{
|
||||
from.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
|
||||
return false;
|
||||
}
|
||||
from.CloseGump( typeof( ArenaGump ) );
|
||||
from.SendGump( new ArenaGump( from, this ) );
|
||||
if (from.Spell != null)
|
||||
{
|
||||
from.SendLocalizedMessage(1049616); // You are too busy to do that at the moment.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !from.Hidden || from.AccessLevel == AccessLevel.Player )
|
||||
Effects.PlaySound( from.Location, from.Map, 0x20E );
|
||||
from.CloseGump(typeof(ArenaGump));
|
||||
from.SendGump(new ArenaGump(from, this));
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!from.Hidden || from.AccessLevel == AccessLevel.Player)
|
||||
Effects.PlaySound(from.Location, from.Map, 0x20E);
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
if ( from.InRange( GetWorldLocation(), 1 ) )
|
||||
UseGate( from );
|
||||
else
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool OnMoveOver( Mobile m )
|
||||
{
|
||||
return ( !m.Player || UseGate( m ) );
|
||||
}
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.InRange(GetWorldLocation(), 1))
|
||||
UseGate(from);
|
||||
else
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
|
||||
}
|
||||
|
||||
public class ArenaGump : Gump
|
||||
{
|
||||
private Mobile m_From;
|
||||
private ArenasMoongate m_Gate;
|
||||
private List<Arena> m_Arenas;
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
return !m.Player || UseGate(m);
|
||||
}
|
||||
}
|
||||
|
||||
private void Append( StringBuilder sb, LadderEntry le )
|
||||
{
|
||||
if ( le == null )
|
||||
return;
|
||||
public class ArenaGump : Gump
|
||||
{
|
||||
private List<Arena> m_Arenas;
|
||||
|
||||
if ( sb.Length > 0 )
|
||||
sb.Append( ", " );
|
||||
private int m_ColumnX = 12;
|
||||
private Mobile m_From;
|
||||
private ArenasMoongate m_Gate;
|
||||
|
||||
sb.Append( le.Mobile.Name );
|
||||
}
|
||||
public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50)
|
||||
{
|
||||
m_From = from;
|
||||
m_Gate = gate;
|
||||
m_Arenas = Arena.Arenas;
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo info )
|
||||
{
|
||||
if ( info.ButtonID != 1 )
|
||||
return;
|
||||
AddPage(0);
|
||||
|
||||
int[] switches = info.Switches;
|
||||
int height = 12 + 20 + m_Arenas.Count * 31 + 24 + 12;
|
||||
|
||||
if ( switches.Length == 0 )
|
||||
return;
|
||||
AddBackground(0, 0, 499 + 40, height, 0x2436);
|
||||
|
||||
int opt = switches[0];
|
||||
List<Arena> list = m_Arenas;
|
||||
|
||||
if ( opt < 0 || opt >= m_Arenas.Count )
|
||||
return;
|
||||
for (int i = 1; i < list.Count; i += 2)
|
||||
AddImageTiled(12, 32 + i * 31, 475 + 40, 30, 0x2430);
|
||||
|
||||
Arena arena = m_Arenas[opt];
|
||||
AddAlphaRegion(10, 10, 479 + 40, height - 20);
|
||||
|
||||
if ( !m_From.InRange( m_Gate.GetWorldLocation(), 1 ) || m_From.Map != m_Gate.Map )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1019002 ); // You are too far away to use the gate.
|
||||
}
|
||||
else if ( DuelContext.CheckCombat( m_From ) )
|
||||
{
|
||||
m_From.SendMessage( 0x22, "You have recently been in combat with another player and cannot use this moongate." );
|
||||
}
|
||||
else if ( m_From.Spell != null )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
|
||||
}
|
||||
else if ( m_From.Map == arena.Facet && arena.Zone.Contains( m_From ) )
|
||||
{
|
||||
m_From.SendLocalizedMessage( 1019003 ); // You are already there.
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseCreature.TeleportPets( m_From, arena.GateIn, arena.Facet );
|
||||
AddColumnHeader(35, null);
|
||||
AddColumnHeader(115, "Arena");
|
||||
AddColumnHeader(325, "Participants");
|
||||
AddColumnHeader(40, "Obs");
|
||||
|
||||
m_From.Combatant = null;
|
||||
m_From.Warmode = false;
|
||||
m_From.Hidden = true;
|
||||
AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0);
|
||||
|
||||
m_From.MoveToWorld( arena.GateIn, arena.Facet );
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
Arena ar = list[i];
|
||||
|
||||
Effects.PlaySound( arena.GateIn, arena.Facet, 0x1FE );
|
||||
}
|
||||
}
|
||||
string name = ar.Name;
|
||||
|
||||
public ArenaGump( Mobile from, ArenasMoongate gate ) : base( 50, 50 )
|
||||
{
|
||||
m_From = from;
|
||||
m_Gate = gate;
|
||||
m_Arenas = Arena.Arenas;
|
||||
if (name == null)
|
||||
name = "(no name)";
|
||||
|
||||
AddPage( 0 );
|
||||
int x = 12;
|
||||
int y = 32 + i * 31;
|
||||
|
||||
int height = 12 + 20 + (m_Arenas.Count * 31) + 24 + 12;
|
||||
int color = ar.Players.Count > 0 ? 0xCCFFCC : 0xCCCCCC;
|
||||
|
||||
AddBackground( 0, 0, 499+40, height, 0x2436 );
|
||||
AddRadio(x + 3, y + 1, 9727, 9730, false, i);
|
||||
x += 35;
|
||||
|
||||
List<Arena> list = m_Arenas;
|
||||
AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
|
||||
x += 115;
|
||||
|
||||
for ( int i = 1; i < list.Count; i += 2 )
|
||||
AddImageTiled( 12, 32 + (i * 31), 475+40, 30, 0x2430 );
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
AddAlphaRegion( 10, 10, 479+40, height - 20 );
|
||||
if (ar.Players.Count > 0)
|
||||
{
|
||||
Ladder ladder = Ladder.Instance;
|
||||
|
||||
AddColumnHeader( 35, null );
|
||||
AddColumnHeader( 115, "Arena" );
|
||||
AddColumnHeader( 325, "Participants" );
|
||||
AddColumnHeader( 40, "Obs" );
|
||||
if (ladder == null)
|
||||
continue;
|
||||
|
||||
AddButton( 499+40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 499+40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0 );
|
||||
LadderEntry p1 = null, p2 = null, p3 = null, p4 = null;
|
||||
|
||||
for ( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
Arena ar = list[i];
|
||||
for (int j = 0; j < ar.Players.Count; ++j)
|
||||
{
|
||||
Mobile mob = ar.Players[j];
|
||||
LadderEntry c = ladder.Find(mob);
|
||||
|
||||
string name = ar.Name;
|
||||
if (p1 == null || c.Index < p1.Index)
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = p1;
|
||||
p1 = c;
|
||||
}
|
||||
else if (p2 == null || c.Index < p2.Index)
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = c;
|
||||
}
|
||||
else if (p3 == null || c.Index < p3.Index)
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = c;
|
||||
}
|
||||
else if (p4 == null || c.Index < p4.Index)
|
||||
{
|
||||
p4 = c;
|
||||
}
|
||||
}
|
||||
|
||||
if ( name == null )
|
||||
name = "(no name)";
|
||||
Append(sb, p1);
|
||||
Append(sb, p2);
|
||||
Append(sb, p3);
|
||||
Append(sb, p4);
|
||||
|
||||
int x = 12;
|
||||
int y = 32 + (i * 31);
|
||||
if (ar.Players.Count > 4)
|
||||
sb.Append(", ...");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("Empty");
|
||||
}
|
||||
|
||||
int color = ( ar.Players.Count > 0 ? 0xCCFFCC : 0xCCCCCC );
|
||||
AddBorderedText(x + 5, y + 5, 325 - 5, sb.ToString(), color, 0);
|
||||
x += 325;
|
||||
|
||||
AddRadio( x + 3, y + 1, 9727, 9730, false, i );
|
||||
x += 35;
|
||||
AddBorderedText(x, y + 5, 40, Center(ar.Spectators.ToString()), color, 0);
|
||||
}
|
||||
}
|
||||
|
||||
AddBorderedText( x + 5, y + 5, 115 - 5, name, color, 0 );
|
||||
x += 115;
|
||||
private void Append(StringBuilder sb, LadderEntry le)
|
||||
{
|
||||
if (le == null)
|
||||
return;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (sb.Length > 0)
|
||||
sb.Append(", ");
|
||||
|
||||
if ( ar.Players.Count > 0 )
|
||||
{
|
||||
Ladder ladder = Ladder.Instance;
|
||||
sb.Append(le.Mobile.Name);
|
||||
}
|
||||
|
||||
if ( ladder == null )
|
||||
continue;
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID != 1)
|
||||
return;
|
||||
|
||||
LadderEntry p1 = null, p2 = null, p3 = null, p4 = null;
|
||||
int[] switches = info.Switches;
|
||||
|
||||
for ( int j = 0; j < ar.Players.Count; ++j )
|
||||
{
|
||||
Mobile mob = (Mobile)ar.Players[j];
|
||||
LadderEntry c = ladder.Find( mob );
|
||||
if (switches.Length == 0)
|
||||
return;
|
||||
|
||||
if ( p1 == null || c.Index < p1.Index )
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = p1;
|
||||
p1 = c;
|
||||
}
|
||||
else if ( p2 == null || c.Index < p2.Index )
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = p2;
|
||||
p2 = c;
|
||||
}
|
||||
else if ( p3 == null || c.Index < p3.Index )
|
||||
{
|
||||
p4 = p3;
|
||||
p3 = c;
|
||||
}
|
||||
else if ( p4 == null || c.Index < p4.Index )
|
||||
{
|
||||
p4 = c;
|
||||
}
|
||||
}
|
||||
int opt = switches[0];
|
||||
|
||||
Append( sb, p1 );
|
||||
Append( sb, p2 );
|
||||
Append( sb, p3 );
|
||||
Append( sb, p4 );
|
||||
if (opt < 0 || opt >= m_Arenas.Count)
|
||||
return;
|
||||
|
||||
if ( ar.Players.Count > 4 )
|
||||
sb.Append( ", ..." );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append( "Empty" );
|
||||
}
|
||||
Arena arena = m_Arenas[opt];
|
||||
|
||||
AddBorderedText( x + 5, y + 5, 325 - 5, sb.ToString(), color, 0 );
|
||||
x += 325;
|
||||
if (!m_From.InRange(m_Gate.GetWorldLocation(), 1) || m_From.Map != m_Gate.Map)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1019002); // You are too far away to use the gate.
|
||||
}
|
||||
else if (DuelContext.CheckCombat(m_From))
|
||||
{
|
||||
m_From.SendMessage(0x22,
|
||||
"You have recently been in combat with another player and cannot use this moongate.");
|
||||
}
|
||||
else if (m_From.Spell != null)
|
||||
{
|
||||
m_From.SendLocalizedMessage(1049616); // You are too busy to do that at the moment.
|
||||
}
|
||||
else if (m_From.Map == arena.Facet && arena.Zone.Contains(m_From))
|
||||
{
|
||||
m_From.SendLocalizedMessage(1019003); // You are already there.
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseCreature.TeleportPets(m_From, arena.GateIn, arena.Facet);
|
||||
|
||||
AddBorderedText( x, y + 5, 40, Center( ar.Spectators.ToString() ), color, 0 );
|
||||
}
|
||||
}
|
||||
m_From.Combatant = null;
|
||||
m_From.Warmode = false;
|
||||
m_From.Hidden = true;
|
||||
|
||||
public string Center( string text )
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
m_From.MoveToWorld(arena.GateIn, arena.Facet);
|
||||
|
||||
public string Color( string text, int color )
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
Effects.PlaySound(arena.GateIn, arena.Facet, 0x1FE);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddBorderedText( int x, int y, int width, string text, int color, int borderColor )
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText( x, y, width, text, color );
|
||||
}
|
||||
public string Center(string text)
|
||||
{
|
||||
return $"<CENTER>{text}</CENTER>";
|
||||
}
|
||||
|
||||
private void AddColoredText( int x, int y, int width, string text, int color )
|
||||
{
|
||||
if ( color == 0 )
|
||||
AddHtml( x, y, width, 20, text, false, false );
|
||||
else
|
||||
AddHtml( x, y, width, 20, Color( text, color ), false, false );
|
||||
}
|
||||
public string Color(string text, int color)
|
||||
{
|
||||
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
|
||||
}
|
||||
|
||||
private int m_ColumnX = 12;
|
||||
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
|
||||
{
|
||||
/*AddColoredText( x - 1, y, width, text, borderColor );
|
||||
AddColoredText( x + 1, y, width, text, borderColor );
|
||||
AddColoredText( x, y - 1, width, text, borderColor );
|
||||
AddColoredText( x, y + 1, width, text, borderColor );*/
|
||||
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
|
||||
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
|
||||
AddColoredText(x, y, width, text, color);
|
||||
}
|
||||
|
||||
private void AddColumnHeader( int width, string name )
|
||||
{
|
||||
AddBackground( m_ColumnX, 12, width, 20, 0x242C );
|
||||
AddImageTiled( m_ColumnX + 2, 14, width - 4, 16, 0x2430 );
|
||||
private void AddColoredText(int x, int y, int width, string text, int color)
|
||||
{
|
||||
if (color == 0)
|
||||
AddHtml(x, y, width, 20, text, false, false);
|
||||
else
|
||||
AddHtml(x, y, width, 20, Color(text, color), false, false);
|
||||
}
|
||||
|
||||
if ( name != null )
|
||||
AddBorderedText( m_ColumnX, 13, width, Center( name ), 0xFFFFFF, 0 );
|
||||
private void AddColumnHeader(int width, string name)
|
||||
{
|
||||
AddBackground(m_ColumnX, 12, width, 20, 0x242C);
|
||||
AddImageTiled(m_ColumnX + 2, 14, width - 4, 16, 0x2430);
|
||||
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name != null)
|
||||
AddBorderedText(m_ColumnX, 13, width, Center(name), 0xFFFFFF, 0);
|
||||
|
||||
m_ColumnX += width;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue