/* Advanced Player Gate Script for RunUO
*
* by Lokai
* modified by Mum_Chamber
*
* Description: This gate allows GameMasters to create custom gates that
* perform a variety of functions. They can simply teleport to somewhere,
* they can change the Player's Stats, Skills, or Hue. They can Resurrect
* the Player, or they can do all of these things. This can be used as a
* Profession Gate, a Resurrection Gate, or a Race Gate.
*
* To Use: Simply add this script to your scripts folder. Then, use the [add
* command to create an AdvancedPlayerGate, and use [props command to adjust
* the many built-in features.
*
* Update at 15/08/2004 by Mum_Chamber
* The gate now can add a title of your choice, limit the number of players,
* show a custom message, give items (blessed or not) and take them back.
*/
using System;
using Server;
using System.Collections;
using System.Reflection;
using Server.Gumps;
using Server.HuePickers;
using Server.Commands;
namespace Server.Items
{
public class AdvancedPlayerGate : Moongate
{
// Private variable declarations.
private bool m_Decays;
private bool m_DoesTeleport = true;
private bool m_DoesResurrect = true;
private bool m_ChangesSkills = true;
private bool m_ChangesStats = true;
private bool m_ChangesHue = false;
private bool m_SkillsGiveItems = false;
private int m_SkillsItemsMin = 50;
private DateTime m_DecayTime;
private Timer m_Timer;
private int m_Int;
private int m_Dex;
private int m_Str;
private string m_GateMessage;
private int[] gAllSkills = new int[58];
#region " Mum_Chamber's Stuff "
// Title
private bool m_TitleAdds = true;
private string m_TitleToAdd = "";
// Player Count
private bool m_PlayerCountLimited = true;
private int m_PlayerCountMax = 10; //set how many players you want to be affected.
private int m_PlayersPassed = 0;
private string m_PlayerCountExeededMessage = "too many players passed already";
// Items
private bool m_GivesItems = true;
private bool m_GivesBlessedItems = true; // if there is an event, noone can loot each other
private bool m_TakesBackGivenItems = true; // when they exit the area, they may pass the gate
// again, so we take back what we give.
public ArrayList ItemsToGive = new ArrayList();
// Title Props
[CommandProperty( AccessLevel.GameMaster )]
public string TitleToAdd {get{ return m_TitleToAdd;} set{ m_TitleToAdd = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool TitleAdds {get{ return m_TitleAdds;} set{ m_TitleAdds = value;}}
// Player Count Props
[CommandProperty( AccessLevel.GameMaster )]
public bool _PlayerCountLimited {get{ return m_PlayerCountLimited;} set{ m_PlayerCountLimited = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int PlayerCountMax {get{ return m_PlayerCountMax;} set{ m_PlayerCountMax = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int PlayersPassed {get{ return m_PlayersPassed;} set{ m_PlayersPassed = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public string PlayerCountExeededMessage {get{ return m_PlayerCountExeededMessage;} set{ m_PlayerCountExeededMessage = value;}}
// Item Props
[CommandProperty( AccessLevel.GameMaster )]
public bool _GivesItems {get{ return m_GivesItems;} set{ m_GivesItems = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool _GivesBlessedItems {get{ return m_GivesBlessedItems;} set{ m_GivesBlessedItems = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool _TakesBackGivenItems {get{ return m_TakesBackGivenItems;} set{ m_TakesBackGivenItems = value;}}
#endregion
#region " skills "
// Public Command-list
[CommandProperty( AccessLevel.GameMaster )]
public int AlchemySkill {get{ return gAllSkills[0];} set{ gAllSkills[0] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int AnatomySkill {get{ return gAllSkills[1];} set{ gAllSkills[1] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int AnimalLoreSkill {get{ return gAllSkills[2];} set{ gAllSkills[2] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int ItemIDSkill {get{ return gAllSkills[3];} set{ gAllSkills[3] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int ArmsLoreSkill {get{ return gAllSkills[4];} set{ gAllSkills[4] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int ParrySkill {get{ return gAllSkills[5];} set{ gAllSkills[5] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int BeggingSkill {get{ return gAllSkills[6];} set{ gAllSkills[6] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int BlacksmithSkill {get{ return gAllSkills[7];} set{ gAllSkills[7] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int FletchingSkill {get{ return gAllSkills[8];} set{ gAllSkills[8] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int PeacemakingSkill {get{ return gAllSkills[9];} set{ gAllSkills[9] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int CampingSkill {get{ return gAllSkills[10];} set{ gAllSkills[10] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int CarpentrySkill {get{ return gAllSkills[11];} set{ gAllSkills[11] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int CartographySkill {get{ return gAllSkills[12];} set{ gAllSkills[12] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int CookingSkill {get{ return gAllSkills[13];} set{ gAllSkills[13] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int DetectHiddenSkill {get{ return gAllSkills[14];} set{ gAllSkills[14] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int DiscordanceSkill {get{ return gAllSkills[15];} set{ gAllSkills[15] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int EvalIntSkill {get{ return gAllSkills[16];} set{ gAllSkills[16] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int HealingSkill {get{ return gAllSkills[17];} set{ gAllSkills[17] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int FishingSkill {get{ return gAllSkills[18];} set{ gAllSkills[18] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int ForensicsSkill {get{ return gAllSkills[19];} set{ gAllSkills[19] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int HerdingSkill {get{ return gAllSkills[20];} set{ gAllSkills[20] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int HidingSkill {get{ return gAllSkills[21];} set{ gAllSkills[21] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int ProvocationSkill {get{ return gAllSkills[22];} set{ gAllSkills[22] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int InscribeSkill {get{ return gAllSkills[23];} set{ gAllSkills[23] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int LockpickingSkill {get{ return gAllSkills[24];} set{ gAllSkills[24] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int MagerySkill {get{ return gAllSkills[25];} set{ gAllSkills[25] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int MagicResistSkill {get{ return gAllSkills[26];} set{ gAllSkills[26] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int TacticsSkill {get{ return gAllSkills[27];} set{ gAllSkills[27] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int SnoopingSkill {get{ return gAllSkills[28];} set{ gAllSkills[28] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int MusicianshipSkill {get{ return gAllSkills[29];} set{ gAllSkills[29] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int PoisoningSkill {get{ return gAllSkills[30];} set{ gAllSkills[30] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int ArcherySkill {get{ return gAllSkills[31];} set{ gAllSkills[31] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int SpiritSpeakSkill {get{ return gAllSkills[32];} set{ gAllSkills[32] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int StealingSkill {get{ return gAllSkills[33];} set{ gAllSkills[33] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int TailoringSkill {get{ return gAllSkills[34];} set{ gAllSkills[34] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int AnimalTamingSkill {get{ return gAllSkills[35];} set{ gAllSkills[35] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int TasteIDSkill {get{ return gAllSkills[36];} set{ gAllSkills[36] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int TinkeringSkill {get{ return gAllSkills[37];} set{ gAllSkills[37] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int TrackingSkill {get{ return gAllSkills[38];} set{ gAllSkills[38] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int VeterinarySkill {get{ return gAllSkills[39];} set{ gAllSkills[39] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int SwordsSkill {get{ return gAllSkills[40];} set{ gAllSkills[40] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int MacingSkill {get{ return gAllSkills[41];} set{ gAllSkills[41] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int FencingSkill {get{ return gAllSkills[42];} set{ gAllSkills[42] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int WrestlingSkill {get{ return gAllSkills[43];} set{ gAllSkills[43] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int LumberjackingSkill {get{ return gAllSkills[44];} set{ gAllSkills[44] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int MiningSkill {get{ return gAllSkills[45];} set{ gAllSkills[45] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int MeditationSkill {get{ return gAllSkills[46];} set{ gAllSkills[46] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int StealthSkill {get{ return gAllSkills[47];} set{ gAllSkills[47] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int RemoveTrapSkill {get{ return gAllSkills[48];} set{ gAllSkills[48] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int NecromancySkill {get{ return gAllSkills[49];} set{gAllSkills[49] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int FocusSkill {get{ return gAllSkills[50];} set{ gAllSkills[50] = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int ChivalrySkill {get{ return gAllSkills[51];} set{ gAllSkills[51] = value;}}
[CommandProperty(AccessLevel.GameMaster)]
public int BushidoSkill { get { return gAllSkills[52]; } set { gAllSkills[52] = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public int NinjitsuSkill { get { return gAllSkills[53]; } set { gAllSkills[53] = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public int SpellWeavingSkill { get { return gAllSkills[54]; } set { gAllSkills[54] = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public int MysticismSkill { get { return gAllSkills[55]; } set { gAllSkills[55] = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public int ImbuingSkill { get { return gAllSkills[56]; } set { gAllSkills[56] = value; } }
[CommandProperty(AccessLevel.GameMaster)]
public int ThrowingSkill { get { return gAllSkills[57]; } set { gAllSkills[57] = value; } }
#endregion
#region " other stuff "
[CommandProperty( AccessLevel.GameMaster )]
public int _Set_Int {get{ return m_Int; } set{ m_Int = value; }}
[CommandProperty( AccessLevel.GameMaster )]
public int _Set_Dex {get{ return m_Dex; } set{ m_Dex = value; }}
[CommandProperty( AccessLevel.GameMaster )]
public int _Set_Str {get{ return m_Str; } set{ m_Str = value; }}
[CommandProperty( AccessLevel.GameMaster )]
public string _GateMessage {get{ return m_GateMessage; }set{ m_GateMessage = value; }}
[CommandProperty( AccessLevel.GameMaster )]
public bool _DoesTeleport {get{return m_DoesTeleport;} set{m_DoesTeleport = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool _DoesResurrect {get{return m_DoesResurrect;} set{m_DoesResurrect = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool _ChangesSkills {get{return m_ChangesSkills;} set{m_ChangesSkills = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool _ChangesStats {get{return m_ChangesStats;} set{m_ChangesStats = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool _ChangesHue {get{return m_ChangesHue;} set{m_ChangesHue = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public bool _SkillsGiveItems {get{return m_SkillsGiveItems;} set{m_SkillsGiveItems = value;}}
[CommandProperty( AccessLevel.GameMaster )]
public int _SkillsItemsMin {get{return m_SkillsItemsMin;} set{m_SkillsItemsMin = value;}}
#endregion
//Base Constructor m_SkillsItemsMin
[Constructable]
public AdvancedPlayerGate() : this( false )
{
Movable = false;
Hue = 0x2D1;
Name = "Advanced Player Gate";
Light = LightType.Circle300;
}
[Constructable]
public AdvancedPlayerGate( bool decays, Point3D loc, Map map ) : this( decays )
{
MoveToWorld( loc, map );
Effects.PlaySound( loc, map, 0x20E );
}
[Constructable]
public AdvancedPlayerGate( bool decays ) : base( new Point3D( 1401, 1625, 28 ), Map.Trammel )
{
Dispellable = false;
ItemID = 0x1FD4;
if ( decays )
{
m_Decays = true;
m_DecayTime = DateTime.Now + TimeSpan.FromMinutes( 2.0 );
m_Timer = new InternalTimer( this, m_DecayTime );
m_Timer.Start();
}
}
public AdvancedPlayerGate( Serial serial ) : base( serial )
{
}
public void OptimizeItemsList()
{
if (ItemsToGive.Count == 0)
return;
for(int i = 0; i < ItemsToGive.Count; i++)
{
for (int j = 0; j < ItemsToGive.Count; j++)
{
if( ItemsToGive[i] is Item && ItemsToGive[j] is Item && i != j )
{
Item itemi = (Item)ItemsToGive[i];
Item itemj = (Item)ItemsToGive[j];
if( itemi.ItemData.Name == itemj.ItemData.Name )
{
itemi.Amount += itemj.Amount;
ItemsToGive.RemoveAt( j );
}
}
}
}
}
public override void OnDoubleClick( Mobile from )
{
if ( !from.Player )
return;
OptimizeItemsList();
// When the player double-clicks on the gate, they see the
// Stats and Skills they will get.
from.SendGump( new GateDialogGump( m_Str, m_Dex, m_Int, _GateMessage,
gAllSkills, from, _DoesResurrect, _ChangesStats, _ChangesSkills,
_SkillsGiveItems, _SkillsItemsMin, m_TitleAdds, m_TitleToAdd,
m_PlayerCountLimited, m_PlayerCountMax, m_PlayersPassed,
m_PlayerCountExeededMessage, this ));
}
public override void UseGate( Mobile m )
{
OptimizeItemsList();
// Murderers are not allowed to use the gate.
if ( m.Kills >= 5 )
{
m.SendLocalizedMessage( 1019004 );
}
// If you cast a spell, you are too busy to use the gate.
else if ( m.Spell != null )
{
m.SendLocalizedMessage( 1049616 );
}
else if ( m_PlayerCountMax <= m_PlayersPassed && m_PlayerCountLimited )
{
m.SendMessage( m_PlayerCountExeededMessage );
}
else
{
if (_ChangesStats)
{
m.Str = this.m_Str;
m.Dex = this.m_Dex;
m.Int = this.m_Int;
}
if (_DoesResurrect && !m.Alive)
{
/*
* why do we modify the name when they resurrect?
string nam = m.Name;
int last = nam.Length;
if (nam.Substring(last-2,2) == " I") nam = nam + "I";
else if (nam.Substring(last-3,3) == " II") nam = nam + "I";
else if (nam.Substring(last-3,3) == "III") nam = nam.Substring(0,last-2) + "V";
else if (nam.Substring(last-2,2) == "IV") nam = nam.Substring(0,last-2) + "V";
else if (nam.EndsWith(" V"))
{
if ( m.Female )
nam = NameList.RandomName( "female" );
else
nam = NameList.RandomName( "male" );
}
else nam = nam + " II";
m.Name = nam;
*/
m.Resurrect();
}
if (_DoesTeleport)
{
m.Map = this.TargetMap;
m.Location = this.Target;
}
if (_ChangesSkills)
{
Server.Skills skills = m.Skills;
for ( int i = 0; i < skills.Length; ++i ) skills[i].Base = gAllSkills[i];
}
if (_ChangesHue) m.Hue = this.Hue;
if (_SkillsGiveItems)
{
Server.Skills s = m.Skills;
for ( int i = 0; i < s.Length; ++i )
if (gAllSkills[i] >= _SkillsItemsMin)
SkillsItems((SkillName)i, m);
}
if (m_TitleAdds)
{
m.Title = this.m_TitleToAdd;
}
if ( m_TakesBackGivenItems )
{
for( int i = 0; i < ItemsToGive.Count; i++)
{
if (ItemsToGive[i] is Item)
{
m.Backpack.ConsumeUpTo( ((Item)(ItemsToGive[i])).GetType(), ((Item)(ItemsToGive[i])).Amount );
}
}
}
if (m_GivesItems)
{
for( int i = 0; i < ItemsToGive.Count; i++)
{
if (ItemsToGive[i] is Item)
{
Item item = (Item)ItemsToGive[i];
if (m_GivesBlessedItems)
{
item.LootType = LootType.Blessed;
}
if( item.Stackable )
PackItem( item, m ) ;
else
{
int times = 0;
int amount = item.Amount;
item.Amount = 1;
//while( times < amount )
//{
// PackItem( item.Copy(1), m ) ;
// times++;
//}
}
}
}
}
m.PlaySound( 0x1FE );
m_PlayersPassed++;
}
}
public override bool OnMoveOver( Mobile m )
{
if ( m.Player )
{
CheckGate( m, 0 );
}
return true;
}
private static void EquipItem( Item item, Mobile m )
{
if ( !Core.AOS )
item.LootType = LootType.Newbied;
if ( m != null && m.EquipItem( item ) )
return;
Container pack = m.Backpack;
if ( pack != null )
pack.DropItem( item );
else
item.Delete();
}
private static void PackItem( Item item, Mobile m )
{
if ( !Core.AOS )
item.LootType = LootType.Newbied;
Container pack = m.Backpack;
if ( pack != null )
pack.DropItem( item );
else
item.Delete();
}
private static void PackInstrument( Mobile m )
{
switch ( Utility.Random( 6 ) )
{
case 0: PackItem( new Drums(), m ); break;
case 1: PackItem( new Harp(), m ); break;
case 2: PackItem( new LapHarp(), m ); break;
case 3: PackItem( new Lute(), m ); break;
case 4: PackItem( new Tambourine(), m ); break;
case 5: PackItem( new TambourineTassel(), m ); break;
}
}
private static void SkillsItems( SkillName skill, Mobile m )
{
switch ( skill )
{
case SkillName.Alchemy:
{
PackItem( new Bottle( 4 ), m );
PackItem( new MortarPestle(), m );
EquipItem( new Robe( Utility.RandomPinkHue() ), m );
break;
}
case SkillName.Anatomy:
{
PackItem( new Bandage( 3 ), m );
EquipItem( new Robe( Utility.RandomYellowHue() ), m );
break;
}
case SkillName.AnimalLore:
{
EquipItem( new ShepherdsCrook(), m );
EquipItem( new Robe( Utility.RandomBlueHue() ), m );
break;
}
case SkillName.Archery:
{
PackItem( new Arrow( 25 ), m );
EquipItem( new Bow(), m );
break;
}
case SkillName.ArmsLore:
{
switch ( Utility.Random( 3 ) )
{
case 0: EquipItem( new Kryss(), m ); break;
case 1: EquipItem( new Katana(), m ); break;
case 2: EquipItem( new Club(), m ); break;
}
break;
}
case SkillName.Begging:
{
EquipItem( new GnarledStaff(), m );
break;
}
case SkillName.Blacksmith:
{
PackItem( new Tongs(), m );
PackItem( new Pickaxe(), m );
PackItem( new Pickaxe(), m );
PackItem( new IronIngot( 50 ), m );
EquipItem( new HalfApron( Utility.RandomYellowHue() ), m );
break;
}
case SkillName.Fletching:
{
PackItem( new Board( 14 ), m );
PackItem( new Feather( 5 ), m );
PackItem( new Shaft( 5 ), m );
break;
}
case SkillName.Camping:
{
// TODO: Bedroll
PackItem( new Kindling( 5 ), m );
break;
}
case SkillName.Carpentry:
{
PackItem( new Board( 10 ), m );
PackItem( new Saw(), m );
EquipItem( new HalfApron( Utility.RandomYellowHue() ), m );
break;
}
case SkillName.Cartography:
{
PackItem( new BlankMap(), m );
PackItem( new BlankMap(), m );
PackItem( new BlankMap(), m );
PackItem( new BlankMap(), m );
PackItem( new Sextant(), m );
break;
}
case SkillName.Cooking:
{
PackItem( new Kindling( 2 ), m );
PackItem( new RawLambLeg(), m );
PackItem( new RawChickenLeg(), m );
PackItem( new RawFishSteak(), m );
PackItem( new SackFlour(), m );
PackItem( new Pitcher( BeverageType.Water ), m );
break;
}
case SkillName.DetectHidden:
{
EquipItem( new Cloak( 0x455 ), m );
break;
}
case SkillName.Discordance:
{
PackInstrument( m );
break;
}
case SkillName.Fencing:
{
EquipItem( new Kryss(), m );
break;
}
case SkillName.Fishing:
{
EquipItem( new FishingPole(), m );
EquipItem( new FloppyHat( Utility.RandomYellowHue() ), m );
break;
}
case SkillName.Healing:
{
PackItem( new Bandage( 50 ), m );
PackItem( new Scissors(), m );
break;
}
case SkillName.Herding:
{
EquipItem( new ShepherdsCrook(), m );
break;
}
case SkillName.Hiding:
{
EquipItem( new Cloak( 0x455 ), m );
break;
}
case SkillName.Inscribe:
{
PackItem( new BlankScroll( 2 ), m );
PackItem( new BlueBook(), m );
break;
}
case SkillName.ItemID:
{
EquipItem( new GnarledStaff(), m );
break;
}
case SkillName.Lockpicking:
{
PackItem( new Lockpick( 20 ), m );
break;
}
case SkillName.Lumberjacking:
{
EquipItem( new Hatchet(), m );
break;
}
case SkillName.Macing:
{
EquipItem( new Club(), m );
break;
}
case SkillName.Magery:
{
BagOfReagents regs = new BagOfReagents( 30 );
if ( !Core.AOS )
{
foreach ( Item item in regs.Items )
item.LootType = LootType.Newbied;
}
PackItem( regs, m );
regs.LootType = LootType.Regular;
Spellbook book = new Spellbook( (ulong)0x382A8C38 );
EquipItem( book, m );
book.LootType = LootType.Blessed;
EquipItem( new Robe( Utility.RandomBlueHue() ), m );
EquipItem( new WizardsHat(), m );
break;
}
case SkillName.Mining:
{
PackItem( new Pickaxe(), m );
break;
}
case SkillName.Musicianship:
{
PackInstrument( m );
break;
}
case SkillName.Parry:
{
EquipItem( new WoodenShield(), m );
break;
}
case SkillName.Peacemaking:
{
PackInstrument( m );
break;
}
case SkillName.Poisoning:
{
PackItem( new LesserPoisonPotion(), m );
PackItem( new LesserPoisonPotion(), m );
break;
}
case SkillName.Provocation:
{
PackInstrument( m );
break;
}
case SkillName.Snooping:
{
PackItem( new Lockpick( 20 ), m );
break;
}
case SkillName.SpiritSpeak:
{
EquipItem( new Cloak( 0x455 ), m );
break;
}
case SkillName.Stealing:
{
PackItem( new Lockpick( 20 ), m );
break;
}
case SkillName.Swords:
{
EquipItem( new Katana(), m );
break;
}
case SkillName.Tactics:
{
EquipItem( new Katana(), m );
break;
}
case SkillName.Tailoring:
{
PackItem( new BoltOfCloth(), m );
PackItem( new SewingKit(), m );
break;
}
case SkillName.Tracking:
{
if ( m != null )
{
Item shoes = m.FindItemOnLayer( Layer.Shoes );
if ( shoes != null )
shoes.Delete();
}
EquipItem( new Boots( Utility.RandomYellowHue() ), m );
EquipItem( new SkinningKnife(), m );
break;
}
case SkillName.Veterinary:
{
PackItem( new Bandage( 5 ), m );
PackItem( new Scissors(), m );
break;
}
case SkillName.Wrestling:
{
EquipItem( new LeatherGloves(), m );
break;
}
}
}
public override void OnAfterDelete()
{
if ( m_Timer != null )
m_Timer.Stop();
base.OnAfterDelete();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 4 ); // version
writer.Write( (bool)m_GivesItems );// version 4
writer.Write( (bool)m_GivesBlessedItems );
writer.Write( (bool)m_TakesBackGivenItems );
writer.Write( (int)ItemsToGive.Count );
for( int i = 0 ; i < ItemsToGive.Count; i++ )
{
writer.Write( (Item)(ItemsToGive[i]) );
}
writer.Write( (bool)m_PlayerCountLimited ); // version 3
writer.Write( (int)m_PlayerCountMax );
writer.Write( (int)m_PlayersPassed );
writer.Write( (string)m_PlayerCountExeededMessage );
writer.Write( m_TitleAdds ); //version 2
writer.Write( (string)m_TitleToAdd );
writer.Write( m_DoesTeleport ); // version 1
writer.Write( m_DoesResurrect );
writer.Write( m_ChangesSkills );
writer.Write( m_ChangesStats );
writer.Write( m_ChangesHue );
writer.Write( m_SkillsGiveItems );
writer.Write( (int)m_SkillsItemsMin );
writer.Write( (int)m_Int );
writer.Write( (int)m_Dex );
writer.Write( (int)m_Str );
for (int x = 0; x<52; x++) writer.Write( (int)gAllSkills[x] );
writer.Write( m_GateMessage );
writer.Write( m_Decays ); // version 0
if ( m_Decays ) writer.WriteDeltaTime( m_DecayTime );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 4:
{
m_GivesItems = reader.ReadBool();
m_GivesBlessedItems = reader.ReadBool();
m_TakesBackGivenItems = reader.ReadBool();
int j = reader.ReadInt();
for( int i = 0 ; i < j; i++ )
{
ItemsToGive.Add( reader.ReadItem() );
}
goto case 3;
}
case 3:
{
m_PlayerCountLimited = reader.ReadBool();
m_PlayerCountMax = reader.ReadInt();
m_PlayersPassed = reader.ReadInt();
m_PlayerCountExeededMessage = reader.ReadString();
goto case 2;
}
case 2:
{
m_TitleAdds = reader.ReadBool();
m_TitleToAdd = reader.ReadString();
goto case 1;
}
case 1:
{
m_DoesTeleport = reader.ReadBool();
m_DoesResurrect = reader.ReadBool();
m_ChangesSkills = reader.ReadBool();
m_ChangesStats = reader.ReadBool();
m_ChangesHue = reader.ReadBool();
m_SkillsGiveItems = reader.ReadBool();
m_SkillsItemsMin = reader.ReadInt();
m_Int = reader.ReadInt();
m_Dex = reader.ReadInt();
m_Str = reader.ReadInt();
for (int y = 0; y<52; y++) gAllSkills[y] = reader.ReadInt();
m_GateMessage = reader.ReadString();
goto case 0;
}
case 0:
{
m_Decays = reader.ReadBool();
if ( m_Decays )
{
m_DecayTime = reader.ReadDeltaTime();
m_Timer = new InternalTimer( this, m_DecayTime );
m_Timer.Start();
}
break;
}
}
}
private class InternalTimer : Timer
{
private Item m_Item;
public InternalTimer( Item item, DateTime end ) : base( end - DateTime.Now )
{
m_Item = item;
}
protected override void OnTick()
{
m_Item.Delete();
}
}
}
}