Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Changing Particle Colour
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#1
Changing Particle Colour

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:
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!

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 03-15-2013, 06:40 AM by CarnivorousJelly.)
03-15-2013, 06:37 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Changing Particle Colour

Just change the colour of the particle.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-15-2013, 06:52 AM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#3
RE: Changing Particle Colour

(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.

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 03-16-2013, 02:19 AM by CarnivorousJelly.)
03-15-2013, 07:04 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Changing Particle Colour

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:
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);

Trying is the first step to success.
(This post was last modified: 03-15-2013, 07:54 AM by FlawlessHappiness.)
03-15-2013, 07:54 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#5
RE: Changing Particle Colour

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)

03-15-2013, 10:52 AM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#6
RE: Changing Particle Colour

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) :
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

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 03-15-2013, 11:04 PM by CarnivorousJelly.)
03-15-2013, 10:51 PM
Find




Users browsing this thread: 2 Guest(s)