XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
448
Reaction score
17
First Language
French
Primarily Uses
Hi, this one can be tricky. In my game I can freeze almost everything.
I want to avoid create a double of every character event, etc... freezed.
So I look a way by script to just change color of event for be in a blue palette for look freezed.
Of course even better will be to put them in a ice cube but can look hard.

I want your suggestion for achive this thanks.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
596
First Language
English
Primarily Uses
RMMV
I came up with a quick and easy plugin. I'm not even sure if this plugin is needed.
PHP:
Sprite_Character.prototype.setCharacterBitmapCached = Sprite_Character.prototype.setCharacterBitmap;
Sprite_Character.prototype.setCharacterBitmap = function() {
   this.setCharacterBitmapCached.call(this, arguments);
   this._character.bitmap = this.bitmap;
};
I just don't know how to access the bitmaps. But sure enough, it's just an object which doesn't copy, but rather alias. Now you can rotateHue from event script.
PHP:
$gameMap._events[this._eventId].bitmap.rotateHue(20); // 20 is just an example

I put that script and a delay in a parallel process to show that it does in fact work.
rotatehue.gif


I guess to freeze color everything...
PHP:
for(var i = 0; i < $gameMap._events.length; i++){
  $gameMap._events[i].bitmap.rotateHue(20); // 20 is just an example
}
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,127
Reaction score
14,643
First Language
English
Primarily Uses
RMMV
What happens there if you have a second event using the same sprite, and you don't do a hue change on it? Does it also change because it's using the same sprite?
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
596
First Language
English
Primarily Uses
RMMV
Yeah. This happens.
rotatehue_1.gif

I should probably warn about having your nonfrozen characters on a second character set png.

I actually have a modified rotateHue function I made for another script that caches the original bitmap before rotating if you need it.

Now that you mention this conundrum, I realize calling rotate hue on two same char set characters will rotate the hue multiple secondary times too.

EDIT:
Maybe something like this will help by event script...
PHP:
for(var i = 0; i < $gameMap._events.length; i++){
  var bitmap = $gameMap._events[i].bitmap;
  if(bitmap._isBlue === undefined || !bitmap._isBlue) {
    bitmap._isBlue = true;
    bitmap.rotateHue(20); // 20 is just an example
  }
}

Then to undo.
PHP:
for(var i = 0; i < $gameMap._events.length; i++){
  var bitmap = $gameMap._events[i].bitmap;
  if(bitmap._isBlue !== undefined && bitmap._isBlue) {
    bitmap._isBlue = false;
    bitmap.rotateHue(-20); // -20 is just an example
  }
}

__________________________________________________________________________________​

EDIT2: I played around with it and I discovered a simple solution way to change hue and have it as a actual separate cached sprite through character name.

This is a totally different plugin so if you prefer this way, ignore the previous plugin.
PHP:
Sprite_Character.prototype.setCharacterBitmap = function() {
   var hue = 0;
   if(this._characterName.match(/:\d+$/) !== null) {
       var data = this._characterName.split(":");
       this._characterName = data[0];
       hue = parseInt(data[1].replace(/\D+/g,""));
   }
   this.bitmap = ImageManager.loadCharacter(this._characterName, hue);
   this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
};

Then just change the character name in event script like so...
PHP:
$gameMap._events[this._eventId]._characterName += ":180";

Name change triggers an update and the new name gets reverted back to old, but the update triggers a hue change. The :180 is the new hue and it can be anything from 0 - 360.

This way only changes the character sprite and not the whole sprite sheet.
Screen Shot 2017-02-24 at 3.08.00 AM.png

To do all events at once...
PHP:
for(var i = 0; i < $gameMap._events.length; i++){
  $gameMap._events[i]._characterName += ":180";
}
 
Last edited:

mega01man

Villager
Member
Joined
Jan 29, 2017
Messages
14
Reaction score
3
First Language
Tagalog
Primarily Uses
RMMV
this is interesting @mogwai and thank you for asking it @XGuarden. I do have a question, I've seen people using meta data/note tags. Will that also work for the same characters but the other have a note tag that says ex. "freeze" instead of searching for the character name?
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
596
First Language
English
Primarily Uses
RMMV
@mega01man

To do that in correlation with one of these other two rotateHue plugins, this plugin should work with one or the other.

