public void TestStatLockInfo(StatLockType str, StatLockType intel, StatLockType dex) { var m = new Mobile(0x1); m.DefaultMobileInit(); m.StrLock = str; m.IntLock = intel; m.DexLock = dex; var expected = new StatLockInfo(m).Compile(); using var ns = PacketTestUtilities.CreateTestNetState(); ns.SendStatLockInfo(m); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }
private void AddStatLock(int x, int y, StatLockType setting, ButtonID buttonID) { if (m_Target.ControlMaster != m_User && m_User.AccessLevel < AccessLevel.GameMaster) { return; // no fooling around with wild/other people's critters! } int buttonID1, buttonID2; int xOffset, yOffset; switch (setting) { default: case StatLockType.Up: buttonID1 = 0x983; buttonID2 = 0x983; xOffset = 3; yOffset = 4; break; case StatLockType.Down: buttonID1 = 0x985; buttonID2 = 0x985; xOffset = 3; yOffset = 4; break; case StatLockType.Locked: buttonID1 = 0x82C; buttonID2 = 0x82C; xOffset = 2; yOffset = 2; break; } AddButton(x + xOffset, y + yOffset, buttonID1, buttonID2, (int)buttonID, GumpButtonType.Reply, 0); }
public static void TryStatGain(SkillInfo info, Mobile from) { // Chance roll double chance = 0.0; if (from is BaseCreature && ((BaseCreature)from).Controlled) { chance = PetChanceToGainStats; } else { chance = PlayerChanceToGainStats; } if (Utility.RandomDouble() * 100.0 >= chance) { return; } // Selection StatLockType primaryLock = StatLockType.Locked; StatLockType secondaryLock = StatLockType.Locked; switch (info.Primary) { case StatCode.Str: primaryLock = from.StrLock; break; case StatCode.Dex: primaryLock = from.DexLock; break; case StatCode.Int: primaryLock = from.IntLock; break; } switch (info.Secondary) { case StatCode.Str: secondaryLock = from.StrLock; break; case StatCode.Dex: secondaryLock = from.DexLock; break; case StatCode.Int: secondaryLock = from.IntLock; break; } // Gain // Decision block of both are selected to gain if (primaryLock == StatLockType.Up && secondaryLock == StatLockType.Up) { if (Utility.Random(4) == 0) { GainStat(from, (Stat)info.Secondary); } else { GainStat(from, (Stat)info.Primary); } } else // Will not do anything if neither are selected to gain { if (primaryLock == StatLockType.Up) { GainStat(from, (Stat)info.Primary); } else if (secondaryLock == StatLockType.Up) { GainStat(from, (Stat)info.Secondary); } } }
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; } } }
private void AddStatLock(int x, int y, StatLockType setting, ButtonID buttonID) { if (m_Target.ControlMaster != m_User && m_User.AccessLevel < AccessLevel.GameMaster) return; // no fooling around with wild/other people's critters! int buttonID1, buttonID2; int xOffset, yOffset; switch (setting) { default: case StatLockType.Up: buttonID1 = 0x983; buttonID2 = 0x983; xOffset = 3; yOffset = 4; break; case StatLockType.Down: buttonID1 = 0x985; buttonID2 = 0x985; xOffset = 3; yOffset = 4; break; case StatLockType.Locked: buttonID1 = 0x82C; buttonID2 = 0x82C; xOffset = 2; yOffset = 2; break; } AddButton(x + xOffset, y + yOffset, buttonID1, buttonID2, (int)buttonID, GumpButtonType.Reply, 0); }
public virtual void Deserialize( GenericReader reader ) { int version = reader.ReadInt(); switch ( version ) { case 36: case 35: case 34: { byte hairflag = reader.ReadByte(); if ( ( hairflag & 0x01 ) != 0 ) m_Hair = new HairInfo( reader ); if ( ( hairflag & 0x02 ) != 0 ) m_FacialHair = new FacialHairInfo( reader ); m_InstanceID = reader.ReadInt(); m_Race = reader.ReadRace(); if ( version < 36 ) reader.ReadDeltaTime(); m_TithingPoints = reader.ReadInt(); m_Corpse = reader.ReadItem() as Container; m_CreationTime = reader.ReadDateTime(); m_Stabled = reader.ReadStrongMobileList(); m_CantWalk = reader.ReadBool(); m_Virtues = new VirtueInfo( reader ); m_Thirst = reader.ReadInt(); m_BAC = reader.ReadInt(); m_ShortTermMurders = reader.ReadInt(); if ( version < 35 ) reader.ReadInt(); m_MagicDamageAbsorb = reader.ReadInt(); m_GuildFealty = reader.ReadMobile(); m_Guild = reader.ReadGuild(); m_DisplayGuildTitle = reader.ReadBool(); m_CanSwim = reader.ReadBool(); m_Squelched = reader.ReadBool(); m_Holding = reader.ReadItem(); m_BaseSoundID = reader.ReadInt(); m_DisarmReady = reader.ReadBool(); m_StunReady = reader.ReadBool(); m_StatCap = reader.ReadInt(); m_NameHue = reader.ReadInt(); m_Hunger = reader.ReadInt(); 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_EquippedItems = new List<Item>( itemCount ); for ( int i = 0; i < itemCount; ++i ) { Item item = reader.ReadItem(); if ( item != null ) m_EquippedItems.Add( item ); } m_IsPlayer = reader.ReadBool(); m_Title = reader.ReadString(); if ( m_Title != null ) m_Title = string.Intern( m_Title ); m_Profile = reader.ReadString(); m_ProfileLocked = reader.ReadBool(); 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 List<StatMod>(); 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_IsPlayer && 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(); UpdateRegion(); UpdateResistances(); break; } } }
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)); } }