2025/08/15 Update

Added Verdant Lord PrC.
Added Create Infusion feat & crafting system.
Added Magical Artisan: Create Infusion feat.
Added Plant Defiance feat.
Added Plant Control feat.
Added Control Plants spell.
Added Forestfold spell.
Added Immunity from Elements spell.
Added Creeping Cold & Greater Creeping Cold spells.
Added Adrenaline Surge spell.
Added Mundane & Infused Herb baseitem types.
Added Mundane & Enchanted Scepter baseitem types.
Added EffectGazeImmunity() effect.
Added Botanical material type.
Created json library for summoning support.
Updated Plant Domain spells.
Fixed bug w/ Regen Circle.
Fixed weapon size bug with Enlarge & Reduce Person.
Fixed TMI bug in Swarm of Arrows (hopefully)
Fixed Blood in the Water.
Fixed Iron Soul / Master of Nine prereq bug.
Fixed Happo Zanshin to work more like PnP.
Fixed targeting bug w/ Ultrablast.
Fixed Ubiquitous Vision.
Fixed Magic Staves for small creatures.
Gave the summoned "treant" from Treebrother a Barkskin vfx.
Radial spells can now be scribed w/ Scribe Scroll.
Fixed Martial Stances not counting bug w/ levelup NUI (@Rakiov)
This commit is contained in:
Jaysyn904
2025-08-15 13:42:37 -04:00
parent dd67019103
commit 9c7b452b9a
3518 changed files with 50047 additions and 45886 deletions

View File

