示例#1
0
        private static void OnModuleUseFeat()
        {
            NWPlayer pc     = _.OBJECT_SELF;
            int      featID = Convert.ToInt32(NWNXEvents.GetEventData("FEAT_ID"));

            if (featID != (int)Feat.ChatCommandTargeter)
            {
                return;
            }

            var target          = _.StringToObject(NWNXEvents.GetEventData("TARGET_OBJECT_ID"));
            var targetPositionX = (float)Convert.ToDouble(NWNXEvents.GetEventData("TARGET_POSITION_X"));
            var targetPositionY = (float)Convert.ToDouble(NWNXEvents.GetEventData("TARGET_POSITION_Y"));
            var targetPositionZ = (float)Convert.ToDouble(NWNXEvents.GetEventData("TARGET_POSITION_Z"));
            var targetPosition  = Vector3(targetPositionX, targetPositionY, targetPositionZ);
            var targetArea      = _.StringToObject(NWNXEvents.GetEventData("AREA_OBJECT_ID"));

            var    targetLocation = Location(targetArea, targetPosition, 0.0f);
            string command        = pc.GetLocalString("CHAT_COMMAND");
            string args           = pc.GetLocalString("CHAT_COMMAND_ARGS");

            if (string.IsNullOrWhiteSpace(command))
            {
                pc.SendMessage("Please enter a chat command and then use this feat. Type /help to learn more about the available chat commands.");
                return;
            }

            IChatCommand chatCommand = GetChatCommandHandler(command);

            ProcessChatCommand(chatCommand, pc, target, targetLocation, args);

            pc.DeleteLocalString("CHAT_COMMAND");
            pc.DeleteLocalString("CHAT_COMMAND_ARGS");
        }
示例#2
0
        private static void OnModuleUseFeat()
        {
            NWPlayer pc     = Object.OBJECT_SELF;
            int      featID = NWNXEvents.OnFeatUsed_GetFeatID();

            if (featID != (int)CustomFeatType.ChatCommandTargeter)
            {
                return;
            }

            var    target         = NWNXEvents.OnFeatUsed_GetTarget();
            var    targetLocation = NWNXEvents.OnFeatUsed_GetTargetLocation();
            string command        = pc.GetLocalString("CHAT_COMMAND");
            string args           = pc.GetLocalString("CHAT_COMMAND_ARGS");

            if (string.IsNullOrWhiteSpace(command))
            {
                pc.SendMessage("Please enter a chat command and then use this feat. Type /help to learn more about the available chat commands.");
                return;
            }

            IChatCommand chatCommand = GetChatCommandHandler(command);

            ProcessChatCommand(chatCommand, pc, target, targetLocation, args);

            pc.DeleteLocalString("CHAT_COMMAND");
            pc.DeleteLocalString("CHAT_COMMAND_ARGS");
        }
        public void OnModuleUseFeat()
        {
            NWPlayer pc     = Object.OBJECT_SELF;
            int      featID = _nwnxEvents.OnFeatUsed_GetFeatID();

            if (featID != (int)CustomFeatType.ChatCommandTargeter)
            {
                return;
            }

            var    target         = _nwnxEvents.OnFeatUsed_GetTarget();
            var    targetLocation = _nwnxEvents.OnFeatUsed_GetTargetLocation();
            string command        = pc.GetLocalString("CHAT_COMMAND");
            string args           = pc.GetLocalString("CHAT_COMMAND_ARGS");

            if (string.IsNullOrWhiteSpace(command))
            {
                pc.SendMessage("Please enter a chat command and then use this feat. Type /help to learn more about the available chat commands.");
                return;
            }

            App.ResolveByInterface <IChatCommand>("ChatCommand." + command, chatCommand =>
            {
                ProcessChatCommand(chatCommand, pc, target, targetLocation, args);
            });

            pc.DeleteLocalString("CHAT_COMMAND");
            pc.DeleteLocalString("CHAT_COMMAND_ARGS");
        }
示例#4
0
        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();
            }
        }
