Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Wingard on June 04, 2013, 04:06:07 pm

Title: [RESOLVED] Problem with animations displayed on screen, not specified target
Post by: Wingard on June 04, 2013, 04:06:07 pm
Hey!  :)

There was one annoying issue with Rpg maker xp since forever and i thought maybe finally its time to put an end to it, but i'll need a help from a experienced scripter!

Well, the thing is about animations that are to be displayed on the screen, not the specified target. If there is more that 1 enemy in the battle then that animation will be displayed multiple times which results in it being pretty chaotic, usually too bright, and overall ugly (in my opinion).

Im not really a scripter but i found this in the Scene_Battle 4:


  #--------------------------------------------------------------------------
 # * Frame Update (main phase step 4 : animation for target)
 #--------------------------------------------------------------------------
 def update_phase4_step4
   # Animation for target
   for target in @target_battlers
     target.animation_id = @animation2_id
     target.animation_hit = (target.damage != "Miss")
   end
   # Animation has at least 8 frames, regardless of its length
   @wait_count = 8
   # Shift to step 5
   @phase4_step = 5
 end


These are the lines 406-419. Is it possible to modify these to solve this issue? To make the script display the animation only once if its set to be displayed on the screen and not the target?

I will be grateful for any help. :)
Title: Re: Problem with animations displayed on screen, not specified target
Post by: Wecoc on June 04, 2013, 04:42:09 pm
QuoteIf there is more that 1 enemy in the battle then that animation will be displayed multiple times which results in it being pretty chaotic, usually too bright, and overall ugly (in my opinion).

Are you sure about that? I think if you set the animation to be displayed at screen this does not occur and is shown just once in the middle of the screen.
Well, in any case, as I know animations always are displayed over a sprite, but this shouldn't be an inconvenient, because you can create an invisible sprite and display animation on it.
Some time ago I thought about a system to make animation projectiles displayed on a mobile invisible sprite using that, to throw for example fire to the enemy. This maybe would be a nice script.
Title: Re: Problem with animations displayed on screen, not specified target
Post by: Wingard on June 05, 2013, 09:38:14 am
QuoteAre you sure about that? I think if you set the animation to be displayed at screen this does not occur and is shown just once in the middle of the screen.


Im absolutely sure about that. I set the transparency of every element of every frame of the animation to 30 (so its almost invisible) and displayed the animation by using the skill while there was 8 enemies in the battle. The animation was visible as if its transparency was set to maximum (255), which proves it is displayed multiple times, depending of the number of enemies. And after i killed few enemies and tried that again the animation was much less visible that before.  :uhm:

I tried the same thing with even less visible animation frames and more enemies and the result is the same.

And while we are still at it... there is one more issue that i encountered which is pretty similiar and i didnt want to create a new thread. The animation set to be displayed on screen is displayed too low if the screen resolution is higher than usual. (I kinda mentioned using the 1300x740 res in the other thread (Continous maps script by Blizzard)).
If there is no way to make the animation be displayed only once then maybe someone can help me to make it be displayed higher on the screen? The Y value that im missing in the script editor.

Screenshot may help to visualise the problem:
Spoiler: ShowHide
(http://img692.imageshack.us/img692/1517/animc.jpg)


Title: Re: Problem with animations displayed on screen, not specified target
Post by: Wecoc on June 11, 2013, 05:41:04 pm
Uops! I think I fixed the first problem, post above main the next code.

#==============================================================================
# ** Scene_Battle (part 4)
#==============================================================================

class Scene_Battle
  def update_phase4_step4
    if $data_animations[@animation2_id].position == 3
      @target_battlers[0].animation_id = @animation2_id
    else
      for target in @target_battlers
        target.animation_id = @animation2_id
      end
    end
    for target in @target_battlers
      target.animation_hit = (target.damage != "Miss")
    end
    @wait_count = 8
    @phase4_step = 5
  end
end


About the second problem I have no idea how to fix that, sorry.
Title: Re: Problem with animations displayed on screen, not specified target
Post by: Wingard on June 12, 2013, 12:58:21 pm
QuoteUops! I think I fixed the first problem, post above main the next code.


Nice work! But it messes up the battle, because when im trying to Defend with my party member some error crashes the game:

error in line 410
"undefined method 'position' for nil:NilClass"

So the animation fix thing indeed works (yay :D) but actors cant defend themselves (nay D:).

I dont know much about scripting but i guess this may be caused by the fact that Defend action has no animation, just white flash on the battler.



QuoteAbout the second problem I have no idea how to fix that, sorry.

Maybe someone else will know, I sure hope so. :)
Title: Re: Problem with animations displayed on screen, not specified target
Post by: Wecoc on June 12, 2013, 01:57:41 pm
QuoteNice work! But it messes up the battle, because when im trying to Defend with my party member some error crashes the game:

error in line 410
"undefined method 'position' for nil:NilClass"


Actually that was a silly failure, sorry.

class Scene_Battle
  def update_phase4_step4
    if @animation2_id != 0 and $data_animations[@animation2_id].position == 3
      @target_battlers[0].animation_id = @animation2_id
    else
      for target in @target_battlers
        target.animation_id = @animation2_id
      end
    end
    for target in @target_battlers
      target.animation_hit = (target.damage != "Miss")
    end
    @wait_count = 8
    @phase4_step = 5
  end
end

Hope this time will be the definitive.
Title: Re: Problem with animations displayed on screen, not specified target
Post by: Wingard on June 12, 2013, 02:08:19 pm
Yes, now it works perfeclty. :D Thank you and good job, i think this little piece of code is a must-have for every project. Really nice little fix for a maker xp in my opinion. :)