Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Djigital Aura
#10
Sorry for double post, but I thought this is needed.
I've managed to somehow through help to make a definable switch to switch the aura searching on and off.


But the biggest problem is the intense lag that the script is creating.

I've made a complete new game without any other scripts.
I tested on a map with 300 events. Without the sript I get like 40 fps.
But with the both scripts in the demo I get like 8 FPS. This is insane.
Is their anyway to fix this?
Now I have the script the way I want to be, but I cant use it... 
( ≧Д≦)
Im so helpless.
BTW: As I noticed this only applies for the edited version below me, with your original script it doesnt happen.
Oh lord, what did I do wrong this time?



Heres the exact code:
The only changed part are these:


Quote:#--------------------------------------------------------------------------
# * Aura System Mode One : Single keypress that draws the aura for X frames
#--------------------------------------------------------------------------
def aura_mode_one
if $game_switches[Aura::AURA_SWITCH] == true then
# Do test if key triggered
aura_test if Input.trigger?(Aura::AURA_KEY)
# Update timer
aura_delay_update
else
aura_cancel
end
end
#--------------------------------------------------------------------------
# * Aura System Mode Two : Constatn keypress the shows aura until released
#--------------------------------------------------------------------------
def aura_mode_two
if $game_switches[Aura::AURA_SWITCH] == true then
# Player cannot be moving
return aura_cancel if $game_player.moving?
# Obtain keypress as local variable (works better as set variable)
test = aura_toggle_key
# If the current aura_key state doesn't match the keypress, we toggled
if @current != test
# Turn on or off the effect based on the new toggle state
(test == true) ? aura_test : aura_cancel
# And reset the toggle aura key toggle state
@current = test
end
else
aura_cancel
end
end




exact code:


Code:
#==============================================================================

# ** Djigital Aura
#------------------------------------------------------------------------------
#    by DerVVulfman
#    version 1.1
#    09-25-2016
#    RGSS / RPGMaker XP
#    Requires the SDK Add-On:  Event Comment Supplemental
#               (http://save-point.org/thread-3823.html)
#==============================================================================
#  
#  INTRODUCTION:
#
#  This script grants the ability to generate an aura effect for map events,
#  whether drawn behind or atop the graphic itself.   Along with that,  this
#  script also includes a feature to render pre-defined  text messages above
#  the event.    Designed to work separate of each other,  the text and aura
#  options must be defined in each event that has the added effect. An event
#  will only require the options required for the effect desired.
#
#  Flexible,  this system allows the desired effect  to be delivered through
#  the use of a scripted Hotkey, a script call, or by way  of a common event
#  using the script call and triggered by an Item of Skill in the database.
#
#
#  AURA EFFECT:
#  The aura effect is made by way of a secondary characterset graphic within
#  the Graphics\Characters folder. Initially, it was only to be drawn behind
#  the event sprite but has been altered so it can be drawn in front.  Along
#  with that, the opacity of the aura effect need not be 100% solid.
#
#  The comment used,  by default is the word Aura followed by the charset in
#  use.  EX:  Aura RedAura
#
#
#  TEXT EFFECT:
#  The text effect appears above the rendered sprite,  and uses the calcula-
#  ted height of the sprite for text placement.  If no height adjustment is
#  required,  you need only supply the string to render.   But if the height
#  needs to be raised or lowered, you must put supply a two-parameter array.
#  Here, the first parameter is a the text (WITHIN QUOTES)  while the second
#  parameter is the height.  
#
#  The comment used, by default is the word AText followed by the text drawn
#  above the character.
#  EX:  AText Thief
#  EX:  AText "Lvl1 Thief"
#  EX:  AText ["Giant Monster!", -30]
#
#
#  THE SCRIPT CALL:
#  For convenience purposes,  a very simple script call was made which will
#  turn on the aura effect for a time, either EXTREMELY BRIEF if the system
#  was set to use the 'constant-press' mode, or for a pre-defined amount of
#  time as set in the configuration section.
#
#
#  USED FROM THE MENU:
#  IF you wish to use a SKILL or ITEM to perform the aura effect,  you will
#  need to add a WAIT command  for approximately  10  frames before calling
#  the aura script call.  Yes, the script call will draw aura effect and/or
#  text effects onto events near the player is merely 'aura'.
#
#
#==============================================================================
#
#  TERMS AND CONDITIONS:
#
#  Free for use, even in commercial games.
#
#==============================================================================


