예제 #1
0
        private void LoadSkillDetails()
        {
            Model              vm      = GetDialogCustomData <Model>();
            PCSkill            pcSkill = _skill.GetPCSkillByID(GetPC().GlobalID, vm.SelectedSkillID);
            SkillXPRequirement req     = _skill.GetSkillXPRequirementByRank(vm.SelectedSkillID, pcSkill.Rank);

            SetPageHeader("SkillDetailsPage", CreateSkillDetailsHeader(pcSkill, req));
        }
예제 #2
0
        private void LoadSkillDetails()
        {
            Model              vm      = GetDialogCustomData <Model>();
            Skill              skill   = SkillService.GetSkill(vm.SelectedSkillID);
            PCSkill            pcSkill = SkillService.GetPCSkill(GetPC(), vm.SelectedSkillID);
            SkillXPRequirement req     = DataService.Single <SkillXPRequirement>(x => x.Rank == pcSkill.Rank && x.SkillID == skill.ID);
            string             header  = CreateSkillDetailsHeader(pcSkill, req);

            SetPageHeader("SkillDetailsPage", header);

            if (!skill.ContributesToSkillCap)
            {
                SetResponseVisible("SkillDetailsPage", 1, false);
            }
        }
예제 #3
0
        private string CreateSkillDetailsHeader(PCSkill pcSkill, SkillXPRequirement req)
        {
            string title;

            if (pcSkill.Rank <= 3)
            {
                title = "Untrained";
            }
            else if (pcSkill.Rank <= 7)
            {
                title = "Neophyte";
            }
            else if (pcSkill.Rank <= 13)
            {
                title = "Novice";
            }
            else if (pcSkill.Rank <= 20)
            {
                title = "Apprentice";
            }
            else if (pcSkill.Rank <= 35)
            {
                title = "Journeyman";
            }
            else if (pcSkill.Rank <= 50)
            {
                title = "Expert";
            }
            else if (pcSkill.Rank <= 65)
            {
                title = "Adept";
            }
            else if (pcSkill.Rank <= 80)
            {
                title = "Master";
            }
            else if (pcSkill.Rank <= 100)
            {
                title = "Grandmaster";
            }
            else
            {
                title = "Unknown";
            }

            title += " (" + pcSkill.Rank + ")";

            string decayLock = _color.White("Unlocked");

            if (pcSkill.IsLocked)
            {
                decayLock = _color.Red("Locked");
            }

            return
                (_color.Green("Skill: ") + pcSkill.Skill.Name + "\n" +
                 _color.Green("Rank: ") + title + "\n" +
                 _color.Green("Exp: ") + _menu.BuildBar(pcSkill.XP, req.XP, 100, _color.TokenStart(255, 127, 0)) + "\n" +
                 _color.Green("Decay Lock: ") + decayLock + "\n\n" +
                 _color.Green("Description: ") + pcSkill.Skill.Description + "\n");
        }
