public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { if (!target.IsValid) { return("Please select a target to harvest."); } int qualityID = target.GetLocalInt("RESOURCE_QUALITY"); if (qualityID <= 0) { return("You cannot harvest that object."); } NWPlayer player = (user.Object); ResourceQuality quality = (ResourceQuality)qualityID; int tier = target.GetLocalInt("RESOURCE_TIER"); int rank = SkillService.GetPCSkillRank(player, SkillType.Harvesting); int difficulty = (tier - 1) * 10 + ResourceService.GetDifficultyAdjustment(quality); int delta = difficulty - rank; if (delta >= 5) { return("Your Harvesting skill rank is too low to harvest this resource."); } return(null); }
public void Run(NWObject target, params object[] args) { int roll = RandomService.Random(0, 100); ResourceQuality quality = ResourceQuality.Low; string qualityName = "Low Quality"; const int NormalQualityChance = 20; const int HighQualityChance = 10; const int VeryHighQualityChance = 2; var dbArea = DataService.Single <Area>(x => x.Resref == target.Area.Resref); int tier = dbArea.ResourceQuality; int maxTier = dbArea.MaxResourceQuality; if (tier <= 0) { Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources."); return; } if (roll <= VeryHighQualityChance) { quality = ResourceQuality.VeryHigh; qualityName = "Very High Quality"; } else if (roll <= HighQualityChance) { quality = ResourceQuality.High; qualityName = "High Quality"; } else if (roll <= NormalQualityChance) { quality = ResourceQuality.Normal; qualityName = "Normal Quality"; } roll = RandomService.Random(0, 100); if (roll <= 2) { tier++; } if (tier > 10) { tier = 10; } if (tier > maxTier) { tier = maxTier; } target.SetLocalInt("RESOURCE_QUALITY", (int)quality); target.SetLocalInt("RESOURCE_TIER", tier); target.SetLocalInt("RESOURCE_COUNT", RandomService.Random(3, 10)); target.SetLocalString("RESOURCE_RESREF", GetResourceResref(tier)); target.SetLocalString("RESOURCE_QUALITY_NAME", qualityName); }
public int CalculateChanceForComponentBonus(NWPlayer player, int tier, ResourceQuality quality) { int rank = _skill.GetPCSkillRank(player, SkillType.Harvesting); int difficulty = (tier - 1) * 10 + GetDifficultyAdjustment(quality); int delta = difficulty - rank; if (delta >= 7) { return(0); } if (delta <= -7) { return(45); } int chance = 0; switch (delta) { case 6: chance = 1; break; case 5: chance = 2; break; case 4: chance = 3; break; case 3: chance = 6; break; case 2: chance = 9; break; case 1: chance = 12; break; case 0: chance = 15; break; case -1: chance = 18; break; case -2: chance = 20; break; case -3: chance = 21; break; case -4: chance = 23; break; case -5: chance = 25; break; case -6: chance = 27; break; } var effectiveStats = _playerStat.GetPlayerItemEffectiveStats(player); int itemBonus = effectiveStats.Harvesting / 2; if (itemBonus > 30) { itemBonus = 30; } chance += itemBonus; return(chance); }
public int GetDifficultyAdjustment(ResourceQuality quality) { switch (quality) { case ResourceQuality.Low: return(-1); case ResourceQuality.Normal: return(0); case ResourceQuality.High: return(1); case ResourceQuality.VeryHigh: return(2); default: throw new ArgumentOutOfRangeException(nameof(quality), quality, null); } }
public void Run(NWObject target, params object[] args) { int retrievalRating = (int)args[0]; int highQualityChance = 10 * retrievalRating; int veryHighQualityChance = 2 * retrievalRating; int roll = _random.Random(0, 100); ResourceQuality quality = ResourceQuality.Normal; if (roll <= veryHighQualityChance) { quality = ResourceQuality.VeryHigh; } else if (roll <= highQualityChance) { quality = ResourceQuality.High; } var ip = _resource.GetRandomComponentBonusIP(quality); _biowareXP2.IPSafeAddItemProperty(target.Object, ip.Item1, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true); switch (ip.Item2) { case 0: target.Name = _color.Green(target.Name); break; case 1: target.Name = _color.Blue(target.Name); break; case 2: target.Name = _color.Purple(target.Name); break; case 3: target.Name = _color.Orange(target.Name); break; } }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = user.Object; ResourceQuality quality = (ResourceQuality)target.GetLocalInt("RESOURCE_QUALITY"); int tier = target.GetLocalInt("RESOURCE_TIER"); int remaining = target.GetLocalInt("RESOURCE_COUNT") - 1; string itemResref = target.GetLocalString("RESOURCE_RESREF"); int gemChance = ResourceService.CalculateChanceForComponentBonus(player, tier, quality); int roll = RandomService.Random(1, 100); int rank = SkillService.GetPCSkillRank(player, SkillType.Harvesting); if (item.RecommendedLevel < rank) { rank = item.RecommendedLevel; } int difficulty = (tier - 1) * 10 + ResourceService.GetDifficultyAdjustment(quality); int delta = difficulty - rank; int baseXP = 0; if (delta >= 6) { baseXP = 400; } else if (delta == 5) { baseXP = 350; } else if (delta == 4) { baseXP = 325; } else if (delta == 3) { baseXP = 300; } else if (delta == 2) { baseXP = 250; } else if (delta == 1) { baseXP = 225; } else if (delta == 0) { baseXP = 200; } else if (delta == -1) { baseXP = 150; } else if (delta == -2) { baseXP = 100; } else if (delta == -3) { baseXP = 50; } else if (delta == -4) { baseXP = 25; } int itemHarvestBonus = item.HarvestingBonus; int scanningBonus = user.GetLocalInt(target.GlobalID.ToString()); gemChance += itemHarvestBonus * 2 + scanningBonus * 2; baseXP = baseXP + scanningBonus * 5; // Spawn the normal resource. NWItem resource = CreateItemOnObject(itemResref, player); user.SendMessage("You harvest " + resource.Name + "."); // If player meets the chance to acquire a gem, create one and modify its properties. if (quality > ResourceQuality.Low && roll <= gemChance) { // Gemstone quality is determined by the quality of the vein. switch (quality) { case ResourceQuality.Normal: resource = CreateItemOnObject("flawed_gemstone", player); break; case ResourceQuality.High: resource = CreateItemOnObject("gemstone", player); break; case ResourceQuality.VeryHigh: resource = CreateItemOnObject("perfect_gemstone", player); break; } var ip = ResourceService.GetRandomComponentBonusIP(quality); BiowareXP2.IPSafeAddItemProperty(resource, ip.Item1, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true); switch (ip.Item2) { case 0: resource.Name = ColorTokenService.Green(resource.Name); break; case 1: resource.Name = ColorTokenService.Blue(resource.Name); break; case 2: resource.Name = ColorTokenService.Purple(resource.Name); break; case 3: resource.Name = ColorTokenService.Orange(resource.Name); break; case 4: resource.Name = ColorTokenService.LightPurple(resource.Name); break; case 5: resource.Name = ColorTokenService.Yellow(resource.Name); break; case 6: resource.Name = ColorTokenService.Red(resource.Name); break; case 7: resource.Name = ColorTokenService.Cyan(resource.Name); break; } user.SendMessage("You harvest " + resource.Name + "."); } float decayMinimum = 0.03f; float decayMaximum = 0.07f; if (delta > 0) { decayMinimum += delta * 0.1f; decayMaximum += delta * 0.1f; } DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(decayMinimum, decayMaximum)); int xp = baseXP; SkillService.GiveSkillXP(player, SkillType.Harvesting, xp); if (remaining <= 0) { NWPlaceable prop = target.GetLocalObject("RESOURCE_PROP_OBJ"); if (prop.IsValid) { prop.Destroy(); } target.Destroy(); user.DeleteLocalInt(target.GlobalID.ToString()); } else { target.SetLocalInt("RESOURCE_COUNT", remaining); } ApplyEffectAtLocation(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Fnf_Summon_Monster_3), target.Location); }
public void Run(NWObject target, params object[] args) { int roll = RandomService.Random(0, 100); ResourceQuality quality = ResourceQuality.Low; string qualityName = "Low Quality"; var dbArea = DataService.Area.GetByResref(target.Area.Resref); int tier = dbArea.ResourceQuality; int maxTier = dbArea.MaxResourceQuality; if (tier <= 0) { Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources."); return; } int NormalQualityChance; int HighQualityChance; int VeryHighQualityChance; switch (tier) { case 1: NormalQualityChance = 20; HighQualityChance = 0; VeryHighQualityChance = 0; break; case 2: NormalQualityChance = 20; HighQualityChance = 2; VeryHighQualityChance = 0; break; case 3: case 4: case 5: NormalQualityChance = 20; HighQualityChance = 2; VeryHighQualityChance = 1; break; case 6: case 7: case 8: NormalQualityChance = 20; HighQualityChance = 10; VeryHighQualityChance = 3; break; case 9: case 10: NormalQualityChance = 20; HighQualityChance = 12; VeryHighQualityChance = 5; break; default: NormalQualityChance = 0; HighQualityChance = 0; VeryHighQualityChance = 0; break; } if (roll <= VeryHighQualityChance) { quality = ResourceQuality.VeryHigh; qualityName = "Very High Quality"; } else if (roll <= HighQualityChance) { quality = ResourceQuality.High; qualityName = "High Quality"; } else if (roll <= NormalQualityChance) { quality = ResourceQuality.Normal; qualityName = "Normal Quality"; } roll = RandomService.Random(0, 100); if (roll <= 3) { tier++; } if (tier > 10) { tier = 10; } if (tier > maxTier) { tier = maxTier; } target.SetLocalInt("RESOURCE_QUALITY", (int)quality); target.SetLocalInt("RESOURCE_TIER", tier); target.SetLocalInt("RESOURCE_COUNT", RandomService.Random(3, 10)); target.SetLocalString("RESOURCE_RESREF", GetResourceResref(tier)); target.SetLocalString("RESOURCE_QUALITY_NAME", qualityName); }
public void Run(NWObject target, params object[] args) { int roll = _random.Random(0, 100); ResourceQuality quality = ResourceQuality.Low; string qualityName = "Sparse"; const int NormalQualityChance = 20; const int HighQualityChance = 10; const int VeryHighQualityChance = 2; var dbArea = _data.Single <Area>(x => x.Resref == target.Area.Resref); int tier = dbArea.ResourceQuality; int maxTier = dbArea.MaxResourceQuality; if (tier <= 0) { Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources."); return; } if (roll <= VeryHighQualityChance) { quality = ResourceQuality.VeryHigh; qualityName = "Very Dense"; } else if (roll <= HighQualityChance) { quality = ResourceQuality.High; qualityName = "Dense"; } else if (roll <= NormalQualityChance) { quality = ResourceQuality.Normal; qualityName = "Thick"; } roll = _random.Random(0, 100); if (roll <= 3) { tier++; } if (tier > 10) { tier = 10; } if (tier > maxTier) { tier = maxTier; } string resref = GetResourceResref(tier); int quantity = _random.Random(3, 10); roll = _random.Random(0, 100); if (roll <= 2) { string[] coloredResrefs = { "p_crystal_red", "p_crystal_green", "p_crystal_blue", "p_crystal_yellow" }; roll = _random.Random(0, 3); resref = coloredResrefs[roll]; } target.SetLocalInt("RESOURCE_QUALITY", (int)quality); target.SetLocalInt("RESOURCE_TIER", tier); target.SetLocalInt("RESOURCE_COUNT", quantity); target.SetLocalString("RESOURCE_RESREF", resref); target.SetLocalString("RESOURCE_QUALITY_NAME", qualityName); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = user.Object; ResourceQuality quality = (ResourceQuality)target.GetLocalInt("RESOURCE_QUALITY"); int tier = target.GetLocalInt("RESOURCE_TIER"); int remaining = target.GetLocalInt("RESOURCE_COUNT") - 1; string itemResref = target.GetLocalString("RESOURCE_RESREF"); int ipBonusChance = _resource.CalculateChanceForComponentBonus(player, tier, quality); int roll = _random.Random(1, 100); int rank = _skill.GetPCSkillRank(player, SkillType.Harvesting); if (item.RecommendedLevel < rank) { rank = item.RecommendedLevel; } int difficulty = (tier - 1) * 10 + _resource.GetDifficultyAdjustment(quality); int delta = difficulty - rank; int baseXP = 0; if (delta >= 6) { baseXP = 400; } else if (delta == 5) { baseXP = 350; } else if (delta == 4) { baseXP = 325; } else if (delta == 3) { baseXP = 300; } else if (delta == 2) { baseXP = 250; } else if (delta == 1) { baseXP = 225; } else if (delta == 0) { baseXP = 200; } else if (delta == -1) { baseXP = 150; } else if (delta == -2) { baseXP = 100; } else if (delta == -3) { baseXP = 50; } else if (delta == -4) { baseXP = 25; } int itemHarvestBonus = item.HarvestingBonus; int scanningBonus = user.GetLocalInt(target.GlobalID.ToString()); ipBonusChance += itemHarvestBonus * 2 + scanningBonus * 2; baseXP = baseXP + scanningBonus * 5; NWItem resource = _.CreateItemOnObject(itemResref, player.Object); if (roll <= ipBonusChance) { var ip = _resource.GetRandomComponentBonusIP(quality); _biowareXP2.IPSafeAddItemProperty(resource, ip.Item1, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true); switch (ip.Item2) { case 0: resource.Name = _color.Green(resource.Name); break; case 1: resource.Name = _color.Blue(resource.Name); break; case 2: resource.Name = _color.Purple(resource.Name); break; case 3: resource.Name = _color.Orange(resource.Name); break; } } float decayMinimum = 0.03f; float decayMaximum = 0.07f; if (delta > 0) { decayMinimum += delta * 0.1f; decayMaximum += delta * 0.1f; } user.SendMessage("You harvest " + resource.Name + "."); _durability.RunItemDecay(player, item, _random.RandomFloat(decayMinimum, decayMaximum)); int xp = baseXP; _skill.GiveSkillXP(player, SkillType.Harvesting, xp); if (remaining <= 0) { NWPlaceable prop = target.GetLocalObject("RESOURCE_PROP_OBJ"); if (prop.IsValid) { prop.Destroy(); } target.Destroy(); user.DeleteLocalInt(target.GlobalID.ToString()); } else { target.SetLocalInt("RESOURCE_COUNT", remaining); } _.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3), target.Location); }
public Tuple <ItemProperty, int> GetRandomComponentBonusIP(ResourceQuality quality) { string[] commonIP = { "compbon_ac1", "compbon_arm1", "compbon_cspd1", "compbon_charges1", "compbon_charges2", "compbon_cooking1", "compbon_dmg1", "compbon_dkdown1", "compbon_dkup1", "compbon_dur1", "compbon_dur2", "compbon_eng1", "compbon_enmdown1", "compbon_harv1", "compbon_wpn1", "compbon_hp1", "compbon_fp1", "compbon_enmup1", "compbon_med1", "compbon_faid1", "compbon_fab1", "compbon_scanup1", "compbon_rest1", "compbon_ab1" }; string[] uncommonIP = { "compbon_ac2", "compbon_arm2", "compbon_cspd2", "compbon_charges3", "compbon_cooking2", "compbon_dmg2", "compbon_dkdown2", "compbon_dkup2", "compbon_dur3", "compbon_eng2", "compbon_enmdown2", "compbon_harv2", "compbon_wpn2", "compbon_hp2", "compbon_fp2", "compbon_enmup2", "compbon_luck1", "compbon_med2", "compbon_faid2", "compbon_hpregen1", "compbon_fpregen1", "compbon_snkatk1", "compbon_fab2", "compbon_scanup2", "compbon_rest2", "compbon_str1", "compbon_dex1", "compbon_con1", "compbon_wis1", "compbon_int1", "compbon_cha1", "compbon_ab2" }; string[] rareIP = { "compbon_ac3", "compbon_arm3", "compbon_cspd3", "compbon_cooking3", "compbon_dmg3", "compbon_dkdown3", "compbon_dkup3", "compbon_eng3", "compbon_enmdown3", "compbon_harv3", "compbon_wpn3", "compbon_hp3", "compbon_fp3", "compbon_enmup3", "compbon_luck2", "compbon_med3", "compbon_faid3", "compbon_hpregen2", "compbon_fpregen2", "compbon_snkatk2", "compbon_fab3", "compbon_scanup3", "compbon_rest3", "compbon_str2", "compbon_dex2", "compbon_con2", "compbon_wis2", "compbon_int2", "compbon_cha2", "compbon_ab3" }; string[] ultraRareIP = { "compbon_luck3", "compbon_hpregen3", "compbon_fpregen3", "compbon_snkatk3", "compbon_str3", "compbon_dex3", "compbon_con3", "compbon_wis3", "compbon_int3", "compbon_cha3", }; // Order: Common, Uncommon, Rare, Ultra Rare int[] chance; switch (quality) { case ResourceQuality.Low: chance = new[] { 100, 0, 0, 0 }; break; case ResourceQuality.Normal: chance = new[] { 80, 20, 0, 0 }; break; case ResourceQuality.High: chance = new[] { 20, 40, 40, 0 }; break; case ResourceQuality.VeryHigh: chance = new[] { 0, 0, 70, 30 }; break; default: throw new ArgumentOutOfRangeException(nameof(quality)); } string[] setToUse = null; int index = _random.GetRandomWeightedIndex(chance); switch (index) { case 0: setToUse = commonIP; break; case 1: setToUse = uncommonIP; break; case 2: setToUse = rareIP; break; case 3: setToUse = ultraRareIP; break; } if (setToUse == null) { throw new NullReferenceException(nameof(setToUse)); } index = _random.Random(0, setToUse.Length - 1); string itemTag = setToUse[index]; return(new Tuple <ItemProperty, int>(_item.GetCustomItemPropertyByItemTag(itemTag), index)); }
public static Tuple <ItemProperty, int> GetRandomComponentBonusIP(ResourceQuality quality) { string[] normalIP = { "compbon_arm1", // Armorsmith 1 "compbon_cspd1", // Cooldown Recovery 1 "compbon_charges1", // Charges 1 //"compbon_cooking1", // Cooking 1 "compbon_dmg1", // Damage 1 "compbon_eng1", // Engineering 1 "compbon_enmdown1", // Enmity Down 1 "compbon_harv1", // Harvesting 1 "compbon_wpn1", // Weaponsmith 1 "compbon_hp2", // Hit Points 2 "compbon_fp2", // Force Points 2 "compbon_enmup1", // Enmity Up 1 "compbon_med1", // Meditate 1 "compbon_faid1", // Medicine 1 "compbon_fab1", // Fabrication 1 "compbon_scanup1", // Scanning 1 "compbon_rest1", // Rest 1 "compbon_ab1" // Attack Bonus 1 }; string[] highIP = { "compbon_arm2", // Armorsmith 2 "compbon_cspd2", // Cooldown Recovery 2 "compbon_charges2", // Charges 2 //"compbon_cooking2", // Cooking 2 "compbon_dmg2", // Damage 2 "compbon_eng2", // Engineering 2 "compbon_enmdown2", // Enmity Down 2 "compbon_harv2", // Harvesting 2 "compbon_wpn2", // Weaponsmith 2 "compbon_hp4", // Hit Points 4 "compbon_fp4", // Force Points 4 "compbon_enmup2", // Enmity Up 2 "compbon_luck1", // Luck 1 "compbon_med2", // Meditate 2 "compbon_faid2", // Medicine 2 "compbon_hpregen1", // HP Regen 1 "compbon_fpregen1", // FP Regen 1 "compbon_snkatk1", // Sneak Attack 1 "compbon_fab2", // Fabrication 2 "compbon_scanup2", // Scanning 2 "compbon_rest2", // Rest 2 "compbon_str1", // Strength 1 "compbon_dex1", // Dexterity 1 "compbon_con1", // Constitution 1 "compbon_wis1", // Wisdom 1 "compbon_int1", // Intelligence 1 "compbon_cha1", // Charisma 1 "compbon_ab2", // Attack Bonus 2 "compbon_scavup1" // Scavenging 1 }; string[] veryHighIP = { "compbon_arm3", // Armorsmith 3 "compbon_cspd3", // Cooldown Recovery 3 //"compbon_cooking3", // Cooking 3 "compbon_charges3", // Charges 3 "compbon_dmg3", // Damage 3 "compbon_eng3", // Engineering 3 "compbon_enmdown3", // Enmity Down 3 "compbon_harv3", // Harvesting 3 "compbon_wpn3", // Weaponsmith 3 "compbon_hp6", // Hit Points 6 "compbon_fp6", // Force Points 6 "compbon_enmup3", // Enmity Up 3 "compbon_luck2", // Luck 2 "compbon_med3", // Meditate 3 "compbon_faid3", // Medicine 3 "compbon_hpregen2", // HP Regen 2 "compbon_fpregen2", // FP Regen 2 "compbon_snkatk2", // Sneak Attack 2 "compbon_fab3", // Fabrication 3 "compbon_scanup3", // Scanning 3 "compbon_rest3", // Rest 3 "compbon_str2", // Strength 2 "compbon_dex2", // Dexterity 2 "compbon_con2", // Constitution 2 "compbon_wis2", // Wisdom 2 "compbon_int2", // Intelligence 2 "compbon_cha2", // Charisma 2 "compbon_ab3", // Attack Bonus 3 "compbon_scavup2" // Scavenging 2 }; string[] setToUse; switch (quality) { case ResourceQuality.Low: case ResourceQuality.Normal: setToUse = normalIP; break; case ResourceQuality.High: setToUse = highIP; break; case ResourceQuality.VeryHigh: setToUse = veryHighIP; break; default: throw new ArgumentOutOfRangeException(nameof(quality), quality, null); } int index = RandomService.Random(0, setToUse.Length - 1); string itemTag = setToUse[index]; return(new Tuple <ItemProperty, int>(ItemService.GetCustomItemPropertyByItemTag(itemTag), Colorize(itemTag))); }