Formation Bonus

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
That is why I wrote that you need to offset the values to suit your battle positions.


You can add different values to the X position and Y position, just replace the 'offset' values from the above code snippet I wrote to whatever is good for you. It is measured in pixels.


If your actors appear above and behind the enemies, and if your enemies are on the left side, than you need to add positive values to their X and Y position. If your enemies are on the left side, than add a negative X offset value and positive Y value.


Also, this script must be placed ABOVE the Implementation section of TSBS!


This script also overwrites the default damage calculations, so if you have any other script altering the damage, than this must be put above it or it needs to be addressed with a compatibility patch.
 

Cymiril

Villager
Member
Joined
May 17, 2015
Messages
8
Reaction score
1
First Language
English
Primarily Uses
Great script! I've been looking for something that lets you define rows by actor position id.

However, I was wondering if someone could show me how to take out the parts that change the formation scene. I'm using Yanfly's Party Manager, with 6 characters, 3 front (0, 1, 2) 3 back (3, 4, 5). From what I can tell, this doesn't let you change rows in battle, which is perfect... but I'd like the rows themselves to remain entirely static, unchangeable by the player (so the player only "changes rows" by the order the actors are in) - and keep the look of Party Manager. Would this make the first 3 character slots front row and the last 3 back row, regardless of what actor is there?
 

Cymiril

Villager
Member
Joined
May 17, 2015
Messages
8
Reaction score
1
First Language
English
Primarily Uses
Hey, sorry Sixth I didn't notice your fixes for Yanfly's Party Manager and Battle Symphony half way down the first page, sorry. I've got those working, now, except...

When you change the order of the party in Party Manager's Formation scene, it doesn't change in battle to reflect the new order.

Edit: Tried starting a test with 8 people in my party, 6 in active battle, and changed out someone in the default starting party for another character. The game crashed at the start of battle, with

"Script 'Yami Battle Symphony' line 2003: NoMethodError occurred.

      undefined method '[]' for nil:NilClass"

line 2003 is your

@origin_x = @screen_x = FORMATION_LOCATIONS[@formation_slot][0] + 180
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Did you apply all my fixes?

The no method error sounds like you haven't made the 2nd fix on my list (the active battle members fix).

And yeah, it got some issues with changing party members with Yanfly's Party Manager scene.

I threw up a quick fix for it, not perfect (will ruin your formation in some cases, like when reverting party changes with the revert button), but it should at least always position your actors in the first available formation slot if something goes wrong, so your actors won't be on top of each other anymore neither will they appear in the lower right corner of the formation.

class Game_Party < Game_Unit alias correct_member_form8654 rearrange_actors def rearrange_actors correct_member_form8654 max_battle_members.times do |pi| if $game_actors[@actors[pi]].formation_slot == -1 (FORMATION_ROWS * FORMATION_COLS).times do |i| if formation_slot(i).nil? $game_actors[@actors[pi]].formation_slot = i break end end end end end endclass Scene_Party < Scene_MenuBase def on_list_ok Sound.play_equip replace = $game_actors[@party_window.item] actor = $game_actors[@list_window.item] # formation addon! saved_rplace = replace.nil? ? -1 : replace.formation_slot saved_aplace = actor.nil? ? -1 : actor.formation_slot actor.formation_slot = saved_rplace if !actor.nil? replace.formation_slot = saved_aplace if !replace.nil? # formation addon end! index1 = @party_window.index actor_id1 = actor.nil? ? 0 : actor.id if actor.nil? $game_party.battle_members_array[index1] = 0 window_refresh @party_window.activate return end actor_id2 = replace.nil? ? 0 : replace.id if $game_party.battle_members_array.include?(actor_id1) index2 = $game_party.battle_members_array.index(actor_id1) $game_party.battle_members_array[index2] = actor_id2 end $game_party.battle_members_array[index1] = actor_id1 window_refresh @party_window.activate endend
The order of scripts is important as well.

Here is how it is in my old project:

1. Yami's Battle Symphony (with all it's addons)

2. Yanfly's Party Manager

3. The above patch

4. Vlue's Formation Bonus

In the battle, it should show up alright, unless you missed to add the $imported tag at the beginning of Vlue's script or if you did not comment out the mentioned lines in Vlue's script (the screen_x and screen_y definitions).

I am using an outdated version of Vlue's script, because I modified it to an unrecognizable state (added multiple formations, xparam/sparam bonuses, XP and level for each formations, bonuses scale with the level of the formation, unlock-able skills for certain formation levels, skills which require a certain formation to be executed, dozens of compatibility fixes, upgraded scene, and so on...), so I have no idea if Vlue has changed something major or not. The only thing I noticed is the ability to set up a custom grid, and I made the patch above with that update in mind.

If you followed the above steps, placed all the scripts in the required order, it should work without any issue.

If it still doesn't work, than either Vlue changed something else in his script or you did something wrong.
 

Cymiril

Villager
Member
Joined
May 17, 2015
Messages
8
Reaction score
1
First Language
English
Primarily Uses
Ok, cool thanks very much for the help,  :D   getting it all working was kind of confusing.  I wasn't having non-battle members show up in battle, so I didn't know I needed that one. Everything as far as switching works well, they rearrange and change out just fine now, but if you could humor me one more time :blush: , there's just one more problem I ran in to :
 
I have Dr. Yami's Classical ATB right under the Holder's Battler Add-on for Symphony, then your patch, and Vlue's Formation. Escape normally works fine, except when a monster is in the middle of an attack - if the escape is successful before the actor takes damage, it either freezes or crashes with this error:
 
"Script 'Yami Battle Symphony' line 1891: NoMethodError occurred.
 
undefined method 'spriteset' for #<Scene_Map:0x80d59c8>"
 
 Here's the code line 1891 falls in:

