RPG making questions

Started by
24 comments, last by Squall012 23 years, 11 months ago
I''m having trouble with my random encounters. I am walking on the world map, happy as can be, and I encounter a monster. I kill the beast, or run away and get back to the world map. Know, if I move one step, it will go back into battle. But then sometimes it will not go back into a battle at all. So what I did was output the random number that it generates..and each time I move the character, it INCREMENTS!? I know how to generate random numbers, it just isn''t working. How do the pro''s do random encounters? Any of you pro''s out there able to help?
Advertisement
Random numbers eh? In C/C++ you can do them like this:

When you init your game call srand(time(NULL)) (don't forget to include time.h). Only call srand() once, or else the numbers won't "look random". Whenever you want a random number you just do varname = rand() % limit - 1. So if you want to generate a number between 0 and 100 you do:

varname = rand() % 101;

/. Muzzafarath

Edited by - Muzzafarath on 4/30/00 2:57:09 PM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Heh heh, thanks..buuuuuut, what I need to know is why after a battle do my numbers not work? For example, I go right into a battle after taking another step, OR I don''t get another battle the rest of the game...it''s like even though I seed the rand function, I STILL can''t get it right.

What I do is (and this is probably the worst way of doing it, I am open for help):

if player hits up

move character up
check for encounter with a monster (random if var >70)
go into the fight

else no encounter go back to world map

Then it is pretty much the same for the rest of the directions. What is wrong with it? why don''t it do the random numbers AFTER the first fight?

that was me, the anonymous...sorry
What I do is make a var that I count down to the encounter.

int encounter = (rand()%max_wait)+min_wait;
//max_wait is the max number of turns
//before you are attacked and
//min_wait is the minimum.

Now every time you enter an area that you can be attacked in, you reasign a random number and then subtract 1 every time you move until encounter = 0, then you call your battle engine. Then after the battle you reasign again.

This way you can set a dificulty for different areas, so they get attacked more in some areas and less in others, and you don't have to worry about getting attacked every square, or never getting attacked at all..

Afastrunner
AKA Camelboy

Edited by - afastrunner on 4/30/00 4:01:01 PM
AfastrunnerAKA Camelboy
That is a good idea, I think I will use that instead of my random only, because sometimes you have to fight a battle right after another, but with this, it is more defined, I like it. Thanks!
Hey since your working on a rpg. Do you have town npc''s like in final fantasy?
how do you make them walk around at different times!
I''m just wondering, I haven''t begun programming anything, but just gathering info..still waiting for a reply to another topic. I assume you do attacks?
how do you do attacks?
I tried it by having an index value
and a case statement called the right procedure.
but I keep having lots of procedures for each attack/spell etc..anyway to clean this up?? thanks.
-codyva
My town''s aren''t developed yet, I''m working on the game a stage at a time, making sure I don''t jump in too far over my head, considering (please everyone don''t yell or criticize)this is my first game...ever in c++....buut, my attack is just like FF7, and very complecated. I have psuedo-real time battles using variables that count up to 100 for both players and the monster. When the monster''s reaches 100, it attacks without worry. When the time bar of either player alive fills up, the menu pops up, and they can do an action. If the other player''s time fills up, then he goes directly AFTER the person attacking. I''m trying to hint at things without telling how to do it, but if you need more specifics, e-mail me.

There is so much to a battle system! Check to see if the battle contains more than one human controlled player, check to see if one of those players is dead, if not, make the time go up. If someone is dead, dont fill up time. IF all are dead, do a game over, if Monster is dead...it goes on and on.
I understand that... but I was just worried about how ff3(I think) makes it so battles also depend on the timer?
as in you save...and take a step..battle..reload the save..wait..take a step and you get no battle.
but if you had a constant number being decremented then you would definatly have a battle anybody enlighten this also?
I don''t know how to do it.
Maybe having the a percentage maybe like 5% of avoiding the battle..?
5% of battles don''t occur even though they were supposed to?
I don''t know..maybe it''s just the emulator.


Also what type of variables do you have?
I do all my stuff(limited) in VB.
type Player
Hp as Integer
Mp as Integer
X as Integer
Y as Integer
end type
stuff like that???
In another project I''m working on I have a different structure that references to tables...
basically stuff happens only if one value in the player structure is bigger etc?
and different differences give different responses..
as in if it''s below by 5 then do this
below by 10 do that.
etc. How do you do your graphics.
I find it''s hard to keep typing in raw data.
but I dont'' know how to load.
pcx snapshots are pretty easy to do right?
what other experience
just tell me if I"m being to nosey.
bye.
I''m a little confused about your first question. I think you could solve it by initializing the game, then setting the random encounter for something different each time you restart the game. So, you could have some variables that are set when the game is reloaded, and then the variables that were in the save file loaded after those have been done. Like you set up the random encounter for the first time, then load in HP,MP,ect....But I''m not too sure I know what you mean. For the other questions....HP is int, pretty much all the numbers in the game (Speed, MP, AG, HPMAX...ect) are all ints, while names are strings..sorry if that made you look stupid...I''m not sure what you were asking there.

Finally, I''m just doing simple 2D sprites for my graphics, considering this is my first game. I load in Windows Bitmaps using the engine from Andre''s books, and that is good enough for my uses. I don''t know what else you need, if you need more, then tell me. I hope this is helping, because I myself have had a hard time trying to find info on making RPGs.

This topic is closed to new replies.

Advertisement