The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: modern algebra on July 18, 2012, 04:12:48 AM

Title: [VXA] Flash Selected Enemy 1.0.0
Post by: modern algebra on July 18, 2012, 04:12:48 AM
Flash Selected Enemy
Version: 1.0.0
Author: modern algebra
Date: July 18, 2012

Version History



Description


This script makes it so that when choosing a target in battle, the battler of the currently selected enemy will flash.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fs16.postimage.org%2Fcj0170mo3%2FFSE_screen.png&hash=5fc08be0378045ce52713b3330ff4025dd5e061f)

Instructions

Simply paste the script into the Script Editor, below Materials but above Main. Beyond that, the script is plug & play and enemy battlers will flash white when selected. If you wish, you can edit the colour, duration, and timing of the flashes starting at line 30.

Script


Code: [Select]
#==============================================================================
#    Flash Selected Enemy
#    Version: 1.0.0
#    Author: modern algebra (rmrk.net)
#    Date: July 18, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#   
#    This script will flash the battler of any enemy currently selected when
#   the player is targetting.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#   
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    This script is designed to work with the DBS and may be incompatible with
#   other battle scripts.
#
#    This script is completely plug & play, and without modification the
#   selected enemy will whiten. If you want to change the colour to which it
#   flashes, the duration of the flash, or the time between flashes, then go to
#   the editable region starting at line 30 and change those three options.
#==============================================================================

$imported ||= {}
$imported[:"FlashSelectedEnemy 1.0.0"] = true

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#    BEGIN Editable Region
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FSE_REST_FRAMES = 4        # Number of frames between flashes
FSE_FLASH_DURATION = 24    # Number of frames for each flash to complete
FSE_FLASH_COLOUR = [255,255,255] # Colour of the flash, format: [red, green, blue]
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#    END Editable Region
#//////////////////////////////////////////////////////////////////////////////

#==============================================================================
# ** Sprite Battler
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - start_effect; update_effect
#    new method - update_fse_flash
#==============================================================================

class Sprite_Battler
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_fse_strteffct_7fk9 start_effect
  def start_effect(effect_type, *args, &block)
    if effect_type == :fse_flash
      @effect_duration = FSE_FLASH_DURATION
      @fse_flash_mod = 320 / FSE_FLASH_DURATION
      @battler_visible = true
    end
    ma_fse_strteffct_7fk9(effect_type, *args, &block)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_fse_updeffct_9hv2 update_effect
  def update_effect(*args, &block)
    # If playing an FSE flash
    if @effect_duration > 0 && @effect_type == :fse_flash
      update_fse_flash
    end
    # Stop effect if set to stop
    if @battler.sprite_effect_type == :fse_revert_to_normal
      revert_to_normal
      @battler.sprite_effect_type = nil
    end
    ma_fse_updeffct_9hv2(*args, &block) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Flash
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_fse_flash
    self.color.set(*FSE_FLASH_COLOUR)
    if @effect_duration > (FSE_FLASH_DURATION / 2)
      self.color.alpha = (FSE_FLASH_DURATION - @effect_duration) * @fse_flash_mod
    else
      self.color.alpha = @effect_duration * @fse_flash_mod
    end
  end
end

#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - select_enemy_selection; update
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start Enemy Selection
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_fse_strtenemyselect_3hk9 select_enemy_selection
  def select_enemy_selection(*args, &block)
    ma_fse_strtenemyselect_3hk9(*args, &block)
    @fse_effect_frames = FSE_FLASH_DURATION
    @fse_flash_frames = 0 # Initialize blink count
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_fse_udat_8hz5 update
  def update(*args, &block)
    old_enemy = @enemy_window.active ? @enemy_window.enemy : nil
    ma_fse_udat_8hz5(*args, &block)
    if !@enemy_window.active || old_enemy != @enemy_window.enemy # If cursor moves
      # Set the flash to the newly selected enemy
      old_enemy.sprite_effect_type = :fse_revert_to_normal if old_enemy && !old_enemy.dead?
      @fse_flash_frames = 0
    end
    if @enemy_window.active
      if @fse_flash_frames <= 0
        @fse_flash_frames = @fse_effect_frames + FSE_REST_FRAMES
        @enemy_window.enemy.sprite_effect_type = :fse_flash
      end
      @fse_flash_frames -= 1
    end
  end
end

This script is also hosted at Pastebin (http://pastebin.com/PQD8psXL)

Credit



Support


Please report bugs, ask questions, and make suggestions in this topic at RMRK.

Known Compatibility Issues

It will not work with some custom battle systems, particularly ones that already have a feature like this built in, such as Yanfly's Ace Battle Engine.

Terms of Use


I adopt the RMRK Terms of Use (http://rmrk.net/index.php/topic,45481.0.html).
Title: Re: Flash Selected Enemy 1.0.0
Post by: Arrow on July 25, 2012, 11:16:51 AM
I know that this will eventually see use in a project of mine. : ) Good work Modern, the little modules like this are the best in my opinion.
Title: Re: Flash Selected Enemy 1.0.0
Post by: modern algebra on July 25, 2012, 01:53:34 PM
Thanks! I'm glad you like it.
Title: Re: Flash Selected Enemy 1.0.0
Post by: JiM83 on August 02, 2012, 09:06:01 PM
I've gotten a strange error when using this script. The battle plays normally for
awhile but then freezes with no errors. I tried it in a fresh project and got the
same result when I killed one enemy and use silence on the remaining two.
Title: Re: Flash Selected Enemy 1.0.0
Post by: modern algebra on August 02, 2012, 09:14:44 PM
I haven't been able to reproduce the error.

What do you mean by freezing anyway? Do you just mean that the enemies don't attack anymore but the actor still can? If so, then it might just be that they are silenced and you haven't given them any actions that aren't magical, like attack.

If that's not the case, I will need to see a demo with the error recreated.
Title: Re: Flash Selected Enemy 1.0.0
Post by: JiM83 on August 02, 2012, 09:41:12 PM
Sorry about that. It seems it was a problem with rpg maker itself.
A quick computer reset fixed it.
Title: Re: [VXA] Flash Selected Enemy 1.0.0
Post by: Japhasca on April 26, 2015, 10:16:46 PM
I've had it freeze in battle with just Yanfly's ACE Core Engine installed and Zeus' Fullscreen++. Here's more info:
http://rmrk.net/index.php?topic=50046.0