@@ -36,7 +36,18 @@ string Get2DACache(string s2DA, string sColumn, int nRow)
s2DA = GetStringLowerCase(s2DA);
sColumn = GetStringLowerCase(sColumn);
/*//get the chest that contains the cache
string s = Get2DAString(s2DA, sColumn, nRow);
return s == "****" ? "" : s;
}
/*string Get2DACache(string s2DA, string sColumn, int nRow)
{
//lower case the 2da and column
s2DA = GetStringLowerCase(s2DA);
sColumn = GetStringLowerCase(sColumn);
//get the chest that contains the cache
object oCacheWP = GetObjectByTag("Bioware2DACache");
//if no chest, use HEARTOFCHAOS in limbo as a location to make a new one
if (!GetIsObjectValid(oCacheWP))
@@ -124,10 +135,10 @@ string Get2DACache(string s2DA, string sColumn, int nRow)
(s == "" ? "****" : s) ); // this sets the stored string to "****" if s is an empty string (else stores s)
if(DEBUG_GET2DACACHE) DoDebug("Get2DACache: Missing from cache: " + s2DA + "|" + sColumn + "|" + IntToString(nRow));
}
//if(DEBUG_GET2DACACHE) PrintString("Get2DACache: Returned value is '" + s + "'");*/
//if(DEBUG_GET2DACACHE) PrintString("Get2DACache: Returned value is '" + s + "'");
string s = Get2DAString(s2DA, sColumn, nRow);
return s == "****" ? "" : s;
}
}*/
string GetBiowareDBName()
{

View File

@@ -47,77 +47,78 @@ const string MES_CONTINGENCIES_YES2 = "The contingencies must expire to allo
*/
//Primogenitors SpellID constants
const int SPELL_EPIC_A_STONE = 0;//4007;
const int SPELL_EPIC_ACHHEEL = 1;//4000;
const int SPELL_EPIC_AL_MART = 2;//4002;
const int SPELL_EPIC_ALLHOPE = 3;//4001;
const int SPELL_EPIC_ANARCHY = 4;//4003;
const int SPELL_EPIC_ANBLAST = 5;//4004;
const int SPELL_EPIC_ANBLIZZ = 6;//4005;
const int SPELL_EPIC_ARMY_UN = 7;//4006;
const int SPELL_EPIC_BATTLEB = 999;//4008;
const int SPELL_EPIC_CELCOUN = 8;//4009;
const int SPELL_EPIC_CHAMP_V = 9;//4010;
const int SPELL_EPIC_CON_RES =10;//4011;
const int SPELL_EPIC_CON_REU =11;//4012;
const int SPELL_EPIC_DEADEYE =12;//4013;
const int SPELL_EPIC_DIREWIN =13;//4015;
const int SPELL_EPIC_DREAMSC =14;//4017;
const int SPELL_EPIC_DRG_KNI =15;//4016;
const int SPELL_EPIC_DTHMARK =1000;//4014;
const int SPELL_EPIC_DULBLAD =16;//4018;
const int SPELL_EPIC_DWEO_TH =17;//4019;
const int SPELL_EPIC_ENSLAVE =18;//4020;
const int SPELL_EPIC_EP_M_AR =19;//4021;
const int SPELL_EPIC_EP_RPLS =20;//4022;
const int SPELL_EPIC_EP_SP_R =21;//4023;
const int SPELL_EPIC_EP_WARD =22;//4024;
const int SPELL_EPIC_ET_FREE =23;//4025;
const int SPELL_EPIC_FIEND_W =24;//4026;
const int SPELL_EPIC_FLEETNS =25;//4027;
const int SPELL_EPIC_GEMCAGE =26;//4028;
const int SPELL_EPIC_GODSMIT =27;//4029;
const int SPELL_EPIC_GR_RUIN =28;//4030;
const int SPELL_EPIC_GR_SP_RE=29;//4031;
const int SPELL_EPIC_GR_TIME =30;//4032;
const int SPELL_EPIC_HELBALL =31;//4034;
const int SPELL_EPIC_HELSEND =1001;//4033;
const int SPELL_EPIC_HERCALL =32;//4035;
const int SPELL_EPIC_HERCEMP =33;//4036;
const int SPELL_EPIC_IMPENET =34;//4037;
const int SPELL_EPIC_LEECH_F =35;//4038;
const int SPELL_EPIC_LEG_ART =1002;//4039;
const int SPELL_EPIC_LIFE_FT =1003;//4040;
const int SPELL_EPIC_MAGMA_B =36;//4041;
const int SPELL_EPIC_MASSPEN =37;//4042;
const int SPELL_EPIC_MORI = 38;//4043;
const int SPELL_EPIC_MUMDUST =39;//4044;
const int SPELL_EPIC_NAILSKY =40;//4045;
const int SPELL_EPIC_NIGHTSU =1004;//4046;
const int SPELL_EPIC_ORDER_R =41;//4047;
const int SPELL_EPIC_PATHS_B =42;//4048;
const int SPELL_EPIC_PEERPEN =43;//4049;
const int SPELL_EPIC_PESTIL = 44;//4050;
const int SPELL_EPIC_PIOUS_P =45;//4051;
const int SPELL_EPIC_PLANCEL =46;//4052;
const int SPELL_EPIC_PSION_S =47;//4053;
const int SPELL_EPIC_RAINFIR =48;//4054;
const int SPELL_EPIC_RISEN_R =1005;//4055;
const int SPELL_EPIC_RUINN = 49;//4056; //NON_STANDARD
const int SPELL_EPIC_SINGSUN =50;//4057;
const int SPELL_EPIC_SP_WORM =51;//4058;
const int SPELL_EPIC_STORM_M =52;//4059;
const int SPELL_EPIC_SUMABER =53;//4060;
const int SPELL_EPIC_SUP_DIS =54;//4061;
const int SPELL_EPIC_SYMRUST =1006;//4062;
const int SPELL_EPIC_THEWITH =55;//4063;
const int SPELL_EPIC_TOLO_KW =56;//4064;
const int SPELL_EPIC_TRANVIT =57;//4065;
const int SPELL_EPIC_TWINF = 58;//4066;
const int SPELL_EPIC_UNHOLYD =59;//4067;
const int SPELL_EPIC_UNIMPIN =60;//4068;
const int SPELL_EPIC_UNSEENW =61;//4069;
const int SPELL_EPIC_WHIP_SH =62;//4070;
const int SPELL_EPIC_A_STONE = 0;//4007;
const int SPELL_EPIC_ACHHEEL = 1;//4000;
const int SPELL_EPIC_AL_MART = 2;//4002;
const int SPELL_EPIC_ALLHOPE = 3;//4001;
const int SPELL_EPIC_ANARCHY = 4;//4003;
const int SPELL_EPIC_ANBLAST = 5;//4004;
const int SPELL_EPIC_ANBLIZZ = 6;//4005;
const int SPELL_EPIC_ARMY_UN = 7;//4006;
const int SPELL_EPIC_BATTLEB = 999;//4008;
const int SPELL_EPIC_CELCOUN = 8;//4009;
const int SPELL_EPIC_CHAMP_V = 9;//4010;
const int SPELL_EPIC_CON_RES = 10;//4011;
const int SPELL_EPIC_CON_REU = 11;//4012;
const int SPELL_EPIC_DEADEYE = 12;//4013;
const int SPELL_EPIC_DIREWIN = 13;//4015;
const int SPELL_EPIC_DREAMSC = 14;//4017;
const int SPELL_EPIC_DRG_KNI = 15;//4016;
const int SPELL_EPIC_DTHMARK = 1000;//4014;
const int SPELL_EPIC_DULBLAD = 16;//4018;
const int SPELL_EPIC_DWEO_TH = 17;//4019;
const int SPELL_EPIC_ENSLAVE = 18;//4020;
const int SPELL_EPIC_EP_M_AR = 19;//4021;
const int SPELL_EPIC_EP_RPLS = 20;//4022;
const int SPELL_EPIC_EP_SP_R = 21;//4023;
const int SPELL_EPIC_EP_WARD = 22;//4024;
const int SPELL_EPIC_ET_FREE = 23;//4025;
const int SPELL_EPIC_FIEND_W = 24;//4026;
const int SPELL_EPIC_FLEETNS = 25;//4027;
const int SPELL_EPIC_GEMCAGE = 26;//4028;
const int SPELL_EPIC_GODSMIT = 27;//4029;
const int SPELL_EPIC_GR_RUIN = 28;//4030;
const int SPELL_EPIC_GR_SP_RE = 29;//4031;
const int SPELL_EPIC_GR_TIME = 30;//4032;
const int SPELL_EPIC_HELBALL = 31;//4034;
const int SPELL_EPIC_HELSEND = 1001;//4033;
const int SPELL_EPIC_HERCALL = 32;//4035;
const int SPELL_EPIC_HERCEMP = 33;//4036;
const int SPELL_EPIC_IMPENET = 34;//4037;
const int SPELL_EPIC_LEECH_F = 35;//4038;
const int SPELL_EPIC_LEG_ART = 1002;//4039;
const int SPELL_EPIC_LIFE_FT = 1003;//4040;
const int SPELL_EPIC_MAGMA_B = 36;//4041;
const int SPELL_EPIC_MASSPEN = 37;//4042;
const int SPELL_EPIC_MORI = 38;//4043;
const int SPELL_EPIC_MUMDUST = 39;//4044;
const int SPELL_EPIC_NAILSKY = 40;//4045;
const int SPELL_EPIC_NIGHTSU = 1004;//4046;
const int SPELL_EPIC_ORDER_R = 41;//4047;
const int SPELL_EPIC_PATHS_B = 42;//4048;
const int SPELL_EPIC_PEERPEN = 43;//4049;
const int SPELL_EPIC_PESTIL = 44;//4050;
const int SPELL_EPIC_PIOUS_P = 45;//4051;
const int SPELL_EPIC_PLANCEL = 46;//4052;
const int SPELL_EPIC_PSION_S = 47;//4053;
const int SPELL_EPIC_RAINFIR = 48;//4054;
//const int SPELL_EPIC_RISEN_R =1005;//4055;
const int SPELL_EPIC_RISEN_R = 49;//4055;
const int SPELL_EPIC_RUINN = 50;//4056; //NON_STANDARD
const int SPELL_EPIC_SINGSUN = 51;//4057;
const int SPELL_EPIC_SP_WORM = 52;//4058;
const int SPELL_EPIC_STORM_M = 53;//4059;
const int SPELL_EPIC_SUMABER = 54;//4060;
const int SPELL_EPIC_SUP_DIS = 55;//4061;
const int SPELL_EPIC_SYMRUST = 1006;//4062;
const int SPELL_EPIC_THEWITH = 56;//4063;
const int SPELL_EPIC_TOLO_KW = 57;//4064;
const int SPELL_EPIC_TRANVIT = 58;//4065;
const int SPELL_EPIC_TWINF = 59;//4066;
const int SPELL_EPIC_UNHOLYD = 60;//4067;
const int SPELL_EPIC_UNIMPIN = 61;//4068;
const int SPELL_EPIC_UNSEENW = 62;//4069;
const int SPELL_EPIC_WHIP_SH = 63;//4070;
/*

View File

@@ -0,0 +1,481 @@
//:://////////////////////////////////////////////
//:: ;-. ,-. ,-. ,-.
//:: | ) | ) / ( )
//:: |-' |-< | ;-:
//:: | | \ \ ( )
//:: ' ' ' `-' `-'
//::///////////////////////////////////////////////
//::
/*
Script: inc_infusion
Author: Jaysyn
Created: 2025-08-11 17:01:26
Description:
Contains most functions related to the Create
Infusion feat.
*/
//::
//:://////////////////////////////////////////////
#include "prc_inc_spells"
int GetMaxDivineSpellLevel(object oCaster, int nClass);
int GetCastSpellCasterLevelFromItem(object oItem, int nSpellID);
int GetIsClassSpell(object oCaster, int nSpellID, int nClass);
int GetHasSpellOnClassList(object oCaster, int nSpellID);
void InfusionSecondSave(object oUser, int nDC);
/**
* @brief Finds the class index for which the given spell is available to the specified caster.
*
* This function iterates through all possible classes and returns the first class
* index for which the specified spell is on the caster's spell list.
*
* @param oCaster The creature object to check.
* @param nSpellID The spell ID to find the class for.
*
* @return The class index that has the spell on its class spell list for the caster,
* or -1 if no matching class is found.
*/
int FindSpellCastingClass(object oCaster, int nSpellID)
{
int i = 0;
int nClassFound = -1;
int nClass;
// Only loop through caster's classes
for (i = 0; i <= 8; i++)
{
nClass = GetClassByPosition(i, oCaster);
if (nClass == CLASS_TYPE_INVALID) continue;
if (GetIsClassSpell(oCaster, nSpellID, nClass))
{
nClassFound = nClass;
break;
}
}
return nClassFound;
}
/**
* @brief Performs validation checks to determine if the caster can use a spell infusion from the specified item.
*
* This function verifies that the item is a valid infused herb, checks the caster's relevant class and ability scores,
* confirms the caster is a divine spellcaster with the necessary caster level, and ensures the spell is on the caster's class spell list.
*
* @param oCaster The creature attempting to use the infusion.
* @param oItem The infused herb item containing the spell.
* @param nSpellID The spell ID of the infusion spell being cast.
*
* @return TRUE if all infusion use checks pass and the caster can use the infusion; FALSE otherwise.
*/
int DoInfusionUseChecks(object oCaster, object oItem, int nSpellID)
{
int bPnPHerbs = GetPRCSwitch(PRC_CREATE_INFUSION_OPTIONAL_HERBS);
if(GetBaseItemType(oItem) != BASE_ITEM_INFUSED_HERB)
{
FloatingTextStringOnCreature("Not casting from an Infused Herb", oCaster);
return FALSE;
}
int nItemSpellLvl = GetCastSpellCasterLevelFromItem(oItem, nSpellID);
if (bPnPHerbs && nItemSpellLvl == -1)
{
FloatingTextStringOnCreature("Item has no spellcaster level.", oCaster);
return FALSE;
}
// **CRITICAL: Find the correct class that actually has the spell on its list**
int nClassCaster = FindSpellCastingClass(oCaster, nSpellID);
if(DEBUG) DoDebug("nClassCaster is: " + IntToString(nClassCaster) + ".");
// Check for valid class
if (nClassCaster == -1)
{
FloatingTextStringOnCreature("No valid class found for this spell.", oCaster);
return FALSE;
}
if(GetMaxDivineSpellLevel(oCaster, nClassCaster) < 1 )
{
FloatingTextStringOnCreature("You must be a divine spellcaster to activate an infusion.", oCaster);
return FALSE;
}
// Must have spell on class list - (This will also double-check via the class)
if (!GetHasSpellOnClassList(oCaster, nSpellID))
{
FloatingTextStringOnCreature("You must have a spell on one of your class spell lists to cast it from an infusion.", oCaster);
return FALSE;
}
// Must meet ability requirement: Ability score >= 10 + spell level
int nSpellLevel = PRCGetSpellLevelForClass(nSpellID, nClassCaster);
int nClassAbility = GetAbilityScoreForClass(nClassCaster, oCaster);
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: nClassCaster is "+IntToString(nClassCaster)+".");
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: Class nSpellLevel is "+IntToString(nSpellLevel)+".");
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: nClassAbility is "+IntToString(nClassAbility)+".");
if (nClassAbility < 10 + nSpellLevel)
{
FloatingTextStringOnCreature("You must meet ability score requirement to cast spell from infusion.", oCaster);
return FALSE;
}
// Must have a divine caster level at least equal to infusion's caster level
int nDivineLvl = GetPrCAdjustedCasterLevelByType(TYPE_DIVINE, oCaster);
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: nDivineLvl is "+IntToString(nDivineLvl)+".");
if (nDivineLvl < nItemSpellLvl)
{
FloatingTextStringOnCreature("Your divine caster level is too low to cast this spell from an infusion.", oCaster);
return FALSE;
}
return TRUE;
}
/* int DoInfusionUseChecks(object oCaster, object oItem, int nSpellID)
{
int bPnPHerbs = GetPRCSwitch(PRC_CREATE_INFUSION_OPTIONAL_HERBS);
if(GetBaseItemType(oItem) != BASE_ITEM_INFUSED_HERB)
{
FloatingTextStringOnCreature("Not casting from an Infused Herb", oCaster);
return FALSE;
}
int nItemSpellLvl = GetCastSpellCasterLevelFromItem(oItem, nSpellID);
if (bPnPHerbs && nItemSpellLvl == -1)
{
FloatingTextStringOnCreature("Item has no spellcaster level.", oCaster);
return FALSE;
}
// Find relevant class for the spell
int nClassCaster = FindSpellCastingClass(oCaster, nSpellID);
if(DEBUG) DoDebug("nClassCaster is: "+IntToString(nClassCaster)+".");
if(GetMaxDivineSpellLevel(oCaster, nClassCaster) < 1 )
{
FloatingTextStringOnCreature("You must be a divine spellcaster to activate an infusion.", oCaster);
return FALSE;
}
// Must have spell on class list
if (!GetHasSpellOnClassList(oCaster, nSpellID))
{
FloatingTextStringOnCreature("You must have a spell on one of your class spell lists to cast it from an infusion.", oCaster);
return FALSE;
}
// Must meet ability requirement: Ability score >= 10 + spell level
int nSpellLevel = PRCGetSpellLevelForClass(nSpellID, nClassCaster);
int nClassAbility = GetAbilityScoreForClass(nClassCaster, oCaster);
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: nClassCaster is "+IntToString(nClassCaster)+".");
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: Class nSpellLevel is "+IntToString(nSpellLevel)+".");
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: nClassAbility is "+IntToString(nClassAbility)+".");
if (nClassAbility < 10 + nSpellLevel)
{
FloatingTextStringOnCreature("You must meet ability score requirement to cast spell from infusion.", oCaster);
return FALSE;
}
// Must have a divine caster level at least equal to infusion's caster level
int nDivineLvl = GetPrCAdjustedCasterLevelByType(TYPE_DIVINE, oCaster);
if(DEBUG) DoDebug("inc_infusion >> DoInfusionUseChecks: nDivineLvl is "+IntToString(nDivineLvl)+".");
if (nDivineLvl < nItemSpellLvl)
{
FloatingTextStringOnCreature("Your divine caster level is too low to cast this spell from an infusion.", oCaster);
return FALSE;
}
return TRUE;
}
*/
/**
* @brief Retrieves the maximum divine spell level known by the caster for a given class.
*
* This function checks the caster's local integers named "PRC_DivSpell1" through "PRC_DivSpell9"
* in descending order to determine the highest divine spell level available.
* It returns the highest spell level for which the corresponding local int is false (zero).
*
* @param oCaster The creature whose divine spell levels are being checked.
* @param nClass The class index for which to check the divine spell level (currently unused).
*
* @return The highest divine spell level known by the caster (1 to 9).
*/
int GetMaxDivineSpellLevel(object oCaster, int nClass)
{
int i = 9;
for (i; i > 0; i--)
{
if(!GetLocalInt(oCaster, "PRC_DivSpell"+IntToString(i)))
return i;
}
return 1;
}
/**
* @brief Retrieves the spell school of an herb based on its resref by looking it up in the craft_infusion.2da file.
*
* This function searches the "craft_infusion" 2DA for a row matching the herb's resref.
* If found, it returns the corresponding spell school as an integer constant.
* If not found or the SpellSchool column is missing/invalid, it returns -1.
*
* @param oHerb The herb object to check.
*
* @return The spell school constant corresponding to the herb's infusion spell school,
* or -1 if the herb is invalid, not found, or the data is missing.
*/
int GetHerbsSpellSchool(object oHerb)
{
if (!GetIsObjectValid(oHerb)) return -1;
string sResref = GetResRef(oHerb);
int nRow = 0;
string sRowResref;
while (nRow < 200)
{
sRowResref = Get2DACache("craft_infusion", "Resref", nRow);
if (sRowResref == "") break;
if (sRowResref == sResref)
{
string sHerbSpellSchool = Get2DAString("craft_infusion", "SpellSchool", nRow);
if (sHerbSpellSchool == "A") return SPELL_SCHOOL_ABJURATION;
else if (sHerbSpellSchool == "C") return SPELL_SCHOOL_CONJURATION;
else if (sHerbSpellSchool == "D") return SPELL_SCHOOL_DIVINATION;
else if (sHerbSpellSchool == "E") return SPELL_SCHOOL_ENCHANTMENT;
else if (sHerbSpellSchool == "V") return SPELL_SCHOOL_EVOCATION;
else if (sHerbSpellSchool == "I") return SPELL_SCHOOL_ILLUSION;
else if (sHerbSpellSchool == "N") return SPELL_SCHOOL_NECROMANCY;
else if (sHerbSpellSchool == "T") return SPELL_SCHOOL_TRANSMUTATION;
else return SPELL_SCHOOL_GENERAL;
return -1;
}
nRow++;
}
return -1; // Not found
}
/**
* @brief Retrieves the infusion spell level of an herb by matching its resref in the craft_infusion.2da file.
*
* This function searches the "craft_infusion" 2DA for a row matching the herb's resref.
* If found, it returns the spell level from the SpellLevel column as an integer.
* If not found or the column is missing, it returns -1.
*
* @param oHerb The herb object whose infusion spell level is to be retrieved.
*
* @return The spell level as an integer if found, or -1 if the herb is invalid, not found, or the column is missing.
*/
int GetHerbsInfusionSpellLevel(object oHerb)
{
if (!GetIsObjectValid(oHerb)) return -1;
string sResref = GetResRef(oHerb);
int nRow = 0;
string sRowResref;
// Brute-force loop <20> adjust limit if your 2DA has more than 500 rows
while (nRow < 200)
{
sRowResref = Get2DACache("craft_infusion", "Resref", nRow);
if (sRowResref == "") break; // End of valid rows
if (sRowResref == sResref)
{
string sSpellLevelStr = Get2DAString("craft_infusion", "SpellLevel", nRow);
return StringToInt(sSpellLevelStr);
}
nRow++;
}
return -1; // Not found
}
/**
* @brief Retrieves the caster level of a specific cast-spell item property from an item.
*
* This function iterates through the item properties of the given item, searching for an
* ITEM_PROPERTY_CAST_SPELL_CASTER_LEVEL property that matches the specified spell ID.
* If found, it returns the caster level value stored in the item property.
*
* @param oItem The item object to check.
* @param nSpellID The spell ID to match against the item property.
*
* @return The caster level associated with the matching cast-spell item property,
* or -1 if no matching property is found.
*/
int GetCastSpellCasterLevelFromItem(object oItem, int nSpellID)
{
int nFoundCL = -1;
itemproperty ip = GetFirstItemProperty(oItem);
while (GetIsItemPropertyValid(ip))
{
int nType = GetItemPropertyType(ip);
// First preference: PRC's CASTER_LEVEL itemprop
if (nType == ITEM_PROPERTY_CAST_SPELL_CASTER_LEVEL)
{
int nSubType = GetItemPropertySubType(ip);
string sSpellIDStr = Get2DAString("iprp_spells", "SpellIndex", nSubType);
int nSubSpellID = StringToInt(sSpellIDStr);
if (nSubSpellID == nSpellID)
{
return GetItemPropertyCostTableValue(ip); // Found exact CL
}
}
// Fallback: vanilla CAST_SPELL property
if (nType == ITEM_PROPERTY_CAST_SPELL && nFoundCL == -1)
{
int nSubType = GetItemPropertySubType(ip);
string sSpellIDStr = Get2DAString("iprp_spells", "SpellIndex", nSubType);
int nSubSpellID = StringToInt(sSpellIDStr);
if (nSubSpellID == nSpellID)
{
// Vanilla uses CostTableValue for *number of uses*, not CL,
// so we<77>ll assume default caster level = spell level * 2 - 1
int nSpellLevel = StringToInt(Get2DAString("spells", "Innate", nSubSpellID));
nFoundCL = nSpellLevel * 2 - 1; // default NWN caster level rule
}
}
ip = GetNextItemProperty(oItem);
}
return nFoundCL; // -1 if not found
}
/**
* @brief Checks if a given spell ID is present on the specified class's spell list for the caster.
*
* This function determines the spell level of the spell for the given class using PRCGetSpellLevelForClass.
* If the spell level is -1, the spell is not on the class's spell list.
* Otherwise, the spell is considered to be on the class spell list.
*
* @param oCaster The creature object casting or querying the spell.
* @param nSpellID The spell ID to check.
* @param nClass The class index to check the spell list against.
*
* @return TRUE if the spell is on the class's spell list; FALSE otherwise.
*/
int GetIsClassSpell(object oCaster, int nSpellID, int nClass)
{
if(DEBUG) DoDebug("inc_infusion >> GetIsClassSpell: nSpellID is: "+IntToString(nSpellID)+".");
if(DEBUG) DoDebug("inc_infusion >> GetIsClassSpell: nClass is: "+IntToString(nClass)+".");
int nSpellLevel = PRCGetSpellLevelForClass(nSpellID, nClass);
if (nSpellLevel == -1)
{
if(DEBUG) DoDebug("inc_infusion >> GetIsClassSpell: SpellLevel is "+IntToString(nSpellLevel)+".");
if(DEBUG) DoDebug("inc_infusion >> GetIsClassSpell: Spell "+IntToString(nSpellID)+" is not in spelllist of "+IntToString(nClass)+".");
return FALSE;
}
return TRUE;
}
/**
* @brief Checks if the caster has the specified spell on any of their class spell lists.
*
* This function iterates through all classes the caster has (up to position 8),
* and returns TRUE if the spell is found on any class's spell list.
*
* @param oCaster The creature object to check.
* @param nSpellID The spell ID to search for.
*
* @return TRUE if the spell is present on at least one of the caster's class spell lists;
* FALSE otherwise.
*/
int GetHasSpellOnClassList(object oCaster, int nSpellID)
{
int i;
for (i = 0; i <= 8; i++)
{
int nClass = GetClassByPosition(i, oCaster);
if (nClass == CLASS_TYPE_INVALID) continue;
if (GetIsClassSpell(oCaster, nSpellID, nClass))
{
if(DEBUG) DoDebug("inc_infusion >> GetHasSpellOnClassList: Class spell found.");
return TRUE;
}
}
if(DEBUG) DoDebug("inc_infusion >> GetHasSpellOnClassList: Class spell not found.");
return FALSE;
}
/**
* @brief Applies a poison nausea effect to the user when infusion use fails.
*
* This function performs an immediate Fortitude saving throw against poison DC based on infusion caster level.
* If the user fails and is not immune to poison, an infusion nausea effect is applied, replacing any existing one.
* A second saving throw is scheduled after 1 minute to attempt to remove the effect.
*
* @param oUser The creature who used the infusion and may be poisoned.
* @param nInfusionCL The caster level of the infusion used, affecting the DC of the saving throw.
*/
void ApplyInfusionPoison(object oUser, int nInfusionCL)
{
int nDC = 10 + (nInfusionCL / 2);
int bImmune = GetIsImmune(oUser, IMMUNITY_TYPE_POISON);
// First save immediately
if (!bImmune && !PRCMySavingThrow(SAVING_THROW_FORT, oUser, nDC, SAVING_THROW_TYPE_POISON))
{
// Remove existing infusion poison nausea effect before applying new
effect eOld = GetFirstEffect(oUser);
while (GetIsEffectValid(eOld))
{
if (GetEffectTag(eOld) == "INFUSION_POISON_TAG")
{
RemoveEffect(oUser, eOld);
break; // Assuming only one effect with this tag
}
eOld = GetNextEffect(oUser);
}
effect eNausea = EffectNausea(oUser, 60.0f);
TagEffect(eNausea, "INFUSION_POISON_TAG");
FloatingTextStringOnCreature("The infusion has made you nauseous.", oUser);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eNausea, oUser, RoundsToSeconds(10));
}
// Second save 1 minute later
if (!bImmune)
{
DelayCommand(60.0, InfusionSecondSave(oUser, nDC));
}
}
void InfusionSecondSave(object oUser, int nDC)
{
if (!PRCMySavingThrow(SAVING_THROW_FORT, oUser, nDC, SAVING_THROW_TYPE_POISON))
{
FloatingTextStringOnCreature("The infusion has made you nauseous.", oUser);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectNausea(oUser, 60.0f), oUser, RoundsToSeconds(10));
}
}
//:: void main (){}

