Пример #1
0
        public static void ParseIOObjects(WorldClient client, string IO)
        {
            string[] data = IO.Split(';');
            if (client.Character.GetJobBySkill(int.Parse(data[1])) != null)
            {
                var job   = client.Character.GetJobBySkill(int.Parse(data[1]));
                var skill = job.GetSkill(int.Parse(data[1]));
                var io    = client.Character.Map.Engine.GetIO(int.Parse(data[0]));
                if (io != null)
                {
                    if (client.Action.NextJobSkill == null)
                    {
                        client.Action.NextJobSkill = skill;
                        return;
                    }
                }
            }
            switch ((Enums.InteractiveObjectEnum) int.Parse(data[1]))
            {
            case Enums.InteractiveObjectEnum.SAVE_POSITION:
                ZaapHandler.SavePosition(client, client.Character.MapID);
                break;

            case Enums.InteractiveObjectEnum.ZAAP:
                ZaapHandler.OnRequestUse(client, int.Parse(data[0]));
                break;

            case Enums.InteractiveObjectEnum.INCARNAM_STATUS:
                client.State = WorldClientState.OnRequestIncarnamStatue;
                break;

            case Enums.InteractiveObjectEnum.MOUNT_DOOR:
                client.State = WorldClientState.OnRequestMountDoor;
                break;
            }
        }
Пример #2
0
        public static void EndAction(WorldClient client, string packet)
        {
            if (packet[3] == '0')
            {
                #region Battle

                /* If in battle */
                if (client.Character.Fighter != null)
                {
                    client.Character.Fighter.Team.Fight.PlayerEndMove(client.Character.Fighter);
                    return;
                }

                #endregion

                #region Cell ID

                var oldCell = client.Character.CellID;
                client.Character.CellID = client.Character.NextMove;

                #endregion

                #region Dropped Items

                Database.Records.WorldItemRecord droppedItem = client.Character.Map.Engine.GetDroppedItem(client.Character.CellID);
                if (droppedItem != null)
                {
                    if (client.Character.Items.HaveItemWithSameEffects(droppedItem.Effects) &&
                        client.Character.Items.HaveItem(droppedItem.Template))
                    {
                        client.Character.Items.AddItem(droppedItem, false, droppedItem.Quantity);
                    }
                    else
                    {
                        client.Character.Items.AddItem(droppedItem, true, droppedItem.Quantity);
                        droppedItem.Owner = client.Character.ID;
                    }
                    client.Character.Map.Engine.RemoveDroppedItem(droppedItem, client.Character.CellID);
                }

                #endregion

                #region Zaaps

                /* Zaap use request */
                if (client.State == WorldClientState.OnRequestZaap)
                {
                    if (client.Character.Map.Engine.Zaap != null)
                    {
                        if (client.Character.CellID == client.Character.Map.Engine.Zaap.CellID)
                        {
                            ZaapHandler.OpenZaapPanel(client);
                        }
                    }
                }

                #endregion

                #region Incarnam Teleporter

                /* Incarnam statue teleporter request */
                if (client.State == WorldClientState.OnRequestIncarnamStatue)
                {
                    Database.Records.IncarnamTeleportRecord incarnamTP = Helper.MapHelper.FindIncarnamTeleporter(client.Character.MapID);
                    if (incarnamTP != null)
                    {
                        if (incarnamTP.CellID == client.Character.CellID)
                        {
                            if (incarnamTP.MaxLevel > client.Character.Level)
                            {
                                Database.Records.OriginalBreedStartMapRecord startmap = Helper.MapHelper.GetOriginalBreedStartMap(client.Character.Breed);
                                Network.World.GoToMap(client, startmap.MapID, startmap.CellID);
                            }
                            else
                            {
                                client.SendImPacket("13");
                            }
                            client.State = WorldClientState.None;
                        }
                    }
                }

                #endregion

                #region Guild Creator Location

                /* Guid creator location */
                if (Utilities.ConfigurationManager.GetBoolValue("EnableGuildCreationLocation"))
                {
                    Database.Records.GuildCreatorLocationRecord guildCreator = Helper.MapHelper.FindGuildCreator(client.Character.MapID, client.Character.CellID);
                    if (guildCreator != null)
                    {
                        if (client.Character.Level >= guildCreator.RequiredLevel)
                        {
                            //TODO: Check object creator required
                            client.Send("gn");
                        }
                        else
                        {
                            client.SendImPacket("13");
                        }
                    }
                }

                #endregion

                #region Mount Door

                if (client.State == WorldClientState.OnRequestMountDoor)
                {
                    client.Character.Map.Engine.ShowPaddocksMounts(client, client.Character.CellID);
                }

                #endregion

                #region Job

                if (client.Action.NextJobSkill != null)
                {
                    var io = client.Character.Map.Engine.GetIO(client.Character.CellID);
                    if (io != null)
                    {
                        if (!client.Action.NextJobSkill.DoSkill(client, io))
                        {
                            client.Action.NextJobSkill = null;
                        }
                    }
                    else
                    {
                        client.Action.NextJobSkill = null;
                    }
                }

                #endregion

                #region Monsters

                /* Monsters On Pos */
                Engines.Map.MonsterGroup monstersOnCell = client.Character.Map.Engine.GetMonsterGroupOnCell(client.Character.CellID);
                if (monstersOnCell != null)
                {
                    if (monstersOnCell.Leader == null)
                    {
                        return;
                    }
                    var freeCell = client.Character.Map.Engine.PathfindingMaker.FreeCellNeightboor(client.Character.CellID);
                    if (freeCell != -1)
                    {
                        client.Character.CellID = freeCell;
                    }
                    StartMonstersBattle(client, monstersOnCell);
                    client.Character.Map.Engine.RemoveMonstersOnMap(monstersOnCell);
                    client.Character.Map.Engine.Spawner.GenerateOneGroup();
                    client.Character.Map.Engine.Players.CharactersOnMap.ForEach(x => client.Character.Map.Engine.ShowMonstersGroup(x));
                    return;
                }

                #endregion

                #region Triggers

                /* Change map by trigger */
                if (client.Character.Map.Triggers.FindAll(x => x.CellID == client.Character.CellID).Count > 0)
                {
                    Database.Records.TriggerRecord trigger = client.Character.Map.Triggers.FirstOrDefault(x => x.CellID == client.Character.CellID);
                    if (client.Character.Level >= trigger.LevelRequired)
                    {
                        World.Network.World.GoToMap(client, trigger.NextMap, trigger.NextCell);
                    }
                    else
                    {
                        client.Action.SystemMessage("Vous n'avez pas level requis pour rentrer sur cette carte, level requis : <b>" + trigger.LevelRequired + "</b>");
                    }
                    return;
                }

                #endregion

                #region Script

                Interop.PythonScripting.ScriptManager.CallEventPlayerMovement(client, oldCell, client.Character.CellID);

                #endregion
            }
            else
            {
                //Doing job stuff
                if (client.Action.NextJobSkill != null)
                {
                    var io = client.Character.Map.Engine.GetIO(client.Character.CellID);
                    if (io != null)
                    {
                        client.Action.NextJobSkill.SkillFinished(client, io);
                    }
                    client.Action.NextJobSkill = null;
                }
            }

            client.State = WorldClientState.None;
        }