Flip Around Single Enemy Graphic During Battle

Status
Not open for further replies.

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
I would like to flip a single enemy around by using a script call or symphony tag during battle. I am not using a spriteset for enemies, only a single png image. I see that there is a method to mirror animations in Sprite_Base but it's a little beyond me on how to implement this for Sprite_Battler let alone reference it by specific Troop Index.

I am using Battle Symphony but the only way I can think of doing this is by creating poses for every enemy. I am hoping there is a simpler solution that I am just not seeing, maybe a symphony tag that already does this or a snippet somewhere that I just can't find.

Any help with this issue would be very much appreciated.

http://forums.rpgmakerweb.com/index.php?/topic/6037-battle-engine-symphony/

Code:
class Sprite_Base < Sprite  #--------------------------------------------------------------------------  # * Start Animation  #--------------------------------------------------------------------------  def start_animation(animation, mirror = false)    dispose_animation    @animation = animation    if @animation      @ani_mirror = mirror      set_animation_rate      @ani_duration = @animation.frame_max * @ani_rate + 1      load_animation_bitmap      make_animation_sprites      set_animation_origin    end  end  #--------------------------------------------------------------------------  # * Set Animation Sprite  #     frame : Frame data (RPG::Animation::Frame)  #--------------------------------------------------------------------------  def animation_set_sprites(frame)    cell_data = frame.cell_data    @ani_sprites.each_with_index do |sprite, i|      next unless sprite      pattern = cell_data[i, 0]      if !pattern || pattern < 0        sprite.visible = false        next      end      sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2      sprite.visible = true      sprite.src_rect.set(pattern % 5 * 192,        pattern % 100 / 5 * 192, 192, 192)      if @ani_mirror        sprite.x = @ani_ox - cell_data[i, 1]        sprite.y = @ani_oy + cell_data[i, 2]        sprite.angle = (360 - cell_data[i, 4])        sprite.mirror = (cell_data[i, 5] == 0)      else        sprite.x = @ani_ox + cell_data[i, 1]        sprite.y = @ani_oy + cell_data[i, 2]        sprite.angle = cell_data[i, 4]        sprite.mirror = (cell_data[i, 5] == 1)      end      sprite.z = self.z + 300 + i      sprite.ox = 96      sprite.oy = 96      sprite.zoom_x = cell_data[i, 3] / 100.0      sprite.zoom_y = cell_data[i, 3] / 100.0      sprite.opacity = cell_data[i, 6] * self.opacity / 255.0      sprite.blend_type = cell_data[i, 7]    end  end
Code:
class Sprite_Battler < Sprite_Base  #--------------------------------------------------------------------------  # * Set New Animation  #--------------------------------------------------------------------------  def setup_new_animation    if @battler.animation_id > 0      animation = $data_animations[@battler.animation_id]      mirror = @battler.animation_mirror      start_animation(animation, mirror)      @battler.animation_id = 0    end  end
 

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
This looks like it could help. Trying to figure it out. Any idea how to turn off all the effects by default and then only apply them in a script call?
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
As that script design goes, everything is automated. But you get to set which troop/ which enemy to be not included in certain effects.
 

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
This was exactly what I needed. Thank you so much. After changing the script a little I was able to call it with this.

TMBSPREX::NO_MIRROR_ENEMY = [$game_variables[362]]

Then remove it with this

TMBSPREX::NO_MIRROR_ENEMY.pop

It only refreshes at battle start but by using this http://himeworks.com/2013/03/enemy-reinforcements/ I was able to add the troop then mirror it.

Changed original script to this.

#-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias tmbsprex_sprite_battler_initialize initialize def initialize(viewport, battler = nil) tmbsprex_sprite_battler_initialize(viewport, battler) if battler && !battler.actor? && (TMBSPREX::NO_MIRROR_TROOP.include?($game_troop.troop.id) || TMBSPREX::NO_MIRROR_ENEMY.include?(battler.enemy.id)) self.mirror = 0 end if battler && !battler.actor? && (TMBSPREX::NO_ZOOM_TROOP.include?($game_troop.troop.id) || TMBSPREX::NO_ZOOM_ENEMY.include?(battler.enemy.id)) border_y = Graphics.height * 65 / 100 self.zoom_x = (battler.screen_y - border_y) * 0.005 + 1.0 end if battler && !battler.actor? && (TMBSPREX::NO_BREATH_TROOP.include?($game_troop.troop.id) || TMBSPREX::NO_BREATH_ENEMY.include?(battler.enemy.id)) @zoom_max = rand(30) + 150 @zoom_count = rand(@zoom_max) end @use_tmbsprex = true endThe battler-motion script looks awesome, I'm gonna have to check that out. Might be a better solution in there somewhere.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
well, if you don't want a large script just to do the flipping... try this:

