Beispiel #1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            //Version 0
            if (version >= 0)
            {
                m_PlayerMobile = (PlayerMobile)reader.ReadMobile();

                m_GrimoirePage       = (GrimoirePage)reader.ReadInt();
                m_BossPageNumber     = reader.ReadInt();
                m_ChampionPageNumber = reader.ReadInt();
                m_LoHBossPageNumber  = reader.ReadInt();
                m_RarePageNumber     = reader.ReadInt();
                m_ParagonPageNumber  = reader.ReadInt();

                m_TotalPointsEarned = reader.ReadInt();
                m_AvailablePoints   = reader.ReadInt();

                int creatureEntriesCount = reader.ReadInt();
                for (int a = 0; a < creatureEntriesCount; a++)
                {
                    Type         creatureType = Type.GetType(reader.ReadString());
                    MHSGroupType groupType    = (MHSGroupType)reader.ReadInt();
                    int          timesKilled  = reader.ReadInt();
                    DateTime     lastKilled   = reader.ReadDateTime();

                    MHSCreaturePlayerEntry creaturePlayerEntry = new MHSCreaturePlayerEntry(creatureType, groupType);
                    creaturePlayerEntry.m_TimesKilled = timesKilled;
                    creaturePlayerEntry.m_LastKilled  = lastKilled;

                    int taskCount = reader.ReadInt();
                    for (int b = 0; b < taskCount; b++)
                    {
                        MHSTaskType taskType       = (MHSTaskType)reader.ReadInt();
                        int         timesCompleted = reader.ReadInt();
                        DateTime    lastCompleted  = reader.ReadDateTime();

                        MHSCreatureTaskPlayerEntry taskEntry = new MHSCreatureTaskPlayerEntry(taskType);
                        taskEntry.m_TimesCompleted    = timesCompleted;
                        taskEntry.m_LastTimeCompleted = lastCompleted;

                        creaturePlayerEntry.m_Tasks.Add(taskEntry);
                    }

                    m_CreatureEntries.Add(creaturePlayerEntry);
                }
            }

            //---------

            MHSPersistance.m_PlayerEntries.Add(this);
        }
Beispiel #2
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); //Version

            //Version 0
            writer.Write(m_PlayerMobile);

            writer.Write((int)m_GrimoirePage);
            writer.Write(m_BossPageNumber);
            writer.Write(m_ChampionPageNumber);
            writer.Write(m_LoHBossPageNumber);
            writer.Write(m_RarePageNumber);
            writer.Write(m_ParagonPageNumber);

            writer.Write(m_TotalPointsEarned);
            writer.Write(m_AvailablePoints);

            writer.Write(m_CreatureEntries.Count);
            for (int a = 0; a < m_CreatureEntries.Count; a++)
            {
                MHSCreaturePlayerEntry creatureEntry = m_CreatureEntries[a];

                writer.Write((string)creatureEntry.m_CreatureType.ToString());
                writer.Write((int)creatureEntry.m_GroupType);
                writer.Write(creatureEntry.m_TimesKilled);
                writer.Write(creatureEntry.m_LastKilled);

                writer.Write(creatureEntry.m_Tasks.Count);
                for (int b = 0; b < creatureEntry.m_Tasks.Count; b++)
                {
                    MHSCreatureTaskPlayerEntry taskEntry = creatureEntry.m_Tasks[b];

                    writer.Write((int)taskEntry.m_TaskType);
                    writer.Write(taskEntry.m_TimesCompleted);
                    writer.Write(taskEntry.m_LastTimeCompleted);
                }
            }
        }