module Aura


  # ACTION CONTROL
  # ==============
  #
    AURA_SWITCH   = 77                # Schalter, um Aura-Feature zu aktivieren
    AURA_MODE     = true             # MODE: (true = while press/false = timed)
    AURA_KEY      = Input::A          # Key Pressed to perform aura test


  # EVENT CONTROL
  # =============
  #
    AURA_GRAPHIC  = 'Aura'            # Event Comment for Aura (Ex: 'Aura Fred')
    AURA_RANGE    = 5                 # Range from event (in Tiles) 


  # RENDER CONTROL
  # ==============
  #
    AURA_DELAY    = 40                # Delay (in frames) that the aura shows
    AURA_OVER     = true              # Drawn over or under the character?
    AURA_OPACITY  = 255                # How solid the aura is drawn (0-255)


  # TEXT CONTROL
  # ============
  #    
    AURA_TEXT     = 'AText'           # Event Comment for text(EX:'AText Thief')
    AURA_FONT     = "Arial"           # Font used to render text
    AURA_SIZE     = 14                # Size of Font Used
    AURA_COLOR    = [255,255,255,255]   # Color of text (RRR,GGG,BBB,AAA)
    AURA_SHADOW   = [0,0,0,255]       # Color of text (or nil if not used)


end


#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  #  * Aura Script's In range? (Near Fantastica addendum Anti-Lag Edit)
  #     object : event object in map
  #--------------------------------------------------------------------------
  def aura_in_range?(object)
    screne_x        = $game_map.display_x
    screne_x        -= 256
    screne_y        = $game_map.display_y
    screne_y        -= 256
    screne_width    = $game_map.display_x
    screne_width    += 2816
    screne_height   = $game_map.display_y
    screne_height   += 2176
    return false    if object.real_x <= screne_x-32
    return false    if object.real_x >= screne_width+32
    return false    if object.real_y <= screne_y-32
    return false    if object.real_y >= screne_height+32
    return true
  end
end



#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :character_name           # character file name  
  attr_accessor :aura_delay               # Aura Delay
  attr_accessor :aura_character           # Original character from Aura
  attr_accessor :aura_text                # Text that appears in Aura
  attr_accessor :aura_text_y              # Y-Adjust for text that appears
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias game_character_aura_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Perform the original call
    game_character_aura_initialize
    # New values
    @aura_delay     = nil
    @aura_character = ""
    @aura_text      = ""
    @aura_text_y    = 0
  end
end



#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page 
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================

class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Public instance variables
  #--------------------------------------------------------------------------
  attr_reader   :page                     # Event page
end