#-------------------------------------------------------------------------- # new method: pose= #-------------------------------------------------------------------------- def pose=(pose) @pose = pose return if self.actor? && !$game_party.battle_members.include?(self) self.sprite.correct_change_pose if SceneManager.scene.spriteset end 
It's so close to working right, since if the monsters are idle and not in the middle of an attack, it goes right back to the map no problem. Thanks so much again, you've been awesome, one of the coolest I've met so far (Sixth = B) )

Edit: I can stop the problem from happening if I set the Party Command window to pause the ATB when it's active, so enemies don't attack at all when selecting "Fight" or "Escape". This is kind of OK, and if there's no other way it'll have to do, but if anyone has any ideas, I'd still be interested.
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
That is a known issue in Yami's ATB. Make a search on the forum for the user name "DoubleX". He made many fixes for Yami's ATB. Install those and you should be fine.


At any rate, your issue is not caused by this script, it got nothing to do with the Formation script.
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,787
Reaction score
939
First Language
Chinese
Primarily Uses
N/A
That is a known issue in Yami's ATB. Make a search on the forum for the user name "DoubleX". He made many fixes for Yami's ATB. Install those and you should be fine.

At any rate, your issue is not caused by this script, it got nothing to do with the Formation script.
To be precise in this case, if DoubleX RMVXA Bug Fixes v1.03a+ to YSA Battle System: Classical ATB is used, triggering party escape while an action's executing should be disabled altogether.

(So being able to trigger party escape while an action's executing is an extremely strong indicator that you didn't use the bug fix :) )

I "fixed" the bug that way as uptil now I still haven't figure out any other possible way. You may want to use that bug fix as well to see if the issue's still there :)

P.S.: I hope I'm not hijacking this topic lol
 
Last edited by a moderator:

Cymiril

Villager
Member
Joined
May 17, 2015
Messages
8
Reaction score
1
First Language
English
Primarily Uses
That is a known issue in Yami's ATB. Make a search on the forum for the user name "DoubleX". He made many fixes for Yami's ATB. Install those and you should be fine.

At any rate, your issue is not caused by this script, it got nothing to do with the Formation script.
OK, sorry... I'm basically a noob (though I am trying to learn) when it comes to scripting, so when I saw the error come from Battle Symphony, I assumed it had something to do with that script and not the CATB script. Thanks so much for your patience in helping me implement this script properly.

I was wondering, though, if I could get some help on adding one note tag to the Formation Bonus script - I just realized that there is no way to define a ranged weapon, and I tried to add this to the script, before the last "end" :

class RPG::EquipItem def row_attack(user) if @note =~ /<ranged>/i return FORMATION_ROW_ATK[0] else return 0 end end end
After I added that, I put <ranged> in the note tag of a weapon and tested it.

It didn't return any errors, but it didn't do anything, either.

Did I put it in the wrong spot in the script? Should I define a new method, instead of using the one from the part of the script I want to change? Or is it just the syntax or another coding error that's wrong?
 
Last edited by a moderator:

sarkocreme

Villager
Member
Joined
Jul 10, 2013
Messages
8
Reaction score
0
First Language
English
Primarily Uses
I've got the script working with all of the fixes from Sixth. However, I had a couple questions:

1) Is it possible to change formations (and thus formation bonuses) mid battle? I'm using Yanfly's Command Party script to allow party changes in battle, but it seems formations are only set out of battle. Is it possible to set them in battle too?

2) Related to the above indirectly to set up these formation shifts correctly...is it possible to change the script to allow selecting a character that is not part of the battle party?

I know the thread's a bit old, but this script is a great addition to the battles so it would be great to work in with party switching.
 

stickyka

Veteran
Veteran
Joined
Oct 15, 2017
Messages
39
Reaction score
10
First Language
english
Primarily Uses
RMVXA
Getting nomethod error when running battle symphony and the two scripts provided here. Followed Sixth's instructions flawlessly 10 times over. line 2034 in symphony, iirc. Really want to use this, too. :(


def update_charset_origin
if bitmap
self.ox = @cw / 2
self.oy = @ch
end
end
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@stickyka Just checking - the most common reason for a no method error is because the person used an existing save file to test it. Did you start a new game after installing this script?
 

stickyka

Veteran
Veteran
Joined
Oct 15, 2017
Messages
39
Reaction score
10
First Language
english
Primarily Uses
RMVXA
@stickyka Just checking - the most common reason for a no method error is because the person used an existing save file to test it. Did you start a new game after installing this script?
Thanks so much for the speedy reply. While I'm setting up the basics for my combat system, every game is a new start. No troop testing, no loading saves, I have a player start set next to a troop.1 combat event.

EDIT: I have a suspicion it's referencing something that Sixth mentioned in the fixes, but I followed every instruction.

Just for reference, I started working with the luna engine default scripts. So, from the luna engine dlc, I just copied a luna engine file over with all the default (scene and menu customization scripts) stuff first, below that, added battle symphony, below that is the sprites script from this OP, below that is the formation script, below that is this guy's script http://www.rpgmakercentral.com/topic/6870-est-enemy-actor-position-v-32-scope_condition/ which I don't see anything that should interfere

Oh, and I have yanfly's weapon weapon attack replace above all of them which is just a notetag script that allows weapons to call a different attack skill by default attack

and below all that, a simple font change script

EDIT 2: also, either of the two, formation without symphony or symphony without the formation scripts work fine with everything else, so I'm sure it's a problem between the two - the spoiler indicates it must have something to do with the sprite draw size?
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Getting nomethod error when running battle symphony and the two scripts provided here. Followed Sixth's instructions flawlessly 10 times over. line 2034 in symphony, iirc. Really want to use this, too. :(


