Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Percentile for Exp

Ikarru

Member

Much like the exp bars for mmorpgs. If it is possible for someone to direct me or make a script for me that allows this.
All that I ask is for a script that changes the X/X exp value to the percent complete.
Say instead of the exp saying 25/50, it says 50%

Is there a script that gives that or can someone make me one?
 
Insert below Window_Base like anywhere:
Code:
#==============================================================================
# ** Draw HP, SP & Exp With Percents By SephirothSpawn
#==============================================================================

#==============================================================================
# ** Window_Base
#==============================================================================

class Window_Base
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Draw "HP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # Gets Percent
    p = Integer(actor.hp / actor.maxhp.to_f * 100)
    p = "#{p} %"
    # Draw HP
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    pw = self.contents.text_size(p).width
    self.contents.draw_text(x + width - pw, y, pw, 32, p, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Draw "SP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # Gets Percent
    p = Integer(actor.sp / actor.maxsp.to_f * 100)
    p = "#{p} %"
    # Draw SP
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    pw = self.contents.text_size(p).width
    self.contents.draw_text(x + width - pw, y, pw, 32, p, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw EXP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_exp(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 24, 32, "E")
    self.contents.font.color = normal_color
    s = "#{actor.next_exp_percent} %"
    self.contents.draw_text(x + 24, y, 180, 32, s)
  end
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor
  #--------------------------------------------------------------------------
  # * Get Next Exp Percent
  #--------------------------------------------------------------------------
  def next_exp_percent
    lst = @exp_list[@level] > 0     ? @exp_list[@level]     : 0
    nxt = @exp_list[@level + 1] > 0 ? @exp_list[@level + 1] : 0
    rst = nxt - @exp
    begin
      return 100 - Integer( rst.to_f / (nxt - lst) * 100 )
    rescue
      return 100
    end
  end
end

That should do the trick.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top