Tutorial: DBS - Ammunition System
Difficulty: Intermediate
RPG Maker: 2003
Author: kid27

Hi folks!!

Do you have a character in your RPG Maker 2003 game who uses a bow or gun or anything else that uses ammo? Isn't it a bit lame that they use 1 MP point instead of 1 item every time they shoot? Well, using a bit of simple coding and 1 variables per character and 1 extra per ammo type, you can have an AMMO SYSTEM in your game!! Whenever they fire their weapon, one ammo item will be removed from their inventory, and if they don't have any bullets left, their gun will be removed from their hand!

Step 1 - Items
First you'll need 2 items. A weapon and a bullet. Let's make a weapon called "Bazooka". Change its stats and graphics to whatever you want, they won't affect the ammo system. Then make a normal item called "Missile". Remember the ID of each item, as you will need them later!!

Step 2 - A Character
Next, make a new hero/heroinne. Call him/her whatever you want and apply whatever attributes you want. Equip the Bazooka to this new character. (The item must be equippable to them!!) For the sake of this tutorial, I will name the character "Bob".

Step 3 - Variables
Now make 2 variables. Name one "Bob Weapon ID", and the other "Missile No". If you are using multiple bullet types (and probably weapons [e.g. a bow and arrows]), you will need one more variable per ammo type.

Step 4 - Battle Events
Create a new Monster Group and place any monsters you wish inside. (It'd be better if they are beatable!!) Create a new battle event with the condition "[Bob] uses command [Attack]". In the events tab, set the variable Bob Weapon ID that you made earlier to Bob's current weapon ID (under the Hero selection, "Weapon No."). Then create a fork condition to check whether that variable is equal to the ID of the Bazooka weapon item you created earlier. If so, assign the variable Missile No to the amount of Missiles carried. Then check if the amount of Missiles carried is 0 or below (specified in Rm2k3 as "below", NOT "less"). If so, unequip the Bazooka weapon item from Bob.

Extra Weapons and Ammo Types
If you want to include extra weapons and/or ammo types in your system, just make one more variable per extra ammo type. Then include an ELSE case in the first Fork Condition (the one checking that Bob's current weapon ID is equal to the first weapon). In that ELSE case, check that his weapon ID is equal to the second weapon - if so, check that the right amount of ammo for that weapon is available. If not, unequip the weapon. (E.g. Bob was not carrying a Bazooka, but he was carrying a Bow - but unfortunately, he had no Arrows left so the Bow was unequipped.) If you are using more than one weapon and/or ammo type, make sure that when you check how much ammo there is, make sure it is linked to the correct weapon. Otherwise, Bazookas could be firing Stones and Slingshots could be firing Missiles.

Thanks for reading this, and I hope it helps!



Click to Return to the Tutorials Page