The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: SirCumferance on April 15, 2011, 07:45:26 PM

Title: auto_mp_recover
Post by: SirCumferance on April 15, 2011, 07:45:26 PM
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.
Title: Re: auto_mp_recover
Post by: modern algebra on April 15, 2011, 10:50:02 PM
Well, you need to define the auto_mp_recover method in the armors. Have you done that?
Title: Re: auto_mp_recover
Post by: SirCumferance on April 16, 2011, 06:52:35 AM
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?
Title: Re: auto_mp_recover
Post by: modern algebra on April 16, 2011, 01:00:45 PM
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.
Title: Re: auto_mp_recover
Post by: SirCumferance on April 16, 2011, 01:57:30 PM
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.
Title: Re: auto_mp_recover
Post by: modern algebra on April 16, 2011, 02:15:00 PM
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
Title: Re: auto_mp_recover
Post by: SirCumferance on April 16, 2011, 02:28:26 PM
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.