Use this script call in troop event to flip an enemy during battle:

$game_troop.members[id].flip = truewhere id = the line up index id of the troop members in battle (starting from 0)

use true/false to flip/unflip

Code:
#==============================================================================# ■ Meow Face Flip Enemy Battler#------------------------------------------------------------------------------# Flip Enemy Battler by Script Call#==============================================================================# How to Use:# [1] Put this script below Meow Face Tile Hue Script# [2] Use this script call in troop's event#          $game_troop.members[id].flip = true          #     Where id = the line up index id of the troop members in battle (starting from 0)#==============================================================================class Sprite_Battler < Sprite_Base  alias meow_update update  def update    self.mirror = battler.flip    meow_update  endendclass Game_Battler < Game_BattlerBase  attr_accessor :flip  alias meow_bat initialize  def initialize    meow_bat    @flip = false  endend
 
Last edited by a moderator:

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
That looks even more what I'm looking for but I get this error when I enter battle.

Script '' line 15: NoMethodError occurred.

undefined method 'flip' for nil:NilClass
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
did you add the script to your project? :p

If you do, that sounds like a custom script placed below it has an overwrite method that overwrites the needed method of this script.

try put this script below any other custom script you have.
 

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
Initially I had placed it in my project with 60+ scripts and recieved this error. I just tried it in a new project, placing it under your Tile Hue script(which is really cool by the way) and recieved the same error.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
weird tho, the tile hue script is using a complete different class and methods.

what do you use in the script call?

note that it's using the member id, not enemy id. so it's starting from 0 ~ the last member of the member in that troop.

try this

$game_troop.members[0].flip = true
 

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
Yeah, I'm not sure what's going on. The error pops up before the battle screen starts so it won't even give me a chance to do the script call.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
Just did a test on that script along with the map hue script + 20 other custom scripts. it's running without any error.





i've implement it into my enemy cloning script and it's working without any error too.

so you will need to be more specific on what you did and how you are doing the script call to get the error as i can't reproduce it on my side.
 
Last edited by a moderator:

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
This is the process I have gone through in detail. It's not a big deal that for some reason I can't get it to work but it has been a learning process trying a few things to attempt to get it to work. The issue was resolved with a minor edit to the first script you suggested, it's just probably not the most elegant of solutions.

I opened a new project and pasted the script at the bottom and then saved.



I put the script call in the Battle Event box, tried for Conditions 'Turn 0' and 'Turn 1'.



I clicked battle test and received this error. I tried saving and running the battle on the map and received the same error.

 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
edit:

nevermind the above, this one should work in both test battle and in game

Code:
#==============================================================================# ■ Meow Face Flip Enemy Battler#------------------------------------------------------------------------------# Flip Enemy Battler by Script Call#==============================================================================# How to Use:# [1] Put this script below Meow Face Tile Hue Script# [2] Use this script call in troop's event#          $game_troop.members[id].flip = true          #     Where id = the line up index id of the troop members in battle (starting from 0)#==============================================================================class Sprite_Battler < Sprite_Base  alias meow_update update  def update    self.mirror = battler.flip if @battler    meow_update  endendclass Game_Battler < Game_BattlerBase  attr_accessor :flip  alias meow_bat initialize  def initialize    meow_bat    @flip = false  endend
 
Last edited by a moderator:

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
Awesome, that fixed it. How did putting @battler do the trick? What does that mean? But at any rate, now my slimes can do a little victory jig. Thank you very much for your help.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
because in test battle the data is read in a different way. battler don't exist until we are inside the battle, unlike in game where the battler exist on the start of the battle.

so add @battler check tells the script to run that line only when battler exist.

and you're welcome! congratulations on your progress! ;)
 
Last edited by a moderator:

pxldrm

Famed Mimic Gogo
Member
Joined
Mar 13, 2014
Messages
17
Reaction score
1
First Language
English
Primarily Uses
Ok, I think I get it. I had gotten all the functionality ready up until the enemy needed to be flipped. This has helped a lot.
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top