def update_charset_origin
if bitmap
self.ox = @cw / 2
self.oy = @ch
end
end
The fixes I made was for an older version of this script, so I can't guarantee that they will work or even still needed.
But how the heck did you manage to decipher that giant mess in my post? :D
Sorry, forum change messed it up and I don't have the project I tested those fixes anymore, nor do I remember about the things I changed in the codes.

Which fix did you apply? Only the Formation + Symphony fix or some others as well?
Note that you must set up a position setting for all of your battle members in the Symphony script in case you increased the number of the battle members from the default 4.
And yes, you must start a new game or else you may get NoMethodError issues.

Also, you should post the full error message and show us the exact line where the error points to.
Just saying that you get an error won't help much.
I can only guess that for some reason, the @cw variable is set to nil, which would cause an error for sure, but back-tracking that would take a lot of time with Symphony scripts, time which I do not have right now, sorry.
 

stickyka

Veteran
Veteran
Joined
Oct 15, 2017
Messages
39
Reaction score
10
First Language
english
Primarily Uses
RMVXA
The fixes I made was for an older version of this script, so I can't guarantee that they will work or even still needed.
But how the heck did you manage to decipher that giant mess in my post? :D
Sorry, forum change messed it up and I don't have the project I tested those fixes anymore, nor do I remember about the things I changed in the codes.

Which fix did you apply? Only the Formation + Symphony fix or some others as well?
Note that you must set up a position setting for all of your battle members in the Symphony script in case you increased the number of the battle members from the default 4.
And yes, you must start a new game or else you may get NoMethodError issues.

Also, you should post the full error message and show us the exact line where the error points to.
Just saying that you get an error won't help much.
I can only guess that for some reason, the @cw variable is set to nil, which would cause an error for sure, but back-tracking that would take a lot of time with Symphony scripts, time which I do not have right now, sorry.

Thank you, and thank you so much for your hard work on the fixes! Well, I just realized there's another place to get this script that I'm going to give a try and see if it works.

As for your questions:

I have been trying to do certain things in my game and posting on forums all week and no one was being as nice as you guys, so I decided to just learn ruby. So, I spent all day learning how to code - enough so, that when I read that tangled mess (no offense, apparently not your fault), I was able to decipher where lines should break up, identify the methods, and add in any missing "end"s. I know, I'm kind of impressed with myself, as well.
I applied only formation + symphony fix from the spoiler.
as for the nomethod, it really just said nomethod and referenced the line I posted in the spoiler above. I read it to see if it referenced any specific "def" parts because I also learned how to use methods to some degree, so I got what the error was more or less saying, it just didn't name a method.

I'd reproduce it for a SS for you, but I did a fresh script install before I saw your post. I'm going to try using the scripts from (possibly) another link and see what happens. If I get the same results, I'll be sure to ss it.

okay, so I took the scripts from http://www.rpgmakercentral.com/topic/24049-formation-bonus/ and tried them, but I'm getting
upload_2017-10-15_1-23-50.png

whenever I activate the battle event and the battle starts the load

EDIT: I applied your very specific instructions for formation + symphony

UPDATE: Okay, original error reproduced:
I got my formation and sprites script from here

http://www.rpgmakercentral.com/topic/24049-formation-bonus/

and my symphony script from here

https://github.com/suppayami/rmvxa-collection/blob/master/battle-symphony/battle-symphony-116e.rb

I did no tinkering with any scripts, just removed the old ones, placed the new ones, symphony first, sprites, then formation, and started game, no errors until i activated the battle event and I gotupload_2017-10-15_1-56-4.png


which is

self.ox = @cw / 2

from

#--------------------------------------------------------------------------
# new method: update_charset_origin
#--------------------------------------------------------------------------
def update_charset_origin
if bitmap
self.ox = @cw / 2
self.oy = @ch
end
end
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Ohh, so you installed the "Actor Sprites" script from Vlue too? Well, that can be the issue itself, because you don't need that with Symphony.
You only need that script if you use a battle system without any actor sprites, but Symphony already make use of actor sprites.

Try to delete that script and see if it works afterwards.
Also, in case it is still needed, you might want to apply the second fix I made, because if I remember right, that one is needed for Symphony as well.
Do this only if you get another NoMethodError (but not the same one you got before) when you start the battle after deleting the "Actor Sprites" script.
 

stickyka

Veteran
Veteran
Joined
Oct 15, 2017
Messages
39
Reaction score
10
First Language
english
Primarily Uses
RMVXA
reprint of instructions for posterity (edited to unscramble it from the transfer):