예제 #4
0
        public void GiveSkillXP(NWPlayer oPC, int skillID, int xp, bool enableResidencyBonus = true)
        {
            if (skillID <= 0 || xp <= 0 || !oPC.IsPlayer)
            {
                return;
            }

            if (enableResidencyBonus)
            {
                xp = (int)(xp + xp * _playerStat.EffectiveResidencyBonus(oPC));
            }
            Player             player  = _data.Get <Player>(oPC.GlobalID);
            Skill              skill   = GetSkill(skillID);
            PCSkill            pcSkill = GetPCSkill(oPC, skillID);
            SkillXPRequirement req     = _data.Single <SkillXPRequirement>(x => x.SkillID == skillID && x.Rank == pcSkill.Rank);
            int   maxRank         = skill.MaxRank;
            int   originalRank    = pcSkill.Rank;
            float xpBonusModifier = player.XPBonus * 0.01f;

            // Guard against XP bonuses being too high.
            if (xpBonusModifier > 0.25)
            {
                xpBonusModifier = 0.25f;
            }

            xp = CalculateTotalSkillPointsPenalty(player.TotalSPAcquired, xp);
            xp = xp + (int)(xp * xpBonusModifier);

            // Run the skill decay rules.
            // If the method returns false, that means all skills are locked.
            // So we can't give the player any XP.
            if (!ApplySkillDecay(oPC, pcSkill, xp))
            {
                return;
            }


            pcSkill.XP = pcSkill.XP + xp;
            oPC.SendMessage("You earned " + skill.Name + " skill experience. (" + xp + ")");

            // Skill is at cap and player would level up.
            // Reduce XP to required amount minus 1 XP
            if (pcSkill.Rank >= maxRank && pcSkill.XP > req.XP)
            {
                pcSkill.XP = pcSkill.XP - 1;
            }

            while (pcSkill.XP >= req.XP)
            {
                pcSkill.XP = pcSkill.XP - req.XP;

                if (player.TotalSPAcquired < SkillCap && skill.ContributesToSkillCap)
                {
                    player.UnallocatedSP++;
                    player.TotalSPAcquired++;
                }

                pcSkill.Rank++;
                oPC.FloatingText("Your " + skill.Name + " skill level increased to rank " + pcSkill.Rank + "!");
                req = _data.Single <SkillXPRequirement>(x => x.SkillID == skillID && x.Rank == pcSkill.Rank);

                // Reapply skill penalties on a skill level up.
                for (int slot = 0; slot < NUM_INVENTORY_SLOTS; slot++)
                {
                    NWItem item = _.GetItemInSlot(slot, oPC.Object);
                    RemoveWeaponPenalties(item);
                    ApplyWeaponPenalties(oPC, new Object());
                    RemoveEquipmentPenalties(item);
                    ApplyEquipmentPenalties(oPC, new Object());
                }
            }

            _data.SubmitDataChange(pcSkill, DatabaseActionType.Update);

            // Update player and apply stat changes only if a level up occurred.
            if (originalRank != pcSkill.Rank)
            {
                _playerStat.ApplyStatChanges(oPC, null);
            }
        }
예제 #5
0
        public static void GiveSkillXP(NWPlayer oPC, int skillID, int xp, bool enableResidencyBonus = true)
        {
            if (skillID <= 0 || xp <= 0 || !oPC.IsPlayer)
            {
                return;
            }

            if (enableResidencyBonus)
            {
                xp = (int)(xp + xp * PlayerStatService.EffectiveResidencyBonus(oPC));
            }
            Player player = DataService.Get <Player>(oPC.GlobalID);
            Skill  skill  = GetSkill(skillID);

            // Check if the player has any undistributed skill ranks for this skill category.
            // If they haven't been distributed yet, the player CANNOT gain XP for this skill.
            var pool = DataService.SingleOrDefault <PCSkillPool>(x => x.PlayerID == oPC.GlobalID &&
                                                                 x.SkillCategoryID == skill.SkillCategoryID &&
                                                                 x.Levels > 0);

            if (pool != null)
            {
                oPC.FloatingText("You must distribute all pooled skill ranks before you can gain any new XP in the '" + skill.Name + "' skill. Access this menu from the 'View Skills' section of your rest menu.");
                return;
            }


            PCSkill            pcSkill = GetPCSkill(oPC, skillID);
            SkillXPRequirement req     = DataService.Single <SkillXPRequirement>(x => x.SkillID == skillID && x.Rank == pcSkill.Rank);
            int   maxRank         = skill.MaxRank;
            int   originalRank    = pcSkill.Rank;
            float xpBonusModifier = player.XPBonus * 0.01f;

            // Guard against XP bonuses being too high.
            if (xpBonusModifier > 0.25)
            {
                xpBonusModifier = 0.25f;
            }

            xp = CalculateTotalSkillPointsPenalty(player.TotalSPAcquired, xp);
            xp = xp + (int)(xp * xpBonusModifier);

            // Run the skill decay rules.
            // If the method returns false, that means all skills are locked.
            // So we can't give the player any XP.
            if (!ApplySkillDecay(oPC, pcSkill, xp))
            {
                return;
            }


            pcSkill.XP = pcSkill.XP + xp;
            oPC.SendMessage("You earned " + skill.Name + " skill experience. (" + xp + ")");

            // Skill is at cap and player would level up.
            // Reduce XP to required amount minus 1 XP
            if (pcSkill.Rank >= maxRank && pcSkill.XP > req.XP)
            {
                pcSkill.XP = req.XP - 1;
            }

            while (pcSkill.XP >= req.XP)
            {
                pcSkill.XP = pcSkill.XP - req.XP;

                if (player.TotalSPAcquired < SkillCap && skill.ContributesToSkillCap)
                {
                    player.UnallocatedSP++;
                    player.TotalSPAcquired++;
                }

                pcSkill.Rank++;
                oPC.FloatingText("Your " + skill.Name + " skill level increased to rank " + pcSkill.Rank + "!");
                req = DataService.Single <SkillXPRequirement>(x => x.SkillID == skillID && x.Rank == pcSkill.Rank);

                // Reapply skill penalties on a skill level up.
                for (int slot = 0; slot < NUM_INVENTORY_SLOTS; slot++)
                {
                    NWItem item = _.GetItemInSlot(slot, oPC.Object);
                    RemoveWeaponPenalties(item);
                    ApplyWeaponPenalties(oPC, item);
                    RemoveEquipmentPenalties(item);
                    ApplyEquipmentPenalties(oPC, item);
                }

                MessageHub.Instance.Publish(new SkillGainedMessage(oPC, skillID));
            }

            DataService.SubmitDataChange(pcSkill, DatabaseActionType.Update);

            // Update player and apply stat changes only if a level up occurred.
            if (originalRank != pcSkill.Rank)
            {
                PlayerStatService.ApplyStatChanges(oPC, null);
            }
        }
