Files
Anphillia_PRC8/_module/nss/anph_inc.nss
Jaysyn904 28cdb617b3 Initial commit
Adding all of the current content for Anphillia Unlimited.
2024-01-04 07:49:38 -05:00

312 lines
9.0 KiB
Plaintext

// General include file for Anphillia
#include "util_inc"
#include "util_names_inc"
#include "chr_inc"
#include "dbg_inc"
#include "faction_inc"
#include "nwnx_webhook"
// These are test-includes to see if the script compiles at all
//#include "hc_inc"
//#include "anph_config_inc"
/* FACTION SETTINGS
These set up all Factions in the game, you can freely add up to this list
as long as you provide the item blueprints, start locations etc...
Maximum Faction Count = 9 */
const int ANPH_NUMBER_OF_FACTIONS = 6;
const string WEBHOOK_ALARM = "/api/webhooks/451346097038819329/5pPVJiIzLucPzWD-Vdh0Efdu5EKr6x1G57S45DHfcG84W8R-_Y_rno78xTryqWcEzo-F/slack";
string anph_DescribePC(object oPC)
{
string s = GetName(oPC);
if (GetIsPC(oPC))
{
if (GetIsDM(oPC)) s += "(DM)";
s += " - Player: " + GetPCPlayerName(oPC);
s += "; CDKey: " + GetPCPublicCDKey(oPC);
s += "; IP: " + GetPCIPAddress(oPC);
s += "; PCID: " + IntToString(chr_GetPCID(oPC));
}
s += "\n";
s += " " + util_GetRaceName(GetRacialType(oPC)) + "(" + GetSubRace(oPC) + ") ";
s += util_GetGenderName(GetGender(oPC)) + " ";
s += util_GetClassName(GetClassByPosition(1, oPC)) + " " + IntToString(GetLevelByPosition(1, oPC));
if (GetLevelByPosition(2, oPC))
s += "/" + util_GetClassName(GetClassByPosition(3, oPC)) + " " + IntToString(GetLevelByPosition(2, oPC));
if (GetLevelByPosition(3, oPC))
s += "/" + util_GetClassName(GetClassByPosition(3, oPC)) + " " + IntToString(GetLevelByPosition(3, oPC));
s += "(" + IntToString(GetXP(oPC)) + " XP)";
s += " Faction: " + fctn_GetFactionName(fctn_GetFaction(oPC));
s += " Gold: " + IntToString(GetGold(oPC));
s += "\n";
s += " Deity: " + GetDeity(oPC);
s += " Age: " + IntToString(GetAge(oPC));
return s;
}
/* This function saves all faction-relevant data to Local Variables */
object AnphFindPlayerByKey (string sName, string sCDK)
{
string sID = sCDK + sName;
string sThisName;
string sThisCDK;
string sThisID;
object oPC = GetFirstPC();
while (GetIsObjectValid (oPC) == TRUE)
{
sThisName = GetName (oPC);
sThisCDK = GetPCPublicCDKey (oPC);
sThisID = sThisCDK + sThisName;
if (sThisID == sID)
{
return (oPC);
}
oPC = GetNextPC ();
}
return (OBJECT_INVALID);
}
string AnphFastGetPlayerTeam(object oPC)
{
return fctn_GetFactionName(fctn_GetFaction(oPC));
}
int AnphFastGetPlayerTeamInt(object oPC)
{
return fctn_GetFaction(oPC);
}
int AnphGetPlayerTeamInt (object oPC)
{
return AnphFastGetPlayerTeamInt(oPC);
}
string AnphGetPlayerTeam (object oPC)
{
return AnphFastGetPlayerTeam(oPC);
}
void AnphSendMessageToTeam (string sTeam, string sMessage)
{
fctn_SendMessageToFaction(sMessage, fctn_GetFactionIdFromName(sTeam));
}
int AnphGetPlayerLevel (object oPC)
{
int iLevel;
iLevel = GetLevelByPosition (1, oPC);
iLevel += GetLevelByPosition (2, oPC);
iLevel += GetLevelByPosition (3, oPC);
return (iLevel);
}
void AnphCheckPK (object oPlayer, object oKiller)
{
string sTeam = AnphGetPlayerTeam (oPlayer);
string sKTeam = AnphGetPlayerTeam (oKiller);
int iPlayerLvl;
int iKillerLvl;
int iXP;
if (sTeam == "" || sKTeam == "")
return;
WriteTimestampedLogEntry("*** PvP Death -!- " + GetPCPlayerName(oKiller) + " -!- " + GetName(oKiller) + " -!- Killed -!- " + GetPCPlayerName(oPlayer) + " -!- " + GetName(oPlayer) + " ***");
if (sTeam != sKTeam)
{
AnphSendMessageToTeam (sTeam, "*** " + GetName (oPlayer) + " was killed by an " + sKTeam + " named " + GetName (oKiller) + " ***");
AnphSendMessageToTeam (sKTeam, "*** " + GetName (oKiller) + " has slain an enemy " + sTeam + " named " + GetName (oPlayer) + " ***");
iPlayerLvl = AnphGetPlayerLevel (oPlayer);
iKillerLvl = AnphGetPlayerLevel (oKiller);
iXP = iPlayerLvl * 50;
if ((iKillerLvl - iPlayerLvl) > 3)
iXP = 0;
if (iXP > 2000)
iXP = 2000;
GiveXPToCreature (oKiller, iXP);
} else if (sTeam == sKTeam)
{
AnphSendMessageToTeam (sTeam, "*** " + GetName (oKiller) + " has killed a fellow " + sKTeam + " named " + GetName (oPlayer) + " ***");
}
}
void AnphSendWarningCall (object oPC, int nSignal=0)
{
string sPCTeam;
string sTeam = AnphGetPlayerTeam (oPC);
object oArea = GetArea (oPC);
string sMessage = "*** The horn of " + sTeam;
if (nSignal)
sMessage += " (signal " + IntToString(nSignal) + ")";
sMessage += " sounds in " + GetName(oArea) + "! ***";
util_SendMessageToAllPCs(sMessage);
NWNX_WebHook_SendWebHookHTTPS("discordapp.com", WEBHOOK_ALARM, sMessage, "Horn of " + sTeam);
SendMessageToAllDMs("*** " + GetName (oPC) + " (" + sTeam + ") blew the horn in the " + GetName (oArea) + "! ***");
object oPlayer;
oPlayer = GetFirstPC ();
object oPC = GetFirstPC();
while (GetIsObjectValid (oPlayer) == TRUE)
{
sPCTeam = AnphGetPlayerTeam (oPlayer);
if (sPCTeam == sTeam)
AssignCommand (oPlayer, PlaySound("as_an_wolfhowl1"));
oPlayer = GetNextPC ();
}
}
void AnphCryDrow (object oPC)
{
string sPCTeam;
string sTeam = "Drow";
object oArea = GetArea (oPC);
AnphSendMessageToTeam (sTeam, "*** " + GetName (oPC) + " cries for drow ("
+ GetPCPlayerName (oPC) + ") ***");
SendMessageToAllDMs("*** " + GetName (oPC) + " needs dm (" + GetPCPlayerName (oPC) + ") ***");
object oPlayer;
oPlayer = GetFirstPC ();
object oPC = GetFirstPC();
while (GetIsObjectValid (oPlayer) == TRUE)
{
sPCTeam = AnphGetPlayerTeam (oPlayer);
if (sPCTeam == sTeam)
{
AssignCommand (oPlayer, PlaySound("as_an_wolfhowl1"));
}
oPlayer = GetNextPC ();
}
}
void UpdateTeamFaction (string sTeam, object oFactionMember, int iRating)
{
object oPC;
string sPlayerTeam;
string sPCTeam;
dbg_Warning("Someone is calling UpdateTeamFaction()! Bad code!", oFactionMember);
oPC = GetFirstPC();
while (GetIsObjectValid (oPC) == TRUE)
{
sPCTeam = AnphGetPlayerTeam (oPC);
if (sPCTeam == sTeam)
{
AdjustReputation (oPC, oFactionMember, iRating);
}
oPC = GetNextPC ();
}
}
void AnphSurrender (object oFactionMember, object oPC)
{
dbg_Warning("Someone is calling AnphSurrender()! Bad code!", oFactionMember);
ExecuteScript ("anph_surrender", oFactionMember);
}
void CheckPlayerTeam (object oPlayer)
{
fctn_UpdateReputation(oPlayer);
}
int AnphUpdatePlayerTeam (object oPC)
{
fctn_UpdateReputation(oPC);
return 1;
}
void AnphSendCorpseHome (object oPC)
{
string sName=GetName(oPC);
string sCDK=GetPCPublicCDKey(oPC);
string sID=sName+sCDK;
object oDeathCorpse;
object oHeadstone;
int iPlace;
object oPlace;
string sTeam;
object oWaypt;
location oLoc;
object oOldDC;
object oModule = GetModule();
oDeathCorpse = GetLocalObject(oModule,"DeathCorpse"+sID);
sTeam = AnphGetPlayerTeam (oPC);
oHeadstone = GetObjectByTag(sTeam + "Headstone");
iPlace = GetLocalInt (oHeadstone, "current-place");
if (iPlace >= 18)
iPlace = 0;
WriteTimestampedLogEntry ("Creating corpse at home.");
iPlace++;
SetLocalInt (oHeadstone, "current-place", iPlace);
oWaypt = GetObjectByTag (sTeam + "Corpse" + IntToString (iPlace));
if (!GetIsObjectValid (oWaypt))
{
WriteTimestampedLogEntry ("Invalid waypt for corpse move!");
return;
}
oLoc = GetLocation (oWaypt);
// We now have the location of where this corpse should
// be put, and the corpse itself, just have to move it.
// FIXME: Destroy contents?
oOldDC = oDeathCorpse;
oDeathCorpse=CreateObject (OBJECT_TYPE_PLACEABLE, "DeathCorpse",
oLoc);
// Make a new PC Token to put on the new Death Corpse
object oDeadMan = CreateItemOnObject ("PlayerCorpse",
oDeathCorpse);
SetLocalObject(oDeadMan,"Owner",oPC);
SetLocalString(oDeadMan,"Name",sName);
SetLocalString(oDeadMan,"Key", sCDK);
SetLocalObject(oDeadMan,"DeathCorpse",oDeathCorpse);
//SetLocalInt(oDeadMan,"Alignment",GetLocalInt(oDropped,"Alignment"));
//SetLocalString(oDeadMan,"Deity",GetLocalString(oDropped,"Deity"));
SetLocalObject(oModule,"DeathCorpse"+sName+sCDK,oDeathCorpse);
SetLocalObject(oModule,"PlayerCorpse"+sName+sCDK,oDeadMan);
SetLocalObject(oDeathCorpse,"Owner",oPC);
SetLocalString(oDeathCorpse,"Name",sName);
SetLocalString(oDeathCorpse,"Key",sCDK);
SetLocalObject(oDeathCorpse,"PlayerCorpse",oDeadMan);
// destroy the old corpse, and everything in it.
object oCT = GetLocalObject (oOldDC, "PlayerCorpse");
DestroyObject (oCT);
object oItem = GetFirstItemInInventory (oOldDC);
while (GetIsObjectValid (oItem))
{
DestroyObject (oItem);
oItem = GetNextItemInInventory (oOldDC);
}
DestroyObject(oOldDC);
}