Author Topic: Scaling Mummy Dust & Dragon Knight  (Read 1951 times)

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #15 on: April 29, 2015, 01:49:03 am »


               

You still trying to figure out the PM caster level bit?



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #16 on: April 29, 2015, 09:36:19 am »


               

The thing I never liked about the EffectSummon command, is that it breaks out of an object centric approach.


CreateObject gives you an object to play with - you can apply effects and modify ability / skills with more nwscript.


 


EffectSummon doesnt return an object that you can directly interact with from within the same script.


(Might be possible through GetAssociate)


 


If it is a case of scaling the creature with your level, you could potentially just increase its ability scores, feats, and skills etc, with nwnx_funcs - if you have access to it.


Of course getting an object reference to the creature summoned by Mummy Dust might be the challenge.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #17 on: April 29, 2015, 02:58:21 pm »


               

Fwiw, I make a call to a routine right after applying the summon effect that uses a GetAssociate(ASSOCIATE_TYPE_SUMMONED, oCaster, nNth) loop. When it finds the one that has not been marked it marks it at returns that object.  Then I can augment the summon as needed. Works nicely.  I allow multiple summons so the marking part is needed. If you don't allow multiples you should be able to just do the single GetAssociate call.


 


EffectSummon returns an effect, just like all the other effect constructors. It would be really broken if it returned an object '<img'>


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #18 on: April 29, 2015, 02:59:11 pm »


               

EffectSummon doesnt return an object that you can directly interact with from within the same script.

(Might be possible through GetAssociate)




 


Interestingly, the GetMaster() does not work the same way.  A summon does not have a master until after the OnSpawn



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #19 on: April 29, 2015, 03:43:57 pm »


               

Its possible to add this functionality through nwnx however.


In order to fix animal companions and familiars for levels 41+ the summoning code basically had to be rewrote to not fail when trying to get level 41+ resrefs.


(Yes - I know this was done in the Unofficial Community Patch, I generally like to code things myself, so I know how they work)


 


By rewriting the code, there are key areas where hooks could be added, in order to return or override the resref used by the summoning script.


Also possible to return the creature being summoned in a hook: and then enhance that creature prior to its onspawn script firing.



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #20 on: May 02, 2015, 05:17:11 pm »


               


You still trying to figure out the PM caster level bit?




 


 


Yes actually. My mod already allows half of a Palemaster's levels to add to casting level. I don't know how to make that be taken into account for the mummy dust/dragon knight script since they don't use a standard get caster level thing. I also wanted to have a version that counted ALL of palemaster's levels (added to their base casting class levels) as part of his casting level for the mummy dust spell specifically, while using half their palemaster levels (added to their base casting class levels) for Dragon Knight.


 


The technical aspects of that scripting is just out of my league to come up with on my own. I didn't press that specific scripting cause I've been asking for scripting help a great deal recently and I don't want to abuse people's good graces too much.



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #21 on: May 04, 2015, 08:51:36 am »


               

How are you determining base casting class levels (in a general sense)?  For example, say I have a 21 Cleric/3 Wizard/16 Pale Master who knows Mummy Dust.  Should my caster level be...


 


A. 21 (cleric levels)


B. 37 (cleric levels plus pale master levels)


C. 19 (wizard levels plus pale master levels because pale master levels trump cleric levels for an undead spell)


D. something else entirely



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #22 on: May 04, 2015, 05:09:01 pm »


               

Just so the OP knows the behavior of GetCasterLevel() in feats, the caster level would be the class level (in feats this is unaffected by level drain) of the class that took the feat while leveling up.  So a Fighter 8/Bard 4/Palemaster 28 would have a caster level of 28 when casting epic spells, as palemaster would be the only class that would be able to select one.  Epic spells can only be selected by a class if that class has reached a certain level (for clerics, druids, wizards, and sorcerers this is 21, for palemaster this is 15).  Qualifying by one class does not mean that another class is qualified.



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #23 on: May 04, 2015, 09:19:38 pm »


               


