Пример #1
0
    public static void HandleCreateDungeon(GameSession session, PacketReader packet)
    {
        int    dungeonId  = packet.ReadInt();
        bool   groupEnter = packet.ReadBool();
        Player player     = session.Player;

        if (player.DungeonSessionId != -1)
        {
            session.SendNotice("Leave your current dungeon before opening another.");
            return;
        }

        int            dungeonLobbyId = DungeonStorage.GetDungeonByDungeonId(dungeonId).LobbyFieldId;
        MapPlayerSpawn spawn          = MapEntityStorage.GetRandomPlayerSpawn(dungeonLobbyId);

        DungeonSession dungeonSession = GameServer.DungeonManager.CreateDungeonSession(dungeonId, groupEnter ? DungeonType.Group : DungeonType.Solo);

        //TODO: Send packet that greys out enter alone / enter as party when already in a dungeon session (sendRoomDungeon packet/s).
        //the session belongs to the party leader
        if (groupEnter)
        {
            Party party = player.Party;
            if (party.DungeonSessionId != -1)
            {
                session.SendNotice("Need to reset dungeon before entering another instance");
                return;
            }
            foreach (Player member in party.Members)
            {
                if (member.DungeonSessionId != -1)
                {
                    session.SendNotice($"{member.Name} is still in a Dungeon Instance.");
                    return;
                }
            }
            party.DungeonSessionId = dungeonSession.SessionId;
            party.BroadcastPacketParty(PartyPacket.PartyHelp(dungeonId));
            //TODO: Update Party with dungeon Info via party packets (0d,0e and others are involved).
        }
        else // solo join dungeon
        {
            player.DungeonSessionId = dungeonSession.SessionId;
        }
        session.Player.Warp(dungeonLobbyId, instanceId: dungeonSession.DungeonInstanceId);
        //TODO: things after map is created here: spawn doctor npc.
        //This packet sets the banner in the dungeon that displays the dungeonname and the playersize it was created for.
        //party.BroadcastPacketParty(DungeonWaitPacket.Show(dungeonId, DungeonStorage.GetDungeonByDungeonId(dungeonId).MaxUserCount));
    }
Пример #2
0
        public static Player Char2(long accountId, long characterId, string name = "Char2")
        {
            Job         job   = Job.Archer;
            PlayerStats stats = new PlayerStats();

            int             mapId     = (int)Map.Queenstown;
            MapPlayerSpawn  spawn     = MapEntityStorage.GetRandomPlayerSpawn(mapId);
            List <SkillTab> skillTabs = new List <SkillTab>
            {
                new SkillTab(job)
            };

            return(new Player
            {
                SkillTabs = skillTabs,
                MapId = mapId,
                AccountId = accountId,
                CharacterId = characterId,
                Name = name,
                Gender = 0,
                Motto = "Motto",
                HomeName = "HomeName",
                Coord = CoordF.From(spawn.Coord.X, spawn.Coord.Y, spawn.Coord.Z),
                Job = job,
                SkinColor = new SkinColor()
                {
                    Primary = Color.Argb(0xFF, 0xEA, 0xBF, 0xAE)
                },
                CreationTime = DateTimeOffset.Now.ToUnixTimeSeconds() + Environment.TickCount,
                Equips = new Dictionary <ItemSlot, Item> {
                    { ItemSlot.ER, Item.EarMale() },
                    { ItemSlot.HR, Item.HairMale() },
                    { ItemSlot.FA, Item.FaceMale() },
                    { ItemSlot.FD, Item.FaceDecorationMale() },
                    { ItemSlot.CL, Item.CloathMale() },
                    { ItemSlot.SH, Item.ShoesMale() },
                },
                Stats = stats
            });
        }
