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.

how to force actor[1] to randomly attack

tatao

Member

"force action" allows you to force an actor to attack, but only based on his position inside the party

i would like to know the line to force a specific actor in the database to attack
 
Attack and only attack?

Well, in Scene_Battle under def phase3_next_actor, you can just set the actions automatically if active battler's id is a certain id.

Code:
class Scene_Battle
  Force_Attack_Battlers = [1]
  alias_method :seph_forceattackbattlers_scnbtl_p3na, :phase3_next_actor
  def phase3_next_actor
    seph_forceattackbattlers_scnbtl_p3na
    return if @phase == 4
    if Force_Attack_Battlers.include?(@active_battler.actor_id)
      @active_battler.current_action.kind = 0
      @active_battler.current_action.basic = 0
      @active_battler.current_action.target_index = rand($game_troop.enemies.size)
      phase3_next_actor
    end
end

Just modify the Force_Attack_Battlers with actor ids who will attack randomly.
 

Jason

Awesome Bro

Seph, does this mean that you could make an NPC join your party and they attack on their own ? If so, would there be a way to turn this on and off, and make it usuable with more than 1 character ?
 
Sure, I guess.

Code:
class Game_Actor
  Force_Attack_Battlers = [1]
  attr_accessor :force_attacking
  alias_method :seph_forceattacking_gmactr_setup, :setup
  def setup(actor_id)
    seph_forceattacking_gmactr_setup(actor_id)
    @force_attacking = Force_Attack_Battlers.include?(actor_id)
  end
end

class Scene_Battle
  Force_Attack_Battlers = [1]
  alias_method :seph_forceattackbattlers_scnbtl_p3na, :phase3_next_actor
  def phase3_next_actor
    seph_forceattackbattlers_scnbtl_p3na
    return if @phase == 4
    if @active_battler.force_attacking
      @active_battler.current_action.kind = 0
      @active_battler.current_action.basic = 0
      @active_battler.current_action.target_index = rand($game_troop.enemies.size)
      phase3_next_actor
    end
  end
end

Fill your Force_Attack_Battlers = [1] with actor id numbers.
To turn on add off, use
Code:
$game_actors[actor_id].force_attacking = true or false
 

tatao

Member

actually i would like to locate the position of a specific actor inside the party, so i'm trying something like

if @party_members.self[0] = 1 then #trying to check if actor 1 is in position 0 of the array
$game_variables[16] = 1 # assigning value 1 to variable 16

it doesn't seem to work
i used the event function "call script" and i added this test inside

any idea?
 

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