Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Maximusmaxy's Eventing Shortcuts, Increase your eventing power
maximusmaxy
post Nov 2 2011, 04:17 AM
Post #1


PZE whore
Group Icon

Group: Revolutionary
Posts: 131
Type: Scripter
RM Skill: Skilled




Maximusmaxy's Eventing Shortcuts

Version: 0.5
Author: Maximusmaxy
Release Date: 18/11/11

Exclusive Script at RPG RPG Revolution

Introduction
This script features a series of script calls which allow you to do multiple event commands and new features in a single script call. This is especially useful for a range of things, such as really long move routes, smooth opacity and colour transitions, and it allows you to use battle effects on the map.

The script was originally written as a PZE script to make longer move routes and character opacity transitions allot simpler, but I decided to add allot more features so it can now be used by anyone to make life simpler for pretty much anything.

Features
  • multiple move route commands in one script call
  • smooth opacity, colour, tone, zoom transitions for events and the player
  • battle effects on the map
  • loopable animations

If there is something you would like added let me know.

Script
CODE
#===============================================================================
# ■ Maximusmaxy's Eventing Shortcuts
#-------------------------------------------------------------------------------
# Increases your eventing power.
#-------------------------------------------------------------------------------
# Author: Maximusmaxy
# Version 0.5: 18/11/11
# Thanks to:
# Baffou - Gave me idea's and suggestions to make this script
#===============================================================================
#
# Instructions:
# Implement one of the following call scripts on your events to do specific
# functions. The functions are pretty self explanatory. The call scripts can
# also be placed in the move route script command, and will effect the
# referenced event or player.
#
# Script Calls:
#
# The following are the move commands repeated multiple times.
#
# EVENT.down(TIMES)
# EVENT.left(TIMES)
# EVENT.right(TIMES)
# EVENT.up(TIMES)
# EVENT.downleft(TIMES)
# EVENT.downright(TIMES)
# EVENT.upleft(TIMES)
# EVENT.upright(TIMES)
# EVENT.random(TIMES)
# EVENT.toward(TIMES)
# EVENT.away(TIMES)
# EVENT.forward(TIMES)
# EVENT.backward(TIMES)
# TIMES is the amount of moves made
#
# EVENT.jump(X,Y,TIMES)
# X and Y are the x/y distance
# TIMES is the amount of jumps made
#
# EVENT.location(X,Y,DIRECTION)
# X and Y are the new location of the character
# DIRECTION is the new facing direction, can be ommited if retained
# Down = 2, Left = 4, Right = 6, Up = 8 (Like the number pad)
#
# The duration for the following script calls can be ommitted if you want
# the change to be instant.
#
# EVENT.fade(OPACITY, DURATION)
# OPACITY is your target opacity. Transparent = 0, Opaque = 255
# DURATION is how long the transition takes
#
# EVENT.flash(R, G, B, DURATION)
# R, G, B is the flash color setting
# DURATION is how long the flash takes
#
# EVENT.color(R, G, B, A, DURATION)
# R, G, B is the color blended into the character. Default is 128, 128, 128
# A is the alpha or opacity of the color. Default is 0
# DURATION is how long the transition takes
#
# EVENT.tone(R, G, B, GREY, DURATION)
# R, G, B, GREY is the tone blended into the character. Default is 0, 0, 0, 0
# DURATION is how long the transition takes
#
# EVENT.zoom(RATIO, DURATION)
# RATIO is the ratio of zoom. Default is 1.0
# DURATION is how long the transition takes
#
# EVENT.reset(DURATION)
# DURATION is how long it takes to reset the opacity, color, tone and zoom ratio
#
# The following are the built in battle effects, which can now be used outside
# of battle on events or the player.
#
# EVENT.whiten
# does a weak flash effect on the character
#
# EVENT.collapse
# collapses the character with a red fade.
#
# EVENT.damage(VALUE,CRITICAL)
# VALUE is the damage shown on the character, it can also be text.
# If VALUE is positive text is white, if negative text is green.
# CRITICAL is true if the word critical is also displayed. Can be ommitted.
#
# EVENT.animation(ID,LOOP)
# ID of the animation
# If LOOP is true the animation will loop until an EVENT.end command
# LOOP defaults as false and can be ommitted
#
# EVENT.end
# ends the animation loop
#
#===============================================================================

