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
Looking for help with creating levelbased summons
Débuté par
Arawan
, oct. 13 2010 12:51
#1
Posté 13 octobre 2010 - 12:51
#2
Posté 13 octobre 2010 - 02:50
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
Posté 13 octobre 2010 - 03:46
I think:
{ int nCasterLevel = GetCasterLevel(OBJECT_SELF)}
should be changed to
int nCasterLevel = GetCasterLevel(OBJECT_SELF);
{ int nCasterLevel = GetCasterLevel(OBJECT_SELF)}
should be changed to
int nCasterLevel = GetCasterLevel(OBJECT_SELF);
#4
Posté 13 octobre 2010 - 03:51
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
Posté 13 octobre 2010 - 04:17
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.
{.....
// 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
Posté 13 octobre 2010 - 04:25
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.
{ 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
Posté 13 octobre 2010 - 07:14
Ah, k, thanks for clearing that up yall.
#8
Posté 14 octobre 2010 - 03:17
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
Posté 14 octobre 2010 - 03:18
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
Posté 14 octobre 2010 - 04:20
Hmm. Thought I stated all that above with the first example that works.
#11
Posté 14 octobre 2010 - 05:24
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
Posté 14 octobre 2010 - 07:12
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
Posté 15 octobre 2010 - 01:32
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.





Retour en haut






