public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { CustomEffectService.RemovePCCustomEffect(target.Object, CustomEffectType.Poison); foreach (Effect effect in target.Effects) { if (_.GetIsEffectValid(effect) == true) { var effectType = _.GetEffectType(effect); if (effectType == EffectTypeScript.Poison || effectType == EffectTypeScript.Disease || effectType == EffectTypeScript.AbilityDecrease) { _.RemoveEffect(target.Object, effect); } } } user.SendMessage("You successfully treat " + target.Name + "'s infection."); int rank = SkillService.GetPCSkillRank(user.Object, SkillType.Medicine); if (target.IsPlayer) { int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); SkillService.GiveSkillXP(user.Object, SkillType.Medicine, xp); } }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = user.Object; var ability = (AbilityType)item.GetLocalInt("ABILITY_TYPE"); int amount = item.GetLocalInt("AMOUNT") + (item.MedicineBonus * 2); int rank = player.IsPlayer ? SkillService.GetPCSkillRank(player, SkillType.Medicine) : 0; int recommendedLevel = item.RecommendedLevel; float duration = 30.0f * (rank / 10); int perkLevel = player.IsPlayer ? PerkService.GetCreaturePerkLevel(player, PerkType.StimFiend) : 0; float percentIncrease = perkLevel * 0.25f; duration = duration + (duration * percentIncrease); Effect effect = _.EffectAbilityIncrease(ability, amount); effect = _.TagEffect(effect, "STIM_PACK_EFFECT"); _.ApplyEffectToObject(DurationType.Temporary, effect, target, duration); user.SendMessage("You inject " + target.Name + " with a stim pack. The stim pack will expire in " + duration + " seconds."); _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The stim pack that you applied to " + target.Name + " has expired."); }); if (!Equals(user, target)) { NWCreature targetCreature = target.Object; targetCreature.SendMessage(user.Name + " injects you with a stim pack."); } int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); SkillService.GiveSkillXP(player, SkillType.Medicine, xp); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player); target.RemoveEffect(EFFECT_TYPE_REGENERATE); int rank = SkillService.GetPCSkillRank(player, SkillType.Medicine); int luck = PerkService.GetPCPerkLevel(player, PerkType.Lucky); int perkDurationBonus = PerkService.GetPCPerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2); float duration = 30.0f + (rank * 0.4f) + perkDurationBonus; int restoreAmount = 1 + item.GetLocalInt("HEALING_BONUS") + effectiveStats.Medicine + item.MedicineBonus; int delta = item.RecommendedLevel - rank; float effectivenessPercent = 1.0f; if (delta > 0) { effectivenessPercent = effectivenessPercent - (delta * 0.1f); } restoreAmount = (int)(restoreAmount * effectivenessPercent); int perkBlastBonus = PerkService.GetPCPerkLevel(player, PerkType.ImmediateImprovement); if (perkBlastBonus > 0) { int blastHeal = restoreAmount * perkBlastBonus; if (RandomService.Random(100) + 1 <= luck / 2) { blastHeal *= 2; } _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(blastHeal), target.Object); } float interval = 6.0f; BackgroundType background = (BackgroundType)player.Class1; if (background == BackgroundType.Medic) { interval *= 0.5f; } _.PlaySound("use_bacta"); Effect regeneration = _.EffectRegenerate(restoreAmount, interval); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, regeneration, target.Object, duration); player.SendMessage("You successfully treat " + target.Name + "'s wounds. The healing kit will expire in " + duration + " seconds."); _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The healing kit that you applied to " + target.Name + " has expired."); }); if (target.IsPlayer) { int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); SkillService.GiveSkillXP(player, SkillType.Medicine, xp); } }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player); int rank = SkillService.GetPCSkillRank(player, SkillType.Medicine); int luck = PerkService.GetCreaturePerkLevel(player, PerkType.Lucky); int perkDurationBonus = PerkService.GetCreaturePerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2); float duration = 30.0f + (rank * 0.4f) + perkDurationBonus + effectiveStats.Medicine; int restoreAmount = 1 + item.GetLocalInt("HEALING_BONUS") + (rank / 10); int delta = item.RecommendedLevel - rank; float effectivenessPercent = 1.0f; if (delta > 0) { effectivenessPercent = effectivenessPercent - (delta * 0.1f); } restoreAmount = (int)(restoreAmount * effectivenessPercent) + item.MedicineBonus; int perkBlastBonus = PerkService.GetCreaturePerkLevel(player, PerkType.ImmediateForcePack); if (perkBlastBonus > 0) { int blastHeal = restoreAmount * perkBlastBonus; if (RandomService.Random(100) + 1 <= luck / 2) { blastHeal *= 2; } AbilityService.RestorePlayerFP(target.Object, blastHeal); } float interval = 6.0f; BackgroundType background = (BackgroundType)player.Class1; if (background == BackgroundType.Medic) { interval *= 0.5f; } string data = (int)interval + ", " + restoreAmount; CustomEffectService.ApplyCustomEffect(user, target.Object, CustomEffectType.ForcePack, (int)duration, restoreAmount, data); player.SendMessage("You successfully apply a force pack to " + target.Name + ". The force pack will expire in " + duration + " seconds."); _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The force pack that you applied to " + target.Name + " has expired."); }); int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); SkillService.GiveSkillXP(player, SkillType.Medicine, xp); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { string growingPlantID = target.GetLocalString("GROWING_PLANT_ID"); if (string.IsNullOrWhiteSpace(growingPlantID)) { user.SendMessage("Water jugs can only target growing plants."); return; } GrowingPlant growingPlant = DataService.Single <GrowingPlant>(x => x.ID == new Guid(growingPlantID)); var plant = DataService.Get <Plant>(growingPlant.PlantID); 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; } int remainingTicks = growingPlant.RemainingTicks; if (growingPlant.WaterStatus > 1) { remainingTicks = remainingTicks / 2; } growingPlant.WaterStatus = 0; growingPlant.RemainingTicks = remainingTicks; DataService.SubmitDataChange(growingPlant, DatabaseActionType.Update); user.SendMessage("You water the plant."); int rank = SkillService.GetPCSkillRank((NWPlayer)user, SkillType.Farming); int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(100, plant.Level, rank); SkillService.GiveSkillXP((NWPlayer)user, SkillType.Farming, xp); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player); CustomEffectService.RemovePCCustomEffect(target.Object, CustomEffectType.Bleeding); player.SendMessage("You finish bandaging " + target.Name + "'s wounds."); int rank = SkillService.GetPCSkillRank(player, SkillType.Medicine); int healAmount = 2 + effectiveStats.Medicine / 2; healAmount += item.MedicineBonus; if (rank >= item.RecommendedLevel && item.MedicineBonus > 0) { _.ApplyEffectToObject(DurationType.Instant, _.EffectHeal(healAmount), target); } if (target.IsPlayer) { int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(100, item.RecommendedLevel, rank); SkillService.GiveSkillXP(player, SkillType.Medicine, xp); } }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = user.Object; var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player); int skillRank = SkillService.GetPCSkillRank(player, SkillType.Medicine); int perkLevel = PerkService.GetCreaturePerkLevel(player, PerkType.ResuscitationDevices); int rank = item.GetLocalInt("RANK"); int baseHeal; switch (rank) { case 1: baseHeal = 1; break; case 2: baseHeal = 11; break; case 3: baseHeal = 31; break; case 4: baseHeal = 51; break; default: return; } baseHeal += perkLevel * 2; baseHeal += effectiveStats.Medicine / 2; baseHeal += item.MedicineBonus / 2; int delta = item.RecommendedLevel - skillRank; float effectivenessPercent = 1.0f; if (delta > 0) { effectivenessPercent = effectivenessPercent - (delta * 0.1f); } if (target.IsPlayer) { baseHeal = (int)(baseHeal * effectivenessPercent); Player dbPlayer = DataService.Player.GetByID(target.GlobalID); int fpRecover = (int)(dbPlayer.MaxFP * (0.01f * baseHeal)); int hpRecover = (int)(target.MaxHP * (0.01f * baseHeal)); _.PlaySound("use_bacta"); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectResurrection(), target); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(hpRecover), target); dbPlayer.CurrentFP = fpRecover; DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update); player.SendMessage("You successfully resuscitate " + target.Name + "!"); int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(600, item.RecommendedLevel, skillRank); SkillService.GiveSkillXP(player, SkillType.Medicine, xp); } else { baseHeal = (int)(baseHeal * effectivenessPercent); int hpRecover = (int)(target.MaxHP * (0.01f * baseHeal)); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectResurrection(), target); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(hpRecover), target); player.SendMessage("You successfully resuscitate " + target.Name + "!"); } }
public void Main() { NWPlaceable point = (_.OBJECT_SELF); NWPlayer oPC = (_.GetLastOpenedBy()); if (!oPC.IsPlayer) { return; } var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(oPC); const int baseChanceToFullyHarvest = 50; bool hasBeenSearched = point.GetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED") == 1; if (hasBeenSearched) { oPC.SendMessage("There's nothing left to harvest here..."); return; } if (!oPC.IsPlayer && !oPC.IsDM) { return; } int rank = SkillService.GetPCSkillRank(oPC, SkillType.Scavenging); int lootTableID = point.GetLocalInt("SCAVENGE_POINT_LOOT_TABLE_ID"); int level = point.GetLocalInt("SCAVENGE_POINT_LEVEL"); int delta = level - rank; if (delta > 8) { oPC.SendMessage("You aren't skilled enough to scavenge through this. (Required Level: " + (level - 8) + ")"); oPC.AssignCommand(() => _.ActionInteractObject(point.Object)); return; } int dc = 6 + delta; if (dc <= 4) { dc = 4; } int searchAttempts = 1 + CalculateSearchAttempts(oPC); int luck = PerkService.GetCreaturePerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck; if (RandomService.Random(100) + 1 <= luck / 2) { dc--; } oPC.AssignCommand(() => _.ActionPlayAnimation(Animation.LoopingGetLow, 1.0f, 2.0f)); for (int attempt = 1; attempt <= searchAttempts; attempt++) { int roll = RandomService.Random(20) + 1; if (roll >= dc) { oPC.FloatingText(ColorTokenService.SkillCheck("Search: *success*: (" + roll + " vs. DC: " + dc + ")")); ItemVO spawnItem = LootService.PickRandomItemFromLootTable(lootTableID); if (spawnItem == null) { return; } if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0) { _.CreateItemOnObject(spawnItem.Resref, point.Object, spawnItem.Quantity); } float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, level, rank); SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp); } else { oPC.FloatingText(ColorTokenService.SkillCheck("Search: *failure*: (" + roll + " vs. DC: " + dc + ")")); float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(50, level, rank); SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp); } dc += RandomService.Random(3) + 1; } // Chance to destroy the scavenge point. int chanceToFullyHarvest = baseChanceToFullyHarvest - (PerkService.GetCreaturePerkLevel(oPC, PerkType.CarefulScavenger) * 5); if (chanceToFullyHarvest <= 5) { chanceToFullyHarvest = 5; } point.SetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED", 1); oPC.SendMessage("This resource has been fully harvested..."); point.SetLocalInt("SCAVENGE_POINT_DESPAWN_TICKS", 30); }
public void ApplyEffects(NWCreature user, NWItem modItem, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); NWItem targetItem = (target.Object); ModSlots slots = ModService.GetModSlots(targetItem); CustomItemPropertyType modType = ModService.GetModType(modItem); int modID = modItem.GetLocalInt("RUNE_ID"); string[] modArgs = modItem.GetLocalString("RUNE_VALUE").Split(','); int modLevel = modItem.RecommendedLevel; int levelIncrease = modItem.LevelIncrease; var mod = ModService.GetModHandler(modID); mod.Apply(player, targetItem, modArgs); string description = mod.Description(player, targetItem, modArgs); bool usePrismatic = false; switch (modType) { case CustomItemPropertyType.RedMod: if (slots.FilledRedSlots < slots.RedSlots) { targetItem.SetLocalInt("MOD_SLOT_RED_" + (slots.FilledRedSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_RED_DESC_" + (slots.FilledRedSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Red("red") + " slot #" + (slots.FilledRedSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.BlueMod: if (slots.FilledBlueSlots < slots.BlueSlots) { targetItem.SetLocalInt("MOD_SLOT_BLUE_" + (slots.FilledBlueSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_BLUE_DESC_" + (slots.FilledBlueSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Blue("blue") + " slot #" + (slots.FilledBlueSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.GreenMod: if (slots.FilledBlueSlots < slots.GreenSlots) { targetItem.SetLocalInt("MOD_SLOT_GREEN_" + (slots.FilledGreenSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_GREEN_DESC_" + (slots.FilledGreenSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Green("green") + " slot #" + (slots.FilledGreenSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.YellowMod: if (slots.FilledBlueSlots < slots.YellowSlots) { targetItem.SetLocalInt("MOD_SLOT_YELLOW_" + (slots.FilledYellowSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_YELLOW_DESC_" + (slots.FilledYellowSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Yellow("yellow") + " slot #" + (slots.FilledYellowSlots + 1)); } else { usePrismatic = true; } break; } if (usePrismatic) { string prismaticText = ModService.PrismaticString(); targetItem.SetLocalInt("MOD_SLOT_PRISMATIC_" + (slots.FilledPrismaticSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_PRISMATIC_DESC_" + (slots.FilledPrismaticSlots + 1), description); player.SendMessage("Mod installed into " + prismaticText + " slot #" + (slots.FilledPrismaticSlots + 1)); } targetItem.RecommendedLevel += levelIncrease; modItem.Destroy(); SkillType skillType; if (ArmorBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Armorsmith; } else if (WeaponsmithBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Weaponsmith; } else if (EngineeringBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Engineering; } else { return; } int rank = SkillService.GetPCSkillRank(player, skillType); int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(400, modLevel, rank); SkillService.GiveSkillXP(player, skillType, xp); }
public bool Run(params object[] args) { NWPlaceable point = (Object.OBJECT_SELF); NWPlayer oPC = (_.GetLastOpenedBy()); if (!oPC.IsPlayer) { return(false); } var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(oPC); const int baseChanceToFullyHarvest = 50; bool alwaysDestroys = point.GetLocalInt("SCAVENGE_POINT_ALWAYS_DESTROYS") == 1; bool hasBeenSearched = point.GetLocalInt("SCAVENGE_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("SCAVENGE_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); } int rank = SkillService.GetPCSkillRank(oPC, SkillType.Scavenging); int lootTableID = point.GetLocalInt("SCAVENGE_POINT_LOOT_TABLE_ID"); int level = point.GetLocalInt("SCAVENGE_POINT_LEVEL"); int delta = level - rank; if (delta > 8) { oPC.SendMessage("You aren't skilled enough to scavenge 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 = PerkService.GetPCPerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck; if (RandomService.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 = RandomService.Random(20) + 1; if (roll >= dc) { oPC.FloatingText(ColorTokenService.SkillCheck("Search: *success*: (" + roll + " vs. DC: " + dc + ")")); ItemVO spawnItem = LootService.PickRandomItemFromLootTable(lootTableID); if (spawnItem == null) { return(false); } if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0) { NWItem resource = _.CreateItemOnObject(spawnItem.Resref, point.Object, spawnItem.Quantity); var componentIP = resource.ItemProperties.FirstOrDefault(x => _.GetItemPropertyType(x) == (int)CustomItemPropertyType.ComponentType); if (componentIP != null) { // Add properties to the item based on Scavenging skill. Similar logic to the resource harvester. var chance = RandomService.Random(1, 100) + PerkService.GetPCPerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck; ResourceQuality quality; if (chance < 50) { quality = ResourceQuality.Low; } else if (chance < 75) { quality = ResourceQuality.Normal; } else if (chance < 95) { quality = ResourceQuality.High; } else { quality = ResourceQuality.VeryHigh; } int ipBonusChance = ResourceService.CalculateChanceForComponentBonus(oPC, (level / 10 + 1), quality, true); if (RandomService.Random(1, 100) <= ipBonusChance) { var ip = ResourceService.GetRandomComponentBonusIP(ResourceQuality.Normal); 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; } } } } float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, level, rank); SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp); } else { oPC.FloatingText(ColorTokenService.SkillCheck("Search: *failure*: (" + roll + " vs. DC: " + dc + ")")); float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(50, level, rank); SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp); } dc += RandomService.Random(3) + 1; } // Chance to destroy the scavenge point. int chanceToFullyHarvest = baseChanceToFullyHarvest - (PerkService.GetPCPerkLevel(oPC, PerkType.CarefulScavenger) * 5); string growingPlantID = point.GetLocalString("GROWING_PLANT_ID"); if (!string.IsNullOrWhiteSpace(growingPlantID)) { Data.Entity.GrowingPlant growingPlant = FarmingService.GetGrowingPlantByID(new Guid(growingPlantID)); chanceToFullyHarvest = chanceToFullyHarvest - (growingPlant.LongevityBonus); } if (chanceToFullyHarvest <= 5) { chanceToFullyHarvest = 5; } if (alwaysDestroys || RandomService.Random(100) + 1 <= chanceToFullyHarvest) { point.SetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED", 1); oPC.SendMessage("This resource has been fully harvested..."); } // Otherwise the scavenge point will be refilled in 10-20 minutes. else { point.SetLocalInt("SCAVENGE_POINT_REFILL_TICKS", 100 + RandomService.Random(100)); } point.SetLocalInt("SCAVENGE_POINT_DESPAWN_TICKS", 30); return(true); }
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); }
public bool Run(params object[] args) { NWPlaceable point = (Object.OBJECT_SELF); NWPlayer oPC = (_.GetLastOpenedBy()); if (!oPC.IsPlayer) { return(false); } var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(oPC); const int baseChanceToFullyHarvest = 50; bool alwaysDestroys = point.GetLocalInt("SCAVENGE_POINT_ALWAYS_DESTROYS") == 1; bool hasBeenSearched = point.GetLocalInt("SCAVENGE_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("SCAVENGE_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); } int rank = SkillService.GetPCSkillRank(oPC, SkillType.Scavenging); int lootTableID = point.GetLocalInt("SCAVENGE_POINT_LOOT_TABLE_ID"); int level = point.GetLocalInt("SCAVENGE_POINT_LEVEL"); int delta = level - rank; if (delta > 8) { oPC.SendMessage("You aren't skilled enough to scavenge 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 = PerkService.GetCreaturePerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck; if (RandomService.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 = RandomService.Random(20) + 1; if (roll >= dc) { oPC.FloatingText(ColorTokenService.SkillCheck("Search: *success*: (" + roll + " vs. DC: " + dc + ")")); ItemVO spawnItem = LootService.PickRandomItemFromLootTable(lootTableID); if (spawnItem == null) { return(false); } if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0) { _.CreateItemOnObject(spawnItem.Resref, point.Object, spawnItem.Quantity); } float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, level, rank); SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp); } else { oPC.FloatingText(ColorTokenService.SkillCheck("Search: *failure*: (" + roll + " vs. DC: " + dc + ")")); float xp = SkillService.CalculateRegisteredSkillLevelAdjustedXP(50, level, rank); SkillService.GiveSkillXP(oPC, SkillType.Scavenging, (int)xp); } dc += RandomService.Random(3) + 1; } // Chance to destroy the scavenge point. int chanceToFullyHarvest = baseChanceToFullyHarvest - (PerkService.GetCreaturePerkLevel(oPC, PerkType.CarefulScavenger) * 5); string growingPlantID = point.GetLocalString("GROWING_PLANT_ID"); if (!string.IsNullOrWhiteSpace(growingPlantID)) { Data.Entity.GrowingPlant growingPlant = FarmingService.GetGrowingPlantByID(new Guid(growingPlantID)); chanceToFullyHarvest = chanceToFullyHarvest - (growingPlant.LongevityBonus); } if (chanceToFullyHarvest <= 5) { chanceToFullyHarvest = 5; } if (alwaysDestroys || RandomService.Random(100) + 1 <= chanceToFullyHarvest) { point.SetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED", 1); oPC.SendMessage("This resource has been fully harvested..."); } // Otherwise the scavenge point will be refilled in 10-20 minutes. else { point.SetLocalInt("SCAVENGE_POINT_REFILL_TICKS", 100 + RandomService.Random(100)); } point.SetLocalInt("SCAVENGE_POINT_DESPAWN_TICKS", 30); return(true); }
private void OnCompleteSmelt(OnCompleteSmelt data) { NWPlayer player = data.Player; string oreResref = data.OreResref; List <ItemProperty> itemProperties = data.ItemProperties; player.IsBusy = false; int rank = SkillService.GetPCSkillRank(player, SkillType.Harvesting); int level = CraftService.GetIngotLevel(oreResref); string ingotResref = CraftService.GetIngotResref(oreResref); if (level < 0 || string.IsNullOrWhiteSpace(ingotResref)) { return; } int delta = rank - level; int count = 2; if (delta > 2) { count = delta; } if (count > 4) { count = 4; } if (RandomService.Random(100) + 1 <= PerkService.GetCreaturePerkLevel(player, PerkType.Lucky)) { count++; } if (RandomService.Random(100) + 1 <= PerkService.GetCreaturePerkLevel(player, PerkType.ProcessingEfficiency) * 10) { count++; } for (int x = 1; x <= count; x++) { var item = (_.CreateItemOnObject(ingotResref, player.Object)); int chance; switch (x) { case 1: case 2: chance = 100; break; case 3: chance = 70; break; case 4: chance = 60; break; case 5: chance = 50; break; default: chance = 30; break; } foreach (var ip in itemProperties) { if (RandomService.D100(1) <= chance) { BiowareXP2.IPSafeAddItemProperty(item, ip, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true); } } } var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player); int harvestingSkill = SkillService.GetPCSkillRank(player, SkillType.Harvesting); int perkBonus = PerkService.GetCreaturePerkLevel(player, PerkType.StronidiumRefining) + 1; int stronidiumAmount = 10 + effectiveStats.Harvesting + harvestingSkill + RandomService.Random(1, 5); stronidiumAmount *= perkBonus; _.CreateItemOnObject("stronidium", player.Object, stronidiumAmount); int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(100, level, rank); SkillService.GiveSkillXP(player, SkillType.Harvesting, xp); }
public bool Run(params object[] args) { NWPlaceable container = (Object.OBJECT_SELF); NWPlayer oPC = (_.GetLastDisturbed()); int type = _.GetInventoryDisturbType(); NWItem item = (_.GetInventoryDisturbItem()); var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(oPC); if (type != _.INVENTORY_DISTURB_TYPE_ADDED) { return(false); } int plantID = item.GetLocalInt("PLANT_ID"); if (plantID <= 0) { ItemService.ReturnItem(oPC, item); oPC.SendMessage("You cannot plant that item."); return(true); } Plant plant = FarmingService.GetPlantByID(plantID); if (plant == null) { ItemService.ReturnItem(oPC, item); oPC.SendMessage("You cannot plant that item."); return(true); } int rank = SkillService.GetPCSkillRank(oPC, SkillType.Farming); if (rank + 2 < plant.Level) { ItemService.ReturnItem(oPC, item); oPC.SendMessage("You do not have enough Farming skill to plant that seed. (Required: " + (plant.Level - 2) + ")"); return(true); } item.Destroy(); string areaTag = container.Area.Tag; Location plantLocation = container.Location; int perkBonus = PerkService.GetPCPerkLevel(oPC, PerkType.FarmingEfficiency) * 2; int ticks = (int)(plant.BaseTicks - ((PerkService.GetPCPerkLevel(oPC, PerkType.ExpertFarmer) * 0.05f)) * plant.BaseTicks); Data.Entity.GrowingPlant growingPlant = new Data.Entity.GrowingPlant { PlantID = plant.ID, RemainingTicks = ticks, LocationAreaTag = areaTag, LocationOrientation = _.GetFacingFromLocation(plantLocation), LocationX = _.GetPositionFromLocation(plantLocation).m_X, LocationY = _.GetPositionFromLocation(plantLocation).m_Y, LocationZ = _.GetPositionFromLocation(plantLocation).m_Z, IsActive = true, DateCreated = DateTime.UtcNow, LongevityBonus = perkBonus }; DataService.SubmitDataChange(growingPlant, DatabaseActionType.Insert); NWPlaceable hole = (container.GetLocalObject("FARM_SMALL_HOLE")); NWPlaceable plantPlc = (_.CreateObject(_.OBJECT_TYPE_PLACEABLE, "growing_plant", hole.Location)); plantPlc.SetLocalString("GROWING_PLANT_ID", growingPlant.ID.ToString()); plantPlc.Name = "Growing Plant (" + plant.Name + ")"; container.Destroy(); hole.Destroy(); int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(200, plant.Level, rank); if (RandomService.Random(100) + 1 <= PerkService.GetPCPerkLevel(oPC, PerkType.Lucky) + effectiveStats.Luck) { xp *= 2; } SkillService.GiveSkillXP(oPC, SkillType.Farming, xp); return(true); }