[VX Ace] Help with turn order

Hello. I created a battle and I noticed sometimes the slower battler can attack first, I tried to check and I think I found the trouble, and it's the random factor in Game_Action script

Code:
  #--------------------------------------------------------------------------
  # * Calculate Action Speed
  #--------------------------------------------------------------------------
  def speed
    speed = subject.agi + rand(5 + subject.agi / 4)
    speed += item.speed if item
    speed += subject.atk_speed if attack?
    speed
  end

I removed the random calc but the problem persists, is there another script is involved in turn order? How can I modify the turn order to remove the involved random factor? Thanks for the help
Check the speed of the item or skill used, as that factors in too. For example if actor A has Agility 50 and actor B has Agility 44, usually Actor B goes first, but if actor A uses a skill with speed 10, then A will now go first, as Actor A's Agility + skill speed is 50 + 10 > 55 (B's Agility)
Code:
def self.make_action_orders
    @action_battlers = []
    @action_battlers += $game_party.battle_members unless @surprise
    @action_battlers += $game_troop.members unless @preemptive
    @action_battlers.each {|battler| battler.make_speed }
    @action_battlers.sort! {|a,b| b.speed - a.speed }
  end

that is the real sorting of actions, from BattleManager.
what you posted initially, is the battler's own action speed, which is called through battler.make_speed

Code:
@action_battlers.sort! {|a,b| b.speed - a.speed }
has the final say.
@bgillisp No, any of the moves I used for the test has an increased/decreased speed.

@gstv87 I see, is there any random factor involved in this part as well?
Code:
def self.make_action_orders
    @action_battlers = []
    @action_battlers += $game_party.battle_members unless @surprise
    @action_battlers += $game_troop.members unless @preemptive
    @action_battlers.each {|battler| battler.make_speed }
    @action_battlers.sort! {|a,b| b.speed - a.speed }
  end

that is the real sorting of actions, from BattleManager.
what you posted initially, is the battler's own action speed, which is called through battler.make_speed

Code:
@action_battlers.sort! {|a,b| b.speed - a.speed }
has the final say.
That's the sorting process itself, and it is based on the exact method posted in the opening post, so modifying that part directly modifies the sorting order.
If you removed the random part, there should be no randomization left in the order.

Basic attacks can also take advantage of the feature named Attack Speed, but only basic attacks, any other skill will ignore this feature. So, if you tested it with basic attacks (Skill 1), than check if your actors/enemies have this feature somewhere on them or not.
Other than this, the already mentioned Speed setting for items/skills is the only other factor for determining the order of actions, unless you have some custom scripts changing this.
@Sixth I'm not using any other battle system related script and I added a script between materials and main with this

Code:
  #--------------------------------------------------------------------------
  # * Calculate Action Speed
  #--------------------------------------------------------------------------
  def speed
    speed = subject.agi
    speed += item.speed if item
    speed += subject.atk_speed if attack?
    speed
  end

But it's still adding certain random factor with turn order where sometimes the slower character is moving first
You can try to debug it by adding this line right above the simple speed line in that method:
Code:
p "#{subject.name}'s speed: #{speed}"
And check what's the console printing. If the speed values are not what you would expect, than something changes it, and you will have to find that something.
Well, I removed the custom script and I directly modified the one in Game_Action, and it worked. So I guess this thread can be closed
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/vx-ace-help-with-turn-order.93681/