View File

@@ -720,7 +720,7 @@ void SetDefaultFileEnds()
SetPRCSwitch("PRC_FILE_END_polymorph", 155);
SetPRCSwitch("PRC_FILE_END_portraits", 1300);
SetPRCSwitch("PRC_FILE_END_prc_craft_alchem", 37);
SetPRCSwitch("PRC_FILE_END_prc_craft_gen_it", 204);
SetPRCSwitch("PRC_FILE_END_prc_craft_gen_it", 253);
SetPRCSwitch("PRC_FILE_END_prc_craft_poison", 62);
SetPRCSwitch("PRC_FILE_END_prc_domains", 59);
SetPRCSwitch("PRC_FILE_END_prc_familiar", 10);
@@ -1074,9 +1074,11 @@ void CreateSwitchNameArray()
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_X2_SCRIBESCROLL_COSTMODIFIER);
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_X2_CRAFTWAND_MAXLEVEL);
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_X2_CRAFTWAND_COSTMODIFIER);
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_X2_CREATEINFUSION_COSTMODIFIER);
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_CRAFTING_ARBITRARY);
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_CRAFTING_COST_SCALE);
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_CRAFTING_TIME_SCALE);
array_set_string(oWP, "Switch_Name", array_get_size(oWP, "Switch_Name"), PRC_CREATE_INFUSION_CASTER_LEVEL);
//spells

View File

@@ -1182,7 +1182,7 @@ int GetMaxEssentiaCapacityFeat(object oMeldshaper)
// Don't allow more than they have
if (nMax > GetTotalUsableEssentia(oMeldshaper)) nMax = GetTotalUsableEssentia(oMeldshaper);
//if (DEBUG) DoDebug("GetMaxEssentiaCapacityFeat: nHD "+IntToString(nHD)+" nMax "+IntToString(nMax));
if(DEBUG) DoDebug("GetMaxEssentiaCapacityFeat: nHD "+IntToString(nHD)+" nMax "+IntToString(nMax));
return nMax;
}

View File

@@ -143,7 +143,7 @@ const int CLASS_TYPE_MASTER_HARPER = 176;
const int CLASS_TYPE_FRE_BERSERKER = 177;
const int CLASS_TYPE_TEMPEST = 178;
const int CLASS_TYPE_FOE_HUNTER = 179;
//:: Free = 180
const int CLASS_TYPE_VERDANT_LORD = 180;
const int CLASS_TYPE_ORC_WARLORD = 181;
const int CLASS_TYPE_THRALL_OF_GRAZZT_A = 182;
const int CLASS_TYPE_NECROCARNATE = 183;

View File

