[XP] Arrow Add-on

Started by ThallionDarkshine, January 18, 2013, 09:17:45 pm

Previous topic - Next topic

ThallionDarkshine

January 18, 2013, 09:17:45 pm Last Edit: January 19, 2013, 07:15:19 am by ThallionDarkshine
Arrow Add-on
Authors: ThallionDarkshine
Version: 0.2
Type: Battle Arrow Add-on
Key Term: Battle Add-on



Introduction

Have you ever looked at the default arrow animation system and thought, "this looks horrible". Well, this script allows you to customize many aspects of the arrows' animation, allowing you to make the arrows grow/shrink, bob, spin, fade, and colorize. You can also use the default option, though why would you, unless in conjunction with other animations.


Features


  • Give your battle arrows cool animations!

  • Use any combination of the animations.




Screenshots




Demo

No demo.


Script

Spoiler: ShowHide

module Arrow_Config
  # whether to use the normal animation, switching between the two arrow graphics
  NORMAL = true
  # how long each graphic should be shown for (RMXP default is 4)
  NORMAL_DURATION = 4
 
  # whether to use a 3D-Spin animation
  SPIN3D = false
  # the duration of one rotation (360 degrees)
  SPIN3D_DURATION = 120
 
  # whether to use a spin animation
  SPIN = false
  # the duration of one rotation (360 degrees)
  SPIN_DURATION = 120
 
  # whether to use a fade animation
  FADE = false
  # how long it should take to fade out fully
  FADE_DURATION = 10
  # how much to fade out
  FADE_AMOUNT = 85
 
  # whether to use a colorize animation
  COLORIZE = false
  # how long it should take to fully colorize
  COLORIZE_DURATION = 20
  # how much to colorize
  COLORIZE_AMOUNT = 127
  # the color to colorize with
  COLORIZE_COLOR = Color.new(255, 0, 0)
 
  # whether to use a grow/shrink animation
  BULGE = false
  # how long to take to fully grow/shrink
  BULGE_DURATION = 20
  # how much to grow (use a negative for shrinking)
  BULGE_AMOUNT = -0.2
 
  # whether to use a bob animation
  BOB = false
  # how much to bob
  BOB_AMOUNT = 3
  # the duration of one bob
  BOB_DURATION = 40
 
  # whether to use a rock animation
  ROCK = false
  # how much to rock (degrees)
  ROCK_AMOUNT = 10
  # the duration of one rock
  ROCK_DURATION = 20
 
  # whether to use a 3D-Rock animation
  ROCK3D = false
  # how much to rock(degrees)
  ROCK3D_AMOUNT = 60
  # the duration of one rock
  ROCK3D_DURATION = 40
 
  # whether to reset all the animations when the player switches between targets
  RESET_ON_SWITCH = false
end

