[VX] Action Order

Action Order
by Dargor
Version 1.9


Introduction

This script displays who's turn is next in a battle, based on the battlers attack speed. Exactly like in FF10 for those who have played this game.  

Screenshots

Image

Script

  1. #==============================================================================
  2. # ** Action Order
  3. #------------------------------------------------------------------------------
  4. #   © Dargor, 2008-2009
  5. #  28/01/09
  6. #  Version 1.9
  7. #------------------------------------------------------------------------------
  8. #  VERSION HISTORY:
  9. #   - 1.0 (22/06/08), Initial release
  10. #   - 1.1 (22/06/08), Added options for the window's opacity/height
  11. #   - 1.2 (22/06/08), Removed the window from the Party Command phase
  12. #   - 1.3 (22/06/08), Bug fixed with the window's disposal
  13. #   - 1.4 (27/06/08), Added battlers order for next turn
  14. #   - 1.5 (27/06/08), Added action speed preview
  15. #   - 1.6 (27/06/08), Added options for Item/Skill windows size correction
  16. #   - 1.7 (27/06/08), Removed dependency over the Custom Commands script
  17. #   - 1.8 (28/01/09), Fixed monsters graphics in action order window
  18. #   - 1.9 (28/01/09), Improved precision when defining action order.
  19. #                     The script now redefines only the acting battler's speed
  20. #                     instead of the whole Party + Troop
  21. #------------------------------------------------------------------------------
  22. #  INSTRUCTIONS:
  23. #   - Paste this above main
  24. #   - Edit the constants in Action_Order module
  25. #==============================================================================
  26.  
  27. #==============================================================================
  28. # ** Action Order Customization Module
  29. #==============================================================================
  30.  
  31. module Action_Order
  32.   # Actors face graphic offset (X,Y)
  33.   # SYNTAX: Face_Offset = face_name => {face_index => [x,y]}}
  34.   Face_Offset = {
  35.                   'Actor1' => {0 => [0, 32]},
  36.                   'Evil'   => {4 => [0, 16]}
  37.                 }
  38.   Face_Offset.default = [0,32]
  39.   # Ememies battler graphic offset (X,Y)
  40.   Battler_Offset = {'Demon' => [42,72]}
  41.   Battler_Offset.default = [0, 32]
  42.   # Is the action window enabled in the Party Command selection phase?
  43.   Enabled_Party_Phase = true
  44.   # Show Actors name instead of face
  45.   Actor_Names = false
  46.   # Show enemies name instead of battler graphic
  47.   Enemy_Names = false
  48.   # Action Window Opacity
  49.   Window_Opacity = 255
  50.   Window_Back_Opacity = 160
  51.   # Maximum number of battlers visible at the same time in the window
  52.   Battlers_Max = 8
  53.   # Small Windows (True is Recommended)
  54.   Small_Windows = true
  55.   # Maximum number of columns when using small windows (1 is recommended)
  56.   Small_Windows_Column_Max = 1
  57. end
  58.  
  59. #==============================================================================
  60. # ** Game_BattleAction
  61. #------------------------------------------------------------------------------
  62. #  This class handles battle actions. This class is used within the
  63. # Game_Battler class.
  64. #==============================================================================
  65.  
  66. class Game_BattleAction
  67.   #--------------------------------------------------------------------------
  68.   # * Alias Listing
  69.   #--------------------------------------------------------------------------
  70.   alias dargor_vx_action_order_action_make_speed make_speed
  71.   #--------------------------------------------------------------------------
  72.   # * Confirm Action Speed
  73.   #--------------------------------------------------------------------------
  74.   def make_speed
  75.     # The usual
  76.     # dargor_vx_action_order_action_make_speed
  77.     @speed = battler.agi #+ rand(5 + battler.agi / 4)
  78.     @speed += skill.speed if skill?
  79.     @speed += item.speed if item?
  80.     @speed += 2000 if guard?
  81.     @speed += 1000 if attack? and battler.fast_attack
  82.     @speed += battler.index * 2 if attack? and battler.is_a?(Game_Actor)
  83.     @speed += battler.index
  84.   end
  85. end
  86.  
  87. #==============================================================================
  88. # ** Window_Item
  89. #------------------------------------------------------------------------------
  90. #  This window displays a list of inventory items for the item screen, etc.
  91. #==============================================================================
  92.  
  93. class Window_Item < Window_Selectable
  94.   #--------------------------------------------------------------------------
  95.   # * Alias Listing
  96.   #--------------------------------------------------------------------------
  97.   alias dargor_vx_action_order_window_item_refresh refresh
  98.   #--------------------------------------------------------------------------
  99.   # * Refresh
  100.   #--------------------------------------------------------------------------
  101.   def refresh
  102.     if $game_temp.in_battle && Action_Order::Small_Windows
  103.       @column_max = Action_Order::Small_Windows_Column_Max
  104.       self.width = 412
  105.       self.x = 132
  106.     end
  107.     dargor_vx_action_order_window_item_refresh
  108.   end
  109. end
  110.  
  111. #==============================================================================
  112. # ** Window_Skill
  113. #------------------------------------------------------------------------------
  114. #  This window displays a list of usable skills on the skill screen, etc.
  115. #==============================================================================
  116.  
  117. class Window_Skill < Window_Selectable
  118.   #--------------------------------------------------------------------------
  119.   # * Alias Listing
  120.   #--------------------------------------------------------------------------
  121.   alias dargor_vx_action_order_window_skill_refresh refresh
  122.   #--------------------------------------------------------------------------
  123.   # * Refresh
  124.   #--------------------------------------------------------------------------
  125.   def refresh
  126.     if $game_temp.in_battle && Action_Order::Small_Windows
  127.       @column_max = Action_Order::Small_Windows_Column_Max
  128.       self.width = 412
  129.       self.x = 132
  130.     end
  131.     dargor_vx_action_order_window_skill_refresh
  132.   end
  133. end
  134.  
  135. #==============================================================================
  136. # ** Window_ActionOrder
  137. #------------------------------------------------------------------------------
  138. #  This window displays action battlers order on the battle screen.
  139. #==============================================================================
  140.  
  141. class Window_ActionOrder < Window_Selectable
  142.   #--------------------------------------------------------------------------
  143.   # * Object Initialization
  144.   #--------------------------------------------------------------------------
  145.   def initialize
  146.     super(0,56,132, 40 + Action_Order::Battlers_Max * 24)
  147.     self.active = false
  148.     self.visible = Action_Order::Enabled_Party_Phase
  149.     self.opacity = Action_Order::Window_Opacity
  150.     self.back_opacity = Action_Order::Window_Back_Opacity
  151.     self.index = 0
  152.     @action_battlers = []
  153.     @next_action_battlers = []
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # * Make Action Orders
  157.   #--------------------------------------------------------------------------
  158.   def make_action_orders(action_battlers)
  159.     return if action_battlers == @action_battlers
  160.     @action_battlers = action_battlers
  161.     for battler in @action_battlers
  162.       @action_battlers.delete(battler) if battler.dead?
  163.       @action_battlers.delete(battler) if battler.hidden
  164.     end
  165.     if @next_action_battlers.empty?
  166.       mul = (Action_Order::Battlers_Max.to_f / @action_battlers.size.to_f).ceil
  167.       for i in 0...mul
  168.         @next_action_battlers += @action_battlers.dup
  169.       end
  170.     end
  171.     refresh
  172.   end
  173.   def remove_first_battler
  174.     @action_battlers.delete_at(0)
  175.     refresh
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # * Remove Battler
  179.   #--------------------------------------------------------------------------
  180.   def remove_battler(battler)
  181.     @action_battlers.delete(battler)
  182.     for battler in @action_battlers
  183.       @action_battlers.delete(battler) if battler.dead?
  184.     end
  185.     refresh
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # * Refresh
  189.   #--------------------------------------------------------------------------
  190.   def refresh
  191.     self.contents.clear
  192.     return if @action_battlers.empty?
  193.     @item_max = @action_battlers.size
  194.     @all_action_battlers = @action_battlers + @next_action_battlers
  195.     create_contents
  196.     for i in 0...@all_action_battlers.size
  197.       battler = @all_action_battlers[i]
  198.       if battler.is_a?(Game_Enemy)
  199.         name = "" + battler.battler_name
  200.         hue = 0 + battler.battler_hue
  201.         if Action_Order::Enemy_Names
  202.           self.contents.draw_text(4,i * WLH,128,WLH,battler.name)
  203.         else
  204.           battler_name = "" + battler.battler_name
  205.           battler_hue = 0 + battler.battler_hue
  206.           draw_battler(battler_name, battler_hue, 2, i * WLH + 2)
  207.         end
  208.       else
  209.         if Action_Order::Actor_Names
  210.           self.contents.draw_text(4,i * WLH,128,WLH,battler.name)
  211.         else
  212.           draw_face(battler.face_name, battler.face_index, 2, i * WLH + 2)
  213.         end
  214.       end
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * Draw Face Graphic
  219.   #     face_name  : Face graphic filename
  220.   #     face_index : Face graphic index
  221.   #     x     : draw spot x-coordinate
  222.   #     y     : draw spot y-coordinate
  223.   #     size       : Display size
  224.   #--------------------------------------------------------------------------
  225.   def draw_face(face_name, face_index, x, y, size = 96)
  226.     bitmap = Cache.face(face_name)
  227.     rect = Rect.new(0, 0, 0, 0)
  228.     rect.x = face_index % 4 * 96 + (96 - size) / 2
  229.     rect.y = face_index / 4 * 96 + (96 - size) / 2
  230.     offset = Action_Order::Face_Offset[face_name][face_index]
  231.     offset = Action_Order::Face_Offset.default if offset.nil?
  232.     rect.x += offset[0]
  233.     rect.y += offset[1]
  234.     rect.width = size
  235.     rect.height = 20
  236.     self.contents.blt(x, y, bitmap, rect)
  237.     bitmap.dispose
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # * Draw Battler Graphic
  241.   #     battler_name  : Face graphic filename
  242.   #     battler_hue : Face graphic index
  243.   #     x     : draw spot x-coordinate
  244.   #     y     : draw spot y-coordinate
  245.   #     size       : Display size
  246.   #--------------------------------------------------------------------------
  247.   def draw_battler(battler_name, battler_hue, x, y, size = 96)
  248.     bitmap = Bitmap.new("Graphics/Battlers/#{battler_name}")
  249.     bitmap.hue_change(battler_hue)
  250.     rect = Rect.new(4, 4, 0, 0)
  251.     offset = Action_Order::Battler_Offset[battler_name]
  252.     offset = Action_Order::Battler_Offset.default if offset.nil?
  253.     rect.x = offset[0]
  254.     rect.y = offset[1]
  255.     rect.width = size
  256.     rect.height = 20
  257.     self.contents.blt(x, y, bitmap, rect)
  258.     bitmap.dispose
  259.   end
  260. end
  261.  
  262. #==============================================================================
  263. # ** Scene_Battle
  264. #------------------------------------------------------------------------------
  265. #  This class performs battle screen processing.
  266. #==============================================================================
  267.  
  268. class Scene_Battle < Scene_Base
  269.   #--------------------------------------------------------------------------
  270.   # * Alias Listing
  271.   #--------------------------------------------------------------------------
  272.   alias dargor_vx_action_order_battle_make_action_orders make_action_orders
  273.   alias dargor_vx_action_order_battle_execute_action execute_action
  274.   alias dargor_vx_action_order_battle_start start
  275.   alias dargor_vx_action_order_battle_start_main start_main
  276.   alias dargor_vx_action_order_battle_terminate terminate
  277.   alias dargor_vx_action_order_update_basic update_basic
  278.   alias dargor_vx_action_order_next_actor next_actor
  279.   alias dargor_vx_action_order_prior_actor prior_actor
  280.   alias dargor_vx_action_order_start_party_command_selection start_party_command_selection
  281.   alias dargor_vx_action_order_start_actor_command_selection start_actor_command_selection
  282.   alias dargor_vx_action_order_update_actor_command_selection update_actor_command_selection
  283.   alias dargor_vx_action_order_update_item_selection update_item_selection
  284.   alias dargor_vx_action_order_update_skill_selection update_skill_selection
  285.   #--------------------------------------------------------------------------
  286.   # * Start processing
  287.   #--------------------------------------------------------------------------
  288.   def start
  289.     dargor_vx_action_order_battle_start
  290.     @action_index = -1
  291.     @action_window = Window_ActionOrder.new
  292.     make_action_orders
  293.     @action_window.make_action_orders(@action_battlers)
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # * Terminate processing
  297.   #--------------------------------------------------------------------------
  298.   def terminate
  299.     dargor_vx_action_order_battle_terminate
  300.     @action_window.dispose
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Basic Update Processing
  304.   #     main : Call from main update method
  305.   #--------------------------------------------------------------------------
  306.   def update_basic(main = false)
  307.     dargor_vx_action_order_update_basic(main)
  308.     @action_window.update
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # * Start party command selection
  312.   #--------------------------------------------------------------------------
  313.   def start_party_command_selection
  314.     @action_window.visible = Action_Order::Enabled_Party_Phase
  315.     if $game_temp.in_battle
  316.       make_action_orders
  317.     end
  318.     dargor_vx_action_order_start_party_command_selection
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # * Start party command selection
  322.   #--------------------------------------------------------------------------
  323.   def start_actor_command_selection
  324.     @action_window.open
  325.     @action_window.visible = true
  326.     dargor_vx_action_order_start_actor_command_selection
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # * Start Execution of Battle Processing
  330.   #--------------------------------------------------------------------------
  331.   def start_main
  332.     @action_window.visible = true
  333.     dargor_vx_action_order_battle_start_main
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # * Go to Command Input for Next Actor
  337.   #--------------------------------------------------------------------------
  338.   def next_actor
  339.     dargor_vx_action_order_next_actor
  340.     make_action_orders
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # * Go to Command Input of Previous Actor
  344.   #--------------------------------------------------------------------------
  345.   def prior_actor
  346.     dargor_vx_action_order_prior_actor
  347.     make_action_orders
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # * Create Action Orders
  351.   #--------------------------------------------------------------------------
  352.   def make_action_orders
  353.     dargor_vx_action_order_battle_make_action_orders
  354.     @action_window.make_action_orders(@action_battlers)
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # * Create Action Order (For a single battler)
  358.   #     battler : Battler
  359.   #--------------------------------------------------------------------------
  360.   def make_action_order(battler)
  361.     @action_battlers = []
  362.     unless $game_troop.surprise
  363.       @action_battlers += $game_party.members
  364.     end
  365.     unless $game_troop.preemptive
  366.       @action_battlers += $game_troop.members
  367.     end
  368.     battler.action.make_speed
  369.     @action_battlers.sort! do |a,b|
  370.       b.action.speed - a.action.speed
  371.     end
  372.     @action_window.make_action_orders(@action_battlers)
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # * Execute Battle Actions
  376.   #--------------------------------------------------------------------------
  377.   def execute_action
  378.     dargor_vx_action_order_battle_execute_action
  379.     @action_window.remove_first_battler
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # * Update Actor Command Selection
  383.   #--------------------------------------------------------------------------
  384.   def update_actor_command_selection
  385.     dargor_vx_action_order_update_actor_command_selection
  386.     return if @active_battler.nil?
  387.     if @actor_command_window.methods.include?('selection')
  388.       case @actor_command_window.selection
  389.       when Vocab::attack
  390.         unless @active_battler.action.attack?
  391.           @active_battler.action.clear
  392.           @active_battler.action.set_attack
  393.           make_action_order(@active_battler)
  394.         end
  395.       when Vocab::guard
  396.         unless @active_battler.action.guard?
  397.           @active_battler.action.clear
  398.           @active_battler.action.set_guard
  399.           make_action_order(@active_battler)
  400.         end
  401.       else
  402.         @active_battler.action.clear
  403.       end
  404.     else
  405.       case @actor_command_window.index
  406.       when 0
  407.         unless @active_battler.action.attack?
  408.           @active_battler.action.clear
  409.           @active_battler.action.set_attack
  410.           make_action_order(@active_battler)
  411.         end
  412.       when 2
  413.         unless @active_battler.action.guard?
  414.           @active_battler.action.clear
  415.           @active_battler.action.set_guard
  416.           make_action_order(@active_battler)
  417.         end
  418.       else
  419.         @active_battler.action.clear
  420.       end
  421.     end
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # * Update Item Selection
  425.   #--------------------------------------------------------------------------
  426.   def update_item_selection
  427.     @item = @item_window.item
  428.     if @active_battler.action.item.id != @item.id
  429.       @active_battler.action.clear
  430.       @active_battler.action.set_item(@item.id)
  431.       make_action_order(@active_battler)
  432.     end
  433.     dargor_vx_action_order_update_item_selection
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # * Update Skill Selection
  437.   #--------------------------------------------------------------------------
  438.   def update_skill_selection
  439.     @skill = @skill_window.skill
  440.     if @active_battler.action.skill.id != @skill.id
  441.       @active_battler.action.clear
  442.       @active_battler.action.set_skill(@skill.id)
  443.       make_action_order(@active_battler)
  444.     end
  445.     dargor_vx_action_order_update_skill_selection
  446.   end
  447. end
  448.  
  449. #==============================================================================
  450. # ** Window_BattleMessage
  451. #------------------------------------------------------------------------------
  452. #  Message window displayed during battle. In addition to the normal message
  453. # window functions, it also has a battle progress narration function.
  454. #==============================================================================
  455.  
  456. class Window_BattleMessage < Window_Message
  457.   #--------------------------------------------------------------------------
  458.   # * Get Text From Last Line
  459.   #--------------------------------------------------------------------------
  460.   def last_instant_text
  461.     line = @lines[-1]
  462.     line = @lines[0] if line.nil?
  463.     return line
  464.   end
  465. end
  466.  