#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display the character.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  if @sprite_character_aura_stack_fix.nil?
    alias sprite_character_aura_initialize initialize
    alias sprite_character_aura_dispose dispose
    @sprite_character_aura_stack_fix = true
  end
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport  : viewport
  #     character : character (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(viewport, character = nil)
    # What kind is the character? (Event or nothing)
    @actor = (character.is_a?(Game_Event)) ? 'event' : nil
    # Perform the original call
    sprite_character_aura_initialize(viewport, character)
  end
  #--------------------------------------------------------------------------
  # * Did the aura change its visibility?
  #--------------------------------------------------------------------------
  def show_hide_aura?
    # According to the kind of the actor, the check is made...
    return false unless @character.is_a?(Game_Event)
    if (@character.aura_character != "" &&
        @character.aura_delay == Aura::AURA_DELAY-1)
      return true 
    end
    if (@character.aura_delay == 0 && @character.aura_character == "")
      @character.aura_delay = nil
      return true 
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Update graphics for Aura effect
  #--------------------------------------------------------------------------
  def update_aura
    # Remember tile ID, file name and hue
    @tile_id        = @character.tile_id
    @character_name = @character.character_name
    @character_hue  = @character.character_hue
    # If the actor isent supported, return immideatly
    return if @actor == nil
    # According to the kind of the actor, the update is made...
    @page = @character.page if @character.is_a?(Game_Event)
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super()
    # If something changed...
    if @tile_id       != @character.tile_id or 
      @character_name != @character.character_name  or
      @character_hue  != @character.character_hue   or show_hide_aura?
      # First, update the information known
      update_aura
      # Then update the graphics
      update_tile
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set rectangular transfer
      sx    = @character.pattern * @cw
      sy    = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x            = @character.screen_x
    self.y            = @character.screen_y
    self.z            = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity      = @character.opacity
    self.blend_type   = @character.blend_type
    self.bush_depth   = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
    update_aura_text
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # Original Dispose
    sprite_character_aura_dispose
    # Dispose aura Sprite
    dispose_aura_text
  end
  #--------------------------------------------------------------------------
  # * Dispose aura Sprite
  #--------------------------------------------------------------------------
  def dispose_aura_text
    # Dispose aura Sprite
    unless @_aura_text_sprite.nil?
      @_aura_text_sprite.dispose
      @_aura_text_sprite = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Update Tile
  #--------------------------------------------------------------------------
  def update_tile
    # Decide between map tile or event tile
    (@tile_id >= 384) ? update_map_tile : update_event_tile
  end
  #--------------------------------------------------------------------------
  # * Update Map Tile (from the tileset)
  #--------------------------------------------------------------------------
  def update_map_tile
    self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id,
                                    @character.character_hue)
    self.src_rect.set(0, 0, 32, 32)
    self.ox = 16
    self.oy = 32
  end
  #--------------------------------------------------------------------------
  # * Update Map Tile (from a map event)
  #--------------------------------------------------------------------------
  def update_event_tile
    # Create an image render array
    renders = []
    # If handling a event
    if @character.is_a?(Game_Event) == true and @actor == 'event'
      # Check for comment input
      params = @character.aura_character
      # If the effect is drawn under the character
      unless Aura::AURA_OVER == true
        # Set up the aura effect character if it exists
        renders.push([params, 0]) if !(params.nil? or params == "")
      end
      # Then set up the character's normal graphic
      renders.push([@character_name, @character_hue])
      # If the effect is drawn over the character
      if Aura::AURA_OVER == true
        # Set up the aura effect character if it exists
        renders.push([params, 0]) if !(params.nil? or params == "")
      end
    end
    # Dispose old bitmap
    self.bitmap.dispose unless self.bitmap.nil?
    # Draws the character bitmap
    bmp           = RPG::Cache.character(@character_name, @character_hue)
    self.bitmap   = Bitmap.new(bmp.width, bmp.height)
    src_rect      = Rect.new(0, 0, bmp.width, bmp.height)
    # If character fits the size
    if renders.size > 0
      for graphic in renders
        next if graphic[0] == nil
        render_bitmap = RPG::Cache.character(graphic[0], graphic[1].to_i)
        src_rect = Rect.new(0, 0, bmp.width, bmp.height)
        opacity = 255
        opacity = Aura::AURA_OPACITY if graphic[0] != @character_name
        self.bitmap.blt(0, 0, render_bitmap, src_rect, opacity)
      end
    else
      src_rect = Rect.new(0, 0, bmp.width, bmp.height)
      self.bitmap.blt(0, 0, bmp, src_rect, 255)
    end
    # Divide the charset into pieces
    @cw       = bitmap.width / 4
    @ch       = bitmap.height / 4
    self.ox   = @cw / 2
    self.oy   = @ch
  end
  #--------------------------------------------------------------------------
  # * Update Display Sprite
  #--------------------------------------------------------------------------
  def update_aura_text
    # Dispose and exit if character has no aura
    return dispose_aura_text    if @character.aura_text.nil?
    # Create the aura text if text sprite doesn't exist
    return create_aura_text     if @_aura_text_sprite.nil?
    # If aura text isn't the same as before
    unless @_aura_display_text == @character.aura_text
      # Dispose Sprite
      dispose_aura_text
      # Re-Create Sprite
      create_aura_text
    end
    # Update aura Sprite Position
    @_aura_text_sprite.x = self.x
    @_aura_text_sprite.y = self.y - self.oy + @character.aura_text_y
  end
  #--------------------------------------------------------------------------
  # * Create aura Sprite
  #--------------------------------------------------------------------------
  def create_aura_text
    # Creates Display Bitmap
    bitmap = Bitmap.new(162, 26)
    # Set font in bitmap
    bitmap.font.name    = Aura::AURA_FONT
    bitmap.font.size    = Aura::AURA_SIZE
    # Turns off Text Shadow written by SephirothSpawn
    bitmap.draw_shadow  = false if bitmap.respond_to?(:draw_shadow)
    # Draws Text Shadow
    unless Aura::AURA_SHADOW.nil?
      bitmap.font.color = create_aura_color(Aura::AURA_SHADOW)
      bitmap.draw_text(1, 1, 160, 24, @character.aura_text, 1)
    end
    # Draws aura Display Text
    bitmap.font.color = create_aura_color(Aura::AURA_COLOR)
    bitmap.draw_text(0, 0, 160, 24, @character.aura_text, 1)
    # Creates Display Text Sprite
    @_aura_text_sprite          = Sprite.new(self.viewport)
    @_aura_text_sprite.bitmap   = bitmap
    @_aura_text_sprite.ox       = 80
    @_aura_text_sprite.oy       = 24
    @_aura_text_sprite.x        = self.x
    @_aura_text_sprite.y        = self.y - self.oy + @character.aura_text_y
    @_aura_text_sprite.z        = 3000
    @_aura_text_sprite.visible  = true
    # Saves aura Text
    @_aura_display_text = @character.aura_text
  end
  #--------------------------------------------------------------------------
  # * Create aura text color
  #     color_array : array of four color parameters (rrr,ggg,bbb,aaa)
  #--------------------------------------------------------------------------
  def create_aura_color(color_array)
    return Color.new(color_array[0], color_array[1],
                     color_array[2], color_array[3])
  end
