예제 #1
0
        private void LoadSkillDetails()
        {
            Model   vm      = GetDialogCustomData <Model>();
            Skill   skill   = SkillService.GetSkill(vm.SelectedSkillID);
            PCSkill pcSkill = SkillService.GetPCSkill(GetPC(), vm.SelectedSkillID);
            int     req     = SkillService.SkillXPRequirements[pcSkill.Rank];
            string  header  = CreateSkillDetailsHeader(pcSkill, req);

            SetPageHeader("SkillDetailsPage", header);

            if (!skill.ContributesToSkillCap)
            {
                SetResponseVisible("SkillDetailsPage", 2, false);
            }
        }
예제 #2
0
        private void HandleDistributeRPXPResponse(int responseID)
        {
            NWPlayer player   = GetPC();
            Player   dbPlayer = DataService.Player.GetByID(player.GlobalID);
            Model    vm       = GetDialogCustomData <Model>();

            int rpXpToDistribute = dbPlayer.RoleplayXP;

            PCSkill pcSkill = SkillService.GetPCSkill(player, vm.SelectedSkillID);
            Skill   skill   = SkillService.GetSkill(vm.SelectedSkillID);
            // Get all player skills and then sum them up by the rank.
            int totalSkillCount = DataService.PCSkill
                                  .GetAllByPlayerID(player.GlobalID)
                                  .Where(x => DataService.Skill.GetByID(x.SkillID).ContributesToSkillCap)
                                  .Sum(s => s.Rank);
            int totalSkillXpToMaxRank = 0;

            //totalSkillCount < SkillService.SkillCap
            for (int x = pcSkill.Rank + 1; x < skill.MaxRank; x++)
            {
                int tempValue;
                if (SkillService.SkillXPRequirements.TryGetValue(x, out tempValue))
                {
                    totalSkillXpToMaxRank += tempValue;
                }
            }

            switch (responseID)
            {
            case 1:     // Select All RP XP
                vm.RPXPDistributing = totalSkillXpToMaxRank;
                break;

            case 2:     // Increase by 1000
                vm.RPXPDistributing += 1000;
                break;

            case 3:     // Increase by 100
                vm.RPXPDistributing += 100;
                break;

            case 4:     // Increase by 10
                vm.RPXPDistributing += 10;
                break;

            case 5:     // Increase by 1
                vm.RPXPDistributing += 1;
                break;

            case 6:     // Decrease by 1000
                vm.RPXPDistributing -= 1000;
                break;

            case 7:     // Decrease by 100
                vm.RPXPDistributing -= 100;
                break;

            case 8:     // Decrease by 10
                vm.RPXPDistributing -= 10;
                break;

            case 9:     // Decrease by 1
                vm.RPXPDistributing -= 1;
                break;

            case 10:     // Distribute Roleplay XP

                // Make sure the player specified how much they want to distribute.
                if (vm.RPXPDistributing <= 0)
                {
                    player.SendMessage("Please specify how much RP XP you'd like to distribute into this skill.");
                    vm.IsConfirming = false;
                }
                else if (vm.RPXPDistributing > totalSkillXpToMaxRank)
                {
                    player.SendMessage("Please lower your distribution amount, current max for this skill is " + totalSkillXpToMaxRank + ".");
                    vm.IsConfirming = false;
                }
                else
                {
                    if (vm.IsConfirming)
                    {
                        // Give the distributed XP to a particular skill.
                        // We disable residency bonuses, DM bonuses, and skill penalties during this distribution because
                        // those are calculated when we give the player RP XP.
                        SkillService.GiveSkillXP(player, vm.SelectedSkillID, vm.RPXPDistributing, false, false);

                        dbPlayer             = DataService.Player.GetByID(player.GlobalID);
                        dbPlayer.RoleplayXP -= vm.RPXPDistributing;
                        DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update);
                        vm.IsConfirming     = false;
                        vm.RPXPDistributing = 0;
                    }
                    else
                    {
                        vm.IsConfirming = true;
                    }
                }
                break;
            }

            if (vm.RPXPDistributing > dbPlayer.RoleplayXP)
            {
                vm.RPXPDistributing = dbPlayer.RoleplayXP;
            }
            else if (vm.RPXPDistributing < 0)
            {
                vm.RPXPDistributing = 0;
            }

            LoadDistributeRPXPPage();
        }
