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.

Auto Life

I just joined. Hiya.

I've been trying to create a skill similar to Auto Life from Final Fantasy. I just set up a simple common event, and it works perfectly, except when the character with the Auto Life state is the last/only character in battle. I know that the party dying takes precedence over everything else, and I was wondering if there was a simple workaround for this.

Thanks in advance.
 
I tried the script you listed above, but I keep receiving an error message every time a battle begins.


Script 'Scene_Battle 1' line 106: NoMethodError occurred.
undefined method 'states' for #<Array:0x13f3198>


I'm familiar with coding, but not scripts in RMXP, so I'm kind of at a loss with how to fix this.
 
I took the liberty of telling trickster to make an Auto Life script for you, so here it is:

Code:
module Auto_Life
  #--------------------------------------------------------------------------
  # * Skills
  #     syntax - skill_id => [amount, percentage, animation]
  #--------------------------------------------------------------------------
  Skills = {81 => [1, 0, 25]}
end

class Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :autolife
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias_method :trick_autolife_battler_initialize, :initialize
  def initialize
    trick_autolife_battler_initialize
    @autolife = false
  end
  #--------------------------------------------------------------------------
  # * Skill Effect
  #--------------------------------------------------------------------------
  alias_method :trick_autolife_battler_skill_effect, :skill_effect
  def skill_effect(user, skill)
    effective = trick_autolife_battler_skill_effect(user, skill)
    if Auto_Life::Skills.include?(skill.id) and not @autolife
      @autolife = Auto_Life::Skills[skill.id]
      effective = true
      @damage = ''
    end
    return effective
  end
end

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Main
  #--------------------------------------------------------------------------
  alias_method :trick_autolife_battle_main, :main
  def main
    $game_party.actors.each {|actor| actor.autolife = false}
    trick_autolife_battle_main
  end
  #--------------------------------------------------------------------------
  # * Update Phase 4 Step 6
  #--------------------------------------------------------------------------
  alias_method :trick_autolife_battle_update_phase4_step6, :update_phase4_step6
  def update_phase4_step6
    trick_autolife_battle_update_phase4_step6
    @target_battlers.each do |target|
      next if target.exist? or not target.autolife
      amount, percentage, animation = target.autolife
      target.remove_state(1, true)
      target.hp = amount + percentage * target.maxhp / 100
      target.damage = 'Auto-Life'
      target.animation_id = animation
      target.damage_pop = true
      target.autolife = false
      end
  end
end

Note these lines:

Code:
#--------------------------------------------------------------------------
  # * Skills
  #     syntax - skill_id => [amount, percentage, animation]
  #--------------------------------------------------------------------------
  Skills = {81 => [1, 0, 25]}
end
First set up your skill as usual, then get the skill id. Amount is the amount to restore, percentage is the percentage to restore, and animation is the animation displayed when they are revived. So what If I want a skill (id 82) to heal 10% hp + 10 hp with animation 26. You would add on to the hash like this:
Skills = {81 => [1, 0, 25], 82 => [10, 10, 26]}

So, remove the script I linked you earlier, and use this instead. And remember to credit Trickster. =)
 
Wow! That worked perfectly. Thanks a lot!

::credits Trickster::

EDIT: I was also wondering how simple it would be for this script to work with a state instead of a skill. (I'm not asking somebody to write a script out for me again-- that was great, though.)
 
This topic has been resolved. If Squieonat or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 

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