end



#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Script Call Command
  #--------------------------------------------------------------------------
  def aura
    return unless $scene.is_a?(Scene_Map)
    $scene.aura_test
  end
end



#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias game_map_aura_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @current = false if @current.nil?
    # Do test if key triggered
    (Aura::AURA_MODE == true) ? aura_mode_two : aura_mode_one
    # Perform the original call
    game_map_aura_update
  end
  #--------------------------------------------------------------------------
  # * Aura System Mode One : Single keypress that draws the aura for X frames
  #--------------------------------------------------------------------------
  def aura_mode_one
    if $game_switches[Aura::AURA_SWITCH] == true then
      # Do test if key triggered
      aura_test if Input.trigger?(Aura::AURA_KEY)
      # Update timer
      aura_delay_update
    else
      aura_cancel
    end
  end
  #--------------------------------------------------------------------------
  # * Aura System Mode Two : Constatn keypress the shows aura until released
  #--------------------------------------------------------------------------
  def aura_mode_two
    if $game_switches[Aura::AURA_SWITCH] == true then
      # Player cannot be moving
      return aura_cancel if $game_player.moving?
      # Obtain keypress as local variable (works better as set variable)
      test = aura_toggle_key
      # If the current aura_key state doesn't match the keypress, we toggled
      if @current != test
        # Turn on or off the effect based on the new toggle state
        (test == true) ? aura_test : aura_cancel
        # And reset the toggle aura key toggle state
        @current = test
      end
    else
      aura_cancel
    end
  end
  #--------------------------------------------------------------------------
  # * Aura System Toggle Key : Returns if the desired keypress is true or not
  #--------------------------------------------------------------------------
  def aura_toggle_key
    return true if Input.press?(Aura::AURA_KEY)
    return false
  end
  #--------------------------------------------------------------------------
  # * Test objects within range of player within the map
  #     range : area range from target (default in config)
  #--------------------------------------------------------------------------
  def aura_test(range=Aura::AURA_RANGE)
    # No larger than approx 1/2 map height (effect safeguard)
    range = 7 if range > 7
    # Cycle through events
    for event in $game_map.events
      # Skip if not in screen range (limit the events tested)
      next unless $game_map.aura_in_range?(event[1])
      # Perform aura if in range of player
      aura_apply(event) if aura_in_range?($game_player, event[1],range)
    end
  end
  #--------------------------------------------------------------------------
  # * Test objects within the map to remove effect
  #--------------------------------------------------------------------------
  def aura_cancel
    # Cycle through events
    for event in $game_map.events
      # Skip if not in screen range (limit the events tested)
      next unless $game_map.aura_in_range?(event[1])
      # Perform aura if in range of player
      aura_reset(event)
    end
  end
  #--------------------------------------------------------------------------
  # * Update the aura delay counter
  #--------------------------------------------------------------------------
  def aura_delay_update
    for event in $game_map.events
      next if event[1].aura_delay.nil?
      next aura_reset(event) if event[1].aura_delay == 0
      event[1].aura_delay -= 1 if event[1].aura_delay > 0
    end
  end
  #--------------------------------------------------------------------------
  # * Reset the event back to no aura
  #     event : event
  #--------------------------------------------------------------------------  
  def aura_reset(event)
    event[1].aura_delay     = 0
    event[1].aura_character = ""
    event[1].aura_text      = ""
    event[1].aura_text_y    = 0
  end
  #--------------------------------------------------------------------------
  #  * Aura Script's In Circle Range? (Near Fantastica View Range Edit)
  #     element : element
  #     object  : object
  #     range   : range from the target in tiles
  #--------------------------------------------------------------------------
  def aura_in_range?(element, object, range)
    x   = (element.x - object.x) * (element.x - object.x)
    y   = (element.y - object.y) * (element.y - object.y)
    r   = x + y
    return true if r <= (range * range)
    return false
  end  
  #--------------------------------------------------------------------------
  # * Apply Aura Effect on Event
  #     event : event
  #--------------------------------------------------------------------------
  def aura_apply(event)
    # Get list of comments
    mylist = SDK.event_comment_list(event[1])
    # Exit if no Aura ID
    return if mylist.nil?
    # Garner data from comment list
    returned = SDK.event_comment_data(mylist, Aura::AURA_TEXT)
    unless returned.nil?
      if returned[0,1] == "["
        r_array = []
        r_array = eval(returned)
        event[1].aura_text    = r_array[0]
        event[1].aura_text_y  = r_array[1].to_i
      else
        event[1].aura_text    = returned
        event[1].aura_text_y  = 0
      end
    end
    # Garner data from comment list
    returned = SDK.event_comment_data(mylist, Aura::AURA_GRAPHIC)
    # Exit if invalid data
    return if returned.nil?    
    event[1].aura_character = returned
    event[1].aura_delay     = (Aura::AURA_MODE == true) ? Aura::AURA_DELAY-1 :
                                                          Aura::AURA_DELAY
  end