예제 #3
0
        private void BuildPerkDetails()
        {
            Model vm = GetDialogCustomData <Model>();

            Data.Entity.Perk perk   = PerkService.GetPerkByID(vm.SelectedPerkID);
            PCPerk           pcPerk = PerkService.GetPCPerkByID(GetPC().GlobalID, perk.ID);
            Player           player = PlayerService.GetPlayerEntity(GetPC().GlobalID);
            var perkLevels          = DataService.Where <PerkLevel>(x => x.PerkID == perk.ID).ToList();

            int       rank             = pcPerk?.PerkLevel ?? 0;
            int       maxRank          = perkLevels.Count();
            string    currentBonus     = "N/A";
            string    nextBonus        = "N/A";
            string    price            = "N/A";
            PerkLevel currentPerkLevel = PerkService.FindPerkLevel(perkLevels, rank);
            PerkLevel nextPerkLevel    = PerkService.FindPerkLevel(perkLevels, rank + 1);

            SetResponseVisible("PerkDetailsPage", 1, PerkService.CanPerkBeUpgraded(GetPC(), vm.SelectedPerkID));

            if (rank > 0)
            {
                if (currentPerkLevel != null)
                {
                    currentBonus = currentPerkLevel.Description;
                }
            }
            if (rank + 1 <= maxRank)
            {
                if (nextPerkLevel != null)
                {
                    nextBonus = nextPerkLevel.Description;
                    price     = nextPerkLevel.Price + " SP (Available: " + player.UnallocatedSP + " SP)";
                }
            }
            var perkCategory     = DataService.Get <PerkCategory>(perk.PerkCategoryID);
            var cooldownCategory = perk.CooldownCategoryID == null ?
                                   null :
                                   DataService.Get <CooldownCategory>(perk.CooldownCategoryID);

            string header = ColorTokenService.Green("Name: ") + perk.Name + "\n" +
                            ColorTokenService.Green("Category: ") + perkCategory.Name + "\n" +
                            ColorTokenService.Green("Rank: ") + rank + " / " + maxRank + "\n" +
                            ColorTokenService.Green("Price: ") + price + "\n" +
                            (perk.BaseFPCost > 0 ? ColorTokenService.Green("FP: ") + perk.BaseFPCost : "") + "\n" +
                            (cooldownCategory != null && cooldownCategory.BaseCooldownTime > 0 ? ColorTokenService.Green("Cooldown: ") + cooldownCategory.BaseCooldownTime + "s" : "") + "\n" +
                            ColorTokenService.Green("Description: ") + perk.Description + "\n" +
                            ColorTokenService.Green("Current Bonus: ") + currentBonus + "\n" +
                            ColorTokenService.Green("Next Bonus: ") + nextBonus + "\n";

            if (nextPerkLevel != null)
            {
                List <PerkLevelSkillRequirement> requirements =
                    DataService.Where <PerkLevelSkillRequirement>(x => x.PerkLevelID == nextPerkLevel.ID).ToList();
                if (requirements.Count > 0)
                {
                    header += "\n" + ColorTokenService.Green("Next Upgrade Skill Requirements:\n\n");

                    bool hasRequirement = false;
                    foreach (PerkLevelSkillRequirement req in requirements)
                    {
                        if (req.RequiredRank > 0)
                        {
                            PCSkill pcSkill = SkillService.GetPCSkill(GetPC(), req.SkillID);
                            Skill   skill   = SkillService.GetSkill(pcSkill.SkillID);

                            string detailLine = skill.Name + " Rank " + req.RequiredRank;

                            if (pcSkill.Rank >= req.RequiredRank)
                            {
                                header += ColorTokenService.Green(detailLine) + "\n";
                            }
                            else
                            {
                                header += ColorTokenService.Red(detailLine) + "\n";
                            }

                            hasRequirement = true;
                        }
                    }

                    if (requirements.Count <= 0 || !hasRequirement)
                    {
                        header += "None\n";
                    }
                }
            }

            SetPageHeader("PerkDetailsPage", header);
        }
