[Review]DoubleX RMVXA Basic ATB

Purpose
Aids other scripters to learn how a basic atb system script can be written

Script Calls
  1. #  * Battler manipulations                                                     |
  2. #    1. batb_val                                                               |
  3. #       - Returns the battler's atb fill percentage                            |
  4. #    2. reset_batb_val(reset)                                                  |
  5. #       - Clears all battler's actions                                         |
  6. #       - Empties the battler's atb bar as well if reset returns true          |
Expand to see the code.


Configurations
  1.    # Sets the base atb fill time from empty to full as BASE_FILL_T seconds
  2.     # If BASE_FILL_T_VAR_ID is a natural number, the value of variable with id
  3.     # BASE_FILL_T_VAR_ID will be used instead of using BASE_FILL_T
  4.     BASE_FILL_T = 5
  5.     BASE_FILL_T_VAR_ID = 0
  6.  
  7.     # Sets the atb wait condition code as WAIT_COND_CODE
  8.     # If WAIT_COND_CODE_VAR_ID is a natural number, the value of variable with
  9.     # id WAIT_COND_CODE_VAR_ID will be used instead of using WAIT_COND_CODE
  10.     # Available atb wait condition codes:
  11.     # 0 - Wait only when an action's executing or a message's showing
  12.     # 1 - Wait when an animation's playing as well
  13.     # 2 - Wait when the target selection window's shown as well
  14.     # 3 - Wait when the skill/item selection window's shown as well
  15.     # 4 - Wait when players can input actions as well
  16.     WAIT_COND_CODE = 0
  17.     WAIT_COND_CODE_VAR_ID = 0
  18.  
  19.     # Sets the code of the unit of the turn clock as TURN_UNIT_CODE
  20.     # If TURN_UNIT_CODE_VAR_ID is a natural number, the value of variable with
  21.     # id TURN_UNIT_CODE_VAR_ID will be used instead of using TURN_UNIT_CODE
  22.     # Available codes of the unit of the turn clock:
  23.     # 0 - Seconds
  24.     # 1 - Number of executed actions in the same turn
  25.     TURN_UNIT_CODE = 0
  26.     TURN_UNIT_CODE_VAR_ID = 0
  27.  
  28.     # Sets the maximum turn clock unit as MAX_TURN_UNIT
  29.     # If MAX_TURN_UNIT_VAR_ID is a natural number, the value of variable with id
  30.     # MAX_TURN_UNIT_VAR_ID will be used instead of using MAX_TURN_UNIT
  31.     MAX_TURN_UNIT = 5
  32.     MAX_TURN_UNIT_VAR_ID = 0
  33.  
  34.     # Sets the atb fill mode as ATB_FILL_MODE
  35.     # If ATB_FILL_MODE_VAR_ID is a natural number, the value of variable with id
  36.     # ATB_FILL_MODE_VAR_ID will be used instead of using ATB_FILL_MODE
  37.     # Available atb fill modes:
  38.     # 0 - Lets battlers input and execute actions when that battler's atb's full
  39.     #     Empties and refills that battler's atb right after executing actions
  40.     # 1 - Lets battlers input actions when that battler's atb's empty
  41.     #     Refills that battler's atb right after inputting actions
  42.     #     Let battlers execute actions when that battler's atb's full
  43.     #     Empties that battler's atb right after executing actions
  44.     # The value of variable with id ATB_FILL_MODE_VAR_ID should remain the same
  45.     # during battles to ensure proper atb fillings and action executions
  46.     ATB_FILL_MODE = 0
  47.     ATB_FILL_MODE_VAR_ID = 0
  48.  
  49.     # (v1.01a+)Sets the starting atb value mode as ATB_START_MODE
  50.     # If ATB_START_MODE_VAR_ID is a natural number, the value of variable with
  51.     # id ATB_START_MODE_VAR_ID will be used instead of using ATB_START_MODE
  52.     # The starting atb value is always 0.0 for:
  53.     # - unmovable battlers
  54.     # - atb fill mode as 1
  55.     # - actors with start type surprise
  56.     # - enemies with start type preemptive
  57.     # The starting atb value is always 100.0 for:
  58.     # - movable actors with atb fill mode as 0 and start type preemptive
  59.     # - movable enemies with atb fill mode as 0 and start type surprise
  60.     # Available starting atb value mode for normal start:
  61.     # - agi is the battler's agi
  62.     # - param_max(6) is the maximum value of any battler's agi
  63.     # 0 - 0.0
  64.     # 1 - 100.0 * agi / param_max(6)
  65.     ATB_START_MODE = 0
  66.     ATB_START_MODE_VAR_ID = 0
  67.  
  68.     # (v1.02a+)Sets the party escape invocation speed as PARTY_ESC_SPEED
  69.     # It'll only be used with ATB_FILL_MODE being 1
  70.     # With ATB_FILL_MODE being 1, if no actor would be able to act without the
  71.     # party escape attempt, that attempt will fail immediately
  72.     # If PARTY_ESC_SPEED_VAR_ID is a natural number, the value of variable with
  73.     # id PARTY_ESC_SPEED_VAR_ID will be used instead of using PARTY_ESC_SPEED
  74.     PARTY_ESC_SPEED = 0
  75.     PARTY_ESC_SPEED_VAR_ID = 0
  76.  
  77.     # Sets the atb refill rate code as ATB_RATE_CODE
  78.     # If ATB_RATE_CODE_VAR_ID is a natural number, the value of variable with id
  79.     # ATB_RATE_CODE_VAR_ID will be used instead of using ATB_RATE_CODE
  80.     # Available atb refill rate code:
  81.     # - speed is
  82.     #   Battler's agi for atb fill mode 0
  83.     #   Battler's agi + batb_item_speed_sum for atb fill mode 1
  84.     # - batb_item_speed_sum is the sum of invocation speeds(+ attack speed for
  85.     #   the attack skill) of all inputted skills/items
  86.     # - DoubleX_RMVXA::BATB.base_batb_fill_t is the base atb fill time
  87.     # - Graphics.frame_rate is the number of frames per second
  88.     # - BattleManager.batb_avg_agi is the average of all battler's agi
  89.     # 0 - speed * 100.0 / DoubleX_RMVXA::BATB.base_batb_fill_t /
  90.     #     Graphics.frame_rate
  91.     # 1 - (formula in code 0) / BattleManager.batb_avg_agi
  92.     # 2 - Same as 1, except BattleManager.batb_avg_agi will always be
  93.     #     reevalauted per frame instead of just at the start of a battle
  94.     ATB_RATE_CODE = 1
  95.     ATB_RATE_CODE_VAR_ID = 0
  96.  
  97.     # Sets the code of the reset atb mechanism as ATB_RESET_CODE
  98.     # If ATB_RESET_CODE_VAR_ID is a natural number, the value of variable with
  99.     # id ATB_RESET_CODE_VAR_ID will be used instead of using ATB_RESET_CODE
  100.     # Available codes of the atb reset mechanism:
  101.     # 0 - Freezes the atb refill while not movable
  102.     # 1 - Same as 0, except the atb will be emptied when becoming unmovable
  103.     ATB_RESET_CODE = 1
  104.     ATB_RESET_CODE_VAR_ID = 0
  105.  
  106.     # Sets the 1st atb bar color as text color ATB_BAR_COLOR1
  107.     # If ATB_BAR_COLOR1_VAR_ID is a natural number, the value of variable with
  108.     # id ATB_BAR_COLOR1_VAR_ID will be used instead of using ATB_BAR_COLOR1
  109.     # The value of variable with id ATB_BAR_COLOR1_VAR_ID should remain the same
  110.     # during battles to ensure proper atb bar color displays
  111.     ATB_BAR_COLOR1 = 7
  112.     ATB_BAR_COLOR1_VAR_ID = 0
  113.  
  114.     # Sets the 2nd atb bar color as text color ATB_BAR_COLOR2
  115.     # If ATB_BAR_COLOR2_VAR_ID is a natural number, the value of variable with
  116.     # id ATB_BAR_COLOR2_VAR_ID will be used instead of using ATB_BAR_COLOR2
  117.     # The value of variable with id ATB_BAR_COLOR2_VAR_ID should remain the same
  118.     # during battles to ensure proper atb bar color displays
  119.     ATB_BAR_COLOR2 = 8
  120.     ATB_BAR_COLOR2_VAR_ID = 0
  121.  
  122.     # Sets the atb bar description text as ATB_BAR_TEXT
  123.     # If ATB_BAR_TEXT_VAR_ID is a natural number, the value of variable with id
  124.     # ATB_BAR_TEXT_VAR_ID will be used instead of using ATB_BAR_TEXT
  125.     # The value of variable with id ATB_BAR_TEXT_VAR_ID should remain the same
  126.     # during battles to ensure proper atb bar text displays
  127.     ATB_BAR_TEXT = "AP"
  128.     ATB_BAR_TEXT_VAR_ID = 0