# Here's the thing:
# Vlue's Formation Bonus script will break the moving animation (any kind of it) in Yami's Battle Symphony.
# We will fix that one too with the edits below!
# First, head over to Vlue's script and at the top of the script, insert these lines:
$imported = {} if $imported.nil?
$imported["Formation-Bonus"] = true
# EDIT from myself (stickyka); IIRC, this part requires an addition of the command "end" as the function is left open, although
# I think it should not be needed if you're not using out-dated scripts
# Second, find the following(s):
def screen_x
def screen_y
# Comment out these (the whole definition, not only the single lines!).
# There, you are done here, move over to the Symphony script.
# Find the following lines:
def set_default_position
# Here you need to replace the following lines:
@origin_x = @screen_x = @destination_x = SYMPHONY::View::ACTORS_POSITION[index][0]
@origin_y = @screen_y = @destination_y = SYMPHONY::View::ACTORS_POSITION[index][1]
# With these lines:
if $imported["Formation-Bonus"]
@origin_x = @screen_x = @destination_x = FORMATION_LOCATIONS[@formation_slot][0] + 180
@origin_y = @screen_y = @destination_y = FORMATION_LOCATIONS[@formation_slot][1] + 180
else
@origin_x = @screen_x = @destination_x = SYMPHONY::View::ACTORS_POSITION[index][0]
@origin_y = @screen_y = @destination_y = SYMPHONY::View::ACTORS_POSITION[index][1]
end
# Notice the numbers '180' at the end of those 2 lines there? That will be the offset of your actors horizontally and vertically.
# That one is necessary, because 'FORMATION_LOCATIONS[@formation_slot]' will return the direct co-ordinates on the screen
# of your actors from the Formation Bonus scene, so it is very likely that your actors will be in some rather "unusual" places
# on the battle screen without these offsets. Edit those numbers freely to change your actors' position in the battle, and yet
# maintain the original formation of your actors.
# Moving on, we are not done here just yet...
# Scroll a bit down and you should see the following line:
def correct_origin_position
# Here we need to replace these lines:
@origin_x = @screen_x = SYMPHONY::View::ACTORS_POSITION[index][0]
@origin_y = @screen_y = SYMPHONY::View::ACTORS_POSITION[index][1]
# With these:
if $imported["Formation-Bonus"]
@origin_x = @screen_x = FORMATION_LOCATIONS[@formation_slot][0] + 180
@origin_y = @screen_y = FORMATION_LOCATIONS[@formation_slot][1] + 180
else
@origin_x = @screen_x = SYMPHONY::View::ACTORS_POSITION[index][0]
@origin_y = @screen_y = SYMPHONY::View::ACTORS_POSITION[index][1]
end
# The numbers at the end ('180') are for the same reason like before, and they should be the same numbers as above.
# Do NOT insert different numbers here than those you set above or "strange" things will happen!
# And this should be it! We managed to mix the 2 scripts with 100% working functions from both scripts. Enjoy!

So, Sixth, you're saying just make the fixes in that spoiler ^ there for symphony only and remove Vlues sprite script? (BTW, removing the sprite script alone results in characters not moving around, only performing while stationary).