@@ -75,6 +75,13 @@ void DeathlessFrenzyCheck(object oTarget);
// * PRC Version of a Bioware function to disable include loops
void PRCRemoveSpellEffects(int nSpell_ID, object oCaster, object oTarget);
/**
* Target is immune to gaze attacks
*
* @return the Dazzle effect
*/
effect EffectGazeImmune();
/**
* Dazzles the target: -1 Attack, Search, Spot, and VFX
*
@@ -583,7 +590,8 @@ effect PRCEffectHeal(int nHP, object oTarget)
return EffectHeal(nHP);
}
effect EffectAbilityBasedSkillIncrease(int iAbility, int iIncrease = 1){
effect EffectAbilityBasedSkillIncrease(int iAbility, int iIncrease = 1)
{
effect eReturn;
switch(iAbility)
{
@@ -639,7 +647,8 @@ effect EffectAbilityBasedSkillIncrease(int iAbility, int iIncrease = 1){
return eReturn;
}
effect EffectAbilityBasedSkillDecrease(int iAbility, int iDecrease = 1){
effect EffectAbilityBasedSkillDecrease(int iAbility, int iDecrease = 1)
{
effect eReturn;
switch(iAbility)
{
@@ -695,7 +704,8 @@ effect EffectAbilityBasedSkillDecrease(int iAbility, int iDecrease = 1){
return eReturn;
}
effect EffectDamageImmunityAll(){
effect EffectDamageImmunityAll()
{
effect eReturn = EffectDamageImmunityIncrease(DAMAGE_TYPE_ACID, 100);
eReturn = EffectLinkEffects(eReturn, EffectDamageImmunityIncrease(DAMAGE_TYPE_BLUDGEONING, 100));
eReturn = EffectLinkEffects(eReturn, EffectDamageImmunityIncrease(DAMAGE_TYPE_COLD, 100));
@@ -712,7 +722,8 @@ effect EffectDamageImmunityAll(){
return eReturn;
}
effect EffectImmunityMiscAll(){
effect EffectImmunityMiscAll()
{
effect eReturn = EffectImmunity(IMMUNITY_TYPE_ABILITY_DECREASE);
eReturn = EffectLinkEffects(eReturn, EffectImmunity(IMMUNITY_TYPE_BLINDNESS));
eReturn = EffectLinkEffects(eReturn, EffectImmunity(IMMUNITY_TYPE_DEAFNESS));
@@ -732,6 +743,31 @@ effect EffectImmunityMiscAll(){
return eReturn;
}
//:: Immunity to all gaze attacks
effect EffectGazeImmune()
{
effect eBlank;
effect eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_CHARM);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_CONFUSION);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DAZE);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DEATH);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DESTROY_CHAOS);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DESTROY_EVIL);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DESTROY_GOOD);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DESTROY_LAW);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DOMINATE);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_DOOM);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_FEAR);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_PARALYSIS);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_PETRIFY);
eReturn = EffectSpellImmunity(SPELLABILITY_GAZE_STUNNED);
eReturn = TagEffect(eReturn, "PRCGazeImmune");
return eReturn;
}
int GetIsShaken(object oTarget)
{
effect eEffect = GetFirstEffect(oTarget);
@@ -747,4 +783,7 @@ int GetIsShaken(object oTarget)
eEffect = GetNextEffect(oTarget);
}
return FALSE;
}
}
//:: Test void
//:: void main() {}

View File

@@ -153,6 +153,7 @@ const int FEAT_EPIC_CRUSADER = 25116;
const int FEAT_EPIC_SWORDSAGE = 25117;
const int FEAT_EPIC_WARBLADE = 25118;
const int FEAT_EPIC_LION_OF_TALISID = 25600;
const int FEAT_EPIC_VERDANT_LORD = 25618;
//:: Vile Martial Strike Expansion
@@ -203,6 +204,21 @@ const int FEAT_LOT_LIONS_POUNCE = 25615;
const int FEAT_LOT_LIONS_SWIFTNESS = 25616;
const int FEAT_LOT_LEONALS_ROAR = 25617;
//::: Verdant Lord
const int FEAT_VL_EXPERT_INFUSION = 25634;
const int FEAT_VL_SUN_SUSTENANCE = 25635;
const int FEAT_VL_SPONTANEITY = 25636;
const int FEAT_VL_PLANT_FACILITY = 25637;
const int FEAT_VL_WILD_SHAPE_TREANT = 25638;
const int FEAT_VL_ANIMATE_TREE = 25639;
const int FEAT_VL_GAEAS_EMBRACE = 25640;
//:: Masters of the Wild feats
const int FEAT_CREATE_INFUSION = 25960;
const int FEAT_MAGICAL_ARTISAN_CREATE_INFUSION = 25961;
const int FEAT_PLANT_DEFIANCE = 25992;
const int FEAT_PLANT_CONTROL = 25993;
//:: Racial Feats
const int FEAT_WEMIC_JUMP_8 = 4518;
@@ -6235,6 +6251,22 @@ const int FEAT_LION_OF_TALISID_SPELLCASTING_SOHEI = 25611;
const int FEAT_LION_OF_TALISID_SPELLCASTING_SOL = 25612;
const int FEAT_LION_OF_TALISID_SPELLCASTING_SPSHAMAN = 25613;
//:: Verdant Lord marker feats
const int FEAT_VERDANT_LORD_SPELLCASTING_ARCHIVIST = 25619;
const int FEAT_VERDANT_LORD_SPELLCASTING_CLERIC = 25620;
const int FEAT_VERDANT_LORD_SPELLCASTING_DRUID = 25621;
const int FEAT_VERDANT_LORD_SPELLCASTING_FAVOURED_SOUL = 25622;
const int FEAT_VERDANT_LORD_SPELLCASTING_HEALER = 25623;
const int FEAT_VERDANT_LORD_SPELLCASTING_JOWAW = 25624;
const int FEAT_VERDANT_LORD_SPELLCASTING_KOTC = 25625;
const int FEAT_VERDANT_LORD_SPELLCASTING_KOTMC = 25626;
const int FEAT_VERDANT_LORD_SPELLCASTING_NENTYAR_HUNTER = 25627;
const int FEAT_VERDANT_LORD_SPELLCASTING_PALADIN = 25628;
const int FEAT_VERDANT_LORD_SPELLCASTING_RANGER = 25629;
const int FEAT_VERDANT_LORD_SPELLCASTING_OASHAMAN = 25630;
const int FEAT_VERDANT_LORD_SPELLCASTING_SOHEI = 25631;
const int FEAT_VERDANT_LORD_SPELLCASTING_SOL = 25632;
const int FEAT_VERDANT_LORD_SPELLCASTING_SPSHAMAN = 25633;
//:: No spellcasting or invoking marker feats
const int FEAT_ASMODEUS_SPELLCASTING_NONE = 19590;

View File

@@ -462,7 +462,7 @@ int PRCGetSpellLevelForClass(int nSpell, int nClass)
return nSpellLevel;
}
// returns the spelllevel of nSpell as it can be cast by oCreature
// returns the spell circle level of nSpell as it can be cast by oCreature
int PRCGetSpellLevel(object oCreature, int nSpell)
{
/*if (!PRCGetHasSpell(nSpell, oCreature))

View File

@@ -109,7 +109,7 @@ void SetupCharacterData(object oPC)
case CLASS_TYPE_ARCANE_DUELIST: sScript = "prc_arcduel"; break;
case CLASS_TYPE_ARCHIVIST: sScript = "prc_archivist"; iData |= 0x01; break;
case CLASS_TYPE_ASSASSIN: break;
case CLASS_TYPE_BAELNORN: sScript = "prc_baelnorn"; break;
//case CLASS_TYPE_BAELNORN: sScript = "prc_baelnorn"; break;
case CLASS_TYPE_BARD: iData |= 0x07; break;
case CLASS_TYPE_BATTLESMITH: sScript = "prc_battlesmith"; break;
case CLASS_TYPE_BEGUILER: iData |= 0x03; break;
@@ -246,6 +246,7 @@ void SetupCharacterData(object oPC)
case CLASS_TYPE_TOTEM_RAGER: sScript = "moi_totemrager"; break;
case CLASS_TYPE_TRUENAMER: sScript = "true_truenamer"; iData |= 0x01; break;
case CLASS_TYPE_VASSAL: sScript = "prc_vassal"; break;
case CLASS_TYPE_VERDANT_LORD: sScript = "prc_verdantlord"; break;
case CLASS_TYPE_VIGILANT: sScript = "prc_vigilant"; break;
case CLASS_TYPE_WARBLADE: sScript = "tob_warblade"; iData |= 0x01; break;
case CLASS_TYPE_WARCHIEF: sScript = "prc_warchief"; break;
@@ -2265,6 +2266,8 @@ void FeatSpecialUsePerDay(object oPC)
FeatUsePerDay(oPC, FEAT_FM_FOREST_DOMINION, ABILITY_CHARISMA, 3);
FeatUsePerDay(oPC, FEAT_SOD_DEATH_TOUCH, -1, (GetLevelByClass(CLASS_TYPE_SLAYER_OF_DOMIEL, oPC)+4)/4);
FeatUsePerDay(oPC, FEAT_SUEL_DISPELLING_STRIKE, -1, (GetLevelByClass(CLASS_TYPE_SUEL_ARCHANAMACH, oPC) + 2) / 4);
FeatUsePerDay(oPC, FEAT_PLANT_CONTROL, ABILITY_CHARISMA, 3);
FeatUsePerDay(oPC, FEAT_PLANT_DEFIANCE, ABILITY_CHARISMA, 3);
FeatDiabolist(oPC);
FeatAlaghar(oPC);
ShadowShieldUses(oPC);

View File

@@ -0,0 +1,750 @@
//:://////////////////////////////////////////////
//:: ;-. ,-. ,-. ,-.
//:: | ) | ) / ( )
//:: |-' |-< | ;-:
//:: | | \ \ ( )
//:: ' ' ' `-' `-'
//:://////////////////////////////////////////////
//::
/*
Library for json related functions.
*/
//::
//:://////////////////////////////////////////////
//:: Script: prc_inc_json.nss
//:: Author: Jaysyn
//:: Created: 2025-08-14 12:52:32
//:://////////////////////////////////////////////
#include "nw_inc_gff"
#include "inc_debug"
//::---------------------------------------------|
//:: Helper functions |
//::---------------------------------------------|
//:: Function to calculate the maximum possible hitpoints for oCreature
int GetMaxPossibleHP(object oCreature)
{
int nMaxHP = 0; // Stores the total maximum hitpoints
int i = 1; // Initialize position for class index
int nConb = GetAbilityModifier(ABILITY_CONSTITUTION, oCreature);
// Loop through each class position the creature may have, checking each class in turn
while (TRUE)
{
// Get the class ID at position i
int nClassID = GetClassByPosition(i, oCreature);
// If class is invalid (no more classes to check), break out of loop
if (nClassID == CLASS_TYPE_INVALID)
break;
// Get the number of levels in this class
int nClassLevels = GetLevelByClass(nClassID, oCreature);
// Get the row index of the class in classes.2da by using class ID as the row index
int nHitDie = StringToInt(Get2DAString("classes", "HitDie", nClassID));
// Add maximum HP for this class (Hit Die * number of levels in this class)
nMaxHP += nClassLevels * nHitDie;
// Move to the next class position
i++;
}
nMaxHP += nConb * GetHitDice(oCreature);
return nMaxHP;
}
// Returns how many feats a creature should gain when its HD increases
int CalculateFeatsFromHD(int nOriginalHD, int nNewHD)
{
// HD increase
int nHDIncrease = nNewHD - nOriginalHD;
if (nHDIncrease <= 0)
return 0; // No new feats if HD did not increase
// D&D 3E: 1 feat per 3 HD
int nBonusFeats = nHDIncrease / 3;
return nBonusFeats;
}
// Returns how many stat boosts a creature needs based on its HD
int GetStatBoostsFromHD(int nCreatureHD, int nModiferCap)
{
// Make sure we don't get negative boosts
int nBoosts = (40 - nCreatureHD) / 4;
if (nBoosts < 0)
{
nBoosts = 0;
}
return nBoosts;
}
// Struct to hold size modifiers
struct SizeModifiers
{
int strMod;
int dexMod;
int conMod;
int naturalAC;
int attackBonus;
int dexSkillMod;
};
//::---------------------------------------------|
//:: JSON functions |
//::---------------------------------------------|
//:: Returns the integer value of a VarTable entry named sVarName, or 0 if not found.
int json_GetLocalIntFromVarTable(json jCreature, string sVarName)
{
json jVarTable = GffGetList(jCreature, "VarTable");
if (jVarTable == JsonNull())
return 0;
int nCount = JsonGetLength(jVarTable);
int i;
for (i = 0; i < nCount; i++)
{
json jEntry = JsonArrayGet(jVarTable, i);
if (jEntry == JsonNull()) continue;
// Get the Name field using GFF functions
json jName = GffGetString(jEntry, "Name");
if (jName == JsonNull()) continue;
string sName = JsonGetString(jName);
if (sName == sVarName)
{
// Get the Type field to verify it's an integer
json jType = GffGetDword(jEntry, "Type");
if (jType != JsonNull())
{
int nType = JsonGetInt(jType);
if (nType == 1) // Type 1 = integer
{
// Get the Value field using GFF functions
json jValue = GffGetInt(jEntry, "Value");
if (jValue == JsonNull()) return 0;
return JsonGetInt(jValue);
}
}
}
}
return 0;
}
//:: Returns the total Hit Dice from a JSON creature GFF.
int json_GetCreatureHD(json jGff)
{
int nHD = 0;
json jClasses = GffGetList(jGff, "ClassList");
if (jClasses == JsonNull())
return 0;
int nCount = JsonGetLength(jClasses);
int i;
for (i = 0; i < nCount; i = i + 1)
{
json jClass = JsonArrayGet(jClasses, i);
if (jClass == JsonNull())
continue;
json jLevel = GffGetShort(jClass, "ClassLevel"); // Use GffGetShort, not GffGetField
if (jLevel != JsonNull())
{
int nLevel = JsonGetInt(jLevel);
nHD += nLevel;
}
}
if (nHD <= 0) nHD = 1;
return nHD;
}
//:: Reads ABILITY_TO_INCREASE from creature's VarTable and applies stat boosts based on increased HD
json json_ApplyAbilityBoostFromHD(json jCreature, int nOriginalHD, int nModifierCap)
{
if (jCreature == JsonNull())
return jCreature;
// Get the ability to increase from VarTable
int nAbilityToIncrease = json_GetLocalIntFromVarTable(jCreature, "ABILITY_TO_INCREASE");
if (nAbilityToIncrease < 0 || nAbilityToIncrease > 5)
{
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Invalid ABILITY_TO_INCREASE value: " + IntToString(nAbilityToIncrease));
return jCreature; // Invalid ability index
}
// Calculate total current HD from ClassList
json jClassList = GffGetList(jCreature, "ClassList");
if (jClassList == JsonNull())
{
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Failed to get ClassList");
return jCreature;
}
int nCurrentTotalHD = 0;
int nClassCount = JsonGetLength(jClassList);
int i;
for (i = 0; i < nClassCount; i++)
{
json jClass = JsonArrayGet(jClassList, i);
if (jClass != JsonNull())
{
json jClassLevel = GffGetShort(jClass, "ClassLevel");
if (jClassLevel != JsonNull())
{
nCurrentTotalHD += JsonGetInt(jClassLevel);
}
}
}
if (nCurrentTotalHD <= 0)
{
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: No valid Hit Dice found");
return jCreature;
}
// Calculate stat boosts based on crossing level thresholds
// Characters get stat boosts at levels 4, 8, 12, 16, 20, etc.
int nOriginalBoosts = nOriginalHD / 4; // How many boosts they already had
int nCurrentBoosts = nCurrentTotalHD / 4; // How many they should have now
int nBoosts = nCurrentBoosts - nOriginalBoosts; // Additional boosts to apply
if (nBoosts <= 0)
{
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: No boosts needed (Original boosts: " + IntToString(nOriginalBoosts) + ", Current boosts: " + IntToString(nCurrentBoosts) + ")");
return jCreature;
}
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Applying " + IntToString(nBoosts) + " boosts to ability " + IntToString(nAbilityToIncrease) + " for HD increase from " + IntToString(nOriginalHD) + " to " + IntToString(nCurrentTotalHD));
// Determine which ability to boost and apply the increases
string sAbilityField;
switch (nAbilityToIncrease)
{
case 0: sAbilityField = "Str"; break;
case 1: sAbilityField = "Dex"; break;
case 2: sAbilityField = "Con"; break;
case 3: sAbilityField = "Int"; break;
case 4: sAbilityField = "Wis"; break;
case 5: sAbilityField = "Cha"; break;
default:
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Unknown ability index: " + IntToString(nAbilityToIncrease));
return jCreature;
}
// Get current ability score
json jCurrentAbility = GffGetByte(jCreature, sAbilityField);
if (jCurrentAbility == JsonNull())
{
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Failed to get " + sAbilityField + " score");
return jCreature;
}
int nCurrentScore = JsonGetInt(jCurrentAbility);
int nNewScore = nCurrentScore + nBoosts;
// Clamp to valid byte range
if (nNewScore < 1) nNewScore = 1;
if (nNewScore > 255) nNewScore = 255;
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Increasing " + sAbilityField + " from " + IntToString(nCurrentScore) + " to " + IntToString(nNewScore));
// Apply the ability score increase
jCreature = GffReplaceByte(jCreature, sAbilityField, nNewScore);
if (jCreature == JsonNull())
{
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Failed to update " + sAbilityField);
return JsonNull();
}
if(DEBUG) DoDebug("json_ApplyAbilityBoostFromHD: Successfully applied ability boosts");
return jCreature;
}
//:: Adjust a skill by its ID (more efficient than name lookup)
json json_AdjustCreatureSkillByID(json jCreature, int nSkillID, int nMod)
{
// Get the SkillList
json jSkillList = GffGetList(jCreature, "SkillList");
if (jSkillList == JsonNull())
{
if(DEBUG) DoDebug("json_AdjustCreatureSkillByID: Failed to get SkillList");
return jCreature;
}
// Check if we have enough skills in the list
int nSkillCount = JsonGetLength(jSkillList);
if (nSkillID >= nSkillCount)
{
if(DEBUG) DoDebug("json_AdjustCreatureSkillByID: Skill ID " + IntToString(nSkillID) + " exceeds skill list length " + IntToString(nSkillCount));
return jCreature;
}
// Get the skill struct at the correct index
json jSkill = JsonArrayGet(jSkillList, nSkillID);
if (jSkill == JsonNull())
{
if(DEBUG) DoDebug("json_AdjustCreatureSkillByID: Failed to get skill at index " + IntToString(nSkillID));
return jCreature;
}
// Get current rank
json jRank = GffGetByte(jSkill, "Rank");
if (jRank == JsonNull())
{
if(DEBUG) DoDebug("json_AdjustCreatureSkillByID: Failed to get Rank for skill ID " + IntToString(nSkillID));
return jCreature;
}
int nCurrentRank = JsonGetInt(jRank);
int nNewRank = nCurrentRank + nMod;
// Clamp to valid range
if (nNewRank < 0) nNewRank = 0;
if (nNewRank > 255) nNewRank = 255;
// Update the rank in the skill struct
jSkill = GffReplaceByte(jSkill, "Rank", nNewRank);
if (jSkill == JsonNull())
{
if(DEBUG) DoDebug("json_AdjustCreatureSkillByID: Failed to replace Rank for skill ID " + IntToString(nSkillID));
return JsonNull();
}
// Replace the skill in the array
jSkillList = JsonArraySet(jSkillList, nSkillID, jSkill);
// Replace the SkillList in the creature
jCreature = GffReplaceList(jCreature, "SkillList", jSkillList);
return jCreature;
}
//:: Reads FutureFeat1..FutureFeatN from the template's VarTable and appends them to FeatList if missing.
json json_AddFeatsFromCreatureVars(json jCreature, int nOriginalHD)
{
if (jCreature == JsonNull())
return jCreature;
// Calculate current total HD
int nCurrentHD = json_GetCreatureHD(jCreature);
int nAddedHD = nCurrentHD - nOriginalHD;
if (nAddedHD <= 0)
{
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: No additional HD to process (Current: " + IntToString(nCurrentHD) + ", Original: " + IntToString(nOriginalHD) + ")");
return jCreature;
}
// Calculate how many feats the creature should get based on added HD
// Characters get a feat at levels 1, 3, 6, 9, 12, 15, 18, etc.
// For added levels, we need to check what feat levels they cross
int nOriginalFeats = (nOriginalHD + 2) / 3; // Feats from original HD
int nCurrentFeats = (nCurrentHD + 2) / 3; // Feats from current HD
int nNumFeats = nCurrentFeats - nOriginalFeats; // Additional feats earned
if (nNumFeats <= 0)
{
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: No additional feats earned from " + IntToString(nAddedHD) + " added HD");
return jCreature;
}
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Processing " + IntToString(nNumFeats) + " feats for " + IntToString(nAddedHD) + " added HD (Original: " + IntToString(nOriginalHD) + ", Current: " + IntToString(nCurrentHD) + ")");
// Get or create FeatList
json jFeatArray = GffGetList(jCreature, "FeatList");
if (jFeatArray == JsonNull())
jFeatArray = JsonArray();
int nOriginalFeatCount = JsonGetLength(jFeatArray);
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Original feat count: " + IntToString(nOriginalFeatCount));
int nAdded = 0;
int i = 1;
int nMaxIterations = 100; // Safety valve
int nIterations = 0;
while (nAdded < nNumFeats && nIterations < nMaxIterations)
{
nIterations++;
string sVarName = "FutureFeat" + IntToString(i);
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Checking " + sVarName);
int nFeat = json_GetLocalIntFromVarTable(jCreature, sVarName);
if (nFeat <= 0)
{
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: " + sVarName + " not found or invalid");
i++;
continue;
}
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Found " + sVarName + " = " + IntToString(nFeat));
// Check if feat already exists
int bHasFeat = FALSE;
int nFeatCount = JsonGetLength(jFeatArray);
int j;
for (j = 0; j < nFeatCount; j++)
{
json jFeatStruct = JsonArrayGet(jFeatArray, j);
if (jFeatStruct != JsonNull())
{
json jFeatValue = GffGetWord(jFeatStruct, "Feat");
if (jFeatValue != JsonNull() && JsonGetInt(jFeatValue) == nFeat)
{
bHasFeat = TRUE;
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Feat " + IntToString(nFeat) + " already exists");
break;
}
}
}
// Insert if missing
if (!bHasFeat)
{
json jNewFeat = JsonObject();
jNewFeat = JsonObjectSet(jNewFeat, "__struct_id", JsonInt(1));
jNewFeat = GffAddWord(jNewFeat, "Feat", nFeat);
if (jNewFeat == JsonNull())
{
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Failed to create feat struct for feat " + IntToString(nFeat));
break;
}
jFeatArray = JsonArrayInsert(jFeatArray, jNewFeat);
nAdded++;
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Added feat " + IntToString(nFeat) + " (" + IntToString(nAdded) + "/" + IntToString(nNumFeats) + ")");
}
i++;
// Safety break if we've checked too many variables
if (i > 100)
{
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Safety break - checked too many FutureFeat variables");
break;
}
}
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Completed. Added " + IntToString(nAdded) + " feats in " + IntToString(nIterations) + " iterations");
// Save back the modified FeatList only if we added something
if (nAdded > 0)
{
jCreature = GffReplaceList(jCreature, "FeatList", jFeatArray);
if (jCreature == JsonNull())
{
if(DEBUG) DoDebug("json_AddFeatsFromCreatureVars: Failed to replace FeatList");
return JsonNull();
}
}
return jCreature;
}
//:: Get the size of a JSON array
int json_GetArraySize(json jArray)
{
int iSize = 0;
while (JsonArrayGet(jArray, iSize) != JsonNull())
{
iSize++;
}
return iSize;
}
//:: Directly modifies oCreature's Base Natural AC if iNewAC is higher.
//::
json json_UpdateBaseAC(json jCreature, int iNewAC)
{
//json jBaseAC = GffGetByte(jCreature, "Creature/value/NaturalAC/value");
json jBaseAC = GffGetByte(jCreature, "NaturalAC");
if (jBaseAC == JsonNull())
{
return JsonNull();
}
else if (JsonGetInt(jBaseAC) > iNewAC)
{
return jCreature;
}
else
{
jCreature = GffReplaceByte(jCreature, "NaturalAC", iNewAC);
return jCreature;
}
}
//:: Directly modifies jCreature's Challenge Rating.
//:: This is useful for most XP calculations.
json json_UpdateCR(json jCreature, int nBaseCR, int nCRMod)
{
int nNewCR;
//:: Add CRMod to current CR
nNewCR = nBaseCR + nCRMod;
//:: Modify Challenge Rating
jCreature = GffReplaceFloat(jCreature, "ChallengeRating", IntToFloat(nNewCR));
return jCreature;
}
//:: Directly modifies ability scores in a creature's JSON GFF.
//::
json json_UpdateTemplateStats(json jCreature, int iModStr = 0, int iModDex = 0, int iModCon = 0,
int iModInt = 0, int iModWis = 0, int iModCha = 0)
{
int iCurrent;
// STR
if (!GffGetFieldExists(jCreature, "Str", GFF_FIELD_TYPE_BYTE))
jCreature = GffAddByte(jCreature, "Str", 10);
iCurrent = JsonGetInt(GffGetByte(jCreature, "Str"));
jCreature = GffReplaceByte(jCreature, "Str", iCurrent + iModStr);
// DEX
if (!GffGetFieldExists(jCreature, "Dex", GFF_FIELD_TYPE_BYTE))
jCreature = GffAddByte(jCreature, "Dex", 10);
iCurrent = JsonGetInt(GffGetByte(jCreature, "Dex"));
jCreature = GffReplaceByte(jCreature, "Dex", iCurrent + iModDex);
// CON
if (!GffGetFieldExists(jCreature, "Con", GFF_FIELD_TYPE_BYTE))
jCreature = GffAddByte(jCreature, "Con", 10);
iCurrent = JsonGetInt(GffGetByte(jCreature, "Con"));
jCreature = GffReplaceByte(jCreature, "Con", iCurrent + iModCon);
// INT
if (!GffGetFieldExists(jCreature, "Int", GFF_FIELD_TYPE_BYTE))
jCreature = GffAddByte(jCreature, "Int", 10);
iCurrent = JsonGetInt(GffGetByte(jCreature, "Int"));
jCreature = GffReplaceByte(jCreature, "Int", iCurrent + iModInt);
// WIS
if (!GffGetFieldExists(jCreature, "Wis", GFF_FIELD_TYPE_BYTE))
jCreature = GffAddByte(jCreature, "Wis", 10);
iCurrent = JsonGetInt(GffGetByte(jCreature, "Wis"));
jCreature = GffReplaceByte(jCreature, "Wis", iCurrent + iModWis);
// CHA
if (!GffGetFieldExists(jCreature, "Cha", GFF_FIELD_TYPE_BYTE))
jCreature = GffAddByte(jCreature, "Cha", 10);
iCurrent = JsonGetInt(GffGetByte(jCreature, "Cha"));
jCreature = GffReplaceByte(jCreature, "Cha", iCurrent + iModCha);
return jCreature;
}
//:: Directly modifies oCreature's ability scores.
//::
json json_UpdateCreatureStats(json jCreature, object oBaseCreature, int iModStr = 0, int iModDex = 0, int iModCon = 0, int iModInt = 0, int iModWis = 0, int iModCha = 0)
{
//:: Retrieve and modify ability scores
int iCurrentStr = GetAbilityScore(oBaseCreature, ABILITY_STRENGTH);
int iCurrentDex = GetAbilityScore(oBaseCreature, ABILITY_DEXTERITY);
int iCurrentCon = GetAbilityScore(oBaseCreature, ABILITY_CONSTITUTION);
int iCurrentInt = GetAbilityScore(oBaseCreature, ABILITY_INTELLIGENCE);
int iCurrentWis = GetAbilityScore(oBaseCreature, ABILITY_WISDOM);
int iCurrentCha = GetAbilityScore(oBaseCreature, ABILITY_CHARISMA);
jCreature = GffReplaceByte(jCreature, "Str", iCurrentStr + iModStr);
jCreature = GffReplaceByte(jCreature, "Dex", iCurrentDex + iModDex);
jCreature = GffReplaceByte(jCreature, "Con", iCurrentCon + iModCon);
jCreature = GffReplaceByte(jCreature, "Int", iCurrentInt + iModInt);
jCreature = GffReplaceByte(jCreature, "Wis", iCurrentWis + iModWis);
jCreature = GffReplaceByte(jCreature, "Cha", iCurrentCha + iModCha);
return jCreature;
}
//:: Increases a creature's Hit Dice in its JSON GFF data by nAmount
json json_AddHitDice(json jCreature, int nAmount)
{
if (jCreature == JsonNull() || nAmount <= 0)
return jCreature;
// Get the ClassList
json jClasses = GffGetList(jCreature, "ClassList");
if (jClasses == JsonNull() || JsonGetLength(jClasses) == 0)
return jCreature;
// Grab the first class entry
json jFirstClass = JsonArrayGet(jClasses, 0);
// Only touch ClassLevel; do NOT modify Class type
json jCurrentLevel = GffGetShort(jFirstClass, "ClassLevel");
int nCurrentLevel = JsonGetInt(jCurrentLevel);
int nNewLevel = nCurrentLevel + nAmount;
// Replace ClassLevel only
jFirstClass = GffReplaceShort(jFirstClass, "ClassLevel", nNewLevel);
// Put modified class back into the array
jClasses = JsonArraySet(jClasses, 0, jFirstClass);
// Replace ClassList in the creature JSON
jCreature = GffReplaceList(jCreature, "ClassList", jClasses);
return jCreature;
}
//:: Adjusts a creature's size by nSizeChange (-4 to +4) and updates ability scores accordingly.
json json_AdjustCreatureSize(json jCreature, int nSizeDelta)
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Entering function. nSizeDelta=" + IntToString(nSizeDelta));
if (jCreature == JsonNull() || nSizeDelta == 0)
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Exiting: jCreature is null or nSizeDelta is 0");
return jCreature;
}
// Get Appearance_Type using GFF functions
json jAppearanceType = GffGetWord(jCreature, "Appearance_Type");
if (jAppearanceType == JsonNull())
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Failed to get Appearance_Type");
return jCreature;
}
int nAppearance = JsonGetInt(jAppearanceType);
int nCurrentSize = StringToInt(Get2DAString("appearances", "Size", nAppearance));
// Default to Medium (4) if invalid
if (nCurrentSize < 0 || nCurrentSize > 8) nCurrentSize = 4;
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Appearance_Type =" + IntToString(nAppearance) + ", Size =" + IntToString(nCurrentSize));
int nSteps = nSizeDelta;
// Calculate modifiers based on size change
int strMod = nSteps * 4;
int dexMod = nSteps * -1;
int conMod = nSteps * 2;
int naturalAC = nSteps * 1;
int dexSkillMod = nSteps * -2;
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Applying stat modifiers: STR=" + IntToString(strMod) +
" DEX=" + IntToString(dexMod) +
" CON=" + IntToString(conMod));
// Update ability scores using GFF functions with error checking
json jStr = GffGetByte(jCreature, "Str");
if (jStr != JsonNull())
{
int nNewStr = JsonGetInt(jStr) + strMod;
if (nNewStr < 1) nNewStr = 1;
if (nNewStr > 255) nNewStr = 255;
jCreature = GffReplaceByte(jCreature, "Str", nNewStr);
if (jCreature == JsonNull())
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Failed to update Str");
return JsonNull();
}
}
json jDex = GffGetByte(jCreature, "Dex");
if (jDex != JsonNull())
{
int nNewDex = JsonGetInt(jDex) + dexMod;
if (nNewDex < 1) nNewDex = 1;
if (nNewDex > 255) nNewDex = 255;
jCreature = GffReplaceByte(jCreature, "Dex", nNewDex);
if (jCreature == JsonNull())
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Failed to update Dex");
return JsonNull();
}
}
json jCon = GffGetByte(jCreature, "Con");
if (jCon != JsonNull())
{
int nNewCon = JsonGetInt(jCon) + conMod;
if (nNewCon < 1) nNewCon = 1;
if (nNewCon > 255) nNewCon = 255;
jCreature = GffReplaceByte(jCreature, "Con", nNewCon);
if (jCreature == JsonNull())
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Failed to update Con");
return JsonNull();
}
}
// Update Natural AC
json jNaturalAC = GffGetByte(jCreature, "NaturalAC");
if (jNaturalAC != JsonNull())
{
int nCurrentNA = JsonGetInt(jNaturalAC);
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Current NaturalAC: " + IntToString(nCurrentNA));
int nNewNA = nCurrentNA + naturalAC;
if (nNewNA < 0) nNewNA = 0;
if (nNewNA > 255) nNewNA = 255;
jCreature = GffReplaceByte(jCreature, "NaturalAC", nNewNA);
if (jCreature == JsonNull())
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Failed to update NaturalAC");
return JsonNull();
}
}
// Adjust all Dexterity-based skills by finding them in skills.2da
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Adjusting DEX-based skills");
int nSkillID = 0;
while (TRUE)
{
string sKeyAbility = Get2DAString("skills", "KeyAbility", nSkillID);
// Break when we've reached the end of skills
if (sKeyAbility == "")
break;
// If this skill uses Dexterity, adjust it
if (sKeyAbility == "DEX")
{
string sSkillLabel = Get2DAString("skills", "Label", nSkillID);
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Adjusting DEX skill: " + sSkillLabel + " (ID: " + IntToString(nSkillID) + ")");
jCreature = json_AdjustCreatureSkillByID(jCreature, nSkillID, dexSkillMod);
if (jCreature == JsonNull())
{
if(DEBUG) DoDebug("prc_inc_json >> json_AdjustCreatureSize: Failed adjusting skill ID " + IntToString(nSkillID));
return JsonNull();
}
}
nSkillID++;
}
if(DEBUG) DoDebug("json_AdjustCreatureSize completed successfully");
return jCreature;
}
//:: Test void
//:: void main (){}

View File

@@ -16,26 +16,28 @@ const int MATERIAL_TYPE_UNKNOWN = 0;
const int MATERIAL_TYPE_BONE = 1;
const int MATERIAL_TYPE_CERAMIC = 2;
const int MATERIAL_TYPE_CRYSTAL = 3;
const int MATERIAL_TYPE_FABRIC = 4;
const int MATERIAL_TYPE_FIBER = 4;
const int MATERIAL_TYPE_LEATHER = 5;
const int MATERIAL_TYPE_METAL = 6;
const int MATERIAL_TYPE_PAPER = 7;
const int MATERIAL_TYPE_ROPE = 8;
const int MATERIAL_TYPE_STONE = 9;
const int MATERIAL_TYPE_WOOD = 10;
const int MATERIAL_TYPE_BOTANICAL = 11;
const string MATERIAL_TYPE_NAME_INVALID = "";
const string MATERIAL_TYPE_NAME_UNKNOWN = "Unknown";
const string MATERIAL_TYPE_NAME_BONE = "Bone";
const string MATERIAL_TYPE_NAME_CERAMIC = "Ceramic";
const string MATERIAL_TYPE_NAME_CRYSTAL = "Crystal";
const string MATERIAL_TYPE_NAME_FABRIC = "Fabric";
const string MATERIAL_TYPE_NAME_FIBER = "Fiber";
const string MATERIAL_TYPE_NAME_LEATHER = "Leather";
const string MATERIAL_TYPE_NAME_METAL = "Metal";
const string MATERIAL_TYPE_NAME_PAPER = "Paper";
const string MATERIAL_TYPE_NAME_ROPE = "Rope";
const string MATERIAL_TYPE_NAME_STONE = "Stone";
const string MATERIAL_TYPE_NAME_WOOD = "Wood";
const string MATERIAL_TYPE_NAME_BOTANICAL = "Bontanical";
//:: Material Itemproperty Constants
//::////////////////////////////////////////////////////////////////////////////////
@@ -163,7 +165,8 @@ const int IP_MATERIAL_OBSIDIAN = 140;
const int IP_MATERIAL_BAMBOO = 141;
const int IP_MATERIAL_POTTERY = 142;
const int IP_MATERIAL_GLASSTEEL = 143;
const int IP_NUM_MATERIALS = 143;
const int IP_MATERIAL_HERB = 144;
const int IP_NUM_MATERIALS = 144;
const string IP_MATERIAL_NAME_INVALID = "";
const string IP_MATERIAL_NAME_UNKNOWN = "Unknown";
@@ -288,6 +291,7 @@ const string IP_MATERIAL_NAME_OBSIDIAN = "Obsidian";
const string IP_MATERIAL_NAME_BAMBOO = "Bamboo";
const string IP_MATERIAL_NAME_POTTERY = "Pottery";
const string IP_MATERIAL_NAME_GLASSTEEL = "Glassteel";
const string IP_MATERIAL_NAME_HERB = "Herbs";
//::///////////////////////////////////////////////////////////////
// GetMaterialName( int iMaterialType, int bLowerCase = FALSE)
@@ -428,6 +432,7 @@ string GetMaterialName( int iMaterialType, int bLowerCase = FALSE)
case IP_MATERIAL_BAMBOO: sName = IP_MATERIAL_NAME_BAMBOO; break;
case IP_MATERIAL_POTTERY: sName = IP_MATERIAL_NAME_POTTERY; break;
case IP_MATERIAL_GLASSTEEL: sName = IP_MATERIAL_NAME_GLASSTEEL; break;
case IP_MATERIAL_HERB: sName = IP_MATERIAL_NAME_HERB; break;
default: return "";
}
@@ -573,6 +578,7 @@ int GetIPMaterial( string sMaterialName)
else if( sMaterialName == GetStringUpperCase(IP_MATERIAL_NAME_BAMBOO)) return IP_MATERIAL_BAMBOO;
else if( sMaterialName == GetStringUpperCase(IP_MATERIAL_NAME_POTTERY)) return IP_MATERIAL_POTTERY;
else if( sMaterialName == GetStringUpperCase(IP_MATERIAL_NAME_GLASSTEEL)) return IP_MATERIAL_GLASSTEEL;
else if( sMaterialName == GetStringUpperCase(IP_MATERIAL_NAME_HERB)) return IP_MATERIAL_HERB;
return IP_MATERIAL_INVALID;
}
@@ -806,6 +812,9 @@ int GetMaterialType(int nMaterial)
|| nMaterial == IP_MATERIAL_DRAKE_IVORY )
return MATERIAL_TYPE_BONE;
else if ( nMaterial == IP_MATERIAL_HERB )
return MATERIAL_TYPE_BOTANICAL;
else if ( nMaterial == IP_MATERIAL_ELUKIAN_CLAY
|| nMaterial == IP_MATERIAL_POTTERY )
return MATERIAL_TYPE_CERAMIC;
@@ -814,7 +823,7 @@ int GetMaterialType(int nMaterial)
|| nMaterial == IP_MATERIAL_COTTON
|| nMaterial == IP_MATERIAL_SILK
|| nMaterial == IP_MATERIAL_WOOL )
return MATERIAL_TYPE_FABRIC;
return MATERIAL_TYPE_FIBER;
else if ( nMaterial == IP_MATERIAL_GEM
|| nMaterial == IP_MATERIAL_GEM_ALEXANDRITE

View File

@@ -20,6 +20,8 @@
/* Function prototypes */
//////////////////////////////////////////////////
//:: Calculates total Shield AC bonuses from all sources
int GetTotalShieldACBonus(object oCreature);
@@ -379,6 +381,36 @@ const int TYPE_DIVINE = -2;
/* Function definitions */
//////////////////////////////////////////////////
// Returns TRUE if nSpellID is a subradial spell, FALSE otherwise
int GetIsSubradialSpell(int nSpellID)
{
string sMaster = Get2DAString("spells", "Master", nSpellID);
// A subradial will have a numeric master ID here, not ****
if (sMaster != "****")
{
return TRUE;
}
return FALSE;
}
// Returns the masterspell SpellID for a subradial spell.
int GetMasterSpellFromSubradial(int nSpellID)
{
string sMaster = Get2DAString("spells", "Master", nSpellID);
if (sMaster != "****")
{
return StringToInt(sMaster);
}
return -1; // No master
}
int GetPrCAdjustedClassLevel(int nClass, object oCaster = OBJECT_SELF)
{
int iTemp;
@@ -415,7 +447,9 @@ int GetPrCAdjustedCasterLevelByType(int nClassType, object oCaster = OBJECT_SELF
{
int nClassLvl;
int nClass1, nClass2, nClass3, nClass4, nClass5, nClass6, nClass7, nClass8;
int nClass1Lvl, nClass2Lvl, nClass3Lvl, nClass4Lvl, nClass5Lvl, nClass6Lvl, nClass7Lvl, nClass8Lvl;
int nClass1Lvl = 0, nClass2Lvl = 0, nClass3Lvl = 0, nClass4Lvl = 0,
nClass5Lvl = 0, nClass6Lvl = 0, nClass7Lvl = 0, nClass8Lvl = 0;
nClass1 = GetClassByPosition(1, oCaster);
nClass2 = GetClassByPosition(2, oCaster);

View File

@@ -70,6 +70,8 @@
43 PRC_CRAFTING_BASE_ITEMS int 1
44 PRC_XP_USE_SIMPLE_LA int 1
45 PRC_XP_USE_SIMPLE_RACIAL_HD int 1
46 PRC_CREATE_INFUSION_CASTER_LEVEL int 1
47 PRC_CREATE_INFUSION_OPTIONAL_HERBS int 0
*/
/* This variable MUST be updated with every new version of the PRC!!! */
@@ -1952,6 +1954,18 @@ const string PRC_CRAFT_ROD_CASTER_LEVEL = "PRC_CRAFT_ROD_CASTER_LEVE
*/
const string PRC_CRAFT_STAFF_CASTER_LEVEL = "PRC_CRAFT_STAFF_CASTER_LEVEL";
/*
* As above, except it applies to herbal infusions
*/
const string PRC_CREATE_INFUSION_CASTER_LEVEL = "PRC_CREATE_INFUSION_CASTER_LEVEL";
/*
* Builder's Option: Enables the optional PnP herbs for creating infusions.
* Each herb is keyed to a spell circle level & spell school as shown on pg. 33
* of the Master's of the Wild sourcebook.
*/
const string PRC_CREATE_INFUSION_OPTIONAL_HERBS = "PRC_CREATE_INFUSION_OPTIONAL_HERBS";
/*
* Characters with a crafting feat always have the appropriate base item in their inventory
*/
@@ -1976,6 +1990,12 @@ const string PRC_X2_BREWPOTION_COSTMODIFIER = "PRC_X2_BREWPOTION_COSTM
*/
const string PRC_X2_SCRIBESCROLL_COSTMODIFIER = "PRC_X2_SCRIBESCROLL_COSTMODIFIER";
/*
* cost modifier of spells infused into herbs
* defaults to 25
*/
const string PRC_X2_CREATEINFUSION_COSTMODIFIER = "PRC_X2_CREATEINFUSION_COSTMODIFIER";
/*
* Max level of spells crafted into wands
* defaults to 4

View File

@@ -180,6 +180,20 @@ int GetIsTurnOrRebuke(object oTarget, int nTurnType, int nTargetRace)
break;
}
case SPELL_PLANT_DEFIANCE:
{
if(nTargetRace == RACIAL_TYPE_PLANT)
nReturn = ACTION_TURN;
break;
}
case SPELL_PLANT_CONTROL:
{
if(nTargetRace == RACIAL_TYPE_PLANT)
nReturn = ACTION_REBUKE;
break;
}
case SPELL_TURN_PLANT:
{
// Plant domain rebukes or commands plants
@@ -372,6 +386,13 @@ int GetTurningClassLevel(object oCaster = OBJECT_SELF, int nTurnType = SPELL_TUR
if (nTurnType == SPELL_OPPORTUNISTIC_PIETY_TURN)
return GetLevelByClass(CLASS_TYPE_FACTOTUM, oCaster);
if (nTurnType == SPELL_PLANT_DEFIANCE || nTurnType == SPELL_PLANT_CONTROL)
{
int nDivineLvl = GetPrCAdjustedCasterLevelByType(TYPE_DIVINE, oCaster);
return nDivineLvl;
}
//Baelnorn & Archlich adds all class levels.
if(GetLevelByClass(CLASS_TYPE_BAELNORN, oCaster) || GetHasFeat(FEAT_TEMPLATE_ARCHLICH_MARKER, oCaster)) //:: Archlich

View File

@@ -29,6 +29,10 @@ const int BASE_ITEM_CRAFTED_STAFF = 201;
const int BASE_ITEM_ELVEN_LIGHTBLADE = 202;
const int BASE_ITEM_ELVEN_THINBLADE = 203;
const int BASE_ITEM_ELVEN_COURTBLADE = 204;
const int BASE_ITEM_CRAFT_SCEPTER = 249;
const int BASE_ITEM_MAGIC_SCEPTER = 250;
const int BASE_ITEM_MUNDANE_HERB = 252;
const int BASE_ITEM_INFUSED_HERB = 253;
//:://////////////////////////////////////////////
//:: Player Health Const

View File

@@ -782,7 +782,7 @@ int IsClassAllowedToUseLevelUpNUI(int nClass)
return TRUE;
if (nClass == CLASS_TYPE_ARCHIVIST)
return TRUE;
return TRUE;
return FALSE;
}
@@ -1566,10 +1566,6 @@ void FinishLevelUp(int nClass, object oPC=OBJECT_SELF)
int nLevel = GetLevelByClass(nClass, oPC);
SetPersistantLocalInt(oPC, "LastSpellGainLevel", nLevel);
}
if (GetIsBladeMagicClass(nClass))
{
DeletePersistantLocalInt(oPC, "AllowedDisciplines");
}
ClearLevelUpNUICaches(nClass, oPC);
}
@@ -2573,7 +2569,8 @@ int HasPreRequisitesForManeuver(int nClass, int spellbookId, object oPC=OBJECT_S
json chosenDisc = JsonObjectGet(discInfo, discipline);
if (chosenDisc != JsonNull())
{
int nManCount = JsonGetInt(JsonObjectGet(chosenDisc, IntToString(MANEUVER_TYPE_MANEUVER)));
int nManCount = (JsonGetInt(JsonObjectGet(chosenDisc, IntToString(MANEUVER_TYPE_MANEUVER)))
+ JsonGetInt(JsonObjectGet(chosenDisc, IntToString(MANEUVER_TYPE_STANCE))));
if (nManCount >= prereqs)
return TRUE;
}
@@ -3338,5 +3335,3 @@ json GetArchivistNewSpellsList(object oPC=OBJECT_SELF)
SetLocalJson(oPC, NUI_LEVEL_UP_ARCHIVIST_NEW_SPELLS_LIST_VAR, retValue);
return retValue;
}
//:: void main(){}

View File

@@ -1363,7 +1363,12 @@ const int SPELL_SPIRIT_WORM = 17248;
const int SPELL_FORCE_MISSILES = 2480;
//:: Masters of the Wild Spells
const int SPELL_LEONALS_ROAR = 17240;
const int SPELL_FORESTFOLD = 17090;
const int SPELL_CREEPING_COLD = 17091;
const int SPELL_GREATER_CREEPING_COLD = 17092;
const int SPELL_CONTROL_PLANTS = 17237;
const int SPELL_ADRENALINE_SURGE = 17238;
const int SPELL_INVULNERABILITY_TO_ELEMENTS = 17239;
const int SPELL_REGEN_RING = 17241;
const int SPELL_REGEN_CIRCLE = 17242;
const int SPELL_REGEN_LIGHT_WOUNDS = 17243;
@@ -1371,14 +1376,22 @@ const int SPELL_REGEN_MODERATE_WOUNDS = 17244;
const int SPELL_REGEN_SERIOUS_WOUNDS = 17245;
const int SPELL_REGEN_CRITICAL_WOUNDS = 17246;
const int SPELL_SPEED_WIND = 17247;
const int SPELL_TORTISE_SHELL = 17250;
const int SPELL_TORTISE_SHELL = 17250;
//:: Book of Exalted Deeds Spells
const int SPELL_LEONALS_ROAR = 17240;
//:: Master of the Wild Feats
const int SPELL_VL_WILD_SHAPE_TREANT = 17989;
const int SPELL_VL_ANIMATE_TREE = 17990;
const int SPELL_PLANT_DEFIANCE = 17991;
const int SPELL_PLANT_CONTROL = 17992;
//:: Book of Exalted Deeds Feats
const int SPELL_FOT_LEONALS_ROAR = 17993;
const int SPELL_FOT_LIONS_SWIFTNESS = 17994;
const int SPELL_FAVORED_OF_THE_COMPANIONS = 17995;
//x
const int SPELL_TENSERS_FLOATING_DISK = 3849;
const int SPELL_WOLFSKIN = 3850;

View File

@@ -299,6 +299,7 @@ int SpellfireDrainItem(object oPC, object oItem, int bCharged = TRUE, int bSingl
{
if((nBase == BASE_ITEM_POTIONS) ||
(nBase == BASE_ITEM_INFUSED_HERB) ||
(nBase == BASE_ITEM_SCROLL) ||
(nBase == BASE_ITEM_SPELLSCROLL) ||
(nBase == BASE_ITEM_BLANK_POTION) ||
@@ -382,6 +383,7 @@ void SpellfireDrain(object oPC, object oTarget, int bCharged = TRUE, int bExempt
if(GetPRCSwitch(PRC_SPELLFIRE_DISALLOW_DRAIN_SCROLL_POTION) &&
((nBase == BASE_ITEM_POTIONS) ||
(nBase == BASE_ITEM_SCROLL) ||
(nBase == BASE_ITEM_INFUSED_HERB) ||
(nBase == BASE_ITEM_BLANK_POTION) ||
(nBase == BASE_ITEM_BLANK_SCROLL)
)
@@ -525,3 +527,4 @@ void SpellfireCrown(object oPC)
}
}
//:: void main() {}

View File

@@ -13,7 +13,7 @@
//:: Created On: 2003-05-09
//:: Last Updated On: 2003-10-14
//:://////////////////////////////////////////////
#include "prc_x2_itemprop"
struct craft_struct
{
@@ -53,13 +53,15 @@ const int PRC_X2_SCRIBESCROLL_COSTMODIFIER = 25; // Scribe
const int PRC_X2_CRAFTWAND_MAXLEVEL = 4;
const int PRC_X2_CRAFTWAND_COSTMODIFIER = 750;
*/
const int X2_CI_BREWPOTION_FEAT_ID = 944; // Brew Potion feat simulation
const int X2_CI_SCRIBESCROLL_FEAT_ID = 945;
const int X2_CI_CRAFTWAND_FEAT_ID = 946;
const int X2_CI_CRAFTROD_FEAT_ID = 2927;
const int X2_CI_CRAFTROD_EPIC_FEAT_ID = 3490;
const int X2_CI_CRAFTSTAFF_FEAT_ID = 2928;
const int X2_CI_CRAFTSTAFF_EPIC_FEAT_ID = 3491;
const int X2_CI_BREWPOTION_FEAT_ID = 944; // Brew Potion feat simulation
const int X2_CI_SCRIBESCROLL_FEAT_ID = 945;
const int X2_CI_CRAFTWAND_FEAT_ID = 946;
const int X2_CI_CRAFTROD_FEAT_ID = 2927;
const int X2_CI_CRAFTROD_EPIC_FEAT_ID = 3490;
const int X2_CI_CRAFTSTAFF_FEAT_ID = 2928;
const int X2_CI_CRAFTSTAFF_EPIC_FEAT_ID = 3491;
const int X2_CI_CREATEINFUSION_FEAT_ID = 25960;
const string X2_CI_BREWPOTION_NEWITEM_RESREF = "x2_it_pcpotion"; // ResRef for new potion item
const string X2_CI_SCRIBESCROLL_NEWITEM_RESREF = "x2_it_pcscroll"; // ResRef for new scroll item
const string X2_CI_CRAFTWAND_NEWITEM_RESREF = "x2_it_pcwand";
@@ -185,6 +187,17 @@ int CheckAlternativeCrafting(object oPC, int nSpell, struct craft_cost_struct co
// Returns the maximum of caster level used and other effective levels from emulating spells
int GetAlternativeCasterLevel(object oPC, int nLevel);
// -----------------------------------------------------------------------------
// Create and Return an herbal infusion with an item property
// matching nSpellID.
// -----------------------------------------------------------------------------
object CICreateInfusion(object oCreator, int nSpellID);
// -----------------------------------------------------------------------------
// Returns TRUE if the player successfully performed Create Infusion
// -----------------------------------------------------------------------------
int CICraftCheckCreateInfusion(object oSpellTarget, object oCaster, int nID = 0);
//////////////////////////////////////////////////
/* Include section */
//////////////////////////////////////////////////
@@ -194,6 +207,7 @@ int GetAlternativeCasterLevel(object oPC, int nLevel);
#include "prc_inc_newip"
#include "prc_inc_spells"
#include "prc_add_spell_dc"
#include "inc_infusion"
//////////////////////////////////////////////////
/* Function definitions */
@@ -261,7 +275,8 @@ int CIGetIsCraftFeatBaseItem(object oItem)
nBt == BASE_ITEM_BLANK_SCROLL ||
nBt == BASE_ITEM_BLANK_WAND ||
nBt == BASE_ITEM_CRAFTED_ROD ||
nBt == BASE_ITEM_CRAFTED_STAFF)
nBt == BASE_ITEM_CRAFTED_STAFF ||
nBt == BASE_ITEM_MUNDANE_HERB)
return TRUE;
else
return FALSE;
@@ -453,11 +468,158 @@ object CICraftCraftWand(object oCreator, int nSpellID )
// -----------------------------------------------------------------------------
// Georg, 2003-06-12
// Create and Return a magic wand with an item property
// matching nSpellID. Charges are set to d20 + casterlevel
// capped at 50 max
// Create and Return a magic scroll with an item property
// matching nSpellID.
// -----------------------------------------------------------------------------
object CICraftScribeScroll(object oCreator, int nSpellID)
{
if (DEBUG) DoDebug("CICraftScribeScroll: Enter (nSpellID=" + IntToString(nSpellID) + ")");
// Keep original and compute one-step master (if subradial)
int nSpellOriginal = nSpellID;
int nSpellMaster = nSpellOriginal;
if (GetIsSubradialSpell(nSpellOriginal))
{
nSpellMaster = GetMasterSpellFromSubradial(nSpellOriginal);
if (DEBUG) DoDebug("CICraftScribeScroll: subradial detected original=" + IntToString(nSpellOriginal) + " master=" + IntToString(nSpellMaster));
}
// Prefer iprp mapping for the original, fallback to master
int nPropID = IPGetIPConstCastSpellFromSpellID(nSpellOriginal);
int nSpellUsedForIP = nSpellOriginal;
if (nPropID < 0)
{
if (DEBUG) DoDebug("CICraftScribeScroll: no iprp for original " + IntToString(nSpellOriginal) + ", trying master " + IntToString(nSpellMaster));
nPropID = IPGetIPConstCastSpellFromSpellID(nSpellMaster);
nSpellUsedForIP = nSpellMaster;
}
// If neither original nor master has an iprp row, we can still try templates,
// but most templates expect a matching iprp. Bail out now if nothing found.
if (nPropID < 0)
{
if (DEBUG) DoDebug("CICraftScribeScroll: no iprp_spells entry for original/master -> aborting");
FloatingTextStringOnCreature("This spell cannot be scribed (no item property mapping).", oCreator, FALSE);
return OBJECT_INVALID;
}
if (DEBUG) DoDebug("CICraftScribeScroll: using spell " + IntToString(nSpellUsedForIP) + " (iprp row " + IntToString(nPropID) + ") for item property");
// Material component check (based on resolved iprp row)
string sMat = GetMaterialComponentTag(nPropID);
if (sMat != "")
{
object oMat = GetItemPossessedBy(oCreator, sMat);
if (oMat == OBJECT_INVALID)
{
FloatingTextStrRefOnCreature(83374, oCreator); // Missing material component
return OBJECT_INVALID;
}
else
{
DestroyObject(oMat);
}
}
// Resolve class and scroll template
int nClass = PRCGetLastSpellCastClass();
string sClass = "";
switch (nClass)
{
case CLASS_TYPE_WIZARD:
case CLASS_TYPE_SORCERER: sClass = "Wiz_Sorc"; break;
case CLASS_TYPE_CLERIC:
case CLASS_TYPE_UR_PRIEST: sClass = "Cleric"; break;
case CLASS_TYPE_PALADIN: sClass = "Paladin"; break;
case CLASS_TYPE_DRUID:
case CLASS_TYPE_BLIGHTER: sClass = "Druid"; break;
case CLASS_TYPE_RANGER: sClass = "Ranger"; break;
case CLASS_TYPE_BARD: sClass = "Bard"; break;
case CLASS_TYPE_ASSASSIN: sClass = "Assassin"; break;
}
object oTarget = OBJECT_INVALID;
string sResRef = "";
// Try to find a class-specific scroll template.
if (sClass != "")
{
// Try original first (so if you made a subradial-specific template it will be used)
sResRef = Get2DACache(X2_CI_2DA_SCROLLS, sClass, nSpellOriginal);
if (sResRef == "")
{
// fallback to the spell that matched an iprp row (master or original)
sResRef = Get2DACache(X2_CI_2DA_SCROLLS, sClass, nSpellUsedForIP);
}
if (sResRef != "")
{
oTarget = CreateItemOnObject(sResRef, oCreator);
if (DEBUG) DoDebug("CICraftScribeScroll: created template " + sResRef + " for class " + sClass);
// Ensure template uses the correct cast-spell property: replace the template's cast-spell IP with ours
if (oTarget != OBJECT_INVALID)
{
itemproperty ipIter = GetFirstItemProperty(oTarget);
while (GetIsItemPropertyValid(ipIter))
{
if (GetItemPropertyType(ipIter) == ITEM_PROPERTY_CAST_SPELL)
{
RemoveItemProperty(oTarget, ipIter);
break;
}
ipIter = GetNextItemProperty(oTarget);
}
itemproperty ipSpell = ItemPropertyCastSpell(nPropID, IP_CONST_CASTSPELL_NUMUSES_SINGLE_USE);
AddItemProperty(DURATION_TYPE_PERMANENT, ipSpell, oTarget);
}
}
}
// If no template or sClass was empty, create generic scroll and add itemprop.
if (oTarget == OBJECT_INVALID)
{
sResRef = "craft_scroll";
oTarget = CreateItemOnObject(sResRef, oCreator);
if (oTarget == OBJECT_INVALID)
{
WriteTimestampedLogEntry("CICraftScribeScroll: failed to create craft_scroll template.");
return OBJECT_INVALID;
}
// Remove existing default IP and add correct one
itemproperty ipFirst = GetFirstItemProperty(oTarget);
if (GetIsItemPropertyValid(ipFirst))
RemoveItemProperty(oTarget, ipFirst);
itemproperty ipSpell = ItemPropertyCastSpell(nPropID, IP_CONST_CASTSPELL_NUMUSES_SINGLE_USE);
AddItemProperty(DURATION_TYPE_PERMANENT, ipSpell, oTarget);
}
// Add PRC metadata (use the same spell that matched the iprp row so metadata and IP line up)
if (GetPRCSwitch(PRC_SCRIBE_SCROLL_CASTER_LEVEL))
{
int nCasterLevel = GetAlternativeCasterLevel(oCreator, PRCGetCasterLevel(oCreator));
itemproperty ipLevel = ItemPropertyCastSpellCasterLevel(nSpellUsedForIP, nCasterLevel);
AddItemProperty(DURATION_TYPE_PERMANENT, ipLevel, oTarget);
itemproperty ipMeta = ItemPropertyCastSpellMetamagic(nSpellUsedForIP, PRCGetMetaMagicFeat());
AddItemProperty(DURATION_TYPE_PERMANENT, ipMeta, oTarget);
int nDC = PRCGetSpellSaveDC(nSpellUsedForIP, GetSpellSchool(nSpellUsedForIP), OBJECT_SELF);
itemproperty ipDC = ItemPropertyCastSpellDC(nSpellUsedForIP, nDC);
AddItemProperty(DURATION_TYPE_PERMANENT, ipDC, oTarget);
}
if (oTarget == OBJECT_INVALID)
{
WriteTimestampedLogEntry("prc_x2_craft::CICraftScribeScroll failed - Resref: " + sResRef + " Class: " + sClass + "(" + IntToString(nClass) + ") " + " SpellID " + IntToString(nSpellID));
return OBJECT_INVALID;
}
if (DEBUG) DoDebug("CICraftScribeScroll: Success - created scroll " + sResRef + " for spell " + IntToString(nSpellUsedForIP));
return oTarget;
}
/* object CICraftScribeScroll(object oCreator, int nSpellID)
{
int nPropID = IPGetIPConstCastSpellFromSpellID(nSpellID);
object oTarget;
@@ -491,6 +653,7 @@ object CICraftScribeScroll(object oCreator, int nSpellID)
break;
case CLASS_TYPE_CLERIC:
case CLASS_TYPE_UR_PRIEST:
case CLASS_TYPE_OCULAR:
sClass = "Cleric";
break;
case CLASS_TYPE_PALADIN:
@@ -506,6 +669,9 @@ object CICraftScribeScroll(object oCreator, int nSpellID)
case CLASS_TYPE_BARD:
sClass = "Bard";
break;
case CLASS_TYPE_ASSASSIN:
sClass = "Assassin";
break;
}
string sResRef;
if (sClass != "")
@@ -542,7 +708,7 @@ object CICraftScribeScroll(object oCreator, int nSpellID)
}
return oTarget;
}
*/
// -----------------------------------------------------------------------------
// Returns TRUE if the player used the last spell to brew a potion
// -----------------------------------------------------------------------------
@@ -1544,7 +1710,7 @@ int AttuneGem(object oTarget = OBJECT_INVALID, object oCaster = OBJECT_INVALID,
// No point scribing Gems from items, and its not allowed.
if (oItem != OBJECT_INVALID)
{
FloatingTextStringOnCreature("You cannot scribe a Gem from an item.", oCaster, FALSE);
FloatingTextStringOnCreature("You cannot attune a Gem from an item.", oCaster, FALSE);
return TRUE;
}
// oTarget here should be the gem. If it's not, fail.
@@ -1951,7 +2117,13 @@ int CIGetSpellWasUsedForItemCreation(object oSpellTarget)
// -------------------------------------------------
nRet = CICraftCheckCraftStaff(oSpellTarget,oCaster);
break;
case BASE_ITEM_MUNDANE_HERB :
// -------------------------------------------------
// Create Infusion
// -------------------------------------------------
nRet = CICraftCheckCreateInfusion(oSpellTarget,oCaster);
break;
// you could add more crafting basetypes here....
}
@@ -2740,6 +2912,11 @@ int GetMagicalArtisanFeat(int nCraftingFeat)
nReturn = FEAT_MAGICAL_ARTISAN_CRAFT_SKULL_TALISMAN;
break;
}
case FEAT_CREATE_INFUSION:
{
nReturn = FEAT_MAGICAL_ARTISAN_CREATE_INFUSION;
break;
}
default:
{
if(DEBUG) DoDebug("GetMagicalArtisanFeat: invalid crafting feat");
@@ -2941,6 +3118,304 @@ int GetAlternativeCasterLevel(object oPC, int nLevel)
return nLevel;
}
// -----------------------------------------------------------------------------
// Returns TRUE if the player successfully performed Create Infusion
// -----------------------------------------------------------------------------
int CICraftCheckCreateInfusion(object oSpellTarget, object oCaster, int nID = 0)
{
if (nID == 0) nID = PRCGetSpellId();
int bIsSubradial = GetIsSubradialSpell(nID);
if(bIsSubradial)
{
nID = GetMasterSpellFromSubradial(nID);
}
// -------------------------------------------------------------------------
// Check if the caster has the Create Infusion feat
// -------------------------------------------------------------------------
if (!GetHasFeat(FEAT_CREATE_INFUSION, oCaster))
{
FloatingTextStrRefOnCreature(40487, oCaster); // Missing feat
return TRUE;
}
// -------------------------------------------------------------------------
// Divine spellcasters only
// -------------------------------------------------------------------------
int nClass = PRCGetLastSpellCastClass();
if (!GetIsDivineClass(nClass))
{
FloatingTextStringOnCreature("Only divine casters can create infusions.", oCaster, FALSE);
return TRUE;
}
// -------------------------------------------------------------------------
// Check if spell is restricted for Create Infusion
// -------------------------------------------------------------------------
if (CIGetIsSpellRestrictedFromCraftFeat(nID, X2_CI_CREATEINFUSION_FEAT_ID))
{
FloatingTextStrRefOnCreature(83451, oCaster); // Spell not allowed
return TRUE;
}
// -------------------------------------------------------------------------
// Optional PnP Herb check
// -------------------------------------------------------------------------
int bPnPHerbs = GetPRCSwitch(PRC_CREATE_INFUSION_OPTIONAL_HERBS);
if(bPnPHerbs)
{
int nSpellschool = GetSpellSchool(nID);
int nHerbSchool = GetHerbsSpellSchool(oSpellTarget);
int nSpellLevel = PRCGetSpellLevelForClass(nID, nClass);
int nHerbLevel = GetHerbsInfusionSpellLevel(oSpellTarget);
if(nSpellschool != nHerbSchool)
{
// Herb is for wrong spellschool
FloatingTextStringOnCreature("This herb isn't appropriate for this spell school", oCaster);
return TRUE;
}
if(nSpellLevel > nHerbLevel)
{
// Herb spell circle level too low
FloatingTextStringOnCreature("This herb isn't appropriate for this spell level", oCaster);
return TRUE;
}
}
// -------------------------------------------------------------------------
// XP/GP Cost Calculation
// -------------------------------------------------------------------------
int nLevel = CIGetSpellInnateLevel(nID, TRUE);
int nCostModifier = GetPRCSwitch(PRC_X2_CREATEINFUSION_COSTMODIFIER);
if (nCostModifier == 0)
nCostModifier = 25;
int nCost = CIGetCraftGPCost(nLevel, nCostModifier, PRC_CREATE_INFUSION_CASTER_LEVEL);
struct craft_cost_struct costs = GetModifiedCostsFromBase(nCost, oCaster, FEAT_CREATE_INFUSION, FALSE);
// Adjust level for metamagic
if (GetPRCSwitch(PRC_CREATE_INFUSION_CASTER_LEVEL))
{
int nMetaMagic = PRCGetMetaMagicFeat();
switch(nMetaMagic)
{
case METAMAGIC_EMPOWER: nLevel += 2; break;
case METAMAGIC_EXTEND: nLevel += 1; break;
case METAMAGIC_MAXIMIZE: nLevel += 3; break;
// Unsupported metamagic IPs not added
}
}
// -------------------------------------------------------------------------
// Check Gold
// -------------------------------------------------------------------------
if (!GetHasGPToSpend(oCaster, costs.nGoldCost))
{
FloatingTextStrRefOnCreature(3786, oCaster); // Not enough gold
return TRUE;
}
// -------------------------------------------------------------------------
// Check XP
// -------------------------------------------------------------------------
if (!GetHasXPToSpend(oCaster, costs.nXPCost))
{
FloatingTextStrRefOnCreature(3785, oCaster); // Not enough XP
return TRUE;
}
// -------------------------------------------------------------------------
// Check alternative spell emulation requirements
// -------------------------------------------------------------------------
if (!CheckAlternativeCrafting(oCaster, nID, costs))
{
FloatingTextStringOnCreature("*Crafting failed!*", oCaster, FALSE);
return TRUE;
}
// -------------------------------------------------------------------------
// Create the infused herb item
// -------------------------------------------------------------------------
object oInfusion = CICreateInfusion(oCaster, nID);
if (GetIsObjectValid(oInfusion))
{
// Get the spell's display name from spells.2da via TLK
int nNameStrRef = StringToInt(Get2DAString("spells", "Name", nID));
string sSpellName = GetStringByStrRef(nNameStrRef);
// Rename the item
string sNewName = "Infusion of " + sSpellName;
SetName(oInfusion, sNewName);
// Post-creation actions
SetIdentified(oInfusion, TRUE);
ActionPlayAnimation(ANIMATION_FIREFORGET_READ, 1.0);
SpendXP(oCaster, costs.nXPCost);
SpendGP(oCaster, costs.nGoldCost);
DestroyObject(oSpellTarget);
FloatingTextStrRefOnCreature(8502, oCaster); // Item creation successful
if (!costs.nTimeCost) costs.nTimeCost = 1;
AdvanceTimeForPlayer(oCaster, RoundsToSeconds(costs.nTimeCost));
return TRUE;
}
else
{
FloatingTextStringOnCreature("Infusion creation failed", oCaster); // Item creation failed
FloatingTextStrRefOnCreature(76417, oCaster); // Item creation failed
return TRUE;
}
/* // -------------------------------------------------------------------------
// Create the infused herb item
// -------------------------------------------------------------------------
object oInfusion = CICreateInfusion(oCaster, nID);
if (GetIsObjectValid(oInfusion))
{
SetIdentified(oInfusion, TRUE);
ActionPlayAnimation(ANIMATION_FIREFORGET_READ, 1.0);
SpendXP(oCaster, costs.nXPCost);
SpendGP(oCaster, costs.nGoldCost);
DestroyObject(oSpellTarget);
FloatingTextStrRefOnCreature(8502, oCaster); // Item creation successful
if (!costs.nTimeCost) costs.nTimeCost = 1;
AdvanceTimeForPlayer(oCaster, RoundsToSeconds(costs.nTimeCost));
return TRUE;
}
else
{
FloatingTextStringOnCreature("Infusion creation failed", oCaster); // Item creation failed
FloatingTextStrRefOnCreature(76417, oCaster); // Item creation failed
return TRUE;
} */
return FALSE;
}
// -----------------------------------------------------------------------------
// Create and return an herbal infusion with an item property matching nSpellID
// -----------------------------------------------------------------------------
object CICreateInfusion(object oCreator, int nSpellID)
{
if (DEBUG) DoDebug("prc_x2_craft >> CICreateInfusion: Entering function");
// Keep the original spell id the engine gave us (may be a subradial)
int nSpellOriginal = nSpellID;
// Compute the master (one-step) if this is a subradial. Keep original intact.
int nSpellMaster = nSpellOriginal;
if (GetIsSubradialSpell(nSpellOriginal))
{
nSpellMaster = GetMasterSpellFromSubradial(nSpellOriginal);
if (DEBUG) DoDebug("CICreateInfusion: detected subradial " + IntToString(nSpellOriginal) + " master -> " + IntToString(nSpellMaster));
}
// Try to find an iprp_spells row for the original subradial first (preferred).
int nPropID = IPGetIPConstCastSpellFromSpellID(nSpellOriginal);
int nSpellUsedForIP = nSpellOriginal;
// If not found for original, fall back to the master/base spell.
if (nPropID < 0)
{
if (DEBUG) DoDebug("CICreateInfusion: no iprp row for original " + IntToString(nSpellOriginal) + ", trying master " + IntToString(nSpellMaster));
nPropID = IPGetIPConstCastSpellFromSpellID(nSpellMaster);
nSpellUsedForIP = nSpellMaster;
}
// If still invalid, bail out with a helpful message
if (nPropID < 0)
{
if (DEBUG) DoDebug("CICreateInfusion: No iprp_spells entry for either original " + IntToString(nSpellOriginal) + " or master " + IntToString(nSpellMaster));
FloatingTextStringOnCreature("This spell cannot be infused (no item property mapping).", oCreator, FALSE);
return OBJECT_INVALID;
}
if (DEBUG) DoDebug("CICreateInfusion: using spell " + IntToString(nSpellUsedForIP) + " (iprp row " + IntToString(nPropID) + ") for item property");
// Optional: check for material component (use the resolved iprp row)
string sMat = GetMaterialComponentTag(nPropID);
if (sMat != "")
{
object oMat = GetItemPossessedBy(oCreator, sMat);
if (oMat == OBJECT_INVALID)
{
FloatingTextStrRefOnCreature(83374, oCreator); // Missing material component
return OBJECT_INVALID;
}
else
{
DestroyObject(oMat);
}
}
// Only allow divine spellcasters
int nClass = PRCGetLastSpellCastClass();
if (!GetIsDivineClass(nClass))
{
FloatingTextStringOnCreature("Only divine casters can use Create Infusion.", oCreator, FALSE);
return OBJECT_INVALID;
}
// Create base infusion item (herb)
string sResRef = "prc_infusion_000";
object oTarget = CreateItemOnObject(sResRef, oCreator);
if (oTarget == OBJECT_INVALID)
{
WriteTimestampedLogEntry("Create Infusion failed: couldn't create item with resref " + sResRef);
return OBJECT_INVALID;
}
// Confirm that the item is a herb
int nBaseItem = GetBaseItemType(oTarget);
if (nBaseItem != BASE_ITEM_INFUSED_HERB)
{
FloatingTextStringOnCreature("Only herbs may be infused.", oCreator, FALSE);
DestroyObject(oTarget);
return OBJECT_INVALID;
}
// Remove all non-material item properties from the herb
itemproperty ipRemove = GetFirstItemProperty(oTarget);
while (GetIsItemPropertyValid(ipRemove))
{
itemproperty ipNext = GetNextItemProperty(oTarget);
if (GetItemPropertyType(ipRemove) != ITEM_PROPERTY_MATERIAL)
RemoveItemProperty(oTarget, ipRemove);
ipRemove = ipNext;
}
// Add the cast-spell itemproperty using the iprp row we resolved
itemproperty ipSpell = ItemPropertyCastSpell(nPropID, IP_CONST_CASTSPELL_NUMUSES_SINGLE_USE);
AddItemProperty(DURATION_TYPE_PERMANENT, ipSpell, oTarget);
// Optional PRC casting metadata: use the SAME spell id that matched the iprp row
// so caster level/DC/meta line up with the actual cast property on the item.
if (GetPRCSwitch(PRC_CREATE_INFUSION_CASTER_LEVEL))
{
int nCasterLevel = GetAlternativeCasterLevel(oCreator, PRCGetCasterLevel(oCreator));
// nSpellUsedForIP is either original (if that had an iprp row) or the master (fallback)
itemproperty ipLevel = ItemPropertyCastSpellCasterLevel(nSpellUsedForIP, nCasterLevel);
AddItemProperty(DURATION_TYPE_PERMANENT, ipLevel, oTarget);
itemproperty ipMeta = ItemPropertyCastSpellMetamagic(nSpellUsedForIP, PRCGetMetaMagicFeat());
AddItemProperty(DURATION_TYPE_PERMANENT, ipMeta, oTarget);
int nDC = PRCGetSpellSaveDC(nSpellUsedForIP, GetSpellSchool(nSpellUsedForIP), OBJECT_SELF);
itemproperty ipDC = ItemPropertyCastSpellDC(nSpellUsedForIP, nDC);
AddItemProperty(DURATION_TYPE_PERMANENT, ipDC, oTarget);
}
return oTarget;
}
// Test main
//void main(){}
// void main(){}

View File

@@ -768,7 +768,6 @@ int IPGetIsBludgeoningWeapon(object oItem)
// ----------------------------------------------------------------------------
// Return the IP_CONST_CASTSPELL_* ID matching to the SPELL_* constant given
// in nSPELL_ID.
// This uses Get2DAstring, so it is slow. Avoid using in loops!
// returns -1 if there is no matching property for a spell
// ----------------------------------------------------------------------------
int IPGetIPConstCastSpellFromSpellID(int nSpellID)

View File

@@ -144,6 +144,8 @@ int PRCGetUserSpecificSpellScriptFinished();
#include "pnp_shft_main"
#include "inc_dynconv"
#include "inc_npc"
#include "inc_infusion"
#include "prc_add_spell_dc"
int Spontaneity(object oCaster, int nCastingClass, int nSpellID, int nSpellLevel)
@@ -199,8 +201,6 @@ int Spontaneity(object oCaster, int nCastingClass, int nSpellID, int nSpellLevel
return TRUE;
}
int DruidSpontSummon(object oCaster, int nCastingClass, int nSpellID, int nSpellLevel)
{
if(nCastingClass != CLASS_TYPE_DRUID)
@@ -217,14 +217,14 @@ int DruidSpontSummon(object oCaster, int nCastingClass, int nSpellID, int nSpell
{
case 0: return TRUE;
case 1: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_1; break;
case 2: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_2; break;
case 2: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_2; break;
case 3: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_3; break;
case 4: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_4; break;
case 4: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_4; break;
case 5: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_5; break;
case 6: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_6; break;
case 7: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_7; break;
case 6: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_6; break;
case 7: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_7; break;
case 8: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_8; break;
case 9: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_9; break;
case 9: nSummonSpell = SPELL_SUMMON_NATURES_ALLY_9; break;
}
//:: All SNA spells are subradial spells
@@ -1001,7 +1001,8 @@ int ShifterCasting(object oCaster, object oSpellCastItem, int nSpellLevel, int n
{
// Potion drinking is not restricted
if(GetBaseItemType(oSpellCastItem) == BASE_ITEM_ENCHANTED_POTION
|| GetBaseItemType(oSpellCastItem) == BASE_ITEM_POTIONS)
|| GetBaseItemType(oSpellCastItem) == BASE_ITEM_POTIONS
|| GetBaseItemType(oSpellCastItem) == BASE_ITEM_INFUSED_HERB)
return TRUE;
//OnHit properties on equipped items not restricted
@@ -3346,6 +3347,28 @@ int X2PreSpellCastCode2()
X2BreakConcentrationSpells();
//---------------------------------------------------------------------------
// Herbal Infusion Use check
//---------------------------------------------------------------------------
if(nContinue && (GetBaseItemType(oSpellCastItem) == BASE_ITEM_INFUSED_HERB))
{
int bIsSubradial = GetIsSubradialSpell(nSpellID);
if(bIsSubradial)
{
nSpellID = GetMasterSpellFromSubradial(nSpellID);
}
int nItemCL = GetCastSpellCasterLevelFromItem(oSpellCastItem, nSpellID);
if(DEBUG) DoDebug("x2_inc_spellhook >> X2PreSpellCastCode2: Item Spellcaster Level: "+IntToString(nItemCL)+".");
if(DEBUG) DoDebug("x2_inc_spellhook >> X2PreSpellCastCode2: Herbal Infusion Found");
if(!DoInfusionUseChecks(oCaster, oSpellCastItem, nSpellID))
{
ApplyInfusionPoison(oCaster, nItemCL);
nContinue = FALSE;
}
}
//---------------------------------------------------------------------------
// No casting while using expertise
//---------------------------------------------------------------------------
if(nContinue)