Hi, this is about a commercial project.
I am in need of a script call which will allow me to move a battler graphic along the y-axis to a defined position when certain conditions are met.
Thanks!
The script call to change position: (Not tested)
iterate_enemy_index(enemy[N]) do |enemy| enemy.y = Y_Axis endN is the index of the currently alive battlers
Y_Axis is the position you want it on the screen
You might need something like this to check for the names of the enemy, don't need to be full, can be partly.
$game_troop.alive_members[N].name.include?('NAME_OF_ENEMY')
And note that the game automatically rename/add to the name of existing enemies when there's more than one in the battle. eg. Bee A, Bee B, Bee C.
I am not sure if simply changing the Y axis works, there's a high chance that we need to call for a refresh/update to make the game redraw the enemy position.
And there might be an easier script call that i am not aware of, so you might want to keep on looking.
---------------------------------
For a 100% eventing only method(and probably easier):
Set up a new enemy with the exact same graphic but with Y position adjusted. During the battle, use the event command "Transform Enemy" and transform to that "new enemy".
Because the HP and MP are carried over, your player will only see it as a position change.
I'm a novice in setting up scripts. I tried something, but it crashed the test. Hopefully I did it right:
I tested this with the mimic battler. That's position 20 on the enemies list, so I used index 20. Hopefully that's the right logic on using an index.
For the axis, I tried a random number - 50.
So:
iterate_enemy_index(enemy[20]) do |enemy|
enemy.y = 50
end
results in:
Script 'Game_Interpreter' line 1411: NameError occured.
undefined local variable or method 'enemy' for
#<Game_Interpreter:0xa83f5a4>
and:
$game_troop.alive_members[20].name.include?('Mimic')
iterate_enemy_index(enemy[20]) do |enemy|
enemy.y = 50
end
results in:
Script 'Game_Interpreter' line 1411: NoMethodError occured
undefined 'name' for nil:NilClass
Edit:
I think for the eventing method, the enemy in the latter position would still show in on the battle screen, unless 'appear halfway' is used. But in any case, I've tinkered with that a bit and realised that it would result in a position jump. I'm looking for a translation. So yes, I believe that this would require the game to redraw the graphic at every few pixles of movment for the translation to work.
As far as i can tell, the default engine avoid refreshing graphic per frame to reduce lag in battles.
Because battlers are probably the biggest sized graphic that the game engine is handling other than tiles/icon_sheet.
The larger the sprites, the more lag it's going to get.
The eventing method should work, not appear halfway but transforming. That's why you need to prepare another "new" enemy with a new graphic. If i remember correctly during the transition of a transform the enemy disappear in lines and reappear line by line. (Not sure if it's VX ace.. Can't remember..)
And if i remember right, you are trying to make the flying enemies fall on the ground right? So, let's say we need to change the Hornet's position. Make a new battler picture of the Hornet and simply move the hornet down (close to its shadow) by editing the existing RTP's Hornet. Make a new Hornet B using that battler picture and use the same settings in all params exactly the same as the old hornet(you can change it if you like, eg grounded enemy are no longer immune to certain attack). And during battle, transform it from the normal Hornet to the new Hornet using troops event should makes it looks as if the Hornet has fallen to the ground. Transform is different from Appearing Halfway, the newly shown enemy inherit the current hp/mp of the old enemy that disappeared, and you can even change it's atk/def as you like, or use the exact same settings.
Using this method you can even do something like "recover", and make the hornet "fly" again simply by transforming it back during battle under certain conditions.
Well, if you insist on using script calls, there are scripts out there that changes/move enemy around the screen(animated battler), so you might be able to find the script call code you need in those scripts.
Edit:
And oh, about the error,
Try replace enemy[20] with $game_troop.alive_members[20]
Umm.. i can't help but asking, why do you have 20 enemies in a battle? 😳
Okay, so you are saying that I should edit the distance of the battler and its shadow for this effect. However, I am using Battler Shadow by MOG for independent control of shadow. So that's why I'm asking for a way to visually move around the battler graphic.
Actually, no. The only option in Battler Show is to set shadow height and opacity. The script generates its own shadow for the battler. The default shadow graphic must still be deleted, otherwise you'll have two static shadows.
I looked around at various animated battle scripts. Seemingly there is no way to change battler's default position on those.
20 enemies in a battle???
No, I tested this out with one enemy - Mimic. Battler's position on enemy list is 020. I thought that is what index means?
See my second line in post #3.
Edit:
Okay, I understand now that the variable was referring to the total number of enemies in battle.
Anyway, still no luck. Disabling MOG's script still results in an error, though a different one, but I want this to work with MOG.
No, that index is the troop index, not enemy id. You can "peek" it from trying to give an enemy in a troop a state or changing it's hp/mp using troops event. There's a drop down list that shows you the number of that enemy.
What you tried to do is finding enemy number 20 in the troop that doesn't exist. Have you tried the new code i gave you?
If there's no error this time but nothing's changed let me know, might need to find a way to manually update the graphic. 😛
I edited my previous post with an update while you were replying; cheers.
Edit:
Manually update the graphic? Wow, I really thought that this was simple. I figured three or four lines of script with a script call would have been enough to shift a graphic 😛
what about the new code i gave you above?
iterate_enemy_index(1) do |enemy| enemy.y = 120 enddoes this work? (test both with and without MOG script)
Same error in both cases:
Script 'Game_Interpreter' line 1411: NoMethodError occured
undefined 'name' for nil:NilClass
Update:
Sorry, wrong code - forget to save the project during testing.
With/without MOG, no error. But no changes. Guess the graphic needs to be refreshed.
Yup, see my previous update. Sorry about that.
So we are on the right track, gimme a sec to look into the default script to see which calls the update.
Try...
iterate_enemy_index(1) do |enemy| enemy.y = 120endSprite_Battler.update_positionlet me know if it works.
When conditions are met for the script call, it crashes with:
Script 'Game_Interpreter' line 1411: NoMethodError occured.
undifined method 'update_position' for Sprite_Battler:Class
I have MOG enabled by the way.
Script 'Game_Interpreter' line 1411: NoMethodError occured.
undifined method 'enemy_sprites' for Spriteset_Battle:Class
Oh, my bad, those are not called in the interpreter where the script calls work.
I need to find an interpreter way to update it.. >_<
worth a try, but i doubt it works
iterate_enemy_index(1) do |enemy| enemy.y = 120endGraphics.updateAt least this one works in interpreter, just not sure if it will update the position.
Try this one too, just in case
iterate_enemy_index(1) do |enemy| enemy.y = 120end$game_troops.updateor
iterate_enemy_index(1) do |enemy| enemy.y = 120endenemy.updateHaving too many conversation at once can be confusing.. lol! All 3 in the forum regarding coding.. >_<