Beispiel #3
0
        public static void ResolveCreatureKilled(MHSGroupType groupType, BaseCreature creature, PlayerMobile player, double damagePercent, bool takenPoisonDamage, bool takenCreatureDamage)
        {
            List <MHSCreatureTask> creatureTasks       = MHSCreatures.GetCreatureTasks(groupType);
            MHSCreaturePlayerEntry creaturePlayerEntry = MHSCreatures.GetCreaturePlayerEntry(player, groupType, creature.GetType());

            MHSCreatureTaskPlayerEntry bestValidTask = null;
            int highestTaskPoints = 0;

            int creatureIndex = -1;
            int taskIndex     = -1;

            foreach (MHSCreatureTask creatureTask in creatureTasks)
            {
                bool taskSuccessful = false;

                switch (creatureTask.m_TaskType)
                {
                case MHSTaskType.Damage5PercentOfTotal:
                    if (damagePercent >= .05)
                    {
                        taskSuccessful = true;
                    }
                    break;

                case MHSTaskType.Damage5PercentOfTotalNoPoisonOrCreatureDamage:
                    if (damagePercent >= .05 && !takenPoisonDamage && !takenCreatureDamage)
                    {
                        taskSuccessful = true;
                    }
                    break;

                case MHSTaskType.Damage33PercentOfTotal:
                    if (damagePercent >= .33)
                    {
                        taskSuccessful = true;
                    }
                    break;

                case MHSTaskType.Damage33PercentOfTotalNoPoisonOrCreatureDamage:
                    if (damagePercent >= .33 && !takenPoisonDamage && !takenCreatureDamage)
                    {
                        taskSuccessful = true;
                    }
                    break;

                case MHSTaskType.Damage66PercentOfTotal:
                    if (damagePercent >= .66)
                    {
                        taskSuccessful = true;
                    }
                    break;

                case MHSTaskType.Damage66PercentOfTotalNoPoisonOrCreatureDamage:
                    if (damagePercent >= .66 && !takenPoisonDamage && !takenCreatureDamage)
                    {
                        taskSuccessful = true;
                    }
                    break;

                case MHSTaskType.Damage95PercentOfTotal:
                    if (damagePercent >= .95)
                    {
                        taskSuccessful = true;
                    }
                    break;

                case MHSTaskType.Damage95PercentOfTotalNoPoisonOrCreatureDamage:
                    if (damagePercent >= .95 && !takenPoisonDamage && !takenCreatureDamage)
                    {
                        taskSuccessful = true;
                    }
                    break;
                }

                if (!taskSuccessful)
                {
                    continue;
                }

                MHSCreatureTaskPlayerEntry playerTaskEntry = null;

                int index = 0;

                for (int a = 0; a < creaturePlayerEntry.m_Tasks.Count; a++)
                {
                    if (creatureTask.m_TaskType == creaturePlayerEntry.m_Tasks[a].m_TaskType)
                    {
                        playerTaskEntry = creaturePlayerEntry.m_Tasks[a];

                        break;
                    }
                }

                if (playerTaskEntry == null)
                {
                    playerTaskEntry = new MHSCreatureTaskPlayerEntry(creatureTask.m_TaskType);
                    creaturePlayerEntry.m_Tasks.Add(playerTaskEntry);

                    index = creaturePlayerEntry.m_Tasks.Count - 1;
                }

                if (playerTaskEntry.m_TimesCompleted > 0 && !creatureTask.m_Repeatable)
                {
                    continue;
                }

                if (creatureTask.m_PointsGranted > highestTaskPoints)
                {
                    highestTaskPoints = creatureTask.m_PointsGranted;
                    bestValidTask     = playerTaskEntry;
                }
            }

            if (highestTaskPoints > 0 && bestValidTask != null)
            {
                creaturePlayerEntry.m_TimesKilled++;
                creaturePlayerEntry.m_LastKilled = DateTime.UtcNow;

                bestValidTask.m_TimesCompleted++;
                bestValidTask.m_LastTimeCompleted = DateTime.UtcNow;

                player.m_MHSPlayerEntry.m_AvailablePoints   += highestTaskPoints;
                player.m_MHSPlayerEntry.m_TotalPointsEarned += highestTaskPoints;

                MHSCreatureDetail creatureDetail = MHSCreatures.GetCreatureDetail(groupType, creature.GetType());

                string   creatureName    = creatureDetail.m_Name;
                string   groupName       = MHSCreatures.GetGroupTypeName(groupType);
                string[] taskDescription = MHSCreatures.GetTaskDescription(bestValidTask.m_TaskType);
                string   taskName        = "";

                int textHue = GetGroupTypeTextHue(groupType);

                for (int a = 0; a < taskDescription.Length; a++)
                {
                    taskName += taskDescription[a];

                    if (a != taskDescription.Length - 1)
                    {
                        taskName += " ";
                    }
                }

                string message = "You have earned " + highestTaskPoints.ToString() + " points in the Monster Hunter's Society for the task of: " + creatureName + " [" + groupName + "]" + " - " + taskName + ".";

                player.SendMessage(textHue, message);

                player.FixedEffect(0x373A, 10, 30, 0, 0);
                player.PlaySound(0x5A7);
            }
        }