예제 #6
0
        private string CreateSkillDetailsHeader(PCSkill pcSkill, SkillXPRequirement req)
        {
            Skill  skill = SkillService.GetSkill(pcSkill.SkillID);
            string title;

            if (pcSkill.Rank <= 3)
            {
                title = "Untrained";
            }
            else if (pcSkill.Rank <= 7)
            {
                title = "Neophyte";
            }
            else if (pcSkill.Rank <= 13)
            {
                title = "Novice";
            }
            else if (pcSkill.Rank <= 20)
            {
                title = "Apprentice";
            }
            else if (pcSkill.Rank <= 35)
            {
                title = "Journeyman";
            }
            else if (pcSkill.Rank <= 50)
            {
                title = "Expert";
            }
            else if (pcSkill.Rank <= 65)
            {
                title = "Adept";
            }
            else if (pcSkill.Rank <= 80)
            {
                title = "Master";
            }
            else if (pcSkill.Rank <= 100)
            {
                title = "Grandmaster";
            }
            else
            {
                title = "Unknown";
            }

            title += " (" + pcSkill.Rank + ")";

            string decayLock = ColorTokenService.Green("Decay Lock: ") + ColorTokenService.White("Unlocked");

            if (pcSkill.IsLocked)
            {
                decayLock = ColorTokenService.Green("Decay Lock: ") + ColorTokenService.Red("Locked");
            }


            // Skills which don't contribute to the cap cannot be locked (there's no reason for it.)
            // Display a message explaining this to the player instead.
            string noContributeMessage = string.Empty;

            if (!skill.ContributesToSkillCap)
            {
                decayLock           = string.Empty;
                noContributeMessage = ColorTokenService.Green("This skill does not contribute to your cumulative skill cap.") + "\n\n";
            }

            Attribute primaryAttribute   = DataService.Get <Attribute>(skill.Primary);
            Attribute secondaryAttribute = DataService.Get <Attribute>(skill.Secondary);
            Attribute tertiaryAttribute  = DataService.Get <Attribute>(skill.Tertiary);
            string    primary            = ColorTokenService.Green("Primary (+" + PlayerStatService.PrimaryIncrease + "): ") + primaryAttribute.Name + "\n";
            string    secondary          = ColorTokenService.Green("Secondary (+" + PlayerStatService.SecondaryIncrease + "): ") + secondaryAttribute.Name + "\n";
            string    tertiary           = ColorTokenService.Green("Tertiary (+" + PlayerStatService.TertiaryIncrease + "): ") + tertiaryAttribute.Name + "\n";

            string header =
                ColorTokenService.Green("Skill: ") + skill.Name + "\n" +
                ColorTokenService.Green("Rank: ") + title + "\n" +
                ColorTokenService.Green("Exp: ") + MenuService.BuildBar(pcSkill.XP, req.XP, 100, ColorTokenService.TokenStart(255, 127, 0)) + "\n" +
                primary +
                secondary +
                tertiary +
                noContributeMessage +
                decayLock + "\n\n" +
                ColorTokenService.Green("Description: ") + skill.Description + "\n";

            return(header);
        }
