Is it doing it to any other variables, or only to variable 30? Sometimes plugins store values to variables (A couple of plugins I was using on VX Ace did, anyway. A particular plugin used 30 and 31 to store the X and Y dimensions for a particular message box, for example).
Terrax Lighting system
JS Plugin Releases (RMMV)Is it doing it to any other variables, or only to variable 30? Sometimes plugins store values to variables (A couple of plugins I was using on VX Ace did, anyway. A particular plugin used 30 and 31 to store the X and Y dimensions for a particular message box, for example).
It did alter another one but i can't remember which one it was now and not with the same frequency as it did with 30.
OK so small issue: Having anything written in the Note box for a map besides DayNight prevents the DayNight cycle from occurring on that map, even if DayNight is still in the box. This is a bit problematic and could do with being fixed, but I can replicate the other functions of the Note box in other ways, so it's not desperate.
I checked over the plugin file, and I'm pretty sure it's something to do with "if (command === daynight')". Does anyone know how to change it to checking for containing 'daynight' instead of being exactly 'daynight'?
I checked over the plugin file, and I'm pretty sure it's something to do with "if (command === daynight')". Does anyone know how to change it to checking for containing 'daynight' instead of being exactly 'daynight'?
*facepalms* Oh. I thought the plugin was updated or something.
In this instance, you'd use some sort of "contains" command, like so:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes
Amazing plugin!
New version (1.2.7) now available
http://mvplugins.com/plugin/Terrax/Terrax%20Lighting%20System
Bug fix : Mapnotes are now searched for 'daynight', so it works with other notes.
Fixed this update.
I included a small boat in the demo with an example script, maybe this will help you on your way.
http://mvplugins.com/plugin/Terrax/Terrax%20Lighting%20System
Bug fix : Mapnotes are now searched for 'daynight', so it works with other notes.
Fixed this update.
I included a small boat in the demo with an example script, maybe this will help you on your way.
Works wonderful except for a slight problem, when entering the vehicle the flash light apears for the person in the direction he'd be facing, rather than the ship incorporating the light after entry, so if i enter the boat ( car in my case ) the car lights come from the person in the direction he enters rather than the car would be.
You can solve this by adding a 'Set movement Route' to the script at the 3rd line
If : Ship is driven
If : Self Switch A is OFF
Set Movement Route : Player (Wait)
: Turn Down -> Set this in the direction your vehicle is pointing
Plugin Command : flashlight on
Plugin Command : light radius 10
end
etc.
What about this implementation?
//OVERWRITE
Game_Player.prototype.executeEncounter = function() {
if (!$gameMap.isEventRunning() && this._encounterCount <= 0) {
this.makeEncounterCount();
var troopId = this.makeEncounterTroopId();
if ($dataTroops[troopId]) {
//NEW
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') { //NEW
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
} else {
$gameTemp._Tint = '#FFFFFF';
}
//NEW
BattleManager.setup(troopId, true, false);
BattleManager.onEncounter();
return true;
} else {
return false;
}
} else {
return false;
}
};
//OVERWRITE
Game_Interpreter.prototype.command301 = function() {
if (!$gameParty.inBattle()) {
var troopId;
if (this._params[0] === 0) {
troopId = this._params[1];
} else if (this._params[0] === 1) {
troopId = $gameVariables.value(this._params[1]);
} else {
troopId = $gamePlayer.makeEncounterTroopId();
}
if ($dataTroops[troopId]) {
//NEW
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') { //NEW
console.log($gameVariables.valueDayNightColor());
console.log($gameVariables.valueDayNightSave());
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
} else {
$gameTemp._Tint = '#FFFFFF';
}
//NEW
BattleManager.setup(troopId, this._params[2], this._params[3]);
BattleManager.setEventCallback(function(n) {
this._branch[this._indent] = n;
}.bind(this));
$gamePlayer.makeEncounterCount();
SceneManager.push(Scene_Battle);
}
}
return true;
};
Spriteset_Battle.prototype.createBattleLightmask = function() {
this._lightmask = new BattleLightmask();
this.addChild(this._lightmask);
};
Spriteset_Battle.prototype.createLowerLayer = function() {
Spriteset_Base.prototype.createLowerLayer.call(this);
this.createBackground();
this.createBattleField();
this.createBattleback();
this.createEnemies();
this.createActors();
this.createBattleLightmask();
}
function BattleLightmask() {
this.initialize.apply(this, arguments);
}
BattleLightmask.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
BattleLightmask.prototype.constructor = BattleLightmask;
BattleLightmask.prototype.initialize = function() {
PIXI.DisplayObjectContainer.call(this);
this._width = Graphics.width;
this._height = Graphics.height;
this._sprites = [];
this._createBitmap();
//Initialize the bitmap
this._addSprite(0,0,this._maskBitmap);
if ($gameTemp._Tint === '#000000' || $gameTemp._Tint === '#111111' || $gameTemp._Tint === '#222222'){
$gameTemp._Tint = '#333333' //The player have to see something
}
this._maskBitmap.FillRect(0,0,maxX,maxY,$gameTemp._Tint);
};
BattleLightmask.prototype._createBitmap = function() {
this._maskBitmap = new Bitmap(maxX,maxY);
var canvas = this._maskBitmap.canvas;
};
BattleLightmask.prototype.update = function() {
//do nothing
};
//@method _createBitmaps
/**
* @method _addSprite
* @private
*/
BattleLightmask.prototype._addSprite = function(x1,y1,selectedbitmap) {
var sprite = new Sprite(this.viewport);
sprite.bitmap = selectedbitmap;
sprite.opacity = 255;
sprite.blendMode = 2;
sprite.x = x1;
sprite.y = y1;
this._sprites.push(sprite);
this.addChild(sprite);
sprite.rotation = 0;
sprite.ax = 0
sprite.ay = 0
sprite.opacity = 255;
};
/**
* @method _removeSprite
* @private
*/
BattleLightmask.prototype._removeSprite = function() {
this.removeChild(this._sprites.pop());
};
Game_Player.prototype.executeEncounter = function() {
if (!$gameMap.isEventRunning() && this._encounterCount <= 0) {
this.makeEncounterCount();
var troopId = this.makeEncounterTroopId();
if ($dataTroops[troopId]) {
//NEW
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') { //NEW
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
} else {
$gameTemp._Tint = '#FFFFFF';
}
//NEW
BattleManager.setup(troopId, true, false);
BattleManager.onEncounter();
return true;
} else {
return false;
}
} else {
return false;
}
};
//OVERWRITE
Game_Interpreter.prototype.command301 = function() {
if (!$gameParty.inBattle()) {
var troopId;
if (this._params[0] === 0) {
troopId = this._params[1];
} else if (this._params[0] === 1) {
troopId = $gameVariables.value(this._params[1]);
} else {
troopId = $gamePlayer.makeEncounterTroopId();
}
if ($dataTroops[troopId]) {
//NEW
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') { //NEW
console.log($gameVariables.valueDayNightColor());
console.log($gameVariables.valueDayNightSave());
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
} else {
$gameTemp._Tint = '#FFFFFF';
}
//NEW
BattleManager.setup(troopId, this._params[2], this._params[3]);
BattleManager.setEventCallback(function(n) {
this._branch[this._indent] = n;
}.bind(this));
$gamePlayer.makeEncounterCount();
SceneManager.push(Scene_Battle);
}
}
return true;
};
Spriteset_Battle.prototype.createBattleLightmask = function() {
this._lightmask = new BattleLightmask();
this.addChild(this._lightmask);
};
Spriteset_Battle.prototype.createLowerLayer = function() {
Spriteset_Base.prototype.createLowerLayer.call(this);
this.createBackground();
this.createBattleField();
this.createBattleback();
this.createEnemies();
this.createActors();
this.createBattleLightmask();
}
function BattleLightmask() {
this.initialize.apply(this, arguments);
}
BattleLightmask.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
BattleLightmask.prototype.constructor = BattleLightmask;
BattleLightmask.prototype.initialize = function() {
PIXI.DisplayObjectContainer.call(this);
this._width = Graphics.width;
this._height = Graphics.height;
this._sprites = [];
this._createBitmap();
//Initialize the bitmap
this._addSprite(0,0,this._maskBitmap);
if ($gameTemp._Tint === '#000000' || $gameTemp._Tint === '#111111' || $gameTemp._Tint === '#222222'){
$gameTemp._Tint = '#333333' //The player have to see something
}
this._maskBitmap.FillRect(0,0,maxX,maxY,$gameTemp._Tint);
};
BattleLightmask.prototype._createBitmap = function() {
this._maskBitmap = new Bitmap(maxX,maxY);
var canvas = this._maskBitmap.canvas;
};
BattleLightmask.prototype.update = function() {
//do nothing
};
//@method _createBitmaps
/**
* @method _addSprite
* @private
*/
BattleLightmask.prototype._addSprite = function(x1,y1,selectedbitmap) {
var sprite = new Sprite(this.viewport);
sprite.bitmap = selectedbitmap;
sprite.opacity = 255;
sprite.blendMode = 2;
sprite.x = x1;
sprite.y = y1;
this._sprites.push(sprite);
this.addChild(sprite);
sprite.rotation = 0;
sprite.ax = 0
sprite.ay = 0
sprite.opacity = 255;
};
/**
* @method _removeSprite
* @private
*/
BattleLightmask.prototype._removeSprite = function() {
this.removeChild(this._sprites.pop());
};
It doesn't allow to use the tint system as well (may be a good extension for later, for now I prefer the classic Tint Screen command), but it creates a special lightmask for battle who have the same color as the previous color of the map.
I like what you have done, but the amount of system-scripts your script overwrites scares me. Overwriting such a large amount of scripts often leads to serious compatibility problems with other plugins.
The guy who invented aliasing was not an imbecile.
var TerraxLighting_Addon_BattleManager_setup = BattleManager.setup;
BattleManager.setup = function(troopId, canEscape, canLose) {
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') {
console.log($gameVariables.valueDayNightColor());
console.log($gameVariables.valueDayNightSave());
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
} else {
$gameTemp._Tint = '#FFFFFF';
}
TerraxLighting_Addon_BattleManager_setup.call(this,troopId, canEscape, canLose);
}
Spriteset_Battle.prototype.createBattleLightmask = function() {
this._lightmask = new BattleLightmask();
this.addChild(this._lightmask);
};
var TerraxLighting_Addon_Spriteset_Base_createLowerLayer = Spriteset_Battle.prototype.createLowerLayer;
Spriteset_Battle.prototype.createLowerLayer = function() {
TerraxLighting_Addon_Spriteset_Base_createLowerLayer.call(this);
this.createBattleLightmask();
}
function BattleLightmask() {
this.initialize.apply(this, arguments);
}
BattleLightmask.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
BattleLightmask.prototype.constructor = BattleLightmask;
BattleLightmask.prototype.initialize = function() {
PIXI.DisplayObjectContainer.call(this);
this._width = Graphics.width;
this._height = Graphics.height;
this._sprites = [];
this._createBitmap();
//Initialize the bitmap
this._addSprite(0,0,this._maskBitmap);
if ($gameTemp._Tint === '#000000' || $gameTemp._Tint === '#111111' || $gameTemp._Tint === '#222222'){
$gameTemp._Tint = '#333333' //The player have to see something
}
this._maskBitmap.FillRect(0,0,maxX,maxY,$gameTemp._Tint);
};
BattleLightmask.prototype._createBitmap = function() {
this._maskBitmap = new Bitmap(maxX,maxY);
var canvas = this._maskBitmap.canvas;
};
BattleLightmask.prototype.update = function() {
//do nothing
};
//@method _createBitmaps
/**
* @method _addSprite
* @private
*/
BattleLightmask.prototype._addSprite = function(x1,y1,selectedbitmap) {
var sprite = new Sprite(this.viewport);
sprite.bitmap = selectedbitmap;
sprite.opacity = 255;
sprite.blendMode = 2;
sprite.x = x1;
sprite.y = y1;
this._sprites.push(sprite);
this.addChild(sprite);
sprite.rotation = 0;
sprite.ax = 0
sprite.ay = 0
sprite.opacity = 255;
};
/**
* @method _removeSprite
* @private
*/
BattleLightmask.prototype._removeSprite = function() {
this.removeChild(this._sprites.pop());
};
BattleManager.setup = function(troopId, canEscape, canLose) {
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') {
console.log($gameVariables.valueDayNightColor());
console.log($gameVariables.valueDayNightSave());
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
} else {
$gameTemp._Tint = '#FFFFFF';
}
TerraxLighting_Addon_BattleManager_setup.call(this,troopId, canEscape, canLose);
}
Spriteset_Battle.prototype.createBattleLightmask = function() {
this._lightmask = new BattleLightmask();
this.addChild(this._lightmask);
};
var TerraxLighting_Addon_Spriteset_Base_createLowerLayer = Spriteset_Battle.prototype.createLowerLayer;
Spriteset_Battle.prototype.createLowerLayer = function() {
TerraxLighting_Addon_Spriteset_Base_createLowerLayer.call(this);
this.createBattleLightmask();
}
function BattleLightmask() {
this.initialize.apply(this, arguments);
}
BattleLightmask.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
BattleLightmask.prototype.constructor = BattleLightmask;
BattleLightmask.prototype.initialize = function() {
PIXI.DisplayObjectContainer.call(this);
this._width = Graphics.width;
this._height = Graphics.height;
this._sprites = [];
this._createBitmap();
//Initialize the bitmap
this._addSprite(0,0,this._maskBitmap);
if ($gameTemp._Tint === '#000000' || $gameTemp._Tint === '#111111' || $gameTemp._Tint === '#222222'){
$gameTemp._Tint = '#333333' //The player have to see something
}
this._maskBitmap.FillRect(0,0,maxX,maxY,$gameTemp._Tint);
};
BattleLightmask.prototype._createBitmap = function() {
this._maskBitmap = new Bitmap(maxX,maxY);
var canvas = this._maskBitmap.canvas;
};
BattleLightmask.prototype.update = function() {
//do nothing
};
//@method _createBitmaps
/**
* @method _addSprite
* @private
*/
BattleLightmask.prototype._addSprite = function(x1,y1,selectedbitmap) {
var sprite = new Sprite(this.viewport);
sprite.bitmap = selectedbitmap;
sprite.opacity = 255;
sprite.blendMode = 2;
sprite.x = x1;
sprite.y = y1;
this._sprites.push(sprite);
this.addChild(sprite);
sprite.rotation = 0;
sprite.ax = 0
sprite.ay = 0
sprite.opacity = 255;
};
/**
* @method _removeSprite
* @private
*/
BattleLightmask.prototype._removeSprite = function() {
this.removeChild(this._sprites.pop());
};
Hello Terrax, very thx for this plugin!
I dont know what im wrong, the game just show me this message when i try to turn On the flashlight :
"Cannot read property 'meta' of undfined"
I've only create a commont event with plugin command "Flashlight 8 12 #888888 "
then add the effect of common event to an object, when i use it the game crash with the error
I dont know what im wrong, the game just show me this message when i try to turn On the flashlight :
"Cannot read property 'meta' of undfined"
I've only create a commont event with plugin command "Flashlight 8 12 #888888 "
then add the effect of common event to an object, when i use it the game crash with the error
@terrax , Hey excellent script, just what my game needed. I put it together with mogs standard time system and evented a much better tinting system using this, however I have ran into a little problem and I am unsure if it is just me. First, I have two common events pulled by a parallel (one that directly sets the tint when a player enters an exterior map, and one that fades gradually when the player is on the map depending on the hour). When a player moves indoors it's supposed to run a similar event (turning on a switch to register for the parallel when they go back outside) that holds the tint depending on a variable I have set up. I also have the player radius set to 0.
I am not sure if this next part was intended or not, but the tinting only works on maps where I have registered a light source (it doesn't matter whether it is turned on or not), any map without a light source ignores all tinting options. If this was intentional is there a work around that doesn't involve me sneaking in a non-active lightsource in every map.
I am not sure if this next part was intended or not, but the tinting only works on maps where I have registered a light source (it doesn't matter whether it is turned on or not), any map without a light source ignores all tinting options. If this was intentional is there a work around that doesn't involve me sneaking in a non-active lightsource in every map.
One lightsource in each map is required. You can use a lightsource with radius 1 and color '000000' if you do not want a lightsource to show.
To activate the flashlight on the player use 'flashlight on'. You trying to use a note-tag call to switch on the player flashlight.
Super upgraded version with no overwrite, no crash when battle-testing and support for tint screen during combat.
var TerraxLighting_Addon_BattleManager_setup = BattleManager.setup;
BattleManager.setup = function(troopId, canEscape, canLose) {
$gameTemp._Tint = '#FFFFFF';
if ($dataMap) {
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') {
console.log($gameVariables.valueDayNightColor());
console.log($gameVariables.valueDayNightSave());
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
}
}
TerraxLighting_Addon_BattleManager_setup.call(this,troopId, canEscape, canLose);
}
Spriteset_Battle.prototype.createBattleLightmask = function() {
this._lightmask = new BattleLightmask();
this.addChild(this._lightmask);
};
var TerraxLighting_Addon_Spriteset_Base_createLowerLayer = Spriteset_Battle.prototype.createLowerLayer;
Spriteset_Battle.prototype.createLowerLayer = function() {
TerraxLighting_Addon_Spriteset_Base_createLowerLayer.call(this);
this.createBattleLightmask();
}
function BattleLightmask() {
this.initialize.apply(this, arguments);
}
BattleLightmask.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
BattleLightmask.prototype.constructor = BattleLightmask;
BattleLightmask.prototype.initialize = function() {
PIXI.DisplayObjectContainer.call(this);
this._width = Graphics.width;
this._height = Graphics.height;
this._sprites = [];
this._createBitmap();
//Initialize the bitmap
this._addSprite(0,0,this._maskBitmap);
var redhex = $gameTemp._Tint.substring(1,3);
var greenhex = $gameTemp._Tint.substring(3,5);
var bluehex = $gameTemp._Tint.substring(5);
var red = parseInt(redhex, 16);
var green = parseInt(greenhex, 16);
var blue = parseInt(bluehex, 16);
var color = red+green+blue;
if (color<153 && red<51 && green<51 && blue<51){
$gameTemp._Tint = '#333333' //The player have to see something
}
$gameTemp._BattleTint = $gameTemp._Tint;
this._maskBitmap.FillRect(0,0,maxX,maxY,$gameTemp._Tint);
$gameTemp._BattleTintSpeed = 0;
};
BattleLightmask.prototype._createBitmap = function() {
this._maskBitmap = new Bitmap(maxX,maxY);
var canvas = this._maskBitmap.canvas;
};
//Plugin commands:
//TintBattle set #FF0000 -> Tint the battle screen to the color used as argument.
Automatically set too dark color to '#333333' otherwise the player wouldn't see anything.
//TintBattle reset -> Reset the battle screen to his original color.
//TintBattle fade #FF0000 5 -> Fade the battle screen to the color used as first argument.
// The second argument is speed of the fade (1 very fast, 20 more slow)
// Still automatically set too dark color to '#333333' otherwise the player wouldn't see anything.
var TerraxLighting_Addon_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
TerraxLighting_Addon_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'tintbattle' && $gameParty.inBattle()) {
if (args[0] === 'set') {
$gameTemp._BattleTint = args[1];
var redhex = $gameTemp._BattleTint.substring(1,3);
var greenhex = $gameTemp._BattleTint.substring(3,5);
var bluehex = $gameTemp._BattleTint.substring(5);
var red = parseInt(redhex, 16);
var green = parseInt(greenhex, 16);
var blue = parseInt(bluehex, 16);
var color = red+green+blue;
if (color<153 && red<51 && green<51 && blue<51){
$gameTemp._BattleTint = '#333333' //The player have to see something
}
$gameTemp._BattleTintSpeed = 0;
}
if (args[0] === 'reset') {
$gameTemp._BattleTint = $gameTemp._Tint;
$gameTemp._BattleTintSpeed = 0;
}
if (args[0] === 'fade') {
$gameTemp._BattleTintFade = $gameTemp._BattleTint;
$gameTemp._BattleTintTimer = 0;
$gameTemp._BattleTint = args[1];
$gameTemp._BattleTintSpeed = args[2];
var redhex = $gameTemp._BattleTint.substring(1,3);
var greenhex = $gameTemp._BattleTint.substring(3,5);
var bluehex = $gameTemp._BattleTint.substring(5);
var red = parseInt(redhex, 16);
var green = parseInt(greenhex, 16);
var blue = parseInt(bluehex, 16);
var color = red+green+blue;
if (color<153 && red<51 && green<51 && blue<51){
$gameTemp._BattleTint = '#333333' //The player have to see something
}
}
}
}
BattleLightmask.prototype.update = function() {
var color1 = $gameTemp._BattleTint;
if ($gameTemp._BattleTintSpeed > 0) {
$gameTemp._BattleTintTimer += 1;
var r = hexToRgb($gameTemp._BattleTintFade).r;
var g = hexToRgb($gameTemp._BattleTintFade).g;
var b = hexToRgb($gameTemp._BattleTintFade).b;
var r2 = hexToRgb($gameTemp._BattleTint).r;
var g2 = hexToRgb($gameTemp._BattleTint).g;
var b2 = hexToRgb($gameTemp._BattleTint).b;
var stepR = (r2-r)/(60*$gameTemp._BattleTintSpeed);
var stepG = (g2-g)/(60*$gameTemp._BattleTintSpeed);
var stepB = (b2-b)/(60*$gameTemp._BattleTintSpeed);
var r3 = Math.floor(r + (stepR * $gameTemp._BattleTintTimer));
var g3 = Math.floor(g + (stepG * $gameTemp._BattleTintTimer));
var b3 = Math.floor(b + (stepB * $gameTemp._BattleTintTimer));
if (r3<0) { r3 = 0 }
if (g3<0) { g3 = 0 }
if (b3<0) { b3 = 0 }
if (r3>255) { r3 = 255 }
if (g3>255) { g3 = 255 }
if (b3>255) { b3 = 255 }
var reddone = false;
var greendone = false;
var bluedone = false;
if (stepR >=0 && r3>=r2) {
reddone = true;
}
if (stepR <=0 && r3<=r2) {
reddone = true;
}
if (stepG >=0 && g3>=g2) {
greendone = true;
}
if (stepG <=0 && g3<=g2) {
greendone = true;
}
if (stepB >=0 && b3>=b2) {
bluedone = true;
}
if (stepB <=0 && b3<=b2) {
bluedone = true;
}
if (reddone == true && bluedone == true && greendone == true) {
$gameTemp._BattleTintFade = $gameTemp._BattleTint;
$gameTemp._BattleTintSpeed = 0;
$gameTemp._BattleTintTimer = 0;
}
color1 = "#" + ((1 << 24) + (r3 << 16) + (g3 << 8) + b3).toString(16).slice(1);
$gameTemp._BattleTintFade = color1;
}
this._maskBitmap.FillRect(0,0,maxX,maxY,color1);
};
//@method _createBitmaps
/**
* @method _addSprite
* @private
*/
BattleLightmask.prototype._addSprite = function(x1,y1,selectedbitmap) {
var sprite = new Sprite(this.viewport);
sprite.bitmap = selectedbitmap;
sprite.opacity = 255;
sprite.blendMode = 2;
sprite.x = x1;
sprite.y = y1;
this._sprites.push(sprite);
this.addChild(sprite);
sprite.rotation = 0;
sprite.ax = 0
sprite.ay = 0
sprite.opacity = 255;
};
/**
* @method _removeSprite
* @private
*/
BattleLightmask.prototype._removeSprite = function() {
this.removeChild(this._sprites.pop());
};
BattleManager.setup = function(troopId, canEscape, canLose) {
$gameTemp._Tint = '#FFFFFF';
if ($dataMap) {
boolean = false;
for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events) {
var note = $dataMap.events.note
var note_args = note.split(" ");
var note_command = note_args.shift().toLowerCase();
if (note_command == "light" || note_command == "fire" || note_command == "daynight" || note_command == "flashlight" ) {
boolean = true;
break;
}
}
}
if ($dataMap.note.toLowerCase() == 'daynight') {
console.log($gameVariables.valueDayNightColor());
console.log($gameVariables.valueDayNightSave());
$gameTemp._Tint = $gameVariables.valueDayNightColor()[$gameVariables.valueDayNightSave()];
} else if (boolean) {
$gameTemp._Tint = $gameVariables.valueTintValueSave();
}
}
TerraxLighting_Addon_BattleManager_setup.call(this,troopId, canEscape, canLose);
}
Spriteset_Battle.prototype.createBattleLightmask = function() {
this._lightmask = new BattleLightmask();
this.addChild(this._lightmask);
};
var TerraxLighting_Addon_Spriteset_Base_createLowerLayer = Spriteset_Battle.prototype.createLowerLayer;
Spriteset_Battle.prototype.createLowerLayer = function() {
TerraxLighting_Addon_Spriteset_Base_createLowerLayer.call(this);
this.createBattleLightmask();
}
function BattleLightmask() {
this.initialize.apply(this, arguments);
}
BattleLightmask.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
BattleLightmask.prototype.constructor = BattleLightmask;
BattleLightmask.prototype.initialize = function() {
PIXI.DisplayObjectContainer.call(this);
this._width = Graphics.width;
this._height = Graphics.height;
this._sprites = [];
this._createBitmap();
//Initialize the bitmap
this._addSprite(0,0,this._maskBitmap);
var redhex = $gameTemp._Tint.substring(1,3);
var greenhex = $gameTemp._Tint.substring(3,5);
var bluehex = $gameTemp._Tint.substring(5);
var red = parseInt(redhex, 16);
var green = parseInt(greenhex, 16);
var blue = parseInt(bluehex, 16);
var color = red+green+blue;
if (color<153 && red<51 && green<51 && blue<51){
$gameTemp._Tint = '#333333' //The player have to see something
}
$gameTemp._BattleTint = $gameTemp._Tint;
this._maskBitmap.FillRect(0,0,maxX,maxY,$gameTemp._Tint);
$gameTemp._BattleTintSpeed = 0;
};
BattleLightmask.prototype._createBitmap = function() {
this._maskBitmap = new Bitmap(maxX,maxY);
var canvas = this._maskBitmap.canvas;
};
//Plugin commands:
//TintBattle set #FF0000 -> Tint the battle screen to the color used as argument.
Automatically set too dark color to '#333333' otherwise the player wouldn't see anything.
//TintBattle reset -> Reset the battle screen to his original color.
//TintBattle fade #FF0000 5 -> Fade the battle screen to the color used as first argument.
// The second argument is speed of the fade (1 very fast, 20 more slow)
// Still automatically set too dark color to '#333333' otherwise the player wouldn't see anything.
var TerraxLighting_Addon_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
TerraxLighting_Addon_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'tintbattle' && $gameParty.inBattle()) {
if (args[0] === 'set') {
$gameTemp._BattleTint = args[1];
var redhex = $gameTemp._BattleTint.substring(1,3);
var greenhex = $gameTemp._BattleTint.substring(3,5);
var bluehex = $gameTemp._BattleTint.substring(5);
var red = parseInt(redhex, 16);
var green = parseInt(greenhex, 16);
var blue = parseInt(bluehex, 16);
var color = red+green+blue;
if (color<153 && red<51 && green<51 && blue<51){
$gameTemp._BattleTint = '#333333' //The player have to see something
}
$gameTemp._BattleTintSpeed = 0;
}
if (args[0] === 'reset') {
$gameTemp._BattleTint = $gameTemp._Tint;
$gameTemp._BattleTintSpeed = 0;
}
if (args[0] === 'fade') {
$gameTemp._BattleTintFade = $gameTemp._BattleTint;
$gameTemp._BattleTintTimer = 0;
$gameTemp._BattleTint = args[1];
$gameTemp._BattleTintSpeed = args[2];
var redhex = $gameTemp._BattleTint.substring(1,3);
var greenhex = $gameTemp._BattleTint.substring(3,5);
var bluehex = $gameTemp._BattleTint.substring(5);
var red = parseInt(redhex, 16);
var green = parseInt(greenhex, 16);
var blue = parseInt(bluehex, 16);
var color = red+green+blue;
if (color<153 && red<51 && green<51 && blue<51){
$gameTemp._BattleTint = '#333333' //The player have to see something
}
}
}
}
BattleLightmask.prototype.update = function() {
var color1 = $gameTemp._BattleTint;
if ($gameTemp._BattleTintSpeed > 0) {
$gameTemp._BattleTintTimer += 1;
var r = hexToRgb($gameTemp._BattleTintFade).r;
var g = hexToRgb($gameTemp._BattleTintFade).g;
var b = hexToRgb($gameTemp._BattleTintFade).b;
var r2 = hexToRgb($gameTemp._BattleTint).r;
var g2 = hexToRgb($gameTemp._BattleTint).g;
var b2 = hexToRgb($gameTemp._BattleTint).b;
var stepR = (r2-r)/(60*$gameTemp._BattleTintSpeed);
var stepG = (g2-g)/(60*$gameTemp._BattleTintSpeed);
var stepB = (b2-b)/(60*$gameTemp._BattleTintSpeed);
var r3 = Math.floor(r + (stepR * $gameTemp._BattleTintTimer));
var g3 = Math.floor(g + (stepG * $gameTemp._BattleTintTimer));
var b3 = Math.floor(b + (stepB * $gameTemp._BattleTintTimer));
if (r3<0) { r3 = 0 }
if (g3<0) { g3 = 0 }
if (b3<0) { b3 = 0 }
if (r3>255) { r3 = 255 }
if (g3>255) { g3 = 255 }
if (b3>255) { b3 = 255 }
var reddone = false;
var greendone = false;
var bluedone = false;
if (stepR >=0 && r3>=r2) {
reddone = true;
}
if (stepR <=0 && r3<=r2) {
reddone = true;
}
if (stepG >=0 && g3>=g2) {
greendone = true;
}
if (stepG <=0 && g3<=g2) {
greendone = true;
}
if (stepB >=0 && b3>=b2) {
bluedone = true;
}
if (stepB <=0 && b3<=b2) {
bluedone = true;
}
if (reddone == true && bluedone == true && greendone == true) {
$gameTemp._BattleTintFade = $gameTemp._BattleTint;
$gameTemp._BattleTintSpeed = 0;
$gameTemp._BattleTintTimer = 0;
}
color1 = "#" + ((1 << 24) + (r3 << 16) + (g3 << 8) + b3).toString(16).slice(1);
$gameTemp._BattleTintFade = color1;
}
this._maskBitmap.FillRect(0,0,maxX,maxY,color1);
};
//@method _createBitmaps
/**
* @method _addSprite
* @private
*/
BattleLightmask.prototype._addSprite = function(x1,y1,selectedbitmap) {
var sprite = new Sprite(this.viewport);
sprite.bitmap = selectedbitmap;
sprite.opacity = 255;
sprite.blendMode = 2;
sprite.x = x1;
sprite.y = y1;
this._sprites.push(sprite);
this.addChild(sprite);
sprite.rotation = 0;
sprite.ax = 0
sprite.ay = 0
sprite.opacity = 255;
};
/**
* @method _removeSprite
* @private
*/
BattleLightmask.prototype._removeSprite = function() {
this.removeChild(this._sprites.pop());
};
Hi Terrax
First, thanks for your work with this plugin!
I have a suggestion for a new version which would bring parallax mapping to a new level (for me at least): You already have the function to block certain regions from having light. I use parallax maps that aren't related to the usual grid and it looks quite uncool with the normal region block. So is there a possibility to have a light block option that is map based (like a layer that blocks the light out)? Or even better: Since I'm using Kaus Ultimate overlay for mapping, having an option that blocks out the light for certain layers only?
First, thanks for your work with this plugin!
I have a suggestion for a new version which would bring parallax mapping to a new level (for me at least): You already have the function to block certain regions from having light. I use parallax maps that aren't related to the usual grid and it looks quite uncool with the normal region block. So is there a possibility to have a light block option that is map based (like a layer that blocks the light out)? Or even better: Since I'm using Kaus Ultimate overlay for mapping, having an option that blocks out the light for certain layers only?
Whenever I use this plugin and enter a map which is a 'parallax map' I get an error saying "Plugin: Xxxpicture below_characters is not a valid layer"
If I enter a non-parallax map it works fine.
If I enter a non-parallax map it works fine.
Original thread: https://forums.rpgmakerweb.com/threads/terrax-lighting-system.49339/


