Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Ally AI - Computer Controlled Allies V2.0

Status
Not open for further replies.
Well I was, but since you got it covered, I will focus on other things. ;)

It's a great system. You even got the great Fuso's attention. I bet he can throw some great adice your way, considering he is probably the best with AI as far as I know.
 
SephirothSpawn;109310":2226jdbo said:
Well I was, but since you got it covered, I will focus on other things. ;)

YEAH LIKE YOUR TEST BED, HOW MANY WEEKS AGO YOU SAID YOU WILL HAVE THE NEW VERSION READY, I'M STILL WAITING (you saw that coming a mile away)


SephirothSpawn;109310":2226jdbo said:
It's a great system. You even got the great Fuso's attention. I bet he can throw some great adice your way, considering he is probably the best with AI as far as I know.

Yeah, I know that this script still needs improvement *points to above posts*

Ammom;109436":2226jdbo said:
Good idea. I wonder why a scripter didn't do this before???
Anyways, yeah, way to go!

Actually I started this script a year ago (It will be on the 19th), I didn't know why but I just stopped working on it, then sometime earlier this year I worked on it some more, then during the downtime I decided to finish this to a stable point.
 
SS":2u3ri8xd said:
Very Very Very Very Very Very Nice.

I am jealous.
Trickster":2u3ri8xd said:
Well I'm jealous of your Test Bed WHICH YOU SHOULD BE WORKING ON Come on 70+ Scripts compared to my 20-40ish amount . on a side note are you still working on your autobattle system
It´s a really suspect reply. I´m starting to get really confident that SS and Trickster are the same lol...

BTW nice script (again xD). I´ll surely use it in a project i´m doing (and do some minor changes, maybe ^^).
 
Now, why would the Admin make the person a mod over the same forums and stuff. Not only that, can you imagine how busy we (or maybe I) would have to be to do all of these scripts?

@Trickster: I know. I am still working on it. I have been working on my site and tutorial, and am organizing on online scripting class that I want to start next year. Plus planning out a future game of my own. So I am not being really lazy, just doing too much at the same time.

I think Sewlyn is also working on something similar, but more of conditional auto-battling. But I won't say too much on that.

