Adding more conditions to enemy action patterns!!!

Today i've been messing with the database trying to make the AI of the enemies less vanilla, so for example I want a specific skill to be usabled only if the enemy have a state, and if it is under certain HP%. The problem is that the database only allows me to select one. Giving more priority would make the skill usable right away (as i can see with the default system), so may be something with enemy notetags can help me. I checked VE- Enemy Action Conditions, but I don't want to have his basic module running on my game (compatibility problems as always).

Does any body knows of an alternative script to this one? or can make this for the community please?  :|
If that script will do what you need it to, you could just check WHAT parts of the basic module are required - you might be lucky to find it only needs one or two modules and you can remove the rest.
thaks, I will try to do that and edit if I can't manage to do it by myself
you could also try removing the victor code to warn you it require basic module. since some of his script don't actually need basic module at all. 😀 . some need only few lines of code.
Have you thought of doing part of this with a custom formula in the skill?  A bit tedious to set up, as it would require more than one state to be created, but if nothing else works it might be worth trying.  Something like this:

a.state?(29)?:b.add_state(49):b.add_state(32);

where state 29 is the one you want to control the whole thing.  If state 29 is present, then it adds state 49 which calls up the skill with the HP condition.  If it is not present, it adds state 32 which calls up a dummy skill which does nothing.

EDIT

Error in formula - see my post below
Have you thought of doing part of this with a custom formula in the skill?  A bit tedious to set up, as it would require more than one state to be created, but if nothing else works it might be worth trying.  Something like this:

a.state?(29)?:b.add_state(49):b.add_state(32);

where state 29 is the one you want to control the whole thing.  If state 29 is present, then it adds state 49 which calls up the skill with the HP condition.  If it is not present, it adds state 32 which calls up a dummy skill which does nothing.
sounds as a good alternative but some of this enemy skills are from the actor class pool too, so I'm not quite sure how they will behave, anyway I'll check Victor code and this back on morning 12:44 am here.
sounds as a good alternative but some of this enemy skills are from the actor class pool too, so I'm not quite sure how they will behave, anyway I'll check Victor code and this back on morning 12:44 am here.
You might need to set up an enemy version of the skill separate from the actor skill.  As the game recognises the skill ID number, not the name, it won't matter if the name is a duplicate.

IMPORTANT EDIT

I was copying my formula from a skill I use, which determines whether the enemy gets hit with one state or another, and although I remembered to change the first b. to a., I forgot to do the rest.  The formula should read:

a.state?(29)?:a.add_state(49):a.add_state(32);
You might need to set up an enemy version of the skill separate from the actor skill.  As the game recognises the skill ID number, not the name, it won't matter if the name is a duplicate.

IMPORTANT EDIT

I was copying my formula from a skill I use, which determines whether the enemy gets hit with one state or another, and although I remembered to change the first b. to a., I forgot to do the rest.  The formula should read:

a.state?(29)?:a.add_state(49):a.add_state(32);
 before your edit: derp, I'm doing this since I'm really trying to avoid duplicates on database by all means, take that as a mini goal on my project.

after edit: Sorry but I didn't understand that too much  :blush:

@Estriole: I removed the part that check for the basic module and many stuff from the header that I don't really care about, but now I have the following error:

Script 'VE Enemy Actions Conditions' line 172: NameError Ocurred.

undefined method 'conditions_met?' for class

'Victor_Engine::Game_Enemy'
 And here is a spoiler with the edited script.

Note:Since Victor terms says that we can Share a like I don't see a problem posting this here:

Spoiler
 
