public void Main() { NWPlaceable container = _.OBJECT_SELF; NWItem firstItem = _.GetFirstItemInInventory(container); NWCreature corpseOwner = container.GetLocalObject("CORPSE_BODY"); if (!firstItem.IsValid) { container.Destroy(); } corpseOwner.AssignCommand(() => { _.SetIsDestroyable(true); }); }
public bool Run(params object[] args) { NWPlaceable placeable = NWPlaceable.Wrap(Object.OBJECT_SELF); NWPlayer user = NWPlayer.Wrap(_.GetLastUsedBy()); if (!user.IsPlayer && !user.IsDM) { return(false); } string conversation = placeable.GetLocalString("CONVERSATION"); _dialog.StartConversation(user, placeable, conversation); return(true); }
private void LoadCreatePostPage() { var player = GetPC(); Model model = GetDialogCustomData <Model>(); NWPlaceable terminal = _.OBJECT_SELF; int price = terminal.GetLocalInt("PRICE"); string header = "Please enter text and then click the 'Set Title' or 'Set Message' buttons. Titles must be 256 characters or less. Messages must be 4000 characters or less.\n\n"; header += "Posting a message costs " + price + " credits. Posts last for 30 days (real world time) before they will expire.\n\n"; header += ColorTokenService.Green("Title: ") + model.Title + "\n"; header += ColorTokenService.Green("Message: ") + model.Message + "\n"; SetPageHeader("CreatePostPage", header); player.SetLocalBool("MESSAGE_BOARD_LISTENING", true); }
public bool Run(params object[] args) { NWPlaceable objSelf = NWPlaceable.Wrap(Object.OBJECT_SELF); foreach (NWItem item in objSelf.InventoryItems) { item.Destroy(); } NWObject parent = NWObject.Wrap(objSelf.GetLocalObject("STRUCTURE_TEMP_PARENT")); parent.DeleteLocalObject("STRUCTURE_TEMP_INVENTORY_OPENED"); objSelf.Destroy(); return(true); }
private void HandleMainPageResponse(int responseID) { switch (responseID) { case 1: // Plant a seed Location location = GetPC().Location; NWPlaceable planter = (_.CreateObject(NWScript.OBJECT_TYPE_PLACEABLE, "farm_plant_seed", location)); planter.SetLocalObject("FARM_SMALL_HOLE", GetDialogTarget().Object); GetPC().AssignCommand(() => _.ActionInteractObject(planter.Object)); break; case 2: // Cover up the hole ChangePage("CoverUpConfirm"); break; } }
public bool Run(params object[] args) { NWPlaceable chest = (Object.OBJECT_SELF); Guid structureID = new Guid(chest.GetLocalString("PC_BASE_STRUCTURE_ID")); var structure = _data.Single <PCBaseStructure>(x => x.ID == structureID); var items = _data.Where <PCBaseStructureItem>(x => x.PCBaseStructureID == structure.ID); foreach (var item in items) { _serialization.DeserializeItem(item.ItemObject, chest); } chest.IsUseable = false; return(true); }
private void HandleCategoryResponse(int responseID) { DialogResponse response = GetResponseByID("MainPage", responseID); if (!response.HasCustomData) { NWPlaceable device = (NWPlaceable)GetDialogTarget(); GetPC().AssignCommand(() => _.ActionInteractObject(device.Object)); return; } int categoryID = (int)response.CustomData[string.Empty]; LoadBlueprintListPage(categoryID); ChangePage("BlueprintListPage"); }
public void DoPlayerExitBuildingInstance(NWPlayer player, NWPlaceable door = null) { NWArea area = player.Area; if (!area.IsInstance) { return; } if (door == null) { NWObject obj = (_.GetFirstObjectInArea(area.Object)); while (obj.IsValid) { if (obj.Tag == "building_exit") { door = (obj.Object); break; } obj = (_.GetNextObjectInArea(area.Object)); } } if (door == null) { return; } Location location = door.GetLocalLocation("PLAYER_HOME_EXIT_LOCATION"); player.AssignCommand(() => _.ActionJumpToLocation(location)); _.DelayCommand(1.0f, () => { player = (_.GetFirstPC()); while (player.IsValid) { if (Equals(player.Area, area)) { return; } player = (_.GetNextPC()); } _area.DestroyAreaInstance(area); }); }
public void RequestItemsFromPC(NWPlayer oPC, NWObject questOwner, int questID, int sequenceID) { if (!oPC.IsPlayer) { return; } PCQuestStatus pcStatus = _db.PCQuestStatus.Single(x => x.PlayerID == oPC.GlobalID && x.QuestID == questID); if (pcStatus == null) { oPC.SendMessage("You have not accepted this quest yet."); return; } QuestState questState = pcStatus.CurrentQuestState; if (questState.Sequence != sequenceID) { oPC.SendMessage("SequenceID mismatch. Please inform an admin there is a bug with this quest. (QuestID = " + questID + ")"); return; } foreach (QuestRequiredKeyItemList ki in questState.QuestRequiredKeyItemLists) { if (!_keyItem.PlayerHasKeyItem(oPC, ki.KeyItemID)) { oPC.SendMessage("You are missing a required key item."); return; } } Location location = oPC.Location; NWPlaceable collector = NWPlaceable.Wrap(_.CreateObject(OBJECT_TYPE_PLACEABLE, "qst_item_collect", location)); collector.AssignCommand(() => { _.SetFacingPoint(oPC.Position); }); collector.SetLocalInt("QUEST_ID", questID); _.CreateItemOnObject(SubmitQuestItemResref, collector.Object); oPC.AssignCommand(() => { _.ActionInteractObject(collector.Object); }); }
private void DoEnterBuilding() { NWPlayer oPC = GetPC(); NWPlaceable door = GetDialogTarget().Object; string pcBaseStructureID = door.GetLocalString("PC_BASE_STRUCTURE_ID"); if (string.IsNullOrWhiteSpace(pcBaseStructureID)) { _.FloatingTextStringOnCreature("ERROR: Door doesn't have a structure ID assigned. Notify an admin about this issue.", oPC.Object, NWScript.FALSE); return; } var structureID = new Guid(pcBaseStructureID); bool canEnterBuilding = _perm.HasStructurePermission(GetPC(), structureID, StructurePermission.CanEnterBuilding); if (!canEnterBuilding) { oPC.FloatingText("You don't have permission to enter that building."); return; } var structure = _data.Single <PCBaseStructure>(x => x.ID == structureID); var pcBase = _data.Get <PCBase>(structure.PCBaseID); var interiorStyle = _data.Get <BuildingStyle>(structure.InteriorStyleID); NWArea instance = GetAreaInstance(structureID); if (instance == null) { string name = structure.CustomName; if (string.IsNullOrWhiteSpace(name)) { Player owner = _player.GetPlayerEntity(pcBase.PlayerID); name = owner.CharacterName + "'s Building"; } instance = _area.CreateAreaInstance(oPC, interiorStyle.Resref, name, "PLAYER_HOME_ENTRANCE"); instance.SetLocalString("PC_BASE_STRUCTURE_ID", structureID.ToString()); instance.SetLocalInt("BUILDING_TYPE", (int)BuildingType.Interior); var childStructures = _data.Where <PCBaseStructure>(x => x.ParentPCBaseStructureID == structure.ID); foreach (var child in childStructures) { _base.SpawnStructure(instance, child.ID); } } _base.JumpPCToBuildingInterior(oPC, instance); }
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 EnterApartment(Guid pcBaseID) { NWPlaceable door = Object.OBJECT_SELF; NWPlayer oPC = GetPC(); int apartmentBuildingID = door.GetLocalInt("APARTMENT_BUILDING_ID"); var permission = DataService.SingleOrDefault <PCBasePermission>(x => x.PlayerID == oPC.GlobalID && x.PCBaseID == pcBaseID && !x.IsPublicPermission); if (permission == null || !permission.CanEnterBuildings) { oPC.FloatingText("You do not have permission to enter that apartment."); return; } // If we're swapping from one apartment to another (without going to an intermediary non-instance) // we'll run a check to see if we need to kill the current instance. var area = door.Area; _.DelayCommand(1.0f, () => { NWPlayer player = (_.GetFirstPC()); while (player.IsValid) { if (Equals(player.Area, area)) { return; } player = (_.GetNextPC()); } AreaService.DestroyAreaInstance(area); }); // Get or create the new apartment instance. NWArea instance = BaseService.GetAreaInstance(pcBaseID, true); if (instance == null) { instance = BaseService.CreateAreaInstance(oPC, pcBaseID, true); } // Port the player to the new instance. BaseService.JumpPCToBuildingInterior(oPC, instance, apartmentBuildingID); }
public void Main() { const int QuestID = 30; NWPlaceable crystal = NWGameObject.OBJECT_SELF; NWPlayer player = _.GetLastUsedBy(); // Check player's current quest state. If they aren't on stage 2 of the quest only show a message. var status = DataService.PCQuestStatus.GetByPlayerAndQuestID(player.GlobalID, QuestID); var currentState = DataService.QuestState.GetByID(status.CurrentQuestStateID); if (currentState.Sequence != 2) { player.SendMessage("The crystal glows quietly..."); return; } // Player is on stage 2, so they're able to click the crystal, get a cluster, complete the quest, and teleport back to the cavern. int type = crystal.GetLocalInt("CRYSTAL_COLOR_TYPE"); string cluster; switch (type) { case 1: cluster = "c_cluster_blue"; break; // Blue case 2: cluster = "c_cluster_red"; break; // Red case 3: cluster = "c_cluster_green"; break; // Green case 4: cluster = "c_cluster_yellow"; break; // Yellow default: throw new Exception("Invalid crystal color type."); } _.CreateItemOnObject(cluster, player); QuestService.AdvanceQuestState(player, crystal, QuestID); // Hide the "Source of Power?" placeable so the player can't use it again. ObjectVisibilityService.AdjustVisibility(player, "81533EBB-2084-4C97-B004-8E1D8C395F56", false); NWObject tpWP = _.GetObjectByTag("FORCE_QUEST_LANDING"); player.AssignCommand(() => _.ActionJumpToLocation(tpWP.Location)); // Notify the player that new lightsaber perks have unlocked. player.FloatingText("You have unlocked the Lightsaber Blueprints perk. Find this under the Engineering category in your perks menu."); }
private void EnterApartment(Guid pcBaseID) { NWPlaceable door = _.OBJECT_SELF; NWPlayer oPC = GetPC(); int apartmentBuildingID = door.GetLocalInt("APARTMENT_BUILDING_ID"); var permission = DataService.PCBasePermission.GetPlayerPrivatePermissionOrDefault(oPC.GlobalID, pcBaseID); if (permission == null || !permission.CanEnterBuildings) { oPC.FloatingText("You do not have permission to enter that apartment."); return; } // If we're swapping from one apartment to another (without going to an intermediary non-instance) // we'll run a check to see if we need to kill the current instance. var area = door.Area; _.DelayCommand(1.0f, () => { NWPlayer player = (_.GetFirstPC()); while (player.IsValid) { if (Equals(player.Area, area)) { return; } player = (_.GetNextPC()); } //AreaService.DestroyAreaInstance(area); }); // Get or create the new apartment instance. NWArea instance = BaseService.GetAreaInstance(pcBaseID, true); if (instance == null) { instance = BaseService.CreateAreaInstance(oPC, pcBaseID, true); } // Port the player to the new instance. In case we are jumping from apartment to apartment, pass the exit location from // the current apartment to use for exiting the new one (to avoid looping back here!). BaseService.JumpPCToBuildingInterior(oPC, instance, apartmentBuildingID, door.GetLocalLocation("PLAYER_HOME_EXIT_LOCATION")); }
public bool Run(params object[] args) { if (_.GetInventoryDisturbType() != _.INVENTORY_DISTURB_TYPE_ADDED) { return(false); } NWPlayer player = _.GetLastDisturbed(); NWPlaceable device = Object.OBJECT_SELF; NWItem item = _.GetInventoryDisturbItem(); // Check the item type to see if it's valid. if (!IsValidItemType(item)) { ItemService.ReturnItem(player, item); player.SendMessage("You cannot reassemble this item."); return(false); } // Only crafted items can be reassembled. if (string.IsNullOrWhiteSpace(item.GetLocalString("CRAFTER_PLAYER_ID"))) { ItemService.ReturnItem(player, item); player.SendMessage("Only crafted items may be reassembled."); return(false); } // DMs cannot reassemble because they don't have the necessary DB records. if (player.IsDM) { ItemService.ReturnItem(player, item); player.SendMessage("DMs cannot reassemble items at this time."); return(false); } // Serialize the item into a string and store it into the temporary data for this player. Destroy the physical item. var model = CraftService.GetPlayerCraftingData(player); model.SerializedSalvageItem = SerializationService.Serialize(item); item.Destroy(); // Start the Molecular Reassembly conversation. DialogService.StartConversation(player, device, "MolecularReassembly"); return(true); }
public void Main() { NWPlaceable point = (_.OBJECT_SELF); NWPlayer player = _.GetLastClosedBy(); if (!player.IsPlayer) { return; } bool isFullyHarvested = point.GetLocalInt("SCAVENGE_POINT_FULLY_HARVESTED") == 1; if (!point.InventoryItems.Any() && isFullyHarvested) { point.Destroy(); } }
private void OnCreatureDeath(OnCreatureDeath @event) { NWCreature creature = _.OBJECT_SELF; if (creature.Resref != "zomb_rancor") { return; } NWArea area = creature.Area; NWArea restrictedArea = area.GetLocalObject("RESTRICTED_LEVEL"); NWPlaceable elevator = _.GetNearestObjectByTag("aban_ele_to_office", _.GetFirstObjectInArea(restrictedArea)); elevator.IsUseable = true; _.SpeakString("The rancor falls to the ground. Suddenly, the nearby elevator lights up. It looks like it can be used."); }
public static void CraftItem(NWPlayer oPC, NWPlaceable device) { var model = GetPlayerCraftingData(oPC); CraftBlueprint blueprint = DataService.CraftBlueprint.GetByID(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); oPC.AssignCommand(() => { _.ClearAllActions(); _.ActionPlayAnimation(Animation.LoopingGetMid, 1.0f, modifiedCraftDelay); }); _.DelayCommand(1.0f * (modifiedCraftDelay / 2.0f), () => { _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Com_Blood_Spark_Medium), device.Object); }); var immobilize = _.EffectCutsceneImmobilize(); immobilize = _.TagEffect(immobilize, "CRAFTING_IMMOBILIZATION"); _.ApplyEffectToObject(DurationType.Permanent, immobilize, oPC.Object); NWNXPlayer.StartGuiTimingBar(oPC, modifiedCraftDelay, ""); var @event = new OnCreateCraftedItem(oPC); oPC.DelayEvent(modifiedCraftDelay, @event); }
public void Main() { if (_.GetInventoryDisturbType() != DisturbType.Added) { return; } NWPlayer pc = (_.GetLastDisturbed()); NWItem item = (_.GetInventoryDisturbItem()); NWPlaceable forge = (_.OBJECT_SELF); if (!CheckValidity(forge, pc, item)) { return; } StartSmelt(forge, pc, item); }
void DoDustClouds(NWLocation loc) { // Utility method to throw some dust clouds up around a landing ship. float x, y; Vector3 v; for (int i = 0; i < 6; i++) { x = loc.X + (5 - _.d10()); y = loc.Y + (5 - _.d10()); v = new Vector3(x, y, loc.Z); NWPlaceable cloud = _.CreateObject(ObjectType.Placeable, "plc_dustplume", _.Location(loc.Area, v, loc.Orientation)); _.DelayCommand(10.0f, () => _.DestroyObject(cloud)); } }
public bool Run(params object[] args) { NWPlaceable site = NWPlaceable.Wrap(Object.OBJECT_SELF); NWPlayer oPC = NWPlayer.Wrap(_.GetLastUsedBy()); int flagID = _structure.GetTerritoryFlagID(site); PCTerritoryFlag entity = _structure.GetPCTerritoryFlagByID(flagID); if (oPC.GlobalID != entity.PlayerID && !oPC.IsDM) { oPC.SendMessage("Only the owner of the territory may use this."); } else { _dialog.StartConversation(oPC, site, "TerritoryFlag"); } return(true); }
public void Main() { if (_.GetInventoryDisturbType() != _.INVENTORY_DISTURB_TYPE_ADDED) { return; } NWPlayer pc = (_.GetLastDisturbed()); NWItem item = (_.GetInventoryDisturbItem()); NWPlaceable forge = (NWGameObject.OBJECT_SELF); if (!CheckValidity(forge, pc, item)) { return; } StartSmelt(forge, pc, item); }
public void Main() { NWPlaceable forge = (_.OBJECT_SELF); int charges = forge.GetLocalInt("FORGE_CHARGES"); if (charges > 0) { charges--; forge.SetLocalInt("FORGE_CHARGES", charges); } if (charges <= 0) { NWPlaceable flames = (forge.GetLocalObject("FORGE_FLAMES")); flames.Destroy(); } }
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(_.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 * PerkService.GetCreaturePerkLevel(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(_.DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), pc.Object, baseCraftDelay); pc.AssignCommand(() => _.ActionPlayAnimation(_.ANIMATION_LOOPING_GET_MID, 1.0f, baseCraftDelay)); item.Destroy(); }
public bool Run(params object[] args) { NWPlayer player = _.GetLastOpenedBy(); if (!player.IsPlayer) { return(false); } NWPlaceable terminal = Object.OBJECT_SELF; NWArea area = terminal.Area; int bankID = terminal.GetLocalInt("BANK_ID"); if (bankID <= 0) { Console.WriteLine("WARNING: Bank ID is not set on bank in area: " + area.Name); return(false); } Data.Entity.Bank entity = _data.SingleOrDefault <Data.Entity.Bank>(x => x.ID == bankID); if (entity == null) { entity = new Data.Entity.Bank { AreaName = area.Name, AreaResref = area.Resref, AreaTag = area.Tag, ID = bankID }; _data.SubmitDataChange(entity, DatabaseActionType.Insert); } var bankItems = _data.Where <BankItem>(x => x.PlayerID == player.GlobalID && x.BankID == entity.ID); foreach (BankItem item in bankItems.Where(x => x.PlayerID == player.GlobalID)) { _serialization.DeserializeItem(item.ItemObject, terminal); } terminal.IsLocked = true; player.SendMessage("Walk away from the terminal when you are finished banking."); return(true); }
public bool Run(params object[] args) { if (_.GetInventoryDisturbType() != _.INVENTORY_DISTURB_TYPE_ADDED) { return(false); } NWPlayer pc = (_.GetLastDisturbed()); NWItem item = (_.GetInventoryDisturbItem()); NWPlaceable forge = (Object.OBJECT_SELF); if (!CheckValidity(forge, pc, item)) { return(false); } StartSmelt(forge, pc, item); return(true); }
public bool Run(params object[] args) { NWPlaceable point = NWPlaceable.Wrap(Object.OBJECT_SELF); bool isFullyHarvested = point.GetLocalInt("FORAGE_POINT_FULLY_HARVESTED") == 1; if (isFullyHarvested) { int despawnTicks = point.GetLocalInt("FORAGE_POINT_REFILL_TICKS") - 1; if (despawnTicks <= 0) { despawnTicks = 0; } point.SetLocalInt("FORAGE_POINT_REFILL_TICKS", despawnTicks); } return(true); }
public bool Run(params object[] args) { NWPlaceable device = NWPlaceable.Wrap(Object.OBJECT_SELF); NWObject oPC = NWObject.Wrap(_.GetLastClosedBy()); foreach (NWItem item in device.InventoryItems) { string resref = item.Resref; if (resref != "cft_choose_bp" && resref != "cft_craft_item") { _.CopyItem(item.Object, oPC.Object, TRUE); } item.Destroy(); } return(true); }
private void HandleRemoveItem() { NWPlayer player = _.GetLastDisturbed(); NWItem item = _.GetInventoryDisturbItem(); NWPlaceable device = Object.OBJECT_SELF; var model = MarketService.GetPlayerMarketData(player); // Done previewing an item. Return to menu. if (item.Resref == "exit_preview") { item.Destroy(); device.DestroyAllInventoryItems(); device.IsLocked = false; model.IsAccessingInventory = false; model.IsReturningFromItemPreview = true; DialogService.StartConversation(player, device, "MarketTerminal"); } }
private void SetHeader() { NWPlaceable door = GetDialogTarget().Object; var structureID = new Guid(door.GetLocalString("PC_BASE_STRUCTURE_ID")); PCBaseStructure structure = DataService.PCBaseStructure.GetByID(structureID); PCBase pcBase = DataService.PCBase.GetByID(structure.PCBaseID); Player owner = PlayerService.GetPlayerEntity(pcBase.PlayerID); string buildingName = owner.CharacterName + "'s Building"; if (!string.IsNullOrWhiteSpace(structure.CustomName)) { buildingName = structure.CustomName; } string header = buildingName + "\n\nPlease select an option."; SetPageHeader("MainPage", header); }