Thatsothoth 4 Posted September 17, 2016 This system allows you to create weapons with unique ammo, and unique magazine sizes. It could be used with bows etc. as well. Just say it’s a quiver instead of a magazine, or alter it to take arrows directly out of inventory as they are fired. Disclaimers:-Probably there are numerous ways of doing this. This is just one possible solution.-I’m not a scripter. Suggestions from people who are would be welcome.-I haven’t tried this with dual wield. Or rather, I have, but it’s with a single actor game and required several messy script edits. And more scripts altogether. Probably it could be done by checking if $game_actors[x].slot_id (is this right?) is 0 or 1. Probably have to set the slot id to a variable in change_equip.-The ammo display is just the number in parentheses by the actor’s name. Getting something better would require more complicated scripting. Any kind of variable hud should work.-This is only my second post ever. DEMO SCRIPTS: HIME:Scene Interpreter Equip Events Item Stack Size Common Event Variables Custom Use Conditions Yanfly:Follow Up Skill Anti-fail Weapon Attack Replace PK8:Weapon Self Data Kread:No Battle Log Also this little tidbit: class Scene_Battle < Scene_Base attr_accessor:log_window end I’m not sure where I got it or who to credit. Anyone? VARIABLES: 2 of the variables are arrays. Check here http://www.rpgmakercentral.com/topic/17574-intermediateadvanced-game-variables/ for a detailed explination of arrays. The array indexes correspond to the actor id’s (index 0 is a dummy). We check the array to see how many rounds are in the current actor's magazine as well as to add rounds during reload and subtract when firing. Initialize the arrays using a one run parallel process: For me the easiest way is to have an entry for all actors even if they will never use guns. All of them are initialized to -1 which means no actor begins the game with a gun equipped. The other array is initialized with the id numbers of the starting weapons of all actors. We use this in the dequip event that checks to see if the weapon that was just dequipped needs to have its rounds returned to the available inventory of ammo. These two lines: weapon_self_variable(9, "mag_size", 11, 0) weapon_self_variable(12, "mag_size", 5, 0) Use the weapon self data script to give our guns magazine capacities. 9 stands for weapon id 9 (9mm), 12 is weapon id 12 (12 gauge). There’s a detailed explanation of how it works in the Weapon Self Variable script. Here's the 9 mil: Note the equip and dequip tags. All weapons, including non-guns, should have both tags. The ammo: The ammo has the same id as the weapon that its for. If you want different guns to use the same ammo, you can use weapon self variables to set what type of ammo a gun requires instead of having to match id’s. You could also use Weapon Types to designate caliber. Each ammo item is linked to a common event so that using it will reload a weapon in combat, but getting it to work from the menu isn’t something I’ve had success with. Hime’s Custom Use Conditions (<use conditions> weapon: 9 </use conditions>) ensures that only those with the proper weapon can use the ammo. The reload skill can be used both in and out of battle. SKILLS: Reload, Ammo Check and Shoot. Reload is set up as a Special skill that can be used anytime an actor has a gun equipped. Ammo Check is the skill that is called by the weapon’s attack as directed by the weapon’s notetag through Yanfly’s Weapon Attack script. This bit from the Ammo Check skill’s notebox: <follow up eval> $game_variables[1][$game_temp.common_event_user.id] > 0 </follow up eval> checks the magazine array to see if the actor has a loaded gun. If so, <follow up 6> will use Yanfly’s Follow Up Skill script to call skill 6 which is the actual gun attack. Skill 6 also calls a common event which will subtract a round from the actor’s magazine. If the <follow up eval> shows the magazine to be 0, skill 6 will not be called, and skill 5’s common event will do a reload and say so in the log (thanks to attr_accessor:log_window). COMMON EVENTS: Reload, Equip and Dequip need the <run scene: current> comment so they will run instantly without having to exit the menu. Hime’s Scene Interpreter script uses this tag. Equip and Dequip use $game_variables[10] as the actor id, and the attack events (check ammo and use ammo) use $game_variables[7]. v[10] is assigned in the Scene_Equip script (see below) and v[7] is assigned the value of Hime’s $game_temp.common_event_user.id which doen’t seem to work for equip events, only skill events. And item events. Reload uses v[7] as well. The equip event shown gets the Weapon Type and if it’s 2 (a gun), it assigns the weapon id which is the same as the ammo item id to a variable and assigns the quantity in inventory to a variable then gets the weapons mag capacity: $game_variables[5] = weapon_self_variable($game_variables[3], "mag_size") Then it either fills the mag or puts as many rounds as available into the mag and subtracts the amount from inventory. If the type comes back as other than type 2 in the original condition, it assigns -1 to the mag. The last conditional is normally handled by the dequip event, but if the actor had nothing equipped, dequip will not have run so we will need to put the new weapon into the old weapon array. It may not be the old weapon yet, but it will be as soon as the weapon is changed and we will need it to see if ammo needs to be put back into inventory. This part: SceneManager.scene.create_status_window Is the only way I’ve been able to get the status window to update instantly. Though it obviously actually creates one. Suggestions from scripters? SCRIPT EDITS: BattleManager: line 168 right under def self.battle_start I inserted: $game_switches[1] = true And line 270 right under def self.battle_end(result) I inserted: $game_switches[1] = false This is just a simple way of keeping track of whether or not the current scene is a battle scene or not. If not, the actor’s status needs updating to reflect ammo changes. As with everything, I’m open to suggestions for a better way to do this. Window_Base: Starting at line 440 I changed: def draw_actor_name(actor, x, y, width = 112) change_color(hp_color(actor)) draw_text(x, y, width, line_height, actor.name) end To: def draw_actor_name(actor, x, y, width = 112) change_color(hp_color(actor)) if $game_variables[1][actor.id] > -1 # gun equpped? ammo = "(" + $game_variables[1][actor.id].to_s + ")" #create ammo display show_name = actor.name + ammo else show_name = actor.name end draw_text(x, y, width, line_height, show_name) end This displays the amount of ammo a character has in their magazine, but only if they have a gun equipped in which case $game_variables[1][actor.id] will be 0 or higher. Scene_Equip: Line 18 right under create_item_window I inserted: $game_variables[10] = @actor.id This makes sure we have the correct actor id for for the equip and dequip common events. Line 144 right under @command_window.activate I inserted: $game_variables[10] = @actor.id In case the player switches actors from within the equip screen. Note: If your using other scripts such as Yanfly Engines you’ll have to make the script changes in these other scripts. If the methods are overwritten. I think. I’m not a scripter. Share this post Link to post Share on other sites