EDIT: Decided to give it a try rather than being unproductive and waiting for a response. Did everything in the instructions EXCEPT the very first step (don't think we need that $imported bit). Figuring the rest of it was referencing actor movements and locations between the scripts, I did the rest of the steps. It brings back the actor movements Symphony style, but doesn't set their origin positions based on Bonus Formation, it's just based on Symphony settings.

EDIT 2: Went back and uncommented the hashed lines from Vlue's script only (meaning I only made adjustments to Symphony) and it goes back to stationary characters, in position based on Vlue.

EDIT 3: If I'm understanding this right, though, the part of Vlue's script that gets hashed out is telling the game where the formation positions are for the sprites. The part you hash out (well, I hashed out instead of replacing) in Symphony is the part that tells where the sprites go for symphony, but it's replaced by the call for if formation bonus is imported which goes at the beginning of Vlue's, which then tells the sprites where to go according to the formation in Vlue's script, but only in the if condition that formation bonus is imported.
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,661
Reaction score
563
First Language
English
Primarily Uses
RMVXA
@Sixth Would you mind reposting the 4x4 script you made. I tried to copy and fix the line breaks, but I would never be sure that I got it right.
 

stickyka

Veteran
Veteran
Joined
Oct 15, 2017
Messages
39
Reaction score
10
First Language
english
Primarily Uses
RMVXA
@Sixth Would you mind reposting the 4x4 script you made. I tried to copy and fix the line breaks, but I would never be sure that I got it right.
Quite a bit in there. I'll give it a shot, maybe save Sixth some time as a thank you. Watch for an update on this post in a little bit, ...

EDIT: Here it is, did the best I could. Hope it works!

UPDATE: Corrected a line as per Sixth's instructions. Cannot attest that the rest of it is correct, though, see intro note.

# EDIT BY STICKYKA: Just some comments from myself. I edited what lies below to correct it from a translation from website
# to website; I've had one day of ruby learning and I am not the author of any of this; I simply am attempting to correct
# the mess of it a website transposition did to it. In all likelihood, there are more than a few errors. My apologies.
# If you use this, do not credit me (stickyka, that is - totally credit the authors, though!) in any way, please!
# These notes are just here as a disclaimer so you know if this doesn't work right, it's probably not the author's fault, but
# a translation error on my part.
# On to the script!
# Yeah, 3x3 grid is solid enough, if someone got only 4 active party member.
# Well, I got 6, and 6 out of 9 slots didn't give me much choice of creating different formations,
# so I decided to modify the script for a 4x4 grid for more places and more possibilities.
# It is not a very hard edit, but I'm not sure that I remember every thing I changed in the script,
# so I will just paste the whole script here, saving you the time of editing many little things,
# and also saving your time of reporting errors and my time of replying with corrections for them.
# NOTE: The following edited script is optimized for a game resolution of 800x600!
# Many things are edited, and some things (like text and other info) will not show at all on lower resolution (out of screen).
# You can, of course, edit any placement of texts/windows shown, or comment out anything that you don't want to show up, if # (stickyka added this "safety hash" because of word wrap issues) you wish.
# The following edited version of Vlue's Formation Bonus Script features:
# - All the related fixes/edits made by me mentioned above.
# - 4x4 grid (16 slots total) to place your actors on, gives much more possibilities of combinations.
# - Extra stats shown: Hit Rate, Critical Rate, Evasion.
# - Extra information shown: The selected actor's: Name, Title (requires Blackmourning's Title System Script)
# - Changed the actor's graphic shown in the Status Window of the Formation Bonus Scene.
# Instead of the actor's sprite, it will now show the actor's face graphic.
# - The default help window is disabled. Instead of that, a new window is created which will display different text,
# depending on where the active cursor is (in the character selection window or in the position selection window).
# - Text and information placement changed, some windows are resized and moved to suit 800x600 resolution.
# Extra note:
# While I actually implemented showing the Title of the actor's on this scene, I don't recommend using that Title script yet,
# because it got some compatibility issues with Yanfly's Class System Script.
# The issue happens when you change your primary (main/default) class while having a title which gives stat increase equipped.
# I will try to fix this too, as a matter of fact, already tried it, but so far nothing I tried fixed it.
# But if you don't use Yanfly's Class System, you might as well ignore this note.
# Things yet to be implemented:
# - While the position selection window is active (aka selecting the position of the selected actor),
# showing the movement of the actual selected actor's sprite graphic on the screen in real time.
# If the cancel button is pressed, the actor would jump back to it's original placement.
# - Giving the bonus only to the actors present in the active formation.
# This would enable lesser formations with fewer battle members, like at the start of the game,
# without actually breaking the bigger formations designed for later stages of your game.
# It would also enable the next thing on the list.
# - Multiple active formations at the same time (I thought about 2 at max, to not complicate it too much).
# This one won't really be helpful unless you got 6 active battle members like me.
# I want to be able to set my actors in lesser formations, like 3 in one formation, and 3 in another one.
# Why? I will leave that to your imagination, the possibilities are almost endless!
# - Locked formations.
# That's right, I want to be able to lock every single formation until my lead character actually learns them in the game.
# I think it should be obvious why, but for a simple example: to prevent OP formations on earlier stages of my game.
# This is all I can think of now, but my braincells are always thinking, so this list might expand,
# or get smaller when I (or anyone else) actually implement them. This is if Vlue allows it, of course.
# Okay, time to actually post the script, right? Here it is:
#Formation Bonus v1.2a - Edited by Sixth
#----------#
#Features: Rearrange actors by rows and make formations, granting bonuses
# based on what row and formation the actors are in.
#
#Usage: Plug and play, customize as needed.#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
# posted on the thread for the script
# given by email: sumptuaryspade@live.ca
# provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#
#---
Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
$imported = {} if $imported.nil?
$imported["Formation-Bonus"] = true
#(EDIT BY STICKYKA: I'm not sure that ^ line is right or will work right anymore)
# Edit by stickyka: The above should be correct now. I hope...
#Location for actor sprites in battle (3x3 grid only right now):
# (Or not, made it 4x4 now! Yay!)
FORMATION_LOCATIONS = [
[375,200],[425,200],[475,200],[525,200],
[395,230],[445,230],[495,230],[545,230],
[415,260],[465,260],[515,260],[565,260],
[435,290],[485,290],[535,290],[585,290]]
#Icon to be displayed as formation slot in the Formation Changing Scene.
FORMATION_ICON = 430
#Change in damage given/recieved based on row position:
#Front row, middle left row, middle right row, back row
FORMATION_ROW_ATK = [1.0, 0.8, 0.7, 0.5]
FORMATION_ROW_DEF = [1.0, 0.8, 0.7, 0.5]
FORMATION_ROW_MAT = [1.0, 1.0, 1.0, 1.0]
FORMATION_ROW_MDF = [1.0, 1.0, 1.0, 1.0]
FORMATION_ROW_TGR = [1.5, 1.0, 0.8, 0.6]
#The special Formations actors can be placed in:
# id => { :name => "name of formation", :slots = [slots to be filled], ... }
# Slot ids are:
# 0, 1, 2, 3
# 4, 5, 6, 7
# 8, 9,10,11
# 12,13,14,15
#
# Stat options are: :hp, :mp, :atk, :def, :mat, :mdf, :agi, :luk
# Formation bonuses apply to all actors.
# Example:
# 1 => { :name => "Back Row", :slots => [2,5,8], :hp => 20, :mp => 5,}
FORMATION_BONUS = {
0 => {},
1 => { :name => "Caution!", :slots => [2,5,6,9,10,14], :hp => 10, :mdf => 10,},
2 => { :name => "Retreat!", :slots => [3,6,7,10,11,15], :mat => 10, :def => 10,},
3 => { :name => "Charge!", :slots => [0,4,5,8,9,12], :atk => 10,},
4 => { :name => "Surround!", :slots => [1,4,7,8,11,13], :mdf => 10, :agi => 10,},
5 => { :name => "Pierce!", :slots => [1,4,5,6,7,9], :atk => 10, :mat => 10, :luk => 10,},
6 => { :name => "Pierce!", :slots => [5,8,9,10,11,13], :atk => 10, :mat => 10, :luk => 10,},
7 => { :name => "'X' Marks the Way!", :slots => [0,2,5,9,12,14], :hp => 5, :mp => 5, :atk => 5, :mat => 5,},
8 => { :name => "Tactical!", :slots => [3,4,6,8,10,15], :hp => 5, :mp => 5, :atk => 5, :def => 5, :mat => 5, :mdf => 5, :agi => 5, :luk => 5,}}
class Game_Actor < Game_Battler
attr_accessor :formation_slot
alias formation_init initialize
alias formation_param param
def initialize(actor_id)
formation_init(actor_id)
@formation_slot = -1
end
#uncomment def screen_x and def screen_y if you don't use Yami's Battle Symphony
#def screen_x
# FORMATION_LOCATIONS[@formation_slot][0]
#end
#def screen_y
# FORMATION_LOCATIONS[@formation_slot][1]
#end
def front_row?
[0,4,8,12].include?(@formation_slot)
end
def middle_left_row?
[1,5,9,13].include?(@formation_slot)
end
def middle_right_row?
[2,6,10,14].include?(@formation_slot)
end
def back_row?
[3,7,11,15].include?(@formation_slot)
end
def param(param_id)
sym = [:hp,:mp,:atk,:def,:mat,:mdf,:agi,:luk]
value = formation_param(param_id)
if $game_party.short_form[sym[param_id]]
value *= ($game_party.short_form[sym[param_id]] * 0.01 + 1)
end
[[value, param_max(param_id)].min, param_min(param_id)].max.to_i end
end
class Game_Enemy < Game_Battler
def front_row?
true
end
def middle_left_row?
false
end
def middle_right_row?
false
end
def back_row?
false
end
end
class Game_Battler
def tgr
return sparam(0) * FORMATION_ROW_TGR[3]
if back_row?
return sparam(0) * FORMATION_ROW_TGR[2]
if middle_right_row?
return sparam(0) * FORMATION_ROW_TGR[1]
if middle_left_row?
return sparam(0) * FORMATION_ROW_TGR[0]
end
def make_damage_value(user, item)
value = item.damage.eval(user, self, $game_variables)
value *= item_element_rate(user, item)
value *= pdr if item.physical?
value *= mdr if item.magical?
value *= rec if item.damage.recover?
value *= row_defense if item.physical? && !item.damage.recover?
value *= row_attack(user) if item.physical? && !item.damage.recover?
value *= row_magic_attack(user) if item.magical? && !item.damage.recover?
value *= row_magic_defense if item.magical? && !item.damage.recover?
value = apply_critical(value) if @result.critical
value = apply_variance(value, item.damage.variance)
value = apply_guard(value)
@result.make_damage(value.to_i, item)
end
def row_defense
return FORMATION_ROW_DEF[1] if middle_left_row?
return FORMATION_ROW_DEF[2] if middle_right_row?
return FORMATION_ROW_DEF[3] if back_row?
return FORMATION_ROW_DEF[0] end def row_attack(user)
return FORMATION_ROW_ATK[3] if user.back_row?
return FORMATION_ROW_ATK[1] if user.middle_left_row?
return FORMATION_ROW_ATK[2] if user.middle_right_row?
return FORMATION_ROW_ATK[0] end def row_magic_defense
return FORMATION_ROW_MDF[1] if middle_left_row?
return FORMATION_ROW_MDF[2] if middle_right_row?
return FORMATION_ROW_MDF[3] if back_row?
return FORMATION_ROW_MDF[0]
end
def row_magic_attack(user)
return FORMATION_ROW_MAT[3] if user.back_row?
return FORMATION_ROW_MAT[2] if user.middle_right_row?
return FORMATION_ROW_MAT[1] if user.middle_left_row?
return FORMATION_ROW_MAT[0]
end
end
class Game_Party
attr_accessor
:formation_id
def first_available_slot
end
def formation_slot(id)
battle_members.each do |actor|
return actor if actor.formation_slot == id
end
return nil
end
def formation_name
return current_formation[:name]
if current_formation
return "-----"
end
def setup_starting_members
@actors = $data_system.party_members.clone
iter = 0
battle_members.each do |actor|
actor.formation_slot = iter
iter += 1
end
current_formation
end
def current_formation
FORMATION_BONUS.each do |sym, form|
next if sym == 0
valid = true
form[:slots].each do |val|
valid = false unless formation_slot(val)
end
next unless valid
@formation_id = sym
return FORMATION_BONUS[sym]
end
@formation_id = 0
return nil
end def short_form
@formation_id = 0
unless @formation_id
FORMATION_BONUS[@formation_id]
end
def add_actor(actor_id)
return if @actors.include?(actor_id)
@actors.push(actor_id)
16.times do |i|
if formation_slot(i).nil?
$game_actors[actor_id].formation_slot = i
break
end
end
$game_player.refresh
$game_map.need_refresh = true
end
def remove_actor(actor_id)
return unless @actors.include?(actor_id)
@actors.delete(actor_id)
$game_actors[actor_id].formation_slot = -1
$game_player.refresh
$game_map.need_refresh = true
end
end
class Scene_Formation < Scene_Base
def start
super
@list_window = Window_FormList.new
@list_window.y = 0
@list_window.set_handler:(ok, method:(list_ok))
@list_window.set_handler:(cancel, method:(list_cancel))
@bonus_window = Window_FormBonus.new
@form_window = Window_Formation.new
@form_window.set_handler:(ok, method:(form_ok))
@form_window.set_handler:(cancel, method:(form_cancel))
@stat_window = Window_FormStat.new
@stat_window.y = @list_window.height
@helpy_window = Window_Helpy.new
# EDIT by stickyka The above section has a lot of ":(" parts that were interpreted as smileys, I hope I corrected it right
(@bonus_window.x, 0, @bonus_window.width, 48)
@helpy_window.x = @list_window.width
@helpy_window.width = @bonus_window.width
@list_window.select(0)
@list_window.activate
end
def update
super
if @list_window.active
@stat_window.set_actor(@list_window.current_item)
@helpy_window.contents.draw_text(0, 0, 300, 24, "Select a party member.", 0)
elsif @form_window.active
if @form_window.current_item
@stat_window.set_actor(@form_window.current_item)
else
@stat_window.set_actor(@list_window.current_item)
end
@helpy_window.contents.draw_text(0, 0, 300, 24, "Select a position.", 0)
end
end
def list_ok
@form_window.select(@list_window.current_item.formation_slot)
@form_window.activate
@helpy_window.refresh
end
def list_cancel
SceneManager.return
end
def form_ok
index = @form_window.current_index
actor = @list_window.current_item
if $game_party.formation_slot(index)
$game_party.formation_slot(index).formation_slot = actor.formation_slot
end
actor.formation_slot = index
@form_window.refresh
@bonus_window.refresh
@stat_window.refresh
@helpy_window.refresh
form_cancel
end
def form_cancel
@form_window.select(-1)
@list_window.activate
@helpy_window.refresh
end
end
class Window_Helpy < Window_Selectable
def initialize
super(Graphics.width/5*2, 0, Graphics.width/5*3, 48)
refresh
end
def refresh
contents.clear
end
def open
refresh
super
end
end
class Window_FormList < Window_Selectable
def initialize
super(0,48,Graphics.width/5*2, 24 * 7)
refresh
end
def item_max
$game_party.battle_members.size
end
def
draw_item(index)
actor = $game_party.battle_members[index]
rect = item_rect(index)
draw_text(rect, actor.name)
draw_text(rect, "Lvl ",2)
draw_text(rect, actor.level,2)
end
def current_item
return $game_party.battle_members[@index] if @index >= 0
return nil
end
end
class Window_FormBonus < Window_Base def initialize
super(Graphics.width/5*2,48+(Graphics.height-48)/3*2,Graphics.width/5*3,(Graphics.height-48)/3)
refresh
end
def refresh
contents.clear
change_color(system_color)
draw_text(0,0,contents.width,line_height,"Bonuses:")
return unless $game_party.current_formation
change_color(normal_color)
form = $game_party.current_formation
xx = 6;yy = line_height;iter = 1
form.each do |key, val|
next unless [:hp,:mp,:atk,:def,:mat,:mdf,:agi,:luk].include?(key)
case key
when :hp
text = sprintf("%s %+d%", Vocab::hp, val.to_s)
when :mp
text = sprintf("%s %+d%", Vocab::mp, val.to_s)
when :atk
text = sprintf("%s %+d%", Vocab::param(2), val.to_s)
when :def
text = sprintf("%s %+d%", Vocab::param(3), val.to_s)
when :mat
text = sprintf("%s %+d%", Vocab::param(4), val.to_s)
when :mdf
text = sprintf("%s %+d%", Vocab::param(5), val.to_s)
when :agi
text = sprintf("%s %+d%", Vocab::param(6), val.to_s)
when :luk
text = sprintf("%s %+d%", Vocab::param(7), val.to_s)
# EDIT by stickyka: The above contains a lot of ":p"s, which were interpreted as tongue faces; my correction to ":p" is based
#on the fact that the previous Vocab::mp, seems to be a variable and thus should not be capitalized, but I've only studied
#Ruby for a single day, so I dunno, good luck!
end
draw_text(xx,yy,contents.width/3,line_height,text)
xx += contents.width/3
if iter % 3 == 0
xx = 5; yy += line_height
end
iter += 1
end
end
end
class Window_Formation < Window_Selectable
def initialize
super(Graphics.width/5*2,48,Graphics.width/5*3,(Graphics.height-48)/3*2)
refresh
end
def refresh
contents.clear
xx = contents.width/4;yy = contents.height/3;iter = 0
4.times do
4.times do
draw_icon(FORMATION_ICON,xx,yy,$game_party.formation_slot(iter))
if $game_party.formation_slot(iter)
draw_actor_graphic($game_party.formation_slot(iter),xx-4,yy-16)
end
xx += 50
iter += 1
end
xx -= 200
yy += 30;xx += 20
end
change_color(system_color)
draw_text(0,0,contents.width,line_height,"Formation: ")
change_color(normal_color)
draw_text(106,0,contents.width,line_height,$game_party.formation_name)
end
def item_rect(index)
xx = contents.width/4;yy = contents.height/3
xx += index % 4 * 50
xx += 20 * (index / 4).to_i
yy += 30 * (index / 4).to_i
Rect.new(xx,yy,24,24)
end
def col_max; 4;
end
def row_max; 4;
end
def item_max; 16;
end
def current_item
$game_party.formation_slot(@index) ? $game_party.formation_slot(@index) : nil
end
def current_index
@index
end
def draw_actor_graphic(actor,x,y)
new_bitmap = Cache.character(actor.character_name)
next_bitmap = new_bitmap.clone
xx = actor.character_index % 4 * new_bitmap.width/4
yy = actor.character_index / 4 * new_bitmap.height/2 next_bitmap.blt(0,0,next_bitmap,Rect.new(xx,yy,next_bitmap.width/4,next_bitmap.height/2))
contents.blt(x,y,next_bitmap,Rect.new(0,next_bitmap.height/8,next_bitmap.width/12,next_bitmap.height/8))
end
end
class Window_FormStat < Window_Base
def initialize
super(0,48+(24*7),Graphics.width/5*2,line_height*18)
refresh end def refresh
contents.clear
change_color(system_color)
draw_text(standard_padding*2+88,0+12,contents.width,line_height,"Name:") draw_text(standard_padding*2+88,line_height+12,contents.width,line_height,"Class:") draw_text(standard_padding*2+88,line_height*2+12,contents.width,line_height,"Title:") if $imported["Title-System"] draw_text(75,line_height*4+8,contents.width/2,line_height,"Status:",1) draw_text(75,line_height*5+10,contents.width/2,line_height,Vocab::param(0)) draw_text(75,line_height*6+10,contents.width/2,line_height,Vocab::param(1)) draw_text(75,line_height*7+10,contents.width/2,line_height,Vocab::param(2)) draw_text(75,line_height*8+10,contents.width/2,line_height,Vocab::param(3)) draw_text(75,line_height*9+10,contents.width/2,line_height,Vocab::param(4)) draw_text(75,line_height*10+10,contents.width/2,line_height,Vocab::param(5)) draw_text(75,line_height*11+10,contents.width/2,line_height,Vocab::param(6)) draw_text(75,line_height*12+10,contents.width/2,line_height,Vocab::param(7)) draw_text(75,line_height*13+10,contents.width/2,line_height,Vocab::x_param(0)) draw_text(75,line_height*14+10,contents.width/2,line_height,Vocab::x_param(2)) draw_text(75,line_height*15+10,contents.width/2,line_height,Vocab::x_param(1))
# EDIT by stickyka: Again, there were a lot of ":p"s above that were converted to tongue faces, see my previous note
return unless @actor
change_color(normal_color)
draw_actor_face(@actor,0,0) draw_text(-4,0+12,contents.width,line_height,@actor.name,2) draw_text(-4,line_height*2+12,contents.width,line_height,Vocab.titles_name(@actor.title_id),2) if $imported["Title-System"] draw_text(75,line_height*5+10,contents.width/2,line_height,@actor.mhp,2) draw_text(75,line_height*6+10,contents.width/2,line_height,@actor.mmp,2) draw_text(75,line_height*7+10,contents.width/2,line_height,@actor.atk,2) draw_text(75,line_height*8+10,contents.width/2,line_height,@actor.def,2) draw_text(75,line_height*9+10,contents.width/2,line_height,@actor.mat,2) draw_text(75,line_height*10+10,contents.width/2,line_height,@actor.mdf,2) draw_text(75,line_height*11+10,contents.width/2,line_height,@actor.agi,2) draw_text(75,line_height*12+10,contents.width/2,line_height,@actor.luk,2)
value1 = eval("@actor.#{:hit}")
text1 = sprintf("%d%", value1 * 100)
value2 = eval("@actor.#{:cri}")
text2 = sprintf("%d%", value2 * 100)
value3 = eval("@actor.#{:eva}")
text3 = sprintf("%d%", value3 * 100)
draw_text(75,line_height*13+10,contents.width/2,line_height,text1,2) draw_text(75,line_height*14+10,contents.width/2,line_height,text2,2) draw_text(75,line_height*15+10,contents.width/2,line_height,text3,2)
if $imported["CXJ-ClassExtensions"]
if @actor.subclass.nil?
text = @actor.class.name
elsif !@actor.class.combined_name[@actor.subclass_id].nil?
text = @actor.class.combined_name[@actor.subclass_id]
else
fmt = YEA::CLASS_SYSTEM::SUBCLASS_TEXT
text = sprintf(fmt, @actor.class.name, @actor.subclass.name)
end
draw_text(-4,line_height+12,contents.width,line_height,text,2)
else
draw_text(-4,line_height+12,contents.width,line_height,@actor.class.name,2)
end
end
def set_actor(actor)
return if @actor == actor
@actor = actor
refresh
end
end
#class Scene_Menu#
def command_formation
#
SceneManager.call(Scene_Formation)
#
end
#end
#################################################################################
# Uncomment this if you don't use (or don't know how to use) Yanfly's Menu Engine
# to show the new command button in the main menu for this scene.
#################################################################################
=begin
class Window_MenuCommand < Window_Command
alias formation1_command add_original_commands
def add_original_commands
formation1_command
add_command("Formation1", :formation1) end
end=end
#################################################################################
# Uncomment this if you don't use (or don't know how to use) Yanfly's Menu Engine
# to show the new command button in the main menu for this scene.
#################################################################################
if $imported["YEA-AceMenuEngine"]
#optional line class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * For Creating An Alias
#--------------------------------------------------------------------------
alias formation1_menu13211
create_command_window
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
formation1_menu13211()
@command_window.set_handler:pformation1,
method:pcommand_formation1))
end
# EDIT by stickyka: More of those ":p"s tongue faces above; see previous notes
#--------------------------------------------------------------------------
# * [Save] Command
#--------------------------------------------------------------------------
def command_formation1
SceneManager.call(Scene_Formation)
end
end
end
#optional line class Window_MenuCommand
def formation_enabled
true
end
end
# This is it! Enjoy!
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
@stickyka
This part:
Code:
$imported = {}
if $imported.nil?
$imported["Formation-Bonus"] = true
Should look like this instead:
Code:
$imported = {} if $imported.nil?
$imported["Formation-Bonus"] = true
There is a huge difference.
What you did sets the $imported global variable to an empty hash every time you start the game.
This in turn deleted all previously loaded values for that hash (so any scripts using the $imported hash loaded before the Formation script will no longer "use" that hash), and this can lead to undesired effects, since the whole purpose of this global variable (which is supposedly set by the community here, not by the engine itself) is to check if a required script is loaded or not.
Try it with the corrected lines, maybe it will work.

