warzone2100/data/script/text/cam2daynight.slo

65 lines
1.3 KiB
Plaintext

// Weather and day/night script for Cam2 (Urban)
//daytime colour
public int Rstart, Gstart, Bstart;
public int Rend, Gend, Bend;
public int Steps;
private int count, Rdiff, Gdiff, Bdiff, Rnow, Gnow, Bnow;
trigger delayTrig(every, 10); //change fog every 1 second
//weather stuff
/* Triggers */
trigger startTrig(every, 500);
trigger stopTrig(every, 1000);
/* Events */
event weatherStop;
event startup(CALL_GAMEINIT)
{
setCampaignNumber(2);
setBackgroundFog(TRUE); //set fog on
setDepthFog(TRUE);
setFogColour(Rstart, Gstart, Bstart); //set fog to start colour
Rdiff = Rstart - Rend;
Gdiff = Gstart - Gend;
Bdiff = Bstart - Bend;
playCDAudio(1);
setEventTrigger(startup, inactive);
}
event changeFog(delayTrig)
{
Rnow = Rstart - (count * Rdiff / Steps);
Gnow = Gstart - (count * Gdiff / Steps);
Bnow = Bstart - (count * Bdiff / Steps);
setFogColour(Rnow, Gnow, Bnow);
count = count + 1;
if (count > Steps)
{
//stop change
count = 0;
setEventTrigger(changeFog, inactive);
}
}
//Weather effects need adding!
event weatherStart(startTrig)
{
if (random(10)< 5)
{
setRain(TRUE);
setEventTrigger(weatherStop, stopTrig);
setEventTrigger(weatherStart, inactive);
}
}
event weatherStop(inactive)
{
if (random(10)< 4)
{
setRain(FALSE);
setEventTrigger(weatherStart, startTrig);
setEventTrigger(weatherStop, inactive);
}
}