Frictional Games Forum (read-only)
[SCRIPT] Changing Particle Colour - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Changing Particle Colour (/thread-20753.html)



Changing Particle Colour - CarnivorousJelly - 03-15-2013

I currently have a script which involves a transition from day to night. I think it looks pretty awesome but I'm biased because I made it. The only problem I have with this script is that I cannot find any ways to change the colour of particle systems. The current ones on the map are orange (because it was sunset), which looks awful with blue lighting. Kind of like a giant cloud of SunnyD.

Is there a way to change the colour without destroying/creating new particles? I would prefer for that to be my last resort.

Spoiler below!

And, if you don't mind answering one more question, is there a way to shorten this:
Code:
void OnStart()
{
    SetGlobalVarInt("NightTriggered", 0);
}

void Intro()
{
    
}

void OnEnter()
{
if (GetGlobalVarInt("NightTriggered") == 0)
    {
        FadeLightTo("PointLight_1", 0.017f, 0.060f, 0.092, 0.010f, 2.50f, 20.0f);
        FadeLightTo("PointLight_2", 0.017f, 0.060f, 0.092, 0.010f, 2.50f, 20.0f);
        FadeLightTo("PointLight_3", 0.053f, 0.058f, 0.071f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_4", 0.000f, 0.000f, 0.000f, 0.150f, 6.00f, 20.0f);
        FadeLightTo("PointLight_5", 0.000f, 0.000f, 0.000f, 0.150f, 6.00f, 20.0f);
        FadeLightTo("PointLight_6", 0.053f, 0.058f, 0.071f, 0.350f, 4.50f, 20.0f);
        FadeLightTo("PointLight_7", 0.053f, 0.058f, 0.071f, 0.350f, 2.50f, 20.0f);
        FadeLightTo("PointLight_8", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_9", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_10", 0.053f, 0.058f, 0.071f, 0.350f, 4.50f, 20.0f);
        FadeLightTo("PointLight_11", 0.017f, 0.060f, 0.092, 0.350f, 2.50f, 20.0f);
        FadeLightTo("PointLight_12", 0.000f, 0.000f, 0.000f, 0.350f, 4.00f, 20.0f);
        FadeLightTo("PointLight_13", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_14", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_15", 0.053f, 0.058f, 0.071f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_16", 0.053f, 0.058f, 0.071f, 0.150f, 3.50f, 20.0f);
        FadeLightTo("PointLight_17", 0.000f, 0.000f, 0.000f, 0.350f, 5.50f, 20.0f);
        FadeLightTo("PointLight_18", 0.053f, 0.058f, 0.071f, 0.000f, 2.50f, 20.0f);
        FadeLightTo("PointLight_19", 0.000f, 0.000f, 0.000f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_21", 0.000f, 0.000f, 0.000f, 0.150f, 4.00f, 20.0f);
        FadeLightTo("PointLight_22", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_23", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_24", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_25", 0.000f, 0.000f, 0.000f, 0.150f, 6.00f, 20.0f);
        FadeLightTo("PointLight_26", 0.053f, 0.058f, 0.071f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_27", 0.017f, 0.060f, 0.092, 0.010f, 2.50f, 20.0f);
        FadeLightTo("PointLight_28", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_29", 0.053f, 0.058f, 0.071f, 0.350f, 4.50f, 20.0f);
        
        FadeLightTo("Billboard Light", 0.053f, 0.058f, 0.071f, 0.500f, 0.25f, 20.0f);
        
        FadeLightTo("SpotLight_2", 0.061f, 0.082f, 0.106f, 0.000f, 5.50f, 20.0f);
        FadeLightTo("SpotLight_4", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_5", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_6", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_7", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_9", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
    }
    
    if (GetGlobalVarInt("NightTriggered") == 1)
    {
        FadeLightTo("PointLight_1", 0.017f, 0.060f, 0.092, 0.010f, 2.50f, 20.0f);
        FadeLightTo("PointLight_2", 0.017f, 0.060f, 0.092, 0.010f, 2.50f, 20.0f);
        FadeLightTo("PointLight_3", 0.053f, 0.058f, 0.071f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_4", 0.000f, 0.000f, 0.000f, 0.150f, 6.00f, 20.0f);
        FadeLightTo("PointLight_5", 0.000f, 0.000f, 0.000f, 0.150f, 6.00f, 20.0f);
        FadeLightTo("PointLight_6", 0.053f, 0.058f, 0.071f, 0.350f, 4.50f, 20.0f);
        FadeLightTo("PointLight_7", 0.053f, 0.058f, 0.071f, 0.350f, 2.50f, 20.0f);
        FadeLightTo("PointLight_8", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_9", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_10", 0.053f, 0.058f, 0.071f, 0.350f, 4.50f, 20.0f);
        FadeLightTo("PointLight_11", 0.017f, 0.060f, 0.092, 0.350f, 2.50f, 20.0f);
        FadeLightTo("PointLight_12", 0.000f, 0.000f, 0.000f, 0.350f, 4.00f, 20.0f);
        FadeLightTo("PointLight_13", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_14", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_15", 0.053f, 0.058f, 0.071f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_16", 0.053f, 0.058f, 0.071f, 0.150f, 3.50f, 20.0f);
        FadeLightTo("PointLight_17", 0.000f, 0.000f, 0.000f, 0.350f, 5.50f, 20.0f);
        FadeLightTo("PointLight_18", 0.053f, 0.058f, 0.071f, 0.000f, 2.50f, 20.0f);
        FadeLightTo("PointLight_19", 0.000f, 0.000f, 0.000f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_21", 0.000f, 0.000f, 0.000f, 0.150f, 4.00f, 20.0f);
        FadeLightTo("PointLight_22", 0.000f, 0.000f, 0.000f, 0.350f, 6.00f, 20.0f);
        FadeLightTo("PointLight_23", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_24", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_25", 0.000f, 0.000f, 0.000f, 0.150f, 6.00f, 20.0f);
        FadeLightTo("PointLight_26", 0.053f, 0.058f, 0.071f, 0.150f, 4.50f, 20.0f);
        FadeLightTo("PointLight_27", 0.017f, 0.060f, 0.092, 0.010f, 2.50f, 20.0f);
        FadeLightTo("PointLight_28", 0.053f, 0.058f, 0.071f, 0.350f, 3.50f, 20.0f);
        FadeLightTo("PointLight_29", 0.053f, 0.058f, 0.071f, 0.350f, 4.50f, 20.0f);
        
        FadeLightTo("Billboard Light", 0.053f, 0.058f, 0.071f, 0.500f, 0.25f, 20.0f);
        
        FadeLightTo("SpotLight_2", 0.061f, 0.082f, 0.106f, 0.000f, 5.50f, 20.0f);
        FadeLightTo("SpotLight_4", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_5", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_6", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_7", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);
        FadeLightTo("SpotLight_9", 0.122f, 0.165f, 0.211f, 0.000f, 8.50f, 20.0f);    
    }
}

void OnLeave()
{
    SetGlobalVarInt("NightTriggered", 1);
}


Thanks for your help!


RE: Changing Particle Colour - PutraenusAlivius - 03-15-2013

Just change the colour of the particle.


RE: Changing Particle Colour - CarnivorousJelly - 03-15-2013

(03-15-2013, 06:52 AM)JustAnotherPlayer Wrote: Just change the colour of the particle.

How...? The lights change colour in game due to the script I set up. I can't find a script that lets me change particle colour.

Edit: I probably worded my question oddly, so here's a video of what I did. It's still currently uploading but shouldn't take longer than 90 minutes to finish.
[video=youtube]http://youtu.be/unv4EGfkE9E[/video]

Hopefully I fixed the brightness issue with the video.


RE: Changing Particle Colour - FlawlessHappiness - 03-15-2013

No, I don't think it's possible.
If a PS is created, it's created.

So now you can destroy it, and create a new one... or better:
Create a new one where the first one was, and THEN destroy the first one.

You specify colors with:
Code:
CreateParticleSystemAtEntityExt(string& asPSName, string& asPSFile, string& asEntity, bool abSavePS,float afR, float afG, float afB, float afA, bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart, float afFadeMaxStart, float afFadeMaxEnd);



RE: Changing Particle Colour - Adrianis - 03-15-2013

Depending on which PS your trying to use, maybe it would be best with a custom particle that itself doesn't last long, then re-create it in a loop using BeeKayK's method rather than apply it in the level ed (e.g. for the floating dust particles), so that it fades out/in naturally. Otherwise if the player is right next to it they may notice sets of particles appearing/dissapearing suddenly (although I'm not sure whether destroying a particle fades it or just stops it instantly)


RE: Changing Particle Colour - CarnivorousJelly - 03-15-2013

Thanks for the help! Both the light dust and fog fade out, which looks really nice, but the new particles are not being created :\

Here's the script for the particles (based on a 20 second change for the lights) :
Code:
if (GetGlobalVarInt("NightTriggered") == 0)
{
///////script stuff that I'm not including//////
    AddTimer("NewParticles", 5.0f, "timer_particles");
    AddTimer("OldParticles", 10.0f, "timer_removeparticles");
}

void timer_particles(string &in asTimer)
{
    /////////PARTICLES///////////
    ////////////FOG//////////////
    CreateParticleSystemAtEntityExt("ParticleSystem_1", "ps_area_fog.ps", "ParticleSystem_30", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_3", "ps_area_fog.ps", "ParticleSystem_31", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_4", "ps_area_fog.ps", "ParticleSystem_32", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_5", "ps_area_fog.ps", "ParticleSystem_33", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_7", "ps_area_fog.ps", "ParticleSystem_34", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_8", "ps_area_fog.ps", "ParticleSystem_35", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_9", "ps_area_fog.ps", "ParticleSystem_36", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_10", "ps_area_fog.ps", "ParticleSystem_37", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_14", "ps_area_fog.ps", "ParticleSystem_38", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_17", "ps_area_fog.ps", "ParticleSystem_39", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_21", "ps_area_fog.ps", "ParticleSystem_40", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_23", "ps_area_fog.ps", "ParticleSystem_41", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_25", "ps_area_fog.ps", "ParticleSystem_42", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_27", "ps_area_fog.ps", "ParticleSystem_43", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_29", "ps_area_fog.ps", "ParticleSystem_44", true, 0.119f, 0.218f, 0.266f, 0.75f, true, 1.0f, 2.0f, 100.0f, 110.0f);
    
    ///////////LIGHT DUST////////////
    CreateParticleSystemAtEntityExt("ParticleSystem_12", "ps_light_dust_large.ps", "ParticleSystem_45", true, 0.122f, 0.165f, 0.211f, 0.75f, true, 0.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_13", "ps_light_dust_large.ps", "ParticleSystem_46", true, 0.122f, 0.165f, 0.211f, 0.75f, true, 0.0f, 2.0f, 100.0f, 110.0f);
    CreateParticleSystemAtEntityExt("ParticleSystem_15", "ps_light_dust_large.ps", "ParticleSystem_47", true, 0.122f, 0.165f, 0.211f, 0.75f, true, 0.0f, 2.0f, 100.0f, 110.0f);
}

void timer_removeparticles(string &in asTimer)
{
    DestroyParticleSystem("ParticleSystem_1");
    DestroyParticleSystem("ParticleSystem_3");
    DestroyParticleSystem("ParticleSystem_4");
    DestroyParticleSystem("ParticleSystem_5");
    DestroyParticleSystem("ParticleSystem_7");
    DestroyParticleSystem("ParticleSystem_8");
    DestroyParticleSystem("ParticleSystem_9");
    DestroyParticleSystem("ParticleSystem_10");
    DestroyParticleSystem("ParticleSystem_14");
    DestroyParticleSystem("ParticleSystem_17");
    DestroyParticleSystem("ParticleSystem_21");
    DestroyParticleSystem("ParticleSystem_23");
    DestroyParticleSystem("ParticleSystem_25");
    DestroyParticleSystem("ParticleSystem_27");
    DestroyParticleSystem("ParticleSystem_29");
    
    DestroyParticleSystem("ParticleSystem_12");
    DestroyParticleSystem("ParticleSystem_13");
    DestroyParticleSystem("ParticleSystem_15");
}

I have it labelled so that the particles numbered 30-47 are the new ones created and anything below that is deleted (there are some holes in my numbers from creating excess particle systems and deleting them).

Other than the lack of new particles, it looks really nice! Thanks again Smile