My idea for auto-battling would be similar to both, but would also have auto-battle selections. It would have catagoric moves, followed by "if you cant do this, do this, if not, do this, ..." I combination of Fantasy Star Online (I think that's what is was) for sega, years ago, just more evolved.
 
SephirothSpawn;110393 said:
Now, why would the Admin make the person a mod over the same forums and stuff. Not only that, can you imagine how busy we (or maybe I) would have to be to do all of these scripts?

In addition to that, there is a rule against having duplicate accounts the admins would've done something by now because they can figure out if an account is a duplicate or not. (Or maybe they just allow us to do this but you will never know [scary sound]OoOoOoOoOoOoOoOoOo[/scary sound]).

SephirothSpawn;110393 said:
@Trickster: I know. I am still working on it. I have been working on my site and tutorial, and am organizing on online scripting class that I want to start next year. Plus planning out a future game of my own. So I am not being really lazy, just doing too much at the same time.

Hehehe. I would like to continue work on my TA (Tetris Attack minigame) but I don't have the script on me and I don't want to start over :(

I too am also planning a game, but that will be a very long time from now before I start.

Well If you need any help with anything I'm always here except for the times that I'm not here :P

SephirothSpawn;110393 said:
I think Sewlyn is also working on something similar, but more of conditional auto-battling. But I won't say too much on that.

Selwyn mentioned that when I posted the ATB+CTB System. The Gambit System from Final Fantasy I'm not familiar with the system or even with FF it comes from (Note: I haven't played any final fantasy games except for Dawn of Souls (I+II) and VI), but he said he has started on it since I posted that CBS.

SephirothSpawn;110393 said:
My idea for auto-battling would be similar to both, but would also have auto-battle selections. It would have catagoric moves, followed by "if you cant do this, do this, if not, do this, ..." I combination of Fantasy Star Online (I think that's what is was) for sega, years ago, just more evolved.

Ahh, ok. I can't wait to see the final product

Seph you are no fun at all, I never get a "Are you working on fixing the bugs from the ATB Battle System?" and here I am stalking you around every corner getting at you about your Test Bed, meh.... (Actually I made some progress with Selection During Actions turns out I have some code in the wrong place, but its still acting a bit funny but alot less funny than before :))
 

fuso

Member

Trickster;108555 said:
Sure Do note that this is jsut the first version

Code:
class Game_AllyAI
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor)
    @actor = actor
    clear
  end
  #--------------------------------------------------------------------------
  # * Attack Action Value
  #--------------------------------------------------------------------------
  def attack_action
    return @aggressiveness
  end
  #--------------------------------------------------------------------------
  # * Magic Action Value
  #--------------------------------------------------------------------------
  def magic_action
    return @actor.skills == 0 ? 0 : @magic_casting
  end
  #--------------------------------------------------------------------------
  # * Item Action Value
  #--------------------------------------------------------------------------
  def item_action
    return @item_using
  end
  #--------------------------------------------------------------------------
  # * Defend Action Value
  #--------------------------------------------------------------------------
  def defend_action
    return @defensiveness
  end
  #--------------------------------------------------------------------------
  # * Wait Action Value
  #--------------------------------------------------------------------------
  def wait_action
    return (@laziness + @cowardice) / 2
  end
  #--------------------------------------------------------------------------
  # * Attacking Intelligence Value
  #--------------------------------------------------------------------------
  def attack_intelligence
    int = (1.5 * @intelligence + 1.5 * @strategist - @aggressiveness).to_i
    return [int, 50].min
  end
  #--------------------------------------------------------------------------
  # * Magic Offense Value
  #--------------------------------------------------------------------------
  def magic_offense
    return @aggressiveness
  end
  #--------------------------------------------------------------------------
  # * Magic Support Value
  #--------------------------------------------------------------------------
  def magic_support  
    return @supportive
  end
  #--------------------------------------------------------------------------
  # * Magic Healing Value
  #--------------------------------------------------------------------------
  def magic_healing
    return @cautiousness
  end
  #--------------------------------------------------------------------------
  # * Magic Status Value
  #--------------------------------------------------------------------------
  def magic_status
    return (@strategist + @supportive + @aggressiveness) / 3
  end
  #--------------------------------------------------------------------------
  # * Magic Strategy Value
  #--------------------------------------------------------------------------
  def magic_strategy
    return (@strategist + @intelligence) / 2
  end
  #--------------------------------------------------------------------------
  # * Magic Heal Percentage
  #--------------------------------------------------------------------------
  def magic_heal_percent
    return ((@supportive / 2 + @cautiousness)/1.5 * 5).to_i
  end
  #--------------------------------------------------------------------------
  # * Magic Heal Multiplier
  #--------------------------------------------------------------------------
  def magic_heal_multiplier
    return (@supportive/2.5 + @cautiousness/1.875).to_i + 1
  end
  #--------------------------------------------------------------------------
  # * Magic Strategy Effective Rate
  #--------------------------------------------------------------------------
  def magic_strategy_effective
    return (2 * @strategist + 3 * @intelligence) / 20
  end
  #--------------------------------------------------------------------------
  # * Magic Status Multiplier
  #--------------------------------------------------------------------------
  def magic_status_multiplier
    return (@strategist/2.5 + @supportive/1.875).to_i + 1
  end
  #--------------------------------------------------------------------------
  # * Magic Strategy Multiplier
  #--------------------------------------------------------------------------
  def magic_strategy_multiplier
    return (@strategist/2.5 + @intelligence/1.875).to_i + 1
  end
  #--------------------------------------------------------------------------
  # * Item Offense Value
  #--------------------------------------------------------------------------
  def item_offense
    return 5 * @aggressiveness / 8 + @intelligence / 8 + @strategist / 4
  end
  #--------------------------------------------------------------------------
  # * Item Support Value
  #--------------------------------------------------------------------------
  def item_support  
    return 5 * @supportive / 8 + 3 * @intelligence / 8
  end
  #--------------------------------------------------------------------------
  # * Item Healing Value
  #--------------------------------------------------------------------------
  def item_healing
    return 5 * @cautiousness / 8 + @intelligence / 8 + @strategist / 4
  end
  #--------------------------------------------------------------------------
  # * Item Status Value
  #--------------------------------------------------------------------------
  def item_status
    return (@strategist + @supportive + @intelligence) / 3
  end
  #--------------------------------------------------------------------------
  # * Item Strategy Value
  #--------------------------------------------------------------------------
  def item_strategy
    return (@strategist + @intelligence) / 2
  end
  #--------------------------------------------------------------------------
  # * Item Heal Percentage
  #--------------------------------------------------------------------------
  def item_heal_percent
    return ((@supportive / 2 + @cautiousness)/1.5 * 5).to_i
  end
  #--------------------------------------------------------------------------
  # * Item Heal Multiplier
  #--------------------------------------------------------------------------
  def item_heal_multiplier
    return (@supportive/2.5 + @cautiousness/1.875).to_i + 1
  end
  #--------------------------------------------------------------------------
  # * Item Strategy Effective Rate
  #--------------------------------------------------------------------------
  def item_strategy_effective
    return (3 * @strategist + 2 * @intelligence) / 20
  end
  #--------------------------------------------------------------------------
  # * Item Status Multiplier
  #--------------------------------------------------------------------------
  def item_status_multiplier
    return (@strategist/2.5 + @supportive/1.875).to_i + 1
  end
  #--------------------------------------------------------------------------
  # * Item Strategy Multiplier
  #--------------------------------------------------------------------------
  def item_strategy_multiplier
    return (@strategist/2.5 + @intelligence/1.875).to_i + 1
  end
  #--------------------------------------------------------------------------
  # * Clear
  #--------------------------------------------------------------------------
  def clear
    @aggressiveness   = @actor.aggressiveness
    @magic_casting    = @actor.magic_casting
    @item_using       = @actor.item_using
    @supportive       = @actor.supportive
    @defensiveness    = @actor.defensiveness
    @intelligence     = @actor.intelligence
    @cautiousness     = @actor.cautiousness
    @laziness         = @actor.laziness
    @cowardice        = @actor.cowardice
    @strategist       = @actor.strategist
    @action_attack    = attack_action
    @action_magic     = magic_action
    @action_item      = item_action
    @action_defend    = defend_action
    @action_wait      = wait_action
    @magic_attack     = 0
    @magic_support    = 0
    @magic_heal       = 0
    @magic_status     = 0
    @magic_strategist = 0
    @item_attack      = 0
    @item_support     = 0
    @item_heal        = 0
    @item_status      = 0
    @item_strategist  = 0
    # Initialize Useable Skill Array
    @useable = []
  end
  #--------------------------------------------------------------------------
  # * Make Action
  #--------------------------------------------------------------------------
  def make_action
    # Clear All Instance Variables
    clear
    # Initialize Actions Array
    actions = []
    # Attack Influences
    attack_influences
    # Magic Influences
    magic_influences
    # Item Influences
    item_influences
    # Defend Influences
    defend_influences
    # Wait Influences
    wait_influences
    # Push Action Numbers onto actions array
    @action_attack.times { actions << 0 }
    @action_magic.times  { actions << 1 }
    @action_item.times   { actions << 2 }
    @action_defend.times { actions << 3 }
    @action_wait.times   { actions << 4 }
    # Generate a random value
    action = actions[rand(actions.size)]
    # Branch By Action Number
    case action
    when 0
      make_action_attack
    when 1
      make_action_magic
    when 2
      make_action_item
    when 3
      make_action_defend
    when 4
      make_action_wait
    end
  end
  #--------------------------------------------------------------------------
  # * Attack Influences
  #--------------------------------------------------------------------------
  def attack_influences
    # Initialize Counter
    number = 0
    # Get Attack Power
    atk = @actor.atk
    # Run Through Each enemy
    $game_troop.enemies.each do |enemy|
      # Skip if non existant
      next if not enemy.exist?
      # Get pdef * Intelligence Rating
      pdef = enemy.pdef * attack_intelligence / 50.0
      # If actor thinks that can at least do some damage add one
      number += 1 if atk > pdef / 2
    end
    # Add To Instance Variable
    @action_attack = @action_attack * number == 0 ? 0 : @action_attack + number
  end
  #--------------------------------------------------------------------------
  # * Magic Influences
  #--------------------------------------------------------------------------
  def magic_influences
    # Initialize Counter
    number = 0
    # Initialize sp Array
    sp = []
    # Run Through Each Skill
    @actor.skills.each {|skill_id| sp << $data_skills[skill_id].sp_cost}
    # If at least one member is in critical condition
    if $game_party.critical?
      # If knows at least one healing skill that can be used
      @actor.skills.each do |skill_id|
        # If skill is healing and can use the skill
        if $data_skills[skill_id].is_healing? && @actor.skill_can_use?(skill_id)
          # Heavy influence for magic
          @action_magic = 20
          # Break
          break
        end
      end
    end
    # If Sp is less than the minimum then fail
    @action_magic = 0 if @actor.sp < sp.min
  end
  #--------------------------------------------------------------------------
  # * Item Influences
  #--------------------------------------------------------------------------
  def item_influences
    # Initialize Counter
    number = 0
    # Run Through each available item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If can be used in battle increase number
      number += 1 if [0,1].include?($data_items[item_id].occasion)
    end
    # If at least one member is in critical condition
    if $game_party.critical?
      # If knows at least one healing skill that can be used
      $game_party.items.each do |item_id, amount|
        # Skip if amount is 0 or nil
        next if amount.to_i == 0
        # If skill is healing and can use the item
        if $data_items[item_id].is_healing? && $game_party.item_can_use?(item_id)
          # Heavy influence for item
          @action_item = 20
          # Break
          break
        end
      end
    end
    # If no usable items then fail
    @action_item = 0 if number == 0
  end
  #--------------------------------------------------------------------------
  # * Defend Influences
  #--------------------------------------------------------------------------
  def defend_influences
  end
  #--------------------------------------------------------------------------
  # * Wait Influences
  #--------------------------------------------------------------------------
  def wait_influences
  end
  #--------------------------------------------------------------------------
  # * Make Action Attack
  #--------------------------------------------------------------------------
  def make_action_attack
    # Initialize Random Array
    random = []
    # Get Attack Power
    atk = @actor.atk
    # Run Through Each enemy
    $game_troop.enemies.each_with_index do |enemy, index|
      # Skip if non existant
      next if not enemy.exist?
      # Get pdef * Intelligence Rating
      pdef = enemy.pdef * attack_intelligence / 50.0
      # If actor thinks that can at least do some damage add one
      random << index if atk > pdef / 2
    end
    # Set Target Index
    @actor.current_action.target_index = random[rand(random.size)]
    # Set Action
    @actor.current_action.kind = 0
    @actor.current_action.basic = 0
  end
  #--------------------------------------------------------------------------
  # * Make Action Magic
  #--------------------------------------------------------------------------
  def make_action_magic
    # Initialize Action Array
    actions = []
    @magic_attack     = magic_offense
    @magic_support    = magic_support
    @magic_heal       = magic_healing
    @magic_status     = magic_status
    @magic_strategist = magic_strategy
    # Attack Influences
    magic_influences_attack
    # Support Influences
    magic_influences_support
    # Healing Influences
    magic_influences_healing
    # Status Influences
    magic_influences_status
    # Strategy Influences
    magic_influences_strategy
    # Push Action Numbers onto actions array
    @magic_attack.times       { actions << 0 }
    @magic_support.times      { actions << 1 }
    @magic_heal.times         { actions << 2 }
    @magic_status.times       { actions << 3 }
    @magic_strategist.times   { actions << 4 }
    # Generate a random value
    action = actions[rand(actions.size)]
    # Branch By Action Number
    case action
    when 0
      make_magic_action_attack
    when 1
      make_magic_action_support
    when 2
      make_magic_action_healing
    when 3
      make_magic_action_status
    when 4
      make_magic_action_strategist
    end
    # Make Skill Choice
    make_skill_choice
    # If skill then make action
    if @actor.current_action.skill_id != 0
      @actor.current_action.kind = 1
      @actor.current_action.basic = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Make Action Item
  #--------------------------------------------------------------------------
  def make_action_item
    # Initialize Action Array
    actions = []
    @item_attack     = item_offense
    @item_support    = item_support
    @item_heal       = item_healing
    @item_status     = item_status
    @item_strategist = item_strategy
    # Attack Influences
    item_influences_attack
    # Support Influences
    item_influences_support
    # Healing Influences
    item_influences_healing
    # Status Influences
    item_influences_status
    # Strategy Influences
    item_influences_strategy
    # Push Action Numbers onto actions array
    @item_attack.times       { actions << 0 }
    @item_support.times      { actions << 1 }
    @item_heal.times         { actions << 2 }
    @item_status.times       { actions << 3 }
    @item_strategist.times   { actions << 4 }
    # Generate a random value
    action = actions[rand(actions.size)]
    # Branch By Action Number
    case action
    when 0
      make_item_action_attack
    when 1
      make_item_action_support
    when 2
      make_item_action_healing
    when 3
      make_item_action_status
    when 4
      make_item_action_strategist
    end
    # Make Item Choice
    make_item_choice
    # If using an item set action to item
    if @actor.current_action.item_id != 0
      @actor.current_action.kind = 2
      @actor.current_action.basic = 0
    end
  end
  #--------------------------------------------------------------------------
  # * Make Action Defend
  #--------------------------------------------------------------------------
  def make_action_defend
    @actor.current_action.kind = 0
    @actor.current_action.basic = 1
  end
  #--------------------------------------------------------------------------
  # * Make Action Wait
  #--------------------------------------------------------------------------
  def make_action_wait
    @actor.current_action.kind = 0
    @actor.current_action.basic = 3
  end
  #--------------------------------------------------------------------------
  # * Magic Influences Attack
  #--------------------------------------------------------------------------
  def magic_influences_attack
    # Initialize Number Counter
    number = 0
    # Run Through each actor skill
    @actor.skills.each do |skill_id|
      # If is an attack skill
      if $data_skills[skill_id].is_offensive?
        # Increase Counter
        number += 1
      end
    end
    # Increase magic attack modifier by amount
    @magic_attack += (number / @actor.skills.size.to_f * 4).ceil
    # If no attack skills then fail
    @magic_attack = number == 0 ? 0 : @magic_attack
  end
  #--------------------------------------------------------------------------
  # * Magic Influences Support
  #--------------------------------------------------------------------------
  def magic_influences_support
    # Initialize Number Counter
    number = 0
    # Support Skills May be used on first turn
    @magic_support += 1 if $game_temp.battle_turn == 0
    # Initialize Elements and States Array
    elements, states = [], []
    # Run Trough Each Enemy gathering there elements
    $game_troop.enemies.each {|enemy| elements += enemy.elements}
    # Remove Duplicates
    elements.uniq!
    # Run Through all Helpful States
    Ally_AI::Helpful_States.each do |state_id|
      # If State has protection against an Element
      if $data_states[state_id].guard_element_set.includes_any?(*elements)
        # Add State
        states << state_id
      end
    end
    # Run Through each actor skill
    @actor.skills.each do |skill_id|
      # If Has any of the states
      if $data_skills[skill_id].plus_state_set.includes_any?(*states)
        # Increase Counter
        number += 1
      end
    end
    # Increase magic support modifier by amount
    @magic_support += (number / @actor.skills.size.to_f * 4).ceil
    # If no support skills then fail
    @magic_support = number == 0 ? 0 : @magic_support
  end
  #--------------------------------------------------------------------------
  # * Magic Influences Healing
  #--------------------------------------------------------------------------
  def magic_influences_healing
    # Initialize Number Counter
    number, healthy = 0, $game_party.actors.size
    # Healing modifiers
    $game_party.actors.each do |actor|
      # Skip if non existing
      if not actor.exist?
        # Not included
        healthy -= 1
        # Skip
        next 
      end
      # Increase Healing influence if less than heal percent
      if (actor.hp * 100.0 / actor.maxhp).to_i <= magic_heal_percent
        @magic_heal += 1
      else
        # Is Healthy
        healthy -= 1
      end
    end
    # If game party is in critical state increase chances of using a skill
    @magic_heal += 3 if $game_party.critical?
    # Run Through each skill
    @actor.skills.each do |skill_id|
      # Increase by 1 if healing skill
      number += 1 if $data_skills[skill_id].is_healing?
    end
    # Increase magic heal modifier by amount
    @magic_heal += (number / @actor.skills.size.to_f * 2).ceil
    # If no Healing Skills then can't use a healing skill
    @magic_heal = number == 0 ? 0 : @magic_heal
    # If all are healty then don't use a healing skill
    @magic_heal = healthy == 0 ? 0 : @magic_heal
  end
  #--------------------------------------------------------------------------
  # * Magic Influences Status
  #--------------------------------------------------------------------------
  def magic_influences_status
    # Initialize Number Counter
    number = 0
    # Initialize Weak States Hash
    weak_states = {}
    # Run Through Each Enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing
      next if not enemy.exist?
      # Run Through each Harmful state
      Ally_AI::Harmful_States.each do |state_id|
        # Get State Effectiveness Value
        effective = enemy.state_effectiveness(state_id)
        # Push if effective enough
        weak_states[state_id] = effective if effective > magic_strategy_effective
      end
    end
    # Run Thorugh each actor skill
    @actor.skills.each do |skill_id|
      # If Skill has any of the states
      if $data_skills[skill_id].plus_state_set.includes_any?(*weak_states.keys)
        # Increase Number
        number += 1
      end
    end
    # Correction if no weak states
    number = 0 if weak_states.keys.size == 0
    # Increase magic status modifier by amount
    @magic_status  += Integer(number / @actor.skills.size.to_f * 4)
    # If no Status Skills then can't us a status skill
    @magic_status  = number == 0 ? 0 : @magic_status 
  end
  #--------------------------------------------------------------------------
  # * Magic Influences Strategy
  #--------------------------------------------------------------------------
  def magic_influences_strategy
    # Initialize Weak Elements Array
    weak_elements = {}
    # Initialize Number Counter
    number = 0
    # Run Through each enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing enemy
      next if not enemy.exist?
      # Run Through Real Elements
      Ally_AI::Real_Elements.each do |element_id|
        # Get Effectiveness
        effective = enemy.element_effectiveness(element_id)
        # If Greater Than magic effectives value
        if effective > magic_strategy_effective
          # Add to weak elements hash
          weak_elements[element_id] = effective
        end
      end
    end
    # Run Through each skill
    @actor.skills.each do |skill_id|
      # If Skills Element Set includes any element in weak elements
      if $data_skills[skill_id].element_set.includes_any?(*weak_elements.keys)
        # Increase Counter
        number += 1
      end
    end
    # Increase magic strategist modifier by amount
    @magic_strategist += (number / @actor.skills.size.to_f * 4).ceil
    # Set to 0 if conditions not met (no strategical skills)
    @magic_strategist = number == 0 ? 0 : @magic_strategist
  end
  #--------------------------------------------------------------------------
  # * Make Magic Action Attack
  #--------------------------------------------------------------------------
  def make_magic_action_attack
    # Run Through each skill
    @actor.skills.each do |skill_id|
      # If is an attack skill Push Skill Id onto list
      @useable << skill_id if $data_skills[skill_id].is_offensive?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Magic Action Support
  #--------------------------------------------------------------------------
  def make_magic_action_support
    # Run Through each skill
    @actor.skills.each do |skill_id|
      # If is a support skill Push Skill Id onto list
      @useable << skill_id if $data_skills[skill_id].is_supporting?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Magic Action Healing
  #--------------------------------------------------------------------------
  def make_magic_action_healing
    # Run Through each skill
    @actor.skills.each do |skill_id|
      # If is a healing skill Push Skill Id onto list
      @useable << skill_id if $data_skills[skill_id].is_healing?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Magic Action Status
  #--------------------------------------------------------------------------
  def make_magic_action_status
    # Run Through each skill
    @actor.skills.each do |skill_id|
      # If is a status skill Push skill onto list
      @useable << skill_id if $data_skills[skill_id].is_status?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Magic Action Strategist
  #--------------------------------------------------------------------------
  def make_magic_action_strategist
    # Initialize elements
    elements = []
    # Run Through each enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing enemy
      next if not enemy.exist?
      # Run Through Real Elements
      Ally_AI::Real_Elements.each do |element_id|
        # Get Effectiveness
        effective = enemy.element_effectiveness(element_id)
        # If Greater Than magic effectives value
        if effective > magic_strategy_effective
          # Add to elements
          elements << element_id
        end
      end
    end
    # Run Through each enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing
      next if not enemy.exist?
      # Run Through each element
      Ally_AI::Real_Elements.each do |element_id|
        # Get Effectiveness
        effective = enemy.element_effectiveness(element_id)
        # Push if effective enough
        elements << element_id if effective > magic_strategy_effective
      end
    end
    # Remove Duplicates
    elements.uniq!
    # Run Through Each Skill
    @actor.skills.each do |skill_id|
      # Push onto useable list if is strategic with respect to elements
      @useable << skill_id if $data_skills[skill_id].is_strategic?(*elements)
    end
  end
  #--------------------------------------------------------------------------
  # * Item Influences Attack
  #--------------------------------------------------------------------------
  def item_influences_attack
    # Initialize Number Counter
    number = 0
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If is an attack item
      if $data_items[item_id].is_offensive?
        # Increase Counter
        number += 1
      end
    end
    # Increase item attack modifier by amount
    @item_attack += number
    # If no attack items then fail
    @item_attack = number == 0 ? 0 : @item_attack
  end
  #--------------------------------------------------------------------------
  # * Item Influences Support
  #--------------------------------------------------------------------------
  def item_influences_support
    # Initialize Number Counter
    number = 0
    # Support Items May be used on first turn
    @item_support += 1 if $game_temp.battle_turn == 0
    # Initialize Elements and States Array
    elements, states = [], []
    # Run Trough Each Enemy gathering there elements
    $game_troop.enemies.each {|enemy| elements += enemy.elements}
    # Remove Duplicates
    elements.uniq!
    # Run Through all Helpful States
    Ally_AI::Helpful_States.each do |state_id|
      # If State has protection against an Element
      if $data_states[state_id].guard_element_set.includes_any?(*elements)
        # Add State
        states << state_id
      end
    end
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If Has any of the states
      if $data_items[item_id].plus_state_set.includes_any?(*states)
        # Increase Counter
        number += 1
      end
    end
    # Increase item support modifier by amount
    @item_support += number
    # If no support items then fail
    @item_support = number == 0 ? 0 : @item_support
  end
  #--------------------------------------------------------------------------
  # * Item Influences Healing
  #--------------------------------------------------------------------------
  def item_influences_healing
    # Initialize Number Counter
    number, healthy = 0, $game_party.actors.size
    # Healing modifiers
    $game_party.actors.each do |actor|
      # Skip if non existing
      if not actor.exist?
        # Not included
        healthy -= 1
        # Skip
        next 
      end
      # Increase Healing influence if less than heal percent
      if (actor.hp * 100.0 / actor.maxhp).to_i <= item_heal_percent
        @item_heal += 1
      else
        # Is Healthy
        healthy -= 1
      end
    end
    # If game party is in critical state increase chances of using a skill
    @item_heal += 3 if $game_party.critical?
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # Increase by 1 if healing skill
      number += 1 if $data_items[item_id].is_healing?
    end
    # Increase item heal modifier by amount
    @item_heal += number
    # If no Healing items then can't use a healing item
    @item_heal = number == 0 ? 0 : @item_heal
    # If all are healty then don't use a healing item
    @item_heal = healthy == 0 ? 0 : @item_heal
  end
  #--------------------------------------------------------------------------
  # * Item Influences Status
  #--------------------------------------------------------------------------
  def item_influences_status
    # Initialize Number Counter
    number = 0
    # Initialize Weak States Hash
    weak_states = {}
    # Run Through Each Enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing
      next if not enemy.exist?
      # Run Through each Harmful state
      Ally_AI::Harmful_States.each do |state_id|
        # Get State Effectiveness Value
        effective = enemy.state_effectiveness(state_id)
        # Push if effective enough
        weak_states[state_id] = effective if effective > item_strategy_effective
      end
    end
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If Item has any of the states
      if $data_items[item_id].plus_state_set.includes_any?(*weak_states.keys)
        # Increase Number
        number += 1
      end
    end
    # Correction if no weak states
    number = 0 if weak_states.keys.size == 0
    # Increase item status modifier by amount
    @item_status += number
    # If no Status Items then can't us3 a status item
    @item_status = number == 0 ? 0 : @item_status 
  end
  #--------------------------------------------------------------------------
  # * Item Influences Strategy
  #--------------------------------------------------------------------------
  def item_influences_strategy
    # Initialize Weak Elements Array
    weak_elements = {}
    # Initialize Number Counter
    number = 0
    # Run Through each enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing enemy
      next if not enemy.exist?
      # Run Through Real Elements
      Ally_AI::Real_Elements.each do |element_id|
        # Get Effectiveness
        effective = enemy.element_effectiveness(element_id)
        # If Greater Than magic effectives value
        if effective > item_strategy_effective
          # Add to weak elements hash
          weak_elements[element_id] = effective
        end
      end
    end
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If Items Element Set includes any element in weak elements
      if $data_items[item_id].element_set.includes_any?(*weak_elements.keys)
        # Increase Counter
        number += 1
      end
    end
    # Increase item strategist modifier by amount
    @item_strategist += number
    # Set to 0 if conditions not met (no strategical items)
    @item_strategist = number == 0 ? 0 : @item_strategist
  end
  #--------------------------------------------------------------------------
  # * Make Item Action Attack
  #--------------------------------------------------------------------------
  def make_item_action_attack
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If is an attack item Push Item Id onto list
      @useable << item_id if $data_items[item_id].is_offensive?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Item Action Support
  #--------------------------------------------------------------------------
  def make_item_action_support
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If is a support item Push Item Id onto list
      @useable << item_id if $data_items[item_id].is_supporting?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Item Action Healing
  #--------------------------------------------------------------------------
  def make_item_action_healing
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If is a healing item Push Item Id onto list
      @useable << item_id if $data_items[item_id].is_healing?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Item Action Status
  #--------------------------------------------------------------------------
  def make_item_action_status
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # If is a status item Push item onto list
      @useable << item_id if $data_items[item_id].is_status?
    end
  end
  #--------------------------------------------------------------------------
  # * Make Item Action Strategist
  #--------------------------------------------------------------------------
  def make_item_action_strategist
    # Initialize elements
    elements = []
    # Run Through each enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing enemy
      next if not enemy.exist?
      # Run Through Real Elements
      Ally_AI::Real_Elements.each do |element_id|
        # Get Effectiveness
        effective = enemy.element_effectiveness(element_id)
        # If Greater Than magic effectives value
        if effective > magic_strategy_effective
          # Add to elements
          elements << element_id
        end
      end
    end
    # Run Through each enemy
    $game_troop.enemies.each do |enemy|
      # Skip if not existing
      next if not enemy.exist?
      # Run Through each element
      Ally_AI::Real_Elements.each do |element_id|
        # Get Effectiveness
        effective = enemy.element_effectiveness(element_id)
        # Push if effective enough
        elements << element_id if effective > magic_strategy_effective
      end
    end
    # Remove Duplicates
    elements.uniq!
    # Run Through each item
    $game_party.items.each do |item_id, amount|
      # Skip if amount is nil or 0
      next if amount.to_i == 0
      # Push onto useable list if is strategic with respect to elements
      @useable << item_id if $data_items[item_id].is_strategic?(*elements)
    end
  end
  #--------------------------------------------------------------------------
  # * Make Skill Choice
  #--------------------------------------------------------------------------
  def make_skill_choice
    # Get Laziness
    chance_lazy = rand(@laziness+1)
    # Get Maximum Mp want to use
    max_mp_used = (20 - chance_lazy).to_f / 20 * @actor.sp
    # Setup Local Useable
    useable = []
    # Run Through Useable Skills
    @useable.each do |skill_id|
      # Push if sp cost is less than max mp want to use
      useable << skill_id if $data_skills[skill_id].sp_cost <= max_mp_used
    end
    # Return if size is 0
    return if useable.size == 0
    # Get Skill Id
    skill_id = useable[rand(useable.size)]
    # Get Random Skill
    @actor.current_action.skill_id = skill_id
    # If not Targets All
    if not $data_skills[skill_id].targets_all?
      # Make Target Choice
      make_magic_target_choice
    end
  end
  #--------------------------------------------------------------------------
  # * Make Magic Target Choice
  #--------------------------------------------------------------------------
  def make_magic_target_choice
    # Get Skill
    skill = $data_skills[@actor.current_action.skill_id]
    # Get Scope
    scope = skill.scope
    # Setup Possible Targets
    possible_targets = []
    # Branch By Scope
    case scope
    when 1
      # Setup States Element Effeienct Targets and Elements Arrays
      states, elem_effiency, targets = [], [], []
      # Run Through each enemy
      $game_troop.enemies.each_with_index do |enemy, index|
        # Skip if non-existant
        next if not enemy.exist?
        # Setup Local Block Variable elements
        elements = []
        # If skill is a status skill
        if skill.is_status?
          # Initialize Enemy Status Points
          enemy_status = 0
          # Run Through each state
          skill.plus_state_set.each do |state_id|
            # Add State Effectiveness
            enemy_status += enemy.state_effectiveness(state_id)
          end
          # Set Index to Status Points
          states[index] = enemy_status
        end
        # Run Through each real element
        Ally_AI::Real_Elements.each do |element_id|
          # Get Element Effectiveness for enemy
          effective = enemy.element_effectiveness(element_id)
          # Add element id if effective
          elements << element_id if effective > magic_strategy_effective
        end
        # If skill is strategic with respect to elements
        if skill.is_strategic?(*elements)
          # Set Local Variable Enemy Element
          enemy_element = 0
          # Run Through each element_id
          skill.element_set.each do |element_id|
            # Add Effectiveness
            enemy_element += enemy.element_effectiveness(element_id)
          end
          # Add Element Effiency
          elem_effiency[index] = enemy_element
        end
        # If Skill is attacking
        if skill.is_offensive?
          # Just Push the index
          targets << index
        end
      end 
      # Add to Possible Targets
      magic_status_multiplier.times do
        possible_targets += states.find_index(states.max)
      end
      magic_strategy_multiplier.times do
        possible_targets += elem_effiency.find_index(elem_effiency.max)
      end
      possible_targets += targets
    when 3
      # Setup Local Hp amount
      hp_amount = Array.new($game_party.actors.size) {0}
      # Setup Minus States Array (set all indexes to 0)
      minus_states = Array.new($game_party.actors.size) {0}
      # Setup Status Array (set all indexes to 0)
      status = Array.new($game_party.actors.size) {0}
      # Run Through Each Actor
      $game_party.actors.each_with_index do |actor, index|
        # If Skill Is Healing
        if skill.is_healing?
          # If power is less than 0 (healing hp) and actor exists
          if skill.power < 0 and actor.exist?
            # Get Percentage
            percentage = (actor.hp * 100.0 / actor.maxhp).to_i
            # Push Percentage of hp left
            hp_amount[index] = 100 - percentage
            # Set to 0 if 
            hp_amount[index] = 0 if percentage > magic_heal_percent
          end
          # Get Remove Harmful States
          remove_states = skill.minus_state_set & Ally_AI::Harmful_States
          # Run Through States Removed
          remove_states.each do |state_id|
            # Get State
            state = $data_states[state_id]
            # Skip if doesn't have state
            next if not actor.state?(state_id)
            # If has bad state increase by 1
            minus_states[index] += 1 
            # If bad state restriction > 0 increase by 1
            minus_states[index] += 1 if state.restriction > 0
            # If Slip Damage increase by 1
            minus_states[index] += 1 if state.slip_damage
            # If zero hp increase by 2
            minus_states[index] += 2 if state.zero_hp
          end
        end
        # Skip if not exists
        next if not actor.exist?
        # If skill is supporting
        if skill.is_supporting?
          # Get Skill Helpful States
          helpful = skill.plus_state_set & Ally_AI::Helpful_States
          # Run Through each actor with index
          $game_party.actors.each_with_index do |actor, index|
            # Run Through Each Helpful State
            helpful.each do |state_id|
              # Increase if actor doesn't have state
              status[index] += 1 if not actor.state?(state_id)
            end
          end
        end
      end
      # If not all zeros
      if hp_amount.sum != 0
        # Get Hp Amounts
        rating = hp_amount
        # Get Percentage By / by sum
        rating.collect! {|rate| rate.to_f / hp_amount.sum}
        # Increase Ratings by heal Multiplier rating
        rating.collect! {|rate| rate * magic_heal_multiplier}
        # Run Through adding indexes and their rating
        rating.each_with_index do |rate, index|
          # Push onto Possible Targets
          possible_targets += Array.new(rate) {index}
        end
      end
      # Run Through adding indexes and their rating
       minus_states.each_with_index do |state_rate, index|
        # Push onto Possible Targets
        possible_targets += Array.new(state_rate) {index}
      end
      # Run Through adding indexes and their rating
       status.each_with_index do |status, index|
        # Push onto Possible Targets
        possible_targets += Array.new(status) {index}
      end
    when 5
      # Run Through all Actors
      $game_party.actors.each_with_index do |actor, index|
        # Push index if non existant
        possible_targets << index if not actor.exist?
      end
    when 7
      # Push itself
      possible_targets << @actor.index
    end
    target_index = possible_targets[rand(possible_targets.size)]
    @actor.current_action.target_index = target_index
  end
  #--------------------------------------------------------------------------
  # * Make Item Choice
  #--------------------------------------------------------------------------
  def make_item_choice
    # Get Item Id
    item_id = @useable[rand(@useable.size)]
    # Set Random Item
    @actor.current_action.item_id = item_id
    # If not Targets All
    if not $data_items[item_id].targets_all?
      # Make Target Choice
      make_item_target_choice
    end
  end
  #--------------------------------------------------------------------------
  # * Make Item Target Choice
  #--------------------------------------------------------------------------
  def make_item_target_choice
    # Get Item
    item = $data_items[@actor.current_action.item_id]
    # Get Scope
    scope = item.scope
    # Setup Possible Targets
    possible_targets = []
    # Branch By Scope
    case scope
    when 1
      # Setup States Element Effeienct Targets and Elements Arrays
      states, elem_effiency, targets = [], [], []
      # Run Through each enemy
      $game_troop.enemies.each_with_index do |enemy, index|
        # Skip if non-existant
        next if not enemy.exist?
        # Setup Local Block Variable elements
        elements = []
        # If skill is a status skill
        if item.is_status?
          # Initialize Enemy Status Points
          enemy_status = 0
          # Run Through each state
          item.plus_state_set.each do |state_id|
            # Add State Effectiveness
            enemy_status += enemy.state_effectiveness(state_id)
          end
          # Set Index to Status Points
          states[index] = enemy_status
        end
        # Run Through each real element
        Ally_AI::Real_Elements.each do |element_id|
          # Get Element Effectiveness for enemy
          effective = enemy.element_effectiveness(element_id)
          # Add element id if effective
          elements << element_id if effective > magic_strategy_effective
        end
        # If item is strategic with respect to elements
        if item.is_strategic?(*elements)
          # Set Local Variable Enemy Element
          enemy_element = 0
          # Run Through each element_id
          item.element_set.each do |element_id|
            # Add Effectiveness
            enemy_element += enemy.element_effectiveness(element_id)
          end
          # Add Element Effiency
          elem_effiency[index] = enemy_element
        end
        # If Item is attacking
        if item.is_offensive?
          # Just Push the index
          targets << index
        end
      end 
      # Add to Possible Targets
      item_status_multiplier.times do
        possible_targets += states.find_index(states.max)
      end
      item_strategy_multiplier.times do
        possible_targets += elem_effiency.find_index(elem_effiency.max)
      end
      possible_targets += targets
    when 3
      # Setup Local Hp amount
      hp_amount = Array.new($game_party.actors.size) {0}
      # Setup Local Sp amount
      sp_amount = Array.new($game_party.actors.size) {0}
      # Setup Minus States Array (set all indexes to 0)
      minus_states = Array.new($game_party.actors.size) {0}
      # Setup Status Array (set all indexes to 0)
      status = Array.new($game_party.actors.size) {0}
      # Run Through Each Actor
      $game_party.actors.each_with_index do |actor, index|
        # If Item Is Healing
        if item.is_healing?
          # If item recover rates is > than 0 (healing hp) and actor exists
          if item.recover_hp_rate > 0 || item.recover_hp > 0 and actor.exist?
            # Get Percentage
            percentage = (actor.hp * 100.0 / actor.maxhp).to_i
            # Push Percentage of hp left
            hp_amount[index] = 100 - percentage
            # Set to 0 if 
            hp_amount[index] = 0 if percentage > item_heal_percent
          end
          # If item recover rates is > than 0 (healing sp)
          if item.recover_sp_rate > 0 || item.recover_sp > 0 
            # Get Percentage
            percentage = (actor.sp * 100.0 / actor.maxsp).to_i
            # Push Percentage of hp left
            sp_amount[index] = 100 - percentage
            # Set to 0 if 
            sp_amount[index] = 0 if percentage <= item_heal_percent
          end
          # Get Remove Harmful States
          remove_states = item.minus_state_set & Ally_AI::Harmful_States
          # Run Through States Removed
          remove_states.each do |state_id|
            # Get State
            state = $data_states[state_id]
            # Skip if doesn't have state
            next if not actor.state?(state_id)
            # If has bad state increase by 1
            minus_states[index] += 1
            # If bad state restriction > 0 increase by 1
            minus_states[index] += 1 if state.restriction > 0
            # If Slip Damage increase by 1
            minus_states[index] += 1 if state.slip_damage
            # If zero hp increase by 2
            minus_states[index] += 2 if state.zero_hp
          end
        end
        # Skip if not exists
        next if not actor.exist?
        # If item is supporting
        if item.is_supporting?
          # Get Skill Helpful States
          helpful = item.plus_state_set & Ally_AI::Helpful_States
          # Run Through each actor with index
          $game_party.actors.each_with_index do |actor, index|
            # Run Through Each Helpful State
            helpful.each do |state_id|
              # Increase if actor doesn't have state
              status[index] += 1 if not actor.state?(state_id)
            end
          end
        end
      end
      # If not all zeros
      if hp_amount.sum != 0
        # Get Hp Amounts
        rating = hp_amount
        # Get Percentage By / by sum
        rating.collect! {|rate| rate.to_f / hp_amount.sum}
        # Increase Ratings by heal Multiplier rating
        rating.collect! {|rate| rate * item_heal_multiplier}
        # Run Through adding indexes and their rating
        rating.each_with_index do |rate, index|
          # Push onto Possible Targets
          possible_targets += Array.new(rate) {index}
        end
      end
      # If not all zeros
      if sp_amount.sum != 0
        # Get Ratings
        rating = sp_amount
        # Get Percentage By / by sum
        rating.collect! {|rate| rate.to_f / sp_amount.sum}
        # Increase Ratings by heal Multiplier rating
        rating.collect! {|rate| rate * item_heal_multiplier}
        # Run Through adding indexes and their rating
        rating.each_with_index do |rate, index|
          # Push onto Possible Targets
          possible_targets += Array.new(rate) {index}
        end
      end
      # Run Through adding indexes and their rating
       minus_states.each_with_index do |state_rate, index|
        # Push onto Possible Targets
        possible_targets += Array.new(state_rate) {index}
      end
      # Run Through adding indexes and their rating
       status.each_with_index do |status, index|
        # Push onto Possible Targets
        possible_targets += Array.new(status) {index}
      end
    when 5
      # Run Through all Actors
      $game_party.actors.each_with_index do |actor, index|
        # Push index if non existant
        possible_targets << index if not actor.exist?
      end
    when 7
      # Push itself
      possible_targets << @actor.index
    end
    target_index = possible_targets[rand(possible_targets.size)]
    @actor.current_action.target_index = target_index
  end
