Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Hue Variator??

Is there any way I can get a constant Hue change in effect with one of my characters? I tried it with the slider, it looks like hes glowing its cool.

Thanks
 
Go into Game_Character, insert below class Game_Character.
Code:
  attr_accessor :character_hue            # character hue

Now to change like the players hue, use:
Code:
$game_player.character_hue += 1
$game_player.character_hue %= 360

To change an events hue, use:
Code:
$game_map.events[event_id].character_hue += 1
$game_map.events[event_id].character_hue %= 360


And I am such a nice guy, you can use this. Insert above Main.
Code:
class Game_Character
  alias_method :seph_charactercyclehue_gmchr_up, :update
  def cycle_hue_forward
    @cycle_hue_forward = true
    @cycle_hue_backward = false
  end
  def cycle_hue_backward
    @cycle_hue_backward = true
    @cycle_hue_forward = false
  end
  def stop_cycle_hue(finish_hue = nil)
    @cycle_hue_stop = true
    @cycle_finish_hue = finish_hue
  end
  def update
    if @cycle_hue_stop && (@cycle_finish_hue == nil || @cycle_finish_hue == @character_hue)
      @cycle_hue_forward = false
      @cycle_hue_backward = false
      @cycle_hue_stop = false
      @cycle_finish_hue = nil
    end
    if @cycle_hue_forward
      @character_hue += 1
      @character_hue %= 360
    elsif @cycle_hue_backward
      @character_hue -= 1
      @character_hue = 360 if @character_hue == 0
    end
    seph_charactercyclehue_gmchr_up
  end
end


Now you can just use:
Code:
# Cycle Player Hue Forward
$game_player.cycle_hue_forward
# Cycle Player Hue Backward
$game_player.cycle_hue_
# Cycle Event Hue Forward
$game_map.events[event_id].cycle_hue_forward
# Cycle Event Hue Backward
$game_map.events[event_id].cycle_hue_backward

# Stop Player Cycler
$game_player.stop_cycle_hue(finish)
# Stop Event
$game_map.events[event_id].stop_cycle_hue(finish)

# When finish is nil, it stops the hue changer wherever it is at
# When finish is a number between 0 and 360, it continues to change hues until it is that hue, then stops.


Mind you, I did this in fast reply, so let me know if any of this doesn't work.
 
Man as soon as I can get the mystic char i want into my party, imma try those.....

that last code for the screen fade worked very nicely tho, sir.

Thanks a lot, I will update as soon as I try them out.
 
I couldn't get it to work........no surprise.....

I put the first line, as told, at the bottom of the class Game_Char list - public instance variables , neatly with the rest of them.....

then didnt know where to put either of the next two lines, so i tried them separately in folders, above main, above the bottom 2 scripts u posted.....

the 2 bottom scripts were in separate folders, stacked, 2 slots up above main.....


ur a scripting genius man, no doubt.......but your instructions are atmatic for a n00b to follow.....=P
 
The lines to change the hue by a fixed amount...
Code:
$game_player.character_hue += 1
$game_player.character_hue %= 360
goes in an event, using the 'script' event command.
(I tested this & it works fine)

The 3rd box works the same, except you can change the hue of an event instead of a player.

The big box, gets pasted above 'main' in the script editor.

Then, any of the commands in the 5th box can be used in an event, with the 'script' command.

This also works, it cycles the sprites hue.
however, it freezes the character from moving.

Be Well
 
Ahhh crap....
I have a cute little cat that if you give Ale to turns into a Demon Cat, and i wanted it to glow while I was walking around......

thanks a lot for the help u guysm seriously. i know i can be pain in the junk. XD
 
@Brewmeister: Yep. I rarely open RMXP for simple request like this. Its sad I have 99% of the default scripts memorized, more than my own.

And I added a speed variance in it.

