This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-06-21 15:51:46

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Battle System

Hey Everyone.
I've been given the task of making a game using scratch.
Asking around i was given the idea of making a pokemon style game (ftw?) and i found that there isn't many full pokemon games (unless i missed them)
So here i am programming my game, i have it so stepping on the grass has a 1 in 3 chance of giving you a battle, if it doesn't then the script will wait then try again.

Now, I've got my sprites rolling in from the side when the battle starts, and it turns to me that i don't have much of an idea for the battle system...

Can anyone give me ideas on how i would go about writing this turn based battle idea? I know that (for now) i will just have one attack, and that will do between a certain amount of damage (depending on level). How can i make it so that the opponent attacks when it should? And how could i eventually make it so the opponent can choose which move?

Please help.

Thanks,
~Buggy


P.S. I may need some beta testers for once i have the main stuff out the way and need some testing...Please tell me if your interested  smile

Offline

 

#2 2010-06-21 15:58:59

06dknibbs
Scratcher
Registered: 2008-01-29
Posts: 1000+

Re: Battle System

There's a few Pokemon RPG's, but it'd probably be hard to explain how to make a full one over the forums  hmm

However Archmage made some RPG's which might help if you were to download the projects and look at the scripts  smile

http://scratch.mit.edu/projects/archmage/182422
http://scratch.mit.edu/projects/archmage/98362

Last edited by 06dknibbs (2010-06-21 15:59:23)


http://i404.photobucket.com/albums/pp129/06dknibbs/Untitled-3-6.jpg

Offline

 

#3 2010-06-21 16:02:21

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Thanks for the links, I'll be checking them out soon  smile

And i don't need to know how to make a whole RPG, just some ideas on how to make the computer wait until it's turn and such. Sorry if you don't get it...watch a pokemon battle on youtube and you'll get it i think  smile

Thanks,
~Buggy

Offline

 

#4 2010-06-21 16:42:32

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Battle System

Here is some psuedocode from http://www.kirupa.com/forum/showthread.php?t=97237


In pseudocode an attack might go

- Gamestate = Your turn
- All user controls for attacking are now enabled
- Select an attack
- Select a target and click 'Attack' button
- Set gamestate to = You attacking (all controls disabled)
- Run animation for current attacker moving in and attacking
- Run animations for bad guy reactions (probably triggered from raising events or targetting the object through the base class)
- Calculate attack power/damage etc through stats and show appropriate damage symbols etc (these can loop and animate independantly of the gamestate)
- Set gamestate to = You finished attacking
- Run jump back animations to reset your character to their position
- Set gamestate to = Enemies turn


This is how most turn based RPG battle systems work. The only diffrence is the battle forumla which you can make up or if you really want it to be perfect you can google search the battle forumla for pokemon and put it in. Mine has a simple made up forumla for the battle engine.


PS: Heres some neat info for random encounters. You said that you give the user a 33% chance to fight an enemy, but in that case the user can face monsters one after another which never happens in real RPGs. What some games like final fantasy do is have a "danger" value for each zone where monsters are. When a player enters a zone with enemies a number is generated equal to a random value between the danger number and the danger number times 1.5. When the player takes an amount of steps equal to the generated number they face a monster.

