modern_algebra

Flash Selected Enemy 1.0.0

Jul 17th, 2012
205
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #    Flash Selected Enemy
  3. #    Version: 1.0.0
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: July 18, 2012
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #    
  9. #    This script will flash the battler of any enemy currently selected when
  10. #   the player is targetting.
  11. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12. #  Instructions:
  13. #    
  14. #    Paste this script into its own slot in the Script Editor, above Main but
  15. #   below Materials.
  16. #
  17. #    This script is designed to work with the DBS and may be incompatible with
  18. #   other battle scripts.
  19. #
  20. #    This script is completely plug & play, and without modification the
  21. #   selected enemy will whiten. If you want to change the colour to which it
  22. #   flashes, the duration of the flash, or the time between flashes, then go to
  23. #   the editable region starting at line 30 and change those three options.
  24. #==============================================================================
  25.  
  26. $imported ||= {}
  27. $imported[:"FlashSelectedEnemy 1.0.0"] = true
  28.  
  29. #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  30. #    BEGIN Editable Region
  31. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  32. FSE_REST_FRAMES = 4        # Number of frames between flashes
  33. FSE_FLASH_DURATION = 24    # Number of frames for each flash to complete
  34. FSE_FLASH_COLOUR = [255,255,255] # Colour of the flash, format: [red, green, blue]
  35. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  36. #    END Editable Region
  37. #//////////////////////////////////////////////////////////////////////////////
  38.  
  39. #==============================================================================
  40. # ** Sprite Battler
  41. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  42. #  Summary of Changes:
  43. #    aliased method - start_effect; update_effect
  44. #    new method - update_fse_flash
  45. #==============================================================================
  46.  
  47. class Sprite_Battler
  48.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49.   # * Start Effect
  50.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  51.   alias ma_fse_strteffct_7fk9 start_effect
  52.   def start_effect(effect_type, *args, &block)
  53.     if effect_type == :fse_flash
  54.       @effect_duration = FSE_FLASH_DURATION
  55.       @fse_flash_mod = 320 / FSE_FLASH_DURATION
  56.       @battler_visible = true
  57.     end
  58.     ma_fse_strteffct_7fk9(effect_type, *args, &block)
  59.   end
  60.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61.   # * Update Effect
  62.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63.   alias ma_fse_updeffct_9hv2 update_effect
  64.   def update_effect(*args, &block)
  65.     # If playing an FSE flash
  66.     if @effect_duration > 0 && @effect_type == :fse_flash
  67.       update_fse_flash
  68.     end
  69.     # Stop effect if set to stop
  70.     if @battler.sprite_effect_type == :fse_revert_to_normal
  71.       revert_to_normal
  72.       @battler.sprite_effect_type = nil
  73.     end
  74.     ma_fse_updeffct_9hv2(*args, &block) # Run Original Method
  75.   end
  76.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77.   # * Update Flash
  78.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79.   def update_fse_flash
  80.     self.color.set(*FSE_FLASH_COLOUR)
  81.     if @effect_duration > (FSE_FLASH_DURATION / 2)
  82.       self.color.alpha = (FSE_FLASH_DURATION - @effect_duration) * @fse_flash_mod
  83.     else
  84.       self.color.alpha = @effect_duration * @fse_flash_mod
  85.     end
  86.   end
  87. end
  88.  
  89. #==============================================================================
  90. # ** Scene_Battle
  91. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  92. #  Summary of Changes:
  93. #    aliased method - select_enemy_selection; update
  94. #==============================================================================
  95.  
  96. class Scene_Battle
  97.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98.   # * Start Enemy Selection
  99.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100.   alias ma_fse_strtenemyselect_3hk9 select_enemy_selection
  101.   def select_enemy_selection(*args, &block)
  102.     ma_fse_strtenemyselect_3hk9(*args, &block)
  103.     @fse_effect_frames = FSE_FLASH_DURATION
  104.     @fse_flash_frames = 0 # Initialize blink count
  105.   end
  106.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107.   # * Frame Update
  108.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  109.   alias ma_fse_udat_8hz5 update
  110.   def update(*args, &block)
  111.     old_enemy = @enemy_window.active ? @enemy_window.enemy : nil
  112.     ma_fse_udat_8hz5(*args, &block)
  113.     if !@enemy_window.active || old_enemy != @enemy_window.enemy # If cursor moves
  114.       # Set the flash to the newly selected enemy
  115.       old_enemy.sprite_effect_type = :fse_revert_to_normal if old_enemy && !old_enemy.dead?
  116.       @fse_flash_frames = 0
  117.     end
  118.     if @enemy_window.active
  119.       if @fse_flash_frames <= 0
  120.         @fse_flash_frames = @fse_effect_frames + FSE_REST_FRAMES
  121.         @enemy_window.enemy.sprite_effect_type = :fse_flash
  122.       end
  123.       @fse_flash_frames -= 1
  124.     end
  125.   end
  126. end
RAW Paste Data