示例#1
0
    internal void SetRegionMonsterTypes()
    {
        //Set Monsters based on the user region
        List <int> regionMonsters = _region.Monsters.Split(',').Select(Int32.Parse).ToList();

        foreach (var monster in _characterDatabase.GetCharacters())
        {
            if (regionMonsters.IndexOf(monster.Id) != -1 && monster.IsEnable)
            {
                //Terrain Monster HealthCheck
                var healthCheck = false;
                foreach (var terrain in _myTerrains)
                {
                    if (!terrain.HasMonster)
                    {
                        continue;
                    }
                    if (terrain.Type == monster.FavoriteTerrainTypes)
                    {
                        healthCheck = true;
                        break;
                    }
                }
                if (!healthCheck)
                {
                    throw new Exception("Terrain with no available monster");
                }
                _monsters.Add(monster);
            }
        }
    }
        private async void ShowCharacterSelectScreen(Client client)
        {
            PlayerData playerData = await Data.PlayerDatabase.GetPlayerData(client.Address);

            uint[] characters = await CharacterDatabase.GetCharacters(playerData.Id);

            CharacterData[] charactersData = await Task.WhenAll(characters.Select(async e => await CharacterDatabase.GetCharacterData(e)));

            string[] characterNames = charactersData.Select(e => e.Name).ToArray();
            NAPI.ClientEvent.TriggerClientEvent(client, "SelectCharacter", string.Join(",", characters), string.Join(",", characterNames));
            NAPI.Player.SetPlayerSkin(client, PedHash.MovAlien01);
        }
        public async void OnGoBackToCharacterSelect(Client client)
        {
            PlayerData playerData = await Data.PlayerDatabase.GetPlayerData(client.Address);

            uint[] characters = await CharacterDatabase.GetCharacters(playerData.Id);

            CharacterData[] charactersData = await Task.WhenAll(characters.Select(async e => await CharacterDatabase.GetCharacterData(e)));

            string[] characterNames = charactersData.Select(e => e.Name).ToArray();

            NAPI.ClientEvent.TriggerClientEvent(client, "ToggleCreateCharacterMenu", false);
            NAPI.ClientEvent.TriggerClientEvent(client, "SelectCharacter", string.Join(",", characters), string.Join(",", characterNames));
        }
示例#4
0
        public static void HandleCharacterList(WorldSession session, ClientCharacterList characterList)
        {
            session.EnqueueEvent(new TaskGenericEvent <List <Character> >(CharacterDatabase.GetCharacters(session.Account.Id),
                                                                          characters =>
            {
                session.Characters.Clear();
                session.Characters.AddRange(characters);

                session.EnqueueMessageEncrypted(new ServerAccountEntitlements
                {
                    Entitlements =
                    {
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.BaseCharacterSlots,
                            Count       = 12
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.ChuaWarriorUnlock,
                            Count       = 1
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.AurinEngineerUnlock,
                            Count       = 1
                        }
                    }
                });

                session.EnqueueMessageEncrypted(new ServerMaxCharacterLevelAchieved
                {
                    Level = 50
                });

                var serverCharacterList = new ServerCharacterList
                {
                    RealmId = WorldServer.RealmId
                };
                foreach (Character character in characters)
                {
                    var listCharacter = new ServerCharacterList.Character
                    {
                        Id          = character.Id,
                        Name        = character.Name,
                        Sex         = (Sex)character.Sex,
                        Race        = (Race)character.Race,
                        Class       = (Class)character.Class,
                        Faction     = character.FactionId,
                        Level       = character.Level,
                        WorldId     = 3460,
                        WorldZoneId = 5967,
                        RealmId     = WorldServer.RealmId
                    };

                    // create a temporary inventory to show equipped gear
                    var inventory = new Inventory(null, character);
                    foreach (ItemVisual itemVisual in inventory.GetItemVisuals())
                    {
                        listCharacter.Gear.Add(itemVisual);
                    }

                    foreach (CharacterAppearance appearance in character.CharacterAppearance)
                    {
                        listCharacter.Appearance.Add(new ItemVisual
                        {
                            Slot      = (ItemSlot)appearance.Slot,
                            DisplayId = appearance.DisplayId
                        });
                    }

                    foreach (CharacterCustomisation customisation in character.CharacterCustomisation)
                    {
                        listCharacter.Labels.Add(customisation.Label);
                        listCharacter.Values.Add(customisation.Value);
                    }

                    foreach (CharacterBone bone in character.CharacterBone.OrderBy(bone => bone.BoneIndex))
                    {
                        listCharacter.Bones.Add(bone.Bone);
                    }

                    serverCharacterList.Characters.Add(listCharacter);
                }

                session.EnqueueMessageEncrypted(serverCharacterList);
            }));
        }
