RPG Maker Forums

This is my AP Combat Mechanic, a plugin for Yanlfy's Battle Engine.
(This script is no longer being developed... The version here is the final version)

This script is no longer supported in any meaningful way, besides maintaining links. I hope you understand, that after several years of not even looking at Ruby code, it would require an unusual amount of time to re-acquaint myself with my own work, long enough to try and even identify fixes/improvements. Thus, I simply won't.



The Core:
At its core, this script is nothing more than a system built on-top of Yanfly's Battle Engine, that's replacing its default order of action, with Initiative Order (instant resolution) and Action Point costs for each action. It displays the battlers remaining AP (action points) at the top of the screen, in the exact same place that Yanfly's FTB Plugin does. This script also adds TWO new battle commands to every actor, which allow them to Delay their turn, or Pass their turn.

Every significant detail is listed verbatim in the spoilered section at the bottom of this post.


Example Video:
For those that wish to see it in action before attempting to use it. (I apologize for the quality... I am not a professional. :p )
(You will see my armor mechanic at work here as well as some additional battle commands for custom item windows. Pleas ignore them for now.)










Note: If you'll notice in the YouTube video, I am using TheoAllen's SBS v1.4 so you can be sure it works with that.



Credits:
- Yanfly
- Hime (of Hime Works, aka: Tsukihime)
- The RM community at large.

Terms of Use:


- New: I would appreciate it if you posted here letting me know you are using the script! It helps keep me motivated.
- Go crazy! Do what you wish with it. Please, make sure to credit me with a link to my blog and consider (not required) giving me a free copy of whatever made with it. I know the lions share of the work, is simply getting your game done. And for that, YOU should be thanked. I'm just glad I could give back the way I've been given. This is a great community! Lets all try to keep it great.

With Love and Cooperation!

Note: Please visit Yanfly's blog and double check its TOU to make sure nothings changed.

Requires:
- Yanfly's Battle Engine! (and to be safe, his Core as well)

Supports:
- Hime's - Command Manager. (For ease of organizing the two new actor battle commands)

Compatibility:
I do not expect this script to work along side any other script, other than Yanfly's Battle Engine, that touches the BattleManager or Scene_Battle classes. So good luck trying.

Known Issues:
- Applying AP Adjustments to non-permanent states (that can be added or removed in battle), is buggy and can break your battlers AP! Unfortunately, fixing this will touch a lot of disparate parts of the code and may introduce even more issues that I do not have time to handle.


You can download(v1.04) it at my blog.
(Last Updated: 15_0827)

Here is a quick look at the details of its use.


Spoiler


CHANGE LOG:

v1.00 - Initial Release

v1.01 -----------------------------------------
- Ensured surprise & preempt messages display when true.
- Removed dependency on Hime's Command Manager. (Now Optional)
- Misc housekeeping.

v1.02 -----------------------------------------
- Fixed a 'Pass Turn' Bug, caused by inadequate action clearing.
- Fixed visible glitch when enemies acted first on first turn.
- Fixed hitching in 'left' access to party command menu.
- Actors now lose Initiative on Delay. Unless disabled. (See: details)
(Implementation still getting tweaked.)
- Added 'Pass' & 'Delay' popups.

v1.03 -----------------------------------------
- Added 'AP Schedules' for Enemies.
- Added MAX_AP_MULTI for customizing default MAX AP.
- Added NEW TURN popup.
- Added SURPRSIE TURN popup.
- Fixed 'on_turn_end' issue with 'Pass Turn'
- Added 'BattleManager.surprise?' event script call.
- Added Support for Yanfly - Combat Log script.
- Added 'Delay' and 'Pass Turn' reporting to battle log.
- Fixed 'next_command' bug regarding 'actor.movable?'


