Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


RPG making questions

This topic is 6954 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post

Link to post
Share on other sites
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..

AKA Camelboy

Edited by - afastrunner on 4/30/00 4:01:01 PM

Share this post

Link to post
Share on other sites
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!

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!