Main Menu
  • Welcome to The RPG Maker Resource Kit.

[RPG Maker VXAce] Enemy Start States

Started by apoclaydon, August 21, 2012, 11:58:18 PM

0 Members and 1 Guest are viewing this topic.

apoclaydon

i would like a script that allows you to define the starting states of enemies (like if you want an enemy to always be confused then you can add a note tag or add a table in the script that states that the enemy starts off with the confused state already in play

modern algebra

Haven't tried it, but is there any reason you couldn't just go into all the troops with the auto-stated enemies and make a battle event running at Turn 0 to apply the state to the enemies?

Alternately, maybe Yanfly's Passive Skills script would have a feature like that, though I haven't looked into that.

TDS

#2
This should do it.


#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemies. It used within the Game_Troop class
# ($game_troop).
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listing
  #-------------------------------------------------------------------------- 
  alias tds_enemy_starting_states_game_enemy_on_battle_start  on_battle_start
  #--------------------------------------------------------------------------
  # * Processing at Start of Battle
  #--------------------------------------------------------------------------
  def on_battle_start(*args, &block)
    # Run Original Method
    tds_enemy_starting_states_game_enemy_on_battle_start(*args, &block)
    # Match Enemy Notes for Starting States
    enemy.note[/<Starting_States: (.+)>/i]
    # Add Starting States if Match is not nil
    $1.split(/\s+/).each {|id| add_state(id.to_i)} if !$1.nil?
  end
end


Just add this to the enemy note box:


<Starting_States: state_id>


state_id is the ID of the state you want the enemy to start with. You can have as many ID's as you can fit, like so:


<Starting_States: 2 3 4 5 6 7 8 9 10 11>


Or


<Starting_States: 1>


Let me know if that works and if you want anything added/removed.

Have a nice day.

modern algebra

Looks good TDS! :) My only suggestion would be accomodate for more than one space between IDs by changing: $1.split(/\s/) to $1.split(/\s+/)

It literally makes no difference, as even as it is, the empty spots would just become 0s and when you try to add them as a state they will return false at state_addable?

Additionally, the collect is a bit redundant. It could equivalently be:

$1.split(/\s+/).each {|id| add_state(id.to_i)} if !$1.nil?

Anyway, neither of those comments are meaningful problems; it's a very smooth and efficient script.

TDS

Thanks, I always appreciate the advice. As for the collect, now that I see it I can't understand why I was using it in the first place, I must really be off my game.

apoclaydon

thank you and will try it out when i get home

apoclaydon