cozziekun's Earthboundish Odometer Script help!

ShinyRedUmbreon

Wannabe-Animator + Gamer
Veteran
Joined
Sep 3, 2017
Messages
61
Reaction score
12
First Language
English
Primarily Uses
RMVXA
On http://rmrk.net/index.php?topic=47693.0 is cozziekun's script for Earthbound. I got a image from somebody because the image there is corrupted. Anyways, I need to change the amount of odometer numbers from 4 to 3. In case you have no idea what I mean, look at this:

Because there are 4 numbers, it covers up some of the MP numbers(or in my case, PP)! Also my game is based off the SNES game, Earthbound. In there, it's almost the same thing, but 3 numbers. So that means changing 4 numbers for each HP and MP to 3 numbers solves 2 problems: The covering up some numbers problem, and the more to the game problem.

Can somebody help me? Here is the code:

Code:
#==============================================================================
# ** Earthbound-Ish Odometer Roll
#------------------------------------------------------------------------------
# Version: 1.0
# Author: cozziekuns
# Date: February 17, 2013
#==============================================================================
# Description:
#------------------------------------------------------------------------------
# This script attempts to emulate the battle system of the Earthbound/Mother
# series; most notably Earthbound and Earthbound 2 (Mother 2 and 3). This
# certain addon addresses the infamous HP/MP scrolling system that made battles
# that much more intense.
#==============================================================================
# Instructions:
#------------------------------------------------------------------------------
# Paste this script into its own slot in the Script Editor, above Main but
# below Materials. Edit the modules to your liking.
#==============================================================================
# Graphics:
#------------------------------------------------------------------------------
# You must have two Odometer pictures in your Graphics/System folder. One of
# them must be named "Odometer_HP", and the other one must be named
# "Odometer_MP". Obviously, they represent the odometer for HP and MP values,
# respectively
#==============================================================================

#==============================================================================
# ** Cozziekuns
#==============================================================================

module Cozziekuns
 
  module Earthboundish
    
    Odometer_Roll_Speed = 4 # Smaller speeds are faster than larger speeds.
    
  end
 
end

include Cozziekuns

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

class Game_Actor
 
  attr_accessor :odometer_hp
  attr_accessor :odometer_mp
 
  alias coz_ebisohd_gmactr_setup setup
  def setup(actor_id, *args)
    coz_ebisohd_gmactr_setup(actor_id, *args)
    @odometer_hp = 0
    @odometer_mp = 0
  end
 
  alias coz_ebishod_gmactr_execute_damage execute_damage
  def execute_damage(user, *args)
    if $game_party.in_battle
      on_damage(@result.hp_damage) if @result.hp_damage > 0
      @odometer_hp += @result.hp_damage
      @odometer_mp += @result.mp_damage
      user.hp += @result.hp_drain
      user.mp += @result.mp_drain
    else
      coz_ebishod_gmactr_execute_damage(user, *args)
    end
  end
 
  [:hp, :mp].each { |stat|
    alias_method("coz_ebishod_gmactr_item_effect_recover_#{stat}".to_sym, "item_effect_recover_#{stat}".to_sym)
    define_method("item_effect_recover_#{stat}".to_sym) { |user, item, effect|
      if $game_party.in_battle
        value = (send("m#{stat}".to_sym) * effect.value1 + effect.value2) * rec
        value *= user.pha if item.is_a?(RPG::Item)
        value = value.to_i
        @result.send("#{stat}_damage=".to_sym, @result.send("#{stat}_damage".to_sym) - value)
        @result.success = true
        send("odometer_#{stat}=".to_sym, send("odometer_#{stat}".to_sym) - value)
      else
        send("coz_ebishod_gmactr_item_effect_recover_#{stat}".to_sym, user, item, effect)       
      end
    }
  }
 
end

#==============================================================================
# ** Game_Enemy
#==============================================================================

class Game_Enemy
 
  def execute_damage(user)
    on_damage(@result.hp_damage) if @result.hp_damage > 0
    self.hp -= @result.hp_damage
    self.mp -= @result.mp_damage
    user.odometer_hp -= @result.hp_drain
    user.odometer_mp -= @result.mp_drain
  end
 
end

#==============================================================================
# ** Window_BattleStatus
#==============================================================================

