Main Menu
  • Welcome to The RPG Maker Resource Kit.

Auto-states while armor is equipped

Started by zerothedarklord, October 27, 2011, 06:07:52 AM

0 Members and 1 Guest are viewing this topic.

zerothedarklord

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)

pacdiggity

#1
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
it's like a metaphor or something i don't know

zerothedarklord

#2
# 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>

pacdiggity

Change combat in line 26 to compact.
*facepalms self*
it's like a metaphor or something i don't know

zerothedarklord

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.

pacdiggity

What else was wrong with that line? Everything else looks fine to me.
it's like a metaphor or something i don't know

LoganF

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'.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

pacdiggity

Oh yeah. Them.

*learns English*
*fixes line*
it's like a metaphor or something i don't know

zerothedarklord

now if I could just get my other requests fulfilled.....