public bool CanPerkBeUpgraded(Data.Entities.Perk perk, PCPerk pcPerk, PlayerCharacter player) { int rank = pcPerk?.PerkLevel ?? 0; int maxRank = perk.PerkLevels.Count; if (rank + 1 > maxRank) { return(false); } PerkLevel level = FindPerkLevel(perk.PerkLevels, rank + 1); if (level == null) { return(false); } if (player.UnallocatedSP < level.Price) { return(false); } foreach (PerkLevelSkillRequirement req in level.PerkLevelSkillRequirements) { PCSkill pcSkill = _db.PCSkills.Single(x => x.PlayerID == player.PlayerID && x.SkillID == req.SkillID); if (pcSkill.Rank < req.RequiredRank) { return(false); } } return(true); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = NWPlayer.Wrap(user.Object); target.RemoveEffect(EFFECT_TYPE_REGENERATE); PCSkill skill = _skill.GetPCSkill(player, SkillType.FirstAid); int luck = _perk.GetPCPerkLevel(player, PerkType.Lucky); int perkDurationBonus = _perk.GetPCPerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2); float duration = 30.0f + (skill.Rank * 0.4f) + perkDurationBonus; int restoreAmount = 1 + item.GetLocalInt("HEALING_BONUS") + player.EffectiveFirstAidBonus; int perkBlastBonus = _perk.GetPCPerkLevel(player, PerkType.ImmediateImprovement); if (perkBlastBonus > 0) { int blastHeal = restoreAmount * perkBlastBonus; if (_random.Random(100) + 1 <= luck / 2) { blastHeal *= 2; } _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(blastHeal), target.Object); } Effect regeneration = _.EffectRegenerate(restoreAmount, 6.0f); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, regeneration, target.Object, duration); player.SendMessage("You successfully treat " + target.Name + "'s wounds."); int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(100, item.RecommendedLevel, skill.Rank); _skill.GiveSkillXP(player, SkillType.FirstAid, xp); }
public string BuildBlueprintHeader(NWPlayer player, int blueprintID) { CraftBlueprint blueprint = _db.CraftBlueprints.Single(x => x.CraftBlueprintID == blueprintID); PCSkill pcSkill = _db.PCSkills.Single(x => x.PlayerID == player.GlobalID && x.SkillID == blueprint.SkillID); string header = _color.Green("Blueprint: ") + _color.White(blueprint.ItemName) + "\n\n"; header += _color.Green("Skill: ") + _color.White(pcSkill.Skill.Name) + "\n"; header += _color.Green("Base Difficulty: ") + CalculateDifficulty(pcSkill.Rank, blueprint.BaseLevel) + "\n"; header += _color.Green("Max Enhancement Slots: ") + blueprint.EnhancementSlots + "\n\n"; header += _color.Green("Components: ") + "\n\n"; header += _color.White(blueprint.MainMinimum + "x " + blueprint.MainComponentType.Name) + "\n"; if (blueprint.SecondaryComponentTypeID > 0) { header += _color.White(blueprint.SecondaryMinimum + "x " + blueprint.SecondaryComponentType.Name) + "\n"; } if (blueprint.TertiaryComponentTypeID > 0) { header += _color.White(blueprint.TertiaryMinimum + "x " + blueprint.TertiaryComponentType.Name) + "\n"; } return(header); }
public void OnModuleEnter() { NWPlayer oPC = _.GetEnteringObject(); if (oPC.IsPlayer) { // Add any missing skills the player does not have. var skills = _data.Where <Skill>(x => { var pcSkill = _data.SingleOrDefault <PCSkill>(s => s.SkillID == x.ID && s.PlayerID == oPC.GlobalID); return(pcSkill == null); }); foreach (var skill in skills) { var pcSkill = new PCSkill { IsLocked = false, SkillID = skill.ID, PlayerID = oPC.GlobalID, Rank = 0, XP = 0 }; _data.SubmitDataChange(pcSkill, DatabaseActionType.Insert); } ForceEquipFistGlove(oPC); } }
public string BuildBlueprintHeader(NWPlayer player, int blueprintID) { CraftBlueprint blueprint = _db.CraftBlueprints.Single(x => x.CraftBlueprintID == blueprintID); PCSkill pcSkill = _db.PCSkills.Single(x => x.PlayerID == player.GlobalID && x.SkillID == blueprint.SkillID); string header = _color.Green("Blueprint: ") + _color.White(blueprint.ItemName) + "\n\n"; header += _color.Green("Skill: ") + _color.White(pcSkill.Skill.Name) + "\n"; if (blueprint.CraftTierLevel > 0) { header += _color.Green("Required Tool Level: ") + blueprint.CraftTierLevel + "\n"; } header += _color.Green("Difficulty: ") + CalculateDifficulty(pcSkill.Rank, blueprint.Level) + "\n\n"; header += _color.Green("Components: ") + "\n\n"; foreach (CraftBlueprintComponent component in blueprint.CraftBlueprintComponents) { string name = _item.GetNameByResref(component.ItemResref); header += _color.White(component.Quantity + "x " + name) + "\n"; } return(header); }
public void GetAllByPlayerID_TwoPlayers_ReturnsTwoItems() { // Arrange var id = Guid.NewGuid(); var id2 = Guid.NewGuid(); var entity1 = new PCSkill { ID = Guid.NewGuid(), PlayerID = id }; var entity2 = new PCSkill { ID = Guid.NewGuid(), PlayerID = id2 }; var entity3 = new PCSkill { ID = Guid.NewGuid(), PlayerID = id }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity3)); var result = _cache.GetAllByPlayerID(id).ToList(); // Assert Assert.AreEqual(2, result.Count); Assert.AreEqual(entity1.ID, result.ElementAt(0).ID); Assert.AreEqual(entity3.ID, result.ElementAt(1).ID); }
public void RegisterPCToNPCForSkill(NWPlayer pc, NWCreature npc, int skillID) { if (!pc.IsPlayer || !pc.IsValid) { return; } if (npc.IsPlayer || npc.IsDM || !npc.IsValid) { return; } if (skillID <= 0) { return; } PCSkill pcSkill = GetPCSkill(pc, skillID); if (pcSkill == null) { return; } CreatureSkillRegistration reg = GetCreatureSkillRegistration(npc.GlobalID); reg.AddSkillRegistrationPoint(pc, skillID, pcSkill.Rank); }
private void RunCreateItem(NWPlayer oPC, NWPlaceable device) { var model = GetPlayerCraftingData(oPC); CraftBlueprint blueprint = _db.CraftBlueprints.Single(x => x.CraftBlueprintID == model.BlueprintID); PCSkill pcSkill = _db.PCSkills.Single(x => x.PlayerID == oPC.GlobalID && x.SkillID == blueprint.SkillID); int pcEffectiveLevel = CalculatePCEffectiveLevel(oPC, device, pcSkill.Rank); float chance = CalculateBaseChanceToAddProperty(pcEffectiveLevel, model.AdjustedLevel); float equipmentBonus = CalculateEquipmentBonus(oPC, (SkillType)blueprint.SkillID); var craftedItems = new List <NWItem>(); NWItem craftedItem = NWItem.Wrap(_.CreateItemOnObject(blueprint.ItemResref, oPC.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 = NWItem.Wrap(_.CreateItemOnObject(blueprint.ItemResref, oPC.Object)); craftedItem.IsIdentified = true; craftedItems.Add(craftedItem); } } foreach (var component in model.MainComponents) { ComponentBonusType bonus = ComponentBonusType.Unknown; foreach (var ip in component.ItemProperties) { if (_.GetItemPropertyType(ip) == (int)CustomItemPropertyType.ComponentBonus) { bonus = (ComponentBonusType)_.GetItemPropertyCostTableValue(ip); } } if (bonus == ComponentBonusType.Unknown) { continue; } if (_random.RandomFloat() * 100.0f + equipmentBonus <= chance) { foreach (var item in craftedItems) { ApplyComponentBonus(item, bonus); } } } oPC.SendMessage("You created " + blueprint.Quantity + "x " + blueprint.ItemName + "!"); float xp = _skill.CalculateRegisteredSkillLevelAdjustedXP(250, model.AdjustedLevel, pcSkill.Rank); _skill.GiveSkillXP(oPC, blueprint.SkillID, (int)xp); ClearPlayerCraftingData(oPC); }
public void ToggleSkillLock(string playerID, int skillID) { PCSkill pcSkill = GetPCSkillByID(playerID, skillID); pcSkill.IsLocked = !pcSkill.IsLocked; _db.SaveChanges(); }
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)); }
public void ToggleSkillLock(Guid playerID, int skillID) { PCSkill pcSkill = _data.Single <PCSkill>(x => x.PlayerID == playerID && x.SkillID == skillID); pcSkill.IsLocked = !pcSkill.IsLocked; _data.SubmitDataChange(pcSkill, DatabaseActionType.Update); }
public static bool CanPerkBeUpgraded(NWPlayer player, int perkID) { var dbPlayer = DataService.Get <Player>(player.GlobalID); var perkLevels = DataService.Where <PerkLevel>(x => x.PerkID == perkID).ToList(); var pcPerk = DataService.SingleOrDefault <PCPerk>(x => x.PlayerID == player.GlobalID && x.PerkID == perkID); int rank = 0; if (pcPerk != null) { rank = pcPerk.PerkLevel; } int maxRank = perkLevels.Count; if (rank + 1 > maxRank) { return(false); } PerkLevel level = FindPerkLevel(perkLevels, rank + 1); if (level == null) { return(false); } if (dbPlayer.UnallocatedSP < level.Price) { return(false); } var skillRequirements = DataService.Where <PerkLevelSkillRequirement>(x => x.PerkLevelID == level.ID).ToList(); var questRequirements = DataService.Where <PerkLevelQuestRequirement>(x => x.PerkLevelID == level.ID).ToList(); foreach (var req in skillRequirements) { PCSkill pcSkill = DataService.Single <PCSkill>(x => x.PlayerID == dbPlayer.ID && x.SkillID == req.SkillID); if (pcSkill.Rank < req.RequiredRank) { return(false); } } foreach (var req in questRequirements) { var pcQuest = DataService.SingleOrDefault <PCQuestStatus>(x => x.PlayerID == dbPlayer.ID && x.QuestID == req.RequiredQuestID && x.CompletionDate != null); if (pcQuest == null) { return(false); } } return(true); }
public bool Run(params object[] args) { NWPlayer player = NWPlayer.Wrap(Object.OBJECT_SELF); NWPlaceable forge = NWPlaceable.Wrap(player.GetLocalObject("FORGE")); string resref = forge.GetLocalString("FORGE_ORE"); forge.DeleteLocalObject("FORGE_USER"); player.DeleteLocalObject("FORGE"); forge.DeleteLocalString("FORGE_ORE"); player.IsBusy = false; PCSkill pcSkill = _skill.GetPCSkill(player, SkillType.Engineering); int level = _craft.GetIngotLevel(resref); string ingotResref = _craft.GetIngotResref(resref); if (pcSkill == null || level < 0 || string.IsNullOrWhiteSpace(ingotResref)) { return(false); } int delta = pcSkill.Rank - level; int count = 2; if (delta > 2) { count = delta; } if (count > 6) { count = 6; } if (_random.Random(100) + 1 <= _perk.GetPCPerkLevel(player, PerkType.Lucky)) { count++; } if (_random.Random(100) + 1 <= _perk.GetPCPerkLevel(player, PerkType.ProcessingEfficiency) * 10) { count++; } for (int x = 1; x <= count; x++) { _.CreateItemOnObject(ingotResref, player.Object); } int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(100, level, pcSkill.Rank); _skill.GiveSkillXP(player, SkillType.Engineering, xp); if (_random.Random(100) + 1 <= 3) { _food.DecreaseHungerLevel(player, 1); } return(true); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { int growingPlantID = target.GetLocalInt("GROWING_PLANT_ID"); if (growingPlantID <= 0) { user.SendMessage("Water jugs can only target growing plants."); return; } GrowingPlant growingPlant = _db.GrowingPlants.Single(x => x.GrowingPlantID == growingPlantID); if (growingPlant.WaterStatus <= 0) { user.SendMessage("That plant doesn't need to be watered at this time."); return; } if (item.Charges <= 0) { user.SendMessage("There's no water in that jug!"); return; } PlayerCharacter pcEntity = _db.PlayerCharacters.Single(x => x.PlayerID == user.GlobalID); // Farmers get a 5% chance to not expend a charge. if (pcEntity.BackgroundID != (int)BackgroundType.Farmer || _random.Random(100) + 1 > 5) { item.Charges--; } int remainingTicks = growingPlant.RemainingTicks; if (growingPlant.WaterStatus > 1) { remainingTicks = remainingTicks / 2; } growingPlant.WaterStatus = 0; growingPlant.RemainingTicks = remainingTicks; _db.SaveChanges(); user.SendMessage("You water the plant."); PCSkill pcSkill = _skill.GetPCSkill((NWPlayer)user, SkillType.Farming); if (pcSkill == null) { return; } int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(100, growingPlant.Plant.Level, pcSkill.Rank); _skill.GiveSkillXP((NWPlayer)user, SkillType.Farming, xp); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { _customEffect.RemovePCCustomEffect((NWPlayer)target, CustomEffectType.Bleeding); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(2), target.Object); user.SendMessage("You finish bandaging " + target.Name + "'s wounds."); PCSkill skill = _skill.GetPCSkill((NWPlayer)user, SkillType.FirstAid); int xp = (int)_skill.CalculateSkillAdjustedXP(100, item.RecommendedLevel, skill.Rank); _skill.GiveSkillXP((NWPlayer)user, SkillType.FirstAid, xp); }
public float Seconds(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { if (_random.Random(100) + 1 <= _perk.GetPCPerkLevel((NWPlayer)user, PerkType.SpeedyMedic) * 10) { return(0.1f); } PCSkill skill = _skill.GetPCSkill((NWPlayer)user, SkillType.FirstAid); return(12.0f - (skill.Rank * 0.1f)); }
private int CalculateBAB(NWPlayer oPC, NWItem ignoreItem) { NWItem weapon = oPC.RightHand; // The unequip event fires before the item is actually unequipped, so we need // to have additional checks to make sure we're not getting the weapon that's about to be // unequipped. if (weapon.Equals(ignoreItem)) { weapon = null; NWItem offHand = oPC.LeftHand; if (offHand.CustomItemType == CustomItemType.Blade || offHand.CustomItemType == CustomItemType.FinesseBlade || offHand.CustomItemType == CustomItemType.Blunt || offHand.CustomItemType == CustomItemType.HeavyBlade || offHand.CustomItemType == CustomItemType.HeavyBlunt || offHand.CustomItemType == CustomItemType.Polearm || offHand.CustomItemType == CustomItemType.TwinBlade || offHand.CustomItemType == CustomItemType.MartialArtWeapon || offHand.CustomItemType == CustomItemType.Bow || offHand.CustomItemType == CustomItemType.Crossbow || offHand.CustomItemType == CustomItemType.Throwing) { weapon = offHand; } } if (weapon == null || !weapon.IsValid) { weapon = oPC.Arms; } if (!weapon.IsValid) { return(0); } int weaponSkillID = GetWeaponSkillID(weapon); PCSkill skill = GetPCSkill(oPC, weaponSkillID); if (skill == null) { return(0); } int skillBAB = skill.Rank / 10; int perkBAB = 0; if (weaponSkillID == (int)SkillType.Throwing) { perkBAB += _perk.GetPCPerkLevel(oPC, PerkType.TossAccuracy); } return(1 + skillBAB + perkBAB); // Note: Always add 1 to BAB. 0 will cause a crash in NWNX. }
public float Seconds(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = NWPlayer.Wrap(user.Object); if (_random.Random(100) + 1 <= _perk.GetPCPerkLevel(player, PerkType.SpeedyMedic) * 10) { return(0.1f); } PCSkill skill = _skill.GetPCSkill(player, SkillType.FirstAid); return(12.0f - (skill.Rank + player.EffectiveFirstAidBonus / 2) * 0.1f); }
private void LoadBlueprintListPageResponses() { Model model = GetDialogCustomData <Model>(); ClearPageResponses("BlueprintListPage"); Location location = GetDialogTarget().Location; PCSkill pcSkill = _skill.GetPCSkill(GetPC(), SkillType.Construction); if (pcSkill == null) { return; } PCTerritoryFlag flag = _structure.GetPCTerritoryFlagByID(model.FlagID); TerritoryStructureCount counts = _structure.GetNumberOfStructuresInTerritory(model.FlagID); List <StructureBlueprint> blueprints = _structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, false, false, false); // Territory markers if (flag != null && counts.VanityCount < flag.StructureBlueprint.VanityCount) { blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, true, false, false, false)); // Vanity } if (flag != null && counts.SpecialCount < flag.StructureBlueprint.SpecialCount) { blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, true, false, false)); // Special } if (flag != null && counts.ResourceCount < flag.StructureBlueprint.ResourceCount) { blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, false, true, false)); // Resource } if (flag != null && counts.BuildingCount < flag.StructureBlueprint.BuildingCount) { blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, false, false, true)); // Building } foreach (StructureBlueprint entity in blueprints) { string entityName = entity.Name + " (Lvl. " + entity.Level + ")"; if (model.IsTerritoryFlag) { if (_structure.WillBlueprintOverlapWithExistingFlags(location, entity.StructureBlueprintID)) { entityName = _color.Red(entityName + " [OVERLAPS]"); } } AddResponseToPage("BlueprintListPage", entityName, entity.IsActive, new Tuple <string, dynamic>(string.Empty, entity.StructureBlueprintID)); } AddResponseToPage("BlueprintListPage", "Back"); }
public void GetByID_OneItem_ReturnsPCSkill() { // Arrange var id = Guid.NewGuid(); PCSkill entity = new PCSkill { ID = id }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity)); // Assert Assert.AreNotSame(entity, _cache.GetByID(id)); }
private void LoadSkillDetails() { Model vm = GetDialogCustomData <Model>(); Skill skill = _skill.GetSkill(vm.SelectedSkillID); PCSkill pcSkill = _skill.GetPCSkill(GetPC(), vm.SelectedSkillID); SkillXPRequirement req = _data.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); } }
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); } }
public void GetByID_TwoItems_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); PCSkill entity1 = new PCSkill { ID = id1 }; PCSkill entity2 = new PCSkill { ID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity2)); // Assert Assert.AreNotSame(entity1, _cache.GetByID(id1)); Assert.AreNotSame(entity2, _cache.GetByID(id2)); }
public void GetByID_RemovedItem_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); PCSkill entity1 = new PCSkill { ID = id1 }; PCSkill entity2 = new PCSkill { ID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkill>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <PCSkill>(entity1)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(id1); }); Assert.AreNotSame(entity2, _cache.GetByID(id2)); }
private void HandleSkillListResponse(int responseID) { DialogResponse response = GetResponseByID("SkillListPage", responseID); int skillID = (int)response.CustomData[string.Empty]; if (skillID == -1) { ChangePage("CategoryPage"); return; } PCSkill pcSkill = _skill.GetPCSkillByID(GetPC().GlobalID, skillID); string header = "Are you sure you want to improve your " + pcSkill.Skill.Name + " skill?"; SetPageHeader("ConfirmPage", header); Model vm = GetDialogCustomData <Model>(); vm.SkillID = skillID; SetDialogCustomData(vm); ChangePage("ConfirmPage"); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { _customEffect.RemovePCCustomEffect((NWPlayer)target, CustomEffectType.Poison); foreach (Effect effect in target.Effects) { if (_.GetIsEffectValid(effect) == TRUE) { int effectType = _.GetEffectType(effect); if (effectType == EFFECT_TYPE_POISON || effectType == EFFECT_TYPE_DISEASE) { _.RemoveEffect(target.Object, effect); } } } user.SendMessage("You successfully treat " + target.Name + "'s infection."); PCSkill skill = _skill.GetPCSkill((NWPlayer)user, SkillType.FirstAid); int xp = (int)_skill.CalculateSkillAdjustedXP(100, item.RecommendedLevel, skill.Rank); _skill.GiveSkillXP((NWPlayer)user, SkillType.FirstAid, xp); }
public bool Run(params object[] args) { NWPlaceable point = NWPlaceable.Wrap(Object.OBJECT_SELF); const int baseChanceToFullyHarvest = 50; bool alwaysDestroys = point.GetLocalInt("FORAGE_POINT_ALWAYS_DESTROYS") == 1; NWPlayer oPC = NWPlayer.Wrap(_.GetLastOpenedBy()); bool hasBeenSearched = point.GetLocalInt("FORAGE_POINT_FULLY_HARVESTED") == 1; if (hasBeenSearched) { oPC.SendMessage("There's nothing left to harvest here..."); return(true); } // Not fully harvested but the timer hasn't counted down yet. int refillTick = point.GetLocalInt("FORAGE_POINT_REFILL_TICKS"); if (refillTick > 0) { oPC.SendMessage("You couldn't find anything new here. Check back later..."); return(true); } if (!oPC.IsPlayer && !oPC.IsDM) { return(false); } PCSkill pcSkill = _skill.GetPCSkill(oPC, SkillType.Forage); if (pcSkill == null) { return(false); } int lootTableID = point.GetLocalInt("FORAGE_POINT_LOOT_TABLE_ID"); int level = point.GetLocalInt("FORAGE_POINT_LEVEL"); int rank = pcSkill.Rank; int delta = level - rank; if (delta > 8) { oPC.SendMessage("You aren't skilled enough to forage through this. (Required Level: " + (level - 8) + ")"); oPC.AssignCommand(() => _.ActionInteractObject(point.Object)); return(true); } int dc = 6 + delta; if (dc <= 4) { dc = 4; } int searchAttempts = 1 + CalculateSearchAttempts(oPC); int luck = _perk.GetPCPerkLevel(oPC, PerkType.Lucky) + oPC.EffectiveLuckBonus; if (_random.Random(100) + 1 <= luck / 2) { dc--; } oPC.AssignCommand(() => _.ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0f, 2.0f)); for (int attempt = 1; attempt <= searchAttempts; attempt++) { int roll = _random.Random(20) + 1; if (roll >= dc) { oPC.FloatingText(_color.SkillCheck("Search: *success*: (" + roll + " vs. DC: " + dc + ")")); ItemVO spawnItem = _loot.PickRandomItemFromLootTable(lootTableID); if (spawnItem == null) { return(false); } if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0) { _.CreateItemOnObject(spawnItem.Resref, point.Object, spawnItem.Quantity); } float xp = _skill.CalculateRegisteredSkillLevelAdjustedXP(50, level, rank); _skill.GiveSkillXP(oPC, SkillType.Forage, (int)xp); } else { oPC.FloatingText(_color.SkillCheck("Search: *failure*: (" + roll + " vs. DC: " + dc + ")")); float xp = _skill.CalculateRegisteredSkillLevelAdjustedXP(10, level, rank); _skill.GiveSkillXP(oPC, SkillType.Forage, (int)xp); } dc += _random.Random(3) + 1; } if (_random.Random(100) + 1 <= 3) { _food.DecreaseHungerLevel(oPC, 1); } // Chance to destroy the forage point. int chanceToFullyHarvest = baseChanceToFullyHarvest - (_perk.GetPCPerkLevel(oPC, PerkType.CarefulForager) * 5); int growingPlantID = point.GetLocalInt("GROWING_PLANT_ID"); if (growingPlantID > 0) { Data.Entities.GrowingPlant growingPlant = _farming.GetGrowingPlantByID(growingPlantID); chanceToFullyHarvest = chanceToFullyHarvest - (growingPlant.LongevityBonus); } if (chanceToFullyHarvest <= 5) { chanceToFullyHarvest = 5; } if (alwaysDestroys || _random.Random(100) + 1 <= chanceToFullyHarvest) { point.SetLocalInt("FORAGE_POINT_FULLY_HARVESTED", 1); oPC.SendMessage("This resource has been fully harvested..."); } // Otherwise the forage point will be refilled in 10-20 minutes. else { point.SetLocalInt("FORAGE_POINT_REFILL_TICKS", 100 + _random.Random(100)); } point.SetLocalInt("FORAGE_POINT_DESPAWN_TICKS", 30); return(true); }
private void BuildPerkDetails() { Model vm = GetDialogCustomData <Model>(); Data.Entity.Perk perk = _perk.GetPerkByID(vm.SelectedPerkID); PCPerk pcPerk = _perk.GetPCPerkByID(GetPC().GlobalID, perk.ID); Player player = _player.GetPlayerEntity(GetPC().GlobalID); var perkLevels = _data.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 = _perk.FindPerkLevel(perkLevels, rank); PerkLevel nextPerkLevel = _perk.FindPerkLevel(perkLevels, rank + 1); SetResponseVisible("PerkDetailsPage", 1, _perk.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 = _data.Get <PerkCategory>(perk.PerkCategoryID); var cooldownCategory = perk.CooldownCategoryID == null ? null : _data.Get <CooldownCategory>(perk.CooldownCategoryID); string header = _color.Green("Name: ") + perk.Name + "\n" + _color.Green("Category: ") + perkCategory.Name + "\n" + _color.Green("Rank: ") + rank + " / " + maxRank + "\n" + _color.Green("Price: ") + price + "\n" + (perk.BaseFPCost > 0 ? _color.Green("FP: ") + perk.BaseFPCost : "") + "\n" + (cooldownCategory != null && cooldownCategory.BaseCooldownTime > 0 ? _color.Green("Cooldown: ") + cooldownCategory.BaseCooldownTime + "s" : "") + "\n" + _color.Green("Description: ") + perk.Description + "\n" + _color.Green("Current Bonus: ") + currentBonus + "\n" + _color.Green("Next Bonus: ") + nextBonus + "\n"; if (nextPerkLevel != null) { List <PerkLevelSkillRequirement> requirements = _data.Where <PerkLevelSkillRequirement>(x => x.PerkLevelID == nextPerkLevel.ID).ToList(); if (requirements.Count > 0) { header += "\n" + _color.Green("Next Upgrade Skill Requirements:\n\n"); bool hasRequirement = false; foreach (PerkLevelSkillRequirement req in requirements) { if (req.RequiredRank > 0) { PCSkill pcSkill = _skill.GetPCSkill(GetPC(), req.SkillID); Skill skill = _skill.GetSkill(pcSkill.SkillID); string detailLine = skill.Name + " Rank " + req.RequiredRank; if (pcSkill.Rank >= req.RequiredRank) { header += _color.Green(detailLine) + "\n"; } else { header += _color.Red(detailLine) + "\n"; } hasRequirement = true; } } if (requirements.Count <= 0 || !hasRequirement) { header += "None\n"; } } } SetPageHeader("PerkDetailsPage", header); }
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(); }
private string CreateSkillDetailsHeader(PCSkill pcSkill, int req) { Player player = DataService.Player.GetByID(pcSkill.PlayerID); 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"; } string rpXP = ColorTokenService.Green("Roleplay XP: ") + player.RoleplayXP + "\n"; Attribute primaryAttribute = DataService.Attribute.GetByID(skill.Primary); Attribute secondaryAttribute = DataService.Attribute.GetByID(skill.Secondary); Attribute tertiaryAttribute = DataService.Attribute.GetByID(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"; return (ColorTokenService.Green("Skill: ") + skill.Name + "\n" + ColorTokenService.Green("Rank: ") + title + "\n" + ColorTokenService.Green("Exp: ") + MenuService.BuildBar(pcSkill.XP, req, 100, ColorTokenService.TokenStart(255, 127, 0)) + "\n" + rpXP + primary + secondary + tertiary + noContributeMessage + decayLock + "\n\n" + ColorTokenService.Green("Description: ") + skill.Description + "\n"); }