Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Rei Recolor, change event or player's sprite color easily!
reijubv
post May 11 2009, 02:07 AM
Post #1


It's been awhile lol
Group Icon

Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced




Rei Actor's Recolor
v.2.0 (May 24th 2009)
by reijubv

I change the script's name, cuz now it's not just a hue changer...

Well, another small script that I made, this script will enable you to change event or player's sprite color easily!
I think someone already made this kind of script, but this one is different!

Just download the demo and you'll see...

Demo :

http://www.mediafire.com/download.php?mmrntzzkm0z 506.9 Kb

See the screenshot too :
[Show/Hide] Screenshot


Download script here :

[Show/Hide] Script here

CODE
#===============================================================================
# † [VX] † Rei Recolor † †
# † With this, you can easily recolor your actor's/event's sprite †
#-------------------------------------------------------------------------------
# † by reijubv [aruyasoft@comic.com]
# † RPG RPG Revolution
# † Released on: 27/04/2009
# † Version: 2.0b (June 12th 2009)
#-------------------------------------------------------------------------------
# > Changelog:
#   V.1.0 (10-05-09) = Initial release
#   V.2.0 (24-05-09) = >Rewrote most of the script, making it better
#                      >Now it is possible to change sprite's red , green, blue, alpha channels
#                      >Changed the script's name to Rei Recolor
#   V.2.0b(12-06-09) = > Added a global variable used for compatibility
#-------------------------------------------------------------------------------
# Credits:
# reijubv for making this script.
#-------------------------------------------------------------------------------
# ? Installation:
# Put this script above main
#-------------------------------------------------------------------------------
# Compatibility :
#                * Rewrites :
#                             class Cache def character
#                             class Sprite_Character def update_bitmap
#                * Aliases :
#                             class Sprite_Character def update
#===============================================================================


#===============================================================================
# ** HOW TO USE (for player) **
#-------------------------------------------------------------------------------
# To change hue :
# Anytime, call script : Rei::Recolor::HUE = number
# Example : Rei::Recolor::HUE = 75
#           This will change player sprite's hue to number
#           number must be between 0-360!
# To change color :
# Anytime, call script : Rei::Recolor::CHANNEL = [red,green,blue,alpha]
# Change red,green,blue,alpha to any integer between -255 to 255
# Remember to set all of those back to 0 if you want to restore player's color to normal!
#===============================================================================
# ** HOW TO USE (for events) **
#-------------------------------------------------------------------------------
# Insert event command 'Comment...' in an event, put following tag to change
# it's color:
# To change hue :
# [rc(number)] : Change event's hue to that number
# Example : [rc15] will change event's hue to 15.
# To change color :
# Rei_recolor red, green, blue, alpha
# Change red,green,blue,alpha to any integer between -255 to 255
# Example : Rei_recolor 15, 0, 26, 0
# That will change event's red channel to 15, green to 0 (normal), blue to 26, and alpha to 0 (normal)
#-------------------------------------------------------------------------------
# Do not touch below!
#===============================================================================
$imported = {} if $imported == nil
$imported["Rei_"+"Recolor"] = true
#---------------------------------------------------------------------------
# ** Rei Module
#---------------------------------------------------------------------------
module Rei
  module Recolor
    HUE = 0 # Initial player's hue value
    HUEVAR = 1 # If you prefer to use variable to change player's hue, set Id here.
               # Use 0 if you don't want to use variable.
    CHANNEL = [0,0,0,0] # Player's initial RGBA channel
  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
  attr_accessor :eventhue
  attr_accessor :eventchannel
  alias reirecinit initialize unless method_defined?('reirecinit')
  def initialize(map_id, event)
    @eventhue = 0
    @eventchannel = [0,0,0,0]
    gethue
    reirecinit(map_id, event)
  end
  #-----------------------------------------------------------------------------
  #  gethue
  #  Get hue value of an event
  #-----------------------------------------------------------------------------
  def gethue
    if !@list.nil?
      for i in 0...@list.size - 1
        next if @list[i].code != 108
        if @list[i].parameters[0].include?("[rc")
          list = @list[i].parameters[0].scan(/\[rc([0-9]+)\]/)
          @eventhue = $1.to_i
        end
      end
      return @eventhue
    end
  end
  # from V2.0
  alias reialphasetup setup unless method_defined?('reialphasetup')
  def setup(*args)
    reialphasetup(*args)
    colors = has_comment2?('Rei_recolor', true)
    if !colors[0]
      @eventchannel = [0,0,0,0]
    else
      @eventchannel = @list[colors[1]].parameters[0].clone
      @eventchannel.sub!('Rei_recolor','').gsub!(/\s+/){''}
      @eventchannel = @eventchannel.split(',')
      @eventchannel.each_index {|i| @eventchannel[i] = @eventchannel[i].to_i }
      for i in 0..3
        if @eventchannel[i] > 255
            @eventchannel[i] = 255
        elsif @eventchannel[i] < -255
            @eventchannel[i] = -255
        end
      end
    end
  end
  
  def has_comment2?(comment, return_index = false )
    if !@list.nil?
      for i in 0...@list.size - 1
        next if @list[i].code != 108
        if @list[i].parameters[0].include?(comment)
          return [true, i] if return_index
          return true
        end
      end
    end
    return [false, nil] if return_index
    return false
  end
  