This should apply a hue method for either plugin you are using in any event with the comment <hue:123> where 123 is any number between 0 and 360. You just have to alter the part in comments.
PHP:
// I call it cached2 so it runs after cached(1) in case you are using my first plugin
Sprite_Character.prototype.setCharacterBitmapCached2 = Sprite_Character.prototype.setCharacterBitmap;
Sprite_Character.prototype.setCharacterBitmap = function(){
   this.setCharacterBitmapCached2.call(this,arguments);
   if(this._character._pageIndex === undefined)
       return;
   var current_page = this._character._pageIndex;
   var event = $dataMap.events[this._character._eventId];
   var page = event.pages[current_page];
   var comments = "";
   for(var i = 0; i < page.list.length; i++) {
       if(page.list[i] === null)
           continue;
       var command = page.list[i];
       if(command.code === 108 || command.code === 408) {
           var param = command.parameters;
           for(var j = 0; j < param.length; j++)
               comments += param[j];
       }
   }
   var meta = /<hue\:\d+>/i;
   if(comments.match(meta) !== null){
       var hue = parseInt(comments.match(meta)[0].replace(/\D+/g,""));
     
       // and then depending on which hue plugin you use,
       // remove comment and delete the other
       /*
       if(this._character.bitmap._isLoading) {
           var _this = this;
           this._character.bitmap.addLoadListener(function(){
               _this._character.bitmap.rotateHue(hue);
           });
        } else {
           this._character.bitmap.rotateHue(hue);
       }
       */
       // do this ^ for plugin 1

       /*
       this._character._characterName += ":" + hue;
       */
       // or do this ^ for plugin 2
   }
}
 

mega01man

Villager
Member
Joined
Jan 29, 2017
Messages
14
Reaction score
3
First Language
Tagalog
Primarily Uses
RMMV
oh my lol XP it slipped my mind of course it would work! lol XP

PHP:
...
   var meta = /<hue\:\d+>/i;
   if(comments.match(meta) !== null){
...

Because of that! Thank you very much for being cool! :kaosalute:
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
596
First Language
English
Primarily Uses
RMMV
There's a default meta property in the $dataMap.events array, but I can't get it to work. I don't know why, so I just wrote my own.

I actually already had this thing wrote for another plugin that took comments like <meta a:123 b:123 c:123>

Also, by "alter the part in comments" I mean edit the orange script comments part. I realize it sounds confusing when we are talking about meta comments.
 

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
448
Reaction score
17
First Language
French
Primarily Uses
What happens there if you have a second event using the same sprite, and you don't do a hue change on it? Does it also change because it's using the same sprite?
No, the player trow ice ball on objet and objet then freeze. SO if any other have same sprite it will not be afected.


Code:
Sprite_Character.prototype.setCharacterBitmap = function() {
   var hue = 0;
   if(this._characterName.match(/:\d+$/) !== null) {
       var data = this._characterName.split(":");
       this._characterName = data[0];
       hue = parseInt(data[1].replace(/\D+/g,""));
   }
   this.bitmap = ImageManager.loadCharacter(this._characterName, hue);
   this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
};

Didt get it... I put that in pluggin and activate it. I call in event the other code but event only disapear. Also, using that name of the objet is not a possibility for me as its used for another plugging lol.


Any idea^


EDIT: I put it all in same script call and work. But its seem to be a lot to much code for what is require.

But I try to put just this.bitmap = ImageManager.loadCharacter(this._characterName, 180); and that didt work.... why
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Alisa: Prophecy of the Falling Stars. Join Alisa, a quiet girl with a heart filled with love and hope, on her journey to prevent a calamity. My next RPG Maker music pack is my largest and most focused pack yet. It's a musical story that focuses on a young heroine named Alisa who has been assigned the ultimate task to prevent a calamity.

SnJj_O.png
Alien Worlds, Minecraft Blocks, Extend Options, Fine Speed Control, Art by Muggu | RPG Maker News #33

Rest in Peace vlog gun...
vloggunsmallface.png
Another unnamed character, and probably last one for now.
She's a dragon girl inspired by fafnir dragon. as always, name suggestion is welcomed.
Dragon_Girl.jpg

Dragon_Girl_1.png

Forum statistics

Threads
111,164
Messages
1,058,883
Members
144,408
Latest member
Bretzel68440
Top