예제 #4
0
        private void RunCreateItem(NWPlayer player)
        {
            foreach (var effect in player.Effects)
            {
                if (_.GetEffectTag(effect) == "CRAFTING_IMMOBILIZATION")
                {
                    _.RemoveEffect(player, effect);
                }
            }

            var model = CraftService.GetPlayerCraftingData(player);

            CraftBlueprint blueprint     = DataService.CraftBlueprint.GetByID(model.BlueprintID);
            BaseStructure  baseStructure = blueprint.BaseStructureID == null ? null : DataService.BaseStructure.GetByID(Convert.ToInt32(blueprint.BaseStructureID));
            PCSkill        pcSkill       = SkillService.GetPCSkill(player, blueprint.SkillID);

            int   pcEffectiveLevel = CraftService.CalculatePCEffectiveLevel(player, pcSkill.Rank, (SkillType)blueprint.SkillID);
            int   itemLevel        = model.AdjustedLevel;
            int   atmosphereBonus  = CraftService.CalculateAreaAtmosphereBonus(player.Area);
            float chance           = CalculateBaseChanceToAddProperty(pcEffectiveLevel, itemLevel, atmosphereBonus);
            float equipmentBonus   = CalculateEquipmentBonus(player, (SkillType)blueprint.SkillID);

            if (chance <= 1.0f)
            {
                player.FloatingText(ColorTokenService.Red("Critical failure! You don't have enough skill to create that item. All components were lost."));
                CraftService.ClearPlayerCraftingData(player, true);
                return;
            }

            int    luckyBonus   = PerkService.GetCreaturePerkLevel(player, PerkType.Lucky);
            var    craftedItems = new List <NWItem>();
            NWItem craftedItem  = (_.CreateItemOnObject(blueprint.ItemResref, player.Object, blueprint.Quantity));

            craftedItem.IsIdentified = true;
            craftedItems.Add(craftedItem);

            // If item isn't stackable, loop through and create as many as necessary.
            if (craftedItem.StackSize < blueprint.Quantity)
            {
                for (int x = 2; x <= blueprint.Quantity; x++)
                {
                    craftedItem = (_.CreateItemOnObject(blueprint.ItemResref, player.Object));
                    craftedItem.IsIdentified = true;
                    craftedItems.Add(craftedItem);
                }
            }

            // Recommended level gets set regardless if all item properties make it on the final product.
            // Also mark who crafted the item. This is later used for display on the item's examination event.
            foreach (var item in craftedItems)
            {
                item.RecommendedLevel = itemLevel < 0 ? 0 : itemLevel;
                item.SetLocalString("CRAFTER_PLAYER_ID", player.GlobalID.ToString());

                BaseService.ApplyCraftedItemLocalVariables(item, baseStructure);
            }

            if (RandomService.Random(1, 100) <= luckyBonus)
            {
                chance += RandomService.Random(1, luckyBonus);
            }

            int successAmount = 0;

            foreach (var component in model.MainComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }
            foreach (var component in model.SecondaryComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }
            foreach (var component in model.TertiaryComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }
            foreach (var component in model.EnhancementComponents)
            {
                var result = RunComponentBonusAttempt(player, component, equipmentBonus, chance, craftedItems);
                successAmount += result.Item1;
                chance         = result.Item2;
            }

            // Structures gain increased durability based on the blueprint
            if (baseStructure != null)
            {
                foreach (var item in craftedItems)
                {
                    var maxDur = DurabilityService.GetMaxDurability(item);
                    maxDur += (float)baseStructure.Durability;
                    DurabilityService.SetMaxDurability(item, maxDur);
                    DurabilityService.SetDurability(item, maxDur);
                }
            }

            player.SendMessage("You created " + blueprint.Quantity + "x " + blueprint.ItemName + "!");
            int   baseXP = 750 + successAmount * RandomService.Random(1, 50);
            float xp     = SkillService.CalculateRegisteredSkillLevelAdjustedXP(baseXP, model.AdjustedLevel, pcSkill.Rank);

            bool exists = DataService.PCCraftedBlueprint.ExistsByPlayerIDAndCraftedBlueprintID(player.GlobalID, blueprint.ID);

            if (!exists)
            {
                xp = xp * 1.50f;
                player.SendMessage("You receive an XP bonus for crafting this item for the first time.");

                var pcCraftedBlueprint = new PCCraftedBlueprint
                {
                    CraftBlueprintID = blueprint.ID,
                    DateFirstCrafted = DateTime.UtcNow,
                    PlayerID         = player.GlobalID
                };

                DataService.SubmitDataChange(pcCraftedBlueprint, DatabaseActionType.Insert);
            }

            SkillService.GiveSkillXP(player, blueprint.SkillID, (int)xp);
            CraftService.ClearPlayerCraftingData(player, true);
            player.SetLocalInt("LAST_CRAFTED_BLUEPRINT_ID_" + blueprint.CraftDeviceID, blueprint.ID);
        }
