New account registration is temporarily disabled.

[RMVX ACE] SHARED HP AND MP

Posts

Pages: 1
So I wanted to create a battle system where all of the actors shared HP and MP, but I'm having troubles implementing it.

I figure you have to set variables equal to each actor's HP, and then add them up so you have the total, but I'm not sure how to display an HP bar with the total HP in it and hide the HP/MP of the actors.

If someone wanted to just write me a scriptlet and be done with it, I wouldn't complain~ However, general advice on how to do this would be appreciated too!
I haven't actually tested this, but this should cover most of it.
class Game_Unit
  attr_accessor :party_hp
  attr_accessor :party_mp

  alias gamUnit_initialize initialize
  def initialize
    gamUnit_initialize
    @party_hp = 0
    @party_mp = 0
    all_members.each {|aktor| @party_hp += aktor.hp; @party_mp += aktor.mp }
  end

  def refresh_party_hpmp
    temp = [0, 0]
    all_members.each {|aktor| temp[0] += aktor.hp; temp[1] += aktor.mp}
    @party_hp, @party_mp = temp
  end
end

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Determine if Cost of Using Skill Can Be Paid
  #--------------------------------------------------------------------------
  def skill_cost_payable?(skill)
    tp >= skill_tp_cost(skill) && (self.actor? ? $game_party.party_mp : $game_troop.party_mp) >= skill_mp_cost(skill)
  end
  #--------------------------------------------------------------------------
  # * Pay Cost of Using Skill
  #--------------------------------------------------------------------------
  def pay_skill_cost(skill)
    (self.actor? ? $game_party.party_mp : $game_troop.party_mp) >= skill_mp_cost(skill) -= skill_mp_cost(skill)
    self.tp -= skill_tp_cost(skill)
  end
end

To hide the HP/MP of actors, look in Window_BattleStatus, at the bottom part. Comment out the draw_actor_hp and draw_actor_mp lines.

To show party hp/mp, if you used the script above, you can access their values with: $game_party.party_hp & $game_party.party_mp.

If you want a quicker (but messier, and less flexible) way to it, you can make all skills target All enemies or All allies, and have them deal percentage damage to the targets based on their max HP. For costs, you can 'rig' it somehow, using multiple checks in the damage formula box, like: 'if sum_of_mp > requirement then hurt_them else dont_hurt_them end'
Hm, that doesn't seem to work for me.



Also, I see the word aktor a lot - is that another way to write actor? Will the maker accept that?

Another question: When this is working, how do I get the maker to draw the party's HP and HP gauge?
I was half asleep when I typed that up, sorry :(

Try replacing them with this:
class Game_Unit
  attr_accessor :party_hp
  attr_accessor :party_mp
  attr_accessor :party_mhp # added; realised you'll also need the max values...
  attr_accessor :party_mmp # added; realised you'll also need the max values...

  alias gamUnit_initialize initialize
  def initialize
    gamUnit_initialize
    @party_hp = 0
    @party_mp = 0
    @party_mhp = 0
    @party_mmp = 0
    # vv changed this (from all_members to battle_members)
    battle_members.each {|aktor| @party_mhp += aktor.mhp; @party_mmp += aktor.mmp; @party_hp += aktor.hp; @party_mp += aktor.mp }
  end

  def refresh_party_hpmp
    temp = [0, 0]
    # vv changed this (from all_members to battle_members)
    battle_members.each {|aktor| temp[0] += aktor.hp; temp[1] += aktor.mp}
    @party_hp, @party_mp = temp
  end
end

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Determine if Cost of Using Skill Can Be Paid
  #--------------------------------------------------------------------------
  def skill_cost_payable?(skill)
    result = tp >= skill_tp_cost(skill)
    # vv separated the 'is_actor?' check
    if self.actor? 
      return result && $game_party.party_mp >= skill_mp_cost(skill)
    else
      return result && $game_troop.party_mp) >= skill_mp_cost(skill)
    end
  end
  #--------------------------------------------------------------------------
  # * Pay Cost of Using Skill
  #--------------------------------------------------------------------------
  def pay_skill_cost(skill)
    # vv separated the 'is_actor?' check
    if self.actor? 
      $game_party.party_mp -= skill_mp_cost(skill)
    else
      $game_troop.party_mp -= skill_mp_cost(skill)
    end
    self.tp -= skill_tp_cost(skill)
  end
end

The 'aktor's are just stand-in variable names. It's used by the loop (battle_members.each) to refer to each existing unit in the party.

As for displaying it, I'm not sure how you'd want it to be shown. A separate window above the party status window? In the status window itself? A stand-alone sprite?

In any case, you should be able to draw it within windows using the draw_gauge method, with the values from $game_party.party_hp & $game_party.party_mp.

Here's a test to see if it's working. This will replace all the actor's hp and mp with the party's.
class Window_BattleStatus < Window_Selectable
  def draw_gauge_area_with_tp(rect, actor)
    #draw_actor_hp(actor, rect.x + 0, rect.y, 72)
    #draw_actor_mp(actor, rect.x + 82, rect.y, 64)
    hp_rate = $game_party.party_hp / $game_party.party_mhp
    mp_rate = $game_party.party_mp / $game_party.party_mmp
    draw_gauge(rect.x + 0, rect.y, 72, hp_rate, hp_gauge_color1, hp_gauge_color2
    draw_gauge(rect.x + 0, rect.y, 72, mp_rate, mp_gauge_color1, mp_gauge_color2
    draw_actor_tp(actor, rect.x + 156, rect.y, 64)
  end
  def draw_gauge_area_without_tp(rect, actor)
    #draw_actor_hp(actor, rect.x + 0, rect.y, 134)
    #draw_actor_mp(actor, rect.x + 144,  rect.y, 76)
    hp_rate = $game_party.party_hp / $game_party.party_mhp
    mp_rate = $game_party.party_mp / $game_party.party_mmp
    draw_gauge(rect.x + 0, rect.y, 72, hp_rate, hp_gauge_color1, hp_gauge_color2
    draw_gauge(rect.x + 0, rect.y, 72, mp_rate, mp_gauge_color1, mp_gauge_color2
  end
end

Edit: Really though. I'm not even sure if this will work seamlessly. Or at all. It's real messy...


Now I am getting this. I appreciate the help, by the way!

I'd want to display the HP/MP like the entire group was just one actor essentially - nothing fancy. The draw gauge method you suggested will most likely be fine!

Edit: I removed the parentheses in the line that gave an error and got this:

Pages: 1