How are you determining base casting class levels (in a general sense)?  For example, say I have a 21 Cleric/3 Wizard/16 Pale Master who knows Mummy Dust.  Should my caster level be...


 


A. 21 (cleric levels)


B. 37 (cleric levels plus pale master levels)


C. 19 (wizard levels plus pale master levels because pale master levels trump cleric levels for an undead spell)


D. something else entirely




 


The caster levels for the palemaster are a total of the arcane casting class and half the palemaster levels. So in your example your casting level would be 11 with arcane spells (this is assuming only half of the palemaster levels counting) and 21 with divine spells. The palemaster levels don't benefit divine casting level. For your example the mummy dust spell would use the cleric levels for its casting level because its higher than the arcane level. So because of the low casting level (21) that character would summon the weakest of the mummy dust summons.


 


It's all tied to the class of spells being cast. If you were say sorc3/wiz7/pale30 your casting level with wizard spells would be 22 but with sorc spells it would be 18... at leas that's how I THINK it works. I'm not exactly the poster child for the comprehension of scripting here.



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #24 on: May 06, 2015, 03:50:04 am »


               


The caster levels for the palemaster are a total of the arcane casting class and half the palemaster levels.




 


Huh?  You said you wanted Mummy Dust to use all of the Pale Master levels...was that a typo?


 


Assuming it wasn't, you should be able to change this section



int iClassCount = 0; //just making sure that the variable is zero probably unnecessary
        int iIndex;
        int nDruid = GetLevelByClass(CLASS_TYPE_DRUID);
        int nWizard = GetLevelByClass(CLASS_TYPE_WIZARD);
        int nSorcerer = GetLevelByClass(CLASS_TYPE_SORCERER);
        int nCleric = GetLevelByClass(CLASS_TYPE_CLERIC);

to



int iClassCount = 0; //just making sure that the variable is zero probably unnecessary
        int iIndex;
        int nDruid = GetLevelByClass(CLASS_TYPE_DRUID);
        int nWizard = GetLevelByClass(CLASS_TYPE_WIZARD) + GetLevelByClass(CLASS_TYPE_PALEMASTER);
        int nSorcerer = GetLevelByClass(CLASS_TYPE_SORCERER) + GetLevelByClass(CLASS_TYPE_PALEMASTER);
        int nCleric = GetLevelByClass(CLASS_TYPE_CLERIC);

Part of my concern here is that spells overlap.  If you simply have the script find the highest caster level when you cast Bull's Strength, for example...then it'll assume Bull's Strength was cast as a level 21 Cleric rather than as a level 11 Wizard/Pale Master due to the fact that both spellbooks have Bull's Strength.  See the issue?


 


This isn't a problem for Epic Spells (since they're not class specific) or spells specific to that class (or, more specifically, unique to that "half" or "third" of the character)...but it definitely can be an issue if all you do is check the highest class level.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #25 on: May 06, 2015, 06:01:15 am »


               

void main()
{
int nClass = GetLastSpellCastClass();
int nCasterLevel = GetLevelByClass(nClass);
object oItem = GetSpellCastItem();
switch (nClass)
 {
 case CLASS_TYPE_WIZARD:
 case CLASS_TYPE_SORCERER:
 case CLASS_TYPE_BARD:
   nCasterLevel += GetLevelByClass(CLASS_TYPE_PALEMASTER);
   break;
 case CLASS_TYPE_PALEMASTER:
   if(GetLevelByClass(CLASS_TYPE_WIZARD) > GetLevelByClass(CLASS_TYPE_SORCERER))
     nCasterLevel += GetLevelByClass(CLASS_TYPE_WIZARD);
   else
     nCasterLevel += GetLevelByClass(CLASS_TYPE_SORCERER);
   break;
 }
if(GetIsObjectValid(oItem))
  nCasterLevel = GetCasterLevel(OBJECT_SELF);
}

               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #26 on: May 07, 2015, 07:18:25 am »


               