Пример #3
0
        public void Warp(int mapId, CoordF coord = default, CoordF rotation = default, long instanceId = 0)
        {
            if (MapEntityStorage.HasSafePortal(MapId))
            {
                ReturnCoord = Coord;
                ReturnMapId = MapId;
            }
            Coord      = coord;
            Rotation   = rotation;
            SafeBlock  = coord;
            MapId      = mapId;
            InstanceId = instanceId;

            if (coord == default || rotation == default)
            {
                MapPlayerSpawn spawn = MapEntityStorage.GetRandomPlayerSpawn(mapId);
                if (spawn == null)
                {
                    Session.SendNotice($"Could not find a spawn for map {mapId}");
                    return;
                }
                if (coord == default)
                {
                    Coord     = spawn.Coord.ToFloat();
                    SafeBlock = spawn.Coord.ToFloat();
                }
                if (rotation == default)
                {
                    Rotation = spawn.Rotation.ToFloat();
                }
            }

            if (!UnlockedMaps.Contains(MapId))
            {
                UnlockedMaps.Add(MapId);
            }

            DatabaseManager.Characters.Update(this);
            Session.Send(FieldPacket.RequestEnter(this));
        }
Пример #4
0
 // Initializes all values to be saved into the database
 public Player(Account account, string name, byte gender, Job job, SkinColor skinColor)
 {
     AccountId   = account.Id;
     Account     = account;
     Name        = name;
     Gender      = gender;
     Job         = job;
     GameOptions = new GameOptions();
     Wallet      = new Wallet(meso: 0, valorToken: 0, treva: 0, rue: 0, haviFruit: 0);
     Levels      = new Levels(playerLevel: 1, exp: 0, restExp: 0, prestigeLevel: 1, prestigeExp: 0, new List <MasteryExp>()
     {
         new MasteryExp(MasteryType.Fishing),
         new MasteryExp(MasteryType.Performance),
         new MasteryExp(MasteryType.Mining),
         new MasteryExp(MasteryType.Foraging),
         new MasteryExp(MasteryType.Ranching),
         new MasteryExp(MasteryType.Farming),
         new MasteryExp(MasteryType.Smithing),
         new MasteryExp(MasteryType.Handicraft),
         new MasteryExp(MasteryType.Alchemy),
         new MasteryExp(MasteryType.Cooking),
         new MasteryExp(MasteryType.PetTaming)
     });
     Timestamps             = new TimeInfo(DateTimeOffset.UtcNow.ToUnixTimeSeconds());
     MapId                  = JobMetadataStorage.GetStartMapId((int)job);
     Coord                  = MapEntityStorage.GetRandomPlayerSpawn(MapId).Coord.ToFloat();
     Stats                  = new PlayerStats(strBase: 10, dexBase: 10, intBase: 10, lukBase: 10, hpBase: 500, critRateBase: 10);
     Motto                  = "Motto";
     ProfileUrl             = "";
     CreationTime           = DateTimeOffset.Now.ToUnixTimeSeconds();
     TitleId                = 0;
     InsigniaId             = 0;
     Titles                 = new List <int>();
     PrestigeRewardsClaimed = new List <int>();
     ChatSticker            = new List <ChatSticker>();
     FavoriteStickers       = new List <int>();
     Emotes                 = new List <int>()
     {
         90200011, 90200004, 90200024, 90200041, 90200042, 90200057, 90200043, 90200022, 90200031, 90200005, 90200006, 90200003, 90200092, 90200077, 90200073, 90200023, 90200001, 90200019, 90200020, 90200021
     };
     StatPointDistribution = new StatDistribution(20);
     Inventory             = new Inventory();
     Mailbox        = new List <Mail>();
     BuddyList      = new List <Buddy>();
     QuestList      = new List <QuestStatus>();
     GatheringCount = new List <GatheringCount>();
     TrophyCount    = new int[3] {
         0, 0, 0
     };
     ReturnMapId      = (int)Map.Tria;
     ReturnCoord      = MapEntityStorage.GetRandomPlayerSpawn(ReturnMapId).Coord.ToFloat();
     GroupChatId      = new int[3];
     SkinColor        = skinColor;
     UnlockedTaxis    = new List <int>();
     UnlockedMaps     = new List <int>();
     ActiveSkillTabId = 1;
     CharacterId      = DatabaseManager.Characters.Insert(this);
     SkillTabs        = new List <SkillTab> {
         new SkillTab(CharacterId, job, 1, $"Build {(SkillTabs == null ? "1" : SkillTabs.Count + 1)}")
     };
 }
        public void MoveUser(int mapId, int triggerId, int boxId)
        {
            List <IFieldObject <Player> > players = Field.State.Players.Values.ToList();

            if (boxId != 0)
            {
                MapTriggerBox box = MapEntityStorage.GetTriggerBox(Field.MapId, boxId);
                List <IFieldObject <Player> > boxedPlayers = new List <IFieldObject <Player> >();
                foreach (IFieldObject <Player> player in players)
                {
                    if (FieldManager.IsPlayerInBox(box, player))
                    {
                        boxedPlayers.Add(player);
                    }
                }
                players = boxedPlayers;
            }

            // move player back to return map
            if (mapId == 0 && triggerId == 0)
            {
                foreach (IFieldObject <Player> player in players)
                {
                    player.Value.Warp(player.Value.ReturnMapId, player.Value.ReturnCoord);
                }
                return;
            }

            if (mapId == Field.MapId)
            {
                IFieldObject <Portal> portal = Field.State.Portals.Values.First(p => p.Value.Id == triggerId);
                foreach (IFieldObject <Player> player in players)
                {
                    player.Coord    = portal.Coord;
                    player.Rotation = portal.Rotation;
                    player.Value.Session.Send(UserMoveByPortalPacket.Move(player, portal.Coord, portal.Rotation));
                }
                return;
            }

            CoordF    moveCoord;
            CoordF    moveRotation;
            MapPortal dstPortal = MapEntityStorage.GetPortals(mapId).FirstOrDefault(portal => portal.Id == triggerId);

            if (dstPortal == null)
            {
                MapPlayerSpawn spawn = MapEntityStorage.GetRandomPlayerSpawn(mapId);
                moveCoord    = spawn.Coord.ToFloat();
                moveRotation = spawn.Rotation.ToFloat();
            }
            else
            {
                moveCoord    = dstPortal.Coord.ToFloat();
                moveRotation = dstPortal.Rotation.ToFloat();
            }

            foreach (IFieldObject <Player> player in players)
            {
                player.Value.Warp(mapId, moveCoord, moveRotation);
            }
        }
