2025/07/21 Update

Updated PEPS AI.
Full compile.
This commit is contained in:
Jaysyn904
2025-07-21 09:41:55 -04:00
parent 0e9e2c6950
commit ca8d5eba41
282 changed files with 920 additions and 646 deletions

View File

@@ -26,6 +26,8 @@ int ai_GetAIButton2(object oPlayer, int nButton, object oAssociate, string sAsso
json ai_CreateCompanionJson(object oPC, string sCompanion2da);
// Return any Metamagic or Domain attributes to place on a spell icon image.
string ai_GetSpellIconAttributes(object oCaster, int nMetaMagic, int nDomain);
// Populates the Quick widget list menu.
void ai_PopulateWidgetList(object oPC, object oAssociate, int nToken, json jWidget);
// Creates the AI options menu.
void ai_CreateAIMainNUI(object oPC);
// Creates the AI options menu.
@@ -129,6 +131,211 @@ string ai_GetSpellIconAttributes(object oCaster, int nMetaMagic, int nDomain)
if(nDomain > 0) sAttributeText += "D";
return sAttributeText;
}
void ai_PopulateWidgetList(object oPC, object oAssociate, int nToken, json jWidget)
{
int nSAIndex, nSpell, nClass, nFeat, nBaseItemType, nIprpSubType, nUses;
int nLevel, nMetaMagic, nDomain, nIndex;
string sIndex, sBaseName, sName, sSpellIcon, sText, sClass, sMetaMagicText;
object oItem;
json jSpell;
while(nIndex < 10)
{
jSpell = JsonArrayGet(jWidget, nIndex);
sIndex = IntToString(nIndex);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(JsonGetType(jSpell) != JSON_TYPE_NULL)
{
nSpell = JsonGetInt(JsonArrayGet(jSpell, 0));
nClass = JsonGetInt(JsonArrayGet(jSpell, 1));
nFeat = JsonGetInt(JsonArrayGet(jSpell, 5));
if(nClass == -1) // This is an Item.
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
nBaseItemType = JsonGetInt(JsonArrayGet(jSpell, 3));
nIprpSubType = JsonGetInt(JsonArrayGet(jSpell, 4));
if(nSpell == SPELL_HEALINGKIT)
{
sName = "Healer's Kit +" + IntToString(nIprpSubType);
sSpellIcon = "isk_heal";
sBaseName = "Healer's Kit";
}
else if(nBaseItemType == BASE_ITEM_ENCHANTED_SCROLL ||
nBaseItemType == BASE_ITEM_SCROLL ||
nBaseItemType == BASE_ITEM_SPELLSCROLL)
{
sSpellIcon = Get2DAString("iprp_spells", "Icon", nIprpSubType);
sBaseName = "Scroll";
}
else
{
if(nBaseItemType == BASE_ITEM_ENCHANTED_POTION ||
nBaseItemType == BASE_ITEM_POTIONS) sBaseName = "Potion";
else if(nBaseItemType == BASE_ITEM_ENCHANTED_WAND ||
nBaseItemType == BASE_ITEM_MAGICWAND ||
nBaseItemType == FEAT_CRAFT_WAND) sBaseName = "Wand";
else sBaseName = ai_StripColorCodes(GetName(GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)))));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
oItem = GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)));
nUses = ai_GetItemUses(oItem, nIprpSubType);
if(nUses)
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(nUses == 999) sText = "Unlimited";
else sText = IntToString(nUses);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sBaseName + " / " + sText + ")"));
}
}
else if(nFeat) // This is a feat.
{
sSpellIcon = "";
if(nSpell)
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
if(sSpellIcon == "" || sSpellIcon == "IR_USE")
{
sName = GetStringByStrRef(StringToInt(Get2DAString("feat", "FEAT", nFeat)));
sSpellIcon = Get2DAString("feat", "ICON", nFeat);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName));
}
else // This is a spell.
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sClass = GetStringByStrRef(StringToInt(Get2DAString("classes", "Name", nClass)));
nLevel = JsonGetInt(JsonArrayGet(jSpell, 2));
nMetaMagic = JsonGetInt(JsonArrayGet(jSpell, 3));
nDomain = JsonGetInt(JsonArrayGet(jSpell, 4));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
if(nClass == 255)
{
nSAIndex = JsonGetInt(JsonArrayGet(jSpell, 6));
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (Special Ability / " + IntToString(nLevel) + ")"));
}
else
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sClass + " / " + IntToString(nLevel) + ")"));
sMetaMagicText = ai_GetSpellIconAttributes(oAssociate, nMetaMagic, nDomain);
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(sMetaMagicText));
}
}
}
else
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString("ctl_cg_btn_splvl"));
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(""));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(FALSE));
}
++nIndex;
}
if(nIndex < 10) return;
// Row 6 Quick widget List2
while(nIndex < 20)
{
jSpell = JsonArrayGet(jWidget, nIndex);
sIndex = IntToString(nIndex);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(JsonGetType(jSpell) != JSON_TYPE_NULL)
{
nSpell = JsonGetInt(JsonArrayGet(jSpell, 0));
nClass = JsonGetInt(JsonArrayGet(jSpell, 1));
nFeat = JsonGetInt(JsonArrayGet(jSpell, 5));
if(nClass == -1) // This is an Item.
{
string sBaseName;
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
int nBaseItemType = JsonGetInt(JsonArrayGet(jSpell, 3));
int nIprpSubType = JsonGetInt(JsonArrayGet(jSpell, 4));
if(nSpell == SPELL_HEALINGKIT)
{
sName = "Healer's Kit +" + IntToString(nIprpSubType);
sSpellIcon = "isk_heal";
sBaseName = "Healer's Kit";
}
else if(nBaseItemType == BASE_ITEM_ENCHANTED_SCROLL ||
nBaseItemType == BASE_ITEM_SCROLL ||
nBaseItemType == BASE_ITEM_SPELLSCROLL)
{
sSpellIcon = Get2DAString("iprp_spells", "Icon", nIprpSubType);
sBaseName = "Scroll";
}
else
{
if(nBaseItemType == BASE_ITEM_ENCHANTED_POTION ||
nBaseItemType == BASE_ITEM_POTIONS) sBaseName = "Potion";
else if(nBaseItemType == BASE_ITEM_ENCHANTED_WAND ||
nBaseItemType == BASE_ITEM_MAGICWAND ||
nBaseItemType == FEAT_CRAFT_WAND) sBaseName = "Wand";
else sBaseName = ai_StripColorCodes(GetName(GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)))));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
oItem = GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)));
int nUses = ai_GetItemUses(oItem, nIprpSubType);
if(nUses)
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(nUses == 999) sText = "Unlimited";
else sText = IntToString(nUses);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sBaseName + " / " + sText + ")"));
}
}
else if(nFeat) // This is a feat.
{
sSpellIcon = "";
if(nSpell)
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
if(sSpellIcon == "" || sSpellIcon == "IR_USE")
{
sName = GetStringByStrRef(StringToInt(Get2DAString("feat", "FEAT", nFeat)));
sSpellIcon = Get2DAString("feat", "ICON", nFeat);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName));
}
else // This is a spell.
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sClass = GetStringByStrRef(StringToInt(Get2DAString("classes", "Name", nClass)));
nLevel = JsonGetInt(JsonArrayGet(jSpell, 2));
nMetaMagic = JsonGetInt(JsonArrayGet(jSpell, 3));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
if(nClass == 255)
{
nSAIndex = JsonGetInt(JsonArrayGet(jSpell, 6));
if(GetSpellAbilityReady(oAssociate, nSAIndex))
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (Special Ability / " + IntToString(nLevel) + ")"));
}
}
else
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sClass + " / " + IntToString(nLevel) + ")"));
sMetaMagicText = ai_GetSpellIconAttributes(oAssociate, nMetaMagic, nDomain);
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(sMetaMagicText));
}
}
}
else
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString("ctl_cg_btn_splvl"));
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(""));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(FALSE));
}
++nIndex;
}
}
void ai_CreateAIMainNUI(object oPC)
{
// Set window to not save until it has been created.
@@ -1174,6 +1381,7 @@ void ai_CreateAssociateAINUI(object oPC, object oAssociate)
SetLocalInt (oPC, AI_NO_NUI_SAVE, TRUE);
DelayCommand (2.0, DeleteLocalInt (oPC, AI_NO_NUI_SAVE));
int bRight, bLeft;
int nAssociateType = GetAssociateType(oAssociate);
float fHeight = 45.0;
// ************************************************************************* Width / Height
int bIsPC = ai_GetIsCharacter(oAssociate);
@@ -1436,7 +1644,7 @@ void ai_CreateAssociateAINUI(object oPC, object oAssociate)
jRow = JsonArrayInsert(jRow, NuiSpacer());
if(bLeft)
{
if(sAssociateType != "summons" && sAssociateType != "dominated")
if(nAssociateType != ASSOCIATE_TYPE_SUMMONED && nAssociateType != ASSOCIATE_TYPE_DOMINATED)
{
jRow = CreateButton(jRow, "Auto Looting", "btn_loot", 200.0, 20.0, -1.0, "btn_loot_tooltip");
jRow = CreateCheckBox(jRow, "", "chbx_loot", 25.0, 20.0);
@@ -1751,7 +1959,7 @@ void ai_CreateAssociateAINUI(object oPC, object oAssociate)
if(ai_GetMagicMode(oAssociate, AI_MAGIC_CURE_SPELLS_OFF)) sText = " Cast Cure Spells Off";
else sText = " Cast Cure Spells On";
NuiSetBind(oPC, nToken, "btn_cure_onoff_tooltip", JsonString(sText));
if(sAssociateType != "summons" && sAssociateType != "dominated")
if(nAssociateType != ASSOCIATE_TYPE_SUMMONED && nAssociateType != ASSOCIATE_TYPE_DOMINATED)
{
sRange = FloatToString(GetLocalFloat(oAssociate, AI_LOOT_CHECK_RANGE), 0, 0);
if(ai_GetAIMode(oAssociate, AI_MODE_PICKUP_ITEMS)) sText = " Looting On [" + sRange + " meters]";
@@ -2238,7 +2446,7 @@ void ai_SetWidgetBinds(object oPC, object oAssociate, string sAssociateType, int
object oItem;
if(JsonGetType(jWidget) != JSON_TYPE_NULL)
{
int nLevel, nSpell, nIndex, nClass, nMetaMagic, nDomain, nSubSpell, nFeat;
int nLevel, nSpell, nIndex, nClass, nMetaMagic, nDomain, nSubSpell, nFeat, nSAIndex;
string sSpellIcon, sMetaMagicText, sSubSpell, sClass, sIndex;
while(nIndex < 10)
{
@@ -2319,14 +2527,20 @@ void ai_SetWidgetBinds(object oPC, object oAssociate, string sAssociateType, int
nSpell = JsonGetInt(JsonArrayGet(jSpell, 0));
nClass = JsonGetInt(JsonArrayGet(jSpell, 1));
nLevel = JsonGetInt(JsonArrayGet(jSpell, 2));
nDomain = JsonGetInt(JsonArrayGet(jSpell, 4));
nMetaMagic = JsonGetInt(JsonArrayGet(jSpell, 3));
nDomain = JsonGetInt(JsonArrayGet(jSpell, 4));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
sMetaMagicText = ai_GetSpellIconAttributes(oAssociate, nMetaMagic, nDomain);
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(sMetaMagicText));
if(GetSpellUsesLeft(oAssociate, nClass, nSpell, nMetaMagic, nDomain))
nSAIndex = JsonGetInt(JsonArrayGet(jSpell, 6));
if(nClass == 255 && GetSpellAbilityReady(oAssociate, nSAIndex))
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (Special Ability / " + IntToString(nLevel) + ")"));
}
else if(GetSpellUsesLeft(oAssociate, nClass, nSpell, nMetaMagic, nDomain))
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sClass = GetStringByStrRef(StringToInt(Get2DAString("classes", "Name", nClass)));
@@ -2419,8 +2633,8 @@ void ai_SetWidgetBinds(object oPC, object oAssociate, string sAssociateType, int
{
nSpell = JsonGetInt(JsonArrayGet(jSpell, 0));
nClass = JsonGetInt(JsonArrayGet(jSpell, 1));
nDomain = JsonGetInt(JsonArrayGet(jSpell, 4));
nMetaMagic = JsonGetInt(JsonArrayGet(jSpell, 3));
nDomain = JsonGetInt(JsonArrayGet(jSpell, 4));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
//SendMessageToPC(oPC, GetName(oAssociate) + " nSpell: " + IntToString(nSpell) +
// " nClass: " + IntToString(nClass) + " nMetaMagic: " + IntToString(nMetaMagic) +
@@ -2431,15 +2645,20 @@ void ai_SetWidgetBinds(object oPC, object oAssociate, string sAssociateType, int
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(sMetaMagicText));
sSubSpell = Get2DAString("spells", "Master", nSpell);
if(sSubSpell != "") nSpell = StringToInt(sSubSpell);
if(nDomain == -1 || GetSpellUsesLeft(oAssociate, nClass, nSpell, nMetaMagic, nDomain))
if(nClass == 255)
{
nSAIndex = JsonGetInt(JsonArrayGet(jSpell, 6));
if(GetSpellAbilityReady(oAssociate, nSAIndex))
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (Special Ability / " + IntToString(nLevel) + ")"));
}
}
else if(GetSpellUsesLeft(oAssociate, nClass, nSpell, nMetaMagic, nDomain))
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
if(nDomain == -1) NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName));
else
{
sClass = GetStringByStrRef(StringToInt(Get2DAString("classes", "Name", nClass)));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sClass + " / " + IntToString(nLevel) + ")"));
}
sClass = GetStringByStrRef(StringToInt(Get2DAString("classes", "Name", nClass)));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sClass + " / " + IntToString(nLevel) + ")"));
}
else NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(FALSE));
}
@@ -2876,7 +3095,6 @@ void ai_CreateWidgetNUI(object oPC, object oAssociate)
}
// Get the window location to restore it from the database.
json jLocations = ai_GetAssociateDbJson(oPC, sAssociateType, "locations");
//SendMessageToPC(oPC, "0i_menu, 2124, sAssociateType: " + sAssociateType + " jLocations: " + JsonDump(jLocations, 1));
if(JsonGetType(jLocations) == JSON_TYPE_NULL)
{
ai_SetupAssociateData(oPC, oAssociate, sAssociateType);
@@ -2885,14 +3103,16 @@ void ai_CreateWidgetNUI(object oPC, object oAssociate)
jLocations = JsonObjectGet(jLocations, sAssociateType + AI_WIDGET_NUI);
float fX = JsonGetFloat(JsonObjectGet(jLocations, "x"));
float fY = JsonGetFloat(JsonObjectGet(jLocations, "y"));
//SendMessageToPC(oPC, "0i_menu, 2901, sAssociateType: " + sAssociateType + AI_WIDGET_NUI + " jLocations: " + JsonDump(jLocations, 1));
// Keeps the widgets from bunching up in the top corner.
if(fY == 0.0 && fX == 0.0)
{
int nAssociateType = GetAssociateType(oAssociate);
if(sAssociateType == "pc") fY = 1.0;
else if(sAssociateType == "familiar") fY = 96.0 * fScale;
else if(sAssociateType == "companion") fY = 192.0 * fScale;
else if(sAssociateType == "summons") fY = 288.0 * fScale;
else if(sAssociateType == "dominated") fY = 384.0 * fScale;
else if(nAssociateType == ASSOCIATE_TYPE_FAMILIAR) fY = 96.0 * fScale;
else if(nAssociateType == ASSOCIATE_TYPE_ANIMALCOMPANION) fY = 192.0 * fScale;
else if(nAssociateType == ASSOCIATE_TYPE_SUMMONED) fY = 288.0 * fScale;
else if(nAssociateType == ASSOCIATE_TYPE_DOMINATED) fY = 384.0 * fScale;
else
{
int nIndex = 1;
@@ -3178,24 +3398,34 @@ void ai_CreateCopySettingsNUI(object oPC, object oAssociate)
jRow = JsonArrayInsert(jRow, NuiSpacer());
// Add row to the column.
jCol = JsonArrayInsert(jCol, NuiRow(jRow));
// Row 4 ******************************************************************* 244 / 185
jRow = JsonArrayInsert(JsonArray(), NuiSpacer());
jRow = CreateButton(jRow, "Summons", "btn_paste_summons", 220.0, 20.0);
jRow = JsonArrayInsert(jRow, NuiSpacer());
// Add row to the column.
jCol = JsonArrayInsert(jCol, NuiRow(jRow));
// Row 5 ******************************************************************* 244 / 213
// Row 4 ******************************************************************* 244 / 213
jRow = JsonArrayInsert(JsonArray(), NuiSpacer());
jRow = CreateButton(jRow, "Dominated", "btn_paste_dominated", 220.0, 20.0);
jRow = JsonArrayInsert(jRow, NuiSpacer());
// Add row to the column.
jCol = JsonArrayInsert(jCol, NuiRow(jRow));
// Row 5+ ****************************************************************** 244 / 241
float fHeight = 241.0;
// Row 5+ ******************************************************************* 244 / 185
float fHeight = 213.0;
int nIndex;
string sAssocName;
object oAssoc;
for(nIndex = 1; nIndex < AI_MAX_HENCHMAN; nIndex++)
{
oAssoc = GetAssociate(ASSOCIATE_TYPE_SUMMONED, oPC, nIndex);
if(oAssoc != OBJECT_INVALID)
{
sAssocName = GetName(oAssoc);
if(GetStringRight(sAssocName, 1) == "s") sAssocName = sAssocName + "'";
else sAssocName = sAssocName + "'s";
jRow = CreateButton(JsonArray(), sAssocName, "btn_paste_summons" + IntToString(nIndex), 220.0, 20.0);
// Add row to the column.
jCol = JsonArrayInsert(jCol, NuiRow(jRow));
fHeight += 28.0;
}
else break;
}
// Row 5+ ****************************************************************** 244 / 241
for(nIndex = 1; nIndex < AI_MAX_HENCHMAN; nIndex++)
{
oAssoc = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC, nIndex);
if(oAssoc != OBJECT_INVALID)
@@ -3661,7 +3891,7 @@ void ai_CreateQuickWidgetSelectionNUI(object oPC, object oAssociate)
{
if(StringToInt(Get2DAString("classes", "SpellCaster", nClass)))
{
int nClassLevel = GetLevelByClass(nClass, oAssociate);
int nClassLevel = ai_GetCasterTotalLevel(oAssociate, nClass);
string sSpellsGained = Get2DAString("classes", "SpellGainTable", nClass);
int nMaxSpellLevel = StringToInt(Get2DAString(sSpellsGained, "NumSpellLevels", nClassLevel - 1));
for(nLevelIndex = 0; nLevelIndex <= 9; nLevelIndex++)
@@ -3741,8 +3971,8 @@ void ai_CreateQuickWidgetSelectionNUI(object oPC, object oAssociate)
jQuickListArray = ai_CheckItemAbilities(jQuickListArray, oAssociate, oItem, jSpell_Icon, jSpell_Text, FALSE);
jSpell_Icon = GetLocalJson(oAssociate, "JSPELL_ICON");
jSpell_Text = GetLocalJson(oAssociate, "JSPELL_NAME");
WriteTimestampedLogEntry("0i_menus, 3643, oAssociate: " + GetName(oAssociate) +
" jSpell_Text: " + JsonDump(jSpell_Text, 4));
//WriteTimestampedLogEntry("0i_menus, 3643, oAssociate: " + GetName(oAssociate) +
// " jSpell_Text: " + JsonDump(jSpell_Text, 4));
}
}
oItem = GetNextItemInInventory(oAssociate);
@@ -3811,9 +4041,9 @@ void ai_CreateQuickWidgetSelectionNUI(object oPC, object oAssociate)
jSpell = JsonArray();
jSpell = JsonArrayInsert(jSpell, JsonInt(nSubSpell));
jSpell = JsonArrayInsert(jSpell, JsonInt(nClass));
jSpell = JsonArrayInsert(jSpell, JsonInt(0));
jSpell = JsonArrayInsert(jSpell, JsonInt(255));
jSpell = JsonArrayInsert(jSpell, JsonInt(0));
jSpell = JsonArrayInsert(jSpell, JsonInt(-1)); // Level
jSpell = JsonArrayInsert(jSpell, JsonInt(255)); // MetaMagic
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // Domain
jSpell = JsonArrayInsert(jSpell, JsonInt(nFeat));
jQuickListArray = JsonArrayInsert(jQuickListArray, jSpell);
}
@@ -3828,9 +4058,9 @@ void ai_CreateQuickWidgetSelectionNUI(object oPC, object oAssociate)
jSpell = JsonArray();
jSpell = JsonArrayInsert(jSpell, JsonInt(nSpell));
jSpell = JsonArrayInsert(jSpell, JsonInt(nClass));
jSpell = JsonArrayInsert(jSpell, JsonInt(0));
jSpell = JsonArrayInsert(jSpell, JsonInt(255));
jSpell = JsonArrayInsert(jSpell, JsonInt(0));
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // Level
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // MetaMagic
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // Domain
jSpell = JsonArrayInsert(jSpell, JsonInt(nFeat));
jQuickListArray = JsonArrayInsert(jQuickListArray, jSpell);
}
@@ -3840,6 +4070,66 @@ void ai_CreateQuickWidgetSelectionNUI(object oPC, object oAssociate)
}
}
}
// Checks for monsters special abilities.
int nCounter = 0, nPreviousSpell = -1, nMaxSpellAbility = GetSpellAbilityCount(oAssociate);
while(nCounter < nMaxSpellAbility)
{
nSpell = GetSpellAbilitySpell(oAssociate, nCounter);
if(nPreviousSpell != nSpell)
{
nPreviousSpell = nSpell;
// Check for subfeats.
nSubSpell = StringToInt(Get2DAString("spells", "SubRadSpell1", nSpell));
if(nSubSpell)
{
for(nSubSpellIndex = 1; nSubSpellIndex <= 5; nSubSpellIndex++)
{
sSubSpellIndex = IntToString(nSubSpellIndex);
nSubSpell = StringToInt(Get2DAString("spells", "SubRadSpell" + sSubSpellIndex, nSpell));
if(nSubSpell != 0)
{
sSpellIcon = Get2DAString("spells", "iConResRef", nSubSpell);
jSpell_Icon = JsonArrayInsert(jSpell_Icon, JsonString(sSpellIcon));
sSpellName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSubSpell)));
jSpell_Text = JsonArrayInsert(jSpell_Text, JsonString(sSpellName));
jSpell = JsonArray();
jSpell = JsonArrayInsert(jSpell, JsonInt(nSubSpell));
jSpell = JsonArrayInsert(jSpell, JsonInt(nClass));
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // Level
jSpell = JsonArrayInsert(jSpell, JsonInt(255)); // MetaMagic
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // Domain
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // Feat
jQuickListArray = JsonArrayInsert(jQuickListArray, jSpell);
}
}
}
else
{
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
jSpell_Icon = JsonArrayInsert(jSpell_Icon, JsonString(sSpellIcon));
sSpellName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
jSpell_Text = JsonArrayInsert(jSpell_Text, JsonString(sSpellName));
sMetaMagicText = ai_GetSpellIconAttributes(oAssociate, nMetaMagic, nDomain);
jMetaMagic_Text = JsonArrayInsert(jMetaMagic_Text, JsonString(sMetaMagicText));
jSpell = JsonArray();
jSpell = JsonArrayInsert(jSpell, JsonInt(nSpell));
jSpell = JsonArrayInsert(jSpell, JsonInt(255)); // Class - Special abilities is always 255.
jSpell = JsonArrayInsert(jSpell, JsonInt(GetSpellAbilityCasterLevel(oAssociate, nCounter)));
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // metamagic
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // domain
jSpell = JsonArrayInsert(jSpell, JsonInt(0)); // feat
// Index of Special ability on monster.
jSpell = JsonArrayInsert(jSpell, JsonInt(nCounter));
jQuickListArray = JsonArrayInsert(jQuickListArray, jSpell);
//SendMessageToPC(oPC, "nSpell: " + IntToString(nSpell) +
// " sSpellIcon: " + sSpellIcon +
// " sSpellName: " + sSpellName+
// " nMaxSlot: " + IntToString(nMaxSpellAbility) +
// " nSpellAbilityIndex: " + IntToString(nCounter));
}
}
nCounter++;
}
// Used in the execution script to get the special abilities.
//jData = JsonArrayInsert(jData, jQuickListArray);
}
@@ -3944,185 +4234,7 @@ void ai_CreateQuickWidgetSelectionNUI(object oPC, object oAssociate)
NuiSetUserData(oPC, nToken, jData);
// Row 4 Quick widget list label.
// Row 5 Quick widget List 1
json jWidget = JsonArrayGet(jSpells, 2);
nIndex = 0;
while(nIndex < 10)
{
jSpell = JsonArrayGet(jWidget, nIndex);
sIndex = IntToString(nIndex);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(JsonGetType(jSpell) != JSON_TYPE_NULL)
{
nSpell = JsonGetInt(JsonArrayGet(jSpell, 0));
nClass = JsonGetInt(JsonArrayGet(jSpell, 1));
nFeat = JsonGetInt(JsonArrayGet(jSpell, 5));
if(nClass == -1) // This is an Item.
{
string sBaseName;
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
int nBaseItemType = JsonGetInt(JsonArrayGet(jSpell, 3));
int nIprpSubType = JsonGetInt(JsonArrayGet(jSpell, 4));
if(nSpell == SPELL_HEALINGKIT)
{
sName = "Healer's Kit +" + IntToString(nIprpSubType);
sSpellIcon = "isk_heal";
sBaseName = "Healer's Kit";
}
else if(nBaseItemType == BASE_ITEM_ENCHANTED_SCROLL ||
nBaseItemType == BASE_ITEM_SCROLL ||
nBaseItemType == BASE_ITEM_SPELLSCROLL)
{
sSpellIcon = Get2DAString("iprp_spells", "Icon", nIprpSubType);
sBaseName = "Scroll";
}
else
{
if(nBaseItemType == BASE_ITEM_ENCHANTED_POTION ||
nBaseItemType == BASE_ITEM_POTIONS) sBaseName = "Potion";
else if(nBaseItemType == BASE_ITEM_ENCHANTED_WAND ||
nBaseItemType == BASE_ITEM_MAGICWAND ||
nBaseItemType == FEAT_CRAFT_WAND) sBaseName = "Wand";
else sBaseName = ai_StripColorCodes(GetName(GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)))));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
oItem = GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)));
int nUses = ai_GetItemUses(oItem, nIprpSubType);
if(nUses)
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(nUses == 999) sText = "Unlimited";
else sText = IntToString(nUses);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sBaseName + " / " + sText + ")"));
}
}
else if(nFeat) // This is a feat.
{
sSpellIcon = "";
if(nSpell)
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
if(sSpellIcon == "" || sSpellIcon == "IR_USE")
{
sName = GetStringByStrRef(StringToInt(Get2DAString("feat", "FEAT", nFeat)));
sSpellIcon = Get2DAString("feat", "ICON", nFeat);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName));
}
else // This is a spell.
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sClass = GetStringByStrRef(StringToInt(Get2DAString("classes", "Name", nClass)));
nLevel = JsonGetInt(JsonArrayGet(jSpell, 2));
nMetaMagic = JsonGetInt(JsonArrayGet(jSpell, 3));
nDomain = JsonGetInt(JsonArrayGet(jSpell, 4));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sClass + " / " + IntToString(nLevel) + ")"));
sMetaMagicText = ai_GetSpellIconAttributes(oAssociate, nMetaMagic, nDomain);
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(sMetaMagicText));
}
}
else
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString("ctl_cg_btn_splvl"));
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(""));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(FALSE));
}
++nIndex;
}
if(nIndex < 10) return;
// Row 6 Quick widget List2
while(nIndex < 20)
{
jSpell = JsonArrayGet(jWidget, nIndex);
sIndex = IntToString(nIndex);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(JsonGetType(jSpell) != JSON_TYPE_NULL)
{
nSpell = JsonGetInt(JsonArrayGet(jSpell, 0));
nClass = JsonGetInt(JsonArrayGet(jSpell, 1));
nFeat = JsonGetInt(JsonArrayGet(jSpell, 5));
if(nClass == -1) // This is an Item.
{
string sBaseName;
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
int nBaseItemType = JsonGetInt(JsonArrayGet(jSpell, 3));
int nIprpSubType = JsonGetInt(JsonArrayGet(jSpell, 4));
if(nSpell == SPELL_HEALINGKIT)
{
sName = "Healer's Kit +" + IntToString(nIprpSubType);
sSpellIcon = "isk_heal";
sBaseName = "Healer's Kit";
}
else if(nBaseItemType == BASE_ITEM_ENCHANTED_SCROLL ||
nBaseItemType == BASE_ITEM_SCROLL ||
nBaseItemType == BASE_ITEM_SPELLSCROLL)
{
sSpellIcon = Get2DAString("iprp_spells", "Icon", nIprpSubType);
sBaseName = "Scroll";
}
else
{
if(nBaseItemType == BASE_ITEM_ENCHANTED_POTION ||
nBaseItemType == BASE_ITEM_POTIONS) sBaseName = "Potion";
else if(nBaseItemType == BASE_ITEM_ENCHANTED_WAND ||
nBaseItemType == BASE_ITEM_MAGICWAND ||
nBaseItemType == FEAT_CRAFT_WAND) sBaseName = "Wand";
else sBaseName = ai_StripColorCodes(GetName(GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)))));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
oItem = GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)));
int nUses = ai_GetItemUses(oItem, nIprpSubType);
if(nUses)
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(TRUE));
if(nUses == 999) sText = "Unlimited";
else sText = IntToString(nUses);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sBaseName + " / " + sText + ")"));
}
}
else if(nFeat) // This is a feat.
{
sSpellIcon = "";
if(nSpell)
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
}
if(sSpellIcon == "" || sSpellIcon == "IR_USE")
{
sName = GetStringByStrRef(StringToInt(Get2DAString("feat", "FEAT", nFeat)));
sSpellIcon = Get2DAString("feat", "ICON", nFeat);
}
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName));
}
else // This is a spell.
{
sName = GetStringByStrRef(StringToInt(Get2DAString("spells", "Name", nSpell)));
sClass = GetStringByStrRef(StringToInt(Get2DAString("classes", "Name", nClass)));
nLevel = JsonGetInt(JsonArrayGet(jSpell, 2));
nMetaMagic = JsonGetInt(JsonArrayGet(jSpell, 3));
sSpellIcon = Get2DAString("spells", "IconResRef", nSpell);
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString(sSpellIcon));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_tooltip", JsonString(" " + sName + " (" + sClass + " / " + IntToString(nLevel) + ")"));
sMetaMagicText = ai_GetSpellIconAttributes(oAssociate, nMetaMagic, nDomain);
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(sMetaMagicText));
}
}
else
{
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_image", JsonString("ctl_cg_btn_splvl"));
NuiSetBind(oPC, nToken, "metamagic_" + sIndex + "_text", JsonString(""));
NuiSetBind(oPC, nToken, "btn_widget_" + sIndex + "_event", JsonBool(FALSE));
}
++nIndex;
}
ai_PopulateWidgetList(oPC, oAssociate, nToken, JsonArrayGet(jSpells, 2));
}
void ai_CreateSpellMemorizationNUI(object oPC, object oAssociate)
{
@@ -4289,7 +4401,7 @@ void ai_CreateSpellMemorizationNUI(object oPC, object oAssociate)
NuiSetBind(oPC, nToken, "btn_class_" + sIndex + "_tooltip", JsonString(" " + sClass));
if(nClassSelected == nIndex)
{
int nClassLevel = GetLevelByClass(nClass, oAssociate);
int nClassLevel = ai_GetCasterTotalLevel(oAssociate, nClass);
string sSpellsGained = Get2DAString("classes", "SpellGainTable", nClass);
int nMaxSpellLevel = StringToInt(Get2DAString(sSpellsGained, "NumSpellLevels", nClassLevel - 1));
for(nIndexLevel = 0; nIndexLevel <= 9; nIndexLevel++)
@@ -4605,7 +4717,7 @@ void ai_CreateSpellKnownNUI(object oPC, object oAssociate)
NuiSetBind(oPC, nToken, "btn_class_" + sIndex + "_tooltip", JsonString(" " + sClass));
if(nClassSelected == nIndex)
{
nClassLevel = GetLevelByClass(nClass, oAssociate);
nClassLevel = ai_GetCasterTotalLevel(oAssociate, nClass);
sSpellsGained = Get2DAString("classes", "SpellGainTable", nClass);
nMaxSpellLevel = StringToInt(Get2DAString(sSpellsGained, "NumSpellLevels", nClassLevel - 1));
for(nIndexLevel = 0; nIndexLevel <= 9; nIndexLevel++)