Coordinate based RPG
Author |
Message |
Supernal
|
Posted: Fri Nov 02, 2007 4:34 pm Post subject: Coordinate based RPG |
|
|
Greetings, everyone. This is my first post on this site.
I was hoping I could acquire some help with a game I'm attempting to make.
My problem right now is:
I set my coordinate system up, and it's working fine. But my battle procedure runs via a randint event. It's basically:
randint (b,1,100)
Where "b" is my *b*attle procedure odds. So... :
if b > 85
then
Battle
end if
Now... I have the battle procedure running perfectly well... Except, when I am done the battle, it just re-loops, even after I've won/lost.
And thats where my problem is. I need a way to terminate the procedure, and re-run the movement procedure.
I'd appreciate any help/criticism. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Degensquared
|
Posted: Fri Nov 02, 2007 5:53 pm Post subject: Re: Coordinate based RPG |
|
|
Well if you could post some more of your code it would be easier for us to get some perspective on the problem
If you are using the loop statement to run through the battle, you might want to use an exit condition such as
code: |
loop
%battle things happen here
exit when hp <= 0
end loop
|
This way when the fight is over, you can just simply exit the loop at that point, and bring you right to the end of the procedure. (or next part of the battle loop, awarding experience, loot, etc )
Also, just as a side tip, try to use Rand.Int, instead of randint. and also the syntax tags help a little
[syntax="turing"]
![Wink Wink](images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
Supernal
|
Posted: Fri Nov 02, 2007 7:07 pm Post subject: RE:Coordinate based RPG |
|
|
Rand.Int is the snobs randint.
I do hope I'm not stupid enough to have forgotten about exit.
I'll post my source Monday.
Thanks for replying relatively quickly. ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Fri Nov 02, 2007 8:57 pm Post subject: Re: RE:Coordinate based RPG |
|
|
Supernal @ Fri Nov 02, 2007 7:07 pm wrote: Rand.Int is the snobs randint. ![Razz Razz](http://compsci.ca/v3/images/smiles/icon_razz.gif)
It really isn't, if I haven't forgotten the details.
randint is a procedure that takes a variable by reference to give you the random number. Rand.Int is a function and returns the random integer. |
|
|
|
|
![](images/spacer.gif) |
Supernal
|
Posted: Fri Nov 02, 2007 11:04 pm Post subject: RE:Coordinate based RPG |
|
|
... You see, thats why I post here for help. Thanks, Mazer.
I do believe I was a dumb ass, and forgot about "exit when *blahblah*"... So, pointless thread and such. Thank you, guys. |
|
|
|
|
![](images/spacer.gif) |
Supernal
|
Posted: Sat Nov 03, 2007 2:33 pm Post subject: RE:Coordinate based RPG |
|
|
New question..
I have my Move procedure in a loop, how would I get the loop to exit when my battle procedure is called?
(I'm not sure whether double posts are frowned upon, I'm sorry if so, but, this would most likely not be looked at for a while otherwise.) |
|
|
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Sat Nov 03, 2007 5:53 pm Post subject: RE:Coordinate based RPG |
|
|
Your move procedure is in a loop, or there's a loop in your move procedure? The latter is a bad idea. |
|
|
|
|
![](images/spacer.gif) |
Supernal
|
Posted: Sat Nov 03, 2007 7:33 pm Post subject: RE:Coordinate based RPG |
|
|
There is a loop on my move procedure. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Degensquared
|
Posted: Sat Nov 03, 2007 7:37 pm Post subject: Re: Coordinate based RPG |
|
|
Well it depends on how you have set up that move procedure, if you mean that you have it in a loop such as:
Check if there is player input, if so then carry out some actions, and then draw the scene in a loop; you could simply call the battle procedure.
By doing so, it would go through all of the code in the battle procedure and then go right back into the moving loop, with no deed to actually exit the loop.
Example:
code: |
loop
moving actions
if < battle conditions met > then
battle procedure
end if
end loop
|
Another solution would be to put it in a nested loop, so you would have the move proc looping, and then when the exit condition is met, it would leave the loop, go to the next part (battle procedure), and then when that finished, go back to the top of the first loop, and re-enter the move proc.
Example:
code: |
loop
loop
moving actions here
end loop
battle actions here
end loop
|
(Hope that answers your question ) |
|
|
|
|
![](images/spacer.gif) |
Supernal
|
Posted: Sat Nov 03, 2007 7:52 pm Post subject: Re: Coordinate based RPG |
|
|
code: |
procedure move
put "", x, ",", y, ""
put ""
put "You're standing at ", x, ",", y, ", which way will you go?"
put ""
put "1.) North"
put "2.) East"
put "3.) South"
put "4.) West"
get DirMove
if DirMove = 1
then
put "You walk north."
x := x + 1
end if
if DirMove = 2
then
put "You walk East."
y := y + 1
end if
if DirMove = 3
then
put "You walk South."
x := x - 1
end if
if DirMove = 4
then
put "You walk West."
y := y - 1
end if
end move
|
That is my move procedure.
code: |
procedure Battle
put ""
put "You are attacked by a monster!"
put "Press 'enter' to continue."
Input.Pause
cls
put "Monster Hp : ", MHp, ""
put ""
put ""
put ""
put ""
put "Choose an action."
put ""
put "1.) Attack"
get FAction
if FAction = 1
then
put MHp - Stren
end if
end Battle
|
And thats my battle procedure. (If you're wondering why I have "Choose an action." when there is only one option, I will add a "Run" option at some point.)
Now, what I want to do is loop the "move" procedure until the randint value is > 75. Then, I want it to jump to the "Battle" procedure. After MHp < 1, I want it to continue back to the "move" procedure, over and over, so on and so forth. |
|
|
|
|
![](images/spacer.gif) |
Supernal
|
Posted: Tue Nov 06, 2007 8:14 pm Post subject: RE:Coordinate based RPG |
|
|
I suppose no help applicable? |
|
|
|
|
![](images/spacer.gif) |
HeavenAgain
![](http://compsci.ca/v3/uploads/user_avatars/139122102045e603120b143.jpg)
|
Posted: Tue Nov 06, 2007 8:32 pm Post subject: RE:Coordinate based RPG |
|
|
for your main
code: | loop
move
if (Rand.Int (min, max) > 75 )
battle
end loop |
and inside your battle procedure or w/e, add an
at the end
![Rolling Eyes Rolling Eyes](http://compsci.ca/v3/images/smiles/icon_rolleyes.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|