public void OnPurchased(NWCreature creature, int newLevel)
 {
     if (!creature.IsPlayer)
     {
         return;
     }
     PlayerStatService.ApplyStatChanges(creature.Object, null);
 }
 public void OnRemoved(NWCreature creature)
 {
     if (!creature.IsPlayer)
     {
         return;
     }
     PlayerStatService.ApplyStatChanges(creature.Object, null);
 }
Esempio n. 3
0
        private void DoPerkRemoval()
        {
            if (!CanRefundPerk())
            {
                return;
            }

            var model        = GetDialogCustomData <Model>();
            var player       = GetPC();
            var pcPerk       = DataService.PCPerk.GetByID(model.PCPerkID);
            var perk         = DataService.Perk.GetByID(pcPerk.PerkID);
            var minimumLevel = 1;

            if (IsGrantedByBackground((PerkType)perk.ID))
            {
                minimumLevel = 2;
            }

            var refundAmount = DataService.PerkLevel.GetAllByPerkID(perk.ID)
                               .Where(x => x.Level <= pcPerk.PerkLevel &&
                                      x.Level >= minimumLevel).Sum(x => x.Price);
            var dbPlayer = DataService.Player.GetByID(player.GlobalID);

            dbPlayer.DatePerkRefundAvailable = DateTime.UtcNow.AddHours(24);
            RemovePerkItem(perk);
            RemovePerkFeat(perk);
            CustomEffectService.RemoveStance(GetPC());
            PlayerStatService.ApplyStatChanges(GetPC(), null);

            dbPlayer.UnallocatedSP += refundAmount;

            var refundAudit = new PCPerkRefund
            {
                PlayerID     = player.GlobalID,
                DateAcquired = pcPerk.AcquiredDate,
                DateRefunded = DateTime.UtcNow,
                Level        = pcPerk.PerkLevel,
                PerkID       = pcPerk.PerkID
            };

            // Bypass caching for perk refunds.
            DataService.DataQueue.Enqueue(new DatabaseAction(refundAudit, DatabaseActionType.Insert));
            DataService.SubmitDataChange(pcPerk, DatabaseActionType.Delete);
            DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update);

            // If perk refunded was one granted by a background bonus, we need to reapply it.
            ReapplyBackgroundBonus((PerkType)pcPerk.PerkID);

            GetPC().FloatingText("Perk refunded! You reclaimed " + refundAmount + " SP.");
            model.TomeItem.Destroy();

            var handler = PerkService.GetPerkHandler(perk.ID);

            handler.OnRemoved(player);
            MessageHub.Instance.Publish(new OnPerkRefunded(player, pcPerk.PerkID));
        }
Esempio n. 4
0
        public string Apply(NWCreature oCaster, NWObject oTarget, int effectiveLevel)
        {
            PlayerStatService.ApplyStatChanges(oTarget.Object, null);
            int healAmount = (int)(CustomEffectService.CalculateEffectHPBonusPercent(oTarget.Object) * oTarget.MaxHP);

            if (healAmount > 0)
            {
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(healAmount), oTarget);
            }

            return(null);
        }
Esempio n. 5
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            NWPlayer targetPlayer = oTarget.Object;

            if (targetPlayer.Chest.CustomItemType != CustomItemType.HeavyArmor)
            {
                CustomEffectService.RemovePCCustomEffect(targetPlayer, CustomEffectType.ShieldBoost);
                PlayerStatService.ApplyStatChanges(targetPlayer, null);

                var vfx = targetPlayer.Effects.SingleOrDefault(x => _.GetEffectTag(x) == "SHIELD_BOOST_VFX");

                if (vfx != null)
                {
                    _.RemoveEffect(targetPlayer, vfx);
                }
            }
        }
Esempio n. 6
0
 public void WearOff(NWCreature oCaster, NWObject oTarget, int effectiveLevel, string data)
 {
     PlayerStatService.ApplyStatChanges(oTarget.Object, null);
 }
Esempio n. 7
0
        private void SkillResponses(int responseID)
        {
            var model = GetDialogCustomData <Model>();

            // This is the first click. Mark the distribution type and wait for confirmation on the next click.
            if (model.DistributionType != responseID)
            {
                model.DistributionType = responseID;
            }
            // This is confirmation to distribute the rank(s). Do it.
            else
            {
                int amount;

                // Figure out how much to increase the skill by.
                if (responseID == 1)
                {
                    amount = 1;
                }
                else if (responseID == 2)
                {
                    amount = 5;
                }
                else if (responseID == 3)
                {
                    amount = 10;
                }
                else
                {
                    // We shouldn't ever see this message, but just in case a future change breaks it...
                    GetPC().FloatingText("You cannot distribute this number of ranks into this skill.");
                    return;
                }

                // Ensure the player can distribute the ranks one more time.
                if (!CanDistribute(amount))
                {
                    GetPC().FloatingText("You cannot distribute these ranks into this skill.");
                    return;
                }

                // Let's do the distribution. Normally, you would want to run the SkillService methods but in this scenario
                // all of that's already been applied. You don't want to reapply the SP gains because they'll get more than they should.
                // Just set the ranks on the DB record and recalc stats.
                var pcSkill = DataService.Single <PCSkill>(x => x.PlayerID == GetPC().GlobalID&& x.SkillID == model.SkillID);
                var skill   = DataService.Get <Skill>(pcSkill.SkillID);

                // Prevent the player from adding too many ranks.
                if (pcSkill.Rank + amount > skill.MaxRank)
                {
                    GetPC().FloatingText("You cannot distribute this number of ranks into this skill.");
                    return;
                }

                pcSkill.Rank += amount;

                DataService.SubmitDataChange(pcSkill, DatabaseActionType.Update);
                PlayerStatService.ApplyStatChanges(GetPC(), null);

                // Reduce the pool levels. Delete the record if it drops to zero.
                var pool = DataService.Single <PCSkillPool>(x => x.PlayerID == GetPC().GlobalID&& x.SkillCategoryID == model.SkillCategoryID);
                pool.Levels -= amount;

                if (pool.Levels <= 0)
                {
                    DataService.SubmitDataChange(pool, DatabaseActionType.Delete);
                    EndConversation();
                    return;
                }
                else
                {
                    DataService.SubmitDataChange(pool, DatabaseActionType.Update);
                }

                model.DistributionType = 0;
            }

            LoadSkillPage();
        }
Esempio n. 8
0
        public string Apply(NWCreature oCaster, NWObject oTarget, int effectiveLevel)
        {
            PlayerStatService.ApplyStatChanges(oTarget.Object, null);

            return(null);
        }
Esempio n. 9
0
 public void OnRemoved(NWPlayer oPC)
 {
     PlayerStatService.ApplyStatChanges(oPC, null);
 }
Esempio n. 10
0
 public void OnPurchased(NWPlayer oPC, int newLevel)
 {
     PlayerStatService.ApplyStatChanges(oPC, null);
 }