예제 #1
0
        public static void CharacterStatsListMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            CharacterStatsListMessage msg = (CharacterStatsListMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (!account.ConfigManager.Restored)
            {
                account.ConfigManager.RecoverConfig();
            }
            account.CharacterStats = msg.stats;
            account.CaracUC.Init();
            if (account.MyGroup != null)
            {
                ((GroupForm)account.ParentForm).AddMember(account.CharacterBaseInformations.name);
            }
            int    percent = (msg.stats.lifePoints / msg.stats.maxLifePoints) * 100;
            string text    = msg.stats.lifePoints + "/" + msg.stats.maxLifePoints + "(" + percent + "%)";

            account.ModifBar(2, (int)msg.stats.maxLifePoints, (int)msg.stats.lifePoints, "Vitalité");
            double i = msg.stats.experience - msg.stats.experienceLevelFloor;
            double j = msg.stats.experienceNextLevelFloor - msg.stats.experienceLevelFloor;

            try
            {
                int xppercent = (int)(Math.Round(i / j, 2) * 100);
            }
            catch (Exception ex)
            {
            }
            account.ModifBar(1, (int)msg.stats.experienceNextLevelFloor - (int)msg.stats.experienceLevelFloor, (int)msg.stats.experience - (int)msg.stats.experienceLevelFloor, "Experience");
            account.ModifBar(4, 0, 0, msg.stats.kamas.ToString());
        }
예제 #2
0
        /// <summary>
        /// Actualize and display the new location.
        /// </summary>
        public void ParseLocation(int mapId, int subAreaId)
        {
            Data           = BlueSheep.Data.D2p.MapsManager.FromId(mapId);
            Data.SubAreaId = subAreaId;
            DataClass subArea     = GameData.GetDataObject(D2oFileEnum.SubAreas, subAreaId);
            string    mapName     = I18N.GetText((int)GameData.GetDataObject(D2oFileEnum.Areas, (int)subArea.Fields["areaId"]).Fields["nameId"]);
            string    subAreaName = I18N.GetText((int)subArea.Fields["nameId"]);

            m_Account.ModifBar(5, 0, 0, "[" + X + ";" + Y + "]" + " " + mapName + " (" + subAreaName + ")");
            m_Account.ModifBar(5, 0, 0, mapName + " (" + subAreaName + ")");
        }
예제 #3
0
        public static void CharacterExperienceGainMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            CharacterExperienceGainMessage msg = (CharacterExperienceGainMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            account.Log(new ActionTextInformation("Experience gagnée : + " + msg.experienceCharacter + " points d'expérience"), 4);
            account.CharacterStats.experience += msg.experienceCharacter;
            double i = account.CharacterStats.experience - account.CharacterStats.experienceLevelFloor;
            double j = account.CharacterStats.experienceNextLevelFloor - account.CharacterStats.experienceLevelFloor;

            try
            {
                int xppercent = (int)((i / j) * 100);
            }
            catch (Exception ex)
            {
            }
            account.ModifBar(1, (int)account.CharacterStats.experienceNextLevelFloor - (int)account.CharacterStats.experienceLevelFloor, (int)account.CharacterStats.experience - (int)account.CharacterStats.experienceLevelFloor, "Experience");
            if (account.Fight != null)
            {
                account.FightData.xpWon[DateTime.Today] += (int)msg.experienceCharacter;
            }
        }
예제 #4
0
        public static void CharacterSelectedSuccessMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            CharacterSelectedSuccessMessage characterSelectedSuccessMessage = (CharacterSelectedSuccessMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                characterSelectedSuccessMessage.Deserialize(reader);
            }

            account.CharacterBaseInformations = characterSelectedSuccessMessage.infos;

            account.Log(new BotTextInformation(account.CharacterBaseInformations.name + " de niveau " + account.CharacterBaseInformations.level + " est connecté."), 1);
            account.ModifBar(7, 0, 0, account.AccountName + " - " + account.CharacterBaseInformations.name);
            account.ModifBar(8, 0, 0, Convert.ToString(account.CharacterBaseInformations.level));

            //MainForm.ActualMainForm.ActualizeAccountInformations();
        }
