public void OnImpact(NWPlayer player, NWObject target, int level) { int damage; float duration; switch (level) { case 1: damage = _random.D4(1); duration = 6; break; case 2: damage = _random.D8(1); duration = 6; break; case 3: damage = _random.D8(2); duration = 6; break; case 4: damage = _random.D8(2); duration = 12; break; case 5: damage = _random.D8(3); duration = 12; break; case 6: damage = _random.D8(4); duration = 12; break; case 7: damage = _random.D8(5); duration = 12; break; case 8: damage = _random.D8(5); duration = 18; break; case 9: damage = _random.D8(6); duration = 24; break; default: return; } _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectDamage(damage, DAMAGE_TYPE_PIERCING), target); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), target, duration); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectVisualEffect(VFX_IMP_ACID_L), target, duration); }
public void OnChestDisturbed(NWPlaceable oChest) { NWPlayer oPC = (_.GetLastDisturbed()); if (!oPC.IsPlayer && !oPC.IsDM) { return; } string pcName = oPC.Name; NWItem oItem = (_.GetInventoryDisturbItem()); int disturbType = _.GetInventoryDisturbType(); if (disturbType == NWScript.INVENTORY_DISTURB_TYPE_ADDED) { _.CopyItem(oItem.Object, oPC.Object, NWScript.TRUE); oItem.Destroy(); } else if (disturbType == NWScript.INVENTORY_DISTURB_TYPE_REMOVED) { SaveChestInventory(oPC, oChest, false); string itemName = oItem.Name; if (string.IsNullOrWhiteSpace(itemName)) { itemName = "money"; } float minSearchSeconds = 1.5f; float maxSearchSeconds = 4.5f; float searchDelay = _random.RandomFloat() * (maxSearchSeconds - minSearchSeconds) + minSearchSeconds; oPC.AssignCommand(() => { _.ActionPlayAnimation(NWScript.ANIMATION_LOOPING_GET_LOW, 1.0f, searchDelay); }); _.ApplyEffectToObject(NWScript.DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), oPC.Object, searchDelay); // Notify party members in the vicinity NWPlayer player = (_.GetFirstPC()); while (player.IsValid) { if (_.GetDistanceBetween(oPC.Object, player.Object) <= 20.0f && player.Area.Equals(oPC.Area) && _.GetFactionEqual(player.Object, oPC.Object) == NWScript.TRUE) { player.SendMessage(pcName + " found " + itemName + "."); } player = (_.GetNextPC()); } } }
public void CraftItem(NWPlayer oPC, NWPlaceable device) { var model = GetPlayerCraftingData(oPC); CraftBlueprint blueprint = _db.CraftBlueprints.Single(x => x.CraftBlueprintID == model.BlueprintID); if (blueprint == null) { return; } if (oPC.IsBusy) { oPC.SendMessage("You are too busy right now."); return; } if (!model.CanBuildItem) { oPC.SendMessage("You are missing one or more components..."); return; } oPC.IsBusy = true; float modifiedCraftDelay = CalculateCraftingDelay(oPC, blueprint.SkillID); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), oPC.Object, modifiedCraftDelay + 0.1f); oPC.AssignCommand(() => { _.ClearAllActions(); _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, modifiedCraftDelay); }); device.DelayCommand(() => { _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_COM_BLOOD_SPARK_MEDIUM), device.Object); }, 1.0f * (modifiedCraftDelay / 2.0f)); _nwnxPlayer.StartGuiTimingBar(oPC, modifiedCraftDelay, ""); oPC.DelayCommand(() => { try { RunCreateItem(oPC, device); oPC.IsBusy = false; } catch (Exception ex) { _error.LogError(ex); } }, modifiedCraftDelay); }
public void CraftItem(NWPlayer oPC, NWPlaceable device) { var model = GetPlayerCraftingData(oPC); CraftBlueprint blueprint = _data.Single <CraftBlueprint>(x => x.ID == model.BlueprintID); if (blueprint == null) { return; } if (oPC.IsBusy) { oPC.SendMessage("You are too busy right now."); return; } if (!model.CanBuildItem) { oPC.SendMessage("You are missing one or more components..."); return; } oPC.IsBusy = true; int atmosphere = CalculateAreaAtmosphereBonus(oPC.Area); float modifiedCraftDelay = CalculateCraftingDelay(oPC, blueprint.SkillID, atmosphere); oPC.AssignCommand(() => { _.ClearAllActions(); _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, modifiedCraftDelay); }); _.DelayCommand(1.0f * (modifiedCraftDelay / 2.0f), () => { _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_COM_BLOOD_SPARK_MEDIUM), device.Object); }); Effect immobilize = _.EffectCutsceneImmobilize(); immobilize = _.TagEffect(immobilize, "CRAFTING_IMMOBILIZATION"); _.ApplyEffectToObject(DURATION_TYPE_PERMANENT, immobilize, oPC.Object); _nwnxPlayer.StartGuiTimingBar(oPC, modifiedCraftDelay, ""); oPC.DelayEvent <CraftCreateItem>( modifiedCraftDelay, oPC); }
private void StartSmelt(NWPlaceable forge, NWPlayer pc, NWItem item) { int charges = forge.GetLocalInt("FORGE_CHARGES"); if (item.Resref == "power_core") { item.Destroy(); charges += 10 + CalculatePerkCoalBonusCharges(pc) + GetPowerCoreDurability(item) * 2; forge.SetLocalInt("FORGE_CHARGES", charges); NWPlaceable flames = (forge.GetLocalObject("FORGE_FLAMES")); if (!flames.IsValid) { Vector flamePosition = _biowarePosition.GetChangedPosition(forge.Position, 0.36f, forge.Facing); Location flameLocation = _.Location(forge.Area.Object, flamePosition, 0.0f); flames = (_.CreateObject(NWScript.OBJECT_TYPE_PLACEABLE, "forge_flame", flameLocation)); forge.SetLocalObject("FORGE_FLAMES", flames.Object); } return; } else if (charges <= 0) { ReturnItemToPC(pc, item, "You must power the refinery with a power unit before refining."); return; } // Ready to smelt float baseCraftDelay = 18.0f - (18.0f * _perk.GetPCPerkLevel(pc, PerkType.SpeedyRefining) * 0.1f); pc.IsBusy = true; _nwnxPlayer.StartGuiTimingBar(pc, baseCraftDelay, string.Empty); // Any component bonuses on the ore get applied to the end product. var itemProperties = item.ItemProperties.Where(x => _.GetItemPropertyType(x) == (int)CustomItemPropertyType.ComponentBonus || _.GetItemPropertyType(x) == (int)CustomItemPropertyType.RecommendedLevel).ToList(); string itemResref = item.Resref; pc.DelayEvent <CompleteSmelt>(baseCraftDelay, pc, itemResref, itemProperties); _.ApplyEffectToObject(NWScript.DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), pc.Object, baseCraftDelay); pc.AssignCommand(() => _.ActionPlayAnimation(NWScript.ANIMATION_LOOPING_GET_MID, 1.0f, baseCraftDelay)); item.Destroy(); }
private void startSmelt(NWPlaceable forge, NWPlayer pc, NWItem item) { int charges = forge.GetLocalInt("FORGE_CHARGES"); if (item.Resref == "coal") { item.Destroy(); charges += 10 + CalculatePerkCoalBonusCharges(pc); forge.SetLocalInt("FORGE_CHARGES", charges); NWPlaceable flames = NWPlaceable.Wrap(forge.GetLocalObject("FORGE_FLAMES")); if (!flames.IsValid) { Vector flamePosition = _biowarePosition.GetChangedPosition(forge.Position, 0.36f, forge.Facing); Location flameLocation = _.Location(forge.Area.Object, flamePosition, 0.0f); flames = NWPlaceable.Wrap(_.CreateObject(OBJECT_TYPE_PLACEABLE, "forge_flame", flameLocation)); forge.SetLocalObject("FORGE_FLAMES", flames.Object); } return; } else if (charges <= 0) { ReturnItemToPC(pc, item, "You must light the forge with coal before smelting."); return; } item.Destroy(); // Ready to smelt float baseCraftDelay = 18.0f - (_perk.GetPCPerkLevel(pc, PerkType.SpeedySmelter) * 0.1f); pc.IsBusy = true; forge.SetLocalObject("FORGE_USER", pc.Object); pc.SetLocalObject("FORGE", forge.Object); forge.SetLocalString("FORGE_ORE", item.Resref); _nwnxPlayer.StartGuiTimingBar(pc, baseCraftDelay, "cft_finish_smelt"); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), pc.Object, baseCraftDelay); pc.AssignCommand(() => _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, baseCraftDelay)); }
public void CraftItem(NWPlayer oPC, NWPlaceable device, int blueprintID) { CraftBlueprint blueprint = _db.CraftBlueprints.Single(x => x.CraftBlueprintID == blueprintID); if (blueprint == null) { return; } bool requiresTools = false; bool foundTools = false; if (oPC.IsBusy) { oPC.SendMessage("You are too busy right now."); return; } // Check for tools, if necessary. if (blueprint.CraftTierLevel > 0) { requiresTools = true; NWItem tools = NWItem.Wrap(device.GetLocalObject("CRAFT_DEVICE_TOOLS")); if (tools.IsValid) { foundTools = true; } } if (requiresTools != foundTools) { oPC.SendMessage(_color.Red("Tools were not found. Please place the tools you wish to use inside the crafting device.")); oPC.IsBusy = false; return; } oPC.IsBusy = true; bool allComponentsFound = CheckItemCounts(oPC, device, blueprint.CraftBlueprintComponents); if (allComponentsFound) { float modifiedCraftDelay = CalculateCraftingDelay(oPC, blueprint.SkillID); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), oPC.Object, modifiedCraftDelay + 0.1f); oPC.AssignCommand(() => { _.ClearAllActions(); _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, modifiedCraftDelay); }); device.DelayCommand(() => { _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_COM_BLOOD_SPARK_MEDIUM), device.Object); }, 1.0f * (modifiedCraftDelay / 2.0f)); _nwnxPlayer.StartGuiTimingBar(oPC, modifiedCraftDelay, ""); oPC.DelayCommand(() => { try { RunCreateItem(oPC, device, blueprintID); oPC.IsBusy = false; } catch (Exception ex) { _error.LogError(ex); } }, modifiedCraftDelay); } else { oPC.SendMessage(_color.Red("You are missing required components...")); } }