Code:
class Game_Character
  alias_method :seph_charactercyclehue_gmchr_up, :update
  def cycle_hue_forward(speed = 5)
    @cycle_hue_forward = true
    @cycle_hue_backward = false
    @cycle_hue_speed = speed
  end
  def cycle_hue_backward(speed = 5)
    @cycle_hue_backward = true
    @cycle_hue_forward = false
    @cycle_hue_speed = speed
  end
  def stop_cycle_hue(finish_hue = nil)
    @cycle_hue_stop = true
    @cycle_finish_hue = finish_hue
  end
  def update
    update_cycle_hue
    seph_charactercyclehue_gmchr_up
  end
  def update_cycle_hue
    back = @cycle_hue_backward
    forw = @cycle_hue_forward
    stop = @cycle_hue_stop
    spd  = @cycle_hue_speed
    fnsh = @cycle_finish_hue
    if stop && (fnsh == nil || 
       (back && @character_hue.between?(fnsh, fnsh + spd)) ||
       (forw && @character_hue.between?(fhsn, fnsh - spd)))
      if fnsh != nil
        @character_hue = fnsh
      end
      @cycle_hue_backward = false
      @cycle_hue_forward = false
      @cycle_hue_stop = false
      @cycle_finish_hue = nil
    end
    if @cycle_hue_forward
      @character_hue += @cycle_hue_speed
      @character_hue %= 360
    elsif @cycle_hue_backward
      @cycle_hue_speed += 360 - @cycle_hue_speed
      @cycle_hue_speed %= 360
    end
  end
end

Works the same way, you just send speed when you start it.
 
Seph, you never cease to amaze! (or amuse! :) )

2 small boo-boo's:
line 29: fhsn -> fnsh
line 29 ( fnsh, fnsh - spd) -> (fnsh - spd, fnsh )

I fix:

Code:
class Game_Character
  alias_method :seph_charactercyclehue_gmchr_up, :update
  def cycle_hue_forward(speed = 5)
    @cycle_hue_forward = true
    @cycle_hue_backward = false
    @cycle_hue_speed = speed
  end
  def cycle_hue_backward(speed = 5)
    @cycle_hue_backward = true
    @cycle_hue_forward = false
    @cycle_hue_speed = speed
  end
  def stop_cycle_hue(finish_hue = nil)
    @cycle_hue_stop = true
    @cycle_finish_hue = finish_hue
  end
  def update
    update_cycle_hue
    seph_charactercyclehue_gmchr_up
  end
  def update_cycle_hue
    back = @cycle_hue_backward
    forw = @cycle_hue_forward
    stop = @cycle_hue_stop
    spd  = @cycle_hue_speed
    fnsh = @cycle_finish_hue
    if stop && 
      (fnsh == nil || (back && @character_hue.between?(fnsh, fnsh + spd)) ||
      (forw && @character_hue.between?(fnsh - spd, fnsh )))
      if fnsh != nil
        @character_hue = fnsh
      end
      @cycle_hue_backward = false
      @cycle_hue_forward = false
      @cycle_hue_stop = false
      @cycle_finish_hue = nil
    end
    if @cycle_hue_forward
      @character_hue += @cycle_hue_speed
      @character_hue %= 360
    elsif @cycle_hue_backward
      @cycle_hue_speed += 360 - @cycle_hue_speed
      @cycle_hue_speed %= 360
    end
  end
end

Bunk,

In your event 'script' command:

$game_player.stop_cycle_hue() # stops color immediately
$game_player.stop_cycle_hue(0) # stops at original color
$game_player.stop_cycle_hue(180) # stops at blue

$game_player.cycle_hue_forward(1) # slow
$game_player.cycle_hue_forward(5) # default
$game_player.cycle_hue_forward # also defult (5)
$game_player.cycle_hue_forward(30) #fast
$game_player.cycle_hue_forward(180) #too fast. Cycle between original color & blue
$game_player.cycle_hue_forward(359) #slow backwards


Possible enhancement: Stop & return to the previous setting, in case the sprite
was initiated at something other than 0.
I gotta go help someone move, I'll try to add this when I get back.

Be Well
 
Im really.sorry to bump an extremely old topic, but i am intrested in this script and also having problems getting it to work. Ive read the topic serveral time, but i really dont get what exactly needed to be put in t e events "scripts" section in order for my character to loop through different color hues. Thanks
 
There are only 2 commands (with arguments).

$game_player.cycle_hue_forward()  # start hue change

$game_player.stop_cycle_hue() # stop hue change

The argument you put in the parantheses sets how fast the hue cycles.
The value for .hue has a range of 1 - 360. If you set the speed to 30,
the hue will cycle through 30,60,90,120,150,180,210,240,270,300,330,360.
Set it to 180, and it will flash between 180 (blue), and 360 (original color)

The argument for 'stop' determines which color it stops at. No argument ()
will stop at whatever value it's currently at (random).  An argument of (0)
will return the character to his original color.

So, if you want a slow hue variation, use

$game_player.cycle_hue_forward(1)

Then, to stop at the original color,

$game_player.stop_cycle_hue(0)

Be Well
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top