Battler Graphic Translation

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.
MOG toys with the battler position a lot, so a new script that does the same thing might have a high chance of conflicts. And MOG already gives you the option of setting the battler's x,y with that script right? The shadow control simply "cut" the original graphics and add a new shadow if i remember right, so in this case, it only draws the enemy at the start of the battle. But if it's update-able, simply change the shadow position to make it looks as if the hornet's on the ground? Hmm.. might look weird in the animation/cut, but still... it's a work around. 😛

As far as i can tell, the game interpreter is using "enemy" as a reference on the "now alive" troops. But MOG might be using a different variable for that. That's why you get an error with the script call? Can't be sure since i never tested it out myself, it's how the game interpreter deals with the troop event's command. I simply do a small modification on it to point to y axis. And since you tested the transform and it works.. then it's probably something wrong with the code i gave you.

Try replace enemy[20] with simply 1 or 2 and give it a try and see if it works.

You can get the number you want from Troops Event i guess, try something like apply a state to the enemy inside the troop event and there should be a drop down list of the number you should be using for that particular enemy.

eg:

Code:
    iterate_enemy_index(1) do |enemy|      enemy.y = 120    end
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 error are you getting this time?

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  😛

 
I was hoping that the graphic will change simply by changing the y. That saves a lot of trouble, but if you are getting no error and the graphic isn't changing, that means the y is changed but the graphic needs an update to draw it in the new y position.
What? Without MOG?

Well

$game_troop.alive_members[1].name.include?('Mimic')

iterate_enemy_index(enemy[1]) do |enemy|

      enemy.y = 50

    end

 

results in same as before:

Script 'Game_Interpreter' line 1411: NoMethodError occured

undefined 'name' for nil:NilClass

and

iterate_enemy_index(enemy[1]) do |enemy|

      enemy.y = 50

    end

 

results in:

Script 'Game_Interpreter' line 1411: NameError occured.

undefined local variable or method 'enemy' for

#<Game_Interpreter:0xa892970>

 

The difference from last time is in red.

 

Edit:

 

I was hoping that the graphic will change simply by changing the y. That saves a lot of trouble, but if you are getting no error and the graphic isn't changing, that means the y is changed but the graphic needs an update to draw it in the new y position.

 
Remember, ideally, I was hoping for a visual movement and that sounds like a teleportation rather than a translation. I really appreciate your ongoing help though  🙂
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.
Why is there a name? oh.. you are adding the name check line too?

Try just use that 3 lines, nothing else.

Simply 3 lines in call script in troops event, nothing else.

Code:
    iterate_enemy_index(1) do |enemy|      enemy.y = 120    end
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.
Hmm wrong call for graphic update then.. will need to find the correct one.

When we get the part where the "teleport" works, we can easily modify it to do "sliding move".

How about...

Code:
iterate_enemy_index(1) do |enemy|   enemy.y = 120endSpriteset_Battle.enemy_sprites.each {|sprite| sprite.update }
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.. >_<

Original thread: https://forums.rpgmakerweb.com/threads/battler-graphic-translation.44851/