| CODE |
using System; using System.Collections; using Server; using Server.Items; using Server.Gumps; using Server.Spells; using Server.Spells.Fifth; using Server.Mobiles; namespace Server.Spells.Seventh { public class PolymorphSpell : Spell { private static SpellInfo m_Info = new SpellInfo( "Polymorph", "Vas Ylem Rel", SpellCircle.Seventh, 221, 9002, Reagent.Bloodmoss, Reagent.SpidersSilk, Reagent.MandrakeRoot ); private int m_NewBody; private static int m_BonusSTR = 0; private static int m_BonusINT = 0; private static int m_BonusDEX = 0; public PolymorphSpell( Mobile caster, Item scroll, int body, Type KelType ) : base( caster, scroll, m_Info ) { if (KelType != null) { BaseCreature Animal = (BaseCreature)Activator.CreateInstance(KelType); m_BonusSTR = (Animal.Str - caster.Str); m_BonusINT = (Animal.Int - caster.Int); m_BonusDEX = (Animal.Dex - caster.Dex); Animal.Delete(); } m_NewBody = body; } public PolymorphSpell( Mobile caster, Item scroll, int body ) : base( caster, scroll, m_Info ) { m_NewBody = body; } public PolymorphSpell( Mobile caster, Item scroll ) : this(caster,scroll,0) { } public override bool CheckCast() { /*if ( Caster.Mounted ) { Caster.SendLocalizedMessage( 1042561 ); //Please dismount first. return false; } else */ if ( Necromancy.TransformationSpell.UnderTransformation( Caster ) ) { Caster.SendLocalizedMessage( 1061633 ); // You cannot polymorph while in that form. return false; } else if ( DisguiseGump.IsDisguised( Caster ) ) { Caster.SendLocalizedMessage( 502167 ); // You cannot polymorph while disguised. return false; } else if ( Caster.BodyMod == 183 || Caster.BodyMod == 184 ) { Caster.SendLocalizedMessage( 1042512 ); // You cannot polymorph while wearing body paint return false; } else if ( !Caster.CanBeginAction( typeof( PolymorphSpell ) ) ) { Caster.SendLocalizedMessage( 1005559 ); // This spell is already in effect. return false; } else if ( m_NewBody == 0 ) { Caster.SendGump( new PolymorphGump( Caster, Scroll ) ); return false; } return true; } public override void OnCast() { /*if ( Caster.Mounted ) { Caster.SendLocalizedMessage( 1042561 ); //Please dismount first. } else */if ( !Caster.CanBeginAction( typeof( PolymorphSpell ) ) ) { Caster.SendLocalizedMessage( 1005559 ); // This spell is already in effect. } else if ( Necromancy.TransformationSpell.UnderTransformation( Caster ) ) { Caster.SendLocalizedMessage( 1061633 ); // You cannot polymorph while in that form. } else if ( DisguiseGump.IsDisguised( Caster ) ) { Caster.SendLocalizedMessage( 502167 ); // You cannot polymorph while disguised. } else if ( Caster.BodyMod == 183 || Caster.BodyMod == 184 ) { Caster.SendLocalizedMessage( 1042512 ); // You cannot polymorph while wearing body paint } else if ( !Caster.CanBeginAction( typeof( IncognitoSpell ) ) || Caster.IsBodyMod ) { DoFizzle(); } else if ( CheckSequence() ) { if ( Caster.BeginAction( typeof( PolymorphSpell ) ) ) { if ( m_NewBody != 0 ) { if ( !((Body)m_NewBody).IsHuman ) { Mobiles.IMount mt = Caster.Mount; if ( mt != null ) mt.Rider = null; } Caster.BodyMod = m_NewBody; if ( m_NewBody == 400 || m_NewBody == 401 ) Caster.HueMod = Utility.RandomSkinHue(); else Caster.HueMod = 0; Caster.Str += m_BonusSTR; Caster.Int += m_BonusINT; Caster.Dex += m_BonusDEX; BaseArmor.ValidateMobile( Caster ); StopTimer( Caster ); Timer t = new InternalTimer( Caster ); m_Timers[Caster] = t; t.Start(); } } else { Caster.SendLocalizedMessage( 1005559 ); // This spell is already in effect. } } FinishSequence(); } private static Hashtable m_Timers = new Hashtable(); public static bool StopTimer( Mobile m ) { Timer t = (Timer)m_Timers[m]; if ( t != null ) { t.Stop(); m_Timers.Remove( m ); } return ( t != null ); } private class InternalTimer : Timer { private Mobile m_Owner; public InternalTimer( Mobile owner ) : base( TimeSpan.FromSeconds( 0 ) ) { m_Owner = owner; int val = (int)owner.Skills[SkillName.Magery].Value; if ( val > 120 ) val = 120; Delay = TimeSpan.FromSeconds( val ); Priority = TimerPriority.OneSecond; } protected override void OnTick() { if ( !m_Owner.CanBeginAction( typeof( PolymorphSpell ) ) ) { m_Owner.BodyMod = 0; m_Owner.HueMod = -1; m_Owner.EndAction( typeof( PolymorphSpell ) ); m_Owner.Str -= m_BonusSTR; m_Owner.Int -= m_BonusINT; m_Owner.Dex -= m_BonusDEX; BaseArmor.ValidateMobile( m_Owner ); } } } } } |
| CODE |
| using System; using Server; using Server.Network; using Server.Targets; using Server.Spells; using Server.Spells.Seventh; using Server.Mobiles; namespace Server.Gumps { public class PolymorphGump : Gump { private class PolymorphEntry { private int m_Art, m_Body, m_Num; private Type m_Type; public PolymorphEntry( int Art, int Body, int LocNum, Type Keltype ) { m_Art = Art; m_Body = Body; m_Num = LocNum; m_Type = Keltype; } public int ArtID { get { return m_Art; } } public int BodyID { get { return m_Body; } } public int LocNumber{ get { return m_Num; } } public Type Type{ get { return m_Type; } } } private class PolymorphCategory { private int m_Num; private PolymorphEntry[] m_Entries; public PolymorphCategory( int num, PolymorphEntry[] entries ) { m_Num = num; m_Entries = entries; } public PolymorphEntry[] Entries{ get { return m_Entries; } } public int LocNumber{ get { return m_Num; } } } private static PolymorphCategory[] Categories = new PolymorphCategory[] { new PolymorphCategory( 1015235, new PolymorphEntry[] //Animals { new PolymorphEntry( 8401, 0xD0, 1015236, typeof( Chicken ) ),//Chicken new PolymorphEntry( 8405, 0xD9, 1015237, typeof( Dog ) ),//Dog new PolymorphEntry( 8426, 0xE1, 1015238, typeof( GreyWolf ) ),//Wolf new PolymorphEntry( 8473, 0xD6, 1015239, typeof( Panther ) ),//Panther new PolymorphEntry( 8437, 0x1D, 1015240, typeof( Gorilla ) ),//Gorilla new PolymorphEntry( 8399, 0xD3, 1015241, typeof( BlackBear ) ),//Black Bear new PolymorphEntry( 8411, 0xD4, 1015242, typeof( GrizzlyBear ) ),//Grizzly Bear new PolymorphEntry( 8417, 0xD5, 1015243, typeof( PolarBear ) ),//Polar Bear new PolymorphEntry( 8397, 0x190, 1015244, null )//Human Male } ), new PolymorphCategory( 1015245, new PolymorphEntry[] //Monsters { new PolymorphEntry( 8424, 0x33, 1015246, typeof( Slime ) ),//Slime new PolymorphEntry( 8416, 0x11, 1015247, typeof( Orc ) ),//Orc new PolymorphEntry( 8414, 0x21, 1015248, typeof( Lizardman ) ),//Lizard Man new PolymorphEntry( 8409, 0x04, 1015249, typeof( Gargoyle ) ),//Gargoyle new PolymorphEntry( 8415, 0x01, 1015250, typeof( Ogre ) ),//Ogre new PolymorphEntry( 8425, 0x36, 1015251, typeof( Troll ) ),//Troll new PolymorphEntry( 8408, 0x02, 1015252, typeof( Ettin ) ),//Ettin new PolymorphEntry( 8403, 0x09, 1015253, typeof( Daemon ) ),//Daemon new PolymorphEntry( 8398, 0x191, 1015254, null ),//Human Female } ) }; private Mobile m_Caster; private Item m_Scroll; public PolymorphGump( Mobile caster, Item scroll ) : base( 50, 50 ) { m_Caster = caster; m_Scroll = scroll; int x,y; AddPage( 0 ); AddBackground( 0, 0, 585, 393, 5054 ); AddBackground( 195, 36, 387, 275, 3000 ); AddHtmlLocalized( 0, 0, 510, 18, 1015234, false, false ); // <center>Polymorph Selection Menu</center> AddHtmlLocalized( 60, 355, 150, 18, 1011036, false, false ); // OKAY AddButton( 25, 355, 4005, 4007, 1, GumpButtonType.Reply, 1 ); AddHtmlLocalized( 320, 355, 150, 18, 1011012, false, false ); // CANCEL AddButton( 285, 355, 4005, 4007, 0, GumpButtonType.Reply, 2 ); y = 35; for ( int i=0;i<Categories.Length;i++ ) { PolymorphCategory cat = (PolymorphCategory)Categories[i]; AddHtmlLocalized( 5, y, 150, 25, cat.LocNumber, true, false ); AddButton( 155, y, 4005, 4007, 0, GumpButtonType.Page, i+1 ); y += 25; } for ( int i=0;i<Categories.Length;i++ ) { PolymorphCategory cat = (PolymorphCategory)Categories[i]; AddPage( i+1 ); for ( int c=0;c<cat.Entries.Length;c++ ) { PolymorphEntry entry = (PolymorphEntry)cat.Entries[c]; x = 198 + (c%3)*129; y = 38 + (c/3)*67; AddHtmlLocalized( x, y, 100, 18, entry.LocNumber, false, false ); AddItem( x+20, y+25, entry.ArtID ); AddRadio( x, y+20, 210, 211, false, (c<<8) + i ); } } } public override void OnResponse( NetState state, RelayInfo info ) { if ( info.ButtonID == 1 && info.Switches.Length > 0 ) { int cnum = info.Switches[0]; int cat = cnum%256; int ent = cnum>>8; if ( cat < Categories.Length ) { if ( ent < Categories[cat].Entries.Length ) { Spell spell = new PolymorphSpell( m_Caster, m_Scroll, Categories[cat].Entries[ent].BodyID, Categories[cat].Entries[ent].Type ); spell.Cast(); } } } } } } |
| QUOTE (Didi @ Jun 13 2004, 04:08 PM) |
private static int m_BonusSTR = 0; private static int m_BonusINT = 0; private static int m_BonusDEX = 0; |