예제 #5
0
        public static void CharacterLevelUpMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            CharacterLevelUpMessage msg = (CharacterLevelUpMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            account.ModifBar(8, 0, 0, Convert.ToString(msg.newLevel));
            account.Log(new BotTextInformation("Level up ! New level : " + Convert.ToString(msg.newLevel)), 3);
            account.CaracUC.UpAuto();
        }
예제 #6
0
        public static void LifePointsRegenEndMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            LifePointsRegenEndMessage msg = (LifePointsRegenEndMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            int percent = (msg.lifePoints / msg.maxLifePoints) * 100;

            account.Log(new BotTextInformation("Fin de la régénération. + " + msg.lifePointsGained + " points de vie"), 2);
            account.ModifBar(2, (int)msg.maxLifePoints, (int)msg.lifePoints, "Vitalité");
        }
예제 #7
0
        /// <summary>
        /// Update the life points of the specified fighter.
        /// </summary>
        public void UpdateFighterLifePoints(long id, int delta)
        {
            BFighter fighter = GetFighter(id);

            if (fighter != null)
            {
                fighter.LifePoints += delta;
                if (fighter.Id == Fighter.Id)
                {
                    m_Account.ModifBar(2, m_Account.FightData.Fighter.MaxLifePoints, m_Account.FightData.Fighter.LifePoints, "Vitalité");
                }
                m_Account.Log(new ActionTextInformation(fighter.Name + ": " + delta + "PV."), 5);
            }
        }
예제 #8
0
        public static void GameActionFightLifePointsLostMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameActionFightLifePointsLostMessage msg = (GameActionFightLifePointsLostMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (account.Fight != null && account.state == Status.Fighting)
            {
                BFighter fighter = account.Fight.GetFighter(msg.targetId);
                account.Fight.Fighters[account.Fight.Fighters.IndexOf(fighter)].LifePoints -= msg.loss;
                if (fighter.Id == account.Fight.Fighter.Id)
                {
                    account.ModifBar(2, account.Fight.Fighter.MaxLifePoints, account.Fight.Fighter.LifePoints, "Vitalité");
                }
            }
        }
예제 #9
0
        public static void InventoryWeightMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            InventoryWeightMessage msg = (InventoryWeightMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            int    Percent = (((int)msg.Weight / (int)msg.WeightMax) * 100);
            string text    = Convert.ToString(msg.Weight) + "/" + Convert.ToString((int)msg.WeightMax) + "(" + Percent + "% )";
            int    w       = Convert.ToInt32(msg.Weight);
            int    wmax    = Convert.ToInt32(msg.WeightMax);

            account.ModifBar(3, wmax, w, "Pods");
            account.Pods                = new Pods((int)msg.Weight, (int)msg.WeightMax);
            account.Inventory.weight    = (int)msg.Weight;
            account.Inventory.maxWeight = (int)msg.WeightMax;
        }
예제 #10
0
        public static void IdentificationSuccessMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            IdentificationSuccessMessage msg = (IdentificationSuccessMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);

            dtDateTime = dtDateTime.AddMilliseconds(msg.subscriptionEndDate).ToLocalTime();
            DateTime subscriptionDate = dtDateTime;

            if (subscriptionDate > DateTime.Now)
            {
                account.ModifBar(9, 0, 0, subscriptionDate.Date.ToShortDateString());
            }
            account.Log(new ConnectionTextInformation("Identification réussie."), 0);
        }
예제 #11
0
        public static void GameActionFightLifePointsGainMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameActionFightLifePointsGainMessage msg = (GameActionFightLifePointsGainMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            /* Credit : Apokah */
            if (account.Fight != null && account.state == Status.Fighting)
            {
                BFighter fighter = account.Fight.GetFighter(msg.targetId);
                if (msg.actionId == 108) // HP Récupérés (delta = combien on a récupérés)
                {
                    account.Fight.Fighters[account.Fight.Fighters.IndexOf(fighter)].LifePoints += msg.delta;
                    if (fighter.Id == account.Fight.Fighter.Id)
                    {
                        account.ModifBar(2, account.Fight.Fighter.MaxLifePoints, account.Fight.Fighter.LifePoints, "Vitalité");
                    }
                }
            }
        }