Expand to see the code.


Games Using This Script
None so far

Video


Prerequisites
Abilities:
1. Little RGSS3 scripting proficiency to fully utilize this script

Terms Of Use
You shall keep this script's Script Info part's contents intact
You shalln't claim that this script is written by anyone other than DoubleX or his aliases
None of the above applies to DoubleX or his aliases

Instructions
1. Open the script editor and put this script into an open slot between Materials and Main, save to take effect.

Author's Notes
  1. #    1. This script's meant to be easy and simple to comprehend and utilize,   |
  2. #       meaning high level control nor freedom won't be given to users, and    |
  3. #       advanced scripting proficiencies won't be applied to this script.      |
  4. #    2. Readability's prioritized over almost everything else in this script to|
  5. #       aid scripters to learn how a basic atb system can be written.          |
  6. #    3. State's Auto-removal Timing as Action End becomes right after the state|
  7. #       owner executed all his/her/its actions to conform with the defaults    |
Expand to see the code.


FAQ
  1. #    Q1. Will this script be compatible with Victor Engine - Basic Module or   |
  2. #        Yanfly Engine Ace - Ace Battle Engine?                                |
  3. #    A1. Probably no, as there's Victor Engine - Active Time Battle, and I've  |
  4. #        been already supporting both CATB and ECATB scripts.                  |
  5. #    Q2. Why this script only has global settings and has no notetag at all?   |
  6. #    A2. To help scripters learn from this script, it's better to focus on the |
  7. #        core concepts and structures when implementing this script, while     |
  8. #        adding notetags as well might impede them from grapsing those basics. |
  9. #    Q3. May you please teach me scripting so I can fully utilize this script? |
  10. #    A3. You can ask me how to set specific settings to meet your specific     |
  11. #        needs, but it seems to me that there are many good scripting teachers |
  12. #        so you may want to ask them instead of me for learning scripting.     |