I used the $imported hash for all of my edits, because I used to test my project with and without the Formation script all the time, and this saved a lot of editing time.
If you are always using the Formation script, you can leave out this part, and use only the else part of the condition checks which use the $imported hash.

What I commented out from Vlue's Formation script is the screen position for actors in battle, yes. You don't need that, because you set that up in the edits I wrote.
Not only you don't need that, but it will also break Symphony, because that relies on more than 1 variables for positioning (see the edits, they actually set 2 variables, not just one and in 2 methods). Because you must put the Formation script below the Symphony scripts, you will overwrite those 2 methods from Symphony with the ones from Vlue's script, and that will break Symphony movements for sure.

Aside from this fix, you will also need the second fix on the list (well, most probably, it was a long time ago).
This one:
2. Eliminating every non-battle party members from the position selection window:
Sorry, no time to fix the lines, so you will have to do that yourself now, but you managed it for the other ones, so you should be fine. :p
When I finally get some free time, I will revisit these fixes and put all of them into a single patch to save people the trouble of editing all over the place.

@Roninator2
Sorry, no time to fix the lines right now, but will do it when I get some free time.
Just note that that script is made for a resolution of 800x600, not for the default resolution. You can still make it work for other resolutions, but you will have to manually re-position the visuals in the script, otherwise many things will get cut down visually.
Ohh, and it was made for v1.2 of the Formation script, so chances are, it is outdated. No idea what did Vlue updated in the later versions, but whatever it was, it is not present in my edited version.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,882
Messages
1,017,231
Members
137,607
Latest member
Maddo
Top