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

advanced random battle (each step script)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Sun Jul 13, 2003 8:51 pm    Post subject: advanced random battle (each step script) Reply with quote

since people like to see some actual code, I will deliver.

(btw, posting ideas IS actually helping people, since they might be an
ace at commands but lacking in originality/inspiration.)

okay the script i'm writing about is simple enough, but if you have
problems tell me and I can post some code.

firstly, this is an "each step script" so make whatever adjustments
nessisary.

second, make sure you know all about the random command, look it
up in a help file or plotscr.hsd if you have continous memory loss.

finally we can begin,

to start create a variable (or global variable) of a value more than one.
This is the no. of steps before a battle. I reckon 20-30 is fine.

Call it something, anything, for an example purposes let it be "walktime"

Now give it a value, in our case "walktime" will equal 30 at highest
and 20 at lowest,


call another variable with a lesser value and call it: "timepass" or something. make it a random value for more unpredicability.
make it the same value or less than walktime.
these are formation no.s so make'em correspond to your game.

now create a "counter", use the 'while' command.
use a random number agian for a wait value if you wish,
call it a variable too, "time".

now HERE'S THE "MAGIC", (sarcasim sucks)

here's what you should have:


while( walktime<=30 )

do( decrement (walktime)
wait (time)
if (walktime==timepass)
then (fight formation (timepass))
if (walktime=0, or, timepass=0)
then ( walktime:=random(30,20)
timepass:=random(30,20))
)

finished, more than likely I have made a mistake somewhere,
since I didn't bother checking the code, hopefully you get the
idea. and hopefully I will be able to reply if this post isn't
locked, again. I think somebody is afraid that I might get a reply
to my deluded rantings....
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Mon Jul 14, 2003 6:54 am    Post subject: Reply with quote

I won't close this thread I guess, since it's a little better than before... But I'd still say it's pretty much useless since we already have a random encounter system installed into the OHR itself. I also feel that anyone could figure this out if they REALLY needed to create such a thing for whatever reasons.

And I'm not worried that people will reply to your messages. Why would I be worried? The reason they're closed is because they don't pose any originality, and don't offer any new gameplay ideas. That's all.

Anyhow, there's a few problems with that script. For example, a while loop may seem like a good idea, but it's completely unnessisary, and a little inefficient. Some people who use the OHR have rather slow computers, and a while loop could make a game run a lot slower than usual. Also, this script doesn't allow it to be used in every given situation. To make this work with every enemy formation group, you'd have to make that many scripts individually for every single map you use it on. If you were planning on just randomising the entire group formation (Like, say you have 20 different formation with varying enemies (randomising enemies 0 to 20))... Well, that just wouldn't be a very good idea. This would present a lot of gameplay imbalances, and a game should try to have as few imbalances as possible.

I've actually wrote a random encounter system for a game, because it uses different gameplay elements than just experience points after battle. Anyhow, the basics of the script is this:

Quote:
wait for hero (me)

if (battle == 0) then (
if (current map == 0) then (
fight formation (random(0, 5))
)
if (current map == 1) then (
fight formation (random(6, 11))
)
if (current map == 2) then (
fight formation (random(12, 16))
)
battle:=random(15, 20)
) else (
decrement(battle)
)


Once the hero comes to the next tile, the if statement is run, which checks the variable "battle" (The global variable I used to keep track of the amount of steps needed for the next battle). If it's equal to 0, then it goes into the final if statements. What these if statements check is the current map the player is on. Depending on the map, a different formation group will be fought. If the variable is not equal to 0, then the number is simply decreased using the "decrement()" command.

What's good about this version of the script is that it's far more customisable and a lot more efficient. All you need to do is create a single script and use it for every map. If you add a new map and enemies, all you have to do is alter the single script Wink.
Back to top
View user's profile Send private message
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Mon Jul 14, 2003 4:53 pm    Post subject: ...aah, I see now. Reply with quote

Since I was a little tied for time yestersay I just typed out as basic
of script as I could. Anyways, yours is much better Happy

The reason why I chose to use a script to fight random enemies is
because some people dislike the limitation of the no. of formations in
a set.

I intended to use a different method cause I thought it would be better
to use a script that makes it more and more likely for a battle to happen
as time goes by, rather than just set a random no. that with time will
just eventually fight a formation when the value is matched.

What i'm suggesting is that instead of the usual random value thing.
It would be more interesting to increase the amount you decrease,
as time goes by (i.e. walking)

I also feel scripts a better because you can use tags and other things.
So for example, if a tag is set so the weather is wet, then the hero
would be more likely to fight water type creatures.

I understand the point you made about the fact that some computers are
slow and to avoid loops. But every script has it's pros and cons.
what's important is getting the right script that suits your game. Happy