$max_events = 0.5

#===============================================================================
# EVENT
#===============================================================================

module EVENT
  def self.down(times) #down
    $game_temp.eventing_character.force_move_multiple(1,times)
    return
  end
  
  def self.left(times) #left
    $game_temp.eventing_character.force_move_multiple(2,times)
    return
  end
  
  def self.right(times) #right
    $game_temp.eventing_character.force_move_multiple(3,times)
    return
  end
  
  def self.up(times) #up
   $game_temp.eventing_character.force_move_multiple(4,times)
    return
  end
  
  def self.downleft(times) #lower left
    $game_temp.eventing_character.force_move_multiple(5,times)
    return
  end
  
  def self.downright(times) #lower right
    $game_temp.eventing_character.force_move_multiple(6,times)
    return
  end
  
  def self.upleft(times) #upper left
    $game_temp.eventing_character.force_move_multiple(7,times)
    return
  end
  
  def self.upright(times) #upper right
    $game_temp.eventing_character.force_move_multiple(8,times)
    return
  end
  
  def self.random(times) #random
    $game_temp.eventing_character.force_move_multiple(9,times)
    return
  end
  
  def self.toward(times) #toward
    $game_temp.eventing_character.force_move_multiple(10,times)
    return
  end
  
  def self.away(times) #away
    $game_temp.eventing_character.force_move_multiple(11,times)
    return
  end
  
  def self.forward(times) #forward
    $game_temp.eventing_character.force_move_multiple(12,times)
    return
  end
  
  def self.backward(times) #backward
    $game_temp.eventing_character.force_move_multiple(13,times)
    return
  end
  
  def self.jump(x,y,times) #jump
    $game_temp.eventing_character.force_jump_multiple(x,y,times)
    return
  end
  
  def self.location(x,y,d = $game_temp.eventing_character.direction) #move to
    $game_temp.eventing_character.moveto(x,y)
    case d
    when 2
      $game_temp.eventing_character.turn_down
    when 4
      $game_temp.eventing_character.turn_left
    when 6
      $game_temp.eventing_character.turn_right
    when 8
      $game_temp.eventing_character.turn_up
    end
    return true
  end
  
  def self.fade(opacity,duration = 1) #fade the character
    $game_temp.eventing_character.opacity_target = opacity
    $game_temp.eventing_character.opacity_duration = duration
    return true
  end
  
  def self.flash(r, g, b, duration = 1) #flash the character
    $game_temp.eventing_character.flash_flag = true
    $game_temp.eventing_character.flash_color = Color.new(r,g,b)
    $game_temp.eventing_character.flash_duration = duration
    return true
  end
  
  def self.color(r, g, b, a, duration = 1) #change the characters color
    $game_temp.eventing_character.color_target = Color.new(r,g,b,a)
    $game_temp.eventing_character.color_duration = duration
    return true
  end
  
  def self.tone(r, g, b, grey, duration = 1) #change the characters tone
    $game_temp.eventing_character.tone_target = Tone.new(r,g,b,grey)
    $game_temp.eventing_character.tone_duration = duration
    return true
  end
  
  def self.zoom(ratio, duration = 1) #zoom the character
    $game_temp.eventing_character.zoom_target = ratio
    $game_temp.eventing_character.zoom_duration = duration
    return true
  end
  
  def self.reset(duration = 1) #reset the opacity, color and zoom ratio
    self.fade(255,duration)
    self.color(128,128,128,0,duration)
    self.tone(0,0,0,0,duration)
    self.zoom(1.0,duration)
    return true
  end
  
  def self.whiten #weak flash effect
    $game_temp.eventing_character.whiten_flag = true
    return true
  end
  
  def self.collapse #collapse effect
    $game_temp.eventing_character.collapse_flag = true
    return true
  end
  
  def self.damage(value, critical = false)
    $game_temp.eventing_character.damage_flag = true
    $game_temp.eventing_character.damage_value = value
    $game_temp.eventing_character.damage_critical = critical
    return
  end
  
  def self.animation(id, loop = false) #loop an animation
    if loop
      $game_temp.eventing_character.animation_loop_id = id
    else
      $game_temp.eventing_character.animation_id = id
    end
    return
  end
  
  def self.end #end an animation loop
    $game_temp.eventing_character.animation_loop_id = 0
    return
  end
