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 DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { var lastSubmission = user.GetLocalString("RESTART_SERVER_LAST_SUBMISSION"); var isFirstSubmission = true; // Check for the last submission, if any. if (!string.IsNullOrWhiteSpace(lastSubmission)) { // Found one, parse it. var dateTime = DateTime.Parse(lastSubmission); if (DateTime.UtcNow <= dateTime.AddSeconds(15)) { // Player submitted a second request within 15 seconds of the last one. // This is a confirmation they want to restart. isFirstSubmission = false; } } // Player hasn't submitted or time has elapsed if (isFirstSubmission) { user.SetLocalString("RESTART_SERVER_LAST_SUBMISSION", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); user.FloatingText("Please confirm server reset by entering another \"/restartserver <CD Key>\" command within 15 seconds."); } else { foreach (var player in NWModule.Get().Players) { _.BootPC(player, $"A DM has restarted the server. Please reconnect shortly."); } NWNXAdmin.ShutdownServer(); } }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { string command = args[0].ToLower(); Effect effect = EffectVisualEffect((VisualEffect)Int32.Parse(args[0])); _.ApplyEffectAtLocation(DurationType.Instant, effect, targetLocation, 6.0f); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { string command = args[0].ToLower(); if (command == "help") { List <string> commands = new List <string> { "help: Displays this help text." }; foreach (SkillType language in _language.GetLanguages()) { commands.Add($"{language.ToString()}: Sets the active language to {language.ToString()}."); } user.SendMessage(commands.Aggregate((a, b) => a + '\n' + b)); return; } foreach (SkillType language in _language.GetLanguages()) { if (language.ToString().ToLower() == command) { _language.SetActiveLanguage(user, language); user.SendMessage($"Set active language to {language.ToString()}."); return; } } user.SendMessage(_color.Red($"Unknown language {command}.")); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { DateTime now = DateTime.UtcNow; string nowText = now.ToString("yyyy-MM-dd hh:mm:ss"); user.SendMessage("Current Server Date: " + nowText); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { user.AssignCommand(() => { _.ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_BORED); }); }
/// <summary> /// Displays all the chat commands available to a user /// </summary> /// <param name="user"></param> /// <param name="target"></param> /// <param name="targetLocation"></param> /// <param name="args"></param> public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { bool isDM = user.IsDM || AuthorizationService.IsPCRegisteredAsDM(user); var classes = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => typeof(IChatCommand).IsAssignableFrom(p) && p.IsClass) .OrderBy(o => o.Name) .ToArray(); foreach (var @class in classes) { var attribute = @class.GetCustomAttribute <CommandDetailsAttribute>(); if (attribute == null) { continue; } if (attribute.Permissions.HasFlag(CommandPermissionType.Player) && user.IsPlayer || attribute.Permissions.HasFlag(CommandPermissionType.DM) && isDM) { user.SendMessage(ColorTokenService.Green("/" + @class.Name.ToLower()) + ColorTokenService.White(": " + attribute.Description)); } } }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { string name = args[0]; string cdKey = args[1].ToUpper(); var record = DataService.AuthorizedDM.GetByCDKeyAndActiveOrDefault(cdKey); var method = DatabaseActionType.Update; if (record == null) { method = DatabaseActionType.Insert; int id = DataService.AuthorizedDM.GetAll().Max(x => x.ID) + 1; record = new AuthorizedDM { ID = id, CDKey = cdKey }; } record.Name = name; record.DMRole = 1; record.IsActive = true; DataService.SubmitDataChange(record, method); user.SendMessage("DM '" + name + "' has been added successfully."); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { // Did the player pass in the 'end' argument? If so, we're ending the concentration effect. bool doEnd = args.Length > 0 && args[0] == "end"; if (doEnd) { AbilityService.EndConcentrationEffect(user); user.SendMessage("You have ended your concentration ability."); } // Otherwise just notify them about what effect is currently active. else { var effect = AbilityService.GetActiveConcentrationEffect(user); if (effect.Type == PerkType.Unknown) { user.SendMessage("No concentration ability is currently active."); } else { var perk = PerkService.GetPerkByID((int)effect.Type); user.SendMessage("Currently active concentration ability: " + perk.Name); } } }
/// <summary> /// Exports user's character bic file. /// </summary> /// <param name="user"></param> /// <param name="target"></param> /// <param name="targetLocation"></param> /// <param name="args"></param> public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { PlayerService.SaveCharacter(user); PlayerService.SaveLocation(user); _.ExportSingleCharacter(user.Object); _.SendMessageToPC(user.Object, "Character saved successfully."); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { // Check timestamp var lastRun = GetLocalString(user, "STUCK_LOCATION_LAST_RUN"); if (!string.IsNullOrWhiteSpace(lastRun)) { var dateTime = DateTime.ParseExact(lastRun, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); if (DateTime.UtcNow < dateTime.AddMinutes(30)) { SendMessageToPC(user, "This command can only be used once every 30 minutes."); return; } } var location = GetLocalLocation(user, "STUCK_LOCATION_RESET"); AssignCommand(user, () => { ClearAllActions(); JumpToLocation(location); }); SetLocalString(user, "STUCK_LOCATION_LAST_RUN", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { Enumeration.EmoteStyle curStyle = EmoteStyleService.GetEmoteStyle(user); Enumeration.EmoteStyle newStyle = curStyle == Enumeration.EmoteStyle.Novel ? Enumeration.EmoteStyle.Regular : Enumeration.EmoteStyle.Novel; EmoteStyleService.SetEmoteStyle(user, newStyle); user.SendMessage($"Toggled emote style to {newStyle.ToString()}."); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { user.AssignCommand(() => { _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID); }); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { user.AssignCommand(() => { _.ActionPlayAnimation(Animation.LoopingGetLow); }); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { user.AssignCommand(() => { _.ActionPlayAnimation(Animation.FireForgetDodgeDuck); }); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { string message = string.Empty; foreach (var arg in args) { message += " " + arg; } if (message.Length > 1000) { user.SendMessage("Your message was too long. Please shorten it to no longer than 1000 characters and resubmit the bug. For reference, your message was: \"" + message + "\""); return; } BugReport report = new BugReport { SenderPlayerID = user.IsPlayer ? new Guid?(user.GlobalID): null, CDKey = _.GetPCPublicCDKey(user), Text = message, TargetName = target.IsValid ? target.Name : user.Name, AreaResref = user.Area.Resref, SenderLocationX = user.Location.X, SenderLocationY = user.Location.Y, SenderLocationZ = user.Location.Z, SenderLocationOrientation = user.Location.Orientation, DateSubmitted = DateTime.UtcNow }; // Bypass the cache and save directly to the DB. DataService.DataQueue.Enqueue(new DatabaseAction(report, DatabaseActionType.Insert)); user.SendMessage("Bug report submitted! Thank you for your report."); }
/// <summary> /// Deletes a player's character. Player must submit the command twice within 30 seconds. /// </summary> /// <param name="user"></param> /// <param name="target"></param> /// <param name="targetLocation"></param> /// <param name="args"></param> public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { string lastSubmission = user.GetLocalString("DELETE_CHARACTER_LAST_SUBMISSION"); bool isFirstSubmission = true; // Check for the last submission, if any. if (!string.IsNullOrWhiteSpace(lastSubmission)) { // Found one, parse it. DateTime dateTime = DateTime.Parse(lastSubmission); if (DateTime.UtcNow <= dateTime.AddSeconds(30)) { // Player submitted a second request within 30 seconds of the last one. // This is a confirmation they want to delete. isFirstSubmission = false; } } // Player hasn't submitted or time has elapsed if (isFirstSubmission) { user.SetLocalString("DELETE_CHARACTER_LAST_SUBMISSION", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); user.FloatingText("Please confirm your deletion by entering another \"/delete <CD Key>\" command within 30 seconds."); } else { Player dbPlayer = DataService.Player.GetByID(user.GlobalID); dbPlayer.IsDeleted = true; DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update); NWNXAdmin.DeletePlayerCharacter(user, true, "Your character has been deleted."); } }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { if (!target.IsPlayer) { user.SendMessage("Only players may be targeted with this command."); return; } NWPlayer player = target.Object; var dbPlayer = DataService.Player.GetByID(player.GlobalID); int leaseRate = int.Parse(args[0]); dbPlayer.LeaseRate = leaseRate; DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update); user.SendMessage(player.Name + ": Lease rate set to " + dbPlayer.LeaseRate + "%"); if (leaseRate == 0) { player.FloatingText("Your lease rate has returned to normal."); } else if (leaseRate > 0) { player.FloatingText("Your lease rate has increased to " + dbPlayer.LeaseRate + "% of normal."); } else if (leaseRate < 0) { player.FloatingText("Your lease rate has decreased to " + dbPlayer.LeaseRate + "% of normal."); } }
public void Main() { NWObject door = NWGameObject.OBJECT_SELF; NWArea area = door.Area; NWPlayer player = GetClickingObject(); if (!player.IsValid) { player = GetLastUsedBy(); } int remainingKeyCards = area.GetLocalInt("KEY_CARDS_REMAINING"); if (remainingKeyCards > 0) { player.FloatingText("You need " + remainingKeyCards + "x key card(s) to access this elevator."); } else { player.FloatingText("You access the elevator with the found key cards."); string destinationWPTag = door.GetLocalString("DESTINATION_WAYPOINT"); string destinationAreaTag = door.GetLocalString("DESTINATION_AREA_TAG"); NWArea destinationArea = area.GetLocalObject(destinationAreaTag); NWLocation destinationLocation = GetLocation(GetNearestObjectByTag(destinationWPTag, GetFirstObjectInArea(destinationArea))); player.AssignCommand(() => { ActionJumpToLocation(destinationLocation); }); } }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { string command = args[0].ToLower(); switch (command) { case "help": DoHelp(user); break; case "d2": case "d4": case "d6": case "d8": case "d10": case "d20": case "d100": int sides = Convert.ToInt32(command.Substring(1)); int count = 1; if (args.Length > 1) { if (!int.TryParse(args[1], out count)) { count = 1; } } DoDiceRoll(user, sides, count); break; default: user.SendMessage(GenericError); return; } }
public NWPlaceable SpawnStructure(NWArea area, Guid pcBaseStructureID) { PCBaseStructure pcStructure = _data.Get <PCBaseStructure>(pcBaseStructureID); PCBase pcBase = _data.Get <PCBase>(pcStructure.PCBaseID); BaseStructure baseStructure = _data.Get <BaseStructure>(pcStructure.BaseStructureID); var exteriorStyle = _data.Get <BuildingStyle>(pcStructure.ExteriorStyleID); NWLocation location = _.Location(area.Object, _.Vector((float)pcStructure.LocationX, (float)pcStructure.LocationY, (float)pcStructure.LocationZ), (float)pcStructure.LocationOrientation); BaseStructureType structureType = (BaseStructureType)baseStructure.BaseStructureTypeID; string resref = baseStructure.PlaceableResref; List <AreaStructure> areaStructures = area.Data["BASE_SERVICE_STRUCTURES"]; if (string.IsNullOrWhiteSpace(resref) && structureType == BaseStructureType.Building) { resref = exteriorStyle.Resref; } NWPlaceable plc = (_.CreateObject(OBJECT_TYPE_PLACEABLE, resref, location)); plc.SetLocalString("PC_BASE_STRUCTURE_ID", pcStructure.ID.ToString()); plc.SetLocalInt("REQUIRES_BASE_POWER", baseStructure.RequiresBasePower ? 1 : 0); plc.SetLocalString("ORIGINAL_SCRIPT_CLOSED", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_CLOSED)); plc.SetLocalString("ORIGINAL_SCRIPT_DAMAGED", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_DAMAGED)); plc.SetLocalString("ORIGINAL_SCRIPT_DEATH", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_DEATH)); plc.SetLocalString("ORIGINAL_SCRIPT_HEARTBEAT", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_HEARTBEAT)); plc.SetLocalString("ORIGINAL_SCRIPT_INVENTORYDISTURBED", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_INVENTORYDISTURBED)); plc.SetLocalString("ORIGINAL_SCRIPT_LOCK", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_LOCK)); plc.SetLocalString("ORIGINAL_SCRIPT_MELEEATTACKED", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_MELEEATTACKED)); plc.SetLocalString("ORIGINAL_SCRIPT_OPEN", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_OPEN)); plc.SetLocalString("ORIGINAL_SCRIPT_SPELLCASTAT", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_SPELLCASTAT)); plc.SetLocalString("ORIGINAL_SCRIPT_UNLOCK", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_UNLOCK)); plc.SetLocalString("ORIGINAL_SCRIPT_USED", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_USED)); plc.SetLocalString("ORIGINAL_SCRIPT_USER_DEFINED_EVENT", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_USER_DEFINED_EVENT)); plc.SetLocalString("ORIGINAL_SCRIPT_LEFT_CLICK", _.GetEventScript(plc.Object, EVENT_SCRIPT_PLACEABLE_ON_LEFT_CLICK)); plc.SetLocalString("ORIGINAL_JAVA_SCRIPT_1", _.GetLocalString(plc.Object, "JAVA_SCRIPT_1")); NWPlaceable door = null; if (structureType == BaseStructureType.Building) { door = SpawnBuildingDoor(exteriorStyle.DoorRule, plc); areaStructures.Add(new AreaStructure(pcStructure.PCBaseID, pcStructure.ID, door, false, null)); } areaStructures.Add(new AreaStructure(pcStructure.PCBaseID, pcStructure.ID, plc, true, door)); if (area.IsInstance && area.GetLocalInt("PC_BASE_STRUCTURE_ID") > 0) { if (DateTime.UtcNow > pcBase.DateFuelEnds && pcBase.Fuel <= 0) { ToggleInstanceObjectPower(area, false); } } return(plc); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { var id = Convert.ToInt32(args[0]); var record = DataService.AuthorizedDM.GetByID(id); var userCDKey = GetPCPublicCDKey(user); if (record == null) { user.SendMessage("Unable to locate an authorized DM with ID #" + id + ". Use the /GetDMs command to find a valid ID."); return; } if (record.CDKey == userCDKey) { user.SendMessage("You cannot remove yourself from the authorized DM list."); return; } if (!record.IsActive) { user.SendMessage("That DM has already been deactivated."); return; } record.IsActive = false; DataService.SubmitDataChange(record, DatabaseActionType.Update); foreach (var dm in AppCache.ConnectedDMs) { if (GetPCPublicCDKey(dm) == record.CDKey) { BootPC(dm, "Your DM authorization has been revoked."); } } }
/// <summary> /// Returns the X and Y position, in tiles, of the user. /// </summary> /// <param name="user"></param> /// <param name="target"></param> /// <param name="targetLocation"></param> /// <param name="args"></param> public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { Vector position = user.Position; int cellX = (int)(position.m_X / 10); int cellY = (int)(position.m_Y / 10); user.SendMessage($"Current Area Coordinates: ({cellX}, {cellY})"); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { foreach (var item in DataService.Cache) { user.SendMessage(item.Key + ": " + item.Value.Count); Console.WriteLine(item.Key + ": " + item.Value.Count); } }
public ObjectSpawn(NWLocation location, bool isStaticSpawnPoint, int spawnTableID, float respawnTime = 120.0f) { Spawn = new Object(); SpawnLocation = location; IsStaticSpawnPoint = isStaticSpawnPoint; RespawnTime = respawnTime; SpawnTableID = spawnTableID; Respawns = true; }
/// <summary> /// Revives and heals user completely. /// </summary> /// <param name="user"></param> /// <param name="target"></param> /// <param name="targetLocation"></param> /// <param name="args"></param> public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { if (user.IsDead) { _.ApplyEffectToObject(NWScript.DURATION_TYPE_INSTANT, _.EffectResurrection(), user.Object); } _.ApplyEffectToObject(NWScript.DURATION_TYPE_INSTANT, _.EffectHeal(999), user.Object); }
public ObjectSpawn(NWLocation location, bool isStaticSpawnPoint, string resref, float respawnTime = 120.0f) { Spawn = new Object(); SpawnLocation = location; IsStaticSpawnPoint = isStaticSpawnPoint; RespawnTime = respawnTime; Resref = resref; Respawns = true; }
/// <summary> /// Revives and heals user completely. /// </summary> /// <param name="user"></param> /// <param name="target"></param> /// <param name="targetLocation"></param> /// <param name="args"></param> public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { if (user.IsDead) { _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectResurrection(), user.Object); } _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectHeal(999), user.Object); AbilityService.RestorePlayerFP(user, 9999); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { if (!user.IsPlayer) { return; } Player entity = DataService.Player.GetByID(user.GlobalID); user.SendMessage(ColorTokenService.Custom("FP: " + entity.CurrentFP + " / " + entity.MaxFP, 32, 223, 219)); }
public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args) { if (!user.IsPlayer) { return; } Player entity = _data.Get <Player>(user.GlobalID); user.SendMessage(_color.Custom("FP: " + entity.CurrentFP + " / " + entity.MaxFP, 32, 223, 219)); }