Skip to content

Nightclub FX - Strobe light script

HaddoxHaddox Member Posts: 9
Hello, I'm not even sure if this idea is possible to do, so I'm currently trying to figure out different ways to solve/work around this concept in case it's impossible.

The Situation/Problem:
I'm going to have a nightclub in one of my modules and I'm trying to add a bit more life and immersion into the milieu atm. So the basic area lighting and music are in place, and I've got dancing patrons as well. However I'd love to add some sort of visual fx, I've got some fog placeables for a bit of added smoke which looks great. However, I'd love for there to be some sort of strobe-light FX for the dance floor as well.

I.e. flashing and flickering lights.

One Idea I have is if there is a script to add and remove light properties to invisible objects, maybe even to the dancing NPCs as well as a way to create a "spotlight" effect. Any other suggestions and ways to tackle this or inputs are greatly appreciated by a noob like myself.

Another idea is to somehow trigger different spells fx-s in order to add a bit of visual fx. It would actually work well with the in-game world which is a bit of sci-fantasy.

Is anything like this possible and if so, how the heck do I do it?? :sweat_smile:

Comments

  • ForSeriousForSerious Member Posts: 455
    I've never tried it out, but I noticed they added functions to change the tile light colors.
    void SetTileMainLightColor(location lTileLocation, int nMainLight1Color, int nMainLight2Color)
    void SetTileSourceLightColor(location lTileLocation, int nSourceLight1Color, int nSourceLight2Color)
    

    You could make a few calls to change those colors in like the area heart beat script.
  • HaddoxHaddox Member Posts: 9
    edited May 11
    I went about it a different way this time, I made it so that when a player enters the area a script and a corresponding invisible placeable adds a light effect to that placeable.

    Being a newbie I managed by splicing GPT-3.5 suggestions with my low-level knowledge to throw this together (ignore the debug stuff)

    This way one can add as many placeables as needed for a bit of a flashing effect. Adding an offset between -0.3 to +0.3 to each placeable script adds the randomness and the business needed;

    For example:
    strobing_fx_001 has a 0.5 duration so then strobing_fx_002 could then have a 0.4 or a 0.6 so that they fire out of sync from one another, then apply the same method for 3,4,5,x)


    OnEnter Script:
    void main()
    {
        object oEnteringObject = GetEnteringObject();
        SendMessageToPC(oEnteringObject, "Entering the area...");
    
        if (GetIsPC(oEnteringObject) && !GetIsDM(oEnteringObject))
        {
            // Get the area where the player is entering
            object oArea = GetArea(oEnteringObject);
    
            // Find and handle each strobe light placeable individually
    
            // Strobe light 1
            object oLight1 = GetObjectByTag("strobe_plc_001");
            if (GetIsObjectValid(oLight1))
            {
                SendMessageToPC(oEnteringObject, "Strobe light object 1 found.");
                SetLocalInt(oLight1, "start_strobe_001", 1);
                ExecuteScript("strobing_fx_001", oLight1);
            }
            else
            {
                SendMessageToPC(oEnteringObject, "Error: Strobe light object 1 not found.");
            }
    
            // Strobe light 2
            object oLight2 = GetObjectByTag("strobe_plc_002");
            if (GetIsObjectValid(oLight2))
            {
                SendMessageToPC(oEnteringObject, "Strobe light object 2 found.");
                SetLocalInt(oLight2, "start_strobe_002", 1);
                ExecuteScript("strobing_fx_002", oLight2);
            }
            else
            {
                SendMessageToPC(oEnteringObject, "Error: Strobe light object 2 not found.");
            }
    
            // Strobe light 3
            object oLight3 = GetObjectByTag("strobe_plc_003");
            if (GetIsObjectValid(oLight3))
            {
                SendMessageToPC(oEnteringObject, "Strobe light object 3 found.");
                SetLocalInt(oLight3, "start_strobe_003", 1);
                ExecuteScript("strobing_fx_003", oLight3);
            }
            else
            {
                SendMessageToPC(oEnteringObject, "Error: Strobe light object 3 not found.");
            }
    
            // Strobe light 4
            object oLight4 = GetObjectByTag("strobe_plc_004");
            if (GetIsObjectValid(oLight4))
            {
                SendMessageToPC(oEnteringObject, "Strobe light object 4 found.");
                SetLocalInt(oLight4, "start_strobe_004", 1);
                ExecuteScript("strobing_fx_004", oLight4);
            }
            else
            {
                SendMessageToPC(oEnteringObject, "Error: Strobe light object 4 not found.");
            }
    
            // Strobe light 5
            object oLight5 = GetObjectByTag("strobe_plc_005");
            if (GetIsObjectValid(oLight5))
            {
                SendMessageToPC(oEnteringObject, "Strobe light object 5 found.");
                SetLocalInt(oLight5, "start_strobe_005", 1);
                ExecuteScript("strobing_fx_005", oLight5);
            }
            else
            {
                SendMessageToPC(oEnteringObject, "Error: Strobe light object 5 not found.");
            }
        }
    }
    

    The individual script per placeable (in this example strobing_fx_001):
    void ApplyStrobeEffect(object oTarget, int nEffectID, float fDuration)
    {
        effect eStrobe = EffectVisualEffect(nEffectID);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eStrobe, oTarget, fDuration);
    }
    
    void main()
    {
        object oLight = GetObjectByTag("strobe_plc_001");
        int nStartStrobe = GetLocalInt(oLight, "start_strobe_001");
       // SendMessageToPC(GetFirstPC(), "Strobe effect script triggered. Start strobe = " + IntToString(nStartStrobe));
    
        if (nStartStrobe == 1)
        {
            int nState = GetLocalInt(oLight, "effect_state_001");
            if (nState == 0)
            {
                ApplyStrobeEffect(oLight, VFX_DUR_LIGHT_WHITE_20, 0.5);
                SetLocalInt(oLight, "effect_state_001", 1);
               // SendMessageToPC(GetFirstPC(), "Strobe effect applied.");
            }
            else
            {
                SetLocalInt(oLight, "effect_state_001", 0);
               // SendMessageToPC(GetFirstPC(), "Strobe effect cleared.");
            }
            DelayCommand(0.5, ExecuteScript("strobing_fx_001", oLight));
        }
        else
        {
            SendMessageToPC(GetFirstPC(), "Strobe effect not started due to condition.");
        }
    }
    
  • HaddoxHaddox Member Posts: 9
    edited May 11
    Here's an .erf with my solution for anybody that wants to try it out :)
Sign In or Register to comment.