class Window_BattleStatus
 
  def refresh_hpmp(actor, index)
    rect = item_rect(index)
    if gauge_area_rect(index) == item_rect(index)
      rect.y += line_height * 2
      rect.height -= line_height * 2
      contents.clear_rect(rect)
    else
      contents.clear_rect(gauge_area_rect(index))
    end
    draw_gauge_area(gauge_area_rect(index), actor)
  end
 
  [:hp, :mp].each { |stat|
    define_method("draw_actor_#{stat}".to_sym) { |actor, x, y, width|
      change_color(system_color)
      draw_text(x, y, 30, line_height, Vocab.send("#{stat}_a"))
      od_x = x + contents.text_size(Vocab.send("#{stat}_a")).width + 4
      actor_hp = actor.send("#{stat}".to_sym)
      actor_od_hp = actor.send("odometer_#{stat}".to_sym)
      draw_odometer(od_x, y, stat, actor_hp, actor_od_hp)
    }
  }
 
  def draw_odometer(x, y, type, value, od_value)
    bitmap = Cache.system("Odometer_#{type.upcase}")
    places = [1000, 100, 10, 1]
    od_ary = value.to_s.split("").collect { |str| str.to_i }
    (4 - od_ary.size).times { od_ary.unshift(0) }
    od_ary.each_index { |i|
      src_y = (9 - od_ary[i]) * 20
      if (od_ary.join.to_i) % places[i] == 0 and od_value != 0
        src_y += 20 / Earthboundish::Odometer_Roll_Speed * (Graphics.frame_count % Earthboundish::Odometer_Roll_Speed)
      end
      contents.blt(x + i * 24, y + 2, bitmap, Rect.new(0, src_y, 24, 20))
    }
  end
 
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
 
  alias coz_ebishod_scbtl_update_basic update_basic
  def update_basic(*args)
    coz_ebishod_scbtl_update_basic(*args)
    update_odometer
  end
 
  def update_odometer
    $game_party.members.each { |actor|
      if actor.odometer_hp != 0 or actor.odometer_mp != 0
        if actor.odometer_hp != 0 and Graphics.frame_count % Earthboundish::Odometer_Roll_Speed == 0
          damage = actor.odometer_hp > 0 ? 1 : - 1
          actor.hp -= damage
          actor.odometer_hp -= damage
        end
        if actor.odometer_mp != 0 and Graphics.frame_count % Earthboundish::Odometer_Roll_Speed == 0
          damage = actor.odometer_mp > 0 ? 1 : - 1
          actor.mp -= damage
          actor.odometer_mp -= damage
        end
        @status_window.refresh_hpmp(actor, actor.index)
      end
    }
  end
 
end
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
'Scripts' is where people who have written scripts they want to share with the community can post them.
[move]RGSSx Script Support[/move]
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
My first guess would be
od_x = x + contents.text_size(Vocab.send("#{stat}_a")).width + 4
change to 3.
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
246
Reaction score
70
First Language
English
Primarily Uses
RMVXA
Hm, that od_x = stuff line seems to be more like: position for odometer's x for HP/MP is where the original value starts, add 4 pixels, and widen this space for the stat's abbreviation (Health Points = HP), or in short, the starting point for draw_odometer.

Well, from what I can interpret from draw_odometer, there's two spots I would take care of: places is an array with four values for each digit, and you got a 4 - od_ary.size two lines down (unshift adds a new item to the beginning of an array, so a value of 30 at this point should be [0,0,3,0]. This stuff is then followed by an array that eventually draws that picture and that same array has 4 values, hence four digits.

Code:
  def draw_odometer(x, y, type, value, od_value)
    bitmap = Cache.system("Odometer_#{type.upcase}")
    places = [100, 10, 1]
     value = 999 if value > 999
    od_ary = value.to_s.split("").collect { |str| str.to_i }
    (3 - od_ary.size).times { od_ary.unshift(0) }
    od_ary.each_index { |i|
      src_y = (9 - od_ary[i]) * 20
      if (od_ary.join.to_i) % places[i] == 0 and od_value != 0
        src_y += 20 / Earthboundish::Odometer_Roll_Speed * (Graphics.frame_count % Earthboundish::Odometer_Roll_Speed)
      end
      contents.blt(x + i * 24, y + 2, bitmap, Rect.new(0, src_y, 24, 20))
    }
  end
