- Joined
- May 16, 2012
- Messages
- 71
- Reaction score
- 25
- First Language
- English
- Primarily Uses
Hi everybody this is a simple script I had made by a friend on the old forums and now I've come to find I'm having slight issues with it.
The purpose of the script is to Check an Actor by ID, check out what weapon he has, based on that it checks for an item (the ammo) and the total of that item is output into a variable (that variable displays a gauge through another script, therefore this is my ammo bar.)
# Ammo Updater# by ???nOBodY???# Requested By: RevivalAMMO_HASH = {# WARRIOR key => [actorID, wpnID, ammoID, varID], "Raven" => [11, 1, 401, 777], "Raven" => [13, 1, 401, 777], }#Frames to wait before updatingUPDATE_DELAY = 90#==============================================================================# ** Game_Player#------------------------------------------------------------------------------# This class handles maps. It includes event starting determinants and map# scrolling functions. The instance of this class is referenced by $game_map.#==============================================================================class Game_Player < Game_Character #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias ammoGauge_initializer initialize def initialize ammoGauge_initializer @ammoCounter = 0 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- alias ammoGauge_updater update def update ammoGauge_updater if @ammoCounter >= UPDATE_DELAY for ammoType in AMMO_HASH.keys actor = $game_actors[AMMO_HASH[ammoType][0]] if actor.weapons.include?($data_weapons[AMMO_HASH[ammoType][1]]) if $game_party.has_item?($data_items[AMMO_HASH[ammoType][2]]) $game_variables[AMMO_HASH[ammoType][3]] = $game_party.item_number($data_items[AMMO_HASH[ammoType][2]]) else $game_variables[AMMO_HASH[ammoType][3]] = 0 end break end end @ammoCounter=0 end @ammoCounter+=1 endendThe problem itself is simple, I even left it in there configured as 'problematic' The issue is I have multiple actors who can use the same weapons - curiously though they are never in the party at the same time so I didn't expect this to conflict, this is a 1 player thing.
So the issue is if I have actor 11 out the game is still checking for ammo on actor 13 even though he isn't present at all. Since actor 13 is not even initialized nor does he have a weapon equipped this results in the gauge as always reading blank with no ammo even though Actor 11 does have it.
The purpose of the script is to Check an Actor by ID, check out what weapon he has, based on that it checks for an item (the ammo) and the total of that item is output into a variable (that variable displays a gauge through another script, therefore this is my ammo bar.)
# Ammo Updater# by ???nOBodY???# Requested By: RevivalAMMO_HASH = {# WARRIOR key => [actorID, wpnID, ammoID, varID], "Raven" => [11, 1, 401, 777], "Raven" => [13, 1, 401, 777], }#Frames to wait before updatingUPDATE_DELAY = 90#==============================================================================# ** Game_Player#------------------------------------------------------------------------------# This class handles maps. It includes event starting determinants and map# scrolling functions. The instance of this class is referenced by $game_map.#==============================================================================class Game_Player < Game_Character #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias ammoGauge_initializer initialize def initialize ammoGauge_initializer @ammoCounter = 0 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- alias ammoGauge_updater update def update ammoGauge_updater if @ammoCounter >= UPDATE_DELAY for ammoType in AMMO_HASH.keys actor = $game_actors[AMMO_HASH[ammoType][0]] if actor.weapons.include?($data_weapons[AMMO_HASH[ammoType][1]]) if $game_party.has_item?($data_items[AMMO_HASH[ammoType][2]]) $game_variables[AMMO_HASH[ammoType][3]] = $game_party.item_number($data_items[AMMO_HASH[ammoType][2]]) else $game_variables[AMMO_HASH[ammoType][3]] = 0 end break end end @ammoCounter=0 end @ammoCounter+=1 endendThe problem itself is simple, I even left it in there configured as 'problematic' The issue is I have multiple actors who can use the same weapons - curiously though they are never in the party at the same time so I didn't expect this to conflict, this is a 1 player thing.
So the issue is if I have actor 11 out the game is still checking for ammo on actor 13 even though he isn't present at all. Since actor 13 is not even initialized nor does he have a weapon equipped this results in the gauge as always reading blank with no ammo even though Actor 11 does have it.

