Aller au contenu

Photo

Scaling Mummy Dust & Dragon Knight


  • Veuillez vous connecter pour répondre
35 réponses à ce sujet

#26
WhiZard

WhiZard
  • Members
  • 1 204 messages
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);
}


#27
MagicalMaster

MagicalMaster
  • Members
  • 2 000 messages

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



#28
Nic Mercy

Nic Mercy
  • Members
  • 181 messages

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
}


#29
WhiZard

WhiZard
  • Members
  • 1 204 messages
#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
}


#30
Nic Mercy

Nic Mercy
  • Members
  • 181 messages

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.



#31
WhiZard

WhiZard
  • Members
  • 1 204 messages

Yeah, edited above to be GetCasterLevel(OBJECT_SELF);



#32
Nic Mercy

Nic Mercy
  • Members
  • 181 messages

Yeah, edited above to be GetCasterLevel(OBJECT_SELF);

 

 

Works perfectly for the palemaster levels ty so much! Only issue is the Druid aspect doesn't seem to be working. Casting mummy dust as a druid should spawn the treant but is spawning the mummy instead.



#33
WhiZard

WhiZard
  • Members
  • 1 204 messages

Add a debugging line to the end of the script to help ascertain the problem.

 

Something like this

 

SendMessageToPC(OBJECT_SELF, "Class: " + IntToString(nClass));
SendMessageToPC(OBJECT_SELF, "Caster Level: " + IntToString(nCasterLevel));


#34
Nic Mercy

Nic Mercy
  • Members
  • 181 messages

The debugging results are:

 

Class: 255

Caster level: 0

 

Upon further testing with lower level spellcasters it seems the same results are occuring. They get the highest level summon and its always the mummy regardless of class or level.

 

I've reverted to my old script using your initial suggestion to count the palemaster levels and it works perfectly. I also was able to use what I saw in your script to make my Dragon Knight spell add half of the palemaster levels as well! So at least I have them functional if not elegant.



#35
WhiZard

WhiZard
  • Members
  • 1 204 messages

The debugging results are:

 

Class: 255

Caster level: 0

 

Upon further testing with lower level spellcasters it seems the same results are occuring. They get the highest level summon and its always the mummy regardless of class or level.

 

I've reverted to my old script using your initial suggestion to count the palemaster levels and it works perfectly. I also was able to use what I saw in your script to make my Dragon Knight spell add half of the palemaster levels as well! So at least I have them functional if not elegant.

 

This suggests that your epic spells are being cast through items.  Nothing wrong with that, you just need to delete the item cast lines I provided.

if(GetIsObjectValid(oItem))
          {
          nCasterLevel = GetCasterLevel(OBJECT_SELF);
          nClass = CLASS_TYPE_INVALID;
          }

Also if 005 is your highest summon, and not a default for being cast from an unknown source then I would suggest the following revision

#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_001";
        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;
          }
       int iEpicIndex = (nCasterLevel - 15)/5;
       if(iEpicIndex > 5)
           iEpicIndex = 5;
       if(iEpicIndex < 1)
           iEpicIndex =1;
       switch(nClass)
          {
          case CLASS_TYPE_WIZARD:
          case CLASS_TYPE_SORCERER:
          case CLASS_TYPE_CLERIC:
          case CLASS_TYPE_PALEMASTER:
             sSummon = "s_morglord_00" + IntToString(iEpicIndex);
             break;
          case CLASS_TYPE_DRUID:
             sSummon = "s_treant_00" + IntToString(iEpicIndex);
             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
}


#36
Nic Mercy

Nic Mercy
  • Members
  • 181 messages

Ah because I am using the same custom epic spell system that the prc uses, epic spells are learned outside of choosing feats in the standard nwn. In this system the spells are learned through research (much closer to pnp style) and are dynamically assigned or removed from the epic spell menu (by virtue of a pc skin) so I guess technically speaking the spells are cast via an item (via a feat dynamically applied to the pc skin).