Exemplo n.º 1
0
        public static void HandleClientTarget(WorldSession session, ClientRapidTransport rapidTransport)
        {
            //TODO: check for cooldown
            //TODO: handle payment

            TaxiNodeEntry taxiNode = GameTableManager.Instance.TaxiNode.GetEntry(rapidTransport.TaxiNode);

            if (taxiNode == null)
            {
                throw new InvalidPacketValueException();
            }

            if (session.Player.Level < taxiNode.AutoUnlockLevel)
            {
                throw new InvalidPacketValueException();
            }

            WorldLocation2Entry worldLocation = GameTableManager.Instance.WorldLocation2.GetEntry(taxiNode.WorldLocation2Id);

            if (worldLocation == null)
            {
                throw new InvalidPacketValueException();
            }

            GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(1307);

            session.Player.CastSpell(entry.Dataint0, new SpellParameters
            {
                TaxiNode = rapidTransport.TaxiNode
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Return money rewarded on completion.
        /// </summary>
        public uint GetRewardMoney()
        {
            if (Entry.RewardCashOverride != 0u)
            {
                return(Entry.RewardCashOverride);
            }

            GameFormulaEntry entry = GameTableManager.GameFormula.GetEntry(530);

            return((uint)(MathF.Pow(Entry.ConLevel, entry.Datafloat0) * DifficultyEntry.CashRewardMultiplier));
        }
Exemplo n.º 3
0
        private uint GetMaxUnlockItemCount()
        {
            // client defaults to 1000 if entry doesn't exist
            GameFormulaEntry entry = GameTableManager.GameFormula.GetEntry(1203);

            if (entry == null)
            {
                return(1000u);
            }

            return(entry.Dataint0 /* + countFromEntitlements*/);
        }
Exemplo n.º 4
0
        private bool MeetsPrerequisites(QuestInfo info)
        {
            if (info.Entry.QuestPlayerFactionEnum == 0u && player.Faction1 != Faction.Exile)
            {
                return(false);
            }
            if (info.Entry.QuestPlayerFactionEnum == 1u && player.Faction1 != Faction.Dominion)
            {
                return(false);
            }
            if (info.Entry.PrerequisiteRace != 0u && player.Race != (Race)info.Entry.PrerequisiteRace)
            {
                return(false);
            }
            if (info.Entry.PrerequisiteClass != 0u && player.Class != (Class)info.Entry.PrerequisiteClass)
            {
                return(false);
            }
            if (player.Level < info.Entry.PrerequisiteLevel)
            {
                return(false);
            }

            // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
            foreach (ushort questId in info.Entry.PrerequisiteQuests.Where(q => q != 0u))
            {
                if (GetQuestState(questId) != QuestState.Completed)
                {
                    return(false);
                }
            }

            if (info.Entry.PrerequisiteId != 0u && !PrerequisiteManager.Instance.Meets(player, info.Entry.PrerequisiteId))
            {
                return(false);
            }

            if (!info.IsContract())
            {
                GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(655);
                // client also hard codes 40 if entry doesn't exist
                if (completedQuests.Count > (entry?.Dataint0 ?? 40u))
                {
                    return(false);
                }
            }
            else
            {
                // TODO: contracts use reward property for max slots, RewardProperty.ActiveContractSlots
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks to see if the targeted <see cref="Mailbox"/> is in range.
        /// </summary>
        private bool IsTargetMailBoxInRange(uint unitId)
        {
            // native client function MailSystemLib.AtMailbox also uses entry 237 for distance check
            GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(237);

            if (entry == null)
            {
                throw new InvalidOperationException();
            }

            var entity = player.GetVisible <WorldEntity>(unitId);

            return(entity is Mailbox && Vector3.Distance(player.Position, entity.Position) < entry.Datafloat0);
        }
Exemplo n.º 6
0
        private uint CalculateMailCost(DeliveryTime time, List <Item> items)
        {
            GameFormulaEntry GetMailParameters()
            {
                if (items.Count == 0)
                {
                    return(GameTableManager.Instance.GameFormula.GetEntry(860));
                }

                switch (time)
                {
                case DeliveryTime.Instant:
                    return(GameTableManager.Instance.GameFormula.GetEntry(861));

                case DeliveryTime.Hour:
                    return(GameTableManager.Instance.GameFormula.GetEntry(862));

                case DeliveryTime.Day:
                    return(GameTableManager.Instance.GameFormula.GetEntry(863));
                }

                return(null);
            }

            GameFormulaEntry parameters = GetMailParameters();
            uint             cost       = parameters.Dataint0;

            foreach (Item item in items)
            {
                cost += parameters.Dataint01;
                // only instant delivery speed takes item worth into consideration
                if (parameters.Datafloat01 > 0.0f)
                {
                    if (item.GetVendorSellCurrency(0) == CurrencyType.Credits)
                    {
                        cost += (uint)(item.GetVendorSellAmount(0) * parameters.Datafloat01);
                    }
                    if (item.GetVendorSellCurrency(1) == CurrencyType.Credits)
                    {
                        cost += (uint)(item.GetVendorSellAmount(1) * parameters.Datafloat01);
                    }
                }
            }

            return(cost);
        }
Exemplo n.º 7
0
        public static void HandleGuildRegister(WorldSession session, ClientGuildRegister guildRegister)
        {
            GuildResultInfo GetResult()
            {
                // hardcoded GameFormula entries come from client GuildLib.GetCreateCost/GetAlternateCreateCost
                switch (guildRegister.GuildType)
                {
                case GuildType.Guild:
                {
                    GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(764);
                    if (!session.Player.CurrencyManager.CanAfford(CurrencyType.Credits, entry.Dataint0))
                    {
                        return(new GuildResultInfo(GuildResult.NotEnoughCredits));
                    }
                    break;
                }

                case GuildType.Community:
                {
                    GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(1159);
                    if (guildRegister.AlternateCost && !session.AccountCurrencyManager.CanAfford(AccountCurrencyType.ServiceToken, entry.Dataint01))
                    {
                        return(new GuildResultInfo(GuildResult.NotEnoughCredits));    // this right guild result for account credits?
                    }
                    if (!guildRegister.AlternateCost && !session.Player.CurrencyManager.CanAfford(CurrencyType.Credits, entry.Dataint0))
                    {
                        return(new GuildResultInfo(GuildResult.NotEnoughCredits));
                    }
                    break;
                }
                }

                return(session.Player.GuildManager.CanRegisterGuild(guildRegister));
            }

            GuildResultInfo result = GetResult();

            if (result.Result != GuildResult.Success)
            {
                GuildBase.SendGuildResult(session, result);
                return;
            }

            session.Player.GuildManager.RegisterGuild(guildRegister);
        }
Exemplo n.º 8
0
        public static void HandleHousingCommunityRename(WorldSession session, ClientHousingCommunityRename housingCommunityRename)
        {
            if (session.Player.Map is not ResidenceMapInstance)
            {
                throw new InvalidPacketValueException();
            }

            // ignore the value in the packet
            Community community = session.Player.GuildManager.GetGuild <Community>(GuildType.Community);

            if (community == null)
            {
                throw new InvalidPacketValueException();
            }

            HousingResult GetResult()
            {
                // client checks if the player has a rank of 0, this is the same
                if (community.LeaderId != session.Player.CharacterId)
                {
                    return(HousingResult.InvalidPermissions);
                }

                if (!TextFilterManager.Instance.IsTextValid(housingCommunityRename.Name) ||
                    !TextFilterManager.Instance.IsTextValid(housingCommunityRename.Name, UserText.HousingResidenceName))
                {
                    return(HousingResult.InvalidResidenceName);
                }

                GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(2395);

                if (entry == null)
                {
                    return(HousingResult.Failed);
                }

                bool canAfford;

                if (housingCommunityRename.AlternativeCurrency)
                {
                    canAfford = session.Player.CurrencyManager.CanAfford(CurrencyType.Renown, entry.Dataint01);
                }
                else
                {
                    canAfford = session.Player.CurrencyManager.CanAfford(CurrencyType.Credits, entry.Dataint0);
                }

                if (!canAfford)
                {
                    return(HousingResult.InsufficientFunds);
                }

                return(HousingResult.Success);
            }

            HousingResult result = GetResult();

            if (result == HousingResult.Success)
            {
                // fun fact: 2395 is the final game formula entry
                GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(2395);
                if (housingCommunityRename.AlternativeCurrency)
                {
                    session.Player.CurrencyManager.CurrencySubtractAmount(CurrencyType.Renown, entry.Dataint01);
                }
                else
                {
                    session.Player.CurrencyManager.CurrencySubtractAmount(CurrencyType.Credits, entry.Dataint0);
                }

                community.RenameGuild(housingCommunityRename.Name);
                community.Residence.Map?.RenameResidence(community.Residence, housingCommunityRename.Name);
            }

            session.EnqueueMessageEncrypted(new ServerHousingCommunityRename
            {
                Result      = HousingResult.Success,
                TargetGuild = new TargetGuild
                {
                    RealmId = WorldServer.RealmId,
                    GuildId = community.Id
                }
            });
        }