示例#5
0
        public static void HandleCharacterList(WorldSession session, ClientCharacterList characterList)
        {
            session.EnqueueEvent(new TaskGenericEvent <List <Character> >(CharacterDatabase.GetCharacters(session.Account.Id),
                                                                          characters =>
            {
                byte MaxCharacterLevelAchieved = 1;

                session.Characters.Clear();
                session.Characters.AddRange(characters);

                session.GenericUnlockManager.SendUnlockList();
                session.EnqueueMessageEncrypted(new ServerAccountEntitlements
                {
                    Entitlements =
                    {
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.BaseCharacterSlots,
                            Count       = 12
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.ExtraDecorSlots,
                            Count       = 2000
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.ChuaWarriorUnlock,
                            Count       = 1
                        },
                        new ServerAccountEntitlements.AccountEntitlementInfo
                        {
                            Entitlement = Entitlement.AurinEngineerUnlock,
                            Count       = 1
                        }
                    }
                });

                var serverCharacterList = new ServerCharacterList
                {
                    RealmId = WorldServer.RealmId
                };

                foreach (Character character in characters)
                {
                    var listCharacter = new ServerCharacterList.Character
                    {
                        Id          = character.Id,
                        Name        = character.Name,
                        Sex         = (Sex)character.Sex,
                        Race        = (Race)character.Race,
                        Class       = (Class)character.Class,
                        Faction     = character.FactionId,
                        Level       = character.Level,
                        WorldId     = character.WorldId,
                        WorldZoneId = character.WorldZoneId,
                        RealmId     = WorldServer.RealmId,
                        Path        = (byte)character.ActivePath
                    };

                    MaxCharacterLevelAchieved = (byte)Math.Max(MaxCharacterLevelAchieved, character.Level);

                    // create a temporary Inventory and CostumeManager to show equipped gear
                    var inventory      = new Inventory(null, character);
                    var costumeManager = new CostumeManager(null, session.Account, character);

                    CostumeEntity costume = null;
                    if (character.ActiveCostumeIndex >= 0)
                    {
                        costume = costumeManager.GetCostume((byte)character.ActiveCostumeIndex);
                    }

                    listCharacter.GearMask = costume?.Mask ?? 0xFFFFFFFF;

                    foreach (ItemVisual itemVisual in inventory.GetItemVisuals(costume))
                    {
                        listCharacter.Gear.Add(itemVisual);
                    }

                    foreach (CharacterAppearance appearance in character.CharacterAppearance)
                    {
                        listCharacter.Appearance.Add(new ItemVisual
                        {
                            Slot      = (ItemSlot)appearance.Slot,
                            DisplayId = appearance.DisplayId
                        });
                    }

                    /*foreach (CharacterCustomisation customisation in character.CharacterCustomisation)
                     * {
                     *  listCharacter.Labels.Add(customisation.Label);
                     *  listCharacter.Values.Add(customisation.Value);
                     * }*/

                    foreach (CharacterBone bone in character.CharacterBone.OrderBy(bone => bone.BoneIndex))
                    {
                        listCharacter.Bones.Add(bone.Bone);
                    }

                    foreach (CharacterStat stat in character.CharacterStat)
                    {
                        if ((Stat)stat.Stat == Stat.Level)
                        {
                            listCharacter.Level = (uint)stat.Value;
                            break;
                        }
                    }

                    serverCharacterList.Characters.Add(listCharacter);
                }

                session.EnqueueMessageEncrypted(new ServerMaxCharacterLevelAchieved
                {
                    Level = MaxCharacterLevelAchieved
                });

                session.EnqueueMessageEncrypted(serverCharacterList);
            }));
        }