Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: ThallionDarkshine on November 11, 2013, 07:35:54 pm

Title: [XP] Event Transitions
Post by: ThallionDarkshine on November 11, 2013, 07:35:54 pm
Event Transitions
Authors: ThallionDarkshine
Version: 1.1
Type: Event Animation System
Key Term: Environment Add-on



Introduction

This script allows you to transition in or out map events using many different transitions. Examples of possible transitions are found in the instructions section.


Features




Screenshots

Spoiler: ShowHide
(http://i.imgur.com/59MVict.png)



Demo

Demo (https://app.box.com/s/a2qyb0rjnnjdap0ck9ly)


Script

Spoiler: ShowHide
Code: ruby

=begin
 Event Transitions
   Author: ThallionDarkshine
 
 Instructions:
   Sample Arguments for fade_out (i.e. fade_out(ONE_OF_THE_EXAMPLES[, EVENT_ID (-1 for player)])).
     # Slicing Animations (Animation #0)
     #   parameters: (amount_movement)
     [0, 40]
     [0, 20]
     [0, 20, [0.6]]
     # Fading Animations (Animation #1)
     #   parameters: none
     [1, 20]
     [1, 30]
     # Zooming Animations (Animation #2)
     #   parameters: (x_zoom, y_zoom) or (zoom)
     [2, 30]
     [2, 20, [1.2]]
     [2, 30, [1, 0]]
     [2, 30, [0, 1]]
     [2, 30, [1.8, 0.2]]
     [2, 30, [0.2, 1.8]]
     [2, 30, [0.2]]
     # Zooming and Spinning Animations (Animation #3)
     #   parameters: (x_zoom, y_zoom, spin_degrees) or (zoom, spin_degrees)
     [3, 20]
     [3, 40, [1.8, 0.2, 720]]
     [3, 40, [0.2, 810]]
     [3, 40, [0.2, 1.8, 720]]
     # 3D Spin Animations (Animation #4)
     #   parameters: (zoom, num_rotations)
     [4, 40]
     [4, 40, [0, 4]]
     [4, 40, [0.5, 6]]
     [4, 30, [0.7, 2]]
     # Shaking Animations (Animation #7)
     #   parameters: (x_strength, x_speed, y_strength, y_speed) or (x_intensity, y_intensity)
     [7, 40]
     [7, 40, [6..9, 4..7]]
     # Ripple/Distort Animations (Animation #8)
     #   parameters: (x_amplitude, x_wavelength, num_x_ripples, y_amplitude, y_wavelength, num_y_ripples) or (x_amount, num_x_ripples, y_amount, num_y_ripples)
     [8, 40]
     [8, 40, [40, 10, 0.5, 10, 10, 2]]
     [8, 40, [10, 10, 2, 40, 10, 0.5]]
     [8, 40, [10, 40, 2, 10, 10, 2]]
     [8, 40, [10, 10, 2, 10, 40, 2]]
     [8, 40, [10, 10, 3, 10, 10, 2]]
     [8, 40, [10, 10, 2, 10, 10, 3]]
     [8, 10, [10, 40, 0.5, 10, 10, 0.5]]
     [8, 10, [10, 10, 0.5, 10, 40, 0.5]]
     # Dissolve to Sprite Animations (Animation #9)
     #   parameters: (fade_duration)
     #            or (fade_duration, x_size, y_size, negative?, tint_amount,
     #                tint_red, tint_green, tint_blue)
     #            or (fade_duration, x_size, y_size, negative?, tint_amount,
     #                tint_red, tint_green, tint_blue, grayscale_amount)
     #   note - use a float for x_size or y_size to specify it as a fraction
     #     example - 1.0 for the width of the sprite, 0.5 for half the width, and so on
     [9, 40]
     [9, 40, [10, 1.0, 1, false, 50, 200, 50, 50]]
     [9, 40, [10, 5, 5, true, 50, 100, 200, 200]]
     [9, 40, [10, 1, 1.0, false, 0, 0, 0, 0, 100]]
     # Dissolve Animations (Animation #10)
     [10, 40]
     [10, 40, [1, 1.0]]
     [10, 40, [5, 5]]
     [10, 20, [10, 10]]
     # Transition Graphic Animations (Animation #11)
     #   parameters: (transition_graphic_name, fade_duration)
     #     fade_duration - how long it takes for each individual pixel of the
     #       sprite to fade out
     [11, 100]
     [11, 40, ['001-Blind01', 5]]
   Sample Arguments for fade_in (i.e. fade_in(ONE_OF_THE_EXAMPLES[, EVENT_ID (-1 for player)])).
     # Fading Animations (Animation #0)
     #   parameters: none
     [0, 20]
     [0, 30]
     # Zooming Animations (Animation #1)
     #   parameters: (x_zoom, y_zoom) or (zoom)
     [1, 30]
     [1, 20, [1.2]]
     [1, 30, [1, 0]]
     [1, 30, [0, 1]]
     [1, 30, [1.8, 0.2]]
     [1, 30, [0.2, 1.8]]
     [1, 30, [0.2]]
     # Zooming and Spinning Animations (Animation #2)
     #   parameters: (x_zoom, y_zoom, spin_degrees) or (zoom, spin_degrees)
     [2, 20]
     [2, 40, [1.8, 0.2, 720]]
     [2, 40, [0.2, 810]]
     [2, 40, [0.2, 1.8, 720]]
     # 3D Spin Animations (Animation #3)
     #   parameters: (horizontal?, zoom, num_rotations)
     [3, 40]
     [3, 40, [true, 0, 4]]
     [3, 40, [true, 0.5, 6]]
     [3, 30, [true, 0.7, 2]]
     # Shaking Animations (Animation #6)
     #   parameters: (x_strength, x_speed, y_strength, y_speed) or (x_intensity, y_intensity)
     [6, 40]
     [6, 40, [6..9, 4..7]]
     # Transition Graphic Animations (Animation #7)
     #   parameters: (transition_graphic_name, fade_duration)
     #     fade_duration - how long it takes for each individual pixel of the
     #       sprite to fade out
     [7, 100]
     [7, 40, ['001-Blind01', 5]]
=end

unless Object.const_defined?(:Transitions)
 raise 'This script requires ThallionDarkshine\'s Transitions Module'
end

class Interpreter
 def fade_out(params, event_id = @event_id)
   if event_id > 0
     $game_map.events[event_id].fade_out(params)
   elsif event_id == -1
     $game_player.fade_out(params)
   end
 end
 
 def fade_in(params, event_id = @event_id)
   if event_id > 0
     $game_map.events[event_id].fade_in(params)
   elsif event_id == -1
     $game_player.fade_in(params)
   end
 end
end

class Game_Character
 attr_accessor :transition, :trans_dir
 
 alias tdks_ev_trans_init initialize
 def initialize(*args)
   tdks_ev_trans_init(*args)
   @transition = nil
   @trans_dir = 0
 end
 
 def fade_out(params)
   @transition = params
   @trans_dir = 0
 end
 
 def fade_in(params)
   @transition = params
   @trans_dir = 1
 end
end

class Sprite_Character
 alias tdks_ev_trans_init initialize
 def initialize(*args)
   tdks_ev_trans_init(*args)
   @visible = true
   @orig_bmp = nil
   @orig_state = nil
 end
 
 alias tdks_ev_trans_updt update
 def update
   if @visible && !Transitions.transitioning_out?(self) && !Transitions.transitioning_in?(self)
     tdks_ev_trans_updt
   end
   if !@character.transition.nil?
     if @character.trans_dir == 0
       @orig_bmp = self.bitmap.clone
       @orig_state = [self.zoom_x, self.zoom_y, self.opacity, self.ox, self.oy, self.angle, self.src_rect.clone]
     elsif !@orig_bmp.nil?
       sr = @orig_state[6]
       self.bitmap = @orig_bmp.clone
       self.x += @orig_state[3] - self.ox
       self.y += @orig_state[4] - self.oy
       self.zoom_x, self.zoom_y, self.opacity, self.ox, self.oy, self.angle = *@orig_state
       self.src_rect = sr
     end
     @character.trans_dir == 0 ? Transitions.transition_out(self, *@character.transition) : Transitions.transition_in(self, *@character.transition)
     @character.transition = nil
     @visible = @character.trans_dir != 0
   end
 end
end



Instructions

Example arguments for the call to fade_out (i.e. fade_out(ONE_OF_THE_EXAMPLES[, EVENT_ID (-1 for player)])).
Spoiler: ShowHide
Code: ruby

   # Slicing Animations (Animation #0)
   #   parameters: (amount_movement)
   [0, 40],
   [0, 20],
   [0, 20, [0.6]],
   # Fading Animations (Animation #1)
   #   parameters: none
   [1, 20],
   [1, 30],
   # Zooming Animations (Animation #2)
   #   parameters: (x_zoom, y_zoom) or (zoom)
   [2, 30],
   [2, 20, [1.2]],
   [2, 30, [1, 0]],
   [2, 30, [0, 1]],
   [2, 30, [1.8, 0.2]],
   [2, 30, [0.2, 1.8]],
   [2, 30, [0.2]],
   # Zooming and Spinning Animations (Animation #3)
   #   parameters: (x_zoom, y_zoom, spin_degrees) or (zoom, spin_degrees)
   [3, 20],
   [3, 40, [1.8, 0.2, 720]],
   [3, 40, [0.2, 810]],
   [3, 40, [0.2, 1.8, 720]],
   # 3D Spin Animations (Animation #4)
   #   parameters: (zoom, num_rotations)
   [4, 40],
   [4, 40, [0, 4]],
   [4, 40, [0.5, 6]],
   [4, 30, [0.7, 2]],
   # Shaking Animations (Animation #7)
   #   parameters: (x_strength, x_speed, y_strength, y_speed) or (x_intensity, y_intensity)
   [7, 40],
   [7, 40, [6..9, 4..7]],
   # Ripple/Distort Animations (Animation #8)
   #   parameters: (x_amplitude, x_wavelength, num_x_ripples, y_amplitude, y_wavelength, num_y_ripples) or (x_amount, num_x_ripples, y_amount, num_y_ripples)
   [8, 40],
   [8, 40, [40, 10, 0.5, 10, 10, 2]],
   [8, 40, [10, 10, 2, 40, 10, 0.5]],
   [8, 40, [10, 40, 2, 10, 10, 2]],
   [8, 40, [10, 10, 2, 10, 40, 2]],
   [8, 40, [10, 10, 3, 10, 10, 2]],
   [8, 40, [10, 10, 2, 10, 10, 3]],
   [8, 10, [10, 40, 0.5, 10, 10, 0.5]],
   [8, 10, [10, 10, 0.5, 10, 40, 0.5]],
   # Dissolve to Sprite Animations (Animation #9)
   #   parameters: (fade_duration)
   #            or (fade_duration, x_size, y_size, negative?, tint_amount,
   #                tint_red, tint_green, tint_blue)
   #            or (fade_duration, x_size, y_size, negative?, tint_amount,
   #                tint_red, tint_green, tint_blue, grayscale_amount)
   #   note - use a float for x_size or y_size to specify it as a fraction
   #     example - 1.0 for the width of the sprite, 0.5 for half the width, and so on
   [9, 40],
   [9, 40, [10, 1.0, 1, false, 50, 200, 50, 50]],
   [9, 40, [10, 5, 5, true, 50, 100, 200, 200]],
   [9, 40, [10, 1, 1.0, false, 0, 0, 0, 0, 100]],
   # Dissolve Animations (Animation #10)
   [10, 40],
   [10, 40, [1, 1.0]],
   [10, 40, [5, 5]],
   [10, 20, [10, 10]],
   # Transition Graphic Animations (Animation #11)
   #   parameters: (transition_graphic_name, fade_duration)
   #     fade_duration - how long it takes for each individual pixel of the
   #       sprite to fade out
   [11, 100],
   [11, 40, ['001-Blind01', 5]],


Example arguments for the call to fade_in (i.e. fade_in(ONE_OF_THE_EXAMPLES[, EVENT_ID (-1 for player)])).
Spoiler: ShowHide
Code: ruby

   # Fading Animations (Animation #0)
   #   parameters: none
   [0, 20],
   [0, 30],
   # Zooming Animations (Animation #1)
   #   parameters: (x_zoom, y_zoom) or (zoom)
   [1, 30],
   [1, 20, [1.2]],
   [1, 30, [1, 0]],
   [1, 30, [0, 1]],
   [1, 30, [1.8, 0.2]],
   [1, 30, [0.2, 1.8]],
   [1, 30, [0.2]],
   # Zooming and Spinning Animations (Animation #2)
   #   parameters: (x_zoom, y_zoom, spin_degrees) or (zoom, spin_degrees)
   [2, 20],
   [2, 40, [1.8, 0.2, 720]],
   [2, 40, [0.2, 810]],
   [2, 40, [0.2, 1.8, 720]],
   # 3D Spin Animations (Animation #3)
   #   parameters: (horizontal?, zoom, num_rotations)
   [3, 40],
   [3, 40, [true, 0, 4]],
   [3, 40, [true, 0.5, 6]],
   [3, 30, [true, 0.7, 2]],
   # Shaking Animations (Animation #6)
   #   parameters: (x_strength, x_speed, y_strength, y_speed) or (x_intensity, y_intensity)
   [6, 40],
   [6, 40, [6..9, 4..7]],
   # Transition Graphic Animations (Animation #7)
   #   parameters: (transition_graphic_name, fade_duration)
   #     fade_duration - how long it takes for each individual pixel of the
   #       sprite to fade out
   [7, 100],
   [7, 40, ['001-Blind01', 5]],



Compatibility

No issues known atm.


Credits and Thanks




Author's Notes

You'll also need my transitions module (http://pastebin.com/raw.php?i=P6YDaVzU) for this script to work, as well as this (https://www.box.com/s/ykkt0r1bsfz84p6khvq5) dll.
Title: Re: [XP] Event Transitions
Post by: Zexion on November 11, 2013, 09:00:10 pm
This is an awesome script! I might use it for epic boss battles, lol. Very nice, darkshine!
Title: Re: [XP] Event Transitions
Post by: LiTTleDRAgo on November 12, 2013, 03:14:11 am
It's a nice script, Thal :)

why didn't you use Game_Character instead Game_Event?
that way you can also use this script to Game_Player as well

cross engined?: ShowHide
VX = defined?(Window_ActorCommand)
raise "Need ThallionDarkshine's Transitions Module" unless defined?(Transitions)

Klass = VX ? Game_Interpreter : Interpreter
class Klass
  def fade_out(params, event_id = @event_id)
    event_id.is_a?(Game_Character) && event_id.fade_out(params)
    event_id.is_a?(Integer) && fade_out(params, get_character(event_id))
    true
  end
 
  def fade_in(params, event_id = @event_id)
    event_id.is_a?(Game_Character) && event_id.fade_in(params)
    event_id.is_a?(Integer) && fade_in(params, get_character(event_id))
    true
  end
end

class Game_Character
  attr_accessor :transition
  define_method(:trans_dir) { @trans_dir ||= 0 }
  define_method(:fade_out)  { |params|  @transition, @trans_dir = params, 0 }
  define_method(:fade_in)   { |params|  @transition, @trans_dir = params, 1 }
end

class Sprite_Character
 
  alias_method :tdks_ev_trans_updt, :update
  def update
    tdks_ev_trans_updt if update_without_trans?
    if @character.is_a?(Game_Character) && @character.transition.is_a?(Array)
      return unless defined?(Transitions)
      if @character.trans_dir == 0
        @orig_bmp = self.bitmap.clone
        @orig_state = [self.zoom_x, self.zoom_y, self.opacity, self.ox,
                   self.oy, self.angle, self.src_rect.clone]
      elsif @orig_bmp.is_a?(Bitmap) && @orig_state.is_a?(Array)
        sr = @orig_state[6]
        self.bitmap = @orig_bmp.clone
        self.x += @orig_state[3] - self.ox
        self.y += @orig_state[4] - self.oy
        self.zoom_x, self.zoom_y, self.opacity,
            self.ox, self.oy, self.angle = *@orig_state
        self.src_rect = sr
      end
      method = @character.trans_dir == 0 ? :transition_out : :transition_in
      Transitions.send(method, self, *@character.transition)
      @character.transition = nil
      @visible = @character.trans_dir != 0 ? true : false
    end
  end
 
  def update_without_trans?
    return true  unless defined?(Transitions)
    return false if @visible.is_a?(FalseClass)
    return false if Transitions.transitioning_out?(self)
    return false if Transitions.transitioning_in?(self)
    return true
  end
end
Title: Re: [XP] Event Transitions
Post by: ThallionDarkshine on November 12, 2013, 06:36:00 am
Yeah, i realized a little while after i wrote it that i should've added in support for the player, as well as events other than the current event. I'll fix that after i get back from school.

Edit - And update to v1.1. You can now call fade_out on any event, including the player, instead of just the event you called the method from.
Title: Re: [XP] Event Transitions
Post by: Zexion on November 13, 2013, 01:44:55 pm
<3
I think you are now added to my list of favorite scripters :P
Title: Re: [XP] Event Transitions
Post by: Heretic86 on November 13, 2013, 08:53:43 pm
We could definitely use a Demo so we can learn from working examples.

Also, dont be afraid to give yourself some credit for creating this!  Typically at the top of the script along with a copy of instructions are good things to include with the script itself.  Its just so people dont have to come to this thread to see the instructions.

Concept is OUTSTANDING!
Title: Re: [XP] Event Transitions
Post by: ThallionDarkshine on November 14, 2013, 03:14:10 pm
Transitions module and rgss_addon.dll updated. This will fix many issues with transitioning out events. Also, the demo is done, and should be up in a matter of minutes. In the demo there are a bunch of transitions graphics that i made a while back. These could be used for cool effects in transitioning out sprites.
Title: Re: [XP] Event Transitions
Post by: Heretic86 on November 18, 2013, 09:37:46 am
A touch of humor in the demo as well, I love it!
Title: Re: [XP] Event Transitions
Post by: Heretic86 on November 20, 2013, 10:01:52 pm
Okay, now that I've had a chance to examine the demo and script...

First Bug: Fade in.  fade_in([8, 40], @event_id) caused the Event Graphic to get stuck and no transition occurs

Next minor bug: After going into Battle then coming back to the Map, the Event is visible again after it disappeared.

F12 causes crash.  /shocked

Next minor recommendation: might change the name of the DLL file so it is more descriptive as what its purpose is.  Event Transitions.

Questions:

Can these effects be applied to Battler Sprites as well as a replacement for the default death animation?

Can these effects be applied to multiple events or other objects simultaneously?

Can the effect be applied to other Sprites, like background?  

Not sure if Game Screen is even possible... and that may just be too much.  But for subtle effects that loop, like underwater distortion, or even Battle Transitions...  I'll just stick with stuff like Backgrounds and Panoramas unless you want to take a crack at Game Screen...

Title: Re: [XP] Event Transitions
Post by: ThallionDarkshine on November 21, 2013, 06:33:29 am
First Bug: fade_in only goes up to 7. This is because some of the transition out modes do not look good with transition in at all. There is a separate section of the instructions for fade_in

Second Bug: I will work on fixing that. I just need to put an array in $game_map that stores which events have already been faded out. Though an alternative would be just creating another page with self switch: a as the condition.

F12: If you want to stop crashes, just use the F12 fix script i posted earlier.

DLL File: It's used for every one of my scripts, so i just keep it named rgss_addon.dll.

Battler Sprites: Yes, that's my battler transitions script.

Multiple Events: Yes.

Other Sprites: Yes, you would just need some scripting knowledge. Syntax would be:
Code: ruby
Transitions.transition_out(SPRITE, PARAMETERS_NOT_AS_ARRAY)
Transitions.transition_in(SPRITE, PARAMETERS_NOT_AS_ARRAY)

Though some of the transitions are not easily reversible so you would have to save the state of the sprite before transitioning it out if you want to transition it back in.
Title: Re: [XP] Event Transitions
Post by: Heretic86 on November 21, 2013, 09:28:47 am
Ok, got me thinking, why not just change the events opacity to 0 at the end of the animation when fading out?