class Arrow_Base
  alias tdks_arrow_init initialize
  def initialize(vpt)
    @oy = 0
    tdks_arrow_init(vpt)
    self.src_rect.set(128, 96, 32, 32)
    self.oy = 16
    @angle = 0
    @angle2d = 0
    @fade_count = 0
    @colorize_count = 0
    @bulge_count = 0
    @bob_count = 0
    @rock_count = Arrow_Config::ROCK_DURATION / 2
    @rock3d_count = Arrow_Config::ROCK3D_DURATION / 2
    @initialized = true
  end
 
  def update
    return if @initialized.nil?
    if (!@lind or @lind != @index) and Arrow_Config::RESET_ON_SWITCH == true
      @lind = @index
      @bob_count = @blink_count = @angle = @angle2d = @fade_count = @colorize_count = 0
      @rock_count = Arrow_Config::ROCK_DURATION / 2
      @rock3d_count = Arrow_Config::ROCK3D_DURATION / 2
    end
    if Arrow_Config::NORMAL
      # Update blink count
      @blink_count = (@blink_count + 1) % (Arrow_Config::NORMAL_DURATION * 2)
      # Set forwarding origin rectangle
      if @blink_count < Arrow_Config::NORMAL_DURATION
        self.src_rect.set(128, 96, 32, 32)
      else
        self.src_rect.set(160, 96, 32, 32)
      end
    end
   
    if Arrow_Config::SPIN3D
      @angle = (@angle + 1) % Arrow_Config::SPIN3D_DURATION
      angle = @angle * 360 / Arrow_Config::SPIN3D_DURATION
      if angle < 90
        self.zoom_x = Math.sin((90 - angle) * Math::PI / 180)
      elsif angle < 180
        self.mirror = true
        self.zoom_x = Math.sin((angle - 90) * Math::PI / 180)
      elsif angle < 270
        self.mirror = true
        self.zoom_x = Math.sin((270 - angle) * Math::PI / 180)
      else
        self.zoom_x = Math.sin((angle - 270) * Math::PI / 180)
      end
    end
   
    if Arrow_Config::ROCK3D
      @rock3d_count = (@rock3d_count + 1) % (2 * Arrow_Config::ROCK3D_DURATION)
      angle = (@rock3d_count < Arrow_Config::ROCK3D_DURATION ? 0-Arrow_Config::ROCK3D_AMOUNT+Arrow_Config::ROCK3D_AMOUNT * 2 * @rock3d_count / Arrow_Config::ROCK3D_DURATION : Arrow_Config::ROCK3D_AMOUNT - Arrow_Config::ROCK3D_AMOUNT * 2 * (@rock3d_count - Arrow_Config::ROCK3D_DURATION) / Arrow_Config::ROCK3D_DURATION)
      if angle < 90
        self.zoom_x = Math.sin((90 - angle) * Math::PI / 180)
      elsif angle < 180
        self.mirror = true
        self.zoom_x = Math.sin((angle - 90) * Math::PI / 180)
      elsif angle < 270
        self.mirror = true
        self.zoom_x = Math.sin((270 - angle) * Math::PI / 180)
      else
        self.zoom_x = Math.sin((angle - 270) * Math::PI / 180)
      end
    end
   
    if Arrow_Config::SPIN
      @angle2d = (@angle2d + 1) % Arrow_Config::SPIN_DURATION
      self.angle = @angle2d * 360 / Arrow_Config::SPIN_DURATION
    end
   
    if Arrow_Config::ROCK
      @rock_count = (@rock_count + 1) % (2 * Arrow_Config::ROCK_DURATION)
      self.angle = (@rock_count < Arrow_Config::ROCK_DURATION ? 0-Arrow_Config::ROCK_AMOUNT+Arrow_Config::ROCK_AMOUNT * 2 * @rock_count / Arrow_Config::ROCK_DURATION : Arrow_Config::ROCK_AMOUNT - Arrow_Config::ROCK_AMOUNT * 2 * (@rock_count - Arrow_Config::ROCK_DURATION) / Arrow_Config::ROCK_DURATION)
    end
   
    if Arrow_Config::FADE
      @fade_count = (@fade_count + 1) % (Arrow_Config::FADE_DURATION * 2)
      self.opacity = (@fade_count < Arrow_Config::FADE_DURATION ? 255 - Arrow_Config::FADE_AMOUNT * @fade_count / Arrow_Config::FADE_DURATION : 255 - Arrow_Config::FADE_AMOUNT * (Arrow_Config::FADE_DURATION * 2 - @fade_count) / Arrow_Config::FADE_DURATION)
    end
   
    if Arrow_Config::COLORIZE
      @colorize_count = (@colorize_count + 1) % (Arrow_Config::COLORIZE_DURATION * 2)
      self.color = Arrow_Config::COLORIZE_COLOR
      self.color.alpha = Arrow_Config::COLORIZE_AMOUNT * (@colorize_count < Arrow_Config::COLORIZE_DURATION ? @colorize_count.to_f / Arrow_Config::COLORIZE_DURATION : (Arrow_Config::COLORIZE_DURATION * 2 - @colorize_count.to_f) / Arrow_Config::COLORIZE_DURATION)
    end
   
    if Arrow_Config::BULGE
      @bulge_count = (@bulge_count + 1) % (Arrow_Config::BULGE_DURATION * 2)
      z = Arrow_Config::BULGE_AMOUNT * (@bulge_count < Arrow_Config::BULGE_DURATION ? @bulge_count.to_f / Arrow_Config::BULGE_DURATION : (Arrow_Config::BULGE_DURATION * 2 - @bulge_count.to_f) / Arrow_Config::BULGE_DURATION)
      self.zoom_x = self.zoom_y = 1 + z
    end
   
    if Arrow_Config::BOB
      @bob_count = (@bob_count + 1) % (Arrow_Config::BOB_DURATION)
      @oy = Arrow_Config::BOB_AMOUNT * Math.sin(@bob_count * Math::PI * 2 / Arrow_Config::BOB_DURATION)
    end
   
    # Update help text (update_help is defined by the subclasses)
    if @help_window != nil
      update_help
    end
  end
end

class Arrow_Enemy
  alias tdks_arrow_updt update
  def update
    tdks_arrow_updt
    self.y -= 48 - @oy
  end
end

class Arrow_Actor
  alias tdks_arrow_updt update
  def update
    tdks_arrow_updt
    self.y -= 48 - @oy
  end
end



Instructions

Just paste in the script and set up the configuration.


Compatibility

May not work with other scripts that modify the battle arrows.


Credits and Thanks


  • ThallionDarkshine




Author's Notes

None.

Blizzard

You should always post some screenshots. xD I usually like to take a look at how the script looks like in action.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ThallionDarkshine

Added screenshots and... update to v0.2. I added a couple more animations, including the rock and 3d-rock animations.