What WhiZard did is a much better way to do it (stating the obvious, really).



               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #27 on: May 07, 2015, 02:22:25 pm »


               

I'm not sure how to incorporate Whizard's second post into my mummy dust script. His first post I was able to do but that most recent one varies greatly from what I have and I am unsure how to use it.


 


Here's the script currently:



#include "prc_alterations"
#include "x2_inc_spellhook"
#include "inc_epicspells"

string GetDruidCreature(int iCreature)

// determines which creature a druid will summon

{
    string sCreatureName;
    switch(iCreature)
    {
        case 0:
               sCreatureName = "s_treant_001";
               break;
        case 1:
               sCreatureName = "s_treant_002";
               break;
        case 2:
               sCreatureName = "s_treant_003";
               break;
        case 3:
               sCreatureName = "s_treant_004";
               break;
        default:
               sCreatureName = "s_treant_005";
               break;
    }
    return sCreatureName;
}

string GetNonDruidCreature(int iCreature)

// determines which creature a non-druid will summon

{
    string sCreatureName;
    switch(iCreature)
    {
        case 0:
               sCreatureName = "s_morglord_001";
               break;
        case 1:
               sCreatureName = "s_morglord_002";
               break;
        case 2:
               sCreatureName = "s_morglord_003";
               break;
        case 3:
               sCreatureName = "s_morglord_004";
               break;
        default:
               sCreatureName = "s_morglord_005";
               break;
    }
    return sCreatureName;
}

void main()
{
DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR");
SetLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_NECROMANCY);

    /*
      Spellcast Hook Code
      Added 2003-06-20 by Georg
      If you want to make changes to all spells,
      check x2_inc_spellhook.nss to find out more

    */

        if (!X2PreSpellCastCode())
        {
        // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
            return;
        }

    if (GetCanCastSpell(OBJECT_SELF, MUMDUST_DC, MUMDUST_S, MUMDUST_XP))
    {
        //Declare major variables

        int nDuration = 24;

        //effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);

        effect eSummon;

        //NC:EDIT
        // Add check for druid for different summon
        //KA: EDIT
        // Add summon scaling every five levels and allowed ALL Palemaster levels
        // to be counted towards caster level for the spell.

        int iClassCount = 0; //just making sure that the variable is zero probably unnecessary
        int iIndex;
        int nDruid = GetLevelByClass(CLASS_TYPE_DRUID);
        int nWizard = GetLevelByClass(CLASS_TYPE_WIZARD) + GetLevelByClass(CLASS_TYPE_PALEMASTER);
        int nSorcerer = GetLevelByClass(CLASS_TYPE_SORCERER) + GetLevelByClass(CLASS_TYPE_PALEMASTER);
        int nCleric = GetLevelByClass(CLASS_TYPE_CLERIC);

// This section of code counts the number of classes the PC has that qualify to be able to cast the spell
// Because I am lazy I also made it so that iIndex is configured for the switch statements

        if(nDruid >= 20)
        {
            iClassCount++;
            iIndex = (nDruid - 20) / 5;
        }
        if(nWizard >= 20)
        {
            iClassCount++;
            iIndex = (nWizard - 20) / 5;
        }
        if(nSorcerer >= 20)
        {
            iClassCount++;
            iIndex = (nSorcerer - 20) / 5;
        }
        if(nCleric >= 20)
        {
            iClassCount++;
            iIndex = (nCleric - 20) / 5;
        }

//The next 2 lines make sure that the PC has 1 and only 1 qualifying class

        if(iClassCount != 1)
            return;

        string sSummon;

//if PC is a druid get druidic creature name otherwise get other name

        if(nDruid>=20)
            sSummon = GetDruidCreature(iIndex);
        else
            sSummon = GetNonDruidCreature(iIndex);

        //NC:EDIT

        //Summon the appropriate creature based on the summoner level
        //Warrior Mummy
        //NC:EDIT
        //Treant Druid only

        eSummon = EffectSummonCreature(sSummon,496,1.0f);

        //NC:EDIT

        eSummon = ExtraordinaryEffect(eSummon);

        //Apply the summon visual and summon the undead.
        //ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetSpellTargetLocation());

        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(nDuration));
    }
    DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR");