Expand to see the code.


Credits and Thanks

Thanks to J4iru5 for requesting this script.
Dude wow!

Does it work exactly like Final Fantasy X?

Now you just need to do the battle algorithms and it'd be set!
-Krobe
Request... can you make it so that the window only appear during the command input phase of the battle.. I'm using a sideview CBS and it obstructs the battle view... great script btw...
I noticed that the window doesn't disappear after battles with RPG Tankentai's Sideview Battle System Version 2.6
Great script but it would be nice if window height and opacity could be added to the customisation module.
Also if it showed actions for the next turn as well as the current turn that would be useful as well.
Great script man, but, is it exactly like FFX? Like, if I choose "Quick Atack", will it change the "Who's Next" table?
@NunoAle
Yes it will.

@iceplosion
I have added the opacity and height options. The height is determined bu the number of battlers visible at the same time in the window.

@van helblaze 
Fixed

@Xemnas13
Done.
Dargor you're awesome.
Oh god, i love this script, its great, thank you so much!
Can I modify how big faces have to be? Is there a limit?
  -KRoP
Dargor, you're God to me.
WOOOOO! Thanks Dargor, this script owns!
lol, i feel so cool being credited, Dargor, you're like a hero dude.
But, do you think it could be so that when a character executes a move, it is done right away, so that the character might have several moves in row (depending on agi)?
Love it, if this were to happen! Thanks again Dargor

