A Small Reminder about Array Iteration
Alright, let this post remind me at times I forget this thing.
I've been developing an RPG project lately. At present I wanted to modify the equip screen. I've added a new equip slot (ammunition) using Yanfly's Ace Equip Engine. By the time the user selects a projectile weapon, I want them to select an ammunition from their inventory list.
The ammunition list shown will correspond to the equipped weapon (you won't get a list of handgun bullets if you're equipping a bowgun). The following method is to remind me to check weapon IDs whether they're a projectile weapon or not.
=beginThe projectile weapon IDs are 5, 29, 6, 8, 30, 7, 9, 10, 11, 24.We create a method to check the weapon ID and return true if the weapon is a projectile weapon.=endclass Window_EquipItem < Window_ItemList def projectile?(weapon) return false unless weapon.is_a?(RPG::Weapon) result = false [5, 29, 6, 8, 30, 7, 9, 10, 11, 24].each do |x| result = true if (weapon.wtype_id == x) end return result endend
At present, the capabilities are:
- Able to equip projectile weapons that uses ammunition.
- The ammunition is defined as armors in the database, but will later be ammunition in-game using Yanfly's Ace Equip Engine's note-tagging.
- There's a corresponding item at the database. An example works best.
- Suppose we're equipping a bowgun.
- The ammunition equipped is a set of birch bolts.
- There is a 'birch bolt' item in the database entry.
- Each time the bowgun is fired, one 'birch bolt' will be lost.
- The attack will fail if we're running out of ammunition, and a corresponding message will be shown.
[*]Each weapon has a new 'weapon power' parameter written in the note box by note-tagging (I wrote the code for implementing weapon power). The damage formula will use the weapon power in conjunction with the actor's statistics.
- Suppose we're equipping a bowgun.
I'll post something when this project is starting to make sense.
-
1



2 Comments
Recommended Comments