2025/12/12 Update

Updated PEPS
Hooked up module GUI event for spell effect manager.
Updated nim tools.
Full compile.
This commit is contained in:
Jaysyn904
2025-12-12 14:33:30 -05:00
parent 36565033c9
commit e2ef284388
411 changed files with 13207 additions and 9627 deletions

View File

@@ -25,6 +25,8 @@ const string AI_DM_TABLE = "DM_TABLE";
// Sets PEPS RULES from the database to the module.
// Creates default rules if they do not exist.
void ai_SetAIRules();
// Returns TRUE if the module is being run as a server.
int ai_GetIsServer();
// Returns TRUE if oCreature is controlled by a player.
int ai_GetIsCharacter(object oCreature);
// Returns TRUE if oCreature is controlled by a dungeon master.
@@ -32,6 +34,9 @@ int ai_GetIsDungeonMaster(object oCreature);
// Returns the Player of oAssociate even if oAssociate is the player.
// If there is no player associated with oAssociate then it returns OBJECT_INVALID.
object ai_GetPlayerMaster(object oAssociate);
// Returns the top master of oAssociate, for example a henchmen summons a bat,
// this will return the henchman's player.
object ai_GetTopMaster(object oAssociate);
// Returns the percentage of hit points oCreature has left.
int ai_GetPercHPLoss(object oCreature);
// Returns a rolled result from sDice string.
@@ -129,6 +134,9 @@ void ai_SetAIRules()
// Allows monsters to prebuff before combat starts.
SetLocalInt(oModule, AI_RULE_BUFF_MONSTERS, AI_PREBUFF);
jRules = JsonObjectSet(jRules, AI_RULE_BUFF_MONSTERS, JsonInt(AI_PREBUFF));
// Allows monsters to prebuff with all spells before combat starts.
SetLocalInt(oModule, AI_RULE_FULL_BUFF_MONSTERS, AI_FULL_BUFF);
jRules = JsonObjectSet(jRules, AI_RULE_FULL_BUFF_MONSTERS, JsonInt(AI_FULL_BUFF));
// Allows monsters cast summons spells when prebuffing.
SetLocalInt(oModule, AI_RULE_PRESUMMON, AI_PRESUMMONS);
jRules = JsonObjectSet(jRules, AI_RULE_PRESUMMON, JsonInt(AI_PRESUMMONS));
@@ -215,6 +223,9 @@ void ai_SetAIRules()
// Allows monsters to prebuff before combat starts.
bValue = JsonGetInt(JsonObjectGet(jRules, AI_RULE_BUFF_MONSTERS));
SetLocalInt(oModule, AI_RULE_BUFF_MONSTERS, bValue);
// Allows monsters to buff with all spells before combat starts.
bValue = JsonGetInt(JsonObjectGet(jRules, AI_RULE_FULL_BUFF_MONSTERS));
SetLocalInt(oModule, AI_RULE_FULL_BUFF_MONSTERS, bValue);
// Allows monsters cast summons spells when prebuffing.
bValue = JsonGetInt(JsonObjectGet(jRules, AI_RULE_PRESUMMON));
SetLocalInt(oModule, AI_RULE_PRESUMMON, bValue);
@@ -307,13 +318,17 @@ void ai_SetAIRules()
SetLocalInt(oModule, sDMAIAccessVarname, bValue);
}
}
int ai_GetIsServer()
{
return GetLocalInt(GetModule(), AI_IS_SERVER) || AI_SERVER;
}
int ai_GetIsCharacter(object oCreature)
{
return (GetIsPC(oCreature) && !GetIsDM(oCreature) && !GetIsDMPossessed(oCreature));
return (GetIsPC(oCreature) && !GetIsDM(oCreature) && !GetIsDMPossessed(oCreature) && !GetIsPlayerDM(oCreature));
}
int ai_GetIsDungeonMaster(object oCreature)
{
return (GetIsDM(oCreature) || GetIsDMPossessed(oCreature));
return (GetIsDM(oCreature) || GetIsDMPossessed(oCreature) || GetIsPlayerDM(oCreature));
}
object ai_GetPlayerMaster(object oAssociate)
{
@@ -322,6 +337,16 @@ object ai_GetPlayerMaster(object oAssociate)
if(ai_GetIsCharacter(oMaster)) return oMaster;
return OBJECT_INVALID;
}
object ai_GetTopMaster(object oAssociate)
{
object oMaster = GetMaster(oAssociate);
while(oMaster != OBJECT_INVALID)
{
if(GetMaster(oMaster) == OBJECT_INVALID) break;
oMaster = GetMaster(oMaster);
}
return oMaster;
}
int ai_GetPercHPLoss(object oCreature)
{
int nHP = GetCurrentHitPoints(oCreature);
@@ -862,12 +887,14 @@ void ai_SetupAIData(object oPlayer, object oAssociate, string sAssociateType)
// We keep it for now as we don't want to move other data.
jAIData = JsonArrayInsert(jAIData, JsonInt(11)); // 7 - Associate Perception DistanceDistance.
SetLocalInt(oAssociate, AI_ASSOCIATE_PERCEPTION, 11);
SetLocalFloat(oAssociate, AI_ASSOC_PERCEPTION_DISTANCE, 20.0);
SetLocalFloat(oAssociate, AI_ASSOC_PERCEPTION_DISTANCE, 25.0);
jAIData = JsonArrayInsert(jAIData, JsonString("")); // 8 - Associate Combat Tactics.
jAIData = JsonArrayInsert(jAIData, JsonFloat(20.0)); // 9 - Open Doors check range.
SetLocalFloat(oAssociate, AI_OPEN_DOORS_RANGE, 20.0);
json jSpells = JsonArray();
jAIData = JsonArrayInsert(jAIData, jSpells); // 10 - Castable spells.
jAIData = JsonArrayInsert(jAIData, JsonFloat(0.1)); // 11 - Delay for casting buff spells.
SetLocalFloat(oAssociate, AI_DELAY_BUFF_CASTING, 0.1);
ai_SetAssociateDbJson(oPlayer, sAssociateType, "aidata", jAIData, AI_TABLE);
}
void ai_SetupLootFilters(object oPlayer, object oAssociate, string sAssociateType)
@@ -979,6 +1006,8 @@ void ai_RestoreDatabase(object oPlayer, object oAssociate, string sAssociateType
SetLocalJson(oPlayer, AI_SPELLS_WIDGET, jValue);
}
jAIData = JsonArrayInsert(jAIData, jValue);
fValue = GetLocalFloat(oAssociate, AI_DELAY_BUFF_CASTING);
jAIData = JsonArrayInsert(jAIData, JsonFloat(fValue));
ai_SetAssociateDbJson(oPlayer, sAssociateType, "aidata", jAIData);
// ********** LootFilters **********
json jLootFilters = JsonArray();
@@ -1080,6 +1109,14 @@ void ai_CheckAssociateData(object oPlayer, object oAssociate, string sAssociateT
ai_SetAssociateDbJson(oPlayer, sAssociateType, "aidata", jAIData);
SetLocalJson(oPlayer, AI_SPELLS_WIDGET, jSpellsWidget);
}
json jSpellDelay = JsonArrayGet(jAIData, 11);
if(JsonGetType(jSpellDelay) == JSON_TYPE_NULL)
{
jAIData = JsonArrayInsert(jAIData, JsonFloat(0.1));
ai_SetAssociateDbJson(oPlayer, sAssociateType, "aidata", jAIData);
SetLocalFloat(oAssociate, AI_DELAY_BUFF_CASTING, 0.1);
}
else SetLocalFloat(oAssociate, AI_DELAY_BUFF_CASTING, JsonGetFloat(jSpellDelay));
}
// ********** LootFilters **********
json jLootFilters = ai_GetAssociateDbJson(oPlayer, sAssociateType, "lootfilters");
@@ -1140,7 +1177,7 @@ void ai_SetupDMData(object oPlayer, string sName)
void ai_CheckDMData(object oPlayer)
{
//ai_Debug("0i_main", "898", "Checking data for DM: " + GetName(oPlayer));
string sName = ai_RemoveIllegalCharacters(GetName(oPlayer));
string sName = ai_RemoveIllegalCharacters(ai_StripColorCodes(GetName(oPlayer)));
// ********** Buttons **********
json jButtons = ai_GetCampaignDbJson("buttons", sName, AI_DM_TABLE);
// if there is no saved AImodes then set the defaults.
@@ -1241,7 +1278,7 @@ json ai_CheckOldPluginJson(object oPC)
json ai_UpdatePluginsForPC(object oPC)
{
// Check if the server is running or single player.
if(!AI_SERVER) return ai_CheckOldPluginJson(oPC);
if(!ai_GetIsServer()) return ai_CheckOldPluginJson(oPC);
int nJsonType, nCounter, nIndex, bWidget, bAllow;
string sScript, sName, sIcon;
json jServerPlugins = ai_GetCampaignDbJson("plugins");
@@ -1283,7 +1320,7 @@ json ai_UpdatePluginsForPC(object oPC)
json ai_UpdatePluginsForDM(object oPC)
{
int nJsonType, nCounter, nIndex, bWidget, bAllow;
string sName, sIcon, sDbName = ai_RemoveIllegalCharacters(GetName(oPC));
string sName, sIcon, sDbName = ai_RemoveIllegalCharacters(ai_StripColorCodes(GetName(oPC)));
json jServerPlugins = ai_GetCampaignDbJson("plugins");
ai_CheckDMDataAndInitialize(oPC);
json jDMPlugin, jDMPlugins = ai_GetCampaignDbJson("plugins", sDbName, AI_DM_TABLE);
@@ -1323,7 +1360,7 @@ void ai_StartupPlugins(object oPC)
int bUpdatePlugins;
string sScript;
json jPlugins;
if(GetIsDM(oPC)) jPlugins = ai_UpdatePluginsForDM(oPC);
if(ai_GetIsDungeonMaster(oPC)) jPlugins = ai_UpdatePluginsForDM(oPC);
else jPlugins = ai_UpdatePluginsForPC(oPC);
// We delete this so each mod can be added that legally loads.
DeleteLocalJson(GetModule(), AI_MONSTER_MOD_JSON);