2025/07/22 Update
Removed PRC8 AI hooks from creature event scripts. Full compile.
This commit is contained in:
@@ -7,12 +7,13 @@
|
||||
#include "util_i_csvlists"
|
||||
#include "util_i_color"
|
||||
#include "nui_c_config"
|
||||
#include "nw_inc_nui"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constants
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const string NUI_VERSION = "0.4.7";
|
||||
const string NUI_VERSION = "0.5.0";
|
||||
const string NUI_DATABASE = "nui_form_data";
|
||||
|
||||
const int NUI_ORIENTATION_ROW = 0;
|
||||
@@ -28,42 +29,23 @@ const int NUI_DRAW_MOUSELEFT = 3;
|
||||
const int NUI_DRAW_MOUSERIGHT = 4;
|
||||
const int NUI_DRAW_MOUSEMIDDLE = 5;
|
||||
|
||||
const int NUI_SCROLLBARS_NONE = 0;
|
||||
const int NUI_SCROLLBARS_X = 1;
|
||||
const int NUI_SCROLLBARS_Y = 2;
|
||||
const int NUI_SCROLLBARS_BOTH = 3;
|
||||
const int NUI_SCROLLBARS_AUTO = 4;
|
||||
|
||||
const int NUI_CHART_LINE = 0;
|
||||
const int NUI_CHART_BAR = 1;
|
||||
|
||||
const int NUI_ASPECT_FIT = 0;
|
||||
const int NUI_ASPECT_FILL = 1;
|
||||
const int NUI_ASPECT_FIT100 = 2;
|
||||
const int NUI_ASPECT_EXACT = 3;
|
||||
const int NUI_ASPECT_EXACTSCALED = 4;
|
||||
const int NUI_ASPECT_STRETCH = 5;
|
||||
|
||||
const int NUI_HALIGN_CENTER = 0;
|
||||
const int NUI_HALIGN_LEFT = 1;
|
||||
const int NUI_HALIGN_RIGHT = 2;
|
||||
|
||||
const int NUI_VALIGN_MIDDLE = 0;
|
||||
const int NUI_VALIGN_TOP = 1;
|
||||
const int NUI_VALIGN_BOTTOM = 2;
|
||||
|
||||
const string NUI_DEFINE = "DefineForm";
|
||||
const string NUI_BIND = "BindForm";
|
||||
const string NUI_EVENT_NUI = "HandleNUIEvents";
|
||||
const string NUI_EVENT_MOD = "HandleModuleEvents";
|
||||
|
||||
const string NUI_OBJECT = "NUI_OBJECT";
|
||||
const string NUI_FUNCTION = "NUI_FUNCTION";
|
||||
const string NUI_ARGS = "NUI_ARGS";
|
||||
|
||||
const int NUI_FI_EVENT_UPDATE_FORMS = 100001;
|
||||
const int NUI_FI_EVENT_UPDATE_EVENTS = 100002;
|
||||
|
||||
json jTrue = JsonBool(TRUE);
|
||||
json jFalse = JsonBool(FALSE);
|
||||
json jTrue = JSON_TRUE;
|
||||
json jFalse = JSON_FALSE;
|
||||
|
||||
const int NUI_USE_CAMPAIGN_DATABASE = FALSE;
|
||||
const string NUI_FORMFILE_PREFIX = "nui_f_";
|
||||
@@ -976,8 +958,10 @@ void NUI_DefineForms(string sFormfile = "");
|
||||
/// @param oPC Client to display the form on.
|
||||
/// @param sFormID ID of the form to display.
|
||||
/// @param sProfile Optional form profile.
|
||||
/// @param bSelfManage If TRUE, call the formfile directly instead of the
|
||||
/// game's NUI event handler.
|
||||
/// @returns Form's token as assigned by the game engine.
|
||||
int NUI_DisplayForm(object oPC, string sFormID, string sProfile = "default");
|
||||
int NUI_DisplayForm(object oPC, string sFormID, string sProfile = "", int bSelfManage = FALSE);
|
||||
|
||||
/// @brief Close an open form.
|
||||
/// @param oPC Client on which to close the form.
|
||||
@@ -1301,7 +1285,7 @@ int nui_InitializeDatabase()
|
||||
"timestamp INTEGER);";
|
||||
SqlStep(nui_PrepareQuery(sQuery));
|
||||
|
||||
sQuery = "SELECT * FROM nui_forms;";
|
||||
sQuery = "SELECT COUNT(*) FROM nui_forms;";
|
||||
return SqlStep(nui_PrepareQuery(sQuery));
|
||||
}
|
||||
|
||||
@@ -1332,9 +1316,9 @@ void nui_CopyDefinitions(string sTable = "nui_forms")
|
||||
string sQuery = "WITH forms AS (SELECT json_object('form', form, 'definition', definition) AS f " +
|
||||
"FROM " + sTable + ") SELECT json_group_array(json(f)) FROM forms;";
|
||||
sqlquery sql = nui_PrepareQuery(sQuery, TRUE);
|
||||
json jForms = SqlStep(sql) ? SqlGetJson(sql, 0) : JsonNull();
|
||||
json jForms = SqlStep(sql) ? SqlGetJson(sql, 0) : JSON_NULL;
|
||||
|
||||
if (jForms == JsonNull())
|
||||
if (jForms == JSON_NULL)
|
||||
return;
|
||||
|
||||
sQuery = "INSERT OR REPLACE INTO " + sTable + " (form, definition) " +
|
||||
@@ -1554,7 +1538,7 @@ void NUI_SaveBindState(object oPC, string sFormID)
|
||||
void NUI_RestoreBindState(object oPC, string sFormID)
|
||||
{
|
||||
json jState = GetLocalJson(oPC, "NUI_STATE:" + sFormID);
|
||||
if (jState == JsonNull())
|
||||
if (jState == JSON_NULL)
|
||||
return;
|
||||
|
||||
json jKeys = JsonObjectKeys(jState);
|
||||
@@ -1732,6 +1716,11 @@ void NUI_CloseRow() {nui_DecrementPath();}
|
||||
|
||||
void NUI_CloseLayout() {nui_DecrementPath();}
|
||||
|
||||
void NUI_AddLayout(json jLayout)
|
||||
{
|
||||
nui_SetProperty("root", JsonDump(jLayout));
|
||||
}
|
||||
|
||||
// Controls --------------------------------------------------------------------
|
||||
|
||||
void NUI_AddCheckbox(string sID = "") {nui_CreateControl("check", sID);}
|
||||
@@ -2269,7 +2258,7 @@ json nui_GetForm(string sFormID, int bForceModule = FALSE)
|
||||
sqlquery sql = nui_PrepareQuery("SELECT definition FROM nui_forms WHERE form = @form;", bForceModule);
|
||||
SqlBindString(sql, "@form", sFormID);
|
||||
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JsonNull();
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JSON_NULL;
|
||||
}
|
||||
|
||||
string nui_GetFormsByPrefix(string sForms, string sPrefix, int nResType)
|
||||
@@ -2294,8 +2283,8 @@ int nui_ExecuteFunction(string sFile, string sFunction, object oTarget = OBJECT_
|
||||
|
||||
if (ResManFindPrefix(sFile, RESTYPE_NCS) == sFile)
|
||||
{
|
||||
SetScriptParam("NUI_FUNCTION", sFunction);
|
||||
SetScriptParam("NUI_ARGS", sArguments);
|
||||
SetScriptParam(NUI_FUNCTION, sFunction);
|
||||
SetScriptParam(NUI_ARGS, sArguments);
|
||||
ExecuteScript(sFile, oTarget);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2314,7 +2303,7 @@ json nui_GetWatchedBinds(string sFormID)
|
||||
"nui_forms.definition, path || '.watch') = true AND form = @form);";
|
||||
sqlquery sql = nui_PrepareQuery(sQuery);
|
||||
SqlBindString(sql, "@form", sFormID);
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JsonArray();
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JSON_ARRAY;
|
||||
}
|
||||
|
||||
json NUI_GetOrphanBinds(string sFormID)
|
||||
@@ -2325,7 +2314,7 @@ json NUI_GetOrphanBinds(string sFormID)
|
||||
"'$.profiles.default') AS value WHERE form = @form));";
|
||||
sqlquery sql = nui_PrepareQuery(sQuery);
|
||||
SqlBindString(sql, "@form", sFormID);
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JsonArray();
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JSON_ARRAY;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -2377,7 +2366,7 @@ json nui_GetProfileBinds(string sFormID, string sProfile = "")
|
||||
sqlquery sql = nui_PrepareQuery(sQuery);
|
||||
SqlBindString(sql, "@form", sFormID);
|
||||
SqlBindString(sql, "@profile", sProfile);
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JsonObject();
|
||||
return SqlStep(sql) ? SqlGetJson(sql, 0) : JSON_OBJECT;
|
||||
}
|
||||
|
||||
/// @private Called during form opening, sets the initial values for all default binds.
|
||||
@@ -2426,7 +2415,7 @@ void NUI_DefineForms(string sFormfile = "")
|
||||
int n; for (n; n < CountList(NUI_FORMFILE_PREFIX); n++)
|
||||
{
|
||||
string sFormfiles = nui_GetForms(GetListItem(NUI_FORMFILE_PREFIX, n));
|
||||
if (sFormfiles == "") return;
|
||||
if (sFormfiles == "") break;
|
||||
|
||||
int f; for (f; f < CountList(sFormfiles); f++)
|
||||
{
|
||||
@@ -2443,14 +2432,16 @@ void NUI_DefineForms(string sFormfile = "")
|
||||
nui_CommitTransaction();
|
||||
}
|
||||
|
||||
int NUI_DisplayForm(object oPC, string sFormID, string sProfile = "default")
|
||||
int NUI_DisplayForm(object oPC, string sFormID, string sProfile = "", int bSelfManage = FALSE)
|
||||
{
|
||||
json jForm = nui_GetForm(sFormID);
|
||||
if (jForm != JsonNull())
|
||||
if (jForm != JSON_NULL)
|
||||
{
|
||||
int nToken = NuiCreate(oPC, jForm, sFormID);
|
||||
json jData = JsonObjectSet(JsonObject(), "profile", JsonString(sProfile));
|
||||
jData = JsonObjectSet(jData, "formfile", JsonString(nui_GetDefinitionValue(sFormID, "formfile")));
|
||||
string sFormfile = nui_GetDefinitionValue(sFormID, "formfile");
|
||||
|
||||
int nToken = NuiCreate(oPC, jForm, sFormID, (bSelfManage ? sFormfile : ""));
|
||||
json jData = JsonObjectSet(JSON_OBJECT, "profile", JsonString(sProfile == "" ? "default" : sProfile));
|
||||
jData = JsonObjectSet(jData, "formfile", JsonString(sFormfile));
|
||||
|
||||
NuiSetUserData(oPC, NuiFindWindow(oPC, sFormID), jData);
|
||||
return nToken;
|
||||
@@ -2490,7 +2481,7 @@ void NUI_CreateProfile(string sProfile, string sBase = "")
|
||||
|
||||
void NUI_SetProfileBind(string sBind, string sJson)
|
||||
{
|
||||
if (sBind == "" || sJson == "" || JsonParse(sJson) == JsonNull())
|
||||
if (sBind == "" || sJson == "" || JsonParse(sJson) == JSON_NULL)
|
||||
return;
|
||||
|
||||
nui_SetProfileBind(sBind, sJson);
|
||||
@@ -2503,7 +2494,7 @@ void NUI_SetProfileBindJ(string sBind, json jValue)
|
||||
|
||||
void NUI_SetProfileBinds(string sBinds, string sJson)
|
||||
{
|
||||
if (sBinds == "" || sJson == "" || JsonParse(sJson) == JsonNull())
|
||||
if (sBinds == "" || sJson == "" || JsonParse(sJson) == JSON_NULL)
|
||||
return;
|
||||
|
||||
int n; for (n; n < CountList(sBinds); n++)
|
||||
|
@@ -11,7 +11,8 @@ void main()
|
||||
// If not runnning normal or better AI then exit for performance reasons
|
||||
if (GetAILevel(OBJECT_SELF) == AI_LEVEL_VERY_LOW) return;
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_hb", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//ExecuteScript("prc_npc_hb", oCreature);
|
||||
if(AI_DEBUG) ai_Debug("nw_c2_default1", "16", GetName(oCreature) + " Heartbeat." +
|
||||
" OnSpawn: " + IntToString(GetLocalInt(oCreature, AI_ONSPAWN_EVENT)));
|
||||
// We run our OnSpawn in the heartbeat so the creator can use the original
|
||||
|
@@ -16,7 +16,8 @@ void main()
|
||||
// * if not runnning normal or better AI then exit for performance reasons
|
||||
//if (GetAILevel() == AI_LEVEL_VERY_LOW) return;
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_percep", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//ExecuteScript("prc_npc_percep", oCreature);
|
||||
if(AI_DEBUG) ai_Debug("nw_c2_default2", "19", "AI_ONSPAWN_EVENT: " + IntToString(GetLocalInt(oCreature, AI_ONSPAWN_EVENT)));
|
||||
if(!GetLocalInt(oCreature, AI_ONSPAWN_EVENT)) return;
|
||||
if(GetLastPerceptionSeen())
|
||||
|
@@ -17,7 +17,8 @@
|
||||
void main()
|
||||
{
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_combat", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//ExecuteScript("prc_npc_combat", oCreature);
|
||||
if(AI_DEBUG) ai_Debug("nw_c2_default3", "20", GetName(oCreature) + " ends combat round." +
|
||||
" Current action: " + IntToString(GetCurrentAction(oCreature)));
|
||||
if(GetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT))
|
||||
|
@@ -12,7 +12,8 @@ void ai_MonsterCommands(object oCreature, object oSpeaker, int nMatch);
|
||||
void main()
|
||||
{
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_conv", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//ExecuteScript("prc_npc_conv", oCreature);
|
||||
if(AI_DEBUG) ai_Debug("nw_c2_default4", "15", GetName(oCreature) + " listens " +
|
||||
IntToString(GetListenPatternNumber()) + " to " + GetName(GetLastSpeaker()) + "." +
|
||||
" AI_AM_I_SEARCHING: " + IntToString(GetLocalInt(oCreature, AI_AM_I_SEARCHING)));
|
||||
|
@@ -10,7 +10,8 @@
|
||||
void main()
|
||||
{
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_physatt", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//ExecuteScript("prc_npc_physatt", oCreature);
|
||||
object oAttacker = GetLastAttacker(oCreature);
|
||||
if(AI_DEBUG) ai_Debug("nw_c2_default5", "14", GetName(oCreature) + " was attacked by " +
|
||||
GetName(oAttacker) + ".");
|
||||
|
@@ -13,7 +13,9 @@
|
||||
void main()
|
||||
{
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_damaged", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//:: ExecuteScript("prc_npc_damaged", oCreature);
|
||||
|
||||
// Send the user-defined event signal
|
||||
if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))
|
||||
{
|
||||
|
@@ -1,113 +0,0 @@
|
||||
//:://////////////////////////////////////////////////
|
||||
//:: NW_C2_DEFAULT7
|
||||
/*
|
||||
Default OnDeath event handler for NPCs.
|
||||
|
||||
Adjusts killer's alignment if appropriate and
|
||||
alerts allies to our death.
|
||||
*/
|
||||
//:://////////////////////////////////////////////////
|
||||
//:: Copyright (c) 2002 Floodgate Entertainment
|
||||
//:: Created By: Naomi Novik
|
||||
//:: Created On: 12/22/2002
|
||||
//:://////////////////////////////////////////////////
|
||||
//:://////////////////////////////////////////////////
|
||||
//:: Modified By: Deva Winblood
|
||||
//:: Modified On: April 1st, 2008
|
||||
//:: Added Support for Dying Wile Mounted
|
||||
//:://///////////////////////////////////////////////
|
||||
|
||||
const string sHenchSummonedFamiliar = "HenchSummonedFamiliar";
|
||||
const string sHenchSummonedAniComp = "HenchSummonedAniComp";
|
||||
const string sHenchLastHeardOrSeen = "LastSeenOrHeard";
|
||||
|
||||
#include "x2_inc_compon"
|
||||
#include "x0_i0_spawncond"
|
||||
|
||||
// Clears the last unheard, unseen enemy location
|
||||
void ClearEnemyLocation();
|
||||
|
||||
void main()
|
||||
{
|
||||
object oKiller = GetLastKiller();
|
||||
object oMaster = GetMaster();
|
||||
|
||||
int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
|
||||
|
||||
if(GetLocalInt(GetModule(), "X3_ENABLE_MOUNT_DB") && GetIsObjectValid(oMaster))
|
||||
SetLocalInt(oMaster, "bX3_STORE_MOUNT_INFO", TRUE);
|
||||
|
||||
// If we're a good/neutral commoner,
|
||||
// adjust the killer's alignment evil
|
||||
if(GetLevelByClass(CLASS_TYPE_COMMONER)
|
||||
&& (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
|
||||
{
|
||||
AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
|
||||
}
|
||||
|
||||
//Start Hench AI
|
||||
if(GetLocalInt(OBJECT_SELF, "GaveHealing"))
|
||||
{
|
||||
// Pausanias: destroy potions of healing
|
||||
object oItem = GetFirstItemInInventory();
|
||||
while(GetIsObjectValid(oItem))
|
||||
{
|
||||
if(GetTag(oItem) == "NW_IT_MPOTION003")
|
||||
DestroyObject(oItem);
|
||||
oItem = GetNextItemInInventory();
|
||||
}
|
||||
}
|
||||
|
||||
if(GetLocalInt(OBJECT_SELF, sHenchSummonedFamiliar))
|
||||
{
|
||||
object oFam = GetLocalObject(OBJECT_SELF, sHenchSummonedFamiliar);
|
||||
if(GetIsObjectValid(oFam))
|
||||
{
|
||||
//if(DEBUG) DoDebug(GetName(OBJECT_SELF) + " destroy familiar");
|
||||
DestroyObject(oFam, 0.1);
|
||||
ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oFam));
|
||||
}
|
||||
}
|
||||
if(GetLocalInt(OBJECT_SELF, sHenchSummonedAniComp))
|
||||
{
|
||||
object oAni = GetLocalObject(OBJECT_SELF, sHenchSummonedAniComp);
|
||||
if(GetIsObjectValid(oAni))
|
||||
{
|
||||
//if(DEBUG) DoDebug(GetName(OBJECT_SELF) + " destroy ani comp");
|
||||
DestroyObject(oAni, 0.1);
|
||||
ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oAni));
|
||||
}
|
||||
}
|
||||
|
||||
ClearEnemyLocation();
|
||||
//End Hench AI
|
||||
|
||||
// Call to allies to let them know we're dead
|
||||
SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
|
||||
|
||||
//Shout Attack my target, only works with the On Spawn In setup
|
||||
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
|
||||
|
||||
// NOTE: the OnDeath user-defined event does not
|
||||
// trigger reliably and should probably be removed
|
||||
if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
|
||||
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
|
||||
|
||||
craft_drop_items(oKiller);
|
||||
|
||||
ExecuteScript("prc_npc_death", OBJECT_SELF);
|
||||
ExecuteScript("prc_pwondeath", OBJECT_SELF);
|
||||
}
|
||||
|
||||
void ClearEnemyLocation()
|
||||
{
|
||||
DeleteLocalInt(OBJECT_SELF, sHenchLastHeardOrSeen);
|
||||
DeleteLocalLocation(OBJECT_SELF, sHenchLastHeardOrSeen);
|
||||
|
||||
object oInvisTarget = GetLocalObject(OBJECT_SELF, sHenchLastHeardOrSeen);
|
||||
if (GetIsObjectValid(oInvisTarget))
|
||||
{
|
||||
DestroyObject(oInvisTarget);
|
||||
DeleteLocalObject(OBJECT_SELF, sHenchLastHeardOrSeen);
|
||||
}
|
||||
}
|
@@ -11,7 +11,8 @@
|
||||
void main()
|
||||
{
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_disturb", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//:: ExecuteScript("prc_npc_disturb", oCreature);
|
||||
if(AI_DEBUG) ai_Debug("nw_c2_default8", "13", GetName(oCreature) + " is been disturbed!");
|
||||
// We do nothing at the moment... lets not mess up our factions ok?
|
||||
// This should be defined by the server admins and is commented out.
|
||||
|
@@ -10,7 +10,8 @@
|
||||
void main()
|
||||
{
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_spellat", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//ExecuteScript("prc_npc_spellat", oCreature);
|
||||
object oCaster = GetLastSpellCaster();
|
||||
SetLocalObject(oCaster, AI_ATTACKED_SPELL, oCreature);
|
||||
if(ai_Disabled(oCreature)) return;
|
||||
|
@@ -9,7 +9,8 @@
|
||||
void main()
|
||||
{
|
||||
object oCreature = OBJECT_SELF;
|
||||
ExecuteScript("prc_npc_blocked", oCreature);
|
||||
//:: Disabled for World of Amon
|
||||
//ExecuteScript("prc_npc_blocked", oCreature);
|
||||
// This actually gets either a Creature or Door that is blocking OBJECT_SELF.
|
||||
object oObject = GetBlockingDoor();
|
||||
if(AI_DEBUG) ai_Debug("nw_c2_defaulte", "14", GetName(oCreature) + " is being blocked by " + GetName(oObject));
|
||||
|
Reference in New Issue
Block a user