Expand to see the code.


Authors
DoubleX

Changelog
  1. #    v1.02c(GMT 1100 5-8-2015):                                                |
  2. #    1. Fixed nil enemy selection and not executing all confirmed actions bug  |
  3. #    2. Further improved this script's compactness, efficiency and readability |
  4. #    v1.02b(GMT 1300 5-7-2015):                                                |
  5. #    1. Fixed hidden battlers and updating atb while game messages' showing bug|
  6. #    2. Improved this script's efficiency                                      |
  7. #    v1.02a(GMT 1200 1-7-2015):                                                |
  8. #    1. Lets users set the party escape speed in atb fill mode 1               |
  9. #    2. On action end now triggers when a battler processed all the actions    |
  10. #    v1.01a(GMT 1100 13-6-2015):                                               |
  11. #    1. Lets users select the starting atb value formulae                      |
  12. #    2. Fixed clearing empty log window upon turn start bug                    |
  13. #    3. Fixed failed party escape not costing anything bug                     |
  14. #       - This bug's still present in atb fill mode 1                          |
  15. #    4. Fixed enemies not executing actions under some conditions bug          |
  16. #    5. Simplified the actor input selection implementations                   |
  17. #    v1.00a(GMT 1400 10-6-2015):                                               |
  18. #    1. 1st version of this script finished                                    |
Expand to see the code.


Download Link
http://pastebin.com/5xUZfbbB

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