Your not so bad afterall, since you appear to be more patient since I
added some code. I'll remember this in future.
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Setu_Firestorm
Music Composer




Joined: 26 Mar 2003
Posts: 2566
Location: Holiday. FL

PostPosted: Tue Jul 15, 2003 1:29 am    Post subject: Reply with quote

Wow! A post by PlanetHunter that wasn't closed. How about that!
_________________


Facebook: http://www.facebook.com/georgerpowell
Newgrounds: http://setu-firestorm.newgrounds.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Tue Jul 15, 2003 11:57 pm    Post subject: ... Reply with quote

... Sarcasim is an empathy of a weak mind. Not that you have a weak
mind or anything setu, whatever you are!
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Setu_Firestorm
Music Composer




Joined: 26 Mar 2003
Posts: 2566
Location: Holiday. FL

PostPosted: Wed Jul 16, 2003 12:19 am    Post subject: Reply with quote

WUT EVA LOLLOLOLOLOLLOLOLOLPOOOOOP!!!111!!!1!
_________________


Facebook: http://www.facebook.com/georgerpowell
Newgrounds: http://setu-firestorm.newgrounds.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Wed Jul 16, 2003 5:03 am    Post subject: Reply with quote

The problem with using an every-step script is that, if you want different formations or encounter rates in different areas, you have to have the engine check if you are on this tile or that tile or this other tile or this other tile or this other tile or this other tile or . . . you see? So much in an if statement and so many if's makes for a very slow running game (I know this, for I have done it, and I am me).
A better method is to use an "instead of battle" script. Here:
Set each formation's encounter rate to whatever you want.
When the script is called, it picks a random formation to fight
-or-
The script turns on a tag and the next time activates a battle (if, say, you have an encounter rate reducing spell)
-or-
It adds to a global variable that counts how many battles you've fought, then fights a battle
-or-
Shows pretty colors and plays a song before hurling monsters at you, replacing the "fade to white" effect that gets really boring after the first few hundred times.

The possibilities for such an engine are endless (technically), and, as an added bonus, it doesn't slow the game down AT ALL. Except for when a battle is triggered.
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Wed Jul 16, 2003 6:55 am    Post subject: Reply with quote

Heheh. I already thought ahead of that and made a function in my downloadable utility library for plotscripting. The command to use, basically, is "In Area". It checks to see if you're in a specific area, and if you are, it returns true. So:

if (In Area (30, 21, 60, 40)) then (

fight formation (random(0, 5))
)


Now, if we're talking about world maps it becomes a little more difficult, but not impossible. I did this for my game, Dimensions I. What I did was create a function which would read the tile the hero was on and if it was within a specific range, return a specific value. This is what it looks like:

script, terrain, begin

variable (tile)

set variable (tile, read map block (hero x(me), hero y(me)))

if (tile == 3, or, (tile >= 31, and, tile <= 34), or, tile == 79) then (
return (grass)
)
if (tile == 4, or, (tile >= 19, and, tile <= 22), or, (tile >= 27, and, tile <= 30), or, tile == 80) then (
return (beach)
)
if ((tile >= 5, and, tile <= 13), or, (tile >= 35, and, tile <= 45)) then (
return (mountain)
)
if (tile == 14) then (
return (snow)
)

end


"Grass", "Beach", "Mountain", and "Snow" are all defined constants. It doesn't really matter what their real values are, but let's just say that they're 0, 1, 2, and 3 respectively.

Now, I would so this on a world map:

if (In Area (30, 21, 60, 40)) then (

if (terrain == grass) then (
fight formation (random(0, 5))
)
if (terrain == mountain) then (
fight formation (random(6, 10))
)
if (terrain == snow) then (
fight formation (random(11, 13))
)
if (terrain == beach) then (
fight formation (random(14, 20))
)
)


And problem solved! All you'd need to do is add all that bit into the script I posted in the 2nd post of this thread.

The trick to making the terrain function was keeping all the simular tiles together (Like all the different grass tiles are all lined together) so you can use them as a range. If they were all separated then you'd have to make a very long if statement that contains all the values for the grass tiles. So, a little pre-planning is needed as well.

Ahh, designing games is crazy fun XD.
Back to top
View user's profile Send private message
Grandtrain




Joined: 02 Feb 2003
Posts: 85

PostPosted: Wed Jul 16, 2003 6:35 pm    Post subject: Reply with quote

There is actually a use for making a random encounter script. Mainly, you can change the encounter rate. I used it in my Magnus contest entry. Also, even if you must make a script for all the maps, it's still faster than placing each foemap one by one.
Back to top
View user's profile Send private message Send e-mail
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Wed Jul 16, 2003 7:58 pm    Post subject: Reply with quote

So that's how you did it...

Cube, I thought you used regular formation set placing and used an after battle script to set the "numbar of battles" variable.

