Unexpected $end

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I have a skill which I have used for 9 hours of game play. The formula looks like this.

Code:
if $game_player.region_id == 40;
if b.state?(23); b.add_debuff(6, 3); end;
base[20] + 4*a.level + a.mat*4 - b.mdf*1.5;
else;
base[20] + 4*a.level + a.mat*3 - b.mdf*1.5;
end
Now, however, I want to include a variable in the calculation of damage, so I have this.
Code:
if $game_player.region_id == 40;
if b.state?(23); b.add_debuff(6, 3); end;
base[20] + 4*a.level + a.mat*4 - b.mdf*1.5 * (v[245]/100);
else;
if b.state?(23); b.add_debuff(6, 3);
base[20] + 4*a.level + a.mat*3 - b.mdf*1.5 * (v[245]/100);
end
When I use the revised skill, however, I get the error message:

unexpected $end, expecting keyword_end

In my ignorance, I had assumed that when I revised the formula, I would leave the "end"s where they were.
I have no idea what is wrong here. Can anyone spot the mistake?

Thanks.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
The error might be the v[245]. I've always had to use $game_variables[245] myself to access variable 245.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@bgillisp changing (v[245]) to ($game_variables[245]) still throws the same error.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
Code:
if $game_player.region_id == 40;
   if b.state?(23); 
      b.add_debuff(6, 3); 
   end;
   base[20] + 4*a.level + a.mat*4 - b.mdf*1.5 * (v[245]/100);
else;
   if b.state?(23); 
     b.add_debuff(6, 3);
     base[20] + 4*a.level + a.mat*3 - b.mdf*1.5 * (v[245]/100);
   end
# "end" closing "else"? 
#unexpected <end> expected *keyword* end
end #*keyword* end, closing "if $game_player.region_id..."
use blocks, not colons.
you'll see the structure much easier.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@gstv87 That extra "end" solved the error message, but I am now only getting 1HP damage for that skill - I have a script which prevents Null damage and always gives a minimum of 1, so I am assuming that the 1HP damage is the result of that script.

For information, variable 245 is, at the moment, set to 100 (it will be increased by plot devices at different times) so I should be getting the 'normal' damage of around 220HP, as it is normal damage formula * 100/100
Is it that logic that I have wrong?

Thanks for the help so far.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
try changing (v[245] / 100) to (v[245] * 0.01)
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
Code:
if $game_player.region_id == 40;
 base[20] + 4*a.level + a.mat*4 - b.mdf*1.5 * (v[245]/100);
else;
 base[20] + 4*a.level + a.mat*3 - b.mdf*1.5 * (v[245]/100);
end;
if b.state?(23);
 b.add_debuff(6, 3);
end;
copy/paste
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@gstv87 Sadly no change.
Maybe I need to find a completely different way of increasing these skills by 10% rather than using a variable. But to be honest, I can't think of one.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
that's impossible.
even if v[245] and base[20] are 0, a.level is still always greater than 1, and that's multiplied by 4.
try moving the "if b.state?" block to the top, and add a "return" instruction before the base[20]
there's no way it will output 1 that way.
if it does, there's something else negating that whole thing.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@gstv87 Sound the trumpets! Ring the bells!
That did it.

Thank you so very much for all your help with this. I deeply appreciate it.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
If you guys are still wondering, it returned 0 from your damage formula because the result of the formula is always the formula's last method call's result.
You checking/adding a state at the end does not result in a valid number, therefore the formula itself would crash the game, but because a rescue is called with the value of 0 for all formulas, the damage formula returned 0 instead of a crash.

Always do additional things (such as adding/removing states) at the start of your damage formula, and do the real damage calculation at the end.
If you happen to do some of these additional things based on the damage itself, you first do the damage calculation, store it in a local variable, do your additional things after, and at the end use the stored local variable to denote the real damage value (using a return variable_name line at the end).
 
  • Like
Reactions: Kes
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,567
Latest member
sashalag
Top