示例#5
0
        private void ChangeName()
        {
            NWPlayer player = GetPC();

            // Player hasn't specified a new name for this item.
            string newName = player.GetLocalString("RENAMED_ITEM_NEW_NAME");

            if (string.IsNullOrWhiteSpace(newName))
            {
                player.FloatingText("Enter a new name into the chat box, select 'Refresh' then select 'Change Name'.");
                return;
            }
            NWItem item = player.GetLocalObject("ITEM_BEING_RENAMED");

            // Item isn't in player's inventory.
            if (_.GetItemPossessor(item) != player.Object)
            {
                player.FloatingText("Item must be in your inventory in order to rename it.");
                return;
            }

            // Item's original name isn't being stored. Do that now.
            if (string.IsNullOrWhiteSpace(item.GetLocalString("RENAMED_ITEM_ORIGINAL_NAME")))
            {
                item.SetLocalString("RENAMED_ITEM_ORIGINAL_NAME", item.Name);
            }

            item.Name = newName;

            player.FloatingText("Item renamed to '" + newName + "'.");
            EndConversation();
        }
示例#6
0
        private void LoadHeader()
        {
            NWPlayer player = GetPC();

            player.SetLocalBool("ITEM_RENAMING_LISTENING", true);

            NWItem item         = player.GetLocalObject("ITEM_BEING_RENAMED");
            string originalName = item.GetLocalString("RENAMED_ITEM_ORIGINAL_NAME");

            if (string.IsNullOrWhiteSpace(originalName))
            {
                originalName = item.Name;
            }
            string currentName  = item.Name;
            string renamingName = player.GetLocalString("RENAMED_ITEM_NEW_NAME");

            if (string.IsNullOrWhiteSpace(renamingName))
            {
                renamingName = "{UNSPECIFIED}";
            }

            string header = "You are renaming an item.\n\n";

            header += ColorTokenService.Green("Original Name: ") + originalName + "\n";
            header += ColorTokenService.Green("Current Name: ") + currentName + "\n";
            header += ColorTokenService.Green("New Name: ") + renamingName + "\n";
            header += "Type in a new name, click 'Refresh', and then select 'Change Name' to make the changes. Click 'Reset Name' to switch back to the item's original name.";

            SetPageHeader("MainPage", header);
        }
示例#7
0
        public static MapPin GetMapPin(NWPlayer oPC, int index)
        {
            index++;
            MapPin mapPin = new MapPin
            {
                Text      = oPC.GetLocalString("NW_MAP_PIN_NTRY_" + index),
                PositionX = oPC.GetLocalFloat("NW_MAP_PIN_XPOS_" + index),
                PositionY = oPC.GetLocalFloat("NW_MAP_PIN_YPOS_" + index),
                Area      = (oPC.GetLocalObject("NW_MAP_PIN_AREA_" + index)),
                Tag       = oPC.GetLocalString("CUSTOM_NW_MAP_PIN_TAG_" + index),
                Player    = oPC,
                Index     = index
            };

            return(mapPin);
        }
示例#8
0
        /// <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.");
            }
        }
示例#9
0
        public static void HandleQueueWeaponSkill(NWPlayer pc, Data.Entity.Perk entity, IPerkHandler ability, int spellFeatID)
        {
            int?   cooldownCategoryID = ability.CooldownCategoryID(pc, entity.CooldownCategoryID, spellFeatID);
            var    cooldownCategory   = DataService.Get <CooldownCategory>(cooldownCategoryID);
            string queueUUID          = Guid.NewGuid().ToString();

            pc.SetLocalInt("ACTIVE_WEAPON_SKILL", entity.ID);
            pc.SetLocalString("ACTIVE_WEAPON_SKILL_UUID", queueUUID);
            pc.SetLocalInt("ACTIVE_WEAPON_SKILL_FEAT_ID", spellFeatID);
            pc.SendMessage("Weapon skill '" + entity.Name + "' queued for next attack.");

            ApplyCooldown(pc, cooldownCategory, ability, spellFeatID);

            // Player must attack within 30 seconds after queueing or else it wears off.
            _.DelayCommand(30f, () =>
            {
                if (pc.GetLocalString("ACTIVE_WEAPON_SKILL_UUID") == queueUUID)
                {
                    pc.DeleteLocalInt("ACTIVE_WEAPON_SKILL");
                    pc.DeleteLocalString("ACTIVE_WEAPON_SKILL_UUID");
                    pc.DeleteLocalInt("ACTIVE_WEAPON_SKILL_FEAT_ID");
                    pc.SendMessage("Your weapon skill '" + entity.Name + "' is no longer queued.");
                }
            });
        }
