Files
PRC8/nwn/nwnprc/trunk/scripts/prc_reservefeat.nss
Jaysyn904 5e9986829f 2025/10/30 Update
Improved Trip / Disarm should be Champion of Corellon bonus feats.
Crinti Shadow Marauders don't get weapon proficiencies.
Epic Dragon Shaman is 21st level.
JPM was missing epic arcane bonus feats.
Karsites & Silverbrows can enter Crinti Shadow Maarauder.
Drunken Rage can allow entry into Frostrager.
Knight of the Sacred Seal was missing FEATOR prereq for Weapon Focus: Shortsword.
Two-Weapon Defense is a general feat.
Tweaked Echoblade enchantment cost.
Added base class equpiment packages more inline with PnP & the actual package descriptions (@Cypher).
Added a modified packages.2da to support the above.
Updated Dynamic Conversation tokens as to greatly lessen the chance of conflicting with module dialogues.
Added weapon proficiencies to FeatToIprop().
Added pnp essentia scaling support for meldshaper levels over 40.
Added GetProficiencyFeatOfWeaponType().
Added GetHasSwashbucklerWeapon().
Added GetHasCorellonWeapon().
Fixed spelling for IP_CONST_FEAT_WEAPON_PROFICIENCY_NUNCHAKU.
Fixed PsyRogue's Enhanced Sneak Attack scaling.
Eldrtich Doom shouldn't target non-hostiles.
Fixed Hellfire Warlock fire resistance to work with other sources of fire resistance.
Fixed text feedback for Island in Time.
Added some DEBUG for Shadow Blade.
prc_2da_cache creature should no longer be accidently targetable, causing faction issues.
Added a PnP cat creature, for the hell of it.  Tibitz is Dragon Magizine, unfortunately.
Updated text tokens for Astral Construct convos.
Updated text tokens for soulknife's mindblade convos.
If you save vs certain fear effects, they fail to work on you for 24 hours, from that source.  (Form of Doom, Dragon Fear)
Fixed Prismatic Sphere VFX bug (@Syrophir)
Fixed Banishment bug on all Prismatic spells.
Bralani Eldarin were missing Low-Light Vision.
Fixed Lips of Rapture bug.
Prelimiary work to making Favoured Soul's Deity's Weapon closer to PnP.
Fixed Firey Burst bug.  I think.

Updated notes.
Updated PRC8 Manual.
2025-10-30 19:04:58 -04:00

453 lines
15 KiB
Plaintext

