Author Topic: [XP] Dynamic Lights by Fabien 3.0(Translated)  (Read 6532 times)

Offline ArcaneAlchemy

  • Awakened Visionist
  • **
  • Posts: 97
  • LV: 6
  • Gender: Male
    • View Profile
[XP] Dynamic Lights by Fabien 3.0(Translated)
« on: June 28, 2014, 09:49:01 AM »
Dynamic Lights by Fabien 3.0(English)
Authors: Fabien
Version: 3.0
Type: Custom Lights
Key Term: Custom Environment System

Introduction

So this is not my script, but I I translated it and man was it an undertaking. Following finalholyknight's suggestion, I went ahead and decided to post this as a new topic. finalholyknight did already contact Fabien and got his permission to share it here. Fabien's contact info is in the script if you would like to contact him. I can help with most questions though since I have been messing with this script pretty intensely for the past few days though.

Fabien's permission to finalholyknight:

(click to show/hide)

Features

  • Multiple dynamic lights on single map
  • Automatic lights on tiles of your choice
  • Permanently uncover dark areas by walking around a map
  • Show a secret view of a hidden map under a "fake" one.
  • Some really nice light images
  • Protect tile areas from being effected by lights
  • Emulate sunrise/sunset with opacity change of darkness overlay

Screenshots

(click to show/hide)
(click to show/hide)
(click to show/hide)
(click to show/hide)


Demo

 http://s000.tinyupload.com/?file_id=32887480091240890860

Script

Multiple Scripts inside Demo


Instructions
TUTORIALS BELOW

To light yourself a torch/flashlight:

