 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Meatballsub Divine Bovine

Joined: 16 Jun 2003 Posts: 437 Location: Northwest Georgia
|
Posted: Sun Oct 07, 2007 11:37 am Post subject: After battle script question |
|
|
Code: | script,afterbattle,begin
suspend box advance
if (hero levelled (find hero (0))) then (
show textbox (362)
if (wait for key (50)) then (
advance text box
set hero stat (find hero (0),stat:Strength,5,maximum stat)
resume box advance
)
else (if (wait for key (31)) then (
advance text box
set hero stat (find hero (0),6,5,maximum stat)
resume box advance
))
else (if (wait for key (30)) then (
advance text box
set hero stat (find hero (0),5,5,maximum stat)
resume box advance
)))
end |
Basically, after a battle where you gain a level, I was going to have a textbox pop up with three options and depending on what button you press, commands are executed. However, nothing happens besides advancing the text box when you press a button. No stats are altered.
My second question is this: what if there is a situation where a person gains two levels in one fight? Or multiple party members gain levels in the same fight? Is there a way to call it twice or multiple times in one sitting?
Any help is appreciated. _________________ MOCBJ Software - My Games
The Hamster Wheel - OHRRPGCE Information Database |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sun Oct 07, 2007 12:40 pm Post subject: |
|
|
I think that the proper way to do this would be to have the command "wait for key" separate like so:
Code: | suspend box advance
if (hero levelled (find hero (0))) then (
show textbox (362)
waitforkey
if (keyispressed (50)) then (
advance text box
set hero stat (find hero (0),stat:Strength,5,maximum stat)
)
if (keyispressed (31)) then (
advance text box
set hero stat (find hero (0),6,5,maximum stat)
)
if (keyispressed (30)) then (
advance text box
set hero stat (find hero (0),5,5,maximum stat)
)
)
resume box advance #just put this at the bottom to make sure that
#box advancement is restored no matter what
end |
As for multiple levels in one battle, I think there is a plotscripting command that returns how many levels a given hero gained in the last battle. If so we can replace the outer "If hero levelled" check with a for loop that like this more or less:
Code: | variable(counter,levels)
levels:=#the plotscripting function that rerturns the amount of levels gained
for(counter,0,levels),do
(
#all the above code, except we don't need to check if hero levelled
)
|
This is just off the top of my head and untested; hope it helps. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
 |
Meatballsub Divine Bovine

Joined: 16 Jun 2003 Posts: 437 Location: Northwest Georgia
|
Posted: Sun Oct 07, 2007 1:05 pm Post subject: |
|
|
Thanks, single level works great. I have yet to try the multiple battle thing though, but I will let you know how it goes.
I have noticed, though, if you gain a level, and then go through with this script, and run from the next battle you encounter, the box will pop up again. Is there any way to fix that? _________________ MOCBJ Software - My Games
The Hamster Wheel - OHRRPGCE Information Database |
|
Back to top |
|
 |
Ysoft_Entertainment VB Programmer

Joined: 23 Sep 2003 Posts: 810 Location: Wherever There is a good game.
|
Posted: Sun Oct 07, 2007 3:59 pm Post subject: |
|
|
with the way the script works now, your hero would have strength of 5 each time s/he levels up. Unless you intend that, then the script is correct, otherwise you would need to increment the stat by 5. _________________ Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals. |
|
Back to top |
|
 |
Meatballsub Divine Bovine

Joined: 16 Jun 2003 Posts: 437 Location: Northwest Georgia
|
Posted: Sun Oct 07, 2007 4:12 pm Post subject: |
|
|
Ysoft_Entertainment wrote: | with the way the script works now, your hero would have strength of 5 each time s/he levels up. Unless you intend that, then the script is correct, otherwise you would need to increment the stat by 5. |
Yep, you are right. I altered it so it reads the current stat and increases it accordingly now. _________________ MOCBJ Software - My Games
The Hamster Wheel - OHRRPGCE Information Database |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Mon Oct 08, 2007 12:26 am Post subject: |
|
|
[Whoops, doublepost.] _________________ "It is so great it is insanely great."
Last edited by TMC on Sat Oct 20, 2007 1:33 am; edited 1 time in total |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Mon Oct 08, 2007 12:52 am Post subject: |
|
|
Meatballsub wrote: | I have noticed, though, if you gain a level, and then go through with this script, and run from the next battle you encounter, the box will pop up again. Is there any way to fix that? |
Crap. I'll try to remember to fix.
Quote: | I think there is a plotscripting command that returns how many levels a given hero gained in the last battle. If so we can replace the outer "If hero levelled" check with a for loop that like this more or less: |
The command is "hero levelled". You'll want to loop from 1 to the value returned, like this:
Code: | script,afterbattle,begin
variable (i)
suspend box advance
for (i, 1, hero levelled (find hero (0))) do (
...
)
end |
Also, if the player pushes some other button, nothing will happen. If you want the script to ignore all other keypresses, you could do something similar to this:
Code: | script,afterbattle,begin
variable (i)
suspend box advance
i := hero levelled (find hero (0))
while (i >> 0) do (
show textbox (362)
waitforkey
if (keyispressed (50)) then (
advance text box
set hero stat (find hero (0),stat:Strength,5,maximum stat)
) else (
if (keyispressed (31)) then (
advance text box
set hero stat (find hero (0),6,5,maximum stat)
) else (
if (keyispressed (30)) then (
advance text box
set hero stat (find hero (0),5,5,maximum stat)
) else (
i += 1
)
)
)
i -= 1
)
resume box advance
end |
And fix the setherostats, of course _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Mon Oct 08, 2007 4:04 am Post subject: |
|
|
Ah yes, start the loop at 1. But you will need the if check on the outside now, like:
levels:=herolevelled(findhero(0))
if(levels>>0),then,(
for(i,1,levels),do
Or else you risk starting a for loop counting up from 1 and trying to reach zero... _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Oct 20, 2007 1:32 am Post subject: |
|
|
No. The for loop won't loop at all if the start value is past the end value (or before, if the increment is negative.
will be skipped
loops once. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|