Gw Temp

Menu

Tutorial - 'Battle Systems 101' by Kuro

An item about RPGMaker 2000 posted on

Blurb

Kuro is back with a huge tutorial on creating Battle Systems in Game maker!

Body

Battle Systems 101



All right class take your seats. Bart! Put down that flamethrower! Moriason! Did you bring enough "Stinger Missile Launchers" for



everybody?! I said sit down you bunch of MAGGOTS!!! Anyway, today we will learn about battle systems! Can anybody tell me what a battle



is?



Its when Batman has to pay Alfred to get into the batcave!



No, that would be a Bat Toll A battle is when a group of heroes have to fight monsters in an attempt to save the world.



Now can anybody tell me why this is pointless?



Because monsters like slimes don't carry around money and items all the time!



Correct. So now I will show you how to make a simple, yet effective battle system. It was started a long time ago in Rpgmaker 2000,



but that's before I discovered Game Maker. I call the battle system: ATObs (Active-Time-Option battle system). It works mainly like an ABS



but .... What is it DP?!



I have to go pee.



*sigh*





Battle Systems 101: ATObs, the ABS system



The ATObs is not complete as of yet. The following tutorial will have the link so be patient and read the following to familiarize



yourself with the system.






Lesson I: Preparations



Your game's going to need some sprites, animations, and stuff like that. So before you even start to create objects rooms etc., take as long



as you need to prepare your resources. Midi, mp3, sprites, backgrounds, tilesets, whatever. This process could take anywhere from weeks to



months, depending on how large your game is. But I urge you to follow a process. If you try to skip a step, you'll curse yourself later.



Follow these steps and keep yourself organized. Don't overwork yourself, and work when you feel the need. The last thing you want is to



lose interest because you worked too hard and your computer crashes. Save often too. As for myself, once I get on a streak, I keep working



until I'm told to stop. That's when my train of thought goes and I stop for a bit. (about a day-four days) Its all up to you.



Lesson II: Outlining and Restructuring



Instead of jumping straight into working on objects and coding, get your maps layed out and plan your ideas on a sheet. How will each battle



take place is important in an ABS. What features will be implemented and affected when a battle starts? (in-game clocks, weather, etc.)



List them down on paper, or on your computer. Either way, try to keep your things organized.



When you've totally gathered your resources, it will be time to show you the ATObs.





Lesson III: ATObs functions



Before you dive in, We'll need learn what functions are. Can anybody give me an example?



Its when a male clown gets kicked in the lower regions.



Stevester, that would be a Fun Shin. A Function would be a group of coding that when called, executes and usually



returns a value. Here's a good example.



function AddTwoValues(int a, int b){

c = a + b;

return c;

}



addValue = AddTwoValues(3,4);



Now can anybody tell me what addValue would contain?



It wou...



Shut up, Stevester.



But I know...



Zip it.



The answer i...



Bart, please hand me your Flamethrower.



Eep!



Indeed.





Sorry. I get a little sidetracked. Ok, the answer would be 7 incase you couldn't figure that out. Now on to the system functions.





Lesson III, System Function 01: GetAttackParams()/SetAttackParams()





GetAttackParams is what the ATObs uses to figure out when it is valid to attack. You wouldn't want the main hero to go crazy on innocent



townspeople would you? The way it works is quite simple. The file checks for instances of every type of enemy in the game using a



for loop. If at any time an enemy is present, a value of TRUE is returned and a boolean (true or false) variable is set. This



variable is used in an if statement in another function for a user's battle controls.



If the above is hard to understand, you need to go read up on either GML coding or check some javascript tutorials. Even some 'C' coding



will get you where you need to go. When you come back, we'll still be here, minus Stevester, which is burning over in the corner.



I'm not dead!



Moriason, can I borrow one of your "Stingers?"



Double-Eep!!



Indeed.



Oh and SetAttackParams() just sets the variable to FALSE. Nothing more to that.



Lesson III, System Function 02: OpenMenu(x,y,w,h,lvl)





This function relates to the opening of Battle Menus. You specify the x and y coord. with the width (w), height (h) and the level of the



menu. The level refers to what menu should open. Lets say level 02 was the menu for your hero's special attacks, and level 04 was for his



current items. With this function, you can even call windows out of battle, if need be. See how flexible that is?





Lesson III, System Function 03: GetCursorPos()



Simple function that gets and displays the cursor position. Nothing more to it.





Lesson II, System Function 04: SetEnemyProps()



This function is called at the beginning of each battle (or when an enemy comes into view). It gets the enemy data by checking the instance



that called the function and sets a 'Path' if necessary and starts the script written in the enemy object. Normally, we could just



initialize the enemy AI inside its Create Event, but what if the enemy's offscreen? You wouldn't want it to attack you when you can't even



see it, especially if it casts spells!





Lesson III, System Function 05: WrapUpBattle()



The name gives the function away. Inside of this function, it will call SetAttackParams() and tell the game to revoke battle controls from



the player. It will also re-initialize any functions like weather control and ingame clocks. Note that this all depends on how your game is



set up.





Lesson III, Final System Function: DebugAllParams(dControl,dValue)



This is the final function of this lesson. Its not a permanent function because its simply used as a master switch. If you need something



to be set, this function will do it. dControl refers to the variable being set, and dValue is obviously its value. A useful thing when



trying out new moves and such.







Lesson IV: Wrap Up and a bit o Code to Read



Okay, so I explained how functions work, but I gave you no code to work with! Not to worry, I'll will reveal all, in the next tutorial! But



for now, we'll do some practice functions. Stay with me.







function SetHeroAI(){

for(i=0;i<2;i+=1){ //-- This is a comment, so it won't be recognized by Game Maker as code.

if(partyMember[i] == "Alex"){

turnHeroOn("Alex",i);

}

if(partyMember[i] == "Raiden"){

turnHeroOn("Raiden",i);

}

if(partyMember[i] == "Sean"){

turnHeroOn("Sean",i);

}

}

}



This function is simply turning on the heroes at their correct places in the party. Assuming that partyMember[0] is the user's (you) player;



if Sean was partyMember[0], he would be controlled by the user (you). The same goes for Raiden and Alex.





function CallSpecialMove(player,move,req){

for(i=0;i
With(player){

if(specialMove[i] == move){

if(req >= specialReq[i]){

return TRUE;

}

}

}

}

return FALSE:

}





The function above is called whenever one of the players calls for a special attack, whatever it may be. The arrays simply contain the



characters special moves and REQuired values. If the move checks out, it will return true and the move will execute (back at the object, not



in this function), else the move fails and FALSE is returned.





function CallSpecialFX(x,y,FX,scale){

Draw_Sprite_Scaled(FX,FX.image_index,x,y,scale);

}





The final function of this chapter refers to drawing any type of special effect like an explosion. The scaled is simply there so the



explosion can be resized if necessary. And if you work the function correctly with timelines (next tutorial) you will be able to constantly



make a explosion grow, giving a cool effect. Note that the function above isn't totally workable, as there are some flaws with it. Drawing



the sprite out has to be done every frame so it can be cut off with simple techniques, but can also fill up the video buffer quite fast.



I'll explain some buffer saving techniques next tutorial.





# Epilogue 2 #



So what have we learned today.



Kuro hates Stevester?



Nah, I don't hate him. He was picked at random so next time, it could be somebody else!



Eep!!!



... ... ...















Indeed.







Peace Outside!!!

Kuro