end

#===============================================================================
# Game_Temp
#===============================================================================

class Game_Temp
  attr_accessor :eventing_character
  alias max_event_initialize_later initialize
  def initialize
    max_event_initialize_later
    #character object accessable from script calls
    @eventing_character = nil
  end
end

#===============================================================================
# Game_Character
#===============================================================================

class Game_Character
  attr_accessor :through
  attr_reader :direction
  attr_accessor :opacity_target
  attr_accessor :opacity_duration
  attr_accessor :flash_flag
  attr_accessor :flash_color
  attr_accessor :flash_duration
  attr_reader :color
  attr_accessor :color_target
  attr_accessor :color_duration
  attr_reader :tone
  attr_accessor :tone_target
  attr_accessor :tone_duration
  attr_reader :zoom_ratio
  attr_accessor :zoom_target
  attr_accessor :zoom_duration
  attr_accessor :whiten_flag
  attr_accessor :collapse_flag
  attr_accessor :damage_flag
  attr_accessor :damage_value
  attr_accessor :damage_critical
  attr_accessor :animation_loop_id
  alias max_event_initialize_later initialize
  alias max_event_update_later update
  alias max_event_custom_later move_type_custom
  def initialize
    @opacity_target = 0
    @opacity_duration = 0
    @flash_flag = false
    @color = Color.new(128,128,128,0)
    @color_target = @color
    @color_duration = 0
    @tone = Tone.new(0,0,0,0)
    @tone_target = @tone
    @tone_duration = 0
    @zoom_ratio = 1.0
    @zoom_target = @zoom_ratio
    @zoom_duration = 0
    @whiten_flag = false
    @collapse_flag = false
    @damage_flag = false
    @animation_loop_id = 0
    max_event_initialize_later
  end
  
  def update
    #update the opacity
    if @opacity_duration > 0
      @opacity = (@opacity * (@opacity_duration - 1) + @opacity_target) /
                  @opacity_duration
      @opacity_duration -= 1
    end
    #update the zoom
    if @zoom_duration > 0
      @zoom_ratio = (@zoom_ratio * (@zoom_duration - 1) + @zoom_target) /
                     @zoom_duration
      @zoom_duration -= 1
    end
    #update the color
    if @color_duration > 0
      d = @color_duration
      @color.red = (@color.red * (d - 1) + @color_target.red) / d
      @color.green = (@color.green * (d - 1) + @color_target.green) / d
      @color.blue = (@color.blue * (d - 1) + @color_target.blue) / d
      @color.alpha = (@color.alpha * (d - 1) + @color_target.alpha) / d
      @color_duration -= 1
    end
    if @tone_duration > 0
      d = @tone_duration
      @tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
      @tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
      @tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
      @tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
      @tone_duration -= 1
    end
    max_event_update_later
  end
  
  def move_type_custom
    #change temp character
    $game_temp.eventing_character = self
    max_event_custom_later
  end
  
  def force_move_multiple(d, times, time_location = -1)
    #create an array to store move commands
    route = []
    #add the move command multiple times
    for i in 0...times
      route[i] = RPG::MoveCommand.new
      route[i].code = d
    end
    #acount for the time system
    index = (time_location == -1 ? @move_route_index : time_location)
    #delete the script at index
    @move_route.list.delete_at(index)
    #insert the move route commands into the characters move route
    @move_route.list.insert index, *route
    #decrement the move route index
    @move_route_index -= 1 if time_location == -1
    return
  end
  
  def force_jump_multiple(x, y, times, time_location = -1)
    #create an array to store move commands
    route = []
    #add the move command multiple times
    for i in 0...times
      route[i] = RPG::MoveCommand.new
      route[i].code = 14
      route[i].parameters = [x, y]
    end
    #acount for the time system
    index = (time_location == -1 ? @move_route_index : time_location)
    #delete the script at index
    @move_route.list.delete_at(index)
    #insert the move route commands into the characters move route
    @move_route.list.insert index, *route
    #decrement the move route index
    @move_route_index -= 1 if time_location == -1
    return
  end
