Battle system. (RPG Style)
Root / Programming Questions / [.]
Z_E_R_OCreated:
There are many ways you could do this. Likely the best way, as mentioned by Toad would be to use an array.
DIM TYPE DIM ATTACK[A,AM]Where TYPE is the type of enemy. When you get into a battle use RND, so if a 1 comes up, that's enemy type 1 and so on. Then ATTACK is 2-dimensional, where A is which attack is being used, and AM is the attack damage amount. This is just the beginning though and would not suffice as a very good system on it's own. Rather than just doing a random attack each time you could use a series of IF statements (in lue of a SWITCH CASE) to determine which attack should be used in certain scenarios. Something like: EHP = Enemy HP
IF EHP<20 THEN A = DEFENSEUP; ENDIFAlso, rather than using a set damage amount or even random, you can use some fairly simple formulas to determine the amount. You can also do something like: If to hit < Toughness/Deflection: Damage = Random(Weapon's min damage, weapons, max damage) - opponent's armor value Else: Damage = Random(Weapon's min damage, weapon's max damage) However, you should start simple, and then decide if you want to implement more complicated formulas. Once you start basing damage calculations on character levels it gets a bit complicated. You can start with a fixed damage system, where damage varies only by weapon. (The damage still varies, it just doesn't matter who uses said weapon)
You could have some randomly generated number thing for multiple enemies to load them into the battle system, though that may not be the best way to go about making it. Also, could you specify what you mean exactly by "How would I make multiple enemies of different types"? All that I think it would involve is maybe having different sprites and attacks honestly. And I'm not completely sure how one would go about making a roulette hp bar thing. This just reminds of how I was thinking about making a simple battle engine for a game I was making, so maybe I could try implementing some of the stuff you mentioned in it.I was asking about How would I make each enemy differ from the others. Its kinda hard to explain. I'm not really good with data And when it comes to things like making battle systems I'm no good. What I mean is like have 5 enemy slots And when you have an encounter The slots are filled with random enemy data Such as
If EnemyGroup==1 then E1=5:E2=3Then Slot one would be a bird monster And slot 2 would be a beast. I just don't know how I would go about giving each one a separate HP While making them do the same thing (Battle,heal themselves and etc,) I have trouble will slot things too because idk how data works.
There are many ways you could do this. Likely the best way, as mentioned by Toad would be to use an array.Yeah I use a formula like this Attack=Atk+Weapon damage-Enemydefense EnemyHp=EnemyHp-attack I really like your way too though, I might combine the twoDIM TYPE DIM ATTACK[A,AM]Where TYPE is the type of enemy. When you get into a battle use RND, so if a 1 comes up, that's enemy type 1 and so on. Then ATTACK is 2-dimensional, where A is which attack is being used, and AM is the attack damage amount. This is just the beginning though and would not suffice as a very good system on it's own. Rather than just doing a random attack each time you could use a series of IF statements (in lue of a SWITCH CASE) to determine which attack should be used in certain scenarios. Something like: EHP = Enemy HPIF EHP<20 THEN A = DEFENSEUP; ENDIFAlso, rather than using a set damage amount or even random, you can use some fairly simple formulas to determine the amount. You can also do something like: If to hit < Toughness/Deflection: Damage = Random(Weapon's min damage, weapons, max damage) - opponent's armor value Else: Damage = Random(Weapon's min damage, weapon's max damage) However, you should start simple, and then decide if you want to implement more complicated formulas. Once you start basing damage calculations on character levels it gets a bit complicated. You can start with a fixed damage system, where damage varies only by weapon. (The damage still varies, it just doesn't matter who uses said weapon)
Try this:
DIM ENGROUP[3,3] RESTORE @GROUPDATA FOR J=0 TO 2 FOR I=0 TO 2 READ ENGROUP[I,J] NEXT NEXT @GROUPDATA DATA 1,5,1 DATA 3,2,5 DATA 1,1,1You can then set the monster types like this:
DIM EN[3] GROUP=0 FOR I=0 TO 2 EN[I]=ENGROUP[GROUP,I] NEXTCan't test it right now, but it should work. Also, don't be afraid to use arrays for everything, the Nintendo 3DS basically has unlimited memory when it comes to making things with SmileBASIC.
Awesome, yeah just experiment, it will come to you eventually!Thank you for your help!
Try this:I'm gonna try that. I haven't been good with arrays but you broke it down really well so I'm gonna try it, Thank you!DIM ENGROUP[3,3] RESTORE @GROUPDATA FOR J=0 TO 2 FOR I=0 TO 2 READ ENGROUP[I,J] NEXT NEXT @GROUPDATA DATA 1,5,1 DATA 3,2,5 DATA 1,1,1You can then set the monster types like this:DIM EN[3] GROUP=0 FOR I=0 TO 2 EN[I]=ENGROUP[GROUP,I] NEXTCan't test it right now, but it should work. Also, don't be afraid to use arrays for everything, the Nintendo 3DS basically has unlimited memory when it comes to making things with SmileBASIC.
Try this:So the data setup works how would I use the data arrays Like how would I use this to setup the enemies.DIM ENGROUP[3,3] RESTORE @GROUPDATA FOR J=0 TO 2 FOR I=0 TO 2 READ ENGROUP[I,J] NEXT NEXT @GROUPDATA DATA 1,5,1 DATA 3,2,5 DATA 1,1,1You can then set the monster types like this:DIM EN[3] GROUP=0 FOR I=0 TO 2 EN[I]=ENGROUP[GROUP,I] NEXTCan't test it right now, but it should work. Also, don't be afraid to use arrays for everything, the Nintendo 3DS basically has unlimited memory when it comes to making things with SmileBASIC.
Do you mean HP and stuff? This is just for enemy groups.
So if enemy 1 was a skeleton and enemy 5 was a goblin, then this:
DATA 1,5,1would make the enemies appear in the order skeleton, goblin, skeleton, in battle. That's all it does. Of course, the enemies that appear would be the ones you make yourself.
Do you mean HP and stuff? This is just for enemy groups. So if enemy 1 was a skeleton and enemy 5 was a goblin, then this:Oh okay, In one case I know how to make them appear like : If EnemyN==1 then spset 0,678 (monster 1) I just don't know how I would take the Data and use it to do something like that Like how would I take the number 1,5,1 and use it Sorry if its annoying I really appreciate your helpDATA 1,5,1would make the enemies appear in the order skeleton, goblin, skeleton, in battle. That's all it does. Of course, the enemies that appear would be the ones you make yourself.
It's okay, I'll help whenever I'm not busy (with homework and stuff). You don't need to use 1 or 5, it was just an example, you can use sprite numbers, but it'd be hard to remember them if you use them them a lot. I hope that I haven't confused you, and good luck with your game!Would I use the read command to use the numbers Like how would I use the numbers... How would I take the numbers from the array and use them for player data
The READ command is for filling the array with data, not reading from it, silly, right?
Instead we'd do something like this:
DEC HP,EN[0,3]' Decrease player's HP by enemy's attack power 'or this: HP = HEAL[3] 'Player's HP variable becomes the fourth value in the HEAL arraySorry for the extremely late reply, I don't use this site very much.
The READ command is for filling the array with data, not reading from it, silly, right? Instead we'd do something like this:Its okay I appreciate you answering my questions. This is what I needed thank you!DEC HP,EN[0,3]' Decrease player's HP by enemy's attack power 'or this: HP = HEAL[3] 'Player's HP variable becomes the fourth value in the HEAL arraySorry for the extremely late reply, I don't use this site very much.
Either you READ VAR1,VAR2,VAR3 or READ ARR I think. I haven't messed with multiple data values on the same line.
Well one way I know how to do that is by loading a dat file with custom data. I'm using something similar for my emulator (load a text-based config which defines a custom instruction set and emulation parameters and load a dat-based BIOS file which contains custom boot code). You can define your enemy data using a text-based configuration file or you can save/load it in the dat format.
For an unencrypted text format configuration system you can do the slot thing in a few different ways. One way is to store each slot's data in a separate text file. Let's say it contains the text data "1:1;10" where the first number is level, the second is attack damage, and the third is hp count. The ":" and the ";" designate separation points". You can also use the newline character (CHR$(10)) to make the data multiline. You can even use tags such as "ENEMY0:" which is useful in a single multiline configuration file which contains all the enemy slot data. This can be a bit complicated but it does make editing your enemy data without editing the main code easier.
(option 2)
A more easier and compact way to do that is to store arrays in dat files. Because it's so easy and simple I'll make a little code example:
DIM ENEMY[4,3] 'Four enemy types, three variables per enemy. Of course you don't really need to define the dimensions when loading a file unless you're creating a new one. IF CHKFILE("DAT:ETYPE") THEN LOAD "DAT:ETYPE",ENEMY 'Code for whatever... ENDIF 'More code for whatever such as what to do if there is a missing file (you might want to change ENDIF to ELSEIF)...As you can see the second option is very simple. The first option woulld require a lot more code such as code for determining tags, string management, etc. If you want to make the second option load different files for different slots make multiple 1d arrays and do a bunch of save/load operations for how many slots you want. That's not a good idea because it would get messy. If you don't want to mess around with code each time you want to make changes to an enemy you can make a separate program (or DEF function in the main code) which loads the dat file and has a gui of some type so you can see what stored data there is so you can manipulate it with said gui. TL;DR read everything below (option 2)
Try this:
'I don't know what type of game you're making, so I'm using an RPG as an example CLS DIM EN$[3,3] 'You can only have string (text) or integer (number) arrays, not a combination of both RESTORE @EDATA FOR J =0 TO 2 FOR I=0 TO 2 READ EN$[I,J] NEXT NEXT MYHP=100 MYPOW=4 PRINT EN$[0,0]+", "+EN$[1,0]+" and "+EN$[2,0]+" are ready to fight!" 'Enemy names PRINT "HP:"+EN$[0,1]+" HP:"+EN$[1,1]+" HP:"+EN$[2,1] PRINT "My HP:" + STR$(MYHP) WAIT 150 PRINT "You attack "+EN$[2,0]+" for "+STR$(MYPOW)+" damage!" 'Enemy 3 EN$[2,1]=STR$(VAL(EN$[2,1])-1) WAIT 150 PRINT EN$[0,0]+", "+EN$[1,0]+" and "+EN$[2,0]+" are ready to fight!" PRINT "HP:"+EN$[0,1]+" HP:"+EN$[1,1]+" HP:"+EN$[2,1] PRINT "My HP:" + STR$(MYHP) PRINT EN$[1,0]+" attacks you for "+EN$[1,2]+" damage" 'Enemy 2's attack power MYHP=MYHP-VAL(EN$[1,2]) WAIT 150 PRINT EN$[0,0]+", "+EN$[1,0]+" and "+EN$[2,0]+" are ready to fight!" PRINT "HP:"+EN$[0,1]+" HP:"+EN$[1,1]+" HP:"+EN$[2,1] PRINT "My HP:" + STR$(MYHP) WHILE TRUE WEND @LEVEL1ENEMYDATA 'You can make multiple data labels for different levels and use RESTORE to get this data, then use READ (shown above) to store it into an array DATA "Goblin","30","5" DATA "Beast","40","7" DATA "Snake","15","5"Also can't test this code, but don't worry if you can't understand it, I'll be here to help whenever I can. :)