public virtual void SetLocation( Point3D newLocation, bool isTeleport ) { if ( m_Deleted ) return; Point3D oldLocation = m_Location; Region oldRegion = m_Region; if ( oldLocation != newLocation ) { m_Location = newLocation; BankBox box = FindBankNoCreate(); if ( box != null && box.Opened ) box.Close(); if ( m_NetState != null ) m_NetState.ValidateAllTrades(); if ( m_Map != null ) m_Map.OnMove( oldLocation, this ); if ( isTeleport && m_NetState != null ) { m_NetState.Sequence = 0; m_NetState.Send( new MobileUpdate( this ) ); ClearFastwalkStack(); } Map map = m_Map; if ( map != null ) { // First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange) Packet removeThis = null; IPooledEnumerable eable = map.GetClientsInRange( oldLocation ); foreach ( NetState ns in eable ) { if ( ns != m_NetState && !Utility.InUpdateRange( newLocation, ns.Mobile.Location ) ) { if ( removeThis == null ) removeThis = this.RemovePacket; ns.Send( removeThis ); } } eable.Free(); NetState ourState = m_NetState; // Check to see if we are attached to a client if ( ourState != null ) { eable = map.GetObjectsInRange( newLocation, Core.GlobalMaxUpdateRange ); // We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients foreach ( object o in eable ) { if ( o is Item ) { Item item = (Item)o; int range = item.GetUpdateRange( this ); Point3D loc = item.Location; if ( !Utility.InRange( oldLocation, loc, range ) && Utility.InRange( newLocation, loc, range ) && CanSee( item ) ) item.SendInfoTo( ourState ); } else if ( o != this && o is Mobile ) { Mobile m = (Mobile)o; if ( !Utility.InUpdateRange( newLocation, m.m_Location ) ) continue; bool inOldRange = Utility.InUpdateRange( oldLocation, m.m_Location ); if ( (isTeleport || !inOldRange) && m.m_NetState != null && m.CanSee( this ) ) { m.m_NetState.Send( new MobileIncoming( m, this ) ); if ( IsDeadBondedPet ) m.m_NetState.Send( new BondedStatus( 0, m_Serial, 1 ) ); if ( ObjectPropertyList.Enabled ) { m.m_NetState.Send( OPLPacket ); //foreach ( Item item in m_Items ) // m.m_NetState.Send( item.OPLPacket ); } } if ( !inOldRange && CanSee( m ) ) { ourState.Send( new MobileIncoming( this, m ) ); if ( m.IsDeadBondedPet ) ourState.Send( new BondedStatus( 0, m.m_Serial, 1 ) ); if ( ObjectPropertyList.Enabled ) { ourState.Send( m.OPLPacket ); //foreach ( Item item in m.m_Items ) // ourState.Send( item.OPLPacket ); } } } } eable.Free(); } else { eable = map.GetClientsInRange( newLocation ); // We're not attached to a client, so simply send an Incoming foreach ( NetState ns in eable ) { if ( (isTeleport || !Utility.InUpdateRange( oldLocation, ns.Mobile.Location )) && ns.Mobile.CanSee( this ) ) { ns.Send( new MobileIncoming( ns.Mobile, this ) ); if ( IsDeadBondedPet ) ns.Send( new BondedStatus( 0, m_Serial, 1 ) ); if ( ObjectPropertyList.Enabled ) { ns.Send( OPLPacket ); //foreach ( Item item in m_Items ) // ns.Send( item.OPLPacket ); } } } eable.Free(); } } m_Region = Region.Find( m_Location, m_Map ); if ( oldRegion != m_Region ) { oldRegion.InternalExit( this ); m_Region.InternalEnter( this ); OnRegionChange( oldRegion, m_Region ); } OnLocationChange( oldLocation ); CheckLightLevels( false ); m_Region.OnLocationChanged( this, oldLocation ); } }
public virtual void MoveToWorld( Point3D newLocation, Map map ) { if ( m_Map == map ) { SetLocation( newLocation, true ); return; } BankBox box = FindBankNoCreate(); if ( box != null && box.Opened ) box.Close(); Point3D oldLocation = m_Location; Map oldMap = m_Map; Region oldRegion = m_Region; if ( oldMap != null ) { oldMap.OnLeave( this ); ClearScreen(); SendRemovePacket(); } for ( int i = 0; i < m_Items.Count; ++i ) ((Item)m_Items[i]).Map = map; m_Map = map; m_Region.InternalExit( this ); m_Location = newLocation; NetState ns = m_NetState; if ( m_Map != null ) { m_Map.OnEnter( this ); m_Region = Region.Find( m_Location, m_Map ); OnRegionChange( oldRegion, m_Region ); m_Region.InternalEnter( this ); if ( ns != null && m_Map != null ) { ns.Sequence = 0; ns.Send( new MapChange( this ) ); ns.Send( new MapPatches() ); ns.Send( SeasonChange.Instantiate( GetSeason(), true ) ); ns.Send( new MobileUpdate( this ) ); ClearFastwalkStack(); } } if ( ns != null ) { if ( m_Map != null ) Send( new ServerChange( this, m_Map ) ); ns.Sequence = 0; ClearFastwalkStack(); Send( new MobileIncoming( this, this ) ); Send( new MobileUpdate( this ) ); CheckLightLevels( true ); Send( new MobileUpdate( this ) ); } SendEverything(); SendIncomingPacket(); if ( ns != null ) { m_NetState.Sequence = 0; ClearFastwalkStack(); Send( new MobileIncoming( this, this ) ); Send( SupportedFeatures.Instantiate( ns.Account ) ); Send( new MobileUpdate( this ) ); Send( new MobileAttributes( this ) ); } OnMapChange( oldMap ); OnLocationChange( oldLocation ); m_Region.OnLocationChanged( this, oldLocation ); }
public virtual void Deserialize( GenericReader reader ) { int version = reader.ReadInt(); switch ( version ) { case 28: { m_LastStatGain = reader.ReadDeltaTime(); goto case 27; } case 27: { m_TithingPoints = reader.ReadInt(); goto case 26; } case 26: case 25: case 24: { m_Corpse = reader.ReadItem() as Container; goto case 23; } case 23: { m_CreationTime = reader.ReadDateTime(); goto case 22; } case 22: // Just removed followers case 21: { m_Stabled = reader.ReadMobileListOrNull(); goto case 20; } case 20: { m_CantWalk = reader.ReadBool(); goto case 19; } case 19: // Just removed variables case 18: { m_Virtues = VirtueInfo.Deserialize( reader ); goto case 17; } case 17: { m_Thirst = reader.ReadInt(); m_BAC = reader.ReadInt(); goto case 16; } case 16: { m_ShortTermMurders = reader.ReadInt(); if ( version <= 24 ) { reader.ReadDateTime(); reader.ReadDateTime(); } goto case 15; } case 15: { if ( version < 22 ) reader.ReadInt(); // followers m_FollowersMax = reader.ReadInt(); goto case 14; } case 14: { m_MagicDamageAbsorb = reader.ReadInt(); goto case 13; } case 13: { m_GuildFealty = reader.ReadMobile(); goto case 12; } case 12: { m_Guild = reader.ReadGuild(); goto case 11; } case 11: { m_DisplayGuildTitle = reader.ReadBool(); goto case 10; } case 10: { m_CanSwim = reader.ReadBool(); goto case 9; } case 9: { m_Squelched = reader.ReadBool(); goto case 8; } case 8: { m_Holding = reader.ReadItem(); goto case 7; } case 7: { m_VirtualArmor = reader.ReadInt(); goto case 6; } case 6: { m_BaseSoundID = reader.ReadInt(); goto case 5; } case 5: { m_DisarmReady = reader.ReadBool(); m_StunReady = reader.ReadBool(); goto case 4; } case 4: { if ( version <= 25 ) { Poison.Deserialize( reader ); /*if ( m_Poison != null ) { m_PoisonTimer = new PoisonTimer( this ); m_PoisonTimer.Start(); }*/ } goto case 3; } case 3: { m_StatCap = reader.ReadInt(); goto case 2; } case 2: { m_NameHue = reader.ReadInt(); goto case 1; } case 1: { m_Hunger = reader.ReadInt(); goto case 0; } case 0: { if ( version < 11 ) m_DisplayGuildTitle = true; if ( version < 3 ) m_StatCap = 225; if ( version < 15 ) { m_Followers = 0; m_FollowersMax = 5; } m_Location = reader.ReadPoint3D(); m_Body = new Body( reader.ReadInt() ); m_Name = reader.ReadString(); if (m_Name != null) m_Name = string.Intern(m_Name); m_GuildTitle = reader.ReadString(); m_Criminal = reader.ReadBool(); m_Kills = reader.ReadInt(); m_SpeechHue = reader.ReadInt(); m_EmoteHue = reader.ReadInt(); m_WhisperHue = reader.ReadInt(); m_YellHue = reader.ReadInt(); m_Language = reader.ReadString(); if (m_Language != null) m_Language = string.Intern(m_Language); m_Female = reader.ReadBool(); m_Warmode = reader.ReadBool(); m_Hidden = reader.ReadBool(); m_Direction = (Direction) reader.ReadByte(); m_Hue = reader.ReadInt(); m_Str = reader.ReadInt(); m_Dex = reader.ReadInt(); m_Int = reader.ReadInt(); m_Hits = reader.ReadInt(); m_Stam = reader.ReadInt(); m_Mana = reader.ReadInt(); m_Map = reader.ReadMap(); m_Blessed = reader.ReadBool(); m_Fame = reader.ReadInt(); m_Karma = reader.ReadInt(); m_AccessLevel = (AccessLevel) reader.ReadByte(); m_Skills = new Skills( this, reader ); int itemCount = reader.ReadInt(); m_Items = new ArrayList( itemCount ); for ( int i = 0; i < itemCount; ++i ) { Item item = reader.ReadItem(); if ( item != null ) m_Items.Add( item ); } m_Player = reader.ReadBool(); m_Title = reader.ReadString(); if (m_Title != null) m_Title = string.Intern(m_Title); m_Profile = reader.ReadString(); m_ProfileLocked = reader.ReadBool(); if ( version <= 18 ) { /*m_LightLevel =*/ reader.ReadInt(); /*m_TotalGold =*/ reader.ReadInt(); /*m_TotalWeight =*/ reader.ReadInt(); } m_AutoPageNotify = reader.ReadBool(); m_LogoutLocation = reader.ReadPoint3D(); m_LogoutMap = reader.ReadMap(); m_StrLock = (StatLockType)reader.ReadByte(); m_DexLock = (StatLockType)reader.ReadByte(); m_IntLock = (StatLockType)reader.ReadByte(); if ( reader.ReadBool() ) { m_StuckMenuUses = new DateTime[reader.ReadInt()]; for ( int i = 0; i < m_StuckMenuUses.Length; ++i ) { m_StuckMenuUses[i] = reader.ReadDateTime(); } } else { m_StuckMenuUses = null; } if ( m_Player && m_Map != Map.Internal ) { m_LogoutLocation = m_Location; m_LogoutMap = m_Map; m_Map = Map.Internal; } if ( m_Map != null ) m_Map.OnEnter( this ); if ( m_Criminal ) { if ( m_ExpireCriminal == null ) m_ExpireCriminal = new ExpireCriminalTimer( this ); m_ExpireCriminal.Start(); } if ( ShouldCheckStatTimers ) CheckStatTimers(); if ( !m_Player && m_Dex <= 100 && m_CombatTimer != null ) m_CombatTimer.Priority = TimerPriority.FiftyMS; else if ( m_CombatTimer != null ) m_CombatTimer.Priority = TimerPriority.EveryTick; m_Region = Region.Find( m_Location, m_Map ); m_Region.InternalEnter( this ); UpdateResistances(); break; } } }
public void ForceRegionReEnter( bool Exit ) { //forces to find the region again and enter it if ( m_Deleted ) return; Region n = Region.Find( m_Location, m_Map ); if ( n != m_Region ) { if ( Exit ) m_Region.InternalExit( this ); m_Region = n; OnRegionChange( n, m_Region ); m_Region.InternalEnter( this ); CheckLightLevels( false ); } }
public virtual void Deserialize(GenericReader reader) { int version = reader.ReadInt(); switch (version) { case 31: { m_STRBonusCap = reader.ReadInt(); goto case 30; } case 30: { int size = reader.ReadInt32(); FlyIDs = new int[size]; for (int i = 0; i < size; i++) { FlyIDs[i] = reader.ReadInt(); } goto case 29; } case 29: { m_CanFly = reader.ReadBool(); goto case 28; } case 28: { m_LastStatGain = reader.ReadDeltaTime(); goto case 27; } case 27: { m_Flags = (MobileFlags)reader.ReadInt32(); goto case 26; } case 26: case 25: case 24: { m_Corpse = reader.ReadItem() as Container; goto case 23; } case 23: { m_CreationTime = reader.ReadDateTime(); goto case 22; } case 22: // Just removed followers case 21: { m_Stabled = reader.ReadMobileList(); goto case 20; } case 20: { m_CantWalk = reader.ReadBool(); goto case 19; } case 19: // Just removed variables case 18: { m_Virtues = new VirtueInfo(reader); goto case 17; } case 17: { m_Thirst = reader.ReadInt32(); m_BAC = reader.ReadInt32(); goto case 16; } case 16: { m_ShortTermMurders = reader.ReadInt32(); if (version <= 24) { reader.ReadDateTime(); reader.ReadDateTime(); } goto case 15; } case 15: { if (version < 22) reader.ReadInt(); // followers m_FollowersMax = reader.ReadInt32(); goto case 14; } case 14: { m_MagicDamageAbsorb = reader.ReadInt32(); goto case 13; } case 13: { m_GuildFealty = reader.ReadMobile(); goto case 12; } case 12: { m_Guild = reader.ReadGuild(); goto case 11; } case 11: { m_DisplayGuildTitle = reader.ReadBool(); goto case 10; } case 10: { m_CanSwim = reader.ReadBool(); goto case 9; } case 9: { m_Squelched = reader.ReadBool(); goto case 8; } case 8: { m_Holding = reader.ReadItem(); goto case 7; } case 7: { m_VirtualArmor = reader.ReadInt32(); goto case 6; } case 6: { m_BaseSoundID = reader.ReadInt32(); goto case 5; } case 5: { m_DisarmReady = reader.ReadBool(); m_StunReady = reader.ReadBool(); goto case 4; } case 4: { if (version <= 25) { Poison.Deserialize(reader); /*if ( m_Poison != null ) { m_PoisonTimer = new PoisonTimer( this ); m_PoisonTimer.Start(); }*/ } goto case 3; } case 3: { m_StatCap = reader.ReadInt32(); goto case 2; } case 2: { m_NameHue = reader.ReadInt32(); goto case 1; } case 1: { m_Hunger = reader.ReadInt32(); goto case 0; } case 0: { if (version < 21) m_Stabled = new ArrayList(); if (version < 18) m_Virtues = new VirtueInfo(); if (version < 11) m_DisplayGuildTitle = true; if (version < 3) m_StatCap = 225; if (version < 15) { m_Followers = 0; m_FollowersMax = 5; } m_Location = reader.ReadPoint3D(); m_Body = new Body(reader.ReadInt32()); m_Name = reader.ReadString(); m_GuildTitle = reader.ReadString(); m_Criminal = reader.ReadBool(); m_Kills = reader.ReadInt32(); m_SpeechHue = reader.ReadInt32(); m_EmoteHue = reader.ReadInt32(); m_WhisperHue = reader.ReadInt32(); m_YellHue = reader.ReadInt32(); m_Language = reader.ReadString(); m_Female = reader.ReadBool(); m_Warmode = reader.ReadBool(); m_Hidden = reader.ReadBool(); m_Direction = (Direction)reader.ReadByte(); m_Hue = reader.ReadInt32(); m_Str = reader.ReadInt32(); m_Dex = reader.ReadInt32(); m_Int = reader.ReadInt32(); m_Hits = reader.ReadInt32(); m_Stam = reader.ReadInt32(); m_Mana = reader.ReadInt32(); m_Map = reader.ReadMap(); m_Blessed = reader.ReadBool(); m_Fame = reader.ReadInt32(); m_Karma = reader.ReadInt32(); m_AccessLevel = (AccessLevel)reader.ReadByte(); // Convert old bonus caps to 'no cap' if (version < 31) m_STRBonusCap = 0; // Convert old access levels to new access levels if (version < 31) { switch (m_AccessLevel) { case (AccessLevel)0: //OldPlayer = 0, { m_AccessLevel = AccessLevel.Player; break; } case (AccessLevel)1: //OldCounselor = 1, { m_AccessLevel = AccessLevel.Counselor; break; } case (AccessLevel)2: //OldGameMaster = 2, { m_AccessLevel = AccessLevel.GameMaster; break; } case (AccessLevel)3: //OldSeer = 3, { m_AccessLevel = AccessLevel.Seer; break; } case (AccessLevel)4: //OldAdministrator = 4, { m_AccessLevel = AccessLevel.Administrator; break; } } } m_Skills = new Skills(this, reader); int itemCount = reader.ReadInt32(); m_Items = new ArrayList(itemCount); for (int i = 0; i < itemCount; ++i) { Item item = reader.ReadItem(); if (item != null) m_Items.Add(item); } m_Player = reader.ReadBool(); m_Title = reader.ReadString(); m_Profile = reader.ReadString(); m_ProfileLocked = reader.ReadBool(); if (version <= 18) { /*m_LightLevel =*/ reader.ReadInt(); /*m_TotalGold =*/ reader.ReadInt(); /*m_TotalWeight =*/ reader.ReadInt(); } m_AutoPageNotify = reader.ReadBool(); m_LogoutLocation = reader.ReadPoint3D(); m_LogoutMap = reader.ReadMap(); m_StrLock = (StatLockType)reader.ReadByte(); m_DexLock = (StatLockType)reader.ReadByte(); m_IntLock = (StatLockType)reader.ReadByte(); m_StatMods = new ArrayList(); if (reader.ReadBool()) { m_StuckMenuUses = new DateTime[reader.ReadInt32()]; for (int i = 0; i < m_StuckMenuUses.Length; ++i) { m_StuckMenuUses[i] = reader.ReadDateTime(); } } else { m_StuckMenuUses = null; } if (m_Player && m_Map != Map.Internal) { m_LogoutLocation = m_Location; m_LogoutMap = m_Map; m_Map = Map.Internal; } if (m_Map != null) m_Map.OnEnter(this); if (m_Criminal) { if (m_ExpireCriminal == null) m_ExpireCriminal = new ExpireCriminalTimer(this); m_ExpireCriminal.Start(); } if (ShouldCheckStatTimers) CheckStatTimers(); if (!m_Player && m_Dex <= 100 && m_CombatTimer != null) m_CombatTimer.Priority = TimerPriority.FiftyMS; else if (m_CombatTimer != null) m_CombatTimer.Priority = TimerPriority.EveryTick; m_Region = Region.Find(m_Location, m_Map); m_Region.InternalEnter(this); //UpdateResistances(); break; } } //Pix: special logic to ensure the DefensiveSpell lock in m_Actions exists if it should //Note protection is a different beast since there are timers that control // BeginAction/EndAction -- protection effects aren't serialized. if (MagicDamageAbsorb > 0 || MeleeDamageAbsorb > 0) { BeginAction(typeof(DefensiveSpell)); } }