The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: zerothedarklord on October 27, 2011, 06:07:52 AM

Title: Auto-states while armor is equipped
Post by: zerothedarklord on October 27, 2011, 06:07:52 AM
I would like to get a script made that allows, through the use of note tags to equipment (weapons and armor) to automatically inflict a state when equipped, and remove the state when the item is unequipped. Example:

an Accessory that allows auto-health regeneration:

<auto-state X>    (X being the state ID) (state X being the regeneration state)

I did actually find a script that allowed for this, but it was inside of one of the yanfly scripts and it was added into another huge script that modified a ton of stuff that I didn't want. So I'm requesting a script that JUST does this (even if someone can simply pull it from the existing yanfly script)
Title: Re: Auto-states while armor is equipped
Post by: pacdiggity on October 27, 2011, 07:01:42 AM
This should do it.
# Put <autostate: x> where x is the ID of a state in the notebox of an eqiup to
# make the state

class RPG::BaseItem
  def auto_state
    return if self.is_a?(RPG::Skill) || self.is_a?(RPG::Item)
    return @auto_state if !@auto_state.nil?
    @auto_state = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:AUTOSTATE|auto state|AUTO_STATE):[ ](\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each { |num|
          @auto_state << $data_states[num.to_i] if num.to_i > 0
        }
      end
    }
    return @auto_state
  end
end

class Game_Battler
  alias pac_as_ga_states states
  def states
    list = pac_as_ga_states
    if actor?
      for equip in equips.compact do list |= equip.auto_state end
    end
    return list.uniq
  end
end
Title: Re: Auto-states while armor is equipped
Post by: zerothedarklord on October 27, 2011, 05:26:47 PM
# Put <autostate: x> where x is the ID of a state in the notebox of an eqiup to
# make the state

class RPG::BaseItem
  def auto_state
    return if self.is_a?(RPG::Skill) || self.is_a?(RPG::Item)
    return @auto_state if !@auto_state.nil?
    @auto_state = []
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when /<(?:AUTOSTATE|auto state|AUTO_STATE):[ ](\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each { |num|
          @auto_state << $data_states[num.to_i] if num.to_i > 0
        }
      end
    }
    return @auto_state
  end
end

class Game_Battler
  alias pac_as_ga_states states
  def states
    list = pac_as_ga_states
    if actor?
      for equip in equips.combat do list |= equip.auto_state end
    end
    return list.uniq
  end
end


"Line 26: NoMethodError occured.
undefined method 'combat' for #<Array:0x2c9bb49>
Title: Re: Auto-states while armor is equipped
Post by: pacdiggity on October 27, 2011, 07:43:01 PM
Change combat in line 26 to compact.
*facepalms self*
Title: Re: Auto-states while armor is equipped
Post by: zerothedarklord on October 27, 2011, 08:59:20 PM
lol, it's fine man, I looked close and you misspelled like half of line 26 so I had to change it. I'd imagine you were probably in a hurry when you wrote it.

But yeah, thanks for checking back, that did it. Thanks again.
Title: Re: Auto-states while armor is equipped
Post by: pacdiggity on October 28, 2011, 11:09:22 AM
What else was wrong with that line? Everything else looks fine to me.
Title: Re: Auto-states while armor is equipped
Post by: LoganF on October 28, 2011, 12:39:51 PM
for eqiup in equips.compat do list |= equip.auto_state end

'equip' is spelled wrong - you put 'eqiup'

It also now says 'compat' instead of 'compact', but at least it's a little more closer than 'combat'.
Title: Re: Auto-states while armor is equipped
Post by: pacdiggity on October 28, 2011, 10:58:35 PM
Oh yeah. Them.

*learns English*
*fixes line*
Title: Re: Auto-states while armor is equipped
Post by: zerothedarklord on October 29, 2011, 08:06:47 PM
now if I could just get my other requests fulfilled.....