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.

Enemy Only Attack Leader

i'm looking for a way to make the enemies attack only the first hero (AKA: leader hero) and i was wondering what codeline i should change, and in what script does this line takes place.
very easy to solve...FOR YOU!!!-for me it's a problem:D
 
Look in Game_Party, under this method:
Code:
  #--------------------------------------------------------------------------
  # * Random Selection of Target Actor
  #     hp0 : limited to actors with 0 HP
  #--------------------------------------------------------------------------
  def random_target_actor(hp0 = false)
    # Initialize roulette
    roulette = []
    # Loop
    for actor in @actors
      # If it fits the conditions
      if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
        # Get actor class [position]
        position = $data_classes[actor.class_id].position
        # Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2
        n = 4 - position
        # Add actor to roulette n times
        n.times do
          roulette.push(actor)
        end
      end
    end
    # If roulette size is 0
    if roulette.size == 0
      return nil
    end
    # Spin the roulette, choose an actor
    return roulette[rand(roulette.size)]
  end

The last line is what picks which actor based off their position.

Basically, what you will want to do is just change that block so instead of basing everything off their battle positions, it choses based off position in the party.

Let me know if you just want the anser given to you.
 
No, it the way they do it is the closer to the front, the more times an actor is added to the roulette. Front actors would be in like 4 time, middle 3 and back 2.

Anyways, if you want them to just start with the first actor and work their way back, just replace your method with this (untested).

Code:
  #--------------------------------------------------------------------------
  # * Random Selection of Target Actor
  #     hp0 : limited to actors with 0 HP
  #--------------------------------------------------------------------------
  def random_target_actor(hp0 = false)
    # Loop
    for actor in @actors
      # If it fits the conditions
      if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
        return actor
      end
    end
    return nil
  end

That should do the trick.
 

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