Last edited by archmage (2010-06-21 16:55:16)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#5 2010-06-22 05:03:06

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Thanks for the danger zone idea, but in Pokemon you can face monsters one after another (Unless i've misread what you've wrote, in which case i'm sorry XD ) and I think i already have a battle formula  smile
But your instructions at the top have really made it clear to me so far, i think i might be able to do it!  smile  Thanks so much!

~Buggy

Offline

 

#6 2010-06-22 09:14:19

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Sorry For the double post, but i thought it better than to make a new topic when it's sort of linked to the battle...

I have a script so when my monster attacks it does damage based on atk*2 - enemy def.
But that leaves me with a positive number, so if i put in change enemy HP then it'd add on to the HP  sad  .

How would i make it so that It'd take off from the enemies HP?

Thanks,

~Buggy

Offline

 

#7 2010-06-22 10:05:11

06dknibbs
Scratcher
Registered: 2008-01-29
Posts: 1000+

Re: Battle System

Buggy132KX wrote:

Sorry For the double post, but i thought it better than to make a new topic when it's sort of linked to the battle...

I have a script so when my monster attacks it does damage based on atk*2 - enemy def.
But that leaves me with a positive number, so if i put in change enemy HP then it'd add on to the HP  sad  .

How would i make it so that It'd take off from the enemies HP?

Thanks,

~Buggy

Instead of changing the Hp by a positive number like 5 when the enemy is hit, change it by a negative number like -5  smile

Also, it's fine to post something different that's on topic. ^^

Last edited by 06dknibbs (2010-06-22 10:06:43)


http://i404.photobucket.com/albums/pp129/06dknibbs/Untitled-3-6.jpg

Offline

 

#8 2010-06-22 10:22:29

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

I got that bit, it's just... Well, I'll get detailed XD

My Battle system has:
Hp
Atk
Sp. Atk
Def
Sp. Def
Level.

Everything is decided by a random number then by it's level.
So Let's say My enemies HP is 13.
The Attack is based on:
My Atk*2-Enemy Def
BUT
That formula will leave me with a positive number.
So Let's say my atk is 10, the enemy def is 9.
The formula would enter 11 into the dmg variable.
But I want to make it so i have HP - Dmg. If I put Change HP by Dmg It'll leave me with 24 instead of 2.
How do i change the dmg variable from positive to negative without recoding all the stats?
Thanks,

~Buggy

Offline

 

#9 2010-06-22 10:31:47

06dknibbs
Scratcher
Registered: 2008-01-29
Posts: 1000+

Re: Battle System

Oh xD

In that case, you could set the attack to -10.
Then make the formula -10*2 and add the defence instead of taking it.

-10*2 = -20.
-20 + 9 = -11

Does that work?  big_smile


http://i404.photobucket.com/albums/pp129/06dknibbs/Untitled-3-6.jpg

Offline

 

#10 2010-06-22 10:34:08

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Hmmm, It'll probably work.
But is there no way to have it so a number changes from positive to negative? Because I may (in future versions) add a stats page, but It'll look weird if it says -10...

Thanks,

~Buggy

Offline

 

#11 2010-06-22 10:38:43

06dknibbs
Scratcher
Registered: 2008-01-29
Posts: 1000+

Re: Battle System

Then you could keep the original formula, and change HP - Dmg to HP - Dmg*-1

Which should change the 11 to -11 and then take it from the HP while leaving the normal damage as 11  smile

And actually, this would probably be easier than the other formula xD

Last edited by 06dknibbs (2010-06-22 10:42:02)


http://i404.photobucket.com/albums/pp129/06dknibbs/Untitled-3-6.jpg

Offline

 

#12 2010-06-22 10:48:34

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Ah, now that's what I'm looking for!
Thanks so much, and for sticking with me when i weren't explaining very well  smile

Your the best,

~Buggy

Offline

 

#13 2010-06-22 11:41:15

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Errm, sorry, but it doesn't appear to be working XD.

My Code:
<forever>
<if><<State = 0  <and>Attack No. = 1  >>
[Un Important Stuff Here]
<change{ Enemy Hp }by( My Atk*1.5 *-1  + enemy Def )
<end>

The State Is whose turn It is, the Attack No. Is which Attack.
I multiplied the attack by -1 and added enemy defence.
In My trial The enemy had 24 HP, I attacked and it had 32.0.

Please Help,

~Buggy

Offline

 

#14 2010-06-22 13:26:54

06dknibbs
Scratcher
Registered: 2008-01-29
Posts: 1000+

Re: Battle System

Your scripts slightly different than I thought  smile . So..

The problem there is, the change block changes by whatever number is left at the end. So if a positive number is left, the enemy gains HP.

Try replacing the "Change: Enemy HP with another variable called damage.

Then, set the "Damage" to My Atk*1.5 - Enemy Defence.

Then add "Change: Enemy HP" by "Damage*-1"

And that should hopefully work XD


http://i404.photobucket.com/albums/pp129/06dknibbs/Untitled-3-6.jpg

Offline

 

#15 2010-06-22 13:28:09

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Ok, I'll set onto that now.
Thanks so much!

~Buggy

Offline

 

#16 2010-06-24 02:45:16

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Sorry for the revival, but I'm having even MORE problems XD
I've just decided to post the game up, as i don't even know what went wrong...never mind how to fix it  sad

http://scratch.mit.edu/projects/Buggy132KX/1148110

(Press Play, go into the top right area...Credits are still old and need updating, ignore them...)
On the script it'll say
Set Snot attack to Pick Random 1 to 1.

That was because I wanted to test it out to see if i could have a turn based battle...It'll be changed to however many moves he'll have  smile

Thanks so much,

~Buggy

Offline

 

#17 2010-06-24 15:20:48

Mike358
Scratcher
Registered: 2009-02-20
Posts: 11

Re: Battle System

You have <set{ Snot damage }to( (( (( (( snot damage <*> 2.5 )) <-> <pick random( (( <{ level }> <*> 1 )) )to( (( level <*> 3 )) )) <-> <{ snipah def }> ))

Shouldn't it be:

<set{ Snot damage }to( (( (( (( snot ATK <*> 2.5 )) <-> <pick random( (( <{ level }> <*> 1 )) )to( (( level <*> 3 )) )) <-> <{ snipah def }> ))?

Offline

 

#18 2010-06-24 15:52:21

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

...

EPIC FACEPALM MOMENT!!!XD
How did i not see that?
Thanks so much!

Tested and working,

~Buggy

Offline

 

#19 2010-06-24 19:18:41

Mike358
Scratcher
Registered: 2009-02-20
Posts: 11

Re: Battle System

No problem. 

I'd like to see how this turns out.

Offline

 

#20 2010-06-24 19:34:20

waveOSBeta
Scratcher
Registered: 2009-12-08
Posts: 1000+

Re: Battle System

Buggy132KX wrote:

Hey Everyone.
I've been given the task of making a game using scratch.
Asking around i was given the idea of making a pokemon style game (ftw?) and i found that there isn't many full pokemon games (unless i missed them)
So here i am programming my game, i have it so stepping on the grass has a 1 in 3 chance of giving you a battle, if it doesn't then the script will wait then try again.

Now, I've got my sprites rolling in from the side when the battle starts, and it turns to me that i don't have much of an idea for the battle system...

Can anyone give me ideas on how i would go about writing this turn based battle idea? I know that (for now) i will just have one attack, and that will do between a certain amount of damage (depending on level). How can i make it so that the opponent attacks when it should? And how could i eventually make it so the opponent can choose which move?

Please help.

Thanks,
~Buggy


P.S. I may need some beta testers for once i have the main stuff out the way and need some testing...Please tell me if your interested  smile

I'm seeing you a lot on the forums. I think a mod should make you a member soon  big_smile


http://internetometer.com/image/10202.png]
New signature coming soon!  smile

Offline

 

#21 2010-06-25 16:44:34

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Awww, thank you  smile

I'm just trying to get me known as someone who's active and polite  smile

~Buggy

P.S.
Mike, I'm hoping to have it done within a week, maybe shorter, as I may be allowed to work on this during my IT lessons at school .. smile

Offline

 

#22 2010-06-26 09:09:21

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

Ach, Even more problems  sad

I'm planning on having a healing system, so in between fights you can heal your guy.
I had a script that said
<When I recieve battle> Battle Starts
<Set Full HP to HP> Set the Full HP variable to your guys current health.

Then at the end of a battle (just coding it at the end atm so it's sorted and i can just move the scripts.

<Set HP to Full HP>

But when i go into a battle again it isn't set as it should be.

What's wrong with my script?

~Buggy

Offline

 

#23 2010-06-26 17:06:15

mariobrosrule
Scratcher
Registered: 2008-06-09
Posts: 1000+

Re: Battle System

to calculate damage go here: http://www.upokecenter.com/games/dungeon2/guides/damage.php

Offline

 

#24 2010-06-26 19:17:02

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Battle System

Buggy132KX wrote:

Ach, Even more problems  sad

I'm planning on having a healing system, so in between fights you can heal your guy.
I had a script that said
<When I recieve battle> Battle Starts
<Set Full HP to HP> Set the Full HP variable to your guys current health.

Then at the end of a battle (just coding it at the end atm so it's sorted and i can just move the scripts.

<Set HP to Full HP>

But when i go into a battle again it isn't set as it should be.

What's wrong with my script?

~Buggy

According to what you have said your script is fine. You either need to give more details or upload your project.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#25 2010-06-27 08:23:13

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Battle System

*sigh*
O.K. Then
I have no idea what else i could add to make it more detailed about the HP.

It'll be uploaded by the time this is posted.
Thanks for still being helpful!

~Buggy

P.S     Link Is http://scratch.mit.edu/projects/Buggy132KX/1155084
P.S.S   . MarioBrosRule, Thanks, but i already have an idea for a simplistic yet still pokemon-like battle system.
P.S.S.S    Is it P.S.S or P.P.S?

Offline

 

Board footer