1. Go ahead and locate your picture that you want to use for your flashlight. If using the demo as a ..well ... demo then go ahead and make a note of the location in your folder called Graphics/Pictures/lumieres (lumieres means "lights" btw since I've been reading French for the past f-cking hour). If using the demo, you'll see a whole bunch of names.

2. Go ahead and choose one. I chose "lampe2" for my little flashlight/torch thing. It will work just fine for you too. It kinda looks like a torch or something.

3. Make a parallel process triggered event on a new map and paste in the following script:

wallpaper_night(240)
lum("lampe2",0,255)

 Actually what they mean by that is they are taking an image and overlaying it to a closer z index on the screen. The picture is overlapping what is on the map.
the (240) is the opacity. You can change this if you'd like the 'darkness' aka. wallpaper_night to be more or less opaque.

so what about the lum("lampe2",0,255) part? Well it's pretty simple.
the "lum" stands for light. So I just think of the word 'light' or like lumination.
Inside the parenthesis it goes as follows:

lum("name_of_image",event_id,opacity)

the image I used was lampe2. The event_id of 0 is the main character sprite. Opacity is at max(255)

So that's how you get yourself a nice little torch. But what about all the other cool shit with the lamps lighting at the same time?

Here's where it really confused me. So, apparently, if you try to use more than one parallel process to illuminate lamps, the game will shit all over itself for no apparent reason. No matter how much French you learn in one day, it will still be more confusing and less telling than a creepy mime on the corner of the wine bistro.

HOW WE SET UP LIGHTS AND TORCH AT THE SAME TIME:(This is good for a flickering torch-like effect)

Here's the meat and potatoes:

1. If you followed my last rant, then you should already have the torch on your player. You will want to use A SINGLE parallel process for all of this, so I will go ahead and post in the script for both the player torch AND the lamp torches. Add this to a SINGLE event on a blank map. I suggest using a map texture set that has something that resembles a light or torch for visual satisfaction purposes only. In this map, make an event for your parallel process, and make three more for your lamps. I did mine like so:

(click to show/hide)

here's the script:


wallpaper_night(240)
lum("lampe2",0,255)
lum("lampe2",1,255-rand(50))
lum("lampe2",2,255-rand(50))
lum("lampe2",3,255-rand(50))


You will notice a few things. Firstly, you will see the code for the original stuff. The first two lines make it dark and give your player a lamp(player = event #0) But if you look above, you'll know this. The next three lines are similar. The numbers after the "lampe2" part are the event id numbers. The other thing you will notice is that in the opacity section, it's set to 255-rand(50). This will create a flickering effect, essentially subtracting a random value of 0-49 of opacity.

Anyway, when you're all said and done, run it and it'll look like this:

(click to show/hide)


HOW TO ILLUMINATE A TILE TYPE AND REPEAT WITHOUT ADDITIONAL SCRIPTING(like in example 2 in demo)

Please use the provided demo here to make this easy for the both of us.

This one really confused me for a bit but I figured it out and man I'm so freaking excited!  :D

(click to show/hide)

Step 2. Add in a couple of lamps(take note of the coordinates of one of the tops of your lamps is located)VERY IMPORTANT

(click to show/hide)

The tip of my lamp in in the picture is at (003,006) x=3 and y=6 *remember this part

Step 3. Set up a parallel process event like so:

(click to show/hide)

Here is the code to put in there:

wallpaper_night(220)
lum_tile("lampadaire",3,6,1,255,-60,-16)

Firstly, there is the wallpaper_night(220). This is just to set up the darkness at 220 opacity.

Secondly there is the lum_tile() part and I will break down each section.
The overview is: lum_tile("name_of_light_picture",x_coordinate_of_tile, y_coordinate_of_tile, i_tile, opacity, image_x, image_y)

Phew, so let's look at these:

lum_tile() is the function that will help us do this awesome trick.
the "name_of_light_picture" is the image you're using. Located in Graphics/Pictures/lumieres.
i_tile is the map layer that your tile is on. 0 = layer 1, 1 = layer 2, 2 = layer 3.
the x_coordinate_of_tile part is the x location of a tile on your map. For instance, if it has a picture of a torch or the top of a light post, this is what you want
y_coordinate_of_tile part is the same as the x above, but applies to the y. Notice my x,y coordinates were 3,6 just like in the code. Make your coordinates work properly to suit your map
opacity is pretty basic and is a value from 0-255 as you probably know already.
image_x is just the x coordinate of the image you're using. move as needed
image_y is same as image_x above but y coordinate

Phew.

Step 4. Now that you've figured out where one lamp tip or torch flame should be at, use a proper picture. I used the "lampadaire" image for the lamp post because that's what it's made for.

If all goes well, you'll be able to post lamps over and over with no additional scripting and they will automatically be lit up. This effect will be more like a solid light. For a flickering effect, use this in opacity

255 - rand(50)     You don't have to use 50 in the rand, use whatever you want. you could even wait a few frames in the event to change the effect as well.

Hopefully you ended up with this:

(click to show/hide)

This took a while so you are welcome! Cool Enjoy.

Compatibility

May have Scene_Map or screen tinting issues.

Credits and Thanks

  • Fabien for the awesome Script
  • finalholylight for putting it here and getting permission
  • ArcaneAlchemy(myself) for my obsession to figure this out

Author's Notes
« Last Edit: July 19, 2014, 10:54:01 PM by ArcaneAlchemy »
"Wait? Do I look like a waiter?" -Kefka

Offline finalholylight

  • Awakened Visionist
  • **
  • Posts: 77
  • LV: 0
    • View Profile
Re: Dynamic Lights by Fabien 3.0(Translated) [XP]
« Reply #1 on: June 28, 2014, 10:16:29 AM »
Nice ! Mod should move this to script database and delete my old topic  :D

Offline finalholylight

  • Awakened Visionist
  • **
  • Posts: 77
  • LV: 0
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #2 on: July 14, 2014, 03:26:29 PM »
Oh no, I don't think about this before, but now, when I test demo, I found a problem.
After I call script :
@memomap=$game_map.bitmap
ecran_decor(@memomap)
decor("lampe",0,0)
$lum.lums[0].zx=$lum.lums[0].zy=0.8

then use save, error pop up:
Scene_Save line 73
No marshal_dump is defined for class Bitmap

I think script "GAME MAP BITMAP" in this demo cause this problem, but I don't know how to fix it.
I wonder if anyone can fix it.
« Last Edit: July 14, 2014, 06:04:17 PM by finalholylight »

Offline Ranquil

  • Transcended Spirit
  • ***
  • Posts: 194
  • LV: 9
  • I like turtles
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #3 on: July 14, 2014, 10:12:53 PM »
I love you.
Quote from: Some guy on Facebook
Life is like a penis. It's short but it feels so long when it gets hard.

Quote from: Steven Winterburn
Before you diagnose yourself with depression or low self-esteem, first make sure that you are not, in fact, just surrounded by assholes.

Offline ArcaneAlchemy

  • Awakened Visionist
  • **
  • Posts: 97
  • LV: 6
  • Gender: Male
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #4 on: July 16, 2014, 01:59:52 AM »
I'll take a look at that Finalholylight. I'll see if I can recreate the same problem.
« Last Edit: July 16, 2014, 02:09:17 AM by ArcaneAlchemy »
"Wait? Do I look like a waiter?" -Kefka

Offline rpg_newbie

  • Total Beginner
  • Posts: 8
  • LV: 0
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #5 on: September 19, 2014, 11:07:17 PM »
It really seems to break the save system. :( Such a shame.

"Script 'Dynamic Lights Version 3.0' line 32: NoMethodError occurred

undefined method 'lums' for nil:NilClass"

On loading save from the map after the beach. Crashes in other areas as well.
« Last Edit: September 20, 2014, 09:24:07 AM by rpg_newbie »

Offline ArcaneAlchemy

  • Awakened Visionist
  • **
  • Posts: 97
  • LV: 6
  • Gender: Male
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #6 on: September 23, 2014, 12:06:47 AM »
I don't think that it breaks the save system, but I can look into it. Have you tried applying this in your own game as well? Yeah man, it's just the Demo and just for you apparently. I think that your are trying to load a map that isn't using the same type of Lum events. I can try to recreate the scenario, but it's not happening for me yet.
« Last Edit: September 23, 2014, 12:12:26 AM by ArcaneAlchemy »
"Wait? Do I look like a waiter?" -Kefka

Offline rpg_newbie

  • Total Beginner
  • Posts: 8
  • LV: 0
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #7 on: September 23, 2014, 09:00:20 AM »
Well, with my limited scripting skills to figure the issue out/fix it I'm not going to waste my time decorating my own maps with something that breaks the original demo. (I am disappointed cause the results in the demo look very pretty.)

After quitting and re-launching the game, loading any save I made crashes the demo.
« Last Edit: September 23, 2014, 07:52:04 PM by rpg_newbie »

Offline finalholylight

  • Awakened Visionist
  • **
  • Posts: 77
  • LV: 0
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #8 on: September 23, 2014, 10:43:02 AM »
I think the reason is because : wallpaper_night(240), this use for init the night filter, and when you shut down the game, this filter will be deleled, then when you continue the game, it will cause error because that filter is NIL, how to resolve: I think you should edit in script, make some variables to save informations of that filter, when load game, these informations will be call, and call wallpaper_night(240) again to avoid error.

Offline ArcaneAlchemy

  • Awakened Visionist
  • **
  • Posts: 97
  • LV: 6
  • Gender: Male
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #9 on: September 24, 2014, 02:21:36 AM »
Okay, I'm getting the error now with this version I have on here. Let me see what I can do. You are probably right finalholylight. The entire array is nil at load it seems. Only with this demo and not with a new game. That's what's strange..

UPDATE: The first thing that I noticed is that if you open a map, then return to title and load a quest, it doesn't do it. So that's weird.

FIXED: Append this just below your 3 scripts for now. I'll add it to the code on here when I get a chance.
Code: [Select]
class Scene_Load < Scene_File
  alias dynamic_light_fix_read_save_data read_save_data
  def read_save_data(file)
    characters = Marshal.load(file)
    Graphics.frame_count = Marshal.load(file)
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    if $game_system.magic_number != $data_system.magic_number
      # マップをリロード
      $game_map.setup($game_map.map_id)
      wallpaper_night
      lum(0)
      $game_map.update   
      $game_player.center($game_player.x, $game_player.y)
    end
    $game_party.refresh
  end
end

As you can see finalholylight, it wasn't calling the needed methods between loading the map and then running it.
« Last Edit: September 24, 2014, 02:52:05 AM by ArcaneAlchemy »
"Wait? Do I look like a waiter?" -Kefka

Offline rpg_newbie

  • Total Beginner
  • Posts: 8
  • LV: 0
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #10 on: September 24, 2014, 10:26:14 AM »
Seems to fix the save issue. Good job!

Edit: Actually saving on the beach map still seems to be broken. I guess it's cause of the Avancement scene variable and multiple pages in the lighting event (EV001).

Example:
AFTER getting the flashlight when I load a save from BEFORE getting the flashlight I get the following:
 "line 172: NoMethodError occurred undefined method 'width' for 0:Fixnum"

I actually got another error like before applying the fix on some reload but I can't replicate it now. Loading a save from after getting the flashlight does not reset the protection on trees.
« Last Edit: September 24, 2014, 08:58:02 PM by rpg_newbie »

Offline ArcaneAlchemy

  • Awakened Visionist
  • **
  • Posts: 97
  • LV: 6
  • Gender: Male
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #11 on: September 24, 2014, 09:05:12 PM »
Cool. Well, I'll take another look at it later. I have a history exam today so it'll take me a bit but I hope you enjoy it as much as I do.
"Wait? Do I look like a waiter?" -Kefka

Offline rpg_newbie

  • Total Beginner
  • Posts: 8
  • LV: 0
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #12 on: September 24, 2014, 09:39:55 PM »
Ah yea, in the dark room map loading a save from AFTER switching the light on also breaks it with the old error on line 32. So maybe it didn't get resolved...

Offline ArcaneAlchemy

  • Awakened Visionist
  • **
  • Posts: 97
  • LV: 6
  • Gender: Male
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #13 on: September 24, 2014, 11:46:52 PM »
that's interesting. It's just a matter of the methods being run in the loading function I'm sure. Anyway, it's not as broken as you might think. I have used the code(as it was before) with perfect success using even more complex lighting schemes based on this code. I would also suggest that you make a demo from a fresh game for yourself rather than copying events over. That will not only help you to create even cooler maps, it will help you understand what I'm trying to convey. I could send you a demo, but I think that it will benefit you to do some footwork for yourself. Not that I won't help to fix the demo on here, but I just think that it's a good practice.

You remember when you watched the commercial for rmxp and it says "No Scripting Required" in bold letters. Well, that's not true if you want to customize stuff.

So, if you want, try and tinker with the code and if you find any solutions on your own, then that's two heads instead of just one. You might think then of giving some code back to the community.
"Wait? Do I look like a waiter?" -Kefka

KaguraM

  • Guest
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #14 on: April 21, 2015, 09:29:12 PM »
Hi,

I don't know how I can resolve this problem : "Script 'Dynamic Lights Version 3.0' line 32: NoMethodError occurred undefined method 'lums' for nil:NilClass"
I try on two differents map and nothing works. I can't go ahead with my game...

(sorry for my bad english, i'm french)
« Last Edit: April 21, 2015, 09:51:34 PM by KaguraM »

Offline ArcaneAlchemy

  • Awakened Visionist
  • **
  • Posts: 97
  • LV: 6
  • Gender: Male
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #15 on: July 21, 2015, 09:33:54 PM »
Sorry for the late reply dude. It's a pretty generic error, but I'm thinking that something is missing either in the level, or a graphic. Make sure you have the lum event on each scene and have it set to parallel process.
"Wait? Do I look like a waiter?" -Kefka

Offline cdaz

  • Trained Member
  • *
  • Posts: 15
  • LV: 1
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #16 on: August 10, 2015, 08:44:13 PM »
Demo link is gone could you re upload it please?

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Lexima Warrior
  • ****
  • Posts: 2988
  • LV: 369
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #17 on: August 10, 2015, 08:58:46 PM »
It's still there... :uhm:



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline cdaz

  • Trained Member
  • *
  • Posts: 15
  • LV: 1
    • View Profile
Re: [XP] Dynamic Lights by Fabien 3.0(Translated)
« Reply #18 on: August 11, 2015, 11:51:26 AM »
I can download it now might be my Internet problem on that time. :^_^':
Thank you by the way