Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        public static void CreateCharacter(Network.WorldClient client, string packet)
        {
            string[] data = packet.Substring(2).Split('|');
            if (!Helper.AccountHelper.ExistName(data[0]))
            {
                if (client.Account.Characters.Count < ConfigurationManager.GetIntValue("MaxCharacterPerServer"))
                {
                    if (data[0].Length > 4 && data[0].Length < 15 && HasValidNickname(data[0]) && int.Parse(data[1]) > 0 && int.Parse(data[1]) < 13 && int.Parse(data[2]) > -1 && int.Parse(data[2]) < 2)
                    {
                        Database.Records.CharacterRecord character = new Database.Records.CharacterRecord()
                        {
                            Nickname    = data[0],
                            Breed       = int.Parse(data[1]),
                            Gender      = int.Parse(data[2]),
                            Color1      = int.Parse(data[3]),
                            Color2      = int.Parse(data[4]),
                            Color3      = int.Parse(data[5]),
                            Scal        = ConfigurationManager.GetIntValue("StartScal"),
                            Kamas       = ConfigurationManager.GetIntValue("StartKamas"),
                            Direction   = ConfigurationManager.GetIntValue("StartDir"),
                            CaractPoint = (ConfigurationManager.GetIntValue("StartLevel") * ConfigurationManager.GetIntValue("RateCapitalPoints")) - 5,
                            SpellPoint  = (ConfigurationManager.GetIntValue("StartLevel") * ConfigurationManager.GetIntValue("RateSpellPoints")) - 1,
                            Owner       = client.Account.ID,
                        };

                        if (client.Account.Vip == 1)
                        {
                            character.Level = 1500;
                        }
                        else
                        {
                            character.Level = ConfigurationManager.GetIntValue("StartLevel");
                        }
                        character.Experience = Helper.ExpFloorHelper.GetCharactersLevelFloor(character.Level).Character;

                        if (Utilities.ConfigurationManager.GetBoolValue("EnableBreedsOriginalStartMap"))
                        {
                            Database.Records.OriginalBreedStartMapRecord originalMap = Helper.MapHelper.GetOriginalBreedStartMap(character.Breed);
                            character.MapID    = originalMap.MapID;
                            character.CellID   = originalMap.CellID;
                            character.SaveMap  = originalMap.MapID;
                            character.SaveCell = originalMap.CellID;
                        }
                        else
                        {
                            character.MapID    = ConfigurationManager.GetIntValue("StartMap");
                            character.CellID   = ConfigurationManager.GetIntValue("StartCell");
                            character.SaveMap  = ConfigurationManager.GetIntValue("StartMap");
                            character.SaveCell = ConfigurationManager.GetIntValue("StartCell");
                        }
                        character.FirstPlay = true;
                        character.Spells.LearnBaseSpell();
                        character.CurrentLife = character.Stats.MaxLife;
                        character.Look        = Helper.AccountHelper.GetDefaultLook(character);

                        /* Add character */
                        character.SaveAndFlush();
                        Database.Cache.CharacterCache.Cache.Add(character);
                        client.Account.Characters.Add(character);

                        Communication.Realm.Communicator.Server.MainRealm.SendMessage
                            (new Communication.Realm.Packet.PlayerCreatedCharacterMessage(character));

                        SendCharacterList(client, packet);
                        Utilities.ConsoleStyle.Infos("'" + client.Account.Username + "' has created the character '" + character.Nickname + "'");
                    }
                    else
                    {
                        client.Send("AAEe");
                    }
                }
            }
            else
            {
                client.Send("AAEa");
            }
        }