예제 #5
0
        private void BuildPerkDetails()
        {
            Model vm = GetDialogCustomData <Model>();

            Data.Entity.Perk perk   = PerkService.GetPerkByID(vm.SelectedPerkID);
            PCPerk           pcPerk = PerkService.GetPCPerkByID(GetPC().GlobalID, perk.ID);
            Player           player = PlayerService.GetPlayerEntity(GetPC().GlobalID);
            var perkLevels          = DataService.Where <PerkLevel>(x => x.PerkID == perk.ID).ToList();

            int       rank                          = pcPerk?.PerkLevel ?? 0;
            int       maxRank                       = perkLevels.Count();
            string    currentBonus                  = "N/A";
            string    currentFPCost                 = string.Empty;
            string    currentConcentrationCost      = string.Empty;
            string    currentSpecializationRequired = "None";
            string    nextBonus                     = "N/A";
            string    nextFPCost                    = "N/A";
            string    nextConcentrationCost         = string.Empty;
            string    price                         = "N/A";
            string    nextSpecializationRequired    = "None";
            PerkLevel currentPerkLevel              = PerkService.FindPerkLevel(perkLevels, rank);
            PerkLevel nextPerkLevel                 = PerkService.FindPerkLevel(perkLevels, rank + 1);

            SetResponseVisible("PerkDetailsPage", 1, PerkService.CanPerkBeUpgraded(GetPC(), vm.SelectedPerkID));

            // Player has purchased at least one rank in this perk. Show their current bonuses.
            if (rank > 0 && currentPerkLevel != null)
            {
                var currentPerkFeat = DataService.SingleOrDefault <PerkFeat>(x => x.PerkID == vm.SelectedPerkID &&
                                                                             x.PerkLevelUnlocked == currentPerkLevel.Level);
                currentBonus = currentPerkLevel.Description;

                // Not every perk is going to have a perk feat. Don't display this information if not necessary.
                if (currentPerkFeat != null)
                {
                    currentFPCost = currentPerkFeat.BaseFPCost > 0 ? (ColorTokenService.Green("Current FP: ") + currentPerkFeat.BaseFPCost + "\n") : string.Empty;

                    // If this perk level has a concentration cost and interval, display it on the menu.
                    if (currentPerkFeat.ConcentrationFPCost > 0 && currentPerkFeat.ConcentrationTickInterval > 0)
                    {
                        currentConcentrationCost = ColorTokenService.Green("Current Concentration FP: ") + currentPerkFeat.ConcentrationFPCost + " / " + currentPerkFeat.ConcentrationTickInterval + "s\n";
                    }
                }

                // If this perk level has required specialization, change the text to that.
                if (currentPerkLevel.SpecializationID > 0)
                {
                    // Convert ID to enum, then get the string of the enum value. If we ever get a specialization with
                    // more than one word, another process will need to be used.
                    currentSpecializationRequired = ((SpecializationType)currentPerkLevel.SpecializationID).ToString();
                }
            }

            // Player hasn't reached max rank and this perk has another perk level to display.
            if (rank + 1 <= maxRank && nextPerkLevel != null)
            {
                var nextPerkFeat = DataService.SingleOrDefault <PerkFeat>(x => x.PerkID == vm.SelectedPerkID &&
                                                                          x.PerkLevelUnlocked == rank + 1);
                nextBonus = nextPerkLevel.Description;
                price     = nextPerkLevel.Price + " SP (Available: " + player.UnallocatedSP + " SP)";

                if (nextPerkFeat != null)
                {
                    nextFPCost = nextPerkFeat.BaseFPCost > 0 ? (ColorTokenService.Green("Next FP: ") + nextPerkFeat.BaseFPCost + "\n") : string.Empty;

                    // If this perk level has a concentration cost and interval, display it on the menu.
                    if (nextPerkFeat.ConcentrationFPCost > 0 && nextPerkFeat.ConcentrationTickInterval > 0)
                    {
                        nextConcentrationCost = ColorTokenService.Green("Next Concentration FP: ") + nextPerkFeat.ConcentrationFPCost + " / " + nextPerkFeat.ConcentrationTickInterval + "s\n";
                    }
                }

                if (nextPerkLevel.SpecializationID > 0)
                {
                    nextSpecializationRequired = ((SpecializationType)nextPerkLevel.SpecializationID).ToString();
                }
            }
            var perkCategory     = DataService.Get <PerkCategory>(perk.PerkCategoryID);
            var cooldownCategory = perk.CooldownCategoryID == null ?
                                   null :
                                   DataService.Get <CooldownCategory>(perk.CooldownCategoryID);

            string header = ColorTokenService.Green("Name: ") + perk.Name + "\n" +
                            ColorTokenService.Green("Category: ") + perkCategory.Name + "\n" +
                            ColorTokenService.Green("Rank: ") + rank + " / " + maxRank + "\n" +
                            ColorTokenService.Green("Price: ") + price + "\n" +
                            currentFPCost +
                            currentConcentrationCost +
                            (cooldownCategory != null && cooldownCategory.BaseCooldownTime > 0 ? ColorTokenService.Green("Cooldown: ") + cooldownCategory.BaseCooldownTime + "s" : "") + "\n" +
                            ColorTokenService.Green("Description: ") + perk.Description + "\n" +
                            ColorTokenService.Green("Current Bonus: ") + currentBonus + "\n" +
                            ColorTokenService.Green("Requires Specialization: ") + currentSpecializationRequired + "\n" +
                            nextFPCost +
                            nextConcentrationCost +
                            ColorTokenService.Green("Next Bonus: ") + nextBonus + "\n" +
                            ColorTokenService.Green("Requires Specialization: ") + nextSpecializationRequired + "\n";


            if (nextPerkLevel != null)
            {
                List <PerkLevelSkillRequirement> requirements =
                    DataService.Where <PerkLevelSkillRequirement>(x => x.PerkLevelID == nextPerkLevel.ID).ToList();
                if (requirements.Count > 0)
                {
                    header += "\n" + ColorTokenService.Green("Next Upgrade Skill Requirements:\n\n");

                    bool hasRequirement = false;
                    foreach (PerkLevelSkillRequirement req in requirements)
                    {
                        if (req.RequiredRank > 0)
                        {
                            PCSkill pcSkill = SkillService.GetPCSkill(GetPC(), req.SkillID);
                            Skill   skill   = SkillService.GetSkill(pcSkill.SkillID);

                            string detailLine = skill.Name + " Rank " + req.RequiredRank;

                            if (pcSkill.Rank >= req.RequiredRank)
                            {
                                header += ColorTokenService.Green(detailLine) + "\n";
                            }
                            else
                            {
                                header += ColorTokenService.Red(detailLine) + "\n";
                            }

                            hasRequirement = true;
                        }
                    }

                    if (requirements.Count <= 0 || !hasRequirement)
                    {
                        header += "None\n";
                    }
                }
            }

            SetPageHeader("PerkDetailsPage", header);
        }