RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

auto_mp_recover

Started by SirCumferance, April 15, 2011, 07:45:26 PM

0 Members and 1 Guest are viewing this topic.

SirCumferance

I have a script that can add abilities to armor and wanted to know if these look correct

  #--------------------------------------------------------------------------
  # * Perform Automatic Recovery (called at end of turn)
  #--------------------------------------------------------------------------
  def do_auto_recovery
    if auto_hp_recover and not dead?
      self.hp += maxhp / 20
    end
    if auto_mp_recover and not dead? #TESTING
      self.mp += maxmp / 20
    end
  end

  #--------------------------------------------------------------------------
  # * Get [Auto MP Recovery] Armor Option TESTING
  #--------------------------------------------------------------------------
  def auto_mp_recover
    for armor in armors.compact
      return true if armor.auto_mp_recover
    end
    return false
  end


I copied and pasted all other instances of auto_hp_recover and changed it to auto_mp_recover but I am still having some errors saying 'undefined method'
I have not learned the Roby language, but I am learning, snippet by snippet, how to alter some things.

modern algebra

Well, you need to define the auto_mp_recover method in the armors. Have you done that?

SirCumferance

I went to all Game_Actor and copied and re-pasted auto_mp_recover exactly like auto_hp_recover and such. I did give it to the armor but got a
'script 'pre/suf' line 329: no method error occured
undefined method 'auto_mp_recover' RPG::armor:ox16843o8

I went to Pre/Suf and found all instance of auto_hp_recover and made a copy for mp_recover but keep getting that error. I just assumed making a copy of something that already works would be easy, what gives?

modern algebra

The difference is that auto_hp_recover is already a method in RPG::Armor and auto_mp_recover is not.

Add the following:


class RPG::Armor
  def auto_mp_recover
    return self.note[/auto_mp/i] != nil
  end
end


Then, that should make it so that if you put:
auto_mp

into the notebox of any armor, then the rest will work.

SirCumferance

#4
I noticed that in the script I am using it seems to define that already.
class Armor
  alias oecs_epss_name name
  alias oecs_epss_description description
  alias oecs_epss_price price
  alias oecs_epss_atk atk
  alias oecs_epss_def def
  alias oecs_epss_spi spi
  alias oecs_epss_agi agi
  if OECS.constants.include?("Durability")
    alias oecs_epss_durability durability
  end
  alias oecs_epss_state_set state_set
  alias oecs_epss_element_set element_set
  alias oecs_epss_prevent_critical prevent_critical
  def prevent_critical
    if @identified
      return self.oecs_epss_prevent_critical
    else
      return self.mother_item.critical
    end
  end
  alias oecs_epss_half_mp_cost half_mp_cost
  def half_mp_cost
    if @identified
      return self.oecs_epss_half_mp_cost
    else
      return self.mother_item.critical
    end
  end 
  alias oecs_epss_double_exp_gain double_exp_gain
  def double_exp_gain
    if @identified
      return self.oecs_epss_double_exp_gain
    else
      return self.mother_item.critical
    end
  end 
  alias oecs_epss_auto_hp_recover auto_hp_recover
  def auto_hp_recover
    if @identified
      return self.oecs_epss_auto_hp_recover
    else
      return self.mother_item.critical
    end
  end
  alias oecs_epss_auto_mp_recover auto_mp_recover
  def auto_mp_recover
    if @identified
      return self.oecs_epss_auto_mp_recover
    else
      return self.mother_item.critical
    end
  end

Ah, there is no script for the RPG::Armor auto_hp thing is there? Is it built in?
Also, I am not sure the method that injects item abilities is not notebox driven. Can I just do

class RPG::Armor
   def auto_mp_recover
   end
end

so that it is defined, then alter game_actor and stuff to cause it to regen mp? I tried but it seems to not be working...my way, that is, not yours.

Edit: Also, if this is the kind of stuff you guys go through to script for us undeserving wretches, you guys deserve a cake.

modern algebra

OK, well I know nothing about that script which totally changes everything about armors (probably a good thing to mention when asking for help by the way) but the problem must be that the armors method of Game_Actor is still returning the default armor objects, not the special armor objects that the script you're using has. How you could fix that I am unsure without seeing the script, but look at the script you're using and see what edits it has made to the Game_Actor class, if any. It might be that which is causing the problem.

Also, yes, RPG::Armor is a hidden class, but you can see everything about it in the Help file

SirCumferance

Sorry about the surprise on the script, I got caught up in almost doing something. I think this is just beyond me, my reach exceeded my grasp.

Thanks modern algebra, for your response and help and for all the bomb scripts you write. Maybe one day I will understand half of what I think I do, but not now and certainly not today.