[VX Ace] Help with turn order

Discussion in 'RGSSx Script Support' started by S.Court, Apr 7, 2018.

Thread Status:
Not open for further replies.
  1. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    96
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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
     
    #1
  2. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    11,584
    Likes Received:
    11,568
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    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)
     
    #2
    S.Court likes this.
  3. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,668
    Likes Received:
    686
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    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.
     
    #3
    S.Court likes this.
  4. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    96
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    @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?
     
    #4
  5. Sixth

    Sixth Veteran Veteran

    Messages:
    2,121
    Likes Received:
    788
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    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.
     
    #5
  6. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    96
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    @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
     
    #6
  7. Sixth

    Sixth Veteran Veteran

    Messages:
    2,121
    Likes Received:
    788
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    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.
     
    #7
  8. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    96
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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
     
    #8
  9. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,132
    Likes Received:
    10,300
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #9
Thread Status:
Not open for further replies.

Share This Page