OcRam - Lights plugin (MZ/MV)

● ARCHIVED · READ-ONLY
Started by OcRam 300 posts Page 11 of 15 View original ↗
  1. OpenTangent said:
    Thanks for the forceDayPhase() function, it gave me an idea to create a nightvision ability and it's working really well. However, it would be nice to explicitly set the fade speed in forceDayPhase() since my dayphase effect transition time is set to 960 frames which is far too long for turning night vision off. This isn't absolutely needed but would be nice to have a smooth transition between darkness and nightvision.

    On another topic I am using isPlayerInLightRadius() as the basis of a thieving system. At the moment it is triggered before the player is lit. I would like to have it be more lenient so that it only returns true if the player is fully lit. Is there a way for me to do that? See example below:

    View attachment 182754
    Hi,

    $gamePlayer._lightData should return null or undefined if player is not lit.

    So: ($gamePlayer._lightData && event.isPlayerInLightRadius()) returns true only when player has light and is in radius.
  2. Hmm, $gamePlayer._lightData seems to have inconsistent results for me. I read up on the best way to check if a value is not null and tried the following:
    JavaScript:
    typeof $gamePlayer._lightData === "object" && !$gamePlayer._lightData
    Still didn't work consistently
  3. OpenTangent said:
    Hmm, $gamePlayer._lightData seems to have inconsistent results for me. I read up on the best way to check if a value is not null and tried the following:
    JavaScript:
    typeof $gamePlayer._lightData === "object" && !$gamePlayer._lightData
    Still didn't work consistently
    It might be that player actually has _lightData, but it's type is 0...
  4. I ended up using isPlayerInLightRadius() in conjunction with YanFly's Event Encounter Aid plugin. The player is still being encountered slightly beyond the light radius but at least now it's only when the enemy is facing the player. Players will learn not to get too close to the light when the enemy is looking your way.
  5. Hello,

    thanks for this nice plugin. I build a stealth-game with it where guards with a cone of sight (=OcRam lights effect) are chasing the player. I'm using the same code like the "Sentry" in your Demo for it (this.event().isPlayerInLightRadius())

    Problem: As soon as I add more then 1 guard the cone of sight in only displayed at the newest guard :-( The guards still react as soon as the see the player, but the cone is not shown. I even copy&past the whole "Sentry" event from your demo into my project and still have this problem (in your demo it is no problem to have multiple "Sentry"-Events)
  6. Zaphitos said:
    Hello,

    thanks for this nice plugin. I build a stealth-game with it where guards with a cone of sight (=OcRam lights effect) are chasing the player. I'm using the same code like the "Sentry" in your Demo for it (this.event().isPlayerInLightRadius())

    Problem: As soon as I add more then 1 guard the cone of sight in only displayed at the newest guard :-( The guards still react as soon as the see the player, but the cone is not shown. I even copy&past the whole "Sentry" event from your demo into my project and still have this problem (in your demo it is no problem to have multiple "Sentry"-Events)
    Thank you for the message,

    If it can't be replicated in new or in my demo -project. It is almost certainly a plugin conflict. Turn them off one by one to pin point the plugin that causes this.
  7. OcRam said:
    Thank you for the message,

    If it can't be replicated in new or in my demo -project. It is almost certainly a plugin conflict. Turn them off one by one to pin point the plugin that causes this.
    Hey,

    I'm super sorry for the work that I caused. It turned out that it was just my incompetence as a beginner ^^ I forgot the Plugin command BG Color. Nevertheless, I wonder why it worked at all (even if it's only for 1 guard) without setting the BG tint ^^
  8. Zaphitos said:
    Hey,

    I'm super sorry for the work that I caused. It turned out that it was just my incompetence as a beginner ^^ I forgot the Plugin command BG Color. Nevertheless, I wonder why it worked at all (even if it's only for 1 guard) without setting the BG tint ^^
    No problem. And I'm glad you got it all figured out! :)
  9. I have another little problem and I'm too noob'ish to find a solution :-(
    I'm using "this.event().isPlayerInLightRadius()" to check if the player is seen by my guards. Is there a way to check if another event is in the light radius?

    What I want to do is that Guards start to roam around if they discover a dead colleague
  10. Thank you for the message,

    Following snippet gets everything in light radius:
    Code:
    this.event().getObjectsInLightRadius().forEach(obj => {
    console.log(obj);
    });
  11. A follow up to my previous issue where [isPlayerInLightRadius] was returning {true} even when the player was beyond the light radius. In the function I changed [Math.ceil] to [Math.floor] for [var r]. That seems like it has fixed my problem. [isPlayerInLightRadius] now only returns {true} if the player is (at least slightly) illuminated.

    JavaScript:
    // Is player or follower in radius of this event?
        Game_Event.prototype.isPlayerInLightRadius = function () { // Must have valid light source - else will return always false
            if (!$gameMap) return false;
            if (!this._lightData || this._lightData[0]._lightType == 0) return false;
            var ld = this._lightData[0]; var r = Math.floor(ld._radius / 48);
            var in_range = _this.isInRange(this._x, this._y, $gamePlayer._x, $gamePlayer._y, r, ld._lightExParams.degrees, this._direction);
            if (in_range) return true; var tc = this;
            $gamePlayer._followers.visibleFollowers().forEach(function (f) {
                if (_this.isInRange(tc._x, tc._y, f._x, f._y, r, ld._lightExParams.degrees, tc._direction)) in_range = true; return;
            }); return in_range;
        };

    Untitled2.png
  12. I'm now using the light plugin in addition of the Time System plugin.

    Before the update, the light data was preserved between maps (meaning that I don't have to reapply it)

    Now when I'm in a cave, though I've set the <indoors> flag in the maps note, when I'm changing map, the day phase tint takes place.

    Disabling Time System plugin solves the problem. any ideas ?

    Edit : I just looked at the code, and I think it's something tied to the _forcedTint_OC variable

    This bit :


    JavaScript:
    if (_useTimeSystem) { // Use OcRam_Time_System?
                if (!$gameMap._forcedTint_OC) {
                    if (_isIndoors && !_useTintIndoors) {
                        _this.debug("Indoors", "NO TINT!");
                        if (_intervalHandle != null) {
                            window.clearInterval(_intervalHandle);
                            _intervalHandle = null; // Let's clear this interval
                        } _tintBG = '#ffffffff'; _currentTintColor = hexToRGBA("#ffffffff");
                    } else {
                        if (!_this._menuCalled) {
                            _prevDayPhase = -1; triggerDayPhase(true);
                        }
                    }
                }
            }

    Checks if I'm using the time system, and if I am, when changing maps, either I'm outside and it uses the dayphase tint, or I'm indoors with autotint disabled and the color is #ffffffff

    It normally wouldn't happen if _forcedTint_OC was "true" but on map transfer, it's set back to false.

    I'll get back to you if I get more info about this (and eventually a fix)

    EDIT : Additionnally, when I open and close the Menu Window, the map gets brighter


    Before
    1620663105665.png


    After
    1620663124785.png


    If I idle inside the map, the tint slowly transitions between the two screens above. The two plugins are up to date.
  13. belatucadrus said:
    I'm now using the light plugin in addition of the Time System plugin.

    Before the update, the light data was preserved between maps (meaning that I don't have to reapply it)

    Now when I'm in a cave, though I've set the <indoors> flag in the maps note, when I'm changing map, the day phase tint takes place.

    Disabling Time System plugin solves the problem. any ideas ?

    Edit : I just looked at the code, and I think it's something tied to the _forcedTint_OC variable

    This bit :


    JavaScript:
    if (_useTimeSystem) { // Use OcRam_Time_System?
                if (!$gameMap._forcedTint_OC) {
                    if (_isIndoors && !_useTintIndoors) {
                        _this.debug("Indoors", "NO TINT!");
                        if (_intervalHandle != null) {
                            window.clearInterval(_intervalHandle);
                            _intervalHandle = null; // Let's clear this interval
                        } _tintBG = '#ffffffff'; _currentTintColor = hexToRGBA("#ffffffff");
                    } else {
                        if (!_this._menuCalled) {
                            _prevDayPhase = -1; triggerDayPhase(true);
                        }
                    }
                }
            }

    Checks if I'm using the time system, and if I am, when changing maps, either I'm outside and it uses the dayphase tint, or I'm indoors with autotint disabled and the color is #ffffffff

    It normally wouldn't happen if _forcedTint_OC was "true" but on map transfer, it's set back to false.

    I'll get back to you if I get more info about this (and eventually a fix)

    EDIT : Additionnally, when I open and close the Menu Window, the map gets brighter


    Before
    View attachment 188912


    After
    View attachment 188913


    If I idle inside the map, the tint slowly transitions between the two screens above. The two plugins are up to date.
    Thank you for the message,

    Sounds like you need to press 'ok' for EACH updated plugin parameters to re-validate their values.

    Especially those "indoors tint" related parameters.
  14. I reloaded the plugin, made a fresh new game with these parameters (Lights Plugin)

    Spoiler
    1620731617744.png


    And these (Time Plugin)

    Spoiler
    1620731665243.png

    Time plugin was put above Lights plugin.

    I put this command in an autorun event in a <indoors> map :

    1620732481901.png

    The map tints properly, and the debug console acknowledges that i'm in an <indoors> map and no auto tint is needed

    1620732460166.png


    However, when I change maps to another <indoors> map, the debug console detects it and says "NO TINT !" again, but still changes the tint of the map back (but no "OcRam_Lights (v2.15) : Tint started! #xxxxxx" message like when I launch the game

    EDIT : Disabled all the other plugins, only Lights and Time plugin are now enabled

    EDIT : tried to play with the parameters. Looks like when the indoors autotint is enabled, it tints properly with the dayphase tints (expected behavior) but if indoors autotint is disabled, the map tint is somehow reset on map transfer, without debugging message
  15. belatucadrus said:
    I reloaded the plugin, made a fresh new game with these parameters (Lights Plugin)

    Spoiler
    View attachment 188989


    And these (Time Plugin)

    Spoiler
    View attachment 188990

    Time plugin was put above Lights plugin.

    I put this command in an autorun event in a <indoors> map :

    View attachment 188992

    The map tints properly, and the debug console acknowledges that i'm in an <indoors> map and no auto tint is needed

    View attachment 188991


    However, when I change maps to another <indoors> map, the debug console detects it and says "NO TINT !" again, but still changes the tint of the map back (but no "OcRam_Lights (v2.15) : Tint started! #xxxxxx" message like when I launch the game

    EDIT : Disabled all the other plugins, only Lights and Time plugin are now enabled

    EDIT : tried to play with the parameters. Looks like when the indoors autotint is enabled, it tints properly with the dayphase tints (expected behavior) but if indoors autotint is disabled, the map tint is somehow reset on map transfer, without debugging message
    Thank you for the message,

    Ok in that setup "vanilla" tint is untouched. So if you use "vanilla" tint you need to manage it manually.

    And "light_bg" plugin command overrides any (light layer) auto-tinting.
  16. OcRam said:
    Thank you for the message,

    Ok in that setup "vanilla" tint is untouched. So if you use "vanilla" tint you need to manage it manually.

    And "light_bg" plugin command overrides any (light layer) auto-tinting.

    Yes, the vanilla tint works well, the main problem is when using both time system and light system, the "light_bg" data is reset with each map transfer. That's already the case with vanilla tint screen, and I already somehow managed that, but before downloading the time system plugin, I have put one "light_bg" command in zone entrances and exits, because the light data was kept between maps

    Now when time system is enabled, light_bg data is reset when changing maps within the same zone

    For now, my workaround is to set a variable in $gameScreen to true the first time the player enters an a map with the <indoors> tag, and I set it to false the first time the player enters a map without the <indoors> tag

    Then in map transfer, the value of _forcedTint_OC is forced to true when changing map if $gameScreen._indoors is true aswell (because if auto tint is disabled indoors, I guess the lighting is only managed by plugin commands)

    Doing like this, it works. Light data is preserved between <indoors> maps.
  17. belatucadrus said:
    Yes, the vanilla tint works well, the main problem is when using both time system and light system, the "light_bg" data is reset with each map transfer. That's already the case with vanilla tint screen, and I already somehow managed that, but before downloading the time system plugin, I have put one "light_bg" command in zone entrances and exits, because the light data was kept between maps

    Now when time system is enabled, light_bg data is reset when changing maps within the same zone

    For now, my workaround is to set a variable in $gameScreen to true the first time the player enters an a map with the <indoors> tag, and I set it to false the first time the player enters a map without the <indoors> tag

    Then in map transfer, the value of _forcedTint_OC is forced to true when changing map if $gameScreen._indoors is true aswell (because if auto tint is disabled indoors, I guess the lighting is only managed by plugin commands)

    Doing like this, it works. Light data is preserved between <indoors> maps.
    Ok now I think I understood the issue. I will check that if <indoor> autotint is set false in plugin parameters it should not meddle with existing light layer tint.

    Anyways I'm glad you got it working!
  18. I'm sorry to bother you again, but I came across another problem...

    Before posting, I of course reverted all the edits I made and I'm using an untouched version of your light plugin.

    I have a "dream" cutscene in my game, and when it ends, the screen fades to white. I'm using the vanilla tint to perform that.

    However, the screen tint never happens, and stays the same.

    When I re-downloaded your plugin and launched the game with the default parameters, the tint works fine, however when I set my own parameters, the vanilla tint fails when I call it.

    EDIT : Disabling the time system plugin solves the problem. So I thought it might be tied to the <indoors> flag, so I removed it from the cutscene map notetag (as I didn't want the screen to be auto-tinted during it), and it works.

    After testing all combinations. The only situation where vanilla tint doesnt work is when :

    - Lights Plugin is ON
    - Time_Plugin is ON
    - The map is flagged <indoors>
    - The Player Light Type is set to 0 (None)
    -
    Lights Plugin parameter "Use Tint Indoors" is set to false (setting it to true solves it)

    Commenting out this line at 1066

    JavaScript:
    _tintBG = '#ffffffff'; _currentTintColor = hexToRGBA("#ffffffff");

    solves it too (but I reverted it back to normal as it looks like important part of the function)
  19. noob question, how do I increase intensity of the light. I find it too dim
  20. bighoncho said:
    noob question, how do I increase intensity of the light. I find it too dim
    Thank you for the message,
    If you mean light bg it can be changed via plugin parameters and/or light bg plugin command.

    All light color values are defined as RGBA hex for example brightest light you can get is #ffffffff

    And if Time_System is used you might not want to use Time_System tint at all it's also a plugin parameter. And "Vanilla" tint layer is beneath OcRam_Lights layer.