예제 #7
0
        private string CreateSkillDetailsHeader(PCSkill pcSkill, SkillXPRequirement req)
        {
            Skill  skill = _skill.GetSkill(pcSkill.SkillID);
            string title;

            if (pcSkill.Rank <= 3)
            {
                title = "Untrained";
            }
            else if (pcSkill.Rank <= 7)
            {
                title = "Neophyte";
            }
            else if (pcSkill.Rank <= 13)
            {
                title = "Novice";
            }
            else if (pcSkill.Rank <= 20)
            {
                title = "Apprentice";
            }
            else if (pcSkill.Rank <= 35)
            {
                title = "Journeyman";
            }
            else if (pcSkill.Rank <= 50)
            {
                title = "Expert";
            }
            else if (pcSkill.Rank <= 65)
            {
                title = "Adept";
            }
            else if (pcSkill.Rank <= 80)
            {
                title = "Master";
            }
            else if (pcSkill.Rank <= 100)
            {
                title = "Grandmaster";
            }
            else
            {
                title = "Unknown";
            }

            title += " (" + pcSkill.Rank + ")";

            string decayLock = _color.Green("Decay Lock: ") + _color.White("Unlocked");

            if (pcSkill.IsLocked)
            {
                decayLock = _color.Green("Decay Lock: ") + _color.Red("Locked");
            }


            // Skills which don't contribute to the cap cannot be locked (there's no reason for it.)
            // Display a message explaining this to the player instead.
            string noContributeMessage = string.Empty;

            if (!skill.ContributesToSkillCap)
            {
                decayLock           = string.Empty;
                noContributeMessage = _color.Green("This skill does not contribute to your cumulative skill cap.") + "\n\n";
            }

            return
                (_color.Green("Skill: ") + skill.Name + "\n" +
                 _color.Green("Rank: ") + title + "\n" +
                 _color.Green("Exp: ") + _menu.BuildBar(pcSkill.XP, req.XP, 100, _color.TokenStart(255, 127, 0)) + "\n" +
                 noContributeMessage +
                 decayLock + "\n\n" +
                 _color.Green("Description: ") + skill.Description + "\n");
        }
예제 #8
0
        public void GiveSkillXP(NWPlayer oPC, int skillID, int xp)
        {
            if (skillID <= 0 || xp <= 0 || !oPC.IsPlayer)
            {
                return;
            }

            PlayerCharacter    player = _db.PlayerCharacters.Single(x => x.PlayerID == oPC.GlobalID);
            PCSkill            skill  = GetPCSkillByID(oPC.GlobalID, skillID);
            SkillXPRequirement req    = _db.SkillXPRequirements.Single(x => x.SkillID == skillID && x.Rank == skill.Rank);
            int maxRank      = _db.SkillXPRequirements.Where(x => x.SkillID == skillID).Max(m => m.Rank);
            int originalRank = skill.Rank;

            xp = CalculateTotalSkillPointsPenalty(player.TotalSPAcquired, xp);

            // Run the skill decay rules.
            // If the method returns false, that means all skills are locked.
            // So we can't give the player any XP.
            if (!ApplySkillDecay(oPC, skill, xp))
            {
                return;
            }

            skill.XP = skill.XP + xp;
            oPC.SendMessage("You earned " + skill.Skill.Name + " skill experience. (" + xp + ")");

            // Skill is at cap and player would level up.
            // Reduce XP to required amount minus 1 XP
            if (skill.Rank >= maxRank && skill.XP > req.XP)
            {
                skill.XP = skill.XP - 1;
            }

            while (skill.XP >= req.XP)
            {
                skill.XP = skill.XP - req.XP;

                if (player.TotalSPAcquired < SkillCap)
                {
                    player.UnallocatedSP++;
                    player.TotalSPAcquired++;
                }

                skill.Rank++;
                oPC.FloatingText("Your " + skill.Skill.Name + " skill level increased!");
                req = _db.SkillXPRequirements.Single(x => x.SkillID == skillID && x.Rank == skill.Rank);

                // Reapply skill penalties on a skill level up.
                for (int slot = 0; slot < NUM_INVENTORY_SLOTS; slot++)
                {
                    NWItem item = NWItem.Wrap(_.GetItemInSlot(slot, oPC.Object));
                    RemoveWeaponPenalties(item);
                    ApplyWeaponPenalties(oPC, NWItem.Wrap(new NWN.Object()));
                }
            }

            _db.SaveChanges();

            // Update player and apply stat changes only if a level up occurred.
            if (originalRank != skill.Rank)
            {
                ApplyStatChanges(oPC, null);
            }
        }