Change the EXP to Current weapon (Blizz Abs) Script help

Started by Cal RPG MGS, April 07, 2011, 09:26:12 am

Previous topic - Next topic

Cal RPG MGS

Game:RPG XP
Blizz ABS: 2.8

I post a topic on RRR on how to change the EXP Meter on the HUD To the current Weapon and it Works but there are to problems.
The person who help me said there may be error but he was un sure of what they would be.

The first One is; when you use the quick weapon change, the name of the weapons over lap each other and do not replace.

the only work around i have to this is to keep going on to the menu to make it refresh

The Second one is if you do not have a weapon equip it causes the game to crash with the error message;
Line 49: NoMethodError occurred
undefined method 'name' for nil:NilClass

This is the edited script

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

if !$BlizzABS || BlizzABS::VERSION < 2.7
  raise 'ERROR: The "EXP in HUD" requires Blizz-ABS 2.7 or higher.'
end

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# word displayed for EXP
EXP_WORD = 'WPN'

#==============================================================================
# Hud
#==============================================================================

class Hud
 
  alias create_positions_expinhud_later create_positions
  def create_positions
    create_positions_expinhud_later
    @exp_x, @exp_y = 4, 49# + @hud_height - @original_height
    @hud_height += 16
    @hot_y += 16
    @left_y += 16
  end
 
  alias draw_basic_expinhud_later draw_basic
  def draw_basic
    draw_basic_expinhud_later
    color = case BlizzABS::Config::HUD_TYPE
    when 0 then Color.new(255, 255, 255, 192)
    when 1 then Color.new(0, 0, 0, 0)
    end
    self.bitmap.fill_rect(@exp_x+32, @exp_y+3, 116, 14, color) if color.is_a?(Color)
    self.bitmap.fill_rect(@exp_x, @exp_y, 32, 20, Color.new(0, 0, 0, 128))
    self.bitmap.font.color = system_color
    self.bitmap.draw_text_full(@exp_x, @exp_y, 80, 20, EXP_WORD)
    self.bitmap.font.color = normal_color
  end
 
  def draw_empty
    return
  end
 
  def draw_exp
    self.bitmap.font.color = normal_color
    self.bitmap.draw_text_full(@exp_x + 54, @exp_y, 84, 20, $data_weapons[$game_party.actors[0].weapon_id].name, 2)
  end
 
  alias upd_expinhud_later update
  def update
    redraw_weapon = ($game_temp.hud_refresh |= test_refresh)
    upd_expinhud_later
    draw_exp if redraw_weapon
  end
 
  def test_refresh
    @lastWeaponID = -1 if @lastWeaponID.nil?
    needs_refresh = @lastWeaponID != $game_party.actors[0].weapon_id
    @lastWeaponID = $game_party.actors[0].weapon_id
    return needs_refresh
  end

end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=



nathmatt

def draw_exp
    self.bitmap.font.color = normal_color
    self.bitmap.fill_rect(@exp_x + 54, @exp_y, 84, 20, Color.new(255, 255, 255, 192))
    self.bitmap.draw_text_full(@exp_x + 54, @exp_y, 84, 20, $data_weapons[$game_party.actors[0].weapon_id].name, 2)
  end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Cal RPG MGS

Thanks nathmatt  :D

Thats Solves the first problem, just the No weapon crash problem now :D

Spaceman McConaughey

You don't seem to have a steady flow of Uranium going to your Flux Capacitor. Fix that, and you should be good. ;)

ForeverZer0

For the second problem, replace the "draw_exp" method with this::


  def draw_exp
    self.bitmap.font.color = normal_color
    wpn = $data_weapons[$game_party.actors[0].weapon_id]
    self.bitmap.draw_text_full(@exp_x + 54, @exp_y, 84, 20, wpn == nil ? 'None' : wpn.name, 2)
  end


The problem is, having no weapon equipped is the 0 index of $data_weapons, which is nil. NilClass doesn't have a "name" paramter to call. Using this little edit will show the word "None" when this occurs.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Cal RPG MGS

April 08, 2011, 07:17:30 am #5 Last Edit: April 08, 2011, 07:28:47 am by Cal RPG MGS
And now i will also thank ForeverZer0, that has saved a massive event based work around  :D

not sure how Tuggernuts post helps but i made me lol.

thanks for the help people.

---EDIT---

if i credit Nathmatt and ForeverZer0 would i be able to post this in the script database, i will say it was originaly created by Blizzard.

it just seems like a very used script(well for me it is and i have seen other requests) and i don't want it to die in time