// Getting rid of the local integer storing the spellschool name
}

               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #28 on: May 09, 2015, 04:09:38 am »


               

#include "prc_alterations"
#include "x2_inc_spellhook"
#include "inc_epicspells"
 
void main()
{
DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR");
SetLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_NECROMANCY);

    /*
      Spellcast Hook Code
      Added 2003-06-20 by Georg
      If you want to make changes to all spells,
      check x2_inc_spellhook.nss to find out more

    */

        if (!X2PreSpellCastCode())
        {
        // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
            return;
        }

    if (GetCanCastSpell(OBJECT_SELF, MUMDUST_DC, MUMDUST_S, MUMDUST_XP))
    {
        //Declare major variables

        int nDuration = 24;

        //effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);

        effect eSummon;

        //NC:EDIT
        // Add check for druid for different summon
        //KA: EDIT
        // Add summon scaling every five levels and allowed ALL Palemaster levels
        // to be counted towards caster level for the spell.
        int nClass = GetLastSpellCastClass();
        int nCasterLevel = GetLevelByClass(nClass);
        object oItem = GetSpellCastItem();
        string sSummon = "s_morglord_005";
        switch (nClass)
          {
          case CLASS_TYPE_WIZARD:
          case CLASS_TYPE_SORCERER:
          case CLASS_TYPE_BARD:
             nCasterLevel += GetLevelByClass(CLASS_TYPE_PALEMASTER);
             break;         
          case CLASS_TYPE_PALEMASTER:
            if(GetLevelByClass(CLASS_TYPE_WIZARD) > GetLevelByClass(CLASS_TYPE_SORCERER))
                nCasterLevel += GetLevelByClass(CLASS_TYPE_WIZARD);
            else
                nCasterLevel += GetLevelByClass(CLASS_TYPE_SORCERER);
            break;
          }
        if(GetIsObjectValid(oItem))
          {
          nCasterLevel = GetCasterLevel(OBJECT_SELF);
          nClass = CLASS_TYPE_INVALID;
          }
       int iEpicIndex = (nCasterLevel - 15)/5;
       if(iEpicIndex > 4)
           iEpicIndex = 4;
       switch(nClass)
          {
          case CLASS_TYPE_WIZARD:
          case CLASS_TYPE_SORCERER:
          case CLASS_TYPE_CLERIC:
          case CLASS_TYPE_PALEMASTER:
             if(nCasterLevel >= 20)
                 sSummon = "s_morglord_00" + IntToString(iEpicIndex);
             break;
          case CLASS_TYPE_DRUID:
             if(nCasterLevel >= 20)
                 sSummon = "s_treant_00" + IntToString(iEpicIndex);
             else
                 sSummon = "s_treant_005";
             break;
           }
          
        //NC:EDIT

        //Summon the appropriate creature based on the summoner level
        //Warrior Mummy
        //NC:EDIT
        //Treant Druid only

        eSummon = EffectSummonCreature(sSummon,496,1.0f);

        //NC:EDIT

        eSummon = ExtraordinaryEffect(eSummon);

        //Apply the summon visual and summon the undead.
        //ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetSpellTargetLocation());

        ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eSummon, GetSpellTargetLocation(), HoursToSeconds(nDuration));
    }
    DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR");
// Getting rid of the local integer storing the spellschool name
}


               
               

               
            

Legacy_Nic Mercy

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
Scaling Mummy Dust & Dragon Knight
« Reply #29 on: May 09, 2015, 06:03:20 pm »


               

I get this error when I try to compile the above script:


 


Error: NSC1007: Required argument "oCreature" missing in call to "GetCasterLevel"

Compilation aborted with errors.