예제 #12
0
        public static void MapComplementaryInformationsWithCoordsMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            MapComplementaryInformationsWithCoordsMessage msg = (MapComplementaryInformationsWithCoordsMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            account.Map.SubAreaId = msg.subAreaId;
            account.Map.Data      = MapsManager.FromId(msg.mapId);
            DataClass subArea     = GameData.GetDataObject(D2oFileEnum.SubAreas, (int)msg.subAreaId);
            string    mapName     = I18N.GetText((int)GameData.GetDataObject(D2oFileEnum.Areas, (int)subArea.Fields["areaId"]).Fields["nameId"]);
            string    subAreaName = I18N.GetText((int)subArea.Fields["nameId"]);

            account.ModifBar(5, 0, 0, "[" + msg.worldX + ";" + msg.worldY + "]" + " " + mapName + " (" + subAreaName + ")");
            account.Map.Entities.Clear();
            account.Map.List.Clear();
            account.Enable(true);
            foreach (GameRolePlayActorInformations actor in msg.actors)
            {
                account.Map.Entities.Add(new BlueSheep.Core.Fight.Entity(actor.contextualId, actor.disposition.cellId));
                if (actor is GameRolePlayGroupMonsterInformations)
                {
                    GameRolePlayGroupMonsterInformations a = (GameRolePlayGroupMonsterInformations)actor;
                    account.Map.List.Add(new MonsterGroup(a.staticInfos, a.disposition.cellId, a.contextualId));
                }
            }
            account.Map.StatedElements.Clear();
            foreach (var statedElementDofus in msg.statedElements)
            {
                if (!(account.Map.StatedElements.ContainsKey(statedElementDofus.elementId)))
                {
                    account.Map.StatedElements.Add(statedElementDofus.elementId, new BlueSheep.Core.Map.Elements.StatedElement((uint)statedElementDofus.elementCellId, (uint)statedElementDofus.elementId, (uint)statedElementDofus.elementState));
                }
            }
            account.Map.InteractiveElements.Clear();
            account.Map.Doors.Clear();
            foreach (var element in msg.interactiveElements)
            {
                account.Map.InteractiveElements.Add(element.elementId, new BlueSheep.Core.Map.Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills)));
                InteractiveElement interactiveElement = element;
                List <int>         listDoorSkillId    = new List <int>(new[] { 184, 183, 187, 198, 114 });
                List <int>         listDoorTypeId     = new List <int>(new[] { -1, 128, 168, 16 });
                if (listDoorTypeId.Contains(interactiveElement.elementTypeId) && (interactiveElement.enabledSkills.Length > 0) && (listDoorSkillId.Contains(interactiveElement.enabledSkills[0].skillId)))
                {
                    foreach (var layer in ((BlueSheep.Data.D2p.Map)account.Map.Data).Layers)
                    {
                        foreach (var cell in layer.Cells)
                        {
                            foreach (var layerElement in cell.Elements)
                            {
                                if (layerElement is GraphicalElement)
                                {
                                    GraphicalElement graphicalElement = (GraphicalElement)layerElement;
                                    if ((graphicalElement.Identifier == interactiveElement.elementId) && !(account.Map.Doors.ContainsKey(cell.CellId)))
                                    {
                                        account.Map.Doors.Add(cell.CellId, new BlueSheep.Core.Map.Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills)));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            account.Npc.Npcs.Clear();
            foreach (GameRolePlayActorInformations a in msg.actors)
            {
                if (a is GameRolePlayNpcInformations)
                {
                    account.Npc.Npcs.Add(a.contextualId, ((GameRolePlayNpcInformations)a).npcId);
                }
            }
            if (account.Path != null)
            {
                if (account.Path.Current_Flag == "<Fight>" && account.state != Enums.Status.Fighting && account.Path.Current_Map == account.Map.X.ToString() + "," + account.Map.Y.ToString())
                {
                    if (account.Fight.SearchFight() == false)
                    {
                        account.Path.PerformActionsStack();
                    }
                }
                else if (account.Path != null & account.state != Enums.Status.Fighting && account.Path.Current_Map == account.Map.X.ToString() + "," + account.Map.Y.ToString())
                {
                    account.Path.PerformActionsStack();
                }
                else if (account.Path != null & account.Path.Current_Map != account.Map.X.ToString() + "," + account.Map.Y.ToString() || account.Map.Id != account.Map.LastMapId)
                {
                    //account.Path.Stop = false;
                    account.Path.Start();
                }
            }
        }