示例#10
0
        public static MapPin GetMapPin(NWPlayer oPC, string pinTag)
        {
            for (int index = 0; index <= GetNumberOfMapPins(oPC); index++)
            {
                string mapPinTag = oPC.GetLocalString("CUSTOM_NWN_MAP_PIN_TAG_" + index);
                if (mapPinTag == pinTag)
                {
                    return(GetMapPin(oPC, index));
                }
            }

            return(null); // Couldn't find a map pin by that tag.
        }
示例#11
0
        public void OnModuleClientLeave()
        {
            NWPlayer oPC       = (_.GetExitingObject());
            string   name      = oPC.Name;
            string   cdKey     = oPC.GetLocalString("PC_CD_KEY");
            string   account   = oPC.GetLocalString("PC_ACCOUNT");
            DateTime now       = DateTime.UtcNow;
            string   nowString = now.ToString("yyyy-MM-dd hh:mm:ss");

            Console.WriteLine(nowString + ": " + name + " (" + account + "/" + cdKey + ") left the server.");

            ClientLogEvent entity = new ClientLogEvent
            {
                AccountName          = account,
                CDKey                = cdKey,
                ClientLogEventTypeID = 2,
                PlayerID             = oPC.IsDM ? null : (Guid?)oPC.GlobalID,
                DateOfEvent          = now
            };

            _data.SubmitDataChange(entity, DatabaseActionType.Insert);
        }
示例#12
0
        private static void OnModuleLeave()
        {
            NWPlayer oPC       = (GetExitingObject());
            string   name      = oPC.Name;
            string   cdKey     = oPC.GetLocalString("PC_CD_KEY");
            string   account   = oPC.GetLocalString("PC_ACCOUNT");
            DateTime now       = DateTime.UtcNow;
            string   nowString = now.ToString("yyyy-MM-dd hh:mm:ss");

            Console.WriteLine(nowString + ": " + name + " (" + account + "/" + cdKey + ") left the server.");

            ModuleEvent entity = new ModuleEvent
            {
                AccountName       = account,
                CDKey             = cdKey,
                ModuleEventTypeID = 2,
                PlayerID          = oPC.IsDM ? null : (Guid?)oPC.GlobalID,
                DateOfEvent       = now
            };

            // Bypass the caching logic.
            DataService.DataQueue.Enqueue(new DatabaseAction(entity, DatabaseActionType.Insert));
        }
示例#13
0
        public static void ChangePlayerDescription(NWPlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            string newDescription = player.GetLocalString("NEW_DESCRIPTION_TO_SET");

            _.SetDescription(player.Object, newDescription);
            _.SetDescription(player.Object, newDescription, false);

            _.FloatingTextStringOnCreature("New description set!", player.Object, false);
        }
示例#14
0
        private void HandleQueueWeaponSkill(NWPlayer pc, Data.Entities.Perk entity, IPerk ability)
        {
            string queueUUID = Guid.NewGuid().ToString();

            pc.SetLocalInt("ACTIVE_WEAPON_SKILL", entity.PerkID);
            pc.SetLocalString("ACTIVE_WEAPON_SKILL_UUID", queueUUID);
            pc.SendMessage("Weapon skill '" + entity.Name + "' queued for next attack.");

            ApplyCooldown(pc, entity.CooldownCategory, ability);

            // Player must attack within 30 seconds after queueing or else it wears off.
            pc.DelayCommand(() =>
            {
                if (pc.GetLocalString("ACTIVE_WEAPON_SKILL_UUID") == queueUUID)
                {
                    pc.DeleteLocalInt("ACTIVE_WEAPON_SKILL");
                    pc.DeleteLocalString("ACTIVE_WEAPON_SKILL_UUID");
                    pc.SendMessage("Your weapon skill '" + entity.Name + "' is no longer queued.");
                }
            }, 30.0f);
        }