end

#===============================================================================
# Sprite_Character
#===============================================================================

class Sprite_Character < RPG::Sprite
  alias max_event_initialize_later initialize
  alias max_event_update_later update
  def initialize(*args)
    @collapsing = false
    @animation_looping = false
    max_event_initialize_later(*args)
  end
  
  def update
    max_event_update_later
    #adjust the color, tone and zoom ratio
    self.color = @character.color if @character.color_duration > 0
    self.tone = @character.tone
    self.zoom_x = @character.zoom_ratio
    self.zoom_y = @character.zoom_ratio
    #whiten if needed
    if @character.whiten_flag
      whiten
      @character.whiten_flag = false
    end
    #flash if needed
    if @character.flash_flag
      flash(@character.flash_color,@character.flash_duration)
      @character.flash_flag = false
    end
    #collapse if needed
    if @character.collapse_flag
      collapse
      @character.collapse_flag = false
      @collapsing = true
    end
    #damage the character
    if @character.damage_flag
      damage(@character.damage_value, @character.damage_critical)
      @character.damage_flag = false
    end
    #loop an animation
    if @character.animation_loop_id != 0
      #if the animation isn't looping
      unless @animation_looping
        #start the animation loop
        loop_animation($data_animations[@character.animation_loop_id])
        @animation_looping = true
      end
    else
      #if the animation is looping
      if @animation_looping
        #end the animation
        dispose_loop_animation
        @animation_looping = false
      end
    end
    #overite opacity if collapsing
    if @collapsing
      if @_collapse_duration > 0
        @_collapse_duration -= 1
        self.opacity = 256 - (48 - @_collapse_duration) * 6
      else
        @character.through = true
        self.opacity = 0
      end
    end
  end
end

#===============================================================================
# Interpreter
#===============================================================================

class Interpreter
  alias max_event_355_later command_355
  def command_355
    #change temp character
    $game_temp.eventing_character = $game_map.events[@event_id]
    max_event_355_later
  end
end

Compatibility
Some of the shortcuts may have incompatibility issues with other scripts that overwrite opacity/colour settings. If there are any problems try placing the script at the bottom of all your other scripts.

DEMO
http://www.mediafire.com/?p71uwne331u97io

Installation
Paste the script above the main below the default scripts

Thanks to
Maximusmaxy - For writing the script.
Baffou - Gave me idea's and suggestions to make this script.

This post has been edited by maximusmaxy: Nov 18 2011, 12:24 AM


__________________________
Check out the new PZE Forums! http://zeldaengine.net/index.php
Go to the top of the page
 
+Quote Post
   
yamina-chan
post Nov 17 2011, 09:08 AM
Post #2


Level 8
Group Icon

Group: Revolutionary
Posts: 128
Type: None
RM Skill: Skilled




Finally I had some time to check this out and I think this can be even more usefull then I thought =D I couldn't find any bugs with it so far.
I can't think of anything that might be missing for this. Exept maybe a command that'd let you turn characters gray similar to what you did with the EVENT.color command. But nice work indeed =)

On a sidenote: when you're talking about setting up the direction (As in EVENT.location(X,Y,DIRECTION) for example) it is not explained in the instructions how you set up the direction. (with 2,4,6 and 8). Someone who knows something about scripts to a certain degree will figgure this out quick, newbies on the other hand might wonder why the project keeps crashing when they set the direction to LEFT as you would in the set mouve route commands e.g.

(Your Demo managed to scare me a second and got me to laugh once as well, by the way XD)


__________________________
There is a game out there for everyone. All you have to do is to find it.
Go to the top of the page
 
+Quote Post
   
maximusmaxy
post Nov 18 2011, 12:23 AM
Post #3


PZE whore
Group Icon

Group: Revolutionary
Posts: 131
Type: Scripter
RM Skill: Skilled




QUOTE
I can't think of anything that might be missing for this. Exept maybe a command that'd let you turn characters gray similar to what you did with the EVENT.color command.

