MZ - [MZ & MV v1.9.7] Shora Lighting & Shadow System

● ARCHIVED · READ-ONLY
Started by Shora 656 posts Page 16 of 33 View original ↗
  1. ShadowDragon said:
    best way is for a conditional branch,
    if switch A is ON / or if button X is pressed
    turn torch ON
    else
    turn torch OFF
    end

    that is the most basic settings, so why 2 common events?
    that's why i've try at first, and the problem is my light stay only few second (like 1 or 2sec if im lucky)
    If i hold the button, it work, but i want a switch, i want to press once the key and the light stay ON, press the key again and the light go OFF
    And this is what i dont understand in my event, it's supposed to do it, no ?

    1667519753878.png

    Sorry, it's in french, but im sure its understandable.

    @AeroFunk80 i dont have this plugin, i cant do it without it ?
  2. Kazuo said:
    that's why i've try at first, and the problem is my light stay only few second (like 1 or 2sec if im lucky)
    If i hold the button, it work, but i want a switch, i want to press once the key and the light stay ON, press the key again and the light go OFF
    And this is what i dont understand in my event, it's supposed to do it, no ?

    View attachment 244370

    Sorry, it's in french, but im sure its understandable.

    @AeroFunk80 i dont have this plugin, i cant do it without it ?
    Oh, yes, you'd need a plugin for what I suggested. Sorry. I would recommend it (not that you have to). You can actually get that plus 40+ more for just $10 on Itch.

    I believe you can still do it without the plugin, but you wouldn't be able to use any button in your common event. RM MV only allows you to set a condition for certain keys (space, enter, etc). Also... since I don't understand the language...

    I know 'Declencheur' is the trigger "Parallel." Your switch is one thing and the conditional branch is another. What conditional branch are you using? And what key are you assigning to activate the flashlight/torch?
  3. 1667564540321.png

    I use "page down" as key, its the basic one from RPG maker, i didnt change any key for the moment
  4. double check the demo where the flashlight is given,
    it might give you the answer you miss, and you can turn off
    and on the flashlight if the player has the item, so not sure
    why you "add item +1" as this normally doesn't show the light
    I believe.
  5. Kazuo said:
    View attachment 244391

    I use "page down" as key, its the basic one from RPG maker, i didnt change any key for the moment
    I tried a couple things and couldn't figure out/get it to work using a parallel common event. Problem with having a parallel event always running to turn a torch on/off is that... it's always running, plus pressing the button once causes a weird glitch.

    I'm not sure if it's within your budget, but I'd highly recommend getting Yanfly's Button Common Event. It'll make what you're trying to achieve so much easier, and I can share what I did for mine with you, as well.

    If you're looking for a way to do this without getting any plugins, I'd recommend posting your question in The Legacy Engine Support forum and then the MV section. I'm sure someone in there may have a solution/suggestion for what you're trying to do without a plugin. You could start there. More people will be able to help if you ask your specific question in that section. Posting it in here just has it buried, so only myself and Shadow have noticed it. Someone else might be able to help by posting in the support channel.
  6. ShadowDragon said:
    double check the demo where the flashlight is given,
    it might give you the answer you miss, and you can turn off
    and on the flashlight if the player has the item, so not sure
    why you "add item +1" as this normally doesn't show the light
    I believe.

    The demo is basically what ive done, it add "flashlight+1" in inventory, and stay ON until you talk again to the npc who put flashlight-1 off inventory :/

    I guess i've to try these plugin tho, i'll come back with more news when it work :D
  7. in the demo when checked, the npc " is giving him" the flashlight,
    which is differently when you "obtained" a flashlight.

    if you gain the item, and turn it off with -1, you cannot acces the flashlight
    to turn it on if it is used :)

    so enable and diable light is differently.

    I will check the plugin as I think you can enable light sourch "flashlight"
    to ON and OFF, as you can turn off the entire plugin on and off as well.
    event light easely with selfswitch ON/OF or by global if you turn off everything.

    as you create a struct with custom lights, you can probably control each light
    the same, but you also need to remember if you make duplicates of the flashlight
    or is used that those are also goes OFF, so you can probably make "pFlashLight"
    for the player item, but the same effect as "flashlight" if used by multiple events.
  8. Kazuo said:
    The demo is basically what ive done, it add "flashlight+1" in inventory, and stay ON until you talk again to the npc who put flashlight-1 off inventory :/

    I guess i've to try these plugin tho, i'll come back with more news when it work :D
    Let me know if you get the button common event plugin. If you need help mapping out your torch/flashlight even there, I can send you what I've done.
  9. I'm back !

    So i've found the Visustella button common event (the same than Yanfly, but for MZ)
    And it work like exactly like you say, i can turn on/off the light with the shotcut i want.

    Thank you
  10. Kazuo said:
    I'm back !

    So i've found the Visustella button common event (the same than Yanfly, but for MZ)
    And it work like exactly like you say, i can turn on/off the light with the shotcut i want.

    Thank you
    Oh, I'm sorry. Not sure why I thought you were using MV. Glad to hear that, plus you have more options regarding which keyboard key you want to use, too.
  11. 1668556868761.png
    Hi all, was wondering how to get the light to not go on top of the player here? thanks
  12. sorencite said:
    View attachment 245247
    Hi all, was wondering how to get the light to not go on top of the player here? thanks
    I'm pretty sure we can't, because the light work as picture i guess.
  13. even if you could, it will be also below the enemy and other tiles which are on normal.
    so it could be doable, but it require some js knowledge as it wont be to for the actor
    alone or set the z-index higher.

    I dont think it would be worth the trouble though.
  14. I'm migrating from Community Lighting. I can't find a way in this plugin to attach light to entire region ID. Is there something I'm missing, or is that feature not supported?
  15. I believe I have gotten region-based lighting working with one big caveat: I had to turn off shadows for all region-based light, because it was displaying wonky and I couldn't for the life of me figure out how to correct it (it is something to do with the displayX and displayY upon entering a map affecting how the shadow geometry gets applied to the light).

    So, first, I re-enabled all of the static light code in the plugin. I also had to modify LightingLayer.addStaticLight a bit, because I wanted to pass in tile coords rather than screen coords:

    JavaScript:
    addStaticLight(options) {
        const tileWidth = $gameMap.tileWidth();
        const tileHeight = $gameMap.tileHeight();
        const displayX = $gameMap.displayX();
        const displayY = $gameMap.displayY();
    
        options.x = (options.x * tileWidth) + (tileWidth / 2) + displayX;
        options.y = (options.y * tileHeight) + (tileHeight / 2) + displayY;
        options.shadow = false;
    
        const light = new LightingSprite(options);
        light.renderable = true;
    
        light.texture.baseTexture.premultipliedAlpha = false;
    
        if (Shora.EngineVersion === 'MV') {
            light.blendMode = PIXI.BLEND_MODES.NORMAL; // TODO
        }
    
        Graphics.app.renderer.render(light, this._staticLighting, this._clearStaticLayer);
        this._clearStaticLayer = false;
    
        // lights will get automatically destroyed by texture collector
        light.destroy();
    }

    After that, it was a simple matter of making my own plugin to walk a map searching for a particular region ID and add static light to all matching tiles:

    JavaScript:
    PluginManager.registerCommand("RegionLighting", "activate", args => {
        const regionId = Number(args.regionId);
        const lightRef = String(args.lightRef);
    
        const mapWidth = $gameMap.width();
        const mapHeight = $gameMap.height();
    
        for (let x = 0; x < mapWidth; x++) {
            for (let y = 0; y < mapHeight; y++) {
                if ($gameMap.regionId(x, y) === regionId) {
                    $gameLighting.addStaticLight(x, y, lightRef);
                }
            }
        }
    });

    This seems to work correctly. It's a bummer that I can't get shadows against this light, but since I'm using this for more of ambient glow on certain tiles, it's not the end of the world. It certainly beats having to switch everything back to Community Lighting to get this feature.

    It would be great to get a plugin update that adds static light properly with shadows enabled!
  16. Shora,
    I can't seem to get shadows to update after I have changed the region ID in game with events. Is this plugin set to re evaluate shadows after there has been region ID changes in game? I have tested it on my end by adding lights that turn on when the region ID changes. The lights turn on, but the shadow still stays.
  17. @Ninja777 how do you change region ID? if you stay on the same map
    and does work after you change maps, you can use a map update request,
    as I use it on my main project in a mechanic, so I think it should work the
    with region based on the same map.
  18. ShadowDragon said:
    @Ninja777 how do you change region ID? if you stay on the same map
    and does work after you change maps, you can use a map update request,
    as I use it on my main project in a mechanic, so I think it should work the
    with region based on the same map.
    I had that thought, so I added in a map transfer or a map update using
    $gameMap.refresh()
    The only thing that works is saving and closing or a complete map change then return.
  19. @Ninja777 for MV, it is this scriptcall:
    $gameMap.requestRefresh();

    for MZ, if might be refresh or a slightly differently as you are mostly "request"
    it to refresh.

    it might be the correct call for MZ you used, as it would be the same as transfer
    and going back, if you need to compleetly exit the game and re-enter it, than
    I dont know.
  20. ShadowDragon said:
    @Ninja777 for MV, it is this scriptcall:
    $gameMap.requestRefresh();

    for MZ, if might be refresh or a slightly differently as you are mostly "request"
    it to refresh.

    it might be the correct call for MZ you used, as it would be the same as transfer
    and going back, if you need to compleetly exit the game and re-enter it, than
    I dont know.
    I tried your alternate version of the script call, but it didn't work either. The lighting script must be set to only evaluate on exiting and re entering a map. I have a rigged event call that transfers the player out and then back. This turns the screen black for a moment, but gets the script to refresh.

    To answer your previous questions, I use this for changing the Region ID in MZ
    RED_SetRegionId/RED_SetRegionID.js at master · Hikitsune-Red/RED_SetRegionId