Hi everyone, im pretty sure this is my first post. i've been reading on these forums for a while and i finally couldn't figure this out... so im breaking down and asking for help with this.
i've been wrapping up the battle part of my script and a function i've always wanted to have is random battle formations.
now im using tankentai and it has a pretty easy setup for battle formation, and i figured i could just cheap it out and spin a variable in the background and use a simple if/elsif statement to get a random battle formation out of a selection of like 6.. but basically it just used one of them and then stuck with that.
is anyone willing to help me modify this to randomly pick a formation..
this is the part of the script that deals with formations...
# Battle member starting positions
# X Y X Y X Y X Y X Y X Y
ACTOR_POSITION = [[420,170],[500,200],[410,230],[510,260],[560,290]]
ACTOR_POSITION2 = [[420,170],[500,200],[410,230],[510,260],[560,290]]
ACTOR_POSITION3 = [[420,170],[500,200],[410,230],[510,260],[560,290]]
ACTOR_POSITION4 = [[420,170],[500,200],[410,230],[510,260],[560,290]]
ACTOR_POSITION5 = [[420,170],[500,200],[410,230],[510,260],[560,290]]
ACTOR_POSITION6 = [[480,170],[500,200],[520,230],[540,260],[560,290]]
i added ACTOR_POSITION2 through ACTOR_POSITION6, i ended up just setting them all the same a while ago but i really want to get this
working now.
this is the section of the actual battle script that references that value.
def base_position
if $game_variables[20] = 1
base = ACTOR_POSITION2[self.index]
@base_position_x = base[0]
@base_position_y = base[1]
@base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
elsif $game_variables[20] = 2
base = ACTOR_POSITION3[self.index]
@base_position_x = base[0]
@base_position_y = base[1]
@base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
elsif $game_variables[20] = 3
base = ACTOR_POSITION4[self.index]
@base_position_x = base[0]
@base_position_y = base[1]
@base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
elsif $game_variables[20] = 4
base = ACTOR_POSITION5[self.index]
@base_position_x = base[0]
@base_position_y = base[1]
@base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
elsif $game_variables[20] = 5
base = ACTOR_POSITION6[self.index]
@base_position_x = base[0]
@base_position_y = base[1]
@base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
elsif $game_variables[20] = 0
base = ACTOR_POSITION[self.index]
@base_position_x = base[0]
@base_position_y = base[1]
@base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
#ATTEMPT BREAK LOOP IF IN BATTLE
end
end
basically i was trying to continuously generate a random number 1-6 and store it in variable 20, figuring that when a battle started it
would choose that formation. but its not working...
is there a better way that i can do this? im feeling pretty stupid right now, lol.
also on a side note. im having problems with blizzard's Party change script, the framerate seems to drop off sharply after using it, though it does work fine, also it might be my fault since i modified it for 5 party members.
at any rate please let me know if you guys have any ideas on how i could either make this work with a variable or simply replace this code with something better.
thanks again!
EDIT: the thought had dawned on me that i might possibly be able to fix this by creating an array with the ACTOR_POSITION values and using the roulette function to choose one. im not really that familiar with the roulette function though. if someone could point me in the right direction. lol
EDIT AGAIN: Im happy to say i figured this out. finally. i ended up using the variable method but i used a common event set to parallel to continuously generate the random number with a switch set to automatically flip to on in scene_title to activate the common event.
its great because it works. but it sucks because it effectively broke battle test. i just have to test on a map now. which isnt such a big deal since i have a five member party anyway.
thanks everyone. if anyone using tankentai wants to do something similar hit me up and ill help you out!