Gw Temp

Menu

Tutorial - 'Tank System' by Guest

An item about RPGMaker 2000 posted on

Blurb

Need a tank in your game? Well this tutorial suits your needs well.

Body

A Tank System
After a (very very) long time without any tutoriel from me, here is a new 1 :).
In this tutoriel I will teach you how to add a tank system (the tank will be able to shoot to) into your game.
The tutoriel will be divided into two parts.
In this part I will teach you the basics of the system and in the next part we will create targets for our tank to.
Things you need to know:
- Switches
- Variables
- Common Events
(In addition you must have a basic known in the programm with all the normal stuff: normal events, commands etc'...)

Notice!: this tutoriel had been wrote for he RM2K3 game creator.
In the older or newer versions the programming may be different.

Index:
- Part 1: Creating the tank
- Part 2: Creating the shoot system
- Part 3: Tips and Ideas

Part 1: Creating the tank
Now this is the easy part.
First we need to set up our map:
Fill the all map with grass and make a road in the middle of the map.
Place the hero in your map whereever you like, and put a skiff (or any other vehicle you wish to use as your tank) on the road.

Now go into the database and into the "Terrain" tab.
In there, make a new terrain type and call it however you like (for the tutoriel I called it "Road" but it's not metter... you can even call him "Big Joe" if you so want :\...).
Make this tarrien be the only passable terrain type for skiff (or the other vehicle you chose).
All the other things (like bg and Initative chances) you can do by yourself.

Now go to the "Tileset" tab and change the tile you used in the map to create the road into the new terrain type you just created.

Now go to the "System" tab.
Change the skiff's (or the other vehicle you chose) sprite into the tank's (you can use the RTP tank or create one of your own) and the skiff BGM to any music you like.

Congratulations!
You now have moving tank :D!
Wasn't that easy?
Good!
Because now comes the harb part...

Part 2: Creating the shoot system
Now to create the shoot system.
The shoot system will work like that:
When you enter the tank the menu will automatticaly will be diabled.
Insted of the menu, every hit on the CANCEL key (Esc/X) will load a bullet.
When the CANCEL key will be unhitted, the bullet will be lunched.
So how do we do that?
First we need to create some switches and variables.
Switches:
- PartyInTank
- BulletHaveBeenShot
- Target1IsDead
Variables:
- Key
- HeroMapID
- HeroX
- HeroY
- BulletX
- BulletY
Now create an event on the map:
Bullet:
GeneralPos - somewhere far from the hero
Graphic - some thing that looks like a ball or a bullet (due to my "great" talent in creating sprites I used a rock from the RTP...)
Movment Frequency - 6: Four Times Normal
Event Layer - Above Hero
Precondition - Switch: xxxx: BulletHaveBeenShot

The map (at least mine) now:

Now for the hard part: programming :\...
Go to the database again and to the "Common Event" tab.
Create a new common event and call it "PartyInTank".
Make this common event parallel process.
Now add a Branch.
make the condition: "Party is riding: Skiff" (or whaever other vehicle you chose) and check the "Execute Custom Handler if Condition not met" checkbox.
now into the branch add a "disallow menu" command and a "ON switch" command to the switch "PartyInTank" switch.
In the "Else Handler" the the exec oposite thing ("allow menu", "OFF switch" to "PartyInTank").
Now your code should look like that:

Now make another common event.
Call it "ShootSystem" and make it parallel process to but! add a trigger switch and make the "PartyInTank" switch be the trigger.
Now add a key input processing into the variable "Key", uncheck the "Wait Until Key Pressed" checkbox, and leave only the "Cancel Key (6)" checked within the keys list.
Now add a branch.
The branch condition will be "Variable is 6".
Inside the branch add a switch oporation and turn switch "BulletHaveBeenShot" switch on.
Now memorize the hero's position into the variables "HeroMapID", "HeroX", "HeroY".
Now add another branch (inside the existing one).
The condition is "Sprite: Skiff Facing Down".
Check the "Execute Custom Handler if Condition Not Met" checkbox.
Add a "Change Event Location" command and change the position of the event "Bullet" we have created to the hero's X and Y positions we memorized.
Now add a "Move Event" command and make the event bullet move down five tiles and then turn the switch "BulletHaveBeenShot" off.
Check the "Ignore Impossible Moves" checkbox.
Notice!: This is VERY importent you use the move event to switch the "BulletHaveBeenShot" switch off.
The code now should looke like that:

The rest is very simple.
Copy the branch (the most inner branch) and copy it into the else handler you made before.
Change the new branches condition into skiff face up and the movement direction to up.
Do it to all directions but don't forget to uncheck the "Execute Custom Handler if Condition Not Met" checkbox for the last branch.
The all code should now look like that:

Congratulations!
You have made a basic tank that can shoot :D!
Next time will amke some targets for our tank :).

Part 3: Tips and Ideas
While this tutoriel is diercted to intermidate game makers, all the advanced or intermidate makers that feel they can, add some nice touches of theire own.
You can try and more realisem by making the tank going slowly backwards one tile each time he shoots as a reaction to the motive force.
Another idea is add a sound effect to the fire, and an explosion to the disappearing.
This is all very simple but it's adding alot.
Until the next part, cya, and don't forget your creativity :), Omer_D.