Edit: I think this means the one with the most agi goes first in battle
Really cool!!!  love this script thanks alot, it really looks good on the battle screen.
I'm curious, would this happen to be compatible with the RPG Tankentai battle system?

EDIT: Never mind...just saw J4iru5's script request.:) This should be really great, (not at my home computer, so can't try it out) considering I'm also using the RPG Tankentai battle system.
Hyper Wind wrote:
I'm curious, would this happen to be compatible with the RPG Tankentai battle system?

EDIT: Never mind...just saw J4iru5's script request.:) This should be really great, (not at my home computer, so can't try it out) considering I'm also using the RPG Tankentai battle system.

the new version of the script works just fine with the SBS
Just one question, what does WLH stand for in the script?  (Trying to mod this a bit to get it more to my tastes, I can get it the way I want fine, just was wondering what it stood for, Window_length_height?)
It's Window Line Height.

@J4iru5
I'll try to do that. 
King Red Of Pancakes wrote:
Can I modify how big faces have to be? Is there a limit?
  -KRoP
Dargor, lets say I wanted to make the faces horizontal, I've already hacked it up so it works like that perfect, only thing is the box that shows the current selection, sort of like a show_choice box or w/e.  How would I get it to resize the thing to go horizontal and only size wide instead of being the entire width and only 20 high?
Wonderful script, its going straight into my game. I loved the FF10 Battle System
Great script! But would we be able to use pictures for monsters. Standard ones, I might add, like in FFX it's used? (Monster A, Monster B, BOSS)

