20250530 Late Update
Added @Rakiov's brilliant NUI spellcast system & power attack GUI. Fixed incorrect constants for Charming the Arrow and Investigator. Updated loadhints.2da.
This commit is contained in:
@@ -1,676 +0,0 @@
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Alternate magic system gain evaluation script
|
||||
//:: prc_amagsys_gain
|
||||
//:://////////////////////////////////////////////
|
||||
/** @file
|
||||
This file determines if the given character
|
||||
has gained new spells / powers / utterances /
|
||||
whathaveyou since the last time it was run.
|
||||
If so, it starts the relevant selection
|
||||
conversations.
|
||||
|
||||
Add new classes to their respective magic
|
||||
user type block, or if such doesn't exist
|
||||
yet for the system the class belongs to,
|
||||
make a new block for them at the end of main().
|
||||
|
||||
|
||||
@author Ornedan
|
||||
@date Created - 2006.12.14
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
//:: Updated for .35 by Jaysyn 2023/03/11
|
||||
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "inc_dynconv"
|
||||
#include "psi_inc_psifunc"
|
||||
#include "inc_newspellbook"
|
||||
#include "true_inc_trufunc"
|
||||
#include "tob_inc_tobfunc"
|
||||
#include "shd_inc_shdfunc"
|
||||
#include "inv_inc_invfunc"
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
/* Function prototypes */
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
void CheckSpellbooks(object oPC);
|
||||
void CheckPsionics(object oPC);
|
||||
void CheckInvocations(object oPC);
|
||||
void CheckToB(object oPC);
|
||||
void CheckShadow(object oPC);
|
||||
void CheckTruenaming(object oPC);
|
||||
int CheckMissingPowers(object oPC, int nClass);
|
||||
int CheckMissingSpells(object oPC, int nClass, int nMinLevel, int nMaxLevel);
|
||||
int CheckMissingUtterances(object oPC, int nClass, int nLexicon);
|
||||
int CheckMissingManeuvers(object oPC, int nClass);
|
||||
int CheckMissingMysteries(object oPC, int nClass);
|
||||
int CheckMissingInvocations(object oPC, int nClass);
|
||||
void AMSCompatibilityCheck(object oPC);
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
/* Function definitions */
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
void main()
|
||||
{
|
||||
object oPC = OBJECT_SELF;
|
||||
|
||||
// Sanity checks - Shifted or polymorphed characters may have their hide fucked up, and might be missing access to their hide-feats
|
||||
// @todo Shifting probably doesn't do this anymore, could be ditchable - Ornedan, 20061214
|
||||
if(GetLocalInt(oPC, "nPCShifted"))
|
||||
return;
|
||||
effect eTest = GetFirstEffect(oPC);
|
||||
while(GetIsEffectValid(eTest))
|
||||
{
|
||||
if(GetEffectType(eTest) == EFFECT_TYPE_POLYMORPH)
|
||||
return;
|
||||
eTest = GetNextEffect(oPC);
|
||||
}
|
||||
|
||||
DelayCommand(0.0f, CheckSpellbooks(oPC));
|
||||
}
|
||||
|
||||
// Handle new spellbooks
|
||||
void CheckSpellbooks(object oPC)
|
||||
{
|
||||
if(GetLevelByClass(CLASS_TYPE_SUBLIME_CHORD, oPC) > 0)
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_SUBLIME_CHORD, 4, 9);
|
||||
|
||||
if(GetHasFeat(FEAT_SUBLIME_CHORD_SPELLCASTING_BARD, oPC))
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_BARD, 0, 3);
|
||||
}
|
||||
if(GetHasFeat(FEAT_SUBLIME_CHORD_SPELLCASTING_SORCERER))
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_SORCERER, 0, 3);
|
||||
}
|
||||
if(GetHasFeat(FEAT_SUBLIME_CHORD_SPELLCASTING_WARMAGE, oPC))
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_WARMAGE, 0, 3);
|
||||
}
|
||||
if(GetHasFeat(FEAT_SUBLIME_CHORD_SPELLCASTING_DUSKBLADE, oPC))
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_DUSKBLADE, 0, 3);
|
||||
}
|
||||
if(GetHasFeat(FEAT_SUBLIME_CHORD_SPELLCASTING_BEGUILER, oPC))
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_BEGUILER, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Check all classes that might need a spellbook update
|
||||
if(GetIsRHDSorcerer(oPC)) CheckMissingSpells(oPC, CLASS_TYPE_SORCERER, 0, 9);
|
||||
if(GetIsRHDBard(oPC)) CheckMissingSpells(oPC, CLASS_TYPE_BARD, 0, 6);
|
||||
|
||||
if(!GetPRCSwitch(PRC_BARD_DISALLOW_NEWSPELLBOOK))
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_BARD, 0, 6);
|
||||
if(!GetPRCSwitch(PRC_SORC_DISALLOW_NEWSPELLBOOK))
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_SORCERER, 0, 9);
|
||||
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_SUEL_ARCHANAMACH, 1, 5);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_FAVOURED_SOUL, 0, 9);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_WARMAGE, 0, 9);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_DREAD_NECROMANCER, 1, 9);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_HEXBLADE, 1, 4);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_DUSKBLADE, 0, 5);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_JUSTICEWW, 1, 4);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_KNIGHT_WEAVE, 1, 6);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_ARCHIVIST, 0, 9);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_BEGUILER, 0, 9);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_HARPER, 1, 3);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_ASSASSIN, 1, 4);
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_CELEBRANT_SHARESS, 1, 4);
|
||||
|
||||
// Check psionics
|
||||
DelayCommand(0.0f, CheckPsionics(oPC));
|
||||
}
|
||||
|
||||
|
||||
/* void CheckSpellbooks(object oPC)
|
||||
{
|
||||
if(GetLevelByClass(CLASS_TYPE_SUBLIME_CHORD, oPC) > 0)
|
||||
{
|
||||
// Manually check Sublime Chord spells (levels 4<>9)
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_SUBLIME_CHORD, 4, 9);
|
||||
|
||||
// Get the character's *base* arcane class (Sublime Chord isn't returned)
|
||||
int nPrimaryArcane = GetPrimaryArcaneClass(oPC);
|
||||
|
||||
// Carveout: Allow known spells from Bard/Sorc/Warmage etc. up to level 3
|
||||
if(nPrimaryArcane == CLASS_TYPE_BARD)
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_BARD, 0, 3);
|
||||
}
|
||||
else if(nPrimaryArcane == CLASS_TYPE_SORCERER)
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_SORCERER, 0, 3);
|
||||
}
|
||||
else if(nPrimaryArcane == CLASS_TYPE_WARMAGE)
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_WARMAGE, 0, 3);
|
||||
}
|
||||
else if(nPrimaryArcane == CLASS_TYPE_DUSKBLADE)
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_DUSKBLADE, 0, 3);
|
||||
}
|
||||
else if(nPrimaryArcane == CLASS_TYPE_BEGUILER)
|
||||
{
|
||||
CheckMissingSpells(oPC, CLASS_TYPE_BEGUILER, 0, 3);
|
||||
}
|
||||
|
||||
// Stop here; Sublime Chord handled separately
|
||||
return;
|
||||
}
|
||||
|
||||
if(GetIsRHDSorcerer(oPC) && CheckMissingSpells(oPC, CLASS_TYPE_SORCERER, 0, 9))
|
||||
return;
|
||||
if(GetIsRHDBard(oPC) && CheckMissingSpells(oPC, CLASS_TYPE_BARD, 0, 6))
|
||||
return;
|
||||
if(!GetPRCSwitch(PRC_BARD_DISALLOW_NEWSPELLBOOK) && CheckMissingSpells(oPC, CLASS_TYPE_BARD, 0, 6))
|
||||
return;
|
||||
if(!GetPRCSwitch(PRC_SORC_DISALLOW_NEWSPELLBOOK) && CheckMissingSpells(oPC, CLASS_TYPE_SORCERER, 0, 9))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_SUEL_ARCHANAMACH, 1, 5))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_FAVOURED_SOUL, 0, 9))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_WARMAGE, 0, 9))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_DREAD_NECROMANCER, 1, 9))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_HEXBLADE, 1, 4))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_DUSKBLADE, 0, 5))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_JUSTICEWW, 1, 4))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_KNIGHT_WEAVE, 1, 6))
|
||||
return;
|
||||
// if(CheckMissingSpells(oPC, CLASS_TYPE_SUBLIME_CHORD, 4, 9))
|
||||
// return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_ARCHIVIST, 0, 9))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_BEGUILER, 0, 9))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_HARPER, 1, 3))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_ASSASSIN, 1, 4))
|
||||
return;
|
||||
if(CheckMissingSpells(oPC, CLASS_TYPE_CELEBRANT_SHARESS, 1, 4))
|
||||
return;
|
||||
|
||||
DelayCommand(0.0f, CheckPsionics(oPC));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Handle psionics
|
||||
void CheckPsionics(object oPC)
|
||||
{
|
||||
if(CheckMissingPowers(oPC, CLASS_TYPE_PSION))
|
||||
return;
|
||||
if(CheckMissingPowers(oPC, CLASS_TYPE_WILDER))
|
||||
return;
|
||||
if(CheckMissingPowers(oPC, CLASS_TYPE_PSYWAR))
|
||||
return;
|
||||
if(CheckMissingPowers(oPC, CLASS_TYPE_PSYCHIC_ROGUE))
|
||||
return;
|
||||
if(CheckMissingPowers(oPC, CLASS_TYPE_FIST_OF_ZUOKEN))
|
||||
return;
|
||||
if(CheckMissingPowers(oPC, CLASS_TYPE_WARMIND))
|
||||
return;
|
||||
//expanded knowledge
|
||||
if(CheckMissingPowers(oPC, -1))
|
||||
return;
|
||||
//epic expanded knowledge
|
||||
if(CheckMissingPowers(oPC, -2))
|
||||
return;
|
||||
|
||||
DelayCommand(0.0f, CheckInvocations(oPC));
|
||||
}
|
||||
|
||||
// Handle Invocations
|
||||
void CheckInvocations(object oPC)
|
||||
{
|
||||
if(CheckMissingInvocations(oPC, CLASS_TYPE_DRAGONFIRE_ADEPT))
|
||||
return;
|
||||
if(CheckMissingInvocations(oPC, CLASS_TYPE_WARLOCK))
|
||||
return;
|
||||
if(CheckMissingInvocations(oPC, CLASS_TYPE_DRAGON_SHAMAN))
|
||||
return;
|
||||
//extra invocations
|
||||
if(CheckMissingInvocations(oPC, CLASS_TYPE_INVALID))
|
||||
return;
|
||||
//epic extra invocations
|
||||
if(CheckMissingInvocations(oPC, -2))
|
||||
return;
|
||||
|
||||
DelayCommand(0.0f, CheckToB(oPC));
|
||||
}
|
||||
|
||||
// Handle Tome of Battle
|
||||
void CheckToB(object oPC)
|
||||
{
|
||||
if(CheckMissingManeuvers(oPC, CLASS_TYPE_CRUSADER))
|
||||
return;
|
||||
if(CheckMissingManeuvers(oPC, CLASS_TYPE_SWORDSAGE))
|
||||
return;
|
||||
if(CheckMissingManeuvers(oPC, CLASS_TYPE_WARBLADE))
|
||||
return;
|
||||
|
||||
DelayCommand(0.0f, CheckShadow(oPC));
|
||||
}
|
||||
|
||||
// Handle Shadowcasting
|
||||
void CheckShadow(object oPC)
|
||||
{
|
||||
if(CheckMissingMysteries(oPC, CLASS_TYPE_SHADOWCASTER))
|
||||
return;
|
||||
if(CheckMissingMysteries(oPC, CLASS_TYPE_SHADOWSMITH))
|
||||
return;
|
||||
|
||||
DelayCommand(0.0f, CheckTruenaming(oPC));
|
||||
}
|
||||
|
||||
// Handle Truenaming - Three different Lexicons to check
|
||||
void CheckTruenaming(object oPC)
|
||||
{
|
||||
if(CheckMissingUtterances(oPC, CLASS_TYPE_TRUENAMER, LEXICON_EVOLVING_MIND))
|
||||
return;
|
||||
if(CheckMissingUtterances(oPC, CLASS_TYPE_TRUENAMER, LEXICON_CRAFTED_TOOL))
|
||||
return;
|
||||
if(CheckMissingUtterances(oPC, CLASS_TYPE_TRUENAMER, LEXICON_PERFECTED_MAP))
|
||||
return;
|
||||
|
||||
if(!GetIsDM(oPC))
|
||||
DelayCommand(0.0f, AMSCompatibilityCheck(oPC));
|
||||
}
|
||||
|
||||
int CheckMissingPowers(object oPC, int nClass)
|
||||
{
|
||||
int nLevel = GetLevelByClass(nClass, oPC);
|
||||
if(!nLevel && nClass != -1 && nClass != -2)
|
||||
return FALSE;
|
||||
else if(nClass == -1 && !GetHasFeat(FEAT_EXPANDED_KNOWLEDGE_1))
|
||||
return FALSE;
|
||||
else if(nClass == -2 && !GetHasFeat(FEAT_EPIC_EXPANDED_KNOWLEDGE_1))
|
||||
return FALSE;
|
||||
|
||||
int nCurrentPowers = GetPowerCount(oPC, nClass);
|
||||
int nMaxPowers = GetMaxPowerCount(oPC, nClass);
|
||||
|
||||
if(nCurrentPowers < nMaxPowers)
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "nClass", nClass);
|
||||
StartDynamicConversation("psi_powconv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CheckMissingInvocations(object oPC, int nClass)
|
||||
{
|
||||
int nLevel = GetLevelByClass(nClass, oPC);
|
||||
if(!nLevel && (nClass == CLASS_TYPE_DRAGONFIRE_ADEPT || nClass == CLASS_TYPE_WARLOCK || nClass == CLASS_TYPE_DRAGON_SHAMAN))
|
||||
return FALSE;
|
||||
else if(nClass == CLASS_TYPE_INVALID && !GetHasFeat(FEAT_EXTRA_INVOCATION_I))
|
||||
return FALSE;
|
||||
else if(nClass == -2 && !GetHasFeat(FEAT_EPIC_EXTRA_INVOCATION_I))
|
||||
return FALSE;
|
||||
|
||||
int nCurrentInvocations = GetInvocationCount(oPC, nClass);
|
||||
if(DEBUG) DoDebug("Current Invocations: " + IntToString(nCurrentInvocations));
|
||||
int nMaxInvocations = GetMaxInvocationCount(oPC, nClass);
|
||||
if(DEBUG) DoDebug("Max Invocations: " + IntToString(nMaxInvocations));
|
||||
|
||||
if(nCurrentInvocations < nMaxInvocations)
|
||||
{
|
||||
// Mark the class for which the PC is to gain invocations and start the conversation
|
||||
SetLocalInt(oPC, "nClass", nClass);
|
||||
StartDynamicConversation("inv_invokeconv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void AddSpellsForLevel(int nClass, int nLevel)
|
||||
{
|
||||
object oPC = OBJECT_SELF;
|
||||
object oSkin = GetPCSkin(oPC);
|
||||
//object oToken = GetHideToken(oPC);
|
||||
string sFile = GetFileForClass(nClass);
|
||||
string sSpellbook;
|
||||
int nSpellbookType = GetSpellbookTypeForClass(nClass);
|
||||
if(nSpellbookType == SPELLBOOK_TYPE_SPONTANEOUS)
|
||||
sSpellbook = "Spellbook"+IntToString(nClass);
|
||||
else
|
||||
sSpellbook = "Spellbook_Known_"+IntToString(nClass)+"_"+IntToString(nLevel);
|
||||
|
||||
// Create spells known persistant array if it is missing
|
||||
int nSize = persistant_array_get_size(oPC, sSpellbook);
|
||||
if (nSize < 0)
|
||||
{
|
||||
persistant_array_create(oPC, sSpellbook);
|
||||
nSize = 0;
|
||||
}
|
||||
|
||||
//check for learnable spells
|
||||
object oToken_Class = GetObjectByTag("SpellLvl_" + IntToString(nClass) + "_Level_" + IntToString(nLevel));
|
||||
int nSpells_Total = persistant_array_get_size(oToken_Class, "Lkup");
|
||||
int i;
|
||||
for(i = 0; i < nSpells_Total; i++)
|
||||
{
|
||||
int nSpellbookID = persistant_array_get_int(oToken_Class, "Lkup", i);
|
||||
if(Get2DAString(sFile, "AL", nSpellbookID) != "1")
|
||||
{
|
||||
persistant_array_set_int(oPC, sSpellbook, nSize, nSpellbookID);
|
||||
nSize++;
|
||||
if(nSpellbookType == SPELLBOOK_TYPE_SPONTANEOUS)
|
||||
{
|
||||
int nIPFeatID = StringToInt(Get2DACache(sFile, "IPFeatID", nSpellbookID));
|
||||
int nFeatID = StringToInt(Get2DACache(sFile, "FeatID", nSpellbookID));
|
||||
AddSpellUse(oPC, nSpellbookID, nClass, sFile, "NewSpellbookMem_" + IntToString(nClass), nSpellbookType, oSkin, nFeatID, nIPFeatID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CheckMissingSpells(object oPC, int nClass, int nMinLevel, int nMaxLevel)
|
||||
{
|
||||
int nLevel;
|
||||
|
||||
//:: Rakshasa cast as sorcerers
|
||||
if(nClass == CLASS_TYPE_SORCERER && !GetLevelByClass(CLASS_TYPE_SORCERER, oPC) && GetRacialType(oPC) == RACIAL_TYPE_RAKSHASA)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_OUTSIDER, oPC);
|
||||
|
||||
//:: Aranea cast as sorcerers
|
||||
else if(nClass == CLASS_TYPE_SORCERER && !GetLevelByClass(CLASS_TYPE_SORCERER, oPC) && GetRacialType(oPC) == RACIAL_TYPE_ARANEA)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_SHAPECHANGER, oPC);
|
||||
|
||||
//::Arkamoi cast as sorcerers
|
||||
else if(nClass == CLASS_TYPE_SORCERER && !GetLevelByClass(CLASS_TYPE_SORCERER, oPC) && GetRacialType(oPC) == RACIAL_TYPE_ARKAMOI)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_MONSTROUS, oPC);
|
||||
|
||||
//::Hobgoblin Warsouls cast as sorcerers
|
||||
else if(nClass == CLASS_TYPE_SORCERER && !GetLevelByClass(CLASS_TYPE_SORCERER, oPC) && GetRacialType(oPC) == RACIAL_TYPE_HOBGOBLIN_WARSOUL)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_MONSTROUS, oPC);
|
||||
|
||||
//:: Driders cast as sorcerers
|
||||
else if(nClass == CLASS_TYPE_SORCERER && !GetLevelByClass(CLASS_TYPE_SORCERER, oPC) && GetRacialType(oPC) == RACIAL_TYPE_DRIDER)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_ABERRATION, oPC);
|
||||
|
||||
//:: Marrutact cast as 6/7 sorcerers
|
||||
else if(nClass == CLASS_TYPE_SORCERER && !GetLevelByClass(CLASS_TYPE_SORCERER, oPC) && GetRacialType(oPC) == RACIAL_TYPE_MARRUTACT)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_MONSTROUS, oPC);
|
||||
|
||||
//:: Redspawn Arcaniss cast as 3/4 sorcerers
|
||||
else if(nClass == CLASS_TYPE_SORCERER && !GetLevelByClass(CLASS_TYPE_SORCERER, oPC) && GetRacialType(oPC) == RACIAL_TYPE_REDSPAWN_ARCANISS)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_MONSTROUS, oPC);
|
||||
|
||||
//:: Gloura cast as bards
|
||||
else if(nClass == CLASS_TYPE_BARD && !GetLevelByClass(CLASS_TYPE_BARD, oPC) && GetRacialType(oPC) == RACIAL_TYPE_GLOURA)
|
||||
nLevel = GetSpellslotLevel(nClass, oPC); //GetLevelByClass(CLASS_TYPE_MONSTROUS, oPC);
|
||||
|
||||
else
|
||||
nLevel = nClass == CLASS_TYPE_SUBLIME_CHORD ? GetLevelByClass(nClass, oPC) : GetSpellslotLevel(nClass, oPC);
|
||||
|
||||
if (DEBUG) DoDebug("CheckMissingSpells 1 Class: " + IntToString(nClass));
|
||||
if (DEBUG) DoDebug("CheckMissingSpells 1 Level: " + IntToString(nLevel));
|
||||
|
||||
if(!nLevel)
|
||||
return FALSE;
|
||||
|
||||
if(nClass == CLASS_TYPE_BARD || nClass == CLASS_TYPE_SORCERER)
|
||||
{
|
||||
if((GetLevelByClass(nClass, oPC) == nLevel) //no PrC
|
||||
&& !(GetHasFeat(FEAT_DRACONIC_GRACE, oPC) || GetHasFeat(FEAT_DRACONIC_BREATH, oPC))) //no Draconic feats that apply
|
||||
return FALSE;
|
||||
}
|
||||
else if(nClass == CLASS_TYPE_ARCHIVIST)
|
||||
{
|
||||
int nLastGainLevel = GetPersistantLocalInt(oPC, "LastSpellGainLevel");
|
||||
nLevel = GetLevelByClass(CLASS_TYPE_ARCHIVIST, oPC);
|
||||
|
||||
if(nLastGainLevel < nLevel)
|
||||
{
|
||||
if(nLevel == 1)
|
||||
{
|
||||
//count the number of available at 1st level spells
|
||||
int nSpellsAvailable = 3 + GetAbilityModifier(ABILITY_INTELLIGENCE, oPC);
|
||||
SetLocalInt(oPC, "LrnLvlUp", nSpellsAvailable);
|
||||
}
|
||||
else if(nLevel > 1)
|
||||
//add additional 2 spells form cleric list
|
||||
SetLocalInt(oPC, "LrnLvlUp", 2);
|
||||
|
||||
SetLocalInt(oPC, "SpellGainClass", CLASS_TYPE_ARCHIVIST);
|
||||
SetLocalInt(oPC, "SpellbookMinSpelllevel", nMinLevel);
|
||||
StartDynamicConversation("prc_s_spellgain", oPC, DYNCONV_EXIT_NOT_ALLOWED, TRUE, FALSE, oPC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
//add cleric spells known for level 0
|
||||
else if(persistant_array_get_size(oPC, "Spellbook_Known_"+IntToString(CLASS_TYPE_ARCHIVIST)+"_0") < 5) // TODO: replace with GetSpellKnownCurrentCount
|
||||
{
|
||||
ActionDoCommand(AddSpellsForLevel(CLASS_TYPE_ARCHIVIST, 0));
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (DEBUG) DoDebug("CheckMissingSpells 2 Class: " + IntToString(nClass));
|
||||
if (DEBUG) DoDebug("CheckMissingSpells 2 Level: " + IntToString(nLevel));
|
||||
|
||||
int i;
|
||||
for(i = nMinLevel; i <= nMaxLevel; i++)
|
||||
{
|
||||
int nMaxSpells = GetSpellKnownMaxCount(nLevel, i, nClass, oPC);
|
||||
if(nMaxSpells > 0)
|
||||
{
|
||||
int nCurrentSpells = GetSpellKnownCurrentCount(oPC, i, nClass);
|
||||
int nSpellsAvailable = GetSpellUnknownCurrentCount(oPC, i, nClass);
|
||||
|
||||
if(nCurrentSpells < nMaxSpells && nSpellsAvailable > 0)
|
||||
{
|
||||
if(GetSpellbookTypeForClass(nClass) == SPELLBOOK_TYPE_SPONTANEOUS && bKnowsAllClassSpells(nClass))
|
||||
{
|
||||
ActionDoCommand(AddSpellsForLevel(nClass, i));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "SpellGainClass", nClass);
|
||||
SetLocalInt(oPC, "SpellbookMinSpelllevel", nMinLevel);
|
||||
SetLocalInt(oPC, "SpellbookMaxSpelllevel", nMaxLevel);
|
||||
StartDynamicConversation("prc_s_spellgain", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Advanced Learning check
|
||||
nLevel = GetLevelByClass(nClass, oPC);
|
||||
int nALSpells = GetPersistantLocalInt(oPC, "AdvancedLearning_"+IntToString(nClass));
|
||||
if(nClass == CLASS_TYPE_BEGUILER && nALSpells < (nLevel+1)/4)//one every 4 levels starting at 3.
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "SpellGainClass", CLASS_TYPE_BEGUILER);
|
||||
SetLocalInt(oPC, "SpellbookMinSpelllevel", nMinLevel);
|
||||
SetLocalInt(oPC, "AdvancedLearning", 1);
|
||||
StartDynamicConversation("prc_s_spellgain", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
return TRUE;
|
||||
}
|
||||
else if(nClass == CLASS_TYPE_DREAD_NECROMANCER && nALSpells < nLevel/4)//one every 4 levels
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "SpellGainClass", CLASS_TYPE_DREAD_NECROMANCER);
|
||||
SetLocalInt(oPC, "SpellbookMinSpelllevel", nMinLevel);
|
||||
SetLocalInt(oPC, "AdvancedLearning", 1);
|
||||
StartDynamicConversation("prc_s_spellgain", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
return TRUE;
|
||||
}
|
||||
else if(nClass == CLASS_TYPE_WARMAGE)
|
||||
{
|
||||
if((nLevel >= 40 && nALSpells < 9) ||// :/
|
||||
(nLevel >= 36 && nLevel < 40 && nALSpells < 8) ||
|
||||
(nLevel >= 32 && nLevel < 36 && nALSpells < 7) ||
|
||||
(nLevel >= 28 && nLevel < 32 && nALSpells < 6) ||
|
||||
(nLevel >= 24 && nLevel < 28 && nALSpells < 5) ||
|
||||
(nLevel >= 16 && nLevel < 24 && nALSpells < 4) ||
|
||||
(nLevel >= 11 && nLevel < 16 && nALSpells < 3) ||
|
||||
(nLevel >= 6 && nLevel < 11 && nALSpells < 2) ||
|
||||
(nLevel >= 3 && nLevel < 6 && nALSpells < 1))
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "SpellGainClass", CLASS_TYPE_WARMAGE);
|
||||
SetLocalInt(oPC, "SpellbookMinSpelllevel", nMinLevel);
|
||||
SetLocalInt(oPC, "AdvancedLearning", 1);
|
||||
StartDynamicConversation("prc_s_spellgain", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if(nClass == CLASS_TYPE_NIGHTSTALKER && nALSpells < (nLevel+1)/6)//one every 6 levels starting at 5th
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "SpellGainClass", CLASS_TYPE_NIGHTSTALKER);
|
||||
SetLocalInt(oPC, "SpellbookMinSpelllevel", nMinLevel);
|
||||
SetLocalInt(oPC, "AdvancedLearning", 1);
|
||||
StartDynamicConversation("prc_s_spellgain", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CheckMissingUtterances(object oPC, int nClass, int nLexicon)
|
||||
{
|
||||
int nLevel = GetLevelByClass(nClass, oPC);
|
||||
if(!nLevel)
|
||||
return FALSE;
|
||||
|
||||
int nCurrentUtterances = GetUtteranceCount(oPC, nClass, nLexicon);
|
||||
int nMaxUtterances = GetMaxUtteranceCount(oPC, nClass, nLexicon);
|
||||
if(DEBUG) DoDebug("CheckMissingUtterances(" + IntToString(nClass) + ", " + IntToString(nLexicon) + ", " + GetName(oPC) + ") = " + IntToString(nCurrentUtterances) + ", " + IntToString(nMaxUtterances));
|
||||
|
||||
if(nCurrentUtterances < nMaxUtterances)
|
||||
{
|
||||
// Mark the class for which the PC is to gain Utterances and start the conversation
|
||||
SetLocalInt(oPC, "nClass", nClass);
|
||||
StartDynamicConversation("true_utterconv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CheckMissingManeuvers(object oPC, int nClass)
|
||||
{
|
||||
int nLevel = GetLevelByClass(nClass, oPC);
|
||||
if(!nLevel)
|
||||
return FALSE;
|
||||
|
||||
int nCurrentManeuvers = GetManeuverCount(oPC, nClass, MANEUVER_TYPE_MANEUVER);
|
||||
int nMaxManeuvers = GetMaxManeuverCount(oPC, nClass, MANEUVER_TYPE_MANEUVER);
|
||||
int nCurrentStances = GetManeuverCount(oPC, nClass, MANEUVER_TYPE_STANCE);
|
||||
int nMaxStances = GetMaxManeuverCount(oPC, nClass, MANEUVER_TYPE_STANCE);
|
||||
|
||||
if(nCurrentManeuvers < nMaxManeuvers || nCurrentStances < nMaxStances)
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "nClass", nClass);
|
||||
StartDynamicConversation("tob_moveconv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CheckMissingMysteries(object oPC, int nClass)
|
||||
{
|
||||
int nLevel = GetLevelByClass(nClass, oPC);
|
||||
if(!nLevel)
|
||||
return FALSE;
|
||||
|
||||
int nCurrentMysteries = GetMysteryCount(oPC, nClass);
|
||||
int nMaxMysteries = GetMaxMysteryCount(oPC, nClass);
|
||||
|
||||
if(nCurrentMysteries < nMaxMysteries)
|
||||
{
|
||||
// Mark the class for which the PC is to gain powers and start the conversation
|
||||
SetLocalInt(oPC, "nClass", nClass);
|
||||
StartDynamicConversation("shd_mystconv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//AMS Compatibility functions - xwarren:
|
||||
void CopyAMSArray(object oPC, object oAMSToken, int nClass, string sArray, int nMin, int nMax, int nLoopSize = 100)
|
||||
{
|
||||
string sFile = GetFileForClass(nClass);
|
||||
int i = nMin;
|
||||
while(i < nMin + nLoopSize && i < nMax)
|
||||
{
|
||||
int nSpellbookID = persistant_array_get_int(oPC, sArray, i);
|
||||
int nSpell = StringToInt(Get2DACache(sFile, "RealSpellID", nSpellbookID));
|
||||
if(DEBUG) DoDebug("Copying spell "+IntToString(nSpell));
|
||||
array_set_int(oAMSToken, sArray, i, nSpell);
|
||||
i++;
|
||||
}
|
||||
if(i < nMax)
|
||||
DelayCommand(0.0, CopyAMSArray(oPC, oAMSToken, nClass, sArray, i, nMax));
|
||||
}
|
||||
|
||||
void DoBuckUpAMS(object oPC, int nClass, string sSpellbook, object oHideToken, object oAMSToken)
|
||||
{
|
||||
if(DEBUG) DoDebug("Creating buck-up copy of "+sSpellbook);
|
||||
if(array_exists(oAMSToken, sSpellbook))
|
||||
array_delete(oAMSToken, sSpellbook);
|
||||
array_create(oAMSToken, sSpellbook);
|
||||
int nSize = persistant_array_get_size(oPC, sSpellbook);
|
||||
DelayCommand(0.0, CopyAMSArray(oPC, oAMSToken, nClass, sSpellbook, 0, nSize));
|
||||
}
|
||||
|
||||
void AMSCompatibilityCheck(object oPC)
|
||||
{
|
||||
//Get an extra hide token with amagsys info
|
||||
object oAMSToken = GetHideToken(oPC, TRUE);
|
||||
object oHideToken = GetHideToken(oPC); //ebonfowl: no longer used but I'm leaving it to not have to edit other functions
|
||||
|
||||
int i;
|
||||
for(i = 1; i <= 8; i++)
|
||||
{
|
||||
int nClass = GetClassByPosition(i, oPC);
|
||||
string sSpellbook;
|
||||
int nSpellbookType = GetSpellbookTypeForClass(nClass);
|
||||
if(nSpellbookType == SPELLBOOK_TYPE_SPONTANEOUS)
|
||||
{
|
||||
sSpellbook = "Spellbook"+IntToString(nClass);
|
||||
int nSize1 = persistant_array_get_size(oPC, sSpellbook);
|
||||
int nSize2 = array_get_size(oAMSToken, sSpellbook);
|
||||
if(nSize1 > nSize2)
|
||||
DelayCommand(0.1f, DoBuckUpAMS(oPC, nClass, sSpellbook, oHideToken, oAMSToken));
|
||||
}
|
||||
else if(nSpellbookType == SPELLBOOK_TYPE_PREPARED)
|
||||
{
|
||||
int j;
|
||||
for(j = 0; j <= 9; j++)
|
||||
{
|
||||
sSpellbook = "Spellbook_Known_"+IntToString(nClass)+"_"+IntToString(j);
|
||||
int nSize1 = persistant_array_get_size(oPC, sSpellbook);
|
||||
int nSize2 = array_get_size(oAMSToken, sSpellbook);
|
||||
if(nSize1 > nSize2)
|
||||
DelayCommand(0.1f, DoBuckUpAMS(oPC, nClass, sSpellbook, oHideToken, oAMSToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,63 +0,0 @@
|
||||
//::///////////////////////////////////////////////
|
||||
//:: Power Attack NUI
|
||||
//:: hp_pa_chatscript
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
A OnChat script that parses what is said and opens the power attack NUI
|
||||
if provided /pa. Otherwise if /pa x is provided run the command directly
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Created By: Rakiov
|
||||
//:: Created On: 22.05.2005
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "nw_inc_nui"
|
||||
#include "hp_pa_view"
|
||||
#include "hp_string_util"
|
||||
|
||||
void main()
|
||||
{
|
||||
// Get current player
|
||||
object oPlayer = GetPCChatSpeaker();
|
||||
if (!GetIsPC(oPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// get current player message and split it up into a list
|
||||
string sCommand = GetPCChatMessage();
|
||||
json sCommandSplit = StringSplit(sCommand);
|
||||
|
||||
if(JsonGetLength(sCommandSplit) > 0)
|
||||
{
|
||||
string firstWord = JsonGetString(JsonArrayGet(sCommandSplit, 0));
|
||||
|
||||
// if first word is /pa we are using the power attack interface
|
||||
if(firstWord == "/pa")
|
||||
{
|
||||
if(JsonGetLength(sCommandSplit) >= 2)
|
||||
{
|
||||
//if a parameter is given then run the power attack command directly.
|
||||
string param1 = JsonGetString(JsonArrayGet(sCommandSplit, 1));
|
||||
int paAmount = StringToInt(param1);
|
||||
SetLocalInt(oPlayer, "PRC_PowerAttack_Level", paAmount);
|
||||
ExecuteScript("hp_pa_script", oPlayer);
|
||||
|
||||
// update the NUI so it is in sync
|
||||
int nToken = NuiFindWindow(oPlayer, NUI_PRC_POWER_ATTACK_WINDOW);
|
||||
if (nToken != 0)
|
||||
{
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_TEXT_BIND, JsonString(IntToString(paAmount)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if no param is given then open the NUI
|
||||
NuiPRCPowerAttackView(oPlayer);
|
||||
}
|
||||
|
||||
// clear message from chat
|
||||
SetPCChatMessage();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
//::///////////////////////////////////////////////
|
||||
//:: Power Attack Script
|
||||
//:: hp_pa_script
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
A script that sets the power attack on a player based on the amount
|
||||
given.
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Created By: Rakiov
|
||||
//:: Created On: 22.05.2005
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "prc_spell_const"
|
||||
|
||||
void SetPowerAttack();
|
||||
|
||||
//
|
||||
// Sets the power attack for a player, if the player has power attack and the
|
||||
// amount is less than or equal to the players BAB it will apply the
|
||||
// power attack and set the current power attack to the player at variable
|
||||
// 'prcPaScriptPaVariable', otherwise it will tell the player it can't.
|
||||
//
|
||||
// Arguments:
|
||||
// amount int the amount of power attack you want
|
||||
// oPlayer object the player to apply the power attack to
|
||||
//
|
||||
void main()
|
||||
{
|
||||
|
||||
ExecuteScript("prc_nui_pwrattk");
|
||||
|
||||
/* int amount = GetLocalInt(OBJECT_SELF, "PRC_PowerAttack_Level");
|
||||
int prevPowerAttack5 = GetLocalInt(OBJECT_SELF, "prevPowerAttack5");
|
||||
int prevPowerAttack1 = GetLocalInt(OBJECT_SELF, "prevPowerAttack1");
|
||||
int powerAttack5Amount = amount / 5;
|
||||
int powerAttack1Amount = amount % 5;
|
||||
|
||||
// Current actions can cause this to not run right away, so clear the queue
|
||||
// and force this to happen.
|
||||
ClearAllActions();
|
||||
|
||||
|
||||
//sets the 5 values for Power attack ranging from 0,5,10,15,20 respectivly
|
||||
if (prevPowerAttack5 != powerAttack5Amount)
|
||||
{
|
||||
if (powerAttack5Amount == 0) // Power Attack 0
|
||||
{
|
||||
ActionDoCommand(ActionCastSpellAtObject(SPELL_POWER_ATTACK6, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
|
||||
}
|
||||
if (powerAttack5Amount == 1) // Power Attack 5
|
||||
{
|
||||
ActionDoCommand(ActionCastSpellAtObject(SPELL_POWER_ATTACK7, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
|
||||
}
|
||||
if (powerAttack5Amount == 2) // Power Attack 10
|
||||
{
|
||||
ActionCastSpellAtObject(SPELL_POWER_ATTACK8, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
|
||||
}
|
||||
if (powerAttack5Amount == 3) // Power Attack 15
|
||||
{
|
||||
ActionCastSpellAtObject(SPELL_POWER_ATTACK9, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
|
||||
}
|
||||
if (powerAttack5Amount == 4) // Power Attack 20
|
||||
{
|
||||
ActionCastSpellAtObject(SPELL_POWER_ATTACK10, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
|
||||
}
|
||||
SetLocalInt(OBJECT_SELF, "prevPowerAttack5", powerAttack5Amount);
|
||||
}
|
||||
|
||||
if (prevPowerAttack1 != powerAttack1Amount)
|
||||
{
|
||||
//sets the 1 values for Power attack ranging from 0,1,2,3,4 respectivly
|
||||
if (powerAttack1Amount == 0) // Power Attack 0
|
||||
{
|
||||
ActionDoCommand(ActionCastSpellAtObject(SPELL_POWER_ATTACK1, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
|
||||
}
|
||||
if (powerAttack1Amount == 1) // Power Attack 1
|
||||
{
|
||||
ActionDoCommand(ActionCastSpellAtObject(SPELL_POWER_ATTACK2, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
|
||||
}
|
||||
if (powerAttack1Amount == 2) // Power Attack 2
|
||||
{
|
||||
ActionCastSpellAtObject(SPELL_POWER_ATTACK3, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
|
||||
}
|
||||
if (powerAttack1Amount == 3) // Power Attack 3
|
||||
{
|
||||
ActionCastSpellAtObject(SPELL_POWER_ATTACK4, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
|
||||
}
|
||||
if (powerAttack1Amount == 4) // Power Attack 4
|
||||
{
|
||||
ActionCastSpellAtObject(SPELL_POWER_ATTACK5, OBJECT_SELF, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
|
||||
}
|
||||
SetLocalInt(OBJECT_SELF, "prevPowerAttack1", powerAttack1Amount);
|
||||
}
|
||||
*/
|
||||
}
|
@@ -1,126 +0,0 @@
|
||||
//::///////////////////////////////////////////////
|
||||
//:: Power Attack NUI
|
||||
//:: ha_pa_view
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
A NUI that sets the power attack on a player based on the amount
|
||||
given.
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Created By: Rakiov
|
||||
//:: Created On: 22.05.2005
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "nw_inc_nui"
|
||||
// #include "nw_inc_nui_insp" // used to debug
|
||||
|
||||
//
|
||||
// NuiPRCPowerAttackView
|
||||
// The NUI window for the Power Attack interface, running this function
|
||||
// creates the window itself
|
||||
//
|
||||
// Arguments:
|
||||
// oPlayer object the player referenced for the NUI
|
||||
//
|
||||
void NuiPRCPowerAttackView(object oPlayer);
|
||||
|
||||
|
||||
// The Window ID
|
||||
const string NUI_PRC_POWER_ATTACK_WINDOW = "nui_prc_power_attack_window";
|
||||
|
||||
// LocalVar for the geometry of the window
|
||||
const string NUI_PRC_PA_GEOMETRY_VAR = "paNuiGeometry";
|
||||
|
||||
// Event For Left Button
|
||||
const string NUI_PRC_PA_LEFT_BUTTON_EVENT = "nui_prc_pa_left_button_event";
|
||||
// Event For Right Button
|
||||
const string NUI_PRC_PA_RIGHT_BUTTON_EVENT = "nui_prc_pa_right_button_event";
|
||||
|
||||
// Bind for Text
|
||||
const string NUI_PRC_PA_TEXT_BIND = "nui_prc_pa_text_bind";
|
||||
// Left Button Enabled Bind
|
||||
const string NUI_PRC_PA_LEFT_BUTTON_ENABLED_BIND = "leftButtonEnabled";
|
||||
// Right Button Enabled Bind
|
||||
const string NUI_PRC_PA_RIGHT_BUTTON_ENABLED_BIND = "rightButtonEnabled";
|
||||
|
||||
void NuiPRCPowerAttackView(object oPlayer)
|
||||
{
|
||||
// First we look for any previous windows, if found (ie, non-zero) we destory them so we can start fresh.
|
||||
int nPreviousToken = NuiFindWindow(oPlayer, NUI_PRC_POWER_ATTACK_WINDOW);
|
||||
if (nPreviousToken != 0)
|
||||
{
|
||||
NuiDestroy(oPlayer, nPreviousToken);
|
||||
}
|
||||
|
||||
// base element for NUI
|
||||
json jRoot = JsonArray();
|
||||
|
||||
// Create and set parameters for left button
|
||||
json jLeftButton = NuiId(NuiButton(JsonString("-")), NUI_PRC_PA_LEFT_BUTTON_EVENT);
|
||||
jLeftButton = NuiWidth(jLeftButton, 32.0f);
|
||||
jLeftButton = NuiHeight(jLeftButton, 32.0f);
|
||||
jLeftButton = NuiEnabled(jLeftButton, NuiBind(NUI_PRC_PA_LEFT_BUTTON_ENABLED_BIND));
|
||||
|
||||
// Create and set parameters for text field
|
||||
json jText = NuiText(NuiBind(NUI_PRC_PA_TEXT_BIND), TRUE, NUI_SCROLLBARS_NONE);
|
||||
jText = NuiWidth(jText, 32.0f);
|
||||
jText = NuiHeight(jText, 32.0f);
|
||||
|
||||
// Create and set parameters for right button
|
||||
json jRightButton = NuiId(NuiButton(JsonString("+")), NUI_PRC_PA_RIGHT_BUTTON_EVENT);
|
||||
jRightButton = NuiWidth(jRightButton, 32.0f);
|
||||
jRightButton = NuiHeight(jRightButton, 32.0f);
|
||||
jRightButton = NuiEnabled(jRightButton, NuiBind(NUI_PRC_PA_RIGHT_BUTTON_ENABLED_BIND));
|
||||
|
||||
// create button layout
|
||||
json jRow = JsonArray();
|
||||
jRow = JsonArrayInsert(jRow, NuiSpacer());
|
||||
jRow = JsonArrayInsert(jRow, jLeftButton);
|
||||
jRow = JsonArrayInsert(jRow, jText);
|
||||
jRow = JsonArrayInsert(jRow, jRightButton);
|
||||
jRow = JsonArrayInsert(jRow, NuiSpacer());
|
||||
jRow = NuiRow(jRow);
|
||||
jRoot = JsonArrayInsert(jRoot, jRow);
|
||||
|
||||
// set overall layout
|
||||
jRoot = NuiCol(jRoot);
|
||||
|
||||
// Create the window and set binds for parameters in case we want to change them later
|
||||
json nui = NuiWindow(jRoot, JsonString("Power Attack"), NuiBind("geometry"), NuiBind("resizable"), NuiBind("collapsed"), NuiBind("closable"), NuiBind("transparent"), NuiBind("border"));
|
||||
|
||||
int nToken = NuiCreate(oPlayer, nui, NUI_PRC_POWER_ATTACK_WINDOW);
|
||||
|
||||
// get the geometry of the window in case we opened this before and have a
|
||||
// preference for location
|
||||
json geometry = GetLocalJson(oPlayer, NUI_PRC_PA_GEOMETRY_VAR);
|
||||
|
||||
// Default to put this near the middle and let the person adjust its location
|
||||
if (geometry == JsonNull())
|
||||
{
|
||||
geometry = NuiRect(1095.0f,312.0f, 166.0f, 93.0f);
|
||||
}
|
||||
|
||||
// Set the binds to their default values
|
||||
NuiSetBind(oPlayer, nToken, "geometry", geometry);
|
||||
NuiSetBind(oPlayer, nToken, "collapsed", JsonBool(FALSE));
|
||||
NuiSetBind(oPlayer, nToken, "resizable", JsonBool(FALSE));
|
||||
NuiSetBind(oPlayer, nToken, "closable", JsonBool(TRUE));
|
||||
NuiSetBind(oPlayer, nToken, "transparent", JsonBool(TRUE));
|
||||
NuiSetBind(oPlayer, nToken, "border", JsonBool(FALSE));
|
||||
|
||||
int paAmount = GetLocalInt(oPlayer, "PRC_PowerAttack_Level");
|
||||
int currentBAB = GetBaseAttackBonus(oPlayer);
|
||||
|
||||
// if we reach the left or right limits of the power attack, then disable the buttons
|
||||
json leftButtonEnabled = (paAmount == 0) ? JsonBool(FALSE) : JsonBool(TRUE);
|
||||
json rightButtonEnabled = (paAmount == currentBAB) ? JsonBool(FALSE) : JsonBool(TRUE);
|
||||
|
||||
|
||||
// set the current PA amount to the window
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_TEXT_BIND, JsonString(IntToString(paAmount)));
|
||||
|
||||
|
||||
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_LEFT_BUTTON_ENABLED_BIND, leftButtonEnabled);
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_RIGHT_BUTTON_ENABLED_BIND, rightButtonEnabled);
|
||||
}
|
@@ -1,99 +0,0 @@
|
||||
//::///////////////////////////////////////////////
|
||||
//:: String Util
|
||||
//:: hp_string_util
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
A util class for providing useful string functions.
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Created By: Rakiov
|
||||
//:: Created On: 22.05.2005
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// StringSplit
|
||||
// Takes a string and splits it by " " into a json list of strings
|
||||
// i.e. "this is a test" returns
|
||||
// {
|
||||
// "this",
|
||||
// "is",
|
||||
// "a",
|
||||
// "test"
|
||||
// }
|
||||
//
|
||||
// Parameters:
|
||||
// string input the string input
|
||||
//
|
||||
// Returns:
|
||||
// json the json list of words
|
||||
//
|
||||
json StringSplit(string input);
|
||||
|
||||
//
|
||||
// TrimString
|
||||
// Takes a string and trims any leading whitespace characters
|
||||
// i.e. " this is a test" returns
|
||||
// "this is a test"
|
||||
//
|
||||
// Parameters:
|
||||
// input string the input string to trim
|
||||
//
|
||||
// Returns:
|
||||
// string the trimmed string
|
||||
//
|
||||
string TrimString(string input);
|
||||
|
||||
json StringSplit(string input)
|
||||
{
|
||||
json retValue = JsonArray();
|
||||
|
||||
string subString = "";
|
||||
//trim any whitespace characters first
|
||||
string currString = TrimString(input);
|
||||
|
||||
// loop until we process the whole string
|
||||
while(currString != "")
|
||||
{
|
||||
string currChar = GetStringLeft(currString, 1);
|
||||
if (currChar != "" && currChar != " ")
|
||||
{
|
||||
// if the current character isn't nothing or whitespace, then add it
|
||||
// to the current sub string.
|
||||
subString += currChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise if the substring is not empty, then add it to the list
|
||||
// of words to return
|
||||
if(subString != "")
|
||||
{
|
||||
retValue = JsonArrayInsert(retValue, JsonString(subString));
|
||||
subString = "";
|
||||
}
|
||||
}
|
||||
|
||||
// pop and move to next character
|
||||
currString = GetStringRight(currString, GetStringLength(currString)-1);
|
||||
}
|
||||
|
||||
// if there is any sub string left at the end of the loop, add it to the list
|
||||
if(subString != "")
|
||||
{
|
||||
retValue = JsonArrayInsert(retValue, JsonString(subString));
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
string TrimString(string input)
|
||||
{
|
||||
string retValue = input;
|
||||
|
||||
// while the string is not empty and we are looking at a whitespace, pop it.
|
||||
while(retValue != "" && GetStringLeft(retValue, 1) == " ")
|
||||
{
|
||||
retValue = GetStringRight(retValue, GetStringLength(retValue)-1);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
@@ -1,115 +0,0 @@
|
||||
//::///////////////////////////////////////////////
|
||||
//:: Power Attack Events
|
||||
//:: hp_pa_events
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
The NUI events for the Power Attack NUI Window
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Created By: Rakiov
|
||||
//:: Created On: 22.05.2005
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "nw_inc_nui"
|
||||
#include "hp_pa_view"
|
||||
|
||||
//
|
||||
// SetWindowGeometry
|
||||
// Sets the window geometry for the Power Attack NUI to the player
|
||||
// so it can be remembered when opened next time
|
||||
//
|
||||
// Arguments:
|
||||
// oPlayer object the player that owns the window
|
||||
// nToken int the windowId
|
||||
//
|
||||
void SetWindowGeometry(object oPlayer, int nToken);
|
||||
|
||||
void main()
|
||||
{
|
||||
object oPlayer = NuiGetEventPlayer();
|
||||
int nToken = NuiGetEventWindow();
|
||||
string sEvent = NuiGetEventType();
|
||||
string sElement = NuiGetEventElement();
|
||||
int nIndex = NuiGetEventArrayIndex();
|
||||
string sWindowId = NuiGetWindowId(oPlayer, nToken);
|
||||
|
||||
//HandleWindowInspectorEvent(); // used to debug
|
||||
|
||||
if(sWindowId != NUI_PRC_POWER_ATTACK_WINDOW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current Power Attack value for player
|
||||
int currentPAAmount = GetLocalInt(oPlayer, "PRC_PowerAttack_Level");
|
||||
|
||||
// if the window is closed, save the geometry
|
||||
if (sEvent == "close")
|
||||
{
|
||||
SetWindowGeometry(oPlayer, nToken);
|
||||
return;
|
||||
}
|
||||
|
||||
// Not a mouseup event, nothing to do.
|
||||
if (sEvent != "mouseup")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int currentBAB = GetBaseAttackBonus(oPlayer);
|
||||
|
||||
if (sElement == NUI_PRC_PA_LEFT_BUTTON_EVENT)
|
||||
{
|
||||
// if the decreased power attack doesn't go below 0 then perform PA decrease
|
||||
if(currentPAAmount-1 >= 0)
|
||||
{
|
||||
SetLocalInt(oPlayer, "PRC_PowerAttack_Level", currentPAAmount-1);
|
||||
ExecuteScript("hp_pa_script", oPlayer);
|
||||
// if decreased pwoer attack is lower than the current BAB then allow
|
||||
// the incrase button
|
||||
if(currentPAAmount-1 <= currentBAB)
|
||||
{
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_RIGHT_BUTTON_ENABLED_BIND, JsonBool(TRUE));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise we have hit the limit and disable the left button
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_LEFT_BUTTON_ENABLED_BIND, JsonBool(FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
if (sElement == NUI_PRC_PA_RIGHT_BUTTON_EVENT)
|
||||
{
|
||||
//if the incrased power attack amount is less than or equal to the BAB
|
||||
// then perform the PA increase
|
||||
if(currentPAAmount+1 <= currentBAB)
|
||||
{
|
||||
SetLocalInt(oPlayer, "PRC_PowerAttack_Level", currentPAAmount+1);
|
||||
ExecuteScript("hp_pa_script", oPlayer);
|
||||
// if the increased power attack amount is greater than 0 then enable
|
||||
// the decrease button
|
||||
if (currentPAAmount+1 > 0)
|
||||
{
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_LEFT_BUTTON_ENABLED_BIND, JsonBool(TRUE));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise we have hit the limit and disable the right button
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_RIGHT_BUTTON_ENABLED_BIND, JsonBool(FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
currentPAAmount = GetLocalInt(oPlayer, "PRC_PowerAttack_Level");
|
||||
|
||||
// set the geometry to the player since we only get mouseup events on button presses :(
|
||||
NuiSetBind(oPlayer, nToken, NUI_PRC_PA_TEXT_BIND, JsonString(IntToString(currentPAAmount)));
|
||||
SetWindowGeometry(oPlayer, nToken);
|
||||
}
|
||||
|
||||
void SetWindowGeometry(object oPlayer, int nToken)
|
||||
{
|
||||
json dimensions = NuiGetBind(oPlayer, nToken, "geometry");
|
||||
SetLocalJson(oPlayer, NUI_PRC_PA_GEOMETRY_VAR, dimensions);
|
||||
}
|
Reference in New Issue
Block a user