Author Topic: Looking for help with creating levelbased summons  (Read 450 times)

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Looking for help with creating levelbased summons
« on: October 13, 2010, 01:51:22 pm »


               Hi all,

I am editing a custom summons scripts, whichs summons based on subrace,  but I would like to alter it to not only summon based on subrace, but also based on casterlevel (Not characterlevel, only casterlevel).

I am not sure how to work with all the "else if"s statements, could anyone perhaps throw a glance at this and show me how to do it?
I would like the spells to change like this:


Summon Spell VI: changes at casterlevel: 24, 27, 30, 33
Summon Spell VII: changes at casterlevel:24, 27, 30, 33
Summon Spell VIII: changes at casterlevel: 24, 27, 30, 33, 36, 39
Summon Spell: IX: changes at casterlevel: 24, 27, 30, 33, 36, 39

The lower summons do not need to change.

The part of the script that contains the custom summons looks like this:

    case SPELL_SUMMON_CREATURE_I:
    case SPELL_SUMMON_CREATURE_II:
    case SPELL_SUMMON_CREATURE_III:
    case SPELL_SUMMON_CREATURE_IV:
    case SPELL_SUMMON_CREATURE_V:
    case SPELL_SUMMON_CREATURE_VI:
    case SPELL_SUMMON_CREATURE_VII:
    case SPELL_SUMMON_CREATURE_VIII:
    case SPELL_SUMMON_CREATURE_IX:
    {
       //Module Config
       if(GetLocalInt(oMod,"ISUM") != 1) break;

       //Only For Players.
       if(!GetIsPC(OBJECT_SELF)) break;

       // Creature constants
       string sSummon = "";

       //Racial
       int nRace = GetRacialType(OBJECT_SELF);
       string sSubRace = GetSubRace(OBJECT_SELF);

       //Dwarf
       if(nRace == RACIAL_TYPE_DWARF)
       {
         if(nSpell==SPELL_SUMMON_CREATURE_I){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_II){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_III){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_IV){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_V){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VI){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VII){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VIII){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_IX){sSummon = "Summons_resref";}
     else {sSummon = "Summons_resref";}
       }



Thanks in advance
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #1 on: October 13, 2010, 03:50:50 pm »


               I think this should work from the example given I added in a caster level get


   case SPELL_SUMMON_CREATURE_I:
    case SPELL_SUMMON_CREATURE_II:
    case SPELL_SUMMON_CREATURE_III:
    case SPELL_SUMMON_CREATURE_IV:
    case SPELL_SUMMON_CREATURE_V:
    case SPELL_SUMMON_CREATURE_VI:
    case SPELL_SUMMON_CREATURE_VII:
    case SPELL_SUMMON_CREATURE_VIII:
    case SPELL_SUMMON_CREATURE_IX:
    {
       //Module Config
       if(GetLocalInt(oMod,"ISUM") != 1) break;

       //Only For Players.
       if(!GetIsPC(OBJECT_SELF)) break;

       // Creature constants
       string sSummon = "";
       { int nCasterLevel = GetCasterLevel(OBJECT_SELF)}

       //Racial
       int nRace = GetRacialType(OBJECT_SELF);
       string sSubRace = GetSubRace(OBJECT_SELF);

       //Dwarf
       if(nRace == RACIAL_TYPE_DWARF)
       {
         if(nSpell==SPELL_SUMMON_CREATURE_I){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_II){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_III){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_IV){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_V){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VI)
         {
            sSummon = "Summons_resref";
            if(nCasterLevel >= 24 && nCasterLevel <= 26)
            {
              sSummon = "Summons resref";
            }
            else if(nCasterLevel >= 27 && nCasterLevel <= 29)
            {
              sSummon = "Summons resref";
            }
            else if(nCasterLevel >= 30 && nCasterLevel <= 32)
            {
                sSummon = "Summons resref";
            }
            else if(nCasterLevel >= 33) sSummon = "Summons resref";
         }
         else if(nSpell==SPELL_SUMMON_CREATURE_VII){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_VIII){sSummon = "Summons_resref";}
         else if(nSpell==SPELL_SUMMON_CREATURE_IX){sSummon = "Summons_resref";}
     else {sSummon = "Summons_resref";}
       }

               
               

               


                     Modifié par Baragg, 13 octobre 2010 - 02:52 .
                     
                  


            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #2 on: October 13, 2010, 04:46:48 pm »


               I think:

 { int nCasterLevel = GetCasterLevel(OBJECT_SELF)}

should be changed to

 int nCasterLevel = GetCasterLevel(OBJECT_SELF);
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #3 on: October 13, 2010, 04:51:55 pm »


               I was thinking that is inside a switch case statement, if so I believe, but could be wrong, that to define a new variable inside a switch case you would need to seperate it out with { }. If it isn't inside the switch then those would not be needed.
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #4 on: October 13, 2010, 05:17:33 pm »


               You have:

{.....

    // Creature constants

      string sSummon = "";

      { int nCasterLevel = GetCasterLevel(OBJECT_SELF)}

.....}

The scope of nCasterLevel is limited to the surrounding { }.  sSummon is available within the whole switch but nCasterLevel is not.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #5 on: October 13, 2010, 05:25:18 pm »


               the extra {} around the int nCasterLevel = GetCasterLevel(OBJECT_SELF); Is not hurting anyhing. If you are getting a compile error it is more to the fack that he mised the simi colon. Should have been
{ int nCasterLevel = GetCasterLevel(OBJECT_SELF);}

The extra {} in this case however is not needed due to the fact that you already have the entire code for the case encapuslated.

ie:
case x:
{
//code
int y= 5;
// more code
}


will work

case x:
//code
{int y= 5;}
// more code


will also work.

case x:
//code
int y= 5;
// more code


will not work.
               
               

               


                     Modifié par Lightfoot8, 13 octobre 2010 - 04:31 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #6 on: October 13, 2010, 08:14:23 pm »


               Ah, k, thanks for clearing that up yall.
               
               

               
            

Legacy_Dagesh

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #7 on: October 14, 2010, 04:17:52 pm »


               

Lightfoot8 wrote...

case x:
//code
int y= 5;
// more code


will not work.


For this case you need to define the variable outside the case statement.  For example:


int nCheck = d20();
int nNumber;//<---Declaring variable outside the switch/case
    switch( nCheck )
    {
        case 1:
            nNumber = 1;
           break;
       case 2:
           nNumber = 5;
           break;
    }

The compiler will freak out if you do this:

int nCheck = d20();
    switch( nCheck )
    {
        case 1://<------No brackets!!
            int nNumber = 1;//<---Declaring inside the case!!
           break;
       case 2:
          int  nNumber = 5;
           break;
    }
You'll get this error:
ERROR: SKIPPING DECLARATION VIA "case" STATEMENT DISALLOWED.


Notice how I declared the variables INSIDE the case and also notice the case does not use brackets.  Compiler will tell you to declare outside the switch/case.  What you can do to work around this is either declare the variable outside the switch/case or add brackets to the case.  For example:


int nCheck = d20();
    switch( nCheck )
    {
        case 1:
        {//<----Notice I placed brackets!
            int nNumber = 1;
           break;
        }
       case 2:
        {
          int  nNumber = 5;
           break;
        }
    }
That will compile fine.  So if you need to declare a variable inside the case, add brackets to it as in this last example.
               
               

               


                     Modifié par Dagesh, 14 octobre 2010 - 03:21 .
                     
                  


            

Legacy_Arawan

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #8 on: October 14, 2010, 04:18:07 pm »


               Thank you all for your aid, it works perfectly now I added the simi colon as Lightfoot pointed out, other than that your code worked like a charm Baragg...  Thx all
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #9 on: October 14, 2010, 05:20:47 pm »


               Hmm.  Thought I stated all that above with the first example that works.
               
               

               
            

Legacy_Dagesh

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #10 on: October 14, 2010, 06:24:53 pm »


               I was simply pointing out when to declare variables in this case.  I did not see it in your previous post and it was an issue I ran into some years back so I felt the need to share.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #11 on: October 14, 2010, 08:12:58 pm »


               No Problem.  I should not have even made my last post.  I was in a bad mood this morning and just took it the wrong way.   Any fault to be given for posts in this thread all belong to me.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Looking for help with creating levelbased summons
« Reply #12 on: October 15, 2010, 02:32:12 am »


               I think that it was a post by Dagesh that I almost remembered that { } thing properly, from a long time ago that is, lol. Well better to have some memory than none at all.