Code:
#==============================================================================# ** Victor Engine - Enemy Actions Conditions v 1.03#------------------------------------------------------------------------------# Author : Victor Sant#------------------------------------------------------------------------------#  This script allows the creation of custom conditions for enemies actions.# Different from the default RPG Maker VX behavior, you can set more than one# condition for the actions. It also give some extra conditions not avaiable# by default.#------------------------------------------------------------------------------# * Alias methods#   class Game_Enemy < Game_Battler#     def initialize(index, enemy_id)#     def conditions_met?(action)#     def action_valid?(action)#------------------------------------------------------------------------------# Enemies note tags:#   Tags to be used on the Enemies note box in the database#  #  <enemy action: x, y>#  conditions;#  </enemy action>#    Setup the action ID, rating and conditions.#      x : skill ID#      y : skill rating, a value between 1-10##    Conditions: conditions that must be met to for the action to be used#      the conditions can be status based or a custom script call#      you can add how many values you want always separating them with a ;#      at the end. Script calls can have multiple lines, just add the ; at#      the end of the last line of the condition.##    stat higher x;      stat equal x;#    stat higher x%;     stat equal x%;#    stat lower x;       stat different x;#    stat lower x%;      stat different x%;#      The action condition will be valid if the stat set meets the#      condition when compared with value y. You can use any stat#      available for the battler,   even custom ones.#        stat : stat name (maxhp, maxmp, maxtp, hp, mp, tp, atk, def, mat...)#        x    : value (can be evaluted), % value can only be used with#               the stats "hp", "mp" and "tp"#    turn: x*;#      The action condition is valid if the turn count is equal the one set.##    turn: x + x*;#      the value x* means tuns multiple of x.##------------------------------------------------------------------------------# Additional instructions:##  Settings from versions previous to 1.02 will not work properly##  *ALL* conditions must be met in order for the action be available for use.#  The game still choose the action randomly based on the action rating,#  so this will not ensure that the action will be used always when the#  condition is met.##------------------------------------------------------------------------------# Example Actions:# #  <enemy action: 26, 8>#  hp lower 50%;#  turn 4*;#  </enemy action>#   Use action ID 26 if the HP is lower than 50% on the fourth turns with very#   high frequency (rating 8)##  <enemy action: 31, 6>#  state?(2);#  </enemy action>#   Use action ID 31 when under the state ID 2##------------------------------------------------------------------------------# Useful script calls:#   Here some useful script calls that can be used:##   state?(x)#    checks if the battler is under state ID x##   state_addable?(x)#    checks if the state ID x can be added (to avoid adding the state if the#    battler is immune)# #   $game_swiches[x]#    checks if game swicth ID x is ON##   $game_variables[x]#    you can use this to compare the variable ID x with any value (be sure to#    to add the comparision sign and the value)##   rand(100) > x#    to make a % chance user rand(100) < x, where x is the % chance# #   you can also use || for "or" and && for "and"#     state?(1) || state?(2) # if state 1 or state 2 is added#     state?(1) && state?(2) # if  boths state 1 and state 2 are added#   #   you can also add a ! in front of the condition to make the opposite check#     !state?(2)         # if state 2 is NOT added#     !$game_switches[3] # if Switch 3 is OFF##==============================================================================#==============================================================================# ** Victor Engine#------------------------------------------------------------------------------#   Setting module for the Victor Engine#==============================================================================module Victor_Engine#==============================================================================# ** RPG::Enemy#------------------------------------------------------------------------------#  This is the data class for enemies.#==============================================================================class RPG::Enemy  #--------------------------------------------------------------------------  # * New method: init_custom_actions  #--------------------------------------------------------------------------  def init_custom_actions    regexp = get_all_values("ENEMY ACTION: (\\d+), *(\\d+)","ENEMY ACTION")    note.scan(regexp) do |id, rating|      action = RPG::Enemy::Action.new      action.skill_id = id.to_i      action.rating   = rating.to_i      action.condition_type = :custom      @actions.push(action)    end  endend#==============================================================================# ** RPG::Enemy::Action#------------------------------------------------------------------------------#  This is the data class for enemies actions.#==============================================================================class RPG::Enemy::Action  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_accessor :index  #--------------------------------------------------------------------------  # * New method: custom?  #--------------------------------------------------------------------------  def custom?    @condition_type == :custom  endend#==============================================================================# ** Game_Enemy#------------------------------------------------------------------------------#  This class handles enemy characters. It's used within the Game_Troop class# ($game_troop).#==============================================================================class Game_Enemy < Game_Battler  #--------------------------------------------------------------------------  # * Alias method: initialize  #--------------------------------------------------------------------------  alias :initialize_ve_enemy_actions :initialize  def initialize(index, enemy_id)    initialize_ve_enemy_actions(index, enemy_id)    enemy.init_custom_actions  end  #--------------------------------------------------------------------------  # * Alias method: conditions_met?  #--------------------------------------------------------------------------  alias :conditions_met_ve_enemy_actions? :conditions_met?  def conditions_met?(action)    return true if action.custom?    conditions_met_ve_enemy_actions?(action)  end  #--------------------------------------------------------------------------  # * Alias method: action_valid?  #--------------------------------------------------------------------------  alias :action_valid_ve_enemy_actions? :action_valid?  def action_valid?(action)    action_valid_ve_enemy_actions?(action) && custom_condition?(action)  end  #--------------------------------------------------------------------------  # * New method: custom_condition?  #--------------------------------------------------------------------------  def custom_condition?(action)    return true unless action.custom?    setup_enemy_actions(action.skill_id)  end  #--------------------------------------------------------------------------  # * New method: setup_enemy_actions  #--------------------------------------------------------------------------  def setup_enemy_actions(id)    regexp = get_all_values("ENEMY ACTION: #{id}, *\\d+", "ENEMY ACTION")    note.scan(regexp).all? { enemy_action_condition($1.dup) }  end  #--------------------------------------------------------------------------  # * New method: enemy_action_condition  #--------------------------------------------------------------------------  def enemy_action_condition(notes)    notes.scan(/([^;]*);/im) do      value   = $1.dup      result1 = value =~ /\w+ (?:HIGHER|LOWER|EQUAL|DIFFERENT) [^><]*/i      result2 = value =~ /TURN \d+\*? *(?:\+ \d+\*)?/i      return false if  result1 && !enemy_action_stat?(value)      return false if  result2 && !enemy_action_turn?(value)      return false if !result1 && !result2 && !enemy_action_custom?(value)    end    return true  end  #--------------------------------------------------------------------------  # * New method: enemy_action_stat?  #--------------------------------------------------------------------------  def enemy_action_stat?(notes)    if notes =~ /(\w+) (HIGHER|LOWER|EQUAL|DIFFERENT) ([^><]*)/im      stat  = $1.dup      cond  = $2.dup      value = $3.dup      if value =~ /(\d+)\%/i and ["HP","MP","TP"].include?(stat.upcase)        return eval("#{stat.downcase}_rate * 100 #{get_cond(cond)} #{$1}")      else        return eval("#{get_param(stat)} #{get_cond(cond)} #{value}")      end    end  end  #--------------------------------------------------------------------------  # * New method: enemy_action_turn?  #--------------------------------------------------------------------------  def enemy_action_turn?(notes)    n = $game_troop.turn_count    notes.scan(/TURN (\d+\*?) *(?:\+ *(\d+)\*)?/i) do |value1, value2|      param1 = value1 =~ /(\d+)\*/i ? 0 : value1.to_i      param2 = value1 =~ /(\d+)\*/i ? $1.to_i : value2 ? value2.to_i : 0      if param2 == 0        return n == param1      else        return n > 0 && n >= param1 && n % param2 == param1 % param2      end    end  end  #--------------------------------------------------------------------------  # * New method: enemy_action_custom?  #--------------------------------------------------------------------------  def enemy_action_custom?(notes)    eval("#{notes.gsub(/\r\n/i, ";")}") rescue false  endendend

Original thread: https://forums.rpgmakerweb.com/threads/adding-more-conditions-to-enemy-action-patterns.18968/