//Reserve Feat Script
//prc_reservefeat
//by ebonfowl 5/5/2022
//Dedicated to Edgar, the real ebonfowl
//Lookup constants
//Domains
const string RESERVESPELL_DOMAIN_DESTRUCTION = "destruc";
const string RESERVESPELL_DOMAIN_DEATH = "dethdom";
const string RESERVESPELL_DOMAIN_WAR = "wardom";
//Descriptors
const string RESERVESPELL_DESCRIPTOR_ACID = "acid";
const string RESERVESPELL_DESCRIPTOR_AIR = "air";
const string RESERVESPELL_DESCRIPTOR_COLD = "cold";
const string RESERVESPELL_DESCRIPTOR_DARKNESS = "darknes";
const string RESERVESPELL_DESCRIPTOR_EARTH = "earth";
const string RESERVESPELL_DESCRIPTOR_ELECTRICITY = "electri";
const string RESERVESPELL_DESCRIPTOR_FIRE = "fire";
const string RESERVESPELL_DESCRIPTOR_FORCE = "force";
const string RESERVESPELL_DESCRIPTOR_GLAMER = "glamer";
const string RESERVESPELL_DESCRIPTOR_HEALING = "healing";
const string RESERVESPELL_DESCRIPTOR_LIGHT = "light";
const string RESERVESPELL_DESCRIPTOR_POLYMORPH = "polymor";
const string RESERVESPELL_DESCRIPTOR_SONIC = "sonic";
const string RESERVESPELL_DESCRIPTOR_SUMMONING = "summon";
const string RESERVESPELL_DESCRIPTOR_TELEPORTATION = "teleprt";
const string RESERVESPELL_DESCRIPTOR_WATER = "water";
//Schools
const string RESERVESPELL_SCHOOL_ABJURATION = "abjurat";
const string RESERVESPELL_SCHOOL_ENCHANTMENT = "enchant";
const string RESERVESPELL_SCHOOL_NECROMANCY = "necro";
//Includes
#include "prc_feat_const"
#include "prc_x2_itemprop"
#include "psi_inc_psifunc"
//ebonfowl: this function is not currently used, but I am leaving it in just in case
/*
int GetHighestSpellAvailable(object oPC)
{
//This will loop all the spells and return the highest level available to cast
string sFile = "prc_all"; //May need to rename
int i;
int nSpellID;
int nNewSpellLevel;
int nSpellLevel = 0;
string sSpellLabel;
for (i = 0; i < 500; i++) // Adjust max i to reflect something close to the highest row number in the 2das
{
nSpellID = StringToInt(Get2DACache(sFile, "SpellID", i));
sSpellLabel = Get2DACache(sFile, "Label", i);
if(sSpellLabel != "") // Non-blank row
{
if(PRCGetHasSpell(nSpellID, oPC))
{
nNewSpellLevel = StringToInt(Get2DACache(sFile, "Innate", i));
if (nNewSpellLevel > nSpellLevel) nSpellLevel = nNewSpellLevel;
}
}
}
return nSpellLevel;
}
*/
int GetHighestSpellAvailableBySchool(object oPC, string sSchool)
{
//This will loop all spells fpr a given school and return the highest level available to cast
string sFile = "prc_desc_" + sSchool;
int i;
int nSpellID;
int nNewSpellLevel;
int nSpellLevel = 0;
string sSpellLabel;
for (i = 0; i < 126; i++) // Adjust max i to reflect something close to the highest row number in the 2das
{
nSpellID = StringToInt(Get2DACache(sFile, "SpellID", i));
sSpellLabel = Get2DACache(sFile, "Label", i);
if(sSpellLabel != "") // Non-blank row
{
if(PRCGetHasSpell(nSpellID, oPC))
{
nNewSpellLevel = StringToInt(Get2DACache(sFile, "Innate", i));
if (nNewSpellLevel > nSpellLevel) nSpellLevel = nNewSpellLevel;
}
}
}
return nSpellLevel;
}
int GetHighestDomainSpellAvailable(object oPC, string sDomain) //This will loop all domain spells for a given domain and return the highest level available to cast
{
string sFile = "prc_desc_" + sDomain;
int i;
int nSpellID;
int nNewSpellLevel;
int nSpellLevel = 0;
string sSpellLabel;
for (i = 0; i < 12; i++) // Adjust max i to reflect something close to the highest row number in the 2das
{
nSpellID = StringToInt(Get2DACache(sFile, "SpellID", i));
sSpellLabel = Get2DACache(sFile, "Label", i);
if(sSpellLabel != "") // Non-blank row
{
if(PRCGetHasSpell(nSpellID, oPC))
{
nNewSpellLevel = StringToInt(Get2DACache(sFile, "Innate", i));
if (nNewSpellLevel > nSpellLevel) nSpellLevel = nNewSpellLevel;
}
}
}
return nSpellLevel;
}
int GetHighestSpellAvailableByDescriptor(object oPC, string sDescriptor)
{
//This will loop all spells fpr a given descriptor and return the highest level available to cast
string sFile = "prc_desc_" + sDescriptor;
int i;
int nSpellID;
int nNewSpellLevel;
int nSpellLevel = 0;
string sSpellLabel;
for (i = 0; i < 125; i++) // Adjust max i to reflect something close to the highest row number in the 2das
{
nSpellID = StringToInt(Get2DACache(sFile, "SpellID", i));
sSpellLabel = Get2DACache(sFile, "Label", i);
if(sSpellLabel != "") // Non-blank row
{
SendMessageToPC(oPC, "GetHighestSpellAvailableByDescriptor >> Entered function.");
SendMessageToPC(oPC, "Row " + IntToString(i) +
" Label = " + sSpellLabel +
" SpellID = " + IntToString(nSpellID) +
" HasSpell " + IntToString(PRCGetHasSpell(nSpellID, oPC)));
if(PRCGetHasSpell(nSpellID, oPC))
{
nNewSpellLevel = StringToInt(Get2DACache(sFile, "Innate", i));
if (nNewSpellLevel > nSpellLevel) nSpellLevel = nNewSpellLevel;
}
}
}
return nSpellLevel;
}
void UpdateReserveFeats(object oPC) //This will check for each reserve feat, call the function to set the bonus, then set the bonus
{
object oWeapon, oOffHand;
int nBonus;
int nDamage;
effect eEffect;
effect eCheckEffect;
string sTag;
//Holy Warrior
if (GetHasFeat(FEAT_HOLY_WARRIOR, oPC)) //Update constant when feat constant is made
{
nBonus = GetHighestDomainSpellAvailable(oPC, RESERVESPELL_DOMAIN_WAR);
nDamage = IPGetDamageBonusConstantFromNumber(nBonus);
oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
oOffHand = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
eEffect = EffectDamageIncrease(nDamage, DAMAGE_TYPE_SLASHING);
eEffect = TagEffect(eEffect, "HolyWarriorBonus");
eEffect = SupernaturalEffect(eEffect);
eCheckEffect = GetFirstEffect(oPC);
while (GetIsEffectValid(eCheckEffect))
{
if (GetEffectTag(eCheckEffect) == "HolyWarriorBonus")
{
RemoveEffect(oPC, eCheckEffect);
}
eCheckEffect = GetNextEffect(oPC);
}
if (IPGetIsMeleeWeapon(oWeapon) ||
IPGetIsMeleeWeapon(oOffHand) ||
GetWeaponRanged(oWeapon) ||
GetWeaponRanged(oOffHand))
{
if (nBonus > 3) ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oPC);
}
}
//Mystic Backlash
if (GetHasFeat(FEAT_MYSTIC_BACKLASH, oPC)) //Update constant when feat constant is made
{
nBonus = GetHighestSpellAvailableBySchool(oPC, RESERVESPELL_SCHOOL_ABJURATION);
DeleteLocalInt(oPC, "MysticBacklashBonus");
if (nBonus > 4) SetLocalInt(oPC, "MysticBacklashBonus", nBonus);
}
//Acidic Splatter
if(GetHasFeat(FEAT_ACIDIC_SPLATTER, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_ACID);
if((GetHasSpell(SPELL_ACID_FOG, oPC)) || (PRCGetIsRealSpellKnown(SPELL_ACID_FOG, oPC)))
{
nBonus = 6;
}
DeleteLocalInt(oPC, "AcidicSplatterBonus");
if (nBonus > 1) SetLocalInt(oPC, "AcidicSplatterBonus", nBonus);
}
//Fiery Burst
if(GetHasFeat(FEAT_FIERY_BURST, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_FIRE);
DeleteLocalInt(oPC, "FieryBurstBonus");
if (nBonus > 1) SetLocalInt(oPC, "FieryBurstBonus", nBonus);
}
//Storm Bolt
if(GetHasFeat(FEAT_STORM_BOLT, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_ELECTRICITY);
DeleteLocalInt(oPC, "StormBoltBonus");
if (nBonus > 2) SetLocalInt(oPC, "StormBoltBonus", nBonus);
}
//Winter's Blast
if(GetHasFeat(FEAT_WINTERS_BLAST, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_COLD);
DeleteLocalInt(oPC, "WintersBlastBonus");
if (nBonus > 1) SetLocalInt(oPC, "WintersBlastBonus", nBonus);
}
//Clap of Thunder
if(GetHasFeat(FEAT_CLAP_OF_THUNDER, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_SONIC);
DeleteLocalInt(oPC, "ClapOfThunderBonus");
if (nBonus > 2) SetLocalInt(oPC, "ClapOfThunderBonus", nBonus);
}
//Sickening Grasp
if (GetHasFeat(FEAT_SICKENING_GRASP, oPC)) //Update constant when feat constant is made
{
nBonus = GetHighestSpellAvailableBySchool(oPC, RESERVESPELL_SCHOOL_NECROMANCY);
DeleteLocalInt(oPC, "SickeningGraspBonus");
if (nBonus > 2) SetLocalInt(oPC, "SickeningGraspBonus", nBonus);
}
//Touch of Healing
if(GetHasFeat(FEAT_TOUCH_OF_HEALING, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_HEALING);
DeleteLocalInt(oPC, "TouchOfHealingBonus");
if (nBonus > 1) SetLocalInt(oPC, "TouchOfHealingBonus", nBonus);
}
//Dimensional Jaunt
if(GetHasFeat(FEAT_DIMENSIONAL_JAUNT, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_TELEPORTATION);
DeleteLocalInt(oPC, "DimensionalJauntBonus");
if (nBonus > 3) SetLocalInt(oPC, "DimensionalJauntBonus", nBonus);
}
//Clutch of Earth
if(GetHasFeat(FEAT_CLUTCH_OF_EARTH, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_EARTH);
DeleteLocalInt(oPC, "ClutchOfEarthBonus");
if (nBonus > 1) SetLocalInt(oPC, "ClutchOfEarthBonus", nBonus);
}
//Borne Aloft
if(GetHasFeat(FEAT_BORNE_ALOFT, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_AIR);
DeleteLocalInt(oPC, "BorneAloftBonus");
if (nBonus > 4) SetLocalInt(oPC, "BorneAloftBonus", nBonus);
}
//Protective Ward
if (GetHasFeat(FEAT_PROTECTIVE_WARD, oPC))
{
nBonus = GetHighestSpellAvailableBySchool(oPC, RESERVESPELL_SCHOOL_ABJURATION);
DeleteLocalInt(oPC, "ProtectiveWardBonus");
if (nBonus > 0) SetLocalInt(oPC, "ProtectiveWardBonus", nBonus);
}
//Shadow Veil
if(GetHasFeat(FEAT_SHADOW_VEIL, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_DARKNESS);
DeleteLocalInt(oPC, "ShadowVeilBonus");
if (nBonus > 1) SetLocalInt(oPC, "ShadowVeilBonus", nBonus);
}
//Sunlight Eyes
if(GetHasFeat(FEAT_SUNLIGHT_EYES, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_LIGHT);
DeleteLocalInt(oPC, "SunlightEyesBonus");
if (nBonus > 1) SetLocalInt(oPC, "SunlightEyesBonus", nBonus);
}
//Touch of Distraction
if (GetHasFeat(FEAT_TOUCH_OF_DISTRACTION, oPC))
{
nBonus = GetHighestSpellAvailableBySchool(oPC, RESERVESPELL_SCHOOL_ENCHANTMENT);
DeleteLocalInt(oPC, "TouchOfDistractionBonus");
if (nBonus > 2) SetLocalInt(oPC, "TouchOfDistractionBonus", nBonus);
}
//Umbral Shroud
if(GetHasFeat(FEAT_UMBRAL_SHROUD, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_DARKNESS);
DeleteLocalInt(oPC, "UmbralShroudBonus");
if (nBonus > 2) SetLocalInt(oPC, "UmbralShroudBonus", nBonus);
}
//Charnel Miasma
if(GetHasFeat(FEAT_CHARNEL_MIASMA, oPC))
{
nBonus = GetHighestDomainSpellAvailable(oPC, RESERVESPELL_DOMAIN_DEATH);
DeleteLocalInt(oPC, "CharnelMiasmaBonus");
if (nBonus > 1) SetLocalInt(oPC, "CharnelMiasmaBonus", nBonus);
}
//Drowning Glance
if(GetHasFeat(FEAT_DROWNING_GLANCE, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_WATER);
DeleteLocalInt(oPC, "DrowningGlanceBonus");
if (nBonus > 3) SetLocalInt(oPC, "DrowningGlanceBonus", nBonus);
}
//Invisible Needle
if(GetHasFeat(FEAT_INVISIBLE_NEEDLE, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_FORCE);
DeleteLocalInt(oPC, "InvisibleNeedleBonus");
if (nBonus > 2) SetLocalInt(oPC, "InvisibleNeedleBonus", nBonus);
}
//Summon Elemental
if(GetHasFeat(FEAT_SUMMON_ELEMENTAL, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_SUMMONING);
DeleteLocalInt(oPC, "SummonElementalBonus");
if (nBonus > 3) SetLocalInt(oPC, "SummonElementalBonus", nBonus);
}
//Dimensional Reach
if(GetHasFeat(FEAT_DIMENSIONAL_REACH, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_SUMMONING);
DeleteLocalInt(oPC, "DimensionalReachBonus");
if (nBonus > 2) SetLocalInt(oPC, "DimensionalReachBonus", nBonus);
}
//Hurricane Breath
if(GetHasFeat(FEAT_HURRICANE_BREATH, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_AIR);
DeleteLocalInt(oPC, "HurricaneBreathBonus");
if (nBonus > 1) SetLocalInt(oPC, "HurricaneBreathBonus", nBonus);
}
//Minor Shapeshift
if(GetHasFeat(FEAT_MINOR_SHAPESHIFT, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_POLYMORPH);
DeleteLocalInt(oPC, "MinorShapeshiftBonus");
if (nBonus > 3) SetLocalInt(oPC, "MinorShapeshiftBonus", nBonus);
}
//Face-Changer
if(GetHasFeat(FEAT_FACECHANGER, oPC))
{
nBonus = GetHighestSpellAvailableByDescriptor(oPC, RESERVESPELL_DESCRIPTOR_GLAMER);
DeleteLocalInt(oPC, "FaceChangerBonus");
if (nBonus > 2) SetLocalInt(oPC, "FaceChangerBonus", nBonus);
}
}
void main()
{
object oPC = OBJECT_SELF;
if(!GetLocalInt(oPC, "ReserveFeatsRunning"))
{
SetLocalInt(oPC, "ReserveFeatsRunning", TRUE);
//Hook this script into event system so it runs on hooked events
AddEventScript(oPC, EVENT_ONACTIVATEITEM, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONACQUIREITEM, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONCLIENTENTER, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONCLIENTLEAVE, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONPLAYERLEVELDOWN, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONPLAYERLEVELUP, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONPLAYERRESPAWN, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONPLAYEREQUIPITEM, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONPLAYERUNEQUIPITEM, "prc_reservefeat", TRUE, FALSE);
AddEventScript(oPC, EVENT_ONUNAQUIREITEM, "prc_reservefeat", TRUE, FALSE);
//Update the feat bonuses
UpdateReserveFeats(oPC);
}
else
{
UpdateReserveFeats(oPC);
}
}