You can see that here:
http://img84.imageshack.us/img84/9871/49093vy3.jpg
http://img241.imageshack.us/img241/6841 ... eenyp1.jpg

And maybe you know what that means in FFX, when one character's face is closer to the left than the other one? Showing how much more say 'passive' attacks you should use instead of 'active' attacks to get more or sooner turns? You can see that really clear in screen 2, and I believe no one has implemented this in a script like this.

EDIT:
I got some points of critique after testing it out. Hope you dont mind?

1. The bar is set every turn at the moment. Meaning that after you perform the actions, the bar refreshes fully. In FFX, and I find this the better way, the bar is always refreshing in the sense that it always stays active and changes on the different actions of the player. It doesnt disappear for a moment and start the battle all over again. Which brings me to point 2.
2. In this script, the bar changes/refreshes when you select a command. Meaning, you would have to press ESC and perform a different action for your tactical way of playing (which is what this system is pretty much meant for). In FFX, and again this is an important feature, you already see how the action order will change when you put your select arrow on a command (meaning you do not select it yet!). This way, it's a lot easier to choose your strategy.
3. The monsters dont disappear! The graphic that is. It's action order is gone, so the monster is not active anymore, but it is still visible in the battle screen. Odd...

Other than that, the design is very nice and the action order works in the basic sense, props!
So, I was just messing with the Tankentai sideview battle system, and there is an option to have an enemy attack more then once per turn.  When I enable that for an enemy to attack twice per turn, it adds its name onto the list twice, but it removes both once it attack once.