v1.04 -----------------------------------------
- Fixed NEW TURN popup on dead battlers BUG.
- Fixed BattleManager.next_command BUG causing enemy actions to not
clear next_command correctly, if confused.
Code:
#===============================================================================# ACTION POINTS (AP):#-------------------------------------------------------------------------------   #------------------------------------  ACTION AP COSTS:  #------------------------------------  Applied only to Usable Items. (Skills, Items)  <ap: formula>      a = battler.self (the battler acting)      v = $game_variables      s = $game_switches      p = $game_party      t = $game_troop    The default BASE cost of all actions without note-tags is (3).    Guidelines are:      0 AP = Instant Action (Extremely limited in use, such as rare items.)        Note: Instant actions completely BREAK game balance. Use cautiously.      1 AP = Quick Action   (Should be limited to limited SELF only actions.)      2 AP = Partial Action (Intended for Item use, and SELF only actions.)      3 AP = Full Action    (All actions that effect other battlers.)      4 AP = Slow Action    (Intended for extra powerful effects.)      5 AP = V.Slow Action  (Intended for RARE extra powerful effects.)    Note:      The above guidelines are based on the DEFAULT values for Battler AP      and action Cost. However, changing the defaults will make these      guidelines pointless. Thus, all AP defined note tags utilize      value formulas for such flexibility.  #------------------------------------  BATTLER BASE AP:  #------------------------------------  Applied only to Feature Items. (Actor, Enemy, Class, Equip, State)  <ap_adjust: formula>      a = battler.self (the battler acting)      v = $game_variables      s = $game_switches      p = $game_party      t = $game_troop    All battlers being equal, have a base of 3 AP to use every turn. However,    this can change due to the addition of any feature object with AP    Adjustments. (Such as a state, or class, or piece of equipment)  #------------------------------------  BATTLER MAXIMUM AP:  #------------------------------------  Applied only to Feature Items. (Actor, Enemy, Class, Equip, State)  <ap_max_adjust: formula>      a = battler.self (the battler acting)      v = $game_variables      s = $game_switches      p = $game_party      t = $game_troop    Battlers are limited to a default maximum AP of (10) in a single turn.    This can be changed like all other limits. However, its hard to justify    why a battler would be able to perform more than THREE FULL ACTIONS in    a single turn... Unless under extremely rare haste effects.  #------------------------------------  ENEMY AP SCHEDULES:  #------------------------------------  Applied only to Enemies.  <ap_schedule: schedule>       Replace 'schedule' with the string name of the schedule you create      inside the options area below.    Enemy AP Schedules, are very powerful overrides for default AP behavior.    The value in the schedule is the 'base' value the enemy will have for    that turn of battle. It will still receive all normal AP adjustments    from feature items (listed above).    Example:      In the options section you'll find the below hash constant.      AP_SCHEDULES = {        :default      => [],        :test         => [3,4,3]      }      Each array [#,] represents a chance to act for every enemy assigned      that schedule. (starting with the very first action)      The turn on which the first action occurs, will change if the enemy      happens to have been preemptively attacked, or is benefiting from      surprise. (Just think of each turn as CHANCES TO ACT.)      In the 'test' schedule, the battler will always get at least 4 AP,      with any adjustments added to it, on its second chance to act, its      fifth chance, its eighth chance, etc... As the array repeats until      the battler dies.      Note: An actor unable to move (stun, etc) LOSES their chance to act        that turn! The chance to act in the array is still tracked, and        the battler will resume right were they would be if they had been        able to move all along.#===============================================================================# INITIATIVE:#-------------------------------------------------------------------------------  #------------------------------------  ORDER OF ACTION: (Initiative)  #------------------------------------    Initiative is determined dynamically at the beginning of every turn.    Every battler is assigned an initiative based on that battlers Finesse    (aka: Agility or AGI) with a slight bias based on whether the battler    is above or below the battlefield finesse average, and its Ingenuity    (aka: Luck or LUK) as compared to the average of all battler's    Ingenuity.    In essence, if a battler has greater than average finesse, its initiative    has less variation (positive or negative) randomization, but it is also    less effected by its ingenuity. But, if a battler has average or    lower than average finesse, its initiative variation is slightly MORE    randomized and its MORE effected by ingenuity. This way, even extremely    superior targets have at least some chance of being beaten to the punch.  #------------------------------------  FOOTING!  #------------------------------------  Applied only to Feature Items. (Actor, Enemy, Class, Equip, State)  <nimble>  <clumsy>    Flagging a feature object as nimble, will grant a +1 Footing, while    flagging it clumsy will grant a -1 Footing. The total of which is    applied to the final initiative of the battler.    Ex: A footing of -2 is by default -20% of the average finesse of the      battlefield, applied to that battlers final initiative. So, if 10%      of the battlefield avg finesse is 1, and the battlers total      initiative was to be a 10, it becomes an 8. Due to the battlers      footing.  #------------------------------------  PASS TURN (Battle Command)  #------------------------------------  Applied only to Actor or Class objects.  <cmd: pass>    Has two uses. First, it allows the battler to end its turn if it can no    longer act, such as when all its actions requiring more AP than it has    to use. Second, it allows an actor that has not taken any AP consuming    action (instant actions do not use AP!) to 'save' roughly half of its    total AP and carry it over into its next turn.    By default, 50% (rounded down) of the battlers AP is saved. Thus if a    battler has 3 AP, 2 AP will carry over. If that same battler had 4 AP,    still only 2 AM will carry over.    <ap_max_adjust: formula>    Note: The total AP that a battler can 'accumulate' this way is limited      by their AP CAP and adjusted by any feature objects with any AP Max      Adjustments.    Note: The AP carried over is based on the 'total' AP of the battler at      the time of passing the turn. Thus, there is a diminishing return as      this total increases. It is always most efficient to pass only ONE      turn before acting.  #------------------------------------  DELAY (Battle Command)  #------------------------------------  Applied only to Actor or Class objects.   <cmd: delay>    This simply 'pauses' the current actors turn, and allows the next most    battler to act instead. It can be done at any time, even if the actor    has already acted and consumed AP.    As long as an actor has AP to spend they can Delay its use until the    very end of the turn.  #------------------------------------  NEW TURN! (Popup)  #------------------------------------    By default this popup uses the "DURSTATE" rule in Yanfly's Battle Engine    POPUP_RULES hash. If you wish to change its size, color, etc... Simply    change that rules details.    Or, if you wish, you can add your own rule, and change the string called    for the popup rule.  #------------------------------------  SURPRISE SCRIPT CALL  #------------------------------------        Intended for use inside a troop event as a conditional. This way you can    check to see if the battle is a surprise, in order to execute an event    on that turn. Such as a tutorial, or plot trigger.        BattleManager.surprise?    Simply add the above script call in the 'script' section of a conditional    branch of an event.#===============================================================================# IMPORTANT!!!:#-------------------------------------------------------------------------------  #------------------------------------  EFFECT DURATIONS:  #------------------------------------    Due to the 'fluid' way that turns process in this system, effects such as    'Guard' might have significantly limited utility. It is suggested that for    those types of 'one turn' fire and forget type effects, you change their    Auto-removal Timing: from Turn End, to Action End.    Be sure to keep in mind that such effects will remain active on the    character until they 'ACT'. Thus 'Dealy' will NOT trigger Action End    processing!! Effectively, it allows for a guarding character    to stay guarded while they wait out the current turn. 'Pass Turn' however    does trigger Action End normally. This way, total 'turn' durations for    Action End triggers remains standard.#-------------------------------------------------------------------------------
Code:
module RDeus  module APCombat  #RDeus::APCombat::FREE_SURPRISE    DISSABLE_HIME_COMMAND_MANAGER = false    #--------------------------------------------    #This is the popup rule used for new turn indications.    NEW_TURN_RULE = "DURSTATE"    #Note: For reference the settings I use are:    #[   2.50,   1.0, 18, true,  false, 255,   0,   0, DEFAULT]    NEW_TURN_TEXT = "NEW TURN!"    #This is the popup rule used for new turn indications.    SUP_TURN_RULE = "DURSTATE"    #    SUP_TURN_TEXT = "!!SURPRISE TURN!!"    #--------------------------------------------    ICON_ACTION = 187      # Icon displayed when there are actions left.    ICON_EMPTY  = 185      # Icon displayed to indicate a used action.    #--------------------------------------------    #The default AP for a battler without custom assignments.    BATTLER_AP = 3    #The default MAX AP of a battler, as a multiple of that battlers    #initial AP. Including initial AP adjustments.    #Ex: Init = 3, adj + 0, Max = ((3+0) * 1.35).to_i or (4.05) = 4    #Ex: Init = 3, adj + 3, Max = ((3+3) * 1.35).to_i or (8.10) = 8    #Note: Regardless, MAX AP will never be less than a battlers initial AP.    MAX_AP_MULTI = 1.35    #The absolute maximum AP a battler can have. No exceptions.    AP_CAP = 10    #The default base AP cost of actions without defined formulas.    COST_BASE = "3" #(This must be a string value.)    #--------------------------------------------    #Setting this TRUE, will prevent actors from losing initiative when    #selecting delay.    #    #Note: Initiative loss was added to prevent a full party of very fast    #actors from 'delay' dancing their way through all of their AP before    #enemies could even act. This way, there was a good chance that given    #enough delays, an enemies action would sneak in.    DISSABLE_DELAY_INIT_LOSS = false    #The amount of initiative (speed) lost when delaying.    INIT_LOST = 1    #The chance of losing double... Delaying to often, has consequences.    DOUBLE_LOSS_RATE = 0.25    #Note: Disabling init loss on delay WILL regularly result in moments    #where the next two battlers to act are ACTORS, and this they will    #be able to 'act' and 'delay' into each other, repeatedly, until    #all their AP is gone. Kind of defeating the purpose of initiative    #all together. So be warned.    #--------------------------------------------    #The percentage adjustment applied to the battlers initiative, for each    #value (positive or negative) of footing.    #(Based on scene's total finesse average)    FOOTING = 0.1    #The variance assigned battlers with greater than average finesse.    #This value is tighter, to prevent greater negative results.    H_AMP = 0.25    #The variance assigned battlers with lower than average finesse.    #(The large variance allows for rare overlap with high finesse battlers.)    L_AMP = 0.33    #Note: To make ALL battlers use the same variance, simply make H_AMP    #   and L_AMP the same value. But do not make them ZERO, or there    #   will be NO randomization of speed values. Battlers will act 100%    #   in order of their totals, in every battle.    #       #   Conversely making them 1.0 will make all speed totally random,    #   regardless of total initiative. However, higher finesse battlers    #   will still have a greater potential result.    #--------------------------------------------    #The total of the resulting ingenuity adjustment to apply to speed.    #(Making this 0, will base speed on only finesse and footing)    ING_RATE = 1.0    #The % of avg battlefield ingenuity to reduce from adjustments for    #higher than average finesse battlers. Higher finesse battlers are    #less effected by ingenuity.    #(Finesse is always the primary determining factor)    ING_BIAS_1 = 0.25    #Battlers with less finesse depend greater on their ingenuity. But    #shouldn't often surpass battlers with far greater finesse.    ING_BIAS_2 = 0.33    #Essentially any random ingenuity bonuses that don't exceed bias % of    #the avg ingenuity of the battlefield, are ignored. Higher values    #require battlers to have greater ingenuity to gain speed.    #NOTE: Lower than average ingenuity has a penalty effect.    #---------------------------------------------------------------------------    #AP SCHEDULES:  RDeus::APCombat::AP_SCHEDULES    #---------------------------------------------------------------------------    #Make sure that the enemies MAX AP is capable of handling the values    #given to it by schedule arrays.    #    #Make sure the note tag contains a 'string' value identical to the    #  schedule symbol. Ex: the :test schedules tag would be    #  <ap_schedule: test>    #      #Note: Its possible to schedule AP greater than max, planning that    #  some enemies assigned the schedule will make better use of it,    #  while others will effectively act as though no schedule existed.    AP_SCHEDULES = { #EDIT ONLY WHATS BETWEEN THE DASHED LINES!    # :default      => [], #Keep this for reference. (Copy the syntax exactly)    #--------------------------------------------      :default      => [],      :test         => [3,4,3]    #--------------------------------------------    }#DO NOT TOUCH THIS LINE  endend

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,354
Members
137,801
Latest member
topsan
Top