I updated the script and added a tone feature to the events so you can change them grey by using EVENT.tone(0,0,0,255)

QUOTE
On a sidenote: when you're talking about setting up the direction (As in EVENT.location(X,Y,DIRECTION) for example) it is not explained in the instructions how you set up the direction. (with 2,4,6 and 8). Someone who knows something about scripts to a certain degree will figgure this out quick, newbies on the other hand might wonder why the project keeps crashing when they set the direction to LEFT as you would in the set mouve route commands e.g.

Thanks for the tip, I added a section in the instructions which explains the directions. It should help solve any error's people are having.

QUOTE
(Your Demo managed to scare me a second and got me to laugh once as well, by the way XD)

It scared me the first time the zoom function worked too happy.gif



__________________________
Check out the new PZE Forums! http://zeldaengine.net/index.php
Go to the top of the page
 
+Quote Post
   
SilentResident
post Nov 18 2011, 10:21 PM
Post #4


PZE Team Member
Group Icon

Group: Revolutionary
Posts: 669
Type: Developer
RM Skill: Skilled




QUOTE (maximusmaxy @ Nov 18 2011, 10:23 AM) *
QUOTE
I can't think of anything that might be missing for this. Exept maybe a command that'd let you turn characters gray similar to what you did with the EVENT.color command.

I updated the script and added a tone feature to the events so you can change them grey by using EVENT.tone(0,0,0,255)

QUOTE
On a sidenote: when you're talking about setting up the direction (As in EVENT.location(X,Y,DIRECTION) for example) it is not explained in the instructions how you set up the direction. (with 2,4,6 and 8). Someone who knows something about scripts to a certain degree will figgure this out quick, newbies on the other hand might wonder why the project keeps crashing when they set the direction to LEFT as you would in the set mouve route commands e.g.

Thanks for the tip, I added a section in the instructions which explains the directions. It should help solve any error's people are having.

QUOTE
(Your Demo managed to scare me a second and got me to laugh once as well, by the way XD)

It scared me the first time the zoom function worked too happy.gif


lol the Zoom makes the NPC/creature events much more 'living' if you get me. Awesome!


__________________________
Create, Share and Play your own Zelda 2D games with the Updated Project Zelda Engine!
The official website here: zeldaengine.net
Download it here: www.rpgrevolution.com
Download it here: www.rmrk.net
Download it here: www.rmxpunlimited.net
Download it here: www.creationasylum.net
Download it here: www.zfgc.com
Go to the top of the page
 
+Quote Post
   
yamina-chan
post Nov 19 2011, 09:33 AM
Post #5


Level 8
Group Icon

Group: Revolutionary
Posts: 128
Type: None
RM Skill: Skilled




So, I've done more testing and I think I found a bug.
When using the EVENT.damage(VALUE,CRITICAL) command, you can not get green text. If I try, I hear the error sound and the project crashes before a error message show's up.
I did try diffrent ways to set this up just to make sure but the result is the same.


__________________________
There is a game out there for everyone. All you have to do is to find it.
Go to the top of the page
 
+Quote Post
   
Tsukihime
post Nov 19 2011, 02:44 PM
Post #6


Level 25
Group Icon

Group: Revolutionary
Posts: 560
Type: None
RM Skill: Undisclosed
Rev Points: 25




QUOTE (yamina-chan @ Nov 19 2011, 10:33 AM) *
So, I've done more testing and I think I found a bug.
When using the EVENT.damage(VALUE,CRITICAL) command, you can not get green text. If I try, I hear the error sound and the project crashes before a error message show's up.
I did try diffrent ways to set this up just to make sure but the result is the same.


I can get green numbers (healing), but ya the "critical" text is still white (though I think he didn't do anything about it)

CODE
EVENT.damage(100) #white
EVENT.damage(-200) #green
EVENT.damage(-200, true) #green, with white "critical
EVENT.damage(100, True) #crashes, True is not recognized, as expected


I looked at the code and it's pretty simple to write as well.
I THINK it might even be more efficient as well, since every separate command probably goes through the interpreter one at a time and then gets passed all over the place before it actually gets to where it wants.

This post has been edited by Tsukihime: Nov 19 2011, 02:47 PM


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 12:20 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker