Terrax Lighting system

Sideroxylon

Veteran
Veteran
Joined
Oct 30, 2015
Messages
29
Reaction score
5
First Language
German
Thank you very much for this plugin, it will be an important part of my game. I will send you the game for free, when it will be finished next year.
 

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
527
Reaction score
106
First Language
English
Primarily Uses
N/A

Nightshade

Veteran
Veteran
Joined
Oct 26, 2015
Messages
591
Reaction score
120
First Language
English
Primarily Uses
RMMV
umm i was given a red flag warning on your file and it was marked unsafe Oo just a heads up probably cause the zip got to many numbers LOL
 

RedAkerston

Veteran
Veteran
Joined
Oct 10, 2015
Messages
67
Reaction score
12
First Language
English
This is a most excellent plugin.

Though the dark layer doesn't block out the text window or pictures,

One thing i have noticed is that the dark layer does block out the pop up windows in the tinygetinfo plugin that came with the pre-order of the game.

I suppose i'll just find an alternative hopefully to that, since it's lower priority than this one, obviously... but i thought i'd bring it up.

Probably the black layer is bound to block out some things in other places too with other plugins.

I'm not sure if anything can be done to make this aspect more versatile? 
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,382
Reaction score
10,824
First Language
English
Primarily Uses
RMVXA
Terrax , please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.

When you want to reply to more than one person, use the Multiquote button, bottom right, and it can all be done in the same post.
 

SolidusPrime

Villager
Member
Joined
May 7, 2015
Messages
11
Reaction score
0
Primarily Uses
Terrax, thank you so much for the work you put into this! It is exactly what I needed, and it works great.

My requests for a future update would be:

-Flickering lights. Used for firelight or a broken light.

-Ability to change shape of the light. I would like to make the player's light a focused cone like a flashlight, or have light coming from a doorway. Scripting is my weak area, so I'm not sure how to dissect this to see if it just uses a mathematical radius, or an image file of some kind to produce the shape. I am guessing it is the former.

Thanks again. This plugin is amazing.
 
Last edited by a moderator:

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
223
First Language
English
New version (1.0.6) now available

http://mvplugins.com...Lighting System

Version 1.0.6

New:

If you replace the light keyword with fire, your lights will have a flicker

So Light 150 #FFCC00  becomes Fire 150 #FFCC00.

New:

First experiment with a flashlight, it's not perfect yet, the directional movement of the light is to quick, i might

need to animate it from one side to the next, take a look and tell me what you think (it's in the chest in last room of the demo).

Terrax
 
Last edited by a moderator:

cropots

Veteran
Veteran
Joined
Oct 31, 2015
Messages
175
Reaction score
27
First Language
Portugues
Very good effect of fire.
 

cropots

Veteran
Veteran
Joined
Oct 31, 2015
Messages
175
Reaction score
27
First Language
Portugues
It would be interesting if you could have a timer to torch like Dark Souls. It would be possible? With a counter on the screen.

EDIT: I managed to make the torch goes out after a while, with common events. ^^

 
Last edited by a moderator:

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
527
Reaction score
106
First Language
English
Primarily Uses
N/A
Just figured I'd mention... The flicker in the Fire can be disorienting when dealing with multiple small radius sources in close proximity to each other. It starts to have a strobe like effect (because all the flickering is 100% in sync) that might give some people headaches.

Is it at all possible to have the rates (including a small randomized change in that flicker) that govern the flicker as plugin parameters? Or possibly have the ability to define light types and if they have flicker or not?
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
223
First Language
English
Just figured I'd mention... The flicker in the Fire can be disorienting when dealing with multiple small radius sources in close proximity to each other. It starts to have a strobe like effect (because all the flickering is 100% in sync) that might give some people headaches.

Is it at all possible to have the rates (including a small randomized change in that flicker) that govern the flicker as plugin parameters? Or possibly have the ability to define light types and if they have flicker or not?
Each flicker is complely random and very small. All i did was do a +random(8) to the radius and a +random(8) to the green value. Higher values give an ever bigger strobe effect and drove me crazy.

Although flicker is a nice effect it gets old very fast, I would keep the amount of flicker to a minimum in the game since it gets disorienting very fast like you mentioned.

I can try to vary the speed (it randomizes each frame at this moment) to lessen the effect. I will see what i can do.

Edit: I've tried and decreasing the flicker frequency helps, it will be included next update.
 
Last edited by a moderator:

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
527
Reaction score
106
First Language
English
Primarily Uses
N/A
Wow. Ok. Its odd how consistently the flicker rate syncs then. It was a bad assumption on my part.

Maybe its a per frame issue? If the flicker was slowed down a bit?

(edit: /facepalm you already said that...)
 
Last edited by a moderator:

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
527
Reaction score
106
First Language
English
Primarily Uses
N/A
Are you planning to add mobile and/or dynamic radius (on command) lights other than the player? :)
 
Joined
Jun 16, 2014
Messages
4
Reaction score
1
First Language
English
This is a really cool plugin. Great for setting atmosphere. Might I suggest another feature for a future update?

I think it would be cool to be able to disable the darkness with a plugin command. Like if you wanted a dark room but could turn on a light switch?

I don't know if that's possible with the plugin in its current state. I tried as a temporary fix making a light switch that expanded the player's light radius really large but it causes a noticable amount of lag. :(
 

Portkey89

Veteran
Veteran
Joined
Apr 4, 2012
Messages
78
Reaction score
16
First Language
English
Primarily Uses
Hi Terrax--

This is working AMAZINGLY.  THANK YOU!  One thing I've noted though, and I was hoping this might be something you'd consider adjusting in an update, is that if changing the radius, it changes INSTANTLY.  The plugin commands ignore a wait command, so what I'd tried to simulate a gradual transition failed, and that was this:  I attempted to have it, every five frames, decrease the radius by 100px increments; however, it jumped to the final radius instantly.  Would you be willing to add the ability to transition the radius over a period of time?  It would be useful for things like the hero's torch burning out, or candles in a room dwindling down, or light fading as the world turns to night, etc.  And it would be much more elegant than the way I tried going about it.  Thank you!!!!
 
Last edited by a moderator:

RedAkerston

Veteran
Veteran
Joined
Oct 10, 2015
Messages
67
Reaction score
12
First Language
English
One more thing i've noticed is that one event only brings the lit area to about half opacity? It takes 2 events to reach full brightness.
 

SolidusPrime

Villager
Member
Joined
May 7, 2015
Messages
11
Reaction score
0
Primarily Uses
New version (1.0.6) now available

http://mvplugins.com...Lighting System

Version 1.0.6

New:

If you replace the light keyword with fire, your lights will have a flicker

So Light 150 #FFCC00  becomes Fire 150 #FFCC00.

New:

First experiment with a flashlight, it's not perfect yet, the directional movement of the light is to quick, i might

need to animate it from one side to the next, take a look and tell me what you think (it's in the chest in last room of the demo).

Terrax
Wow, fantastic man, truly.

I can see why you would feel the flashlight would be a little too fast, but honestly it looks good, and that seems to be how it behaves in most other games. An animation would make it feel more natural to the eye, but  I don't think you'll get any complaints the way it is. I know I personally love it. Thanks again for the work.
 

White Dragon

Villager
Member
Joined
Oct 27, 2015
Messages
10
Reaction score
1
First Language
German
I have one question:

When I process a battle from a map with the light script on then the lights are still active in the battle scene.

I suppose this is not intended.

Could this please be fixed or am I doing something wrong?

Thanks! :)

EDIT:

Fixed it with battleback change.

The battle process used the battleback from the lighted map instead of the battleback that I wanted it to use.
 
Last edited by a moderator:

PartyPowered

Warper
Member
Joined
Nov 8, 2015
Messages
1
Reaction score
0
First Language
Spanish/English
Hi everyone, specially Terrax.

I'm gonna use your simple script in my game :) .

I have been reading your code, and it's nice.

But I found some strange cases:

1) With the character light player, the gradient you are creating is quite different from the rest of lights cause the start radius is diferent from 0,(it's 20). I understand why you did this but for my case, I would prefer to have it also at 0. I made the player light radius available at values smaller than 30.

2) To call some changes you use the plugin command. So you for example, write a string like "Light radius 140 #ffffff", where everything is string and non numeric. So I tried to elaborate a script instead of the plugin command to call your functions.

So, I have made some changes at your script for my own profit. But here I give you all them, to share if you like the changes.

Code:
// This code wil assign the Light player radius as the variable stored at position 2,// And it will alse set the color of the light to #ff0ff0// It's just an example, but it represents a dinamyc parameters access// and with this you can imagine that you can create more dynamic lightsGame_Interpreter.prototype.pluginCommand("Light",["radius" ,""+$gameVariables.value(2),"#ff0ff0"] );
Code:
//=============================================================================// Terrax Plugins - Lighting system// TerraxLighting.js// Version: 1.04//=============================================================================//// This script should be compatible with most other scripts, it overwrites one// core script (Spriteset_Map.prototype.createLowerLayer) in rpg_sprites.js to// add a new layer. //============================================================================= /*: * @plugindesc v1.04 Creates an extra layer that darkens a map and adds lightsources! * @author Terrax * * @param Player radius * @desc Adjust the light radius around the player                          . * Default: 300 * @default 300 * * @help * To activate the script in an area, do the following: * 1. Put an event switch into the map. * 2. In the 'Note' field (Next to the name) put the following text : * Light 250 #FFFFFF * - Light activates the script * - 250 is the lightradius of the object * - #FFFFFF is the lightcolor (white in this case) * 3. You're done, its that simple. * * To alter the player radius in game use the following plugin command :  * Light radius 200 #FFFFFF   * (to change the radius and the color) * * Optional: to turn on and off lightsources in the game, do the following: * Give the lightsource the normal def :  Light 250 #FFFFFF and an extra number  * so it becomes 'Light 250 #FFFFFF 1' * To turn on this light use plugin command : 'Light on 1'. * The plugin command will also trigger SelfSwitch 'D' on the targeted light(s). * To turn off the light use plugin command : 'Light off 1'. * * Released under the MIT license, * if used for commercial projects feel free to make a donation or  * better yet, give me a free version of what you have created. * e-mail : fox(AT)caiw.nl / terraxz2 on steam. * *///=============================================================================//  ps.. if my code looks funky, i'm an old guy..// object orientated programming bugs the hell out of me.var testcounter = 0;var lightarray_id = [];var lightarray_state = [];(function() {	var oldmap = 0;    var playercolor = '#FFFFFF';    	var parameters = PluginManager.parameters('TerraxLighting');    var player_radius = Number(parameters['Player radius'] || 300);		        var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;    Game_Interpreter.prototype.pluginCommand = function(command, args) {        _Game_Interpreter_pluginCommand.call(this, command, args);               if (command === 'Light') {            	        var evid = this._eventId;	        // Light radius 100 #FFFFFF  	    	        if (args[0] == 'radius') {    			var newradius = Number(args[1]);    			if (newradius > 0) {    				player_radius = newradius;				} else 				{ 					player_radius = 0;				}							if (args.length > 2) {					playercolor = args[2];					var isValidPlayerColor  = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(playercolor) 	    					if (!isValidPlayerColor) {						playercolor = '#FFFFFF'    					}				}			}  			if (args[0] == 'on') {    	 		var lightid = Number(args[1]);    			var idfound = false;				for (var i = 0; i < lightarray_id.length; i++) {					if (lightarray_id[i] == lightid) {						idfound = true;						lightarray_state[i] = true;						//Graphics.printError('test','found');					}				}				if (idfound == false) {					lightarray_id.push(lightid);					lightarray_state.push(true);									}			}	 			if (args[0] == 'off') {    			var lightid = Number(args[1]);    			var idfound = false;				for (var i = 0; i < lightarray_id.length; i++) {					if (lightarray_id[i] == lightid) {						idfound = true;						lightarray_state[i] = false;					}				}				if (idfound == false) {					lightarray_id.push(lightid);					lightarray_state.push(false);				}			}		  		}  	}    	Spriteset_Map.prototype.createLightmask = function() {	    this._lightmask = new Lightmask();	    this.addChild(this._lightmask);	};			function Lightmask() {	    this.initialize.apply(this, arguments);	}		Lightmask.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);	Lightmask.prototype.constructor = Lightmask;		Lightmask.prototype.initialize = function() {	    PIXI.DisplayObjectContainer.call(this);		    this._width = Graphics.width;	    this._height = Graphics.height;	    this._sprites = [];	    this._createBitmap();	    	};		//Updates the Lightmask for each frame.		Lightmask.prototype.update = function() {	    this._updateMask();	};		//@method _createBitmaps		Lightmask.prototype._createBitmap = function() {		    this._maskBitmap = new Bitmap(2500,1500);   // one big bitmap to fill the intire screen with black	    var canvas = this._maskBitmap.canvas;	};		/**	 * @method _updateAllSprites	 * @private	 */	Lightmask.prototype._updateMask = function() {				// ****** DETECT MAP CHANGES ********		var map_id = $gameMap.mapId();		if (map_id != oldmap) {			// remove old sprites			for (var i = 0; i < this._sprites.length; i++) {	  // remove all old sprites				this._removeSprite();			}											// are there lightsources on this map?			for (var i = 0; i < $dataMap.events.length; i++) {	        	if ($dataMap.events[i]) {	            	var note = $dataMap.events[i].note	            	var note_args = note.split(" ");	    			var note_command = note_args.shift();	            	if (note_command == "Light" || note_command == "light") {									this._addSprite(0,0,this._maskBitmap); // yes.. then turn off the lights						break;					}				}			}								}				    // ****** PLAYER LIGHTGLOBE ********		    var canvas = this._maskBitmap.canvas;	   	var ctx = canvas.getContext("2d");	    this._maskBitmap.fillRect(0, 0, 2500, 1500, 'black');	  		//ctx.globalCompositeOperation = 'lighten';		ctx.globalCompositeOperation = 'lighter';				var pw = $gameMap.tileWidth()	    var ph = $gameMap.tileHeight();		var dx = $gameMap.displayX();		var dy = $gameMap.displayY();		var px = $gamePlayer._realX;		var py = $gamePlayer._realY;					var x1 = (pw/2)+( (px-dx)*pw);		var y1 = (ph/2)+( (py-dy)*ph);	    var paralax = false;		// paralax does something weird with coordinates.. recalc needed		if (dx>$gamePlayer.x) {			var xjump = $gameMap.width() - Math.floor(dx-px);  			x1 = (pw/2)+(xjump*pw);		} 		if (dy>$gamePlayer.y) {			var yjump = $gameMap.height() - Math.floor(dy-py);			y1 = (ph/2)+(yjump*ph);		}		this._maskBitmap.radialgradientFillRect(x1,y1, 0, player_radius, playercolor, 'black'); 		// ********** OTHER LIGHTSOURCES **************				for (var i = 0; i < $dataMap.events.length; i++) {	        if ($dataMap.events[i]) {	            var note = $dataMap.events[i].note;	            //var eventid = $dataMap.events[i].id;	            var note_args = note.split(" ");	    		var note_command = note_args.shift();	            if (note_command == "Light" || note_command == "light") {		        	var light_radius = note_args.shift();		        			        			        	// light radius		        	if (light_radius > 0) {			        				        	// light color			        	var colorvalue = note_args.shift();			        	var isValidColor  = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(colorvalue) 	    			            if (!isValidColor) {				        	colorvalue = '#FFFFFF'    			            }			            			            // lights on/off			            /*			        	var lightswitch = note_args.shift();			        	if (lightswitch > 0) {				            var lighton = $gameSwitches.value(lightswitch);				            if (lighton == false) {					            light_radius = 0;			        		}  					    } 					    */					    //$gameSelfSwitches.setValue(key, true/false);	key = [mapId, eventId, A-D]					  					    var lightid = note_args.shift();					    var state = true;					     					    			        	if (lightid > 0) {				        	var state = false;					    	for (var j = 0; j < lightarray_id.length; j++) {								if (lightarray_id[j] == lightid) {									idfound = true;									state = lightarray_state[j]; 									var mapid = $gameMap.mapId();									var eventid = $dataMap.events[i].id;									//Graphics.printError('test',mapid+' '+eventid);									key = [mapid,eventid,'D'];									if (state == true) {										$gameSelfSwitches.setValue(key, true);									} else {										$gameSelfSwitches.setValue(key, false);									}								}							}						}  					    			        				        				            if (state == true) {			        				        					            var lpx = $dataMap.events[i].x;				            var lpy = $dataMap.events[i].y;				            var lx1 = (pw/2)+( (lpx-dx)*pw);							var ly1 = (ph/2)+( (lpy-dy)*ph);							// paralax does something weird with coordinates.. recalc needed							if (dx-10>lpx) {								var lxjump = $gameMap.width() - (dx-lpx);								lx1 = (pw/2)+(lxjump*pw);							} 							if (dy-10>lpy) {								var lyjump = $gameMap.height() -(dy-lpy);								ly1 = (ph/2)+(lyjump*ph);							}				            this._maskBitmap.radialgradientFillRect(lx1,ly1, 0, light_radius , colorvalue, 'black'); 		            	}	            	}	            }	            	        }	    }				// reset drawmode to normal	    ctx.globalCompositeOperation =  'source-over';	    		};			/**	 * @method _addSprite	 * @private	 */	Lightmask.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	 */	Lightmask.prototype._removeSprite = function() {	    this.removeChild(this._sprites.pop());	};		// Fill gradient circle		Bitmap.prototype.radialgradientFillRect = function(x1, y1, r1, r2, color1, color2) {	    var context = this._context;	    var grad;	    	    grad = context.createRadialGradient(x1, y1, r1, x1, y1, r2);		    grad.addColorStop(0, color1);	    grad.addColorStop(1, color2);	    context.save();	    context.fillStyle = grad;	    context.fillRect(x1-r2, y1-r2, r2*2, r2*2);	    context.restore();	    this._setDirty();	};		//****	// This function is overwritten from rpg_sprites.js	//****	Spriteset_Map.prototype.createLowerLayer = function() {	    Spriteset_Base.prototype.createLowerLayer.call(this);	    this.createParallax();	    this.createTilemap();	    this.createCharacters();	    this.createShadow();	    this.createDestination();	    this.createLightmask();	    this.createWeather();		};	})();
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
223
First Language
English
New version (1.0.7) now available

http://mvplugins.com...Lighting System

Version 1.0.7

Fixed:

Fire will flicker a little less fast to reduce the strobe effect

New:

You can completly turn off the script with the plugin command: 'Light deactivate'

And you can turn it on again with the plugin command: 'Light activate'

New:

You can slowly grow or shrink the player radius with the  plugin command 'Light radiusgrow 100 #FFFFFF'

Still in research:

- Radius growth/shrink on objects.

- Mobile lightsources.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

So the overhaul on my project has been going great, I like this version of the project a lot more. It's more contained and less overly ambitious for what I can achieve given my constraints on time, money, and skills in advanced programming. I'm going to wait till my project is mostly finished to begin working UI polish again. I'm going to learn how to use LUNA MV to polish the project.
last time i used this site i was a different gender.. wow rlly makes u think... anyway transing ur gender is pretty cool and theres hair growing on my feet now 10/10
I should have listened to RPGMAKER Meme thread. I should have backed up my data. The Orphan of Time, my WIP, is completely gone, all those hours of work are completely gone :(
God what was my life before smartphones (I had a grandma's phone before wednesday)
Stream will be live shortly with The Witcher 3! Feel free to drop by!

Forum statistics

Threads
93,381
Messages
911,847
Members
122,883
Latest member
TEKILAO
Top