end
Reply }


Messages In This Thread
Djigital Aura - by DerVVulfman - 09-23-2016, 05:08 AM
RE: Djigital Aura - by Djigit - 09-24-2016, 12:17 AM
RE: Djigital Aura - by DerVVulfman - 09-24-2016, 03:05 AM
RE: Djigital Aura - by DerVVulfman - 09-25-2016, 09:32 PM
RE: Djigital Aura - by RASHIDA12 - 09-26-2016, 04:00 AM
RE: Djigital Aura - by DerVVulfman - 09-26-2016, 04:24 AM
RE: Djigital Aura - by RASHIDA12 - 09-26-2016, 04:35 AM
RE: Djigital Aura - by DerVVulfman - 09-26-2016, 04:51 AM
RE: Djigital Aura - by RASHIDA12 - 09-26-2016, 02:14 PM
RE: Djigital Aura - by RASHIDA12 - 10-07-2016, 01:50 AM
RE: Djigital Aura - by DerVVulfman - 10-07-2016, 04:05 AM
RE: Djigital Aura - by RASHIDA12 - 10-07-2016, 12:50 PM
RE: Djigital Aura - by DerVVulfman - 10-08-2016, 03:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Victor Engine - State Aura Victor Sant 0 4,010 08-02-2012, 12:04 AM
Last Post: Victor Sant



Users browsing this thread: