Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

After battle script question

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Meatballsub
Divine Bovine




Joined: 16 Jun 2003
Posts: 437
Location: Northwest Georgia

PostPosted: Sun Oct 07, 2007 11:37 am    Post subject: After battle script question Reply with quote

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
View user's profile Send private message Visit poster's website
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Sun Oct 07, 2007 12:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Meatballsub
Divine Bovine




Joined: 16 Jun 2003
Posts: 437
Location: Northwest Georgia

PostPosted: Sun Oct 07, 2007 1:05 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Sun Oct 07, 2007 3:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Meatballsub
Divine Bovine




Joined: 16 Jun 2003
Posts: 437
Location: Northwest Georgia

PostPosted: Sun Oct 07, 2007 4:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Mon Oct 08, 2007 12:26 am    Post subject: Reply with quote

[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
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Mon Oct 08, 2007 12:52 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Mon Oct 08, 2007 4:04 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Oct 20, 2007 1:32 am    Post subject: Reply with quote

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.
Code:
for(i,1,0)do()

will be skipped
Code:
for(i,1,1)do()

loops once.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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