177 lines
6.5 KiB
Plaintext
177 lines
6.5 KiB
Plaintext
#include "anph_cfg"
|
|
#include "dbg_inc"
|
|
#include "dev_inc"
|
|
#include "faction_inc"
|
|
#include "nwnx_player"
|
|
#include "nwnx_creature"
|
|
#include "nwnx_webhook"
|
|
#include "nwnx_admin"
|
|
#include "nwnx_time"
|
|
#include "pat_inc"
|
|
#include "socket_inc"
|
|
#include "ip_inc"
|
|
|
|
const string WEBHOOK_DM = "/api/webhooks/1282444730202067058/IsS4ikaaqCNiB8YCaQc4StVz6ih2FeQo7jS5CAq67Qu45Y942So_f2l1O4UbIDLuXSDm/slack";
|
|
|
|
const string BADPARSE = "[BADPARSE]";
|
|
string ParseCommand(string sMessage, string sCommand)
|
|
{
|
|
int sCommandLen = GetStringLength(sCommand);
|
|
if (GetStringLeft(sMessage, sCommandLen) == sCommand)
|
|
return GetSubString(sMessage, sCommandLen+1, GetStringLength(sMessage)-sCommandLen-1);
|
|
else
|
|
return BADPARSE;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
object oDM = GetPCChatSpeaker();
|
|
if (!dev_IsTeamMember(oDM))
|
|
{
|
|
dbg_Warning("dev_commands called on non-team PC", oDM);
|
|
return;
|
|
}
|
|
|
|
string sParams;
|
|
string sMessage = GetPCChatMessage();
|
|
|
|
if ((sParams = ParseCommand(sMessage, "#modname")) != BADPARSE)
|
|
{
|
|
if (sParams == "" || sParams == " ")
|
|
sParams = "Anphillia " + ANPH_VERSION + " (" + NWNX_Time_GetSystemDate() +")";
|
|
NWNX_Administration_SetModuleName(sParams);
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#password")) != BADPARSE)
|
|
{
|
|
if (sParams == "" || sParams == " ")
|
|
NWNX_Administration_ClearPlayerPassword();
|
|
else
|
|
NWNX_Administration_SetPlayerPassword(sParams);
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#xp")) != BADPARSE)
|
|
{
|
|
if (sParams == "reload")
|
|
ExecuteScript("xp_reload", OBJECT_SELF);
|
|
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "XP tables reloaded from database" + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#faction")) != BADPARSE)
|
|
{
|
|
if (sParams == "reset")
|
|
{
|
|
object oPC = GetFirstPC();
|
|
while (oPC != OBJECT_INVALID)
|
|
{
|
|
fctn_UpdateReputation(oPC);
|
|
oPC = GetNextPC();
|
|
}
|
|
}
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "Faction relations for PCs reset." + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#gainxp")) != BADPARSE)
|
|
{
|
|
GiveXPToCreature(oDM, StringToInt(sParams));
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#area")) != BADPARSE)
|
|
{
|
|
if (sParams == "neutral")
|
|
{
|
|
SetLocalInt(GetArea(oDM), "AREA_NEUTRAL_ZONE", 1);
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "Area " + GetName(GetArea(oDM)) + " is now a neutral zone." + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
else if (sParams == "pvp")
|
|
{
|
|
SetLocalInt(GetArea(oDM), "AREA_NEUTRAL_ZONE", 0);
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "Area " + GetName(GetArea(oDM)) + " is now a pvp zone." + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#encounter")) != BADPARSE)
|
|
{
|
|
if (sParams == "on")
|
|
{
|
|
util_ToggleEncountersInArea(GetArea(oDM), TRUE);
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "Enabled encounters in " + GetName(GetArea(oDM)) + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
else if (sParams == "off")
|
|
{
|
|
util_ToggleEncountersInArea(GetArea(oDM), FALSE);
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "Disabled encounters in " + GetName(GetArea(oDM)) + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#gainitem")) != BADPARSE)
|
|
{
|
|
CreateItemOnObject(sParams, oDM, max(1, StringToInt(sParams)));
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#pat")) != BADPARSE)
|
|
{
|
|
if (sParams == "clearareacache")
|
|
{
|
|
pat_ClearAreaCache();
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "PAT Area CR Cache cleared" + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
if (sParams == "updateareas")
|
|
{
|
|
pat_UpdateAreasTable();
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "PAT Area table updated" + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
if (GetStringLeft(sParams, 4) == "dmcr")
|
|
{
|
|
int nCR = StringToInt(GetStringRight(sParams, GetStringLength(sParams) - 5));
|
|
pat_SetDMSetting(oDM, nCR);
|
|
string sHint;
|
|
switch (nCR)
|
|
{
|
|
case 0: sHint = "Use Area Setting"; break;
|
|
case -1: sHint = "PAT deactivated"; break;
|
|
default: sHint = "Override Area Setting"; break;
|
|
}
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "PAT Personal Spawn Setting modified to " + IntToString(nCR) + " (" + sHint + ")" + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
}
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#socket")) != BADPARSE)
|
|
{
|
|
if (sParams == "reload")
|
|
{
|
|
socket_DropTables();
|
|
ExecuteScript("socket_ini", GetModule());
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "SOCKET Database reinitialized" + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
}
|
|
else if ((sParams = ParseCommand(sMessage, "#ip")) != BADPARSE)
|
|
{
|
|
if (sParams == "reload")
|
|
{
|
|
ip_DropTable();
|
|
ExecuteScript("ip_ini", GetModule());
|
|
string sNotification = COLOR_CODE_BLUE_DARK + "IP Database reinitialized" + COLOR_CODE_END;
|
|
SendMessageToPC(oDM, sNotification);
|
|
SendMessageToAllDMs(sNotification);
|
|
}
|
|
}
|
|
else return;
|
|
|
|
string sMsg = GetName(oDM) + " used command " + sMessage;
|
|
NWNX_WebHook_SendWebHookHTTPS("discordapp.com", WEBHOOK_DM, sMsg, GetName(oDM));
|
|
WriteTimestampedLogEntry(sMsg);
|
|
SetPCChatMessage("");
|
|
}
|