I noticed in your script and in Tankentai, that you both modify the make_action_orders.

Any suggestions?
Thanks for the comments and suggestions, these are all very pertinent.
The basic idea of the script was simply to display a single turn based on the VX action speed algorithm, but I was also planning on doing it more 'FF10' like.
Besides that, with all your comments and suggestions, I'm going to release an even better version of this script very soon.

Thanks a lot ant take care!
-Dargor
King Red Of Pancakes wrote:
King Red Of Pancakes wrote:
Can I modify how big faces have to be? Is there a limit?
  -KRoP

You can modify the height in the draw_face method of Window_ActionOrder. The default value for width is 96 and height is 20.
Dargor, I have a problem...

Like, I have hidden monsters in most of my battles. And, while they are hidden, their names appear, even though they aren't seeable or do nothing in the battle.

How can I fix this?
NunoAle wrote:
How can I fix this?

With scripting.
Well...

Can someone fix it for me then xD?
is there a way I can change the coordinates of the Action Order box?
NunoAle wrote:
Dargor, I have a problem...

Like, I have hidden monsters in most of my battles. And, while they are hidden, their names appear, even though they aren't seeable or do nothing in the battle.

How can I fix this?


I'll fix that, I have never though about hidden monsters. Thanks for pointing this out.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=49866