Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / RPG Monster stats and Npc text

Author
Message
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 23rd Aug 2005 12:02
I am currently making a RPG. However I need to find a way of storing the monster's stats when you are fighting it. This is my first time making a RPG game i am guessing that writing all the monsters stats out and storing them as variables is a waste of time and could become very confusing. I thought the best way would be to write the stats in notepad and save it as a *.dat then when you come to fight it open to read the *.dat file.

Also for NPC text you could do something similar because it is a waste of time to keep doing "text 100,100, etc" this would make changing the text alot easier.

I'm probably going crazy but this is just an idea could someone tell me if i'm on the right track because as i said i have never done this before.

Cheers
Jozers

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd Aug 2005 14:09
If you mean "saving" npc stats, storing as a .dat is probably the best way. But when using stats in your game I would suggest arrays.
For example:
dim npc(100,5)
where:
npc(5,1) = position x of npc 5
npc(10,2) = position z of npc 10
npc(49,3) = life of npc 49
npc(15,4) = max life of npc 15
npc(27,5) = attack of npc 27
etc...

You can change the values of your arrays according to the number of npc's and number of stats that should be accessed.

It's indeed a good idea to store the talking data of each npc in a file. Since this data can be very long, it could make your code pretty messy. Also, when storing in a .dat file, it's easy to access and edit it.

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 23rd Aug 2005 15:04
Thanks Sven,

