private void TeleportPlayerToBindPoint(NWObject pc, PlayerCharacter entity) { if (entity.CurrentHunger < 50) { entity.CurrentHunger = 50; } if (string.IsNullOrWhiteSpace(entity.RespawnAreaTag)) { NWObject defaultRespawn = NWObject.Wrap(_.GetWaypointByTag("DEFAULT_RESPAWN_POINT")); Location location = defaultRespawn.Location; pc.AssignCommand(() => { _.ActionJumpToLocation(location); }); } else { pc.AssignCommand(() => { NWArea area = NWArea.Wrap(_.GetObjectByTag(entity.RespawnAreaTag)); Vector position = _.Vector((float)entity.RespawnLocationX, (float)entity.RespawnLocationY, (float)entity.RespawnLocationZ); Location location = _.Location(area.Object, position, (float)entity.RespawnLocationOrientation); _.ActionJumpToLocation(location); }); } }
private static void TeleportPlayerToBindPoint(NWObject pc, Player entity) { // Instances if (pc.Area.IsInstance) { var area = pc.Area; NWLocation entrance = area.GetLocalLocation("INSTANCE_ENTRANCE"); pc.AssignCommand(() => { _.ActionJumpToLocation(entrance); }); } // Send player to default respawn point if no bind point is set. else if (string.IsNullOrWhiteSpace(entity.RespawnAreaResref)) { NWObject defaultRespawn = _.GetWaypointByTag("DEFAULT_RESPAWN_POINT"); Location location = defaultRespawn.Location; pc.AssignCommand(() => { _.ActionJumpToLocation(location); }); } // Send player to their stored bind point. else { NWArea area = NWModule.Get().Areas.Single(x => x.Resref == entity.RespawnAreaResref); Vector position = _.Vector((float)entity.RespawnLocationX, (float)entity.RespawnLocationY, (float)entity.RespawnLocationZ); Location location = _.Location(area.Object, position, (float)entity.RespawnLocationOrientation); pc.AssignCommand(() => { _.ActionJumpToLocation(location); }); } }
public void TurnToFaceObject(NWObject oObjectToFace, NWObject oTarget) { oTarget.AssignCommand(() => { _.SetFacingPoint(oObjectToFace.Position); }); }
/// <summary> /// Causes object to face another object. /// </summary> /// <param name="objectToFace">The object to face towards</param> /// <param name="facer">The object which will change facing</param> public static void TurnToFaceObject(NWObject objectToFace, NWObject facer) { facer.AssignCommand(() => { _.SetFacingPoint(objectToFace.Position); }); }
public bool Run(params object[] args) { NWObject oPC = NWObject.Wrap(_.GetLastUsedBy()); oPC.AssignCommand(() => _.ActionAttack(Object.OBJECT_SELF)); return(true); }
public void Main() { NWPlaceable overridePlaceable = _.OBJECT_SELF; NWObject door = _.GetNearestObjectByTag("aban_director_exit", overridePlaceable); NWPlayer player = _.GetLastUsedBy(); door.AssignCommand(() =>_.SetLocked(door, false)); int questID = overridePlaceable.GetLocalInt("QUEST_ID_1"); _.SpeakString("The tractor beam has been disabled. A door in this room has unlocked."); NWArea mainLevel = overridePlaceable.Area.GetLocalObject("MAIN_LEVEL"); NWArea restrictedLevel = overridePlaceable.Area.GetLocalObject("RESTRICTED_LEVEL"); NWArea directorsChambers = overridePlaceable.Area.GetLocalObject("DIRECTORS_CHAMBERS"); // Enable the shuttle back to Viscara object. NWPlaceable teleportObject = _.GetNearestObjectByTag("aban_shuttle_exit", mainLevel); teleportObject.IsUseable = true; var quest = QuestService.GetQuestByID(questID); // Advance each party member's quest progression if they are in one of these three instance areas. foreach (var member in player.PartyMembers) { // Not in one of the three areas? Move to the next member. NWArea area = member.Area; if (area != mainLevel && area != restrictedLevel && area != directorsChambers) continue; quest.Advance(member.Object, overridePlaceable); } // Disable this placeable from being used again for this instance. overridePlaceable.IsUseable = false; }
/// <summary> /// Causes object to face a location /// </summary> /// <param name="locationToFace">The location to face towards</param> /// <param name="facer">The object which will change facing</param> public static void TurnToFaceLocation(Location locationToFace, NWObject facer) { facer.AssignCommand(() => { _.SetFacingPoint(_.GetPositionFromLocation(locationToFace)); }); }
public void Main() { NWObject user = _.GetLastUsedBy(); user.AssignCommand(() => { _.ActionSit(NWGameObject.OBJECT_SELF); }); }
public bool Run(params object[] args) { NWObject user = NWObject.Wrap(_.GetLastUsedBy()); user.AssignCommand(() => { _.ActionSit(Object.OBJECT_SELF); }); return(true); }
public void Run(NWPlayer player, NWObject questSource, int questID, string[] args) { string resref = args[0]; int amount = 1; if (args.Length > 1) { amount = Convert.ToInt32(args[1]); } if (amount < 1) { amount = 1; } else if (amount > 99) { amount = 99; } if (string.IsNullOrWhiteSpace(resref)) { questSource.AssignCommand(() => { _.SpeakString("GiveItemRule misconfigured. Must set resref as first argument. Notify an admin."); }); return; } NWItem item = _.CreateItemOnObject(resref, player, amount); if (!item.IsValid) { questSource.AssignCommand(() => { _.SpeakString("GiveItemRule misconfigured. Couldn't locate item with resref '" + resref + "'. Notify an admin."); }); } }
public void Run(NWPlayer player, NWObject questSource, int questID, string[] args) { int amount = Convert.ToInt32(args[0]); if (amount <= 0) { questSource.AssignCommand(() => { _.SpeakString("CreditBonusRule misconfigured. Must set credit amount as first argument. Notify an admin."); }); return; } _.GiveGoldToCreature(player, amount); }
public void ReturnItem(NWObject target, NWItem item) { if (_.GetHasInventory(item) == TRUE) { NWObject possessor = item.Possessor; possessor.AssignCommand(() => { _.ActionGiveItem(item, target); }); } else { _.CopyItem(item.Object, target.Object, TRUE); item.Destroy(); } }
public static void ReturnItem(NWObject target, NWItem item) { if (GetHasInventory(item) == true) { NWObject possessor = item.Possessor; possessor.AssignCommand(() => { ActionGiveItem(item, target); }); } else { CopyItem(item.Object, target.Object, true); item.Destroy(); } }
public void AdjustVisibility(NWPlayer player, NWObject target, bool isVisible) { if (!player.IsPlayer) { return; } if (target.IsPlayer || target.IsDM) { return; } string visibilityObjectID = target.GetLocalString("VISIBILITY_OBJECT_ID"); if (string.IsNullOrWhiteSpace(visibilityObjectID)) { target.AssignCommand(() => { _.SpeakString("Unable to locate VISIBILITY_OBJECT_ID variable. Need this in order to adjust visibility. Notify an admin if you see this message."); }); return; } var visibility = _data.SingleOrDefault <PCObjectVisibility>(x => x.PlayerID == player.GlobalID && x.VisibilityObjectID == visibilityObjectID); DatabaseActionType action = DatabaseActionType.Update; if (visibility == null) { visibility = new PCObjectVisibility { PlayerID = player.GlobalID, VisibilityObjectID = visibilityObjectID }; action = DatabaseActionType.Insert; } visibility.IsVisible = isVisible; _data.SubmitDataChange(visibility, action); if (visibility.IsVisible) { _nwnxPlayer.SetVisibilityOverride(player, target, (int)PlayerVisibilityType.Visible); } else { _nwnxPlayer.SetVisibilityOverride(player, target, (int)PlayerVisibilityType.Hidden); } }
public bool Run(params object[] args) { NWObject oPC = NWObject.Wrap(_.GetLastUsedBy()); NWPlaceable self = NWPlaceable.Wrap(Object.OBJECT_SELF); string destination = self.GetLocalString("DESTINATION"); int visualEffectID = self.GetLocalInt("VISUAL_EFFECT"); if (visualEffectID > 0) { _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(visualEffectID), oPC.Object); } oPC.AssignCommand(() => { Location location = _.GetLocation(_.GetWaypointByTag(destination)); _.ActionJumpToLocation(location); }); return(true); }
public static void StartConversation(NWPlayer player, NWObject talkTo, string @class) { if (string.IsNullOrWhiteSpace(@class)) { throw new ArgumentException(nameof(@class), nameof(@class) + " cannot be null, empty, or whitespace."); } LoadConversation(player, talkTo, @class, -1); PlayerDialog dialog = AppCache.PlayerDialogs[player.GlobalID]; // NPC conversations if (GetObjectType(talkTo) == ObjectType.Creature && !talkTo.IsPlayer && !talkTo.IsDM) { talkTo.AssignCommand(() => ActionStartConversation(player, "dialog" + dialog.DialogNumber, true, false)); } // Everything else else { player.AssignCommand(() => ActionStartConversation(talkTo.Object, "dialog" + dialog.DialogNumber, true, false)); } }
private static void ProcessCorpse() { SetIsDestroyable(false); NWObject self = _.OBJECT_SELF; if (self.Tag == "spaceship_copy") { return; } Vector3 lootPosition = Vector3(self.Position.X, self.Position.Y, self.Position.Z - 0.11f); Location spawnLocation = Location(self.Area, lootPosition, self.Facing); NWPlaceable container = CreateObject(ObjectType.Placeable, "corpse", spawnLocation); container.SetLocalObject("CORPSE_BODY", self); container.Name = self.Name + "'s Corpse"; container.AssignCommand(() => { TakeGoldFromCreature(self.Gold, self); }); // Dump equipped items in container for (var slot = 0; slot < NumberOfInventorySlots; slot++) { var inventorySlot = (InventorySlot)slot; if (inventorySlot == InventorySlot.CreatureArmor || inventorySlot == InventorySlot.CreatureBite || inventorySlot == InventorySlot.CreatureRight || inventorySlot == InventorySlot.CreatureLeft) { continue; } NWItem item = GetItemInSlot(inventorySlot, self); if (item.IsValid && !item.IsCursed && item.IsDroppable) { NWItem copy = CopyItem(item, container, true); if (inventorySlot == InventorySlot.Head || inventorySlot == InventorySlot.Chest) { copy.SetLocalObject("CORPSE_ITEM_COPY", item); } else { item.Destroy(); } } } foreach (var item in self.InventoryItems) { if (item.IsValid && !item.IsCursed && item.IsDroppable) { CopyItem(item, container, true); item.Destroy(); } } DelayCommand(300.0f, () => { if (!container.IsValid) { return; } NWObject body = container.GetLocalObject("CORPSE_BODY"); body.AssignCommand(() => SetIsDestroyable(true)); body.DestroyAllInventoryItems(); body.Destroy(); container.DestroyAllInventoryItems(); container.Destroy(); }); }
private static void ProcessCorpse() { SetIsDestroyable(FALSE); NWObject self = NWGameObject.OBJECT_SELF; if (self.Tag == "spaceship_copy") { return; } Vector lootPosition = Vector(self.Position.m_X, self.Position.m_Y, self.Position.m_Z - 0.11f); Location spawnLocation = Location(self.Area, lootPosition, self.Facing); NWPlaceable container = CreateObject(OBJECT_TYPE_PLACEABLE, "corpse", spawnLocation); container.SetLocalObject("CORPSE_BODY", self); container.Name = self.Name + "'s Corpse"; container.AssignCommand(() => { TakeGoldFromCreature(self.Gold, self); }); // Dump equipped items in container for (int slot = 0; slot < NUM_INVENTORY_SLOTS; slot++) { if (slot == INVENTORY_SLOT_CARMOUR || slot == INVENTORY_SLOT_CWEAPON_B || slot == INVENTORY_SLOT_CWEAPON_L || slot == INVENTORY_SLOT_CWEAPON_R) { continue; } NWItem item = GetItemInSlot(slot, self); if (item.IsValid && !item.IsCursed && item.IsDroppable) { NWItem copy = CopyItem(item, container, TRUE); if (slot == INVENTORY_SLOT_HEAD || slot == INVENTORY_SLOT_CHEST) { copy.SetLocalObject("CORPSE_ITEM_COPY", item); } else { item.Destroy(); } } } foreach (var item in self.InventoryItems) { CopyItem(item, container, TRUE); item.Destroy(); } DelayCommand(360.0f, () => { if (!container.IsValid) { return; } NWObject body = container.GetLocalObject("CORPSE_BODY"); body.AssignCommand(() => SetIsDestroyable(TRUE)); body.DestroyAllInventoryItems(); body.Destroy(); container.DestroyAllInventoryItems(); container.Destroy(); }); }