Your script seems a little advanced, for it's purpose but doesn't effect
gameplay. Which is all that matters really...

For my game I was thinking to have different formations to fight at
different 'times'. Should I check the master palette for differences
or use tags. My game has a day and night script, but I also want less
creatures to appear at night ( cause it's dark obiviously)

I'm unsure which method to use, placing sets or scripts.
I already have four globals: morning, midday, evening, night.
they run accordingly when a game is started.
_________________
~PH
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Wed Jul 16, 2003 8:27 pm    Post subject: Reply with quote

Uh... The only reason you'd use my script is to alter gameplay. I don't see how you see it, but it makes a game play very differently. For example, in my game I ALSO has a real time system. You can stand on the world map and see the colors slowly change from day to sunset, from sunset to night, and then from night to day again. It has a perfect transition. Hmm...Pictures, heh:





Anyhow, the way I keep track of the time is having a number that ranges from 0 to 3600. It runs through a loop that slowly increases the number. Depending on what the number is, the changes to the palette differ each time the loop is run. Once it hits 3600 it automatically reset to 0.

Anyhow, back to the battle script. How it effects gameplay is that you can fight different enemies during different times of the day (But that's only in my game. You could cut and paste that script somewhere else and use it for other purposes if you wanted. Right now, it's just a simple encounter system but can be altered to have particular differences). Using the number as well you can change the amount of steps needed for battle each turn. All that is needed is a if statement that checks those conditions:

if (In Area (30, 21, 60, 40)) then (

if (time <= 899, and, time >= 0) then (
if (terrain == grass) then (
fight formation (random(0, 5))
)
if (terrain == mountain) then (
fight formation (random(6, 10))
)
if (terrain == snow) then (
fight formation (random(11, 13))
)
if (terrain == beach) then (
fight formation (random(14, 20))
)
)
if (time <=1799, and, time >> 900) then (
if (terrain == grass) then (
fight formation (random(20, 25))
)
if (terrain == mountain) then (
fight formation (random(26, 30))
)
if (terrain == snow) then (
fight formation (random(31, 33))
)
if (terrain == beach) then (
fight formation (random(34, 40))
)
)
)


And so on. For what YOU want though, all you'd need to do is before the variable that keeps tracks of the needed steps to fight in a battle is create an if statement that checks the time like I did in my script.

if (time <= 2700, and, time << 900) then (

battle:=random(15, 20)
)
if (time <= 3600, and, time >> 2700) then (
battle:=random(25, 30)
)


Like that. As you might be able to tell, 0-900 is the sun rising, 900-1800 is the day, 1800-2700 is the sun setting, and 2700-3600 is the evening. Using a single variable to keep track of the time of day is much more efficient since it only uses one of the varaibles, and it's very flexable for special events.

Anyhow...I guess that's all I really have to say.
Back to top
View user's profile Send private message
Me
HI.




Joined: 30 Mar 2003
Posts: 870
Location: MY CUSTOM TITLE CAME BACK

PostPosted: Wed Jul 16, 2003 11:47 pm    Post subject: Reply with quote

Nice system, kind of like what I have in my games (fyi, this does not imply that I am stealing your script as we type and inserting it into my games. That wouldn't be very nice.)
The only real problem I can see is the fact that having all those scripts runing at once could slow your game down quite a bit. Does it still run at near full speed? If it does, then I commend your scripting skills.[/u]
_________________
UP DOWN UP DOWN LEFT LEFT RIGHT RIGHT A B START
Back to top
View user's profile Send private message AIM Address
Setu_Firestorm
Music Composer




Joined: 26 Mar 2003
Posts: 2566
Location: Holiday. FL

PostPosted: Thu Jul 17, 2003 12:28 am    Post subject: Reply with quote

Geez, Cube. You put, like, too much into this stuff.

.........I like it!
_________________


Facebook: http://www.facebook.com/georgerpowell
Newgrounds: http://setu-firestorm.newgrounds.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Squall
is fantastic




Joined: 02 Feb 2003
Posts: 758
Location: Nampa, Idaho

PostPosted: Thu Jul 17, 2003 12:31 am    Post subject: Reply with quote

I think we should all send Cube $10 (canadian) for being a swell fellow.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Setu_Firestorm
Music Composer




Joined: 26 Mar 2003
Posts: 2566
Location: Holiday. FL

PostPosted: Thu Jul 17, 2003 12:33 am    Post subject: Reply with quote

Yeah, I think he's old enough to see Enemy at the Gates. I'll send him my copy. It may be rated R here (and you can't see it until your 17 (at the movies anyway)), but there it's only CA-14.


..............I'll shut up now.
_________________


Facebook: http://www.facebook.com/georgerpowell
Newgrounds: http://setu-firestorm.newgrounds.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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