I prefer to variable for the stats because i do find it a little easier(don't know why???). Will this give me any major problems in the future if i use variables??
Cheers
Jozers

Life is like a box of chocolates...
John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 23rd Aug 2005 15:15
Well, you are going to end up with a lot of variables if you have many npc's.

How about simplifying it by having more than one array e.g.

Dim npcPosX(100)
Dim npcPosZ(100)

Then you can store the positions of up to 100 npc's by just referencing the index (I assume you set Y to the ground height).

Position Object 1001,npcPosX(1), Get Ground Height(1,npcPosX(1),npcPosZ(1)), npcPosZ(1)

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd Aug 2005 17:01
JohnY is right.

Let's say you have 100 npcs:
this means 100 variables:

posx1# = 0.0 : posx2# = 20.0 ...
posz1# = 0.0 : posz2# = 20.0 ...

You can imagine how much this is going to take if you add status,life,maxlife,attack,defense,special attack, special defense, level, ...

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 23rd Aug 2005 17:19
I have changed all my NPC stats like you said. At the moment i have only i npc (monster) which you fight in battles I am going to make it so you can fight up to 5-6 monsters at a time. There will also be 3 good guys to a party. So after thinking about it, it will be easier in the long run if i use arrays. It's just i am going to have to good guys stats which may take a while as they are more complexed.

from what i understand if you have 3 people in a party the stats array would be like this:


And this would be the same for the Monsters

But if i want to fight a different type of monster at random what would i do???

Would i do something like this:




Thanks again for the help
Jozers

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd Aug 2005 17:26
That's a good option.

But use the load array before the loop too.



Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 23rd Aug 2005 17:52 Edited at: 23rd Aug 2005 17:56
Thanks Sven,
But it doesn't seem to be working. it doesn't seem to load the arrays. I will have a go at fixing it tonight.
Thanks
jozers

Edit: got it now, my mistake it works perfectly

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd Aug 2005 17:56
I actually have never loaded arrays... So I based myself on the help files in DBC

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 23rd Aug 2005 18:10 Edited at: 23rd Aug 2005 18:10
Well thanks anyway it's great btw was i right in what i said about arrays
Quote: "from what i understand if you have 3 people in a party the stats array would be like this:

"


Just one more question. If i am right, What would happen if you only had one/two person in the party?? would you leave the stats(1,3)=etc blank??

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd Aug 2005 19:09
You should always use the same array index as the one that you used to save it. Else the data will be seriously mixed up.

If you have an array stats(3,5) doesn't mean you should create 3 characters...

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 23rd Aug 2005 19:28
No i said if you wanted to have three character would you have an array stats(10,3) to store the data of all the characters in the party???

But say at the begining of the game you only have one character in the party would you just leave the stats(1,2) and stats(1,3) blank??

Well thats what i meant to say anyway. I have a habbit of mixing things up, so probably my bad.

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 24th Aug 2005 11:05
so you use the second dimension for each character?

I would use the same array for the whole game, even if you have 1 character playing. Maybe you can tell the pc the character doesn't exist by setting his maximum hp to 0? Or maybe his attack or defense...

I think if you use different arrays, the loading and saving can be pretty messy...

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 24th Aug 2005 17:01
ok i have changed all the characters stats from variables to arrays but when i try to save the arrays i get a problem its says that the array name is not valid.



This is what i have done i think it is probably to do with the arrays being declared before the main loop but i'm not really sure.
Thanks
Jozers

Life is like a box of chocolates...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 25th Aug 2005 12:59
I have sorted out the problem i had yesterday.

I have had another problem for a while now and was wondering if someone could take a look at my code.


I keep getting an error after a battle saying 'Runtime Warning at line 673. File does not exist' I don't understand why i have all the files to run the program in my project folder.
Cheers
Jozers

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Aug 2005 13:17
It's a good idea to set 1 standard directory. And if you want to store/load a file into a submap. Use this:

load array "Monster Stats/monster_data.dat",array(0)

Or something like that.

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 25th Aug 2005 13:53
I don't think i understand

Will this solve the 'Runtime Error. File does not exist' problem i am having.

Please could you explain it again.
Thanks
Jozers

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Aug 2005 14:52
No, I meant that it can prevent these errors. Since you are switching so often, it might be possible that you forgot to switch it back to the folder where the current file is stored in.

When using my way, you don't even have to worry about where the exe is stored in.. But when using your code, the media files ALWAYS have to be in the darkbasic directory.



This is the full code.
You don't have to use it, but it's just how I would do it.

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 26th Aug 2005 12:01
yeah it seems solve the runtime error that must have been the problem. i'm getting a object already exists error though i will try to fix that today if i can.

when it comes to animation is it better if i put all the animation into one file instead of using append object etc... loads of times.

And how would i get the object to move when it is attacking or should i use path animation??

Jozers

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th Aug 2005 12:45 Edited at: 26th Aug 2005 12:45
I'll try and explain it with pseudo-code:



This should be the most simple way. Remember the distance can variate when using more then 1 monsters/players.

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 26th Aug 2005 22:50
That kind of helps but how can i get the player to move smoothly to the target?? Would a kind of timer work where the timer increases then the player z position increases and where is gets to a certain point it starts to decrease until it reaches its original position.

Is there any commands that tell you when an object (animation) has finished playing?? because i what the damage to be taken away then not before animation has started or half way through it.

I can't work out why i am getting object already exist errors after the battles i have deleted all objects added in battle at the end of the battle. once i have fixed that i will be able to walk around the landscape and be able have random battles and then return to the landscape once again.

Sorry for all the questions i am new to creating RPG's
Thanks for all the Help
Jozers

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th Aug 2005 23:00
Jozers,

You are looking too far. I think you know how to move an object forward and how to point the object at the enemy.

A tip:

You can check if animation is playing with "object playing(objnr)" command. It'll return a 1 when playing (so 0 when it stopped).

and for your "object already exist" error. Well, I can say very much about this. But use "flush video memory" to clear ALL bobjects,animation,images,bitmaps... from your memory.

Immunity and Annihalation makes Immunihalation...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 27th Aug 2005 12:26 Edited at: 27th Aug 2005 17:05
The flush video memory doesn't seem to do anything but thanks for the tip for the animation it should make it alot easier now.

Jozers

EDIT: Just fixed the object already exist problem. I made a Cube which i was coming to use as a place holder for a NPC but i fogot to delete it before the battle.

Life is like a box of chocolates...
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 28th Aug 2005 14:24
I still can't get my move when i tell it to attack. when i use 'move object' then object moves very suddenly and when i use `stats#(15,1)=newxvalue(etc) etc...` the object doesn't move at all. not sure what to trynext any ideas would be great. Also the object playing command doesn't seem to be returning a value.

Life is like a box of chocolates...
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 28th Aug 2005 17:47
When using move object, and after it you use position object, the object's position will be reset to the position where you got your data. You should retrieve the object's position AFTER you use the move object command.

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2025-05-22 15:22:29
Your offset time is: 2025-05-22 15:22:29