Example #1
0
        /// <summary>
        /// Return basic information about all items and pet item type, name, graphic, and buffs in JSON format
        /// </summary>
        /// <returns></returns>
        public virtual ActionResult Gear()
        {
            IDbStaticItemRepository repo = new EFDbStaticItemRepository();

            var output = repo.DbStaticItems.AsEnumerable().Select(
                c => new {
                FriendlyName = c.FriendlyName,
                ItemType     = c.ItemType,
                PortraitUrl  = HtmlHelpers.GetImageUrl(c.PortraitUrl, c.ItemType == PvPStatics.ItemType_Pet ? PvPStatics.MobilityPet : PvPStatics.MobilityInanimate, true).ToString(),
                Discipline   = c.Discipline,
                Perception   = c.Perception,
                Charisma     = c.Charisma,
                Fortitude    = c.Fortitude,
                Agility      = c.Agility,
                Allure       = c.Allure,
                Magicka      = c.Magicka,
                Succour      = c.Succour,
                Luck         = c.Luck
            });

            return(Json(output, JsonRequestBehavior.AllowGet));
        }
        public static void ClaimReward(Player attacker, Player victim, DbStaticForm victimNewForm)
        {
            if (attacker == null || victim == null || victimNewForm == null)
            {
                return;
            }

            // Ensure victim is still in PvP, or not a player (in case we want to support bounties on NPCs)
            if (victim.BotId == AIStatics.ActivePlayerBotId && victim.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return;
            }

            // NPCs are not eligible to claim bounties
            if (attacker.BotId != AIStatics.ActivePlayerBotId)
            {
                return;
            }

            // Only reward PvP players to avoid friend list/alt abuse
            if (attacker.GameMode != (int)GameModeStatics.GameModes.PvP)
            {
                return;
            }

            var bountyStaticEffectIds = MAPPINGS.Select(se => se.EffectSourceId);
            var victimEffects         = EffectProcedures.GetPlayerEffects2(victim.Id).Where(e => bountyStaticEffectIds.Contains(e.dbEffect.EffectSourceId));
            var award = 0;

            foreach (var victimEffect in victimEffects)
            {
                var bounty = BountyDetails(victim, victimEffect.dbEffect.EffectSourceId);

                if (bounty == null)
                {
                    continue;
                }

                if (victimNewForm.Id == bounty.Form?.Id)
                {
                    // Victim has been turned into the requested form - full reward
                    award = bounty.CurrentReward;
                }
                else if (victimNewForm.ItemSourceId.HasValue)
                {
                    // Award half bounty for a different inanimate form of the same type
                    IDbStaticItemRepository itemsRepo = new EFDbStaticItemRepository();
                    var itemForm = itemsRepo.DbStaticItems.FirstOrDefault(i => i.Id == victimNewForm.ItemSourceId.Value);

                    if (itemForm?.ItemType == bounty.Category)
                    {
                        award = bounty.CurrentReward / 2;
                    }
                }

                if (award > 0)
                {
                    // Release the victim from the claimed bounty
                    EffectProcedures.SetPerkDurationToZero(victimEffect.dbEffect.EffectSourceId, victim);

                    // Award bounty funds to attacker
                    PlayerLogProcedures.AddPlayerLog(attacker.Id, $"For turning {victim.GetFullName()} into a {victimNewForm.FriendlyName} you claim a bounty of {award} arpeyjis.", true);
                    PlayerProcedures.GiveMoneyToPlayer(attacker, award);

                    StatsProcedures.AddStat(attacker.MembershipId, StatsProcedures.Stat__BountiesClaimed, award);

                    break;
                }
            }
        }