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.

Turn Order Script?

Maybe I'm just dumb, but could anyone tell me what is going on in this part of Scene_Battle:

Code:
#--------------------------------------------------------------------------
  # * Make Action Orders
  #--------------------------------------------------------------------------
  def make_action_orders
    # Initialize @action_battlers array
    @action_battlers = []
    # Add enemy to @action_battlers array
    for enemy in $game_troop.enemies
      @action_battlers.push(enemy)
    end
    # Add actor to @action_battlers array
    for actor in $game_party.actors
      @action_battlers.push(actor)
    end
    # Decide action speed for all
    for battler in @action_battlers
      battler.make_action_speed
    end
    # Line up action speed in order from greatest to least
    @action_battlers.sort! {|a,b|
      b.current_action.speed - a.current_action.speed }
  end

I'm guessing the first couple lines must be putting active (i.e. in-party, non-dead) enemies and players into the array but I don't get much the rest. How is the DBS determining the turn order here?

I'm just curious because I'd want to do a similar turn order in a custom script, or find some easier way to do so.
 
for battler in @action_battlers
battler.make_action_speed
end
It picks a random + based on stats number and it's considered the battler's "turn". It's a 1 line command in Game_Battler 1

# Line up action speed in order from greatest to least
@action_battlers.sort! {|a,b|
b.current_action.speed - a.current_action.speed }
That sorts the action/battlers afterwards. They are then in their turn order
 
I found that 1 line command in Game_Battler 1:

Code:
#--------------------------------------------------------------------------
  # * Determine Action Speed
  #--------------------------------------------------------------------------
  def make_action_speed
    @current_action.speed = agi + rand(10 + agi / 4)
  end

So if I got this right... Say Basil has 62 Agility... So it'd be 62 + rand(10 + 62 / 4)... Or, 62 + a random number between 0-26 (25.5 rounded up); I think that's how rand works. That means his action speed can range from 62-88?

EDIT: I'll assume from the silence that means yes. All righty, then! Thanks for that post, Sandgolem. No, I'm not being sarcastic.
 

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