/*
Script Name: ChampGate.cs
Author: CEO
Version: 1.0
Public Release: 02/04/05
Purpose: Creates a ONE-WAY gate to champspawn destinations with look and feel simular to the public moongates.
Description: The teleport locations are for the most part the standard OSI spots. If you
have moved champ spawns or the Z axis doesn't match the ones used for this script
you may need to tweak them to prevent teleportation stuckation.
See the item's properties for Security settings. You may give Players access, not
a great idea, but it works well for new shards or ones with a limited population. It
does encourage champ spawn activity, one started up on our shard within minutes
of the gate being created. Probably more of a novelty thing for Players, could be
useful for Staff as a perma gate in Green Acres.
The gump will show a warning for Players as they will NOT be hidden (Staff hides) when
coming out on the otherside of the gate. Could be deadly for those not prepared to run!
Installation: Unzip ChampGate.zip into your custom scripts folder and restart.
[add ChampGate
*/
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Items
{
public class Champgate : Item
{
private AccessLevel m_AccessLevel;
[CommandProperty( AccessLevel.GameMaster )]
public AccessLevel Security
{
get {
return m_AccessLevel;
}
set {
if ((value <= AccessLevel.Administrator) && (value >= AccessLevel.Player)) {
m_AccessLevel = value;
} else {
return;
};
}
}
[Constructable]
public Champgate() : base( 0xF6C )
{
Movable = false;
Light = LightType.Circle300;
Hue = 34;
m_AccessLevel = AccessLevel.GameMaster;
}
public Champgate( Serial serial ) : base( serial )
{
}
public override void OnDoubleClick( Mobile from )
{
if ( !from.Player )
return;
if ( from.InRange( GetWorldLocation(), 1 ) )
UseGate( from );
else
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
public override bool OnMoveOver( Mobile m )
{
return !m.Player || UseGate( m );
}
public bool UseGate( Mobile m )
{
if ( m.Criminal )
{
m.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
return false;
}
else if ( Server.Spells.SpellHelper.CheckCombat( m ) )
{
m.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
return false;
}
else if ( m.Spell != null )
{
m.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
return false;
}
else if ( m.AccessLevel < m_AccessLevel )
{
m.SendMessage( "You are unable to use that!" );
return false;
}
else
{
m.CloseGump( typeof( ChampgateGump ) );
m.SendGump( new ChampgateGump( m, this ) );
Effects.PlaySound( m.Location, m.Map, 0x20E );
return true;
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (int) m_AccessLevel );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
m_AccessLevel = (AccessLevel) reader.ReadInt();
}
}
public class CMEntry
{
private Point3D m_Location;
private string m_Mapname;
public Point3D Location
{
get
{
return m_Location;
}
}
public string Mapname
{
get
{
return m_Mapname;
}
}
public CMEntry( Point3D loc, string mapname )
{
m_Location = loc;
m_Mapname = mapname;
}
}
public class CMList
{
private Map m_Map;
private string m_Mapname;
private CMEntry[] m_Entries;
public Map Map
{
get
{
return m_Map;
}
}
public string Mapname
{
get
{
return m_Mapname;
}
}
public CMEntry[] Entries
{
get
{
return m_Entries;
}
}
public CMList( Map map, string mapname, CMEntry[] entries )
{
m_Map = map;
m_Mapname = mapname;
m_Entries = entries;
}
public static readonly CMList T2A =
new CMList( Map.Felucca, "T2A", new CMEntry[]
{
new CMEntry( new Point3D( 5511, 2361, 25 ), "Ice West" ),
new CMEntry( new Point3D( 6038, 2400, 31 ), "Ice East" ),
new CMEntry( new Point3D( 5549, 2640, 3 ), "Oasis" ),
new CMEntry( new Point3D( 5637, 2915, 21 ), "Desert" ),
new CMEntry( new Point3D( 6035, 2940, 35 ), "Terra Sanctum" ),
new CMEntry( new Point3D( 5265, 3171, 92 ), "Marble" ),
new CMEntry( new Point3D( 5283, 3368, 37 ), "Damwin" ),
new CMEntry( new Point3D( 5954, 3475, 10 ), "Hoppers Bog" ),
new CMEntry( new Point3D( 5208, 3636, 6 ), "City of Death" ),
new CMEntry( new Point3D( 5561, 3759, 7 ), "Wild (Lord Oaks)" ),
new CMEntry( new Point3D( 5982, 3882, 6 ), "Khaldun" ),
new CMEntry( new Point3D( 5726, 3993, 25 ), "Tortoise" )
} );
public static readonly CMList Dungeons =
new CMList( Map.Felucca, "Dungeons", new CMEntry[]
{
new CMEntry( new Point3D( 5253, 832, 41 ), "Destard (Cold Blood)" ),
new CMEntry( new Point3D( 5189, 1608, 6 ), "Tera-Keep (Arachnid)"),
new CMEntry( new Point3D( 5815, 1351, -13 ), "Fire (Abyss)"),
new CMEntry( new Point3D( 5179, 707, 6 ), "Deceit (Unholy Terror)"),
new CMEntry( new Point3D( 5556, 823, 50 ), "Despise (Vermin Horde)")
} );
public static readonly CMList Ilshenar =
new CMList( Map.Ilshenar, "Ilshenar", new CMEntry[]
{
new CMEntry( new Point3D( 469, 927, -80 ), "Humility" ),
new CMEntry( new Point3D( 1645, 1108, -5 ), "Lord Oaks/Forest Queen" )
} );
public static readonly CMList Special =
new CMList( Map.Felucca, "Special", new CMEntry[]
{
new CMEntry( new Point3D( 5137, 1767, 0 ), "StarRoom" )
} );
public static readonly CMList[] UORLists = new CMList[]{ T2A, Dungeons, Special };
public static readonly CMList[] LBRLists = new CMList[]{ T2A, Dungeons, Ilshenar, Special };
public static readonly CMList[] AOSLists = new CMList[]{ T2A, Dungeons, Ilshenar, Special };
public static readonly CMList[] RedLists = new CMList[]{ T2A, Dungeons, Special };
}
public class ChampgateGump : Gump
{
private Mobile m_Mobile;
private Item m_Champgate;
private CMList[] m_Lists;
private int listLength;
public ChampgateGump( Mobile mobile, Item Champgate ) : base( 100, 100 )
{
m_Mobile = mobile;
m_Champgate = Champgate;
CMList[] checkLists;
if ( mobile.Player )
{
if ( mobile.Kills >= 5 )
{
checkLists = CMList.RedLists;
}
else
{
int flags = mobile.NetState == null ? 0 : mobile.NetState.Flags;
if ( Core.AOS && (flags & 0x8) != 0 )
checkLists = CMList.AOSLists;
else if ( (flags & 0x4) != 0 )
checkLists = CMList.LBRLists;
else
checkLists = CMList.UORLists;
}
}
else
{
checkLists = CMList.AOSLists;
}
m_Lists = new CMList[checkLists.Length];
for ( int i = 0; i < m_Lists.Length; ++i )
m_Lists[i] = checkLists[i];
listLength = m_Lists.Length;
AddPage( 0 );
AddBackground( 0, 0, 380, 355, 5054 );
AddButton( 10, 285, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 285, 140, 25, 1011036, false, false ); // OKAY
AddButton( 10, 310, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 310, 140, 25, 1011012, false, false ); // CANCEL
AddHtmlLocalized( 5, 5, 200, 20, 1012011, false, false ); // Pick your destination:
AddHtml( 262, 5, 200, 20, "CEO's ChampGate V1.0", false, false);
if ( mobile.AccessLevel == AccessLevel.Player ) // Players don't get the Special gates
{ // and need a warning cause I don't want
listLength = m_Lists.Length - 1; // any whining about getting killed.
AddHtml( 10, 240, 200, 20,"Warning: You will not be hidden", false, false);
AddHtml( 67, 260, 200, 20,"on the other side!", false, false);
}
for ( int i = 0; i < listLength; ++i )
{
AddButton( 10, 35 + (i * 25), 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf( m_Lists, checkLists[i] ) + 1 );
AddHtml( 30, 35 + (i * 25), 150, 20, m_Lists[i].Mapname, false, false );
}
for ( int i = 0; i < m_Lists.Length; ++i )
RenderPage( i, Array.IndexOf( checkLists, m_Lists[i] ) );
}
private void RenderPage( int index, int offset )
{
CMList list = m_Lists[index];
AddPage( index + 1 );
AddButton( 10, 35 + (offset * 25), 2117, 2118, 0, GumpButtonType.Page, index + 1 );
AddHtml( 30, 35 + (offset * 25), 150, 20, "" + list.Mapname +"", false, false);
CMEntry[] entries = list.Entries;
for ( int i = 0; i < entries.Length; ++i )
{
AddRadio( 200, 35 + (i * 25), 210, 211, false, (index * 100) + i );
AddHtml( 225, 35 + (i * 25), 150, 20, entries[i].Mapname, false, false );
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID == 0 ) // Cancel
return;
else if ( m_Mobile.Deleted || m_Champgate.Deleted || m_Mobile.Map == null )
return;
int[] switches = info.Switches;
if ( switches.Length == 0 )
return;
int switchID = switches[0];
int listIndex = switchID / 100;
int listEntry = switchID % 100;
if ( listIndex < 0 || listIndex >= m_Lists.Length )
return;
CMList list = m_Lists[listIndex];
if ( listEntry < 0 || listEntry >= list.Entries.Length )
return;
CMEntry entry = list.Entries[listEntry];
if ( !m_Mobile.InRange( m_Champgate.GetWorldLocation(), 1 ) || m_Mobile.Map != m_Champgate.Map )
{
m_Mobile.SendLocalizedMessage( 1019002 ); // You are too far away to use the gate.
}
else if ( m_Mobile.Player && m_Mobile.Kills >= 5 && list.Map != Map.Felucca )
{
m_Mobile.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there.
}
else if ( m_Mobile.Criminal )
{
m_Mobile.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
}
else if ( Server.Spells.SpellHelper.CheckCombat( m_Mobile ) )
{
m_Mobile.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
}
else if ( m_Mobile.Spell != null )
{
m_Mobile.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
}
else if ( m_Mobile.Map == list.Map && m_Mobile.InRange( entry.Location, 1 ) )
{
m_Mobile.SendLocalizedMessage( 1019003 ); // You are already there.
}
else
{
BaseCreature.TeleportPets( m_Mobile, entry.Location, list.Map );
m_Mobile.Combatant = null;
m_Mobile.Warmode = false;
if ( m_Mobile.AccessLevel > AccessLevel.Player )
m_Mobile.Hidden = true;
else
m_Mobile.Hidden = false; //Unhide a player
m_Mobile.MoveToWorld( entry.Location, list.Map );
Effects.PlaySound( entry.Location, list.Map, 0x1FE );
}
}
}
}