[RESOLVED][XP] - Animated Enemies

Started by MarkHest, August 31, 2011, 06:22:37 am

Previous topic - Next topic

MarkHest

August 31, 2011, 06:22:37 am Last Edit: August 31, 2011, 08:46:38 am by MarkHest
I'm unsure whether to post this here or not, move it if i'm in the wrong section.

-The Script is using the default battle system-
The script i want some help with is a script that wasn't made on this forum.
It is a script that breaks down an enemy battlers into four pictures and moves between them to make them animated.

The problem is that, this script seems to be causing some major lagg whenever you use events in the battles(Tint screen, animations, message winows) and the lagg becomes more intense depening on how many party members you have.

This is the script:


#==============================================================================
# ** Night_Runner's Animated Enemies.
#------------------------------------------------------------------------------
# History:
#  Date Created: 29/Aug/10
#  Created for: MarkHest
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=44674
#
# Description:
#  This script is designed to animate the enemy battlers in the default
#   RMXP battle system.
#
# How to Install:
#  Copy this entire script, go into your game, along the top select Tools >>
#   Script Editor. Along the left scroll to the bottom, right click on Main,
#   and select insert. Paste this code in the window on the right.
#
# Customization:
#  The enemy sprite will be split into 4 frames by default (as deined
#   by line 37) and will stay on that frame for 20 frames by default
#   (as defined by line 38).
#==============================================================================



#==============================================================================
# ** Scene_Battler
#------------------------------------------------------------------------------
#  Edited to give enemies a animated battle stance.
#==============================================================================

class Sprite_Battler
 #--------------------------------------------------------------------------
 # * Invariables
 #--------------------------------------------------------------------------
 FRAMES = 4
 FRAMES_PER_FRAME = 20
 #--------------------------------------------------------------------------
 # * Alias Methods
 #--------------------------------------------------------------------------
 alias_method  :nr_anime_update,  :update  unless $@
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update(*args)
   # Run the original update
   return_value = nr_anime_update(*args)
   # If the enemy is a enemy
   if @battler.is_a?(Game_Enemy)
     # Check to see if the animation needs updating
     if @nr_x.nil? or (@nr_x != (Graphics.frame_count.to_i % (FRAMES * FRAMES_PER_FRAME)) / FRAMES_PER_FRAME)
       # Set the x offsef for the animation
       @nr_x = (Graphics.frame_count.to_i % (FRAMES * FRAMES_PER_FRAME)) / FRAMES_PER_FRAME
       # Get the original battler
       src_bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
       # Reset the dimension
       @width = src_bitmap.width / FRAMES
       self.ox = @width / 2
       # Get a rectangle around the bitmap
       src_rect = Rect.new(@nr_x * @width, 0, @width, src_bitmap.height)
       # Transfer the bitmap to the self.bitmap
       self.bitmap.clear
       self.bitmap = Bitmap.new(@width, src_bitmap.height)
       self.bitmap.blt(0, 0, src_bitmap, src_rect)
       # Dispose the src_bitmap
       src_bitmap.dispose
     end
   end
 end
end



#==============================================================================
# End of Script.
#==============================================================================


if you want to try it, use one of my battlers i use in my game, saving you the trouble of making one yourself (Not that you have to, but to demonstrate)

Here: ShowHide





My question is. What chould be causing so much lagg and is there a way to fix it or reduce it?
(Someone mentioned in a feedback message about my game that he/she experienced a lot of lagg in battles, suposedly even when no events were in effect)
   

G_G

No. Using Zeriab's anti-lag system was made for maps with lots of events. I don't know if it'll work in battle. But besides that, ToA has an animated battlers script. It can be used for both enemies and actors.

ToA:
http://forum.chaos-project.com/index.php/topic,105.0.html

MarkHest

August 31, 2011, 08:14:48 am #2 Last Edit: August 31, 2011, 08:45:58 am by MarkHest
I'll take a look into that Tons of Addons script. Thanks :)
I'll altso check out that lagg fix for my more larger maps ^^

EDIT: I'll use the one from Tons of Addons, it's going to be so much easier for me and it realy did stop the lag! *At least on my computer*


Thanks for reminding me that Tons of Addons had this ^^

[Resolved]