end

Don't have DRGSS here so I'm not entirely sure, but does the status "effectiveness" take into account whether the target is already affected by the status effect? Otherwise, you may want to remove the status effects that are already in effect when determining if the status skill is usable or not.

Personally I'm not into designing AI, where you try to construct an AI that works as some other actor (although to construct an AI that through some model, statistical methods for instance, learn the behavioral pattern of other actors and then possibly applies this, recursively on a meta level even, is tasty). The "influence"-scores you've created seems to push the behavior more towards the personality traits that you created initially (though merely cause you give them a certain name and try to use them in a certain way doesn't mean that the behavior that emerges nec. will be of that type. The semantics that we attribute to entities to make them easier to put into context may sometimes fool us to see more than there is.). It still seems weird to me though that you do not allow them to act intelligently It may cause the actor to still perform some useless actions, thinking he is better than he is (or the other way around), but this should give some nice results. With the presence of a bit deeper reader, it should be quite interesting, planning based on what it believes of himself and the world, rather than how it is, I like it.

Adding some strategist score will in effect allow it to take more actions into account but the performance is still limited since only a few context sensistive properties are available. The personalities seems to define a policy which aside from certain effectless actions is static. I think the current environment should play a bit larger role, such as by valuing the results and picking among these. Sometimes, taking all actions into account isn't feasible cause it takes too much time, I'm not sure what is the case here. You only pick one of the multiple possible strategies in one or two steps, and thereby eliminates a decent portion of the possible actions. If the extra processing added by considering all actions isn't a problem, it would otherwise be nice to test all the actions, rate them (according to the personality) and merely picking the best, or a weighted roulette. Actions can be rather stressful and without good control, some randomness is expected. On the other extreme, it would be awkward to see a highly intelligent and experienced strategist pick different actions in similar situations, especially actions that are clearly inferior.


EDIT:
It still seems weird to be though that you do allow them to act intelligectly.
should have been
It still seems weird to me though that you do not allow them to act [purely] intelligently.
 

Juuhou

Sponsor

Um wow. This script is gonna come in handy. This reminds me of the strategies (tactics) you can employ on your characters in the "Tales of" games and the Star Ocean games. Although it isnt completed finished, I can't wait until this comes out. I can see this being one of those must have scripts for RMXP games. :P
 
fuso;112363 said:
Don't have DRGSS here so I'm not entirely sure, but does the status "effectiveness" take into account whether the target is already affected by the status effect? Otherwise, you may want to remove the status effects that are already in effect when determining if the status skill is usable or not.

Personally I'm not into designing AI, where you try to construct an AI that works as some other actor (although to construct an AI that through some model, statistical methods for instance, learn the behavioral pattern of other actors and then possibly applies this, recursively on a meta level even, is tasty). The "influence"-scores you've created seems to push the behavior more towards the personality traits that you created initially (though merely cause you give them a certain name and try to use them in a certain way doesn't mean that the behavior that emerges nec. will be of that type. The semantics that we attribute to entities to make them easier to put into context may sometimes fool us to see more than there is.). It still seems weird to be though that you do allow them to act intelligectly. It may cause the actor to still perform some useless actions, thinking he is better than he is (or the other way around), but this should give some nice results. With the presence of a bit deeper reader, it should be quite interesting, planning based on what it believes of himself and the world, rather than how it is, I like it.

Adding some strategist score will in effect allow it to take more actions into account but the performance is still limited since only a few context sensistive properties are available. The personalities seems to define a policy which aside from certain effectless actions is static. I think the current environment should play a bit larger role, such as by valuing the results and picking among these. Sometimes, taking all actions into account isn't feasible cause it takes too much time, I'm not sure what is the case here. You only pick one of the multiple possible strategies in one or two steps, and thereby eliminates a decent portion of the possible actions. If the extra processing added by considering all actions isn't a problem, it would otherwise be nice to test all the actions, rate them (according to the personality) and merely picking the best, or a weighted roulette. Actions can be rather stressful and without good control, some randomness is expected. On the other extreme, it would be awkward to see a highly intelligent and experienced strategist pick different actions in similar situations, especially actions that are clearly inferior.

Whew Fuso, thanks for the lengthy reply. I'm still trying to read through all of this.

Oh <game_enemy>.state_effectiveness is one of those methods I used all It does is just returns a value 0-5 corresponding to the A-F setup in RMXP's database (with A being 5 and F being 0)

Code:
  def state_effectiveness(state_id)
    table = [0,5,4,3,2,1,0]
    effective = table[$data_enemies[@enemy_id].state_ranks[state_id]]
    return effective
  end

Really thanks for the reply

Juuhou":2odzehj6 said:
Um wow. This script is gonna come in handy. This reminds me of the strategies (tactics) you can employ on your characters in the "Tales of" games and the Star Ocean games. Although it isnt completed finished, I can't wait until this comes out. I can see this being one of those must have scripts for RMXP games.

Thanks for the reply
 
hi master! remember me? im the one requesting this kind of script way back in rmxp.net.
anyways, i was wondering if the other members could have options like the main character where they can auto-battle only if selected.
tnx
 
Oww... I was late finding this script that I made my own auto-battle script, which AI will never be better than yours! Mine only capable of selecting targets with highest/lowest HP, one (random) target until die, and preferably random at all time. I can only auto-use Attack, Defend, Skill, and Defend command. Now with your permission, may I merge your script with mine? (I accidentally merged it with my Game_Settings script so it won't be compatible with other scripts, and I can't just copy-paste your script :().

Anyway, it will be nice if you can set the ally AI manually during the game (maybe via game settings from the menu?).
 
Ok script is updated to V2.0 I don't know if I fixed all of the bugs so we will see about it

now SDK 2.x compliant

Also adds an addon to configure the AI stuff, enjoy and test test test!
 
Really nice...
I have to test it with TRTAB

Edit: I'm having an error when trying to use it below TRTAB
Game.exe":1dl7sv31 said:
Script 'Edits to Classes' line 62: NoMethodError occurred.

undefined method `cpu_controlled' for #<Game_Enemy:0x5846d80>
The code with this error is:
Code:
class Game_Battler
  #--------------------------------------------------------------------------
  # * Inputable?
  #--------------------------------------------------------------------------
  alias_method :trick_allyai_battler_inputable?, :inputable?
  def inputable?
    return trick_allyai_battler_inputable? && !self.cpu_controlled
  end
end
So I tried to fix that by replacing the code with
Code:
    return false if self.respond_to?(:cpu_controlled) && self.cpu_controlled
    return trick_allyai_battler_inputable?
It worked, but both the enemies and the cpu-controlled actors aren't attacking, or doing anything. Any tips?
 

vrdi

Member

Do you think someone could make this script compatible with DerVVulfman's Three-Member Battlestatus script?

Hehe, two minutes later, I figure it out :)P)
 

Taylor

Sponsor

Trickster;226911 said:
hmmm I'll take a look at it when I get the chance
I'm getting the same problem, do you think you could take a look... sooner? ^^;

Also how could I replace certain elements like attacking with the use of specific skills or a range of skills. e.g Attacking or Agressivness does not make the character 'Attack' but use certain skills or a range of skills.
The range would be my Weapon Skills using your Weapon/Amour Skill learning script, the character would try and use any skills it knows within the range, and if not, just use skill 0001.

Hope that's clear enough. My battle system is skill based you see?
 
um...this is a great script but don't necropost.

Also Trickster doesn't post here anymore, he's mostly on other RPG Maker sites now.
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top