Aller au contenu

Photo

Looking for help with creating levelbased summons


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

#1
Arawan

Arawan
  • Members
  • 24 messages
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

#2
Baragg

Baragg
  • Members
  • 271 messages
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 .


#3
Mudeye

Mudeye
  • Members
  • 126 messages
I think:

{ int nCasterLevel = GetCasterLevel(OBJECT_SELF)}

should be changed to

int nCasterLevel = GetCasterLevel(OBJECT_SELF);

#4
Baragg

Baragg
  • Members
  • 271 messages
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.

#5
Mudeye

Mudeye
  • Members
  • 126 messages
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.

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 .


#7
Baragg

Baragg
  • Members
  • 271 messages
Ah, k, thanks for clearing that up yall.

#8
Dagesh

Dagesh
  • Members
  • 30 messages

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 .


#9
Arawan

Arawan
  • Members
  • 24 messages
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

#10
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Hmm. Thought I stated all that above with the first example that works.

#11
Dagesh

Dagesh
  • Members
  • 30 messages
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.

#12
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#13
Baragg

Baragg
  • Members
  • 271 messages
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.