Here we go. With 3 "digits" in the array now, I remove 1000 to be in sync with 3 digits and added another line just in case we're over 999 (because you don't have a pic for 10(0)(0)), though I do recommend you change param_max to ensure hp/mp values more than 999 are properly capped. I did this for you:

Code:
class Game_Actor < Game_Battler

def param_max(param_id)
  return 999 if param_id == 0  # MHP
  return 999 if param_id == 1  # MMP
  return super
end

end
 
Last edited:

ShinyRedUmbreon

Wannabe-Animator + Gamer
Veteran
Joined
Sep 3, 2017
Messages
61
Reaction score
12
First Language
English
Primarily Uses
RMVXA
Sorry, I couldn't find where to put the second code:
Code:
class Game_Actor < Game_Character

def param_max(param_id)
  return 999 if param_id == 0  # MHP
  return 999 if param_id == 1  # MMP
  return super
end

end
I put it at the end, creating a another category and it said this:
Capture.PNG
I checked that line, it was:
Capture.PNG
I checked and both Game_Actor and Game_Character were in the scriptlist. Notice how Game_Actor is blue and Game_Character is black. Does that mean anything? Sorry, I am a noob when it comes to scripting.
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
246
Reaction score
70
First Language
English
Primarily Uses
RMVXA
Oh, sorry, my bad there. Character is a class for the guys on the map, and Battler for the guys in the battle which Actor is a part of. It's actually:

class Game_Actor < Game_Battler

Edit: This does change the "size" from 4 digits to 3, but it doesn't shift the MP to the left. You want to change the draw_gauge_area (without tp judging by the picture) as that method determines where the HP and MP allocate their bars, or odometers in this case.

Code:
 class Window_BattleStatus
  def draw_gauge_area_without_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 0, rect.y, 134)
    draw_actor_mp(actor, rect.x + 120,  rect.y, 76)
  end
end
 
Last edited:

ShinyRedUmbreon

Wannabe-Animator + Gamer
Veteran
Joined
Sep 3, 2017
Messages
61
Reaction score
12
First Language
English
Primarily Uses
RMVXA
(Read the whole thing before commenting)

So I put the scripts and fixed the 2nd code. And it...

Didn't work.

But the problem said it expected end so I put one at the end(not a pun) of the 3rd code and it worked. Thank you so much Harosata!

Also thank you for trying to fix it even though that only changed the width Roninator2.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Glad it worked for you. My last comment was just a guess.
I played around with it some more cause I didn't like how for me it seem to cut off the digits a bit.
So in the battle core script I changed a section under Window_Battlestatus
Code:
  def window_width
    if $game_party.members.size == 1
      Graphics.width / ( 3.5 / $game_party.members.size.to_f )
    elsif $game_party.battle_members.size == 2
      Graphics.width / ( 3.8 / $game_party.members.size.to_f )
    elsif $game_party.battle_members.size == 3
      Graphics.width / ( 4 / $game_party.members.size.to_f )
    else
      Graphics.width
    end
  end
This would probably not work for you since you have a different layout for the display (which I was wondering how you got it to look like that? Luna engine?)
earthbound1.PNG earthbound2.PNG
 

ShinyRedUmbreon

Wannabe-Animator + Gamer
Veteran
Joined
Sep 3, 2017
Messages
61
Reaction score
12
First Language
English
Primarily Uses
RMVXA
I used font, window color and the scripts Harosata shown me.
 

ShinyRedUmbreon

Wannabe-Animator + Gamer
Veteran
Joined
Sep 3, 2017
Messages
61
Reaction score
12
First Language
English
Primarily Uses
RMVXA
Oh, sorry. So, I replaced line 136-149 with Harosata's first code. That changed it to 3 numbers. Then Harosata's second code I made a new category(obviously using comments) and pasted the code. RPG Maker notifed me that it didn't work. It turned out you had to replace Game_Character with Game_Battler. That made it so if the HP tried to go over 999 HP, it would not work. Harosata's third script, was to shift the MP to the left. There was nothing like that in the script already, so that meant I had to create a new category(again, I used comments) and pasted the code there.

So that was it. What I'd like to know is how you got that Mother 3 Core Battle Script to work. PM me cause this thread was only for the odometer problem.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top