using System; using System.IO; using System.Reflection; using System.Collections; using System.Collections.Generic; using Server; using Server.Commands; using Server.Network; using Server.Items; using Server.Spells; using Server.Mobiles; using Server.Gumps; using Server.Menus.Questions; using Server.Engines.Event; using Server.Spells.Eighth; using Server.Spells.Sixth; using Server.Spells.Fourth; using Server.Spells.Seventh; using Server.Spells.Third; namespace Server.Regions { public class PvpSpectatorRegion : BaseRegion { PvpEvent m_Event; public PvpSpectatorRegion( PvpEvent e, Map map, params Rectangle3D[] area ) : base( e.Name + " spectators", map, DefaultPriority, area ) { //LoadFromXml = false; //Priority = Region.HighestPriority; //Coords = new ArrayList(); //Coords.Add(coords); m_Event = e; Region.AddRegion(this); } public void Clean() { m_Event = null; Region.RemoveRegion(this); } public override bool AllowBeneficial( Mobile from, Mobile target ){return from == target;} public override bool AllowHarmful( Mobile from, Mobile target ){return false;} public override bool AllowHousing( Mobile from, Point3D p ){return false;} public override bool AllowSpawn(){return true;} public override bool CanUseStuckMenu( Mobile m ){return false;} public override bool OnDamage( Mobile m, ref int Damage ) { m.SendMessage( "You cannot be damaged here." ); return false; } public override bool OnBeginSpellCast( Mobile from, ISpell s ) { if ( from.AccessLevel == AccessLevel.Player ) { Spell spell = s as Spell; if ( ((Spell)s).Info.Name == "Ethereal Mount" && !m_Event.Requirements.AllowMounts ) { from.SendMessage( "You cannot mount your ethereal here." ); return false; } else { from.SendMessage( "You cannot cast spells in the spectator area."); return false; } } return true; } public override bool OnHeal( Mobile m, ref int Heal ) { return true; //Users can always heal in the spectator area } public override bool OnSkillUse( Mobile m, int skill ) { bool restricted = false; switch(skill) { case (int)SkillName.Peacemaking: case (int)SkillName.Hiding: case (int)SkillName.Stealing: case (int)SkillName.Snooping: case (int)SkillName.Musicianship: restricted = true; break; case (int)SkillName.Healing: restricted = false; //Users can heal in spectator area break; } if ( restricted && m.AccessLevel == AccessLevel.Player ) { m.SendMessage( "You cannot use that skill here." ); return false; } return base.OnSkillUse( m, skill ); } public override void OnExit( Mobile m ) { base.OnExit( m ); } public override void OnEnter( Mobile m ) { base.OnEnter( m ); } public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation ) { return true; } public override TimeSpan GetLogoutDelay( Mobile m ) { return TimeSpan.Zero; } public override bool OnDoubleClick( Mobile m, object o ) { if( o is Corpse ) { Corpse c = (Corpse)o; return c.Owner == m; } if(o is StrongBackpack && RealmPlayer.FindOwner((Item) o) != m && m.AccessLevel == AccessLevel.Player) { m.SendMessage("You cannot snoop animals here."); return false; } return base.OnDoubleClick( m, o ); } } public class PvpFighterRegion : BaseRegion { PvpEvent m_Event; public PvpFighterRegion( PvpEvent e, Map map, Rectangle2D coords ) : base( "", e.Name + " fighters", map ) { LoadFromXml = false; Priority = 0x96; Coords = new ArrayList(); Coords.Add(coords); m_Event = e; Region.AddRegion(this); } public void Clean() { m_Event = null; Region.RemoveRegion(this); } public override bool AllowBeneficial( Mobile from, Mobile target ) { return ((from == target) || m_Event.SameTeam(from, target)); } public override bool AllowHarmful( Mobile from, Mobile target ) { return !m_Event.SameTeam(from, target); } public override bool AllowHousing( Mobile from, Point3D p ){return false;} public override bool AllowSpawn(){return true;} public override bool CanUseStuckMenu( Mobile m ){return false;} public override bool OnDeath( Mobile m ) { m_Event.MobileDied(m); return false; } public override bool OnDamage( Mobile m, ref int Damage ) { return true; } public override bool OnBeginSpellCast( Mobile from, ISpell s ) { if ( from.AccessLevel == AccessLevel.Player ) { if(m_Event.Status != PvpEventStatus.MatchInProgress) return false; Spell spell = s as Spell; if ( spell is EnergyVortexSpell || spell is AirElementalSpell || spell is WaterElementalSpell || spell is FireElementalSpell || spell is EarthElementalSpell || spell is SummonDaemonSpell || spell is RecallSpell || spell is MarkSpell || spell is TeleportSpell || spell is InvisibilitySpell || spell is GateTravelSpell) { from.SendMessage( "You cannot cast that spell here." ); return false; } if( m_Event.EventStyle == PvpEventStyle.Caveman || m_Event.EventStyle == PvpEventStyle.Wrestling ) { from.SendMessage("You cannot cast spells in this style of PvP event."); return false; } if ( ((Spell)s).Info.Name == "Ethereal Mount" && !m_Event.Requirements.AllowMounts ) { from.SendMessage( "You cannot mount your ethereal here." ); return false; } } foreach(Item i in new ArrayList(from.Items)) { if(i is BaseWeapon && ((BaseWeapon)i).Attributes.SpellChanneling == 0 && from.Backpack != null && ((Spell)s).ClearHandsOnCast) from.Backpack.DropItem(i); } return true; } public override bool OnHeal( Mobile m, ref int Heal ) { return m_Event.Status == PvpEventStatus.MatchInProgress; } public override bool OnSkillUse( Mobile m, int skill ) { bool restricted = false; switch(skill) { case (int)SkillName.Peacemaking: case (int)SkillName.Hiding: case (int)SkillName.Stealing: case (int)SkillName.Snooping: case (int)SkillName.Musicianship: restricted = true; break; case (int)SkillName.Healing: restricted = (m_Event.Status != PvpEventStatus.MatchInProgress); break; } if ( restricted && m.AccessLevel == AccessLevel.Player ) { m.SendMessage( "You cannot use that skill here." ); return false; } return base.OnSkillUse( m, skill ); } public override void OnExit( Mobile m ) { base.OnExit( m ); } public override void OnEnter( Mobile m ) { base.OnEnter( m ); } public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation ) { if(m.AccessLevel == AccessLevel.Player) { if( !this.Contains( oldLocation ) && m_Event != null ) { return(m_Event.CanMoveIntoArena(m)); } /*else { if(m_Event.EventStyle == PvpEventStyle.MageDuel) { m.SendMessage("You cannot move in a pure mage duel."); return false; } }*/ } return true; } public override TimeSpan GetLogoutDelay( Mobile m ) { return TimeSpan.Zero; } public override bool OnDoubleClick( Mobile m, object o ) { if( m_Event.Status != PvpEventStatus.MatchInProgress) return false; if( o is BasePotion && !m_Event.AllowPotions ) { m.SendMessage( "You cannot drink potions here." ); return false; } if( o is Corpse ) { Corpse c = (Corpse)o; return c.Owner == m; } if(o is StrongBackpack && RealmPlayer.FindOwner((Item) o) != m && m.AccessLevel == AccessLevel.Player) { m.SendMessage("You cannot snoop animals here."); return false; } return base.OnDoubleClick( m, o ); } } }