RE Weapon System II show ammunitions in custo menu

Howdy,

I'm currently using the RE Weapon System II as a battle system for my game, the game's HUD is very simple and is run by a separate script here.

Code:
#==============================================================================
# Resident Evil Like Weapons System
#==============================================================================
#------------------------------------------------------------------------------
# Créditos: Leon-S.K --- ou --- Andre Luiz Marques Torres Micheletti
#==============================================================================

#------------------------------------------------------------------------------
# HUD
#------------------------------------------------------------------------------
module Hud_Config
 
  #------------------------------------------------------------------------------
  # CONFIGURAÇÕES GERAIS
  #------------------------------------------------------------------------------
  Switch = 11        # Id da Switch que ativa\desativa a HUD
  Show_Key = :Z     # Tecla que mostra\esconde a HUD
  #------------------------------------------------------------------------------
  # Fim das Configurações
  #------------------------------------------------------------------------------
end
#==============================================================================
 
  #------------------------------------------------------------------------------
  # AREA NAO EDITAVEl!
  #------------------------------------------------------------------------------

class Hud < Window_Base
 
  attr_accessor :hp
  attr_accessor :mp
  attr_accessor :ammo
 
  def initialize
    super(0,0,250,300)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    @hp = $game_party.members[0].hp
    @maxhp = $game_party.members[0].mhp
    if $game_player.equipped_weapon != nil
      @ammo = $game_player.equipped_weapon.bullets
      @mags =  $game_party.item_number($game_player.equipped_weapon.magazine)
    end
    self.z = 999
    self.contents.font.color = Color.new(200,200,200)
    refresh
  end
 
  def refresh
    @hp = $game_party.members[0].hp
    @maxhp = $game_party.members[0].mhp
    if $game_player.equipped_weapon != nil
      @ammo = $game_player.equipped_weapon.bullets
      @mags =  $game_party.item_number($game_player.equipped_weapon.magazine)
    end
    @wb = 149 * @hp / @maxhp
    self.contents.clear
    self.contents.fill_rect(0,8,151,11,Color.new(49,0,0))
    self.contents.fill_rect(1,9,149,9,Color.new(0,0,0))
    self.contents.gradient_fill_rect(1,9,@wb,9,Color.new(89,0,0),Color.new(169,0,0))
    self.contents.draw_text(0,8,151,21," ",1)
    if $game_player.equipped_weapon != nil
      self.contents.draw_text(30,45,120,20,@ammo.to_s)
      draw_icon($game_variables[16], 5, 40)
      self.contents.draw_text(100,45,120,20,@mags.to_s) if not @mags.nil?
      draw_icon($game_player.equipped_weapon.iconset_id, 70, 40)
    end
  end
 
  def dispose
    super
  end
end

class Scene_Map < Scene_Base
 
  include Hud_Config
  attr_accessor :hud
    
  alias hud_start start
  def start
    hud_start
    if $game_switches[Switch] == true
      @hud = Hud.new
    end
  end
 
  alias hud_update update
  def update
    hud_update
    if Input.trigger?(Show_Key)
      $game_switches[Switch] ? $game_switches[Switch] = false : $game_switches[Switch] = true
    end
    if $game_switches[Switch] == true
      @hud.nil? ? @hud = Hud.new : refresh_hud
    else
      if not @hud.nil?; @hud.dispose; @hud = nil; end
    end
  end
 
  def refresh_hud
    @hud.refresh if $game_party.members[0].hp != @hud.hp or $game_party.members[0].mp != @hud.mp or @hud.ammo != $game_player.equipped_weapon.bullets
  end
 
  alias hud_terminate terminate
  def terminate
    @hud.dispose if @hud != nil
    hud_terminate
  end
end

What I would like to do is draw the ammout of ammos left in the gun ( that would be @ammo i guess) into a specific box in the "Equip" window in the menu, here:

upload_2018-8-17_21-3-32.png


this is the segmet of the script concerning the "equip window":

Code:
def create_Equip_window
    @Equip_window = Window_Base.new(475,183,165,48)
    @Equip_window.contents.clear
    if @actor.equips[0] != nil
      @Equip_window.draw_icon(@actor.equips[0].icon_index, 36, 0, true)
      @Equip_window.draw_text(0, -12 , 120, 48, RE_MENU::Equip)
      #INSERT CURRENT / REMAINING AMMO HERE?? # OTTO
      #@Equip_window.draw_text(10, 40 , 150, 50, @actor.equips[0].name)
    else
      @Equip_window.draw_text(0, -12 , 120, 48, RE_MENU::Equip)
    end

basically draw the @ammo number right after the weapon icon, lke this:

upload_2018-8-17_20-59-38.png


is this possible? if so, how can I do this?

Thanks in advance 🙂
Code:
@actor.equips[0].name

$game_player.equipped_weapon.bullets

Code:
@ammo = $game_player.equipped_weapon.bullets

@ammo is internal to HUD classes, which Equip_Window is not.

but since @ammo is in reality $game_player.equipped_weapon.bullets which is external to the Window class, you can read it from within the window by calling it over.

remember to double check for weapon AND bullets, just like it's done in the HUD class.

Code:
if $game_player.equipped_weapon != nil
 @ammo = $game_player.equipped_weapon.bullets
 @mags = $game_party.item_number($game_player.equipped_weapon.magazine)
end

you were not too far from the solution
@gstv87 thanks, that worked 🙂

upload_2018-8-17_23-44-54.png

Original thread: https://forums.rpgmakerweb.com/threads/re-weapon-system-ii-show-ammunitions-in-custo-menu.99034/