end
#===============================================================================
# ** Cache
#-------------------------------------------------------------------------------
#  This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#===============================================================================
module Cache
  #-----------------------------------------------------------------------------
  # * Get Character Graphic
  #     filename : Filename
  #     hue      : hue of the picture
  #-----------------------------------------------------------------------------
  def self.character(filename, hue=0)
    load_bitmap("Graphics/Characters/", filename, hue)
  end
end
#===============================================================================
# ** Sprite_Character rewrite : def update_bitmap alias : def update
#===============================================================================
class Sprite_Character
  def update_bitmap
    if @character.is_a?(Game_Event)
      self.tone.set(@character.eventchannel[0],@character.eventchannel[1],@character.eventchannel[2],@character.eventchannel[3])
    elsif @character.is_a?(Game_Player)
      self.tone.set(Rei::Recolor::CHANNEL[0],Rei::Recolor::CHANNEL[1],Rei::Recolor::CHANNEL[2],Rei::Recolor::CHANNEL[3])
    end
    if @tile_id != @character.tile_id or
      @character_name != @character.character_name or @character_index != @character.character_index
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_index = @character.character_index
      if @tile_id > 0
        sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
        sy = @tile_id % 256 / 8 % 16 * 32;
        self.bitmap = tileset_bitmap(@tile_id)
        self.src_rect.set(sx, sy, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        @hue = 0
        if @character.is_a?(Game_Player)
          if Rei::Recolor::HUEVAR == 0 and @hue != Rei::Recolor::HUE
            @hue = Rei::Recolor::HUE
          elsif Rei::Recolor::HUEVAR > 0 and @hue != $game_variables[Rei::Recolor::HUEVAR]
            @hue = $game_variables[Rei::Recolor::HUEVAR]
          end
        elsif @character.is_a?(Game_Event) and @character.has_comment2?("[rc")
          if @hue != @character.gethue
            @hue = @character.gethue
          end
        end
        self.bitmap = Cache.character(@character_name,@hue)
        sign = @character_name[/^[\!\$]./]
        if sign != nil and sign.include?('$')
          @cw = self.bitmap.width / 3
          @ch = self.bitmap.height / 4
        else
          @cw = self.bitmap.width / 12
          @ch = self.bitmap.height / 8
        end
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
  end
  alias reiupdateplayerhue update unless method_defined?('reiupdateplayerhue')
  def update
    reiupdateplayerhue
    @hue = 0
    if @character.is_a?(Game_Player) and Rei::Recolor::HUEVAR == 0
      if @hue != Rei::Recolor::HUE
        @hue = Rei::Recolor::HUE
        self.bitmap = Cache.character(@character.character_name, @hue)
      end
    elsif @character.is_a?(Game_Player) and Rei::Recolor::HUEVAR > 0
      if @hue != $game_variables[Rei::Recolor::HUEVAR]
        @hue = $game_variables[Rei::Recolor::HUEVAR]
        self.bitmap = Cache.character(@character.character_name, @hue)
      end
    end
  end
end
#===============================================================================
# ** END OF SCRIPT **
#===============================================================================



To use the script :

CODE
** HOW TO USE (for player) **
  To change hue :
  Anytime, call script : Rei::Recolor::HUE = number
  Example : Rei::Recolor::HUE = 75
            This will change player sprite's hue to number
            number must be between 0-360!
  To change color :
  Anytime, call script : Rei::Recolor::CHANNEL = [red,green,blue,alpha]
  Change red,green,blue,alpha to any integer between -255 to 255
  Remember to set all of those back to 0 if you want to restore player's color to normal!
===============================================================================
  ** HOW TO USE (for events) **
  Insert event command 'Comment...' in an event, put following tag to change
  it's color:
  To change hue :
  [rc(number)] : Change event's hue to that number
  Example : [rc15] will change event's hue to 15.
  To change color :
  Rei_recolor red, green, blue, alpha
  Change red,green,blue,alpha to any integer between -255 to 255
  Example : Rei_recolor 15, 0, 26, 0
  That will change event's red channel to 15, green to 0 (normal), blue to 26, and alpha to 0 (normal)


Example of usage :

to change color set :

to change hue :


Installation :
Put this script above main

Credits :
reijubv for making this script.

This post has been edited by reijubv: Jun 12 2009, 10:20 PM


__________________________
I'll be back again :P
Go to the top of the page
 
+Quote Post
   
TheFierceDeity
post May 11 2009, 11:44 AM
Post #2


Level 12
Group Icon

Group: Revolutionary
Posts: 215
Type: Developer
RM Skill: Intermediate




QUOTE (reijubv @ May 11 2009, 02:07 AM) *
Rei Actor's Hue Changer
v.1.0 (May 10th 2009)
by reijubv

Well, another small script that I made, this script will enable you to change event or player's sprite color easily!
I think someone already made this kind of script, but this one is different!

Just download the demo and you'll see...

Demo :

http://www.mediafire.com/download.php?0iqy1oyn30n 398 Kb

See the screenshot too :
[Show/Hide] Screenshot


Download script here :

[Show/Hide] Script here

CODE
#===============================================================================
# �€� [VX] �€� Rei Actor's Hue Changer �€� �€�
# �€� With this, you can easily recolor your actor's/event's sprite �€�
#-------------------------------------------------------------------------------
# �€� by reijubv [aruyasoft@comic.com]
# �€� RPG RPG Revolution
# �€� Released on: 27/04/2009
# �€� Version: 1.0 (May 10th 2009)
#-------------------------------------------------------------------------------
# Credits:
# reijubv for making this script.
#-------------------------------------------------------------------------------
# ? Installation:
# Put this script above main
#-------------------------------------------------------------------------------
# Compatibility :
#                * Rewrites :
#                             class Cache def character
#===============================================================================
#===============================================================================
# ** HOW TO USE (for player) **
#-------------------------------------------------------------------------------
# Anytime, call script : Rei::Recolor::HUE = number
# Example : Rei::Recolor::HUE = 75
#           This will change player sprite's hue to number
#           number must be between 0-255!
# Remember to set this back to 0 if you want to restore player's color to normal!
#===============================================================================
# ** HOW TO USE (for events) **
#-------------------------------------------------------------------------------
# Insert event command 'Comment...' in an event, put following tag to change
# it's color:
#
# [rc(number)] : Change event's hue to that number
# Example : [rc15] will change event's hue to 15.
# Simple, yes?
#-------------------------------------------------------------------------------
# Do not touch below!
#===============================================================================
#---------------------------------------------------------------------------
# ** Rei Module
#---------------------------------------------------------------------------
module Rei
   module Recolor
     HUE = 0 # Initial player hue value
   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
   attr_accessor :eventhue
   alias reiinit initialize
   def initialize(map_id, event)
     @eventhue = 0
     gethue
     reiinit(map_id, event)
   end
   #-----------------------------------------------------------------------------
   #  gethue
   #  Get hue value of an event
   #-----------------------------------------------------------------------------
   def gethue
     if !@list.nil?
       for i in 0...@list.size - 1
         next if @list[i].code != 108
         if @list[i].parameters[0].include?("[rc")
           list = @list[i].parameters[0].scan(/\[rc([0-9]+)\]/)
           @eventhue = $1.to_i
         end
       end
       return @eventhue
     end
   end
end
#===============================================================================
# ** Cache
#-------------------------------------------------------------------------------
#  This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#===============================================================================
module Cache
   #-----------------------------------------------------------------------------
   # * Get Character Graphic
   #     filename : Filename
   #     hue      : hue of the picture
   #-----------------------------------------------------------------------------
   def self.character(filename, hue=0)
     load_bitmap("Graphics/Characters/", filename, hue)
   end
end
#===============================================================================
# ** Sprite_Character
#===============================================================================
class Sprite_Character
   alias reiupdate update
   def update
     reiupdate
     if @character.is_a?(Game_Player)
       self.bitmap = Cache.character(@character.character_name, Rei::Recolor::HUE)
     elsif @character.is_a?(Game_Event)
       self.bitmap = Cache.character(@character.character_name, @character.gethue)
     end
   end
end
#===============================================================================
# ** END OF SCRIPT **
#===============================================================================



To use the script :

CODE
** HOW TO USE (for player) **
  Anytime, call script : Rei::Recolor::HUE = number
  Example : Rei::Recolor::HUE = 75
                This will change player sprite's hue to number
                number must be between 0-255!
  Remember to set this back to 0 if you want to restore player's color to normal!
===============================================================================
** HOW TO USE (for events) **
  Insert event command 'Comment...' in an event, put following tag to change
  it's color:

  [rc(number)] : Change event's hue to that number
  Example : [rc15] will change event's hue to 15.
  Simple, yes?


Installation :
Put this script above main

Credits :
reijubv for making this script.



Nice will be using this in upcoming game keep up the good work


__________________________
Games I support
http://i537.photobucket.com/albums/ff333/T...00/Support2.png

RRR's Zelda Expert "Warning if you ask me to play your game, I WILL critique it."
Go to the top of the page
 
+Quote Post
   
GuyInTraining
post May 12 2009, 02:29 AM
Post #3


Aiming for 999999 graze points on UFO
Group Icon

Group: Revolutionary
Posts: 244
Type: Artist
RM Skill: Intermediate




Tell you what? This'll be very, very useful for people who are using Crissaegrim's ABS.
...and I've been looking for this for so long!

Thanks reijubv!


__________________________

Forever!

Signature
Userbars


Play with Tokari!


Charming Miscellany




Go to the top of the page
 
+Quote Post
   
reijubv
post May 13 2009, 12:25 AM
Post #4


It's been awhile lol
Group Icon

Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced




Well thanks, happy.gif
Hope this simple script can be useful to anyone!


__________________________
I'll be back again :P
Go to the top of the page
 
+Quote Post
   
Zammoron
post May 16 2009, 04:33 AM
Post #5


Level 1
Group Icon

Group: Member
Posts: 8
Type: None
RM Skill: Skilled




Yo yo!

I've been trying to try out this excellent script and now I am encountering a weird error:

Script 'Cache' line 89 error: TypeError occurred.

no implicit conversion from nil to interger




Line 89 in Chache looks like this (I have not altered it, checked it against your Demo):

@cache[key].hue_change(hue)



Now, I've done some tinkering, and this only occurs for one of my maps. I've manually added every script I have to a new project and then run it with your HUE script and I get no errors. It's only when I test-play one of my maps that I get this error. In this map I have found that the error occurs because of 4 events that run after one another, controlling and triggering lots of variables and influencing which graphic events shall have and so on. If you want, I could try to send you a project with that map to show you. When I removed the 4 events I get no error.

Hopefully you will look at this and go "Lol, noob, you need to do like this..." wink.gif

Otherwise, just message me and I will send you a project containing the map.

Thanks!
-Max
(edit: Spelling)

This post has been edited by Zammoron: May 16 2009, 05:50 AM
Go to the top of the page
 
+Quote Post
   
reijubv
post May 24 2009, 01:50 AM
Post #6


It's been awhile lol
Group Icon

Group: Revolutionary
Posts: 168
Type: Artist
RM Skill: Advanced




I've update the script to V.2.0
The demo also updated!

I hope it will fix some problems done by the script...


__________________________
I'll be back again :P
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 03:35 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker