Author Topic: Need Function for Specialist Casters  (Read 394 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need Function for Specialist Casters
« on: April 27, 2012, 05:18:09 pm »


               I want to integrate a special Bonus Damage function into all spells, as I'm revising my 2nd edtion of my Custom Spell System to be much more dynamic....

Part of that will include checking to see if the Wizard / Sorcerer is a Specialist, e.g. A Necromancer, etc....

I need a function that can return if they are a specialist and which specialist they are... anyone?
               
               

               


                     Modifié par _Guile, 27 avril 2012 - 04:18 .
                     
                  


            

Legacy_Alex Warren

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +0/-0
Need Function for Specialist Casters
« Reply #1 on: April 27, 2012, 06:34:44 pm »


               This is only possible with NWNX.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need Function for Specialist Casters
« Reply #2 on: April 28, 2012, 01:22:38 am »


               Till NWNX came I have successfuly used this trick to find out if the wizard is necromancer:

void CheckAbleDivination_continue(object oCopy)
{
talent t = GetCreatureTalentRandom(9,oCopy);
 if(!GetIsTalentValid(t))
 {
 //PC cannot cast use true strike scroll thus must be necromancy spell school specialist
 //do something
 }
DestroyObject(oCopy);
}

void CheckAbleDivination(object oPC)
{
object oCopy = CopyObject(oPC,GetStartingLocation());
ForceRest(oCopy);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,SupernaturalEffect(EffectLinkEffects(EffectAbilityDecrease(ABILITY_INTELLIGENCE,10),EffectSpellFailure())),oCopy);
SetXP(oCopy,0);
int n;
object item;
 for(;n < NUM_INVENTORY_SLOTS;n++)
 {
 item = GetItemInSlot(n,oCopy);
  if(item != OBJECT_INVALID)  DestroyObject(item);
 }
item = GetFirstItemInInventory(oCopy);
 while(item != OBJECT_INVALID)
 {
 DestroyObject(item);
 item=GetNextItemInInventory(oCopy);
 }
CreateItemOnObject("x1_it_sparscr104",oCopy);
DelayCommand(0.1,CheckAbleDivination_continue(oCopy));
}


But since MaxRock released nwnx plugin that can read this information from bic file I abadoned this solution. Still might be for some use for single player modules.

This solution works perfectly for necromancy spell school and will work also for illusions and conjuration but its unreliable for others spell school unless they are changed via 2DA so none of two has same opposite school.'B)'

edit: i havent bothered with !sanity checks" as I used it only for wizards, so spare breath and dont tell me it wont work for non-wizards ':kissing:'
               
               

               


                     Modifié par ShaDoOoW, 28 avril 2012 - 12:24 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need Function for Specialist Casters
« Reply #3 on: April 28, 2012, 02:42:48 pm »


               OK guys, thanks...

Looks like I'll just stick with the current configuration include I made, any suggestions on it?

This will be released to the public so that we can have a solid & good adjustable spell system...
(All Spells hook into multiple configurations scripts to give the builder greater control over spells)

/////////////////////

// gen_sbd_config (Spells Bonus Damage Configuration Include Script)
////////////////////////////////////////////////////////////////////////////////
// Created By Genisys / Guile
// Created On 4/28/2012
////////////////////////////////////////////////////////////////////////////////
// SETTINGS....

//Set this to TRUE if you want to use Additional Damage Bonuses
const int USE_SPELL_DAMAGE_BONUSES = TRUE; // Default = FALSE; (NO Dmg Bonuses)

//Set this to FALSE if you DO NOT want to use Bonus Durations & Damage
//based upon if the Caster has Spell Focus Feat(s)...
// + 10% Dmg Bonus / Spell Focus Feat
// e.g. +30 % Dmg Bonus if Caster has the Epic Spell Focus Feat (For that spell!)
const int USE_SPELL_FOCUS_BONUS = TRUE; //Default = TRUE (Use Focus Bonus)

// Calculate Damage Bonuses...

// Set this to the damage bonus given / X Levels of the caster...
// e.g. if set to 1, then + 1 Damage / 1 Caster Levels...
// e.g. if set to 2, then + 1 Damage / 2 Caster Levels...
// ### WARNING ###   DO NOT SET THIS TO 0!!!!!
const int SPELL_DMG_BONUS_LVL = 2; //Default = 2; (+1 dmg / 2 Levels)


// Set the following settings to the Bonus Given Based Upon The SPELL LEVEL
// This is set to +1 Dmg / X Caster Levels By Default
// The Above Setting controls the X Caster Levels, this controls how much
// damage is given based upon the Level of The Spell (For Finer Control!)

// NOTE: If Bonus Damage is NOT used, then this will never be calculated..

const int SPELL_LVL_0_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_1_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_2_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_3_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_4_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_5_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_6_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_7_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_8_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels
const int SPELL_LVL_9_BONUS_DMG = 1; // + 1 Dmg / X Caster Levels

//The Math is really simple on this....
//First divide Caster Level by SPELL_DMG_BONUS_LVL
//Then Multiply that by SPELL_LVL_X_BONUS_DMG

////////////////////////////////////////////////////////////////////////////////
// END SETTINGS...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//###############################################
// WARNING DO NOT TOUCH ANYTHING BELOW THIS LINE
//###############################################
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// Define PROTOTYPE

// This function will check to see if the caster has the Spell Focus Feat(s)
// if so, then it will return the bonus for Durations & Damage!
// Durations are only slightly extended by +1 / 2 / 3 / 4 rounds/turns etc..

int GetFocusBonus(object oCaster, int nSchool)
{
  //Determine which Spell Focus level the Caster Has
  int nESF, nGSF, nSF;
  //See which feats they have...
  switch(nSchool)
  {
   case IP_CONST_SPELLSCHOOL_ABJURATION: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_ABJURATION, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ABJURATION, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_ABJURATION, oCaster);   } break;

   case IP_CONST_SPELLSCHOOL_CONJURATION: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_CONJURATION, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_CONJURATION, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_CONJURATION, oCaster);   } break;

   case IP_CONST_SPELLSCHOOL_DIVINATION: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_DIVINATION, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_DIVINATION, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_DIVINATION, oCaster);   } break;

   case IP_CONST_SPELLSCHOOL_ENCHANTMENT: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_ENCHANTMENT, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ENCHANTMENT, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_ENCHANTMENT, oCaster);   } break;

   case IP_CONST_SPELLSCHOOL_EVOCATION: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_EVOCATION, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_EVOCATION, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_EVOCATION, oCaster);   } break;

   case IP_CONST_SPELLSCHOOL_ILLUSION: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_ILLUSION, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_ILLUSION, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_ILLUSION, oCaster);   } break;

   case IP_CONST_SPELLSCHOOL_NECROMANCY: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_NECROMANCY, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_NECROMANCY, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_NECROMANCY, oCaster);   } break;

   case IP_CONST_SPELLSCHOOL_TRANSMUTATION: {
   nESF = GetHasFeat(FEAT_EPIC_SPELL_FOCUS_TRANSMUTATION, oCaster);
   nGSF = GetHasFeat(FEAT_GREATER_SPELL_FOCUS_TRANSMUTATION, oCaster);
   nSF = GetHasFeat(FEAT_SPELL_FOCUS_TRANSMUTATION, oCaster);   } break;
  }

  //Calculate Power Based upon Feats...
  int nFeatLevel = 1; //By Default NO Bonus Damage or Duration!
  if(nESF)
  { nFeatLevel = 4; }   // +30 % Base Bonus Damage
  else if(nGSF)
  { nFeatLevel = 3; }   // +20 % Base Bonus Damage
  else if(nSF)
  { nFeatLevel = 2; }   // +10 % Base Bonus Damage

  if(USE_SPELL_FOCUS_BONUS)
  return nFeatLevel;
  else
  return 1; // No Bonus...( X1 or +0)
}

////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// Define PROTOTYPE

// This Function simply calculates the bonus damage for Spell Focus Feat(s)

int GetFocusDamage(int iDam, int nSFBonus)
{
 int iFinal = 0;
 float fSF = IntToFloat(nSFBonus);
 float fDam = IntToFloat(iDam);

 switch(nSFBonus)
 {
  case 1: { fSF = 0.0; }break;
  case 2: { fSF = 0.1; } break;
  case 3: { fSF = 0.2; } break;
  case 4: { fSF = 0.3; } break;
 }
 if(nSFBonus == 1) { return iDam; } //Stop Here... (No Bonus!)

 float fAdj = fSF * fDam; // + 10 - 30% dmg (IF caster has Spell Focus Feat(s)
 iFinal = iDam + FloatToInt(fAdj); //Add the bonus damage!

 return iFinal;
}

////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// Define PROTOTYPE

// NOTE: This function will add damage to ALL Spells, as it's added to
// the base damage that spells do normally.

int GetBonusDamage(object oCaster, int nSpellLevel, int nSchool, int CLvl)
{

 //Only run this if it is set to use this (see setting above)
 if(USE_SPELL_DAMAGE_BONUSES == FALSE)
 { return 0; } // There is not bonus, return 0 (no damage bonus).. STOP HERE..

  int iDam = 0;
  int nSFBonus = GetFocusBonus(oCaster, nSchool);

  //Calculate Bonus Damage Based Upon Constants Above!
  int iLvl = CLvl / SPELL_DMG_BONUS_LVL; // X Levels

  //---------------------------------------------------------------
  //Control Spells By LEVEL and NOT by which school it is!!
  switch(nSpellLevel)
  {
   case 0:{ iDam = SPELL_LVL_0_BONUS_DMG * iLvl; } break;
   case 1:{ iDam = SPELL_LVL_1_BONUS_DMG * iLvl; } break;
   case 2:{ iDam = SPELL_LVL_2_BONUS_DMG * iLvl; } break;
   case 3:{ iDam = SPELL_LVL_3_BONUS_DMG * iLvl; } break;
   case 4:{ iDam = SPELL_LVL_4_BONUS_DMG * iLvl; } break;
   case 5:{ iDam = SPELL_LVL_5_BONUS_DMG * iLvl; } break;
   case 6:{ iDam = SPELL_LVL_6_BONUS_DMG * iLvl; } break;
   case 7:{ iDam = SPELL_LVL_7_BONUS_DMG * iLvl; } break;
   case 8:{ iDam = SPELL_LVL_8_BONUS_DMG * iLvl; } break;
   case 9:{ iDam = SPELL_LVL_9_BONUS_DMG * iLvl; } break;
  }

 //---------------------------------------------------------------

 //If we are using the Spell Focus Bonus...
 if(USE_SPELL_FOCUS_BONUS)
 {
  // Calculate Spell Focus Bonus + Original Bonus (iDam)..
  iDam = GetFocusDamage(iDam, nSFBonus);
 }

 return iDam;

//End Prototype
}

////////////////////////////////////////////////////////////////////////////////
// END INCLUDE
////////////////////////////////////////////////////////////////////////////////
               
               

               


                     Modifié par _Guile, 28 avril 2012 - 03:31 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need Function for Specialist Casters
« Reply #4 on: April 28, 2012, 04:46:23 pm »


               The thing that becomes redundant is looking up the spell school for each spell, so that I can code bonus damage....  I didn't want to use a 2da String Look Up Function, because it would slow the spell system down...  I wanted the spell system to be completely optimized, then put it in two forms, standard ERF (overwrite all spells) & a Hak File (w/ configuration includes in the ERF for importing & configuring)...