Пример #6
0
        public override void Handle(GameSession session, PacketReader packet)
        {
            byte mode  = packet.ReadByte();
            long price = 0;
            bool paid  = false;
            int  mapId = 0;

            if (mode != 5)
            {
                mapId = packet.ReadInt();
            }

            switch (mode)
            {
            case 1:     // car taxi
                price = packet.ReadShort();
                if (session.Player.Mesos >= price)
                {
                    session.Player.Mesos -= price;
                    session.Send(MesosPacket.UpdateMesos(session));
                    paid = true;
                }
                break;

            case 3:     // rotors using mesos
                price = 60000;
                if (session.Player.Mesos >= price)
                {
                    session.Player.Mesos -= price;
                    session.Send(MesosPacket.UpdateMesos(session));
                    paid = true;
                }
                break;

            case 4:     // rotors using merets
                price = 15;
                if (session.Player.Merets >= price)
                {
                    session.Player.Merets -= price;
                    session.Send(MeretsPacket.UpdateMerets(session));
                    paid = true;
                }
                break;

            case 5:     // is sent after using rotors with meret, idk why..
                return;
            }

            if (paid)
            {
                MapPlayerSpawn spawn = MapEntityStorage.GetRandomPlayerSpawn(mapId);

                if (spawn != null)
                {
                    session.Player.MapId    = mapId;
                    session.Player.Coord    = spawn.Coord.ToFloat();
                    session.Player.Rotation = spawn.Rotation.ToFloat();
                    session.Send(FieldPacket.RequestEnter(session.FieldPlayer));
                }
            }
        }