Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → ok.... i am compleatly carped here guys....
ok.... i am compleatly carped here guys....
2003-05-28, 12:10 PM #1
i got this script.. its um.. well cool. it just dosent work.
as your clearence is B4 you are alowed to see and fix it.. and know what it dose.. jsut not know why i need it... commader says so... sry [http://forums.massassi.net/html/frown.gif]

(makes day/night/rain/fog/thunder/lightning/+more if it workes ever)

Code:
# Jedi Knight Cog Script
#
# day.cog
#
# creates day and night, as well as surface rain.(and fog)
# thanks to DSLS_DeathSythe for his SURF_RAIN01.COG, the base of the rain in this.
#
# This Cog is Not supported by LucasArts Entertainment Co
flags=0x240
#=====
symbols
#-----                                                                        
message      startup                                                          
message      timer                                                            
flex         random=0                           local                         
flex         daynight=32400                                                   
flex         addlight=0.8                                                     
sector       i=0                                local                         
surface      x=0                                local                         
material     mat                                local                         
material     day                                                              
material     dusk                                                             
material     dawn                                                             
material     night                                                            
int          daya=0                             local                         
int          debug=0                                                          
flex         sec_lite=0.0                       local                         
int          fogr                                                             
int          fogg                                                             
int          fogb                                                             
int          effecthandle                       local                         
#-----                                                                        
flex         x_maxr=1.0                                                       
flex         y_maxr=1.0                                                       
template     rain_tpl=+repeaterball             local                         
template     train_tpl=+repeaterball                                          
template     tunder_tpl=+repeaterball                                         
template     lightning_tpl=+repeaterball                                      
template     fog_tpl=+repeaterball                                            
flex         p=0.0                                                            
flex         y=90.0                                                           
flex         maxrain_delay=0.5                                                
int          rain_drips=3                                                     
flex         range=3.0                                                        
#-----                                                                        
thing        player=-1                          local                         
vector       pyr_vec                            local                         
surface      a                                  local                         
int          d=0                                local                         
vector       surf_vec01                         local                         
vector       rand_Svec01                        local                         
sector       surf_sec01                         local                         
flex         surf_Vx01                          local                         
flex         surf_Vy01                          local                         
flex         surf_Vz01                          local                         
flex         delay1=0.0                         local                         
surface      b                                  local                         
int          e=0                                local                         
vector       surf_vec02                         local                         
vector       rand_Svec02                        local                         
sector       surf_sec02                         local                         
flex         surf_Vx02                          local                         
flex         surf_Vy02                          local                         
flex         surf_Vz02                          local                         
flex         delay2=0.0                         local                         
surface      c                                  local                         
int          f=0                                local                         
vector       surf_vec03                         local                         
vector       rand_Svec03                        local                         
sector       surf_sec03                         local                         
flex         surf_Vx03                          local                         
flex         surf_Vy03                          local                         
flex         surf_Vz03                          local                         
flex         delay3=0.0                         local                         
#-----                                                                        
end                                                                           
#=====
code
#-----
startup:
Sleep(2.0);
player = GetLocalPlayerThing();
//-Setup the PYR of the rain_tpl...
pyr_vec = VectorSet(p, y, 0.0);
if((IsServer()) || (!IsMulti()))
{
//-Make it DAY...
for(i=0; i<GetSectorCount(); i=i+1)
//-look for the special sector flag...
if(GetSectorFlags(i) & 0x100)
{
sec_lite = GetSectorLight(i);
sec_lite = sec_lite + addlight;
SetSectorLight(i, sec_lite, 0.0);
}
//-Set the sky to DAY...
for(x=0; x<GetSurfaceCount(); x=x+1)
//-look for the two types of sky flags...
if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
SetSurfaceMat(x, day);
daya = 0;
SetTimerEx((daynight / 2), 1, 0, 0);
SetTimerEx(daynight, 2, 0, 0);
SetTimerEx((daynight / 4), 3, 0, 0);
}
return;
#-----
timer:
if(GetSenderID()== 1)
{
//-Start the light fade...
if(daya == 0)
daya = 1;
else
if(daya == 1)
daya = 0;
for(i=0; i<GetSectorCount(); i=i+1)
//-look for the special sector flag...
if(GetSectorFlags(i) & 0x100)
{
if(daya == 0)
{
if(debug == 1)
Print("going to day...");
sec_lite = GetSectorLight(i);
sec_lite = sec_lite + addlight;
SetSectorLight(i, sec_lite, (daynight * 1.75));
}
else
if(daya == 1)
{
if(debug == 1)
Print("going to night...");
sec_lite = GetSectorLight(i);
sec_lite = sec_lite - addlight;
SetSectorLight(i, sec_lite, (daynight * 1.75));
}
}
return;
}
else
if(GetSenderID() == 2)
{
//-Change the sky...
for(x=0; x<GetSurfaceCount(); x=x+1)
//-look for the two types of sky flags...
if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
{
mat = GetSurfaceMat(x);
if(mat == day)
SetSurfaceMat(x, dusk); 
else
if(mat == dusk)
{
SetSurfaceMat(x, night);
SetTimerEx((daynight / 2), 1, 0, 0); 
}
else
if(mat == night)
SetSurfaceMat(x, dawn); 
else
if(mat == dawn)
{
SetSurfaceMat(x, day);
SetTimerEx((daynight / 2), 1, 0, 0);
}
}
SetTimerEx(daynight, 2, 0, 0);
if(GetSenderID() == 3)
{
//this is the weather man speaking! muhahahaahaahah! (BBUUZZZZAAAPP!!!!)
//first make a random nuber appear, it will deside what weather to have.
random=Rand(); 
//mext find out what wether we are haveing. you just cant wait can you?
if (random<=0.5) //if more weather is needed put it ABOVE this line
{
call sun;
return;
}
if (random<=0.6) 
{
call rain;
return;
}
if (random<=0.7)
{
call snow;
return;
}
if (random<=0.8) 
{
call fog;
return;
}
if (random<=0.9) 
{
call thunder;
return;
}
if (random<=1) 
{
call death;
return;
}
#====
return;
}
return;
}
//time to rain on me :-(
//-TIMER - (1)
if(GetSenderID() == 4)
{
for(a=0; a<GetSurfaceCount(); a=a+1)
{
//-Look for all surfaces that are flaged as SKY...
if((GetSurfaceFlags(a) & 0x200) || (GetSurfaceFlags(a) & 0x400))
{
//-Check to see if the surface is flat and aiming down...
if(VectorZ(GetSurfaceNormal(a)) == -1.0)
{
//-Get the surfaces center vec, and the surfaces sector...
surf_sec01 = GetSurfaceSector(a);
surf_vec01 = GetSurfaceCenter(a);
surf_Vx01 = VectorX(surf_vec01);
surf_Vy01 = VectorY(surf_vec01);
surf_Vz01 = VectorZ(surf_vec01);
surf_Vz01 = surf_Vz01 - 0.025;
for(d=0; d<rain_drips; d=d+1)
{
//-Randomize the vector...
rand_Svec01 = VectorSet(((surf_Vx01 + (Rand() - 0.5) * x_maxr)), ((surf_Vy01 + (Rand() - 0.5) * y_maxr)), surf_Vz01);
//-Check to see if the rand_Svec is within the range...
if((VectorDist(rand_Svec01, GetThingPos(player)) <= range))
{
CreateThingAtPos(rain_tpl, surf_sec01, rand_Svec01, pyr_vec);
}
}
}
}
}
//-Reset the random timer...
delay1 = Rand();
if(delay1 > maxrain_delay)
delay1 = maxrain_delay;
SetTimerEx(delay1, 4, 0, 0);
return;
}
//-TIMER - (2)
else
if(GetSenderID() == 5)
{
for(b=0; b<GetSurfaceCount(); b=b+1)
{
//-Look for all surfaces that are flaged as SKY...
if((GetSurfaceFlags(b) & 0x200) || (GetSurfaceFlags(b) & 0x400))
{
//-Check to see if the surface is flat and aiming down...
if(VectorZ(GetSurfaceNormal(b)) == -1.0)
{
//-Get the surfaces center vec...
surf_vec02 = GetSurfaceCenter(b);
surf_sec02 = GetSurfaceSector(b);
surf_Vx02 = VectorX(surf_vec02);
surf_Vy02 = VectorY(surf_vec02);
surf_Vz02 = VectorZ(surf_vec02);
surf_Vz02 = surf_Vz02 - 0.025;
//-Make the amount of rain_drips for each surface...
for(e=0; e<rain_drips; e=e+1)
{
//-Randomize the vector...
rand_Svec02 = VectorSet(((surf_Vx02 + (Rand() - 0.5) * x_maxr)), ((surf_Vy02 + (Rand() - 0.5) * y_maxr)), surf_Vz02);
//-Check to see if the rand_Svec is within the range...
if((VectorDist(rand_Svec02, GetThingPos(player)) <= range))
{
CreateThingAtPos(rain_tpl, surf_sec02, rand_Svec02, pyr_vec);
} 
}
}
}
}
//-Reset the random timer...
delay2 = Rand();
if(delay2 > maxrain_delay)
delay2 = maxrain_delay;
SetTimerEx(delay2, 5, 0, 0);
return;
}
//-TIMER - (3)
else
if(GetSenderID() == 6)
{
for(c=0; c<GetSurfaceCount(); c=c+1)
{
//-Look for all surfaces that are flaged as SKY...
if((GetSurfaceFlags(c) & 0x200) || (GetSurfaceFlags(c) & 0x400))
{
//-Check to see if the surface is flat and aiming down...
if(VectorZ(GetSurfaceNormal(c)) == -1.0)
{
//-Get the surfaces center vec...
surf_sec03 = GetSurfaceSector(c);
surf_vec03 = GetSurfaceCenter(c);
surf_Vx03 = VectorX(surf_vec03);
surf_Vy03 = VectorY(surf_vec03);
surf_Vz03 = VectorZ(surf_vec03);
surf_Vz03 = surf_Vz03 - 0.025;
//-Make the amount of rain_drips for each surface...
for(f=0; f<rain_drips; f=f+1)
{
//-Randomize the vector...
rand_Svec03 = VectorSet(((surf_Vx03 + (Rand() - 0.5) * x_maxr)), ((surf_Vy03 + (Rand() - 0.5) * y_maxr)), surf_Vz03);
//-Check to see if the rand_Svec is within the range...
if((VectorDist(rand_Svec03, GetThingPos(player)) <= range))
{
CreateThingAtPos(rain_tpl, surf_sec03, rand_Svec03, pyr_vec);
}
}
}
}
}
//-Reset the random timer...
delay3 = Rand();
if(delay3 > maxrain_delay)
delay3 = maxrain_delay;
SetTimerEx(delay3, 6, 0, 0);
return;
}
return;
#=====
//wether pattens go here
sun:
//its a perfect day, so do nothing but add light.
call addlight;
call returna;
return;
rain:
//its not a good forcast, lets make it dark.
call darklight;
//time for the rain
y=90.0;
rain_tpl=train_tpl;
call returna;
call rainme;
return;
snow:
//its not a good forcast, lets make it dark.
call darklight;
call returna;
return;
fog:
rain_tpl=fog_tpl;
effecthandle=newColorEffect(0, 0, 0, 0, 0, 0, fogr, fogg, fogb, 0);
//its not a good forcast, lets make it dark.
call darklight;
call returna;
return;
thunder:
//its not a good forcast, lets make it dark.
call darklight;
y=0.0;
rain_tpl=tunder_tpl;
call returna;
call rainme;
return;
death:
//its not a good forcast, lets make it dark.
call darklight;
y=90.0;
rain_tpl=lightning_tpl;
call returna;          
call rainme;                             
return;
addlight:
for(i=0; i<GetSectorCount(); i=i+1)
if(GetSectorFlags(i) & 0x100)
{
sec_lite = GetSectorLight(i);
sec_lite = sec_lite + 0.5;
SetSectorLight(i, sec_lite, 0.0);
}
return;
darklight:
for(i=0; i<GetSectorCount(); i=i+1)
if(GetSectorFlags(i) & 0x100)
{
sec_lite = GetSectorLight(i);
sec_lite = sec_lite -0.5;
SetSectorLight(i, sec_lite, 0.0);
}
return;
returna:
#sleep(daynight / 4);
//clear all the problems from erlyer
FreeColorEffect(effecthandle);
SetTimerEx((daynight / 4), 3, 0, 0);
return;
rainme:
SetTimerEx(0.25, 4, 0, 0);
SetTimerEx(0.5, 5, 0, 0);
SetTimerEx(0.75, 6, 0, 0);
return;
#=====
end


please please tell me its not totaly ruined... parsec says its clean.. i got a hint it may be a problem with the timers and there calling.. but after two days of searching i am totaly confused..

P.s. A get a feeling we are gonne need help...

-puts GBK on cellophane pops it on a big lamp on top of the police station and shines it inot the clouds-

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-05-28, 2:16 PM #2
first off why in the world are you putting those two cog together???
second it would be easier to read your cogs if you tab in a little instead of having everything line up on the left colum.

anyways i think i found your problem.
the timer (2) didnt finish before timer (3) began. needed one more braket at the end of timer (2).
heres the cog, should be fixed but i didnt try it out.
Code:
# Jedi Knight Cog Script
#
# day.cog
#
# creates day and night, as well as surface rain.(and fog)
# thanks to DSLS_DeathSythe for his SURF_RAIN01.COG, the base of the rain in this.
#
# This Cog is Not supported by LucasArts Entertainment Co.
#=====
flags=0x240
symbols
#-----
message      startup
message      timer
flex         random=0.0                         local
flex         daynight=32400.0
flex         addlight=0.8
sector       i=0                                local
surface      x=0                                local
material     mat                                local
material     day
material     dusk
material     dawn
material     night
int          daya=0                             local
int          debug=0
flex         sec_lite=0.0                       local
int          fogr
int          fogg
int          fogb
int          effecthandle                       local
#-----
flex         x_maxr=1.0
flex         y_maxr=1.0
template     rain_tpl=+repeaterball             local
template     train_tpl=+repeaterball
template     tunder_tpl=+repeaterball
template     lightning_tpl=+repeaterball
template     fog_tpl=+repeaterball
flex         p=0.0
flex         y=90.0
flex         maxrain_delay=0.5
int          rain_drips=3
flex         range=3.0
#-----
thing        player=-1                          local
vector       pyr_vec                            local
surface      a                                  local
int          d=0                                local
vector       surf_vec01                         local
vector       rand_Svec01                        local
sector       surf_sec01                         local
flex         surf_Vx01=0.0                      local
flex         surf_Vy01=0.0                      local
flex         surf_Vz01=0.0                      local
flex         delay1=0.0                         local
surface      b                                  local
int          e=0                                local
vector       surf_vec02                         local
vector       rand_Svec02                        local
sector       surf_sec02                         local
flex         surf_Vx02=0.0                      local
flex         surf_Vy02=0.0                      local
flex         surf_Vz02=0.0                      local
flex         delay2=0.0                         local
surface      c                                  local
int          f=0                                local
vector       surf_vec03                         local
vector       rand_Svec03                        local
sector       surf_sec03                         local
flex         surf_Vx03                          local
flex         surf_Vy03                          local
flex         surf_Vz03                          local
flex         delay3=0.0                         local
#-----
end
#=====
code
#-----
startup:
  Sleep(2.0);
  player = GetLocalPlayerThing();
  //-Setup the PYR of the rain_tpl...
  pyr_vec = VectorSet(p, y, 0.0);
  if((IsServer()) || (!IsMulti()))
    {
    //-Make it DAY...
    for(i=0; i<GetSectorCount(); i=i+1)
      //-look for the special sector flag...
      if(GetSectorFlags(i) & 0x100)
        {
        sec_lite = GetSectorLight(i);
        sec_lite = sec_lite + addlight;
        SetSectorLight(i, sec_lite, 0.0);
        }
      //-Set the sky to DAY...
      for(x=0; x<GetSurfaceCount(); x=x+1)
        //-look for the two types of sky flags...
        if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
          SetSurfaceMat(x, day);
    daya = 0;
    SetTimerEx((daynight / 2), 1, 0, 0);
    SetTimerEx(daynight, 2, 0, 0);
    SetTimerEx((daynight / 4), 3, 0, 0);
    }
return;
#-----
timer:
  //-TIMER ID - (1)
  //-Start the light fade...
  if(GetSenderID()== 1)
    {
    if(daya == 0)
      daya = 1;
    else
    if(daya == 1)
      daya = 0;
    for(i=0; i<GetSectorCount(); i=i+1)
      {
      //-look for the special sector flag...
      if(GetSectorFlags(i) & 0x100)
        {
        if(daya == 0)
          {
          if(debug == 1)
            Print("going to day...");
          sec_lite = GetSectorLight(i);
          sec_lite = sec_lite + addlight;
          SetSectorLight(i, sec_lite, (daynight * 1.75));
          return;
          }
        else
        if(daya == 1)
          {
          if(debug == 1)
            Print("going to night...");
          sec_lite = GetSectorLight(i);
          sec_lite = sec_lite - addlight;
          SetSectorLight(i, sec_lite, (daynight * 1.75));
          return;
          }
        }
      }
    return;
    }
  //-TIMER ID - (2)
  //-Change the sky...
  else
  if(GetSenderID() == 2)
    {
    for(x=0; x<GetSurfaceCount(); x=x+1)
      {
      //-look for the two types of sky flags...
      if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
        {
        mat = GetSurfaceMat(x);
        if(mat == day)
          SetSurfaceMat(x, dusk); 
        else
        if(mat == dusk)
          {
          SetSurfaceMat(x, night);
          SetTimerEx((daynight / 2), 1, 0, 0); 
          }
        else
        if(mat == night)
          SetSurfaceMat(x, dawn); 
        else
        if(mat == dawn)
          {
          SetSurfaceMat(x, day);
          SetTimerEx((daynight / 2), 1, 0, 0);
          }
        }
      SetTimerEx(daynight, 2, 0, 0);
      }
    return;
    }
  //-TIMER ID - (3)
  //-this is the weather man speaking! muhahahaahaahah! (BBUUZZZZAAAPP!!!!)
  else
  if(GetSenderID() == 3)
    {
    //-first make a random nuber appear, it will deside what weather to have.
    random = Rand(); 
    //-next find out what weather we are haveing. you just cant wait can you?
    //-if more weather is needed put it ABOVE this line
    if(random <= 0.4)
      {
      Call sun;
      return;
      }
    else
    if(random <= 0.5) 
      {
      Call rain;
      return;
      }
    else
    if(random <= 0.6)
      {
      Call snow;
      return;
      }
    else
    if(random <= 0.7)
      {
      Call fog;
      return;
      }
    else
    if(random <= 0.8) 
      {
      Call thunder;
      return;
      }
    else
    if(random <= 0.95) 
      {
      Call death;
      return;
      }
    return;
    }
  //-time to rain on me :-(
  //-TIMER ID - (4)
  //-RAIN burst (1)...
  else
  if(GetSenderID() == 4)
    {
    for(a=0; a<GetSurfaceCount(); a=a+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(a) & 0x200) || (GetSurfaceFlags(a) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(a)) == -1.0)
          {
          //-Get the surfaces center vec, and the surfaces sector...
          surf_sec01 = GetSurfaceSector(a);
          surf_vec01 = GetSurfaceCenter(a);
          surf_Vx01 = VectorX(surf_vec01);
          surf_Vy01 = VectorY(surf_vec01);
          surf_Vz01 = VectorZ(surf_vec01);
          surf_Vz01 = surf_Vz01 - 0.025;
          for(d=0; d<rain_drips; d=d+1)
            {
            //-Randomize the vector...
            rand_Svec01 = VectorSet(((surf_Vx01 + (Rand() - 0.5) * x_maxr)), ((surf_Vy01 + (Rand() - 0.5) * y_maxr)), surf_Vz01);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec01, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec01, rand_Svec01, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset the random timer...
    delay1 = Rand();
    if(delay1 > maxrain_delay)
      delay1 = maxrain_delay;
    SetTimerEx(delay1, 4, 0, 0);
    return;
    }
  //-TIMER ID - (5)
  //-RAIN burst (2)
  else
  if(GetSenderID() == 5)
    {
    for(b=0; b<GetSurfaceCount(); b=b+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(b) & 0x200) || (GetSurfaceFlags(b) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(b)) == -1.0)
          {
          //-Get the surfaces center vec...
          surf_vec02 = GetSurfaceCenter(b);
          surf_sec02 = GetSurfaceSector(b);
          surf_Vx02 = VectorX(surf_vec02);
          surf_Vy02 = VectorY(surf_vec02);
          surf_Vz02 = VectorZ(surf_vec02);
          surf_Vz02 = surf_Vz02 - 0.025;
          //-Make the amount of rain_drips for each surface...
          for(e=0; e<rain_drips; e=e+1)
            {
            //-Randomize the vector...
            rand_Svec02 = VectorSet(((surf_Vx02 + (Rand() - 0.5) * x_maxr)), ((surf_Vy02 + (Rand() - 0.5) * y_maxr)), surf_Vz02);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec02, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec02, rand_Svec02, pyr_vec);
              } 
            }
          }
        }
      }
    //-Reset the random timer...
    delay2 = Rand();
    if(delay2 > maxrain_delay)
      delay2 = maxrain_delay;
    SetTimerEx(delay2, 5, 0, 0);
    return;
    }
  //-TIMER ID - (6)
  //-RAIN burst (3)
  else
  if(GetSenderID() == 6)
    {
    for(c=0; c<GetSurfaceCount(); c=c+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(c) & 0x200) || (GetSurfaceFlags(c) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(c)) == -1.0)
          {
          //-Get the surfaces center vec...
          surf_sec03 = GetSurfaceSector(c);
          surf_vec03 = GetSurfaceCenter(c);
          surf_Vx03 = VectorX(surf_vec03);
          surf_Vy03 = VectorY(surf_vec03);
          surf_Vz03 = VectorZ(surf_vec03);
          surf_Vz03 = surf_Vz03 - 0.025;
          //-Make the amount of rain_drips for each surface...
          for(f=0; f<rain_drips; f=f+1)
            {
            //-Randomize the vector...
            rand_Svec03 = VectorSet(((surf_Vx03 + (Rand() - 0.5) * x_maxr)), ((surf_Vy03 + (Rand() - 0.5) * y_maxr)), surf_Vz03);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec03, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec03, rand_Svec03, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset the random timer...
    delay3 = Rand();
    if(delay3 > maxrain_delay)
      delay3 = maxrain_delay;
    SetTimerEx(delay3, 6, 0, 0);
    return;
    }
return;
#=====
  //weather pattens go here
sun:
  //its a perfect day, so do nothing but add light.
  Call addlight;
  Call clear_probs;
return;
#-----
rain:
  //-its not a good forcast, lets make it dark.
  call darklight;
  //-time for the rain
  y = 90.0;
  rain_tpl = train_tpl;
  Call clear_probs;
  Call rainme;
return;
#-----
snow:
  //its not a good forcast, lets make it dark.
  Call darklight;
  Call clear_probs;
return;
#-----
fog:
  rain_tpl=fog_tpl;
  effecthandle = newColorEffect(0, 0, 0, 0, 0, 0, fogr, fogg, fogb, 0);
  //-its not a good forcast, lets make it dark.
  Call darklight;
  Call clear_probs;
return;
#-----
thunder:
  //its not a good forcast, lets make it dark.
  Call darklight;
  y = 90.0;
  rain_tpl = tunder_tpl;
  Call clear_probs;
  Call rainme;
return;
#-----
death:
  //its not a good forcast, lets make it dark.
  Call darklight;
  y = 90.0;
  rain_tpl = lightning_tpl;
  Call clear_probs;          
  Call rainme;                             
return;
#-----
addlight:
  for(i=0; i<GetSectorCount(); i=i+1)
    {
    if(GetSectorFlags(i) & 0x100)
      {
      sec_lite = GetSectorLight(i);
      sec_lite = sec_lite + 0.5;
      SetSectorLight(i, sec_lite, 0.0);
      }
    }
return;
#-----
darklight:
  for(i=0; i<GetSectorCount(); i=i+1)
    {
    if(GetSectorFlags(i) & 0x100)
      {
      sec_lite = GetSectorLight(i);
      sec_lite = sec_lite - 0.5;
      SetSectorLight(i, sec_lite, 0.0);
      }
    }
return;
#-----
clear_probs:
  #sleep(daynight / 4);
  //-clear all the problems from erlyer
  FreeColorEffect(effecthandle);
  SetTimerEx((daynight / 4), 3, 0, 0);
return;
#-----
rainme:
  SetTimerEx(0.25, 4, 0, 0);
  SetTimerEx(0.5, 5, 0, 0);
  SetTimerEx(0.75, 6, 0, 0);
return;
#=====
end

i added tabs and changed a few little things.
try it out and see if it works.

------------------
Famous last words - "It seemed like a good idea at the time."
Famous last words - "It seemed like a good idea at the time."
2003-05-30, 2:49 AM #3
it works, then it stops suddenly.. i mean it sticks on teh thunder (or lightnin) and also, the "thunder" shoudl have its Y valuse left at 90 whle the others get 180..

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-05-30, 7:18 AM #4
i have no idea why it would suddenly stop.
can you explain it a little better?
do you mean that it just keeps raining those templates?

the PYR vector that the Y flex is for is set on startup so just changing the Y flex at any time wont do anything. you will have to change it like this.
Code:
//-Setup the PYR of the rain_tpl...  
y = 90.0;
pyr_vec = VectorSet(p, y, 0.0);

so any time you want to change the Y value and have it be used thats how you'd have to do it.

also i was wondering, why is the daynight set to 32400 seconds? you do realize how long that is dont you?
32400s/60spm = 540 minutes
540m/60mph = 9 HOURS!!!
so it would take 9 hours for the sky to change? just curious why you have that.

one more thing.
the cog is a 'flags=0x240', and you have in the timer ID 3 section 'random=Rand();'. you do realize that the random number it gets can be different for each player, meaning that each player may have different weather.
the 'flags=0x240' needs to be there so that the rain doesnt lag the game. if you want to have the same weather for all players you may have to use a trigger that sends the random number that the server gets to all players so that they all get the same weather. if it doesnt matter to you then never mind.

------------------
Famous last words - "It seemed like a good idea at the time."

[This message has been edited by DSLS_DeathSythe (edited May 30, 2003).]
Famous last words - "It seemed like a good idea at the time."
2003-06-02, 6:37 AM #5
yes, it "stic" on the thunder/lightning and wont move on.

triggers, thats C/S HMG i dont knwo that.

i am in up to my scalp here some one bale me out.

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-06-02, 8:31 AM #6
if i took the two cogs that you used to make this one and made them work together (by useing triggers) the way this cog works would that be ok?
or do you want it to be one cog.
it would be easier (in a lot ways) to have them as two cogs.

------------------
Famous last words - "It seemed like a good idea at the time."

[This message has been edited by DSLS_DeathSythe (edited June 02, 2003).]
Famous last words - "It seemed like a good idea at the time."
2003-06-22, 8:09 AM #7
OMFG! i missed this post!!
yes yes, do that. no need for one cog [http://forums.massassi.net/html/biggrin.gif]

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD

[This message has been edited by [SF]pjb (edited June 22, 2003).]
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-06-23, 3:35 PM #8
ok, it will take me a little while to do because i havent started working on them and there are still some bugs to work out.

------------------
Famous last words - "It seemed like a good idea at the time."
Famous last words - "It seemed like a good idea at the time."
2003-06-23, 5:31 PM #9
ok heres the cogs.
im not sure if they work, i havent tested them at all, and i think i may have missed some things but im not sure. [http://forums.massassi.net/html/redface.gif]
Code:
######
# Jedi Knight Cog Script
#-----
# WEATHER_DAYNIGHT01.COG
#-----
# Written By DSLS_DeathSythe
# This Cog is Not supported by LucasArts Entertainment Co
######
symbols
#=====
message   startup
message   timer
flex      daynight=10.0
flex      addlight=0.8
flex      light_norm=0.0     local
sector    i=0     local
surface   x=0     local
material  mat     local
material  day
material  dusk
material  dawn
material  night
int       is_day=0     local
flex      sec_light=0.0     local
flex      weather_type=0.0     local
#-Trig Ints
int       ChangeWeather_Trig=1
#-----
end
#=====
code
#-----
startup:
  light_norm = addlight;
  if(IsServer() || !IsMulti())
    {
    //-Make it DAY...
    for(i=0; i<GetSectorCount(); i=i+1)
      {
      //-look for the special sector flag...
      if(GetSectorFlags(i) & 0x100)
        {
        sec_light = GetSectorLight(i);
        sec_light = sec_light + addlight;
        SetSectorLight(i, sec_light, 0.0);
        }
      }
    //-Set the sky to DAY...
    for(x=0; x<GetSurfaceCount(); x=x+1)
      {
      //-look for the two types of sky flags...
      if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
        SetSurfaceMat(x, day);
      }
    is_day = 0;
    SetTimerEx((daynight / 2), 1, 0, 0);
    SetTimerEx(daynight, 2, 0, 0);
    }
return;
#-----
timer:
  if(GetSenderID() == 1)
    {
    //-Start the light fade...
    if(is_day == 0)
      is_day = 1;
    else
      is_day = 0;
    for(i=0; i<GetSectorCount(); i=i+1)
      {
      //-look for the special sector flag...
      if(GetSectorFlags(i) & 0x100)
        {
        if(is_day == 0)
          {
          sec_light = GetSectorLight(i);
          sec_light = sec_light + addlight;
          SetSectorLight(i, sec_light, (daynight * 1.75));
          }
        else
        if(is_day == 1)
          {
          sec_light = GetSectorLight(i);
          sec_light = sec_light - addlight;
          SetSectorLight(i, sec_light, (daynight * 1.75));
          }
        }
      }
    return;
    }
  else
  if(GetSenderID() == 2)
    {
    //-Change the sky...
    for(x=0; x<GetSurfaceCount(); x=x+1)
      {
      //-look for the two types of sky flags...
      if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
        {
        mat = GetSurfaceMat(x);
        if(mat == day)
          SetSurfaceMat(x, dusk); 
        else
        if(mat == dusk)
          {
          SetSurfaceMat(x, night);
          Call find_weather;
          SetTimerEx((daynight / 2), 1, 0, 0); 
          }
        else
        if(mat == night)
          SetSurfaceMat(x, dawn); 
        else
        if(mat == dawn)
          {
          SetSurfaceMat(x, day);
          SetTimerEx((daynight / 2), 1, 0, 0);
          }
        }
      }
    SetTimerEx(daynight, 2, 0, 0);
    return;
    }
return;
#-----
find_weather:
  if(IsServer() || !IsMulti())
    {
    //-First we need to find out what kind of weather we are going to have...
    weather_type = Rand();
    #=================#
    #- SUNNY weather -#
    #=================#
    if(weather_type >= 0.9)
      {
      addlight = light_norm + 0.5;
      if(IsServer())
        SendTrigger(-1, ChangeWeather_Trig, weather_type, 0, 0, 0);
      }
    #=================#
    #- RAINY weather -#
    #=================#
    else
    if(weather_type >= 0.8)
      {
      addlight = light_norm - 0.5;
      if(IsServer())
        SendTrigger(-1, ChangeWeather_Trig, weather_type, 0, 0, 0);
      }
    #=================#
    #- SNOWY weather -#
    #=================#
    else
    if(weather_type >= 0.7)
      {
      addlight = light_norm - 0.5;
      if(IsServer())
        SendTrigger(-1, ChangeWeather_Trig, weather_type, 0, 0, 0);
      }
    #=================#
    #- FOGGY weather -#
    #=================#
    else
    if(weather_type >= 0.6)
      {
      addlight = light_norm - 0.5;
      if(IsServer())
        SendTrigger(-1, ChangeWeather_Trig, weather_type, 0, 0, 0);
      }
    #===================#
    #- THUNDER weather -#
    #===================#
    else
    if(weather_type >= 0.5)
      {
      addlight = light_norm - 0.5;
      if(IsServer())
        SendTrigger(-1, ChangeWeather_Trig, weather_type, 0, 0, 0);
      }
    #=====================#
    #- LIGHTNING weather -#
    #=====================#
    else
      {
      addlight = light_norm - 0.5;
      if(IsServer())
        SendTrigger(-1, ChangeWeather_Trig, weather_type, 0, 0, 0);
      }
    }
return;
#=====
end

this daynight cog is the one that changes the sector light, sky mat and decides the weather. leave the daynight flex low while your testing it.
Code:
######
# Jedi Knight Cog Script
#-----
# WEATHER_SURFRAIN01.COG
#-----
# Written By DSLS_DeathSythe
# This Cog is Not supported by LucasArts Entertainment Co
######
flags=0x240
symbols
#=====
message   startup
message   trigger
message   timer
#-----
flex      x_maxr=1.0
flex      y_maxr=1.0
template  rain_tpl     local
template  train_tpl=+repeaterball
template  snow_tpl=+repeaterball
template  thunder_tpl=+repeaterball
template  lightning_tpl=+repeaterball
template  fog_tpl=+repeaterball
flex      p=0.0
flex      y=0.0
flex      maxrain_delay=0.5
int       rain_drips=3
flex      range=3.0
int       is_raining=0     local
#-----
flex      weather_type=0.0     local
flex      fog_red=0.0
flex      fog_grn=0.0
flex      fog_blu=0.0
int       effecthandle=-1     local
#-----
thing     player=-1     local
vector    pyr_vec     local
surface   a     local
int       d=0     local
vector    surf_vec01     local
vector    rand_Svec01     local
sector    surf_sec01     local
flex      surf_Vx01     local
flex      surf_Vy01     local
flex      surf_Vz01     local
flex      delay1=0.0     local
surface   b     local
int       e=0     local
vector    surf_vec02     local
vector    rand_Svec02     local
sector    surf_sec02     local
flex      surf_Vx02     local
flex      surf_Vy02     local
flex      surf_Vz02     local
flex      delay2=0.0     local
surface   c     local
int       f=0     local
vector    surf_vec03     local
vector    rand_Svec03     local
sector    surf_sec03     local
flex      surf_Vx03     local
flex      surf_Vy03     local
flex      surf_Vz03     local
flex      delay3=0.0     local
#-Trig Ints
int       ChangeWeather_Trig=1
#-----
end
#=====
code
#-----
startup:
  player = GetLocalPlayerThing();
return;
#-----
trigger:
  if(GetSourceRef() != ChangeWeather_Trig) return;
  weather_type = GetParam(0);
  #=================#
  #- SUNNY weather -#
  #=================#
  if(weather_type >= 0.9)
    {
    //-Stop all raining, and clear fog color...
    KillTimerEx(1);
    KillTimerEx(2);
    KillTimerEx(3);
    is_raining = 0;
    //-Backup timer incase we missed one of the rain timers...
    SetTimerEx(0.1, 4, 0, 0);
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      }
    }
  #=================#
  #- RAINY weather -#
  #=================#
  else
  if(weather_type >= 0.8)
    {
    //-Clear the fog color and start the raining...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      }
    y = -90.0;
    rain_tpl = train_tpl;
    if(is_raining == 0)
      {
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    }
  #=================#
  #- SNOWY weather -#
  #=================#
  else
  if(weather_type >= 0.7)
    {
    //-Clear the fog color and start the snowing...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      }
    y = -90.0;
    rain_tpl = snow_tpl;
    if(is_raining == 0)
      {
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    }
  #=================#
  #- FOGGY weather -#
  #=================#
  else
  if(weather_type >= 0.6)
    {
    //-Make it foggy and rain the fog_tpl...
    effecthandle = newColorEffect(0, 0, 0, 0, 0, 0, fog_red, fog_grn, fog_blu, 0);
    y = -90.0;
    rain_tpl = fog_tpl;
    if(is_raining == 0)
      {
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    }
  #===================#
  #- THUNDER weather -#
  #===================#
  else
  if(weather_type >= 0.5)
    {
    //-Clear the fog color and start the thundering...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      }
    y = 0.0;
    rain_tpl = thunder_tpl;
    if(is_raining == 0)
      {
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    }
  #=====================#
  #- LIGHTNING weather -#
  #=====================#
  else
    {
    //-Clear the fog color and start the lightning...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      }
    y = -90.0;
    rain_tpl = lightning_tpl;
    if(is_raining == 0)
      {
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    }
return;
#-----
timer:
  //-TIMER - (1)
  if(GetSenderID() == 1)
    {
    for(a=0; a<GetSurfaceCount(); a=a+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(a) & 0x200) || (GetSurfaceFlags(a) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(a)) == -1.0)
          {
          //-Get the surfaces center vec, and the surfaces sector...
          surf_sec01 = GetSurfaceSector(a);
          surf_vec01 = GetSurfaceCenter(a);
          surf_Vx01 = VectorX(surf_vec01);
          surf_Vy01 = VectorY(surf_vec01);
          surf_Vz01 = VectorZ(surf_vec01);
          surf_Vz01 = surf_Vz01 - 0.025;
          //-Setup the PYR of the rain_tpl...
          pyr_vec = VectorSet(p, y, 0.0);
          //-Make the amount of rain_drips for each surface...
          for(d=0; d<rain_drips; d=d+1)
            {
            //-Randomize the vector...
            rand_Svec01 = VectorSet(((surf_Vx01 + (Rand() - 0.5) * x_maxr)), ((surf_Vy01 + (Rand() - 0.5) * y_maxr)), surf_Vz01);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec01, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec01, rand_Svec01, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset the random timer...
    delay1 = Rand();
    if(delay1 > maxrain_delay)
      delay1 = maxrain_delay;
    SetTimerEx(delay1, 1, 0, 0);
    return;
    }
  //-TIMER - (2)
  else
  if(GetSenderID() == 2)
    {
    for(b=0; b<GetSurfaceCount(); b=b+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(b) & 0x200) || (GetSurfaceFlags(b) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(b)) == -1.0)
          {
          //-Get the surfaces center vec...
          surf_vec02 = GetSurfaceCenter(b);
          surf_sec02 = GetSurfaceSector(b);
          surf_Vx02 = VectorX(surf_vec02);
          surf_Vy02 = VectorY(surf_vec02);
          surf_Vz02 = VectorZ(surf_vec02);
          surf_Vz02 = surf_Vz02 - 0.025;
          //-Setup the PYR of the rain_tpl...
          pyr_vec = VectorSet(p, y, 0.0);
          //-Make the amount of rain_drips for each surface...
          for(e=0; e<rain_drips; e=e+1)
            {
            //-Randomize the vector...
            rand_Svec02 = VectorSet(((surf_Vx02 + (Rand() - 0.5) * x_maxr)), ((surf_Vy02 + (Rand() - 0.5) * y_maxr)), surf_Vz02);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec02, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec02, rand_Svec02, pyr_vec);
              } 
            }
          }
        }
      }
    //-Reset the random timer...
    delay2 = Rand();
    if(delay2 > maxrain_delay)
      delay2 = maxrain_delay;
    SetTimerEx(delay2, 2, 0, 0);
    return;
    }
  //-TIMER - (3)
  else
  if(GetSenderID() == 3)
    {
    for(c=0; c<GetSurfaceCount(); c=c+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(c) & 0x200) || (GetSurfaceFlags(c) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(c)) == -1.0)
          {
          //-Get the surfaces center vec...
          surf_sec03 = GetSurfaceSector(c);
          surf_vec03 = GetSurfaceCenter(c);
          surf_Vx03 = VectorX(surf_vec03);
          surf_Vy03 = VectorY(surf_vec03);
          surf_Vz03 = VectorZ(surf_vec03);
          surf_Vz03 = surf_Vz03 - 0.025;
          //-Setup the PYR of the rain_tpl...
          pyr_vec = VectorSet(p, y, 0.0);
          //-Make the amount of rain_drips for each surface...
          for(f=0; f<rain_drips; f=f+1)
            {
            //-Randomize the vector...
            rand_Svec03 = VectorSet(((surf_Vx03 + (Rand() - 0.5) * x_maxr)), ((surf_Vy03 + (Rand() - 0.5) * y_maxr)), surf_Vz03);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec03, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec03, rand_Svec03, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset the random timer...
    delay3 = Rand();
    if(delay3 > maxrain_delay)
      delay3 = maxrain_delay;
    SetTimerEx(delay3, 3, 0, 0);
    return;
    }
  //-TIMER - (4)
  //-Backup timer incase we missed one of the rain timers...
  else
  if(GetSenderID() == 4)
    {
    KillTimerEx(1);
    KillTimerEx(2);
    KillTimerEx(3);
    is_raining = 0;
    return;
    }
return;
#=====
end

the surfrain cog does all the raining and controls the tint on the screen.

i made it so that it changes the weather everytime its night.
just remember to keep the ChangeWeather_Trig int the same number in both cogs.

they should work but like i said im not sure. i may have missed doing something somewhere.
good luck, tell me exactly what happens if something goes wrong.

------------------
Famous last words - "It seemed like a good idea at the time."
Famous last words - "It seemed like a good idea at the time."
2003-06-24, 7:15 AM #10
woohoo.
ill go and test taht right now

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-06-24, 7:55 AM #11
well, other from teh fact i got no thunder, or lightning, it worked good.

my fog was to thick and it stayed on the screen, wasent removed like.

it was good.

is there any way the wether can change more than one time every day?

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-06-26, 7:41 AM #12
hola, i need some help here......... no thunder, and fog got stuck

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-06-26, 4:07 PM #13
im sorry pjb. [http://forums.massassi.net/html/frown.gif] ive been trying to get these cogs to work but they keep messing up. i got the rain and stuff to come down but now the fog wont even come on, it does go away though when it does come on.
the sectors havent been changing light properly, some times they just stay bright until the night sky comes.
heres the updated cogs, i cant get them to work right no matter what i try, sorry [http://forums.massassi.net/html/frown.gif]
Code:
######
# Jedi Knight Cog Script
#-----
# WEATHER_DAYNIGHT01.COG
#-----
# Written By DSLS_DeathSythe
# This Cog is Not supported by LucasArts Entertainment Co
######
symbols
#=====
message   startup
message   timer
flex      daynight=10.0
flex      addlight=0.8
flex      light_norm=0.0     local
sector    i=0     local
surface   x=0     local
material  mat     local
material  day
material  dusk
material  dawn
material  night
int       is_day=0     local
flex      sec_light=0.0     local
flex      weather_type=0.0     local
int       is_busy=0     local
#-Trig Ints
int       ChangeWeather_Trig=1
#-----
end
#=====
code
#-----
startup:
  light_norm = addlight;
  if(IsServer() || !IsMulti())
    {
    //-Make it DAY...
    for(i=0; i<GetSectorCount(); i=i+1)
      {
      //-look for the special sector flag...
      if(GetSectorFlags(i) & 0x100)
        {
        sec_light = GetSectorLight(i);
        sec_light = sec_light + addlight;
        SetSectorLight(i, sec_light, 0.0);
        }
      }
    //-Set the sky to DAY...
    for(x=0; x<GetSurfaceCount(); x=x+1)
      {
      //-look for the two types of sky flags...
      if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
        SetSurfaceMat(x, day);
      }
    is_day = 0;
    SetTimerEx((daynight / 2), 1, 0, 0);
    SetTimerEx(daynight, 2, 0, 0);
    }
return;
#-----
timer:
  if(GetSenderID() == 1)
    {
    //-Start the light fade...
    if(is_day == 0)
      is_day = 1;
    else
      is_day = 0;
    for(i=0; i<GetSectorCount(); i=i+1)
      {
      //-look for the special sector flag...
      if(GetSectorFlags(i) & 0x100)
        {
        if(is_day == 0)
          {
          sec_light = GetSectorLight(i);
          sec_light = sec_light + addlight;
          SetSectorLight(i, sec_light, (daynight * 1.75));
          }
        else
        if(is_day == 1)
          {
          sec_light = GetSectorLight(i);
          sec_light = sec_light - addlight;
          SetSectorLight(i, sec_light, (daynight * 1.75));
          }
        }
      }
    return;
    }
  else
  if(GetSenderID() == 2)
    {
    //-Change the sky...
    for(x=0; x<GetSurfaceCount(); x=x+1)
      {
      //-look for the two types of sky flags...
      if((GetSurfaceFlags(x) & 0x200) || (GetSurfaceFlags(x) & 0x400))
        {
        mat = GetSurfaceMat(x);
        if(mat == day)
          SetSurfaceMat(x, dusk); 
        else
        if(mat == dusk)
          {
          SetSurfaceMat(x, night);
          Call find_weather;
          SetTimerEx((daynight / 2), 1, 0, 0); 
          }
        else
        if(mat == night)
          SetSurfaceMat(x, dawn); 
        else
        if(mat == dawn)
          {
          SetSurfaceMat(x, day);
          SetTimerEx((daynight / 2), 1, 0, 0);
          }
        }
      }
    SetTimerEx(daynight, 2, 0, 0);
    return;
    }
  else
  if(GetSenderID() == 3)
    {
//    Print("sky IS_BUSY cleared...");
    is_busy = 0;
    return;
    }
return;
#-----
find_weather:
  if(is_busy == 1)
	{
//	Print("sky fade busy...");
	return;
	}
  is_busy = 1;
  SetTimerEx(1.0, 3, 0, 0);
//	Print("weather called...");
  //-First we need to find out what kind of weather we are going to have...
  weather_type = Rand();
  #=================#
  #- SUNNY weather -#
  #=================#
  if(weather_type <= 1.0 && weather_type > 0.9)
    {
    addlight = light_norm + 0.25;
    if(IsServer())
      SendTrigger(-1, ChangeWeather_Trig, weather_type, 1, 0, 0);
    return;
    }
  #=================#
  #- RAINY weather -#
  #=================#
  else
  if(weather_type <= 0.9 && weather_type > 0.8)
    {
    addlight = light_norm - 0.25;
    if(IsServer())
      SendTrigger(-1, ChangeWeather_Trig, weather_type, 2, 0, 0);
    return;
    }
  #=================#
  #- SNOWY weather -#
  #=================#
  else
  if(weather_type <= 0.8 && weather_type > 0.7)
    {
    addlight = light_norm - 0.25;
    if(IsServer())
      SendTrigger(-1, ChangeWeather_Trig, weather_type, 3, 0, 0);
    return;
    }
  #=================#
  #- FOGGY weather -#
  #=================#
  else
  if(weather_type <= 0.7 && weather_type > 0.6)
    {
    addlight = light_norm - 0.25;
    if(IsServer())
      SendTrigger(-1, ChangeWeather_Trig, weather_type, 4, 0, 0);
    return;
    }
  #===================#
  #- THUNDER weather -#
  #===================#
  else
  if(weather_type <= 0.6 && weather_type > 0.5)
    {
    addlight = light_norm - 0.25;
    if(IsServer())
      SendTrigger(-1, ChangeWeather_Trig, weather_type, 5, 0, 0);
    return;
    }
  #=====================#
  #- LIGHTNING weather -#
  #=====================#
  else
    {
    addlight = light_norm - 0.25;
    if(IsServer())
      SendTrigger(-1, ChangeWeather_Trig, weather_type, 6, 0, 0);
    return;
    }
return;
#=====
end

Code:
######
# Jedi Knight Cog Script
#-----
# WEATHER_SURFRAIN01.COG
#-----
# Written By DSLS_DeathSythe
# This Cog is Not supported by LucasArts Entertainment Co
######
flags=0x240
symbols
#=====
message   startup
message   trigger
message   timer
#-----
flex      x_maxr=1.0
flex      y_maxr=1.0
template  rain_tpl     local
template  train_tpl=+repeaterball
template  snow_tpl=+repeaterball
template  thunder_tpl=+repeaterball
template  lightning_tpl=+repeaterball
template  fog_tpl=+repeaterball
flex      ptch=0.0
flex      yaw=0.0
flex      maxrain_delay=0.5
int       rain_drips=3
flex      range=3.0
int       is_raining=0     local
int       is_busy=0     local
#-----
int       weather_type=0     local
flex      fog_red=0.0
flex      fog_grn=0.0
flex      fog_blu=0.0
int       effecthandle=-1     local
#-----
thing     player=-1     local
vector    pyr_vec     local
surface   a     local
int       d=0     local
vector    surf_vec01     local
vector    rand_Svec01     local
sector    surf_sec01     local
flex      surf_Vx01     local
flex      surf_Vy01     local
flex      surf_Vz01     local
flex      delay1=0.0     local
surface   b     local
int       e=0     local
vector    surf_vec02     local
vector    rand_Svec02     local
sector    surf_sec02     local
flex      surf_Vx02     local
flex      surf_Vy02     local
flex      surf_Vz02     local
flex      delay2=0.0     local
surface   c     local
int       f=0     local
vector    surf_vec03     local
vector    rand_Svec03     local
sector    surf_sec03     local
flex      surf_Vx03     local
flex      surf_Vy03     local
flex      surf_Vz03     local
flex      delay3=0.0     local
#-Trig Ints
int       ChangeWeather_Trig=1
#-----
end
#=====
code
#-----
startup:
  player = GetLocalPlayerThing();
  is_raining = 0;
return;
#-----
trigger:
  if(GetSourceRef() != ChangeWeather_Trig) return;
  if(is_busy == 1)
	{
//	Print("rain cog is busy");
	return;
	}
  is_busy = 1;
  SetTimerEx(1.0, 5, 0, 0);
//	Print("Got weather trigger...");
  weather_type = GetParam(1);
	PrintInt(weather_type);
  #=================#
  #- SUNNY weather -#
  #=================#
  if(weather_type == 1)
    {
	Print("weather is sunny...");
    //-Stop all raining, and clear fog color...
    KillTimerEx(1);
    KillTimerEx(2);
    KillTimerEx(3);
    is_raining = 0;
    //-Backup timer incase we missed one of the rain timers...
//    SetTimerEx(0.1, 4, 0, 0);
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      DisableIRMode();
      }
    return;
    }
  #=================#
  #- RAINY weather -#
  #=================#
  else
  if(weather_type == 2)
    {
    //-Clear the fog color and start the raining...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      DisableIRMode();
      }
    ptch = -90.0;
    //-Setup the PYR of the rain_tpl...
    pyr_vec = VectorSet(ptch, yaw, 0.0);
	PrintVector(pyr_vec);
    rain_tpl = train_tpl;
    if(is_raining == 0)
      {
	Print("starting the rain...");
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    return;
    }
  #=================#
  #- SNOWY weather -#
  #=================#
  else
  if(weather_type == 3)
    {
    //-Clear the fog color and start the snowing...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      DisableIRMode();
      }
    ptch = -90.0;
    //-Setup the PYR of the rain_tpl...
    pyr_vec = VectorSet(ptch, yaw, 0.0);
	PrintVector(pyr_vec);
    rain_tpl = snow_tpl;
    if(is_raining == 0)
      {
	Print("starting the snow...");
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    return;
    }
  #=================#
  #- FOGGY weather -#
  #=================#
  else
  if(weather_type == 4)
    {
    //-Make it foggy and rain the fog_tpl...
    effecthandle = newColorEffect(0, 0, 0, 0, 0, 0, fog_red, fog_grn, fog_blu, 0);
    EnableIRMode(0.3, 1);
    ptch = -90.0;
    //-Setup the PYR of the rain_tpl...
    pyr_vec = VectorSet(ptch, yaw, 0.0);
	PrintVector(pyr_vec);
    rain_tpl = fog_tpl;
    if(is_raining == 0)
      {
	Print("starting the fog...");
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    return;
    }
  #===================#
  #- THUNDER weather -#
  #===================#
  else
  if(weather_type == 5)
    {
    //-Clear the fog color and start the thundering...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      DisableIRMode();
      }
    ptch = 0.0;
    //-Setup the PYR of the rain_tpl...
    pyr_vec = VectorSet(ptch, yaw, 0.0);
	PrintVector(pyr_vec);
    rain_tpl = thunder_tpl;
    if(is_raining == 0)
      {
	Print("starting the thunder...");
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
      }
    return;
    }
  #=====================#
  #- LIGHTNING weather -#
  #=====================#
  else
  if(weather_type == 6)
    {
    //-Clear the fog color and start the lightning...
    if(effecthandle != -1)
      {
      FreeColorEffect(effecthandle);
      effecthandle = -1;
      DisableIRMode();
      }
    ptch = -90.0;
    //-Setup the PYR of the rain_tpl...
    pyr_vec = VectorSet(ptch, yaw, 0.0);
	PrintVector(pyr_vec);
    rain_tpl = lightning_tpl;
    if(is_raining == 0)
      {
	Print("starting the lightning...");
      SetTimerEx(0.25, 1, 0, 0);
      SetTimerEx(0.5, 2, 0, 0);
      SetTimerEx(0.75, 3, 0, 0);
      is_raining = 1;
     }
    return;
    }
return;
#-----
timer:
  //-TIMER - (1)
  if(GetSenderID() == 1)
    {
    for(a=0; a<GetSurfaceCount(); a=a+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(a) & 0x200) || (GetSurfaceFlags(a) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(a)) == -1.0)
          {
          //-Get the surfaces center vec, and the surfaces sector...
          surf_sec01 = GetSurfaceSector(a);
          surf_vec01 = GetSurfaceCenter(a);
          surf_Vx01 = VectorX(surf_vec01);
          surf_Vy01 = VectorY(surf_vec01);
          surf_Vz01 = VectorZ(surf_vec01);
          surf_Vz01 = surf_Vz01 - 0.025;
          //-Make the amount of rain_drips for each surface...
          for(d=0; d<rain_drips; d=d+1)
            {
            //-Randomize the vector...
            rand_Svec01 = VectorSet(((surf_Vx01 + (Rand() - 0.5) * x_maxr)), ((surf_Vy01 + (Rand() - 0.5) * y_maxr)), surf_Vz01);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec01, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec01, rand_Svec01, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset the random timer...
    delay1 = Rand();
    if(delay1 > maxrain_delay)
      delay1 = maxrain_delay;
    SetTimerEx(delay1, 1, 0, 0);
    return;
    }
  //-TIMER - (2)
  else
  if(GetSenderID() == 2)
    {
    for(b=0; b<GetSurfaceCount(); b=b+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(b) & 0x200) || (GetSurfaceFlags(b) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(b)) == -1.0)
          {
          //-Get the surfaces center vec...
          surf_vec02 = GetSurfaceCenter(b);
          surf_sec02 = GetSurfaceSector(b);
          surf_Vx02 = VectorX(surf_vec02);
          surf_Vy02 = VectorY(surf_vec02);
          surf_Vz02 = VectorZ(surf_vec02);
          surf_Vz02 = surf_Vz02 - 0.025;
          //-Make the amount of rain_drips for each surface...
          for(e=0; e<rain_drips; e=e+1)
            {
            //-Randomize the vector...
            rand_Svec02 = VectorSet(((surf_Vx02 + (Rand() - 0.5) * x_maxr)), ((surf_Vy02 + (Rand() - 0.5) * y_maxr)), surf_Vz02);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec02, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec02, rand_Svec02, pyr_vec);
              } 
            }
          }
        }
      }
    //-Reset the random timer...
    delay2 = Rand();
    if(delay2 > maxrain_delay)
      delay2 = maxrain_delay;
    SetTimerEx(delay2, 2, 0, 0);
    return;
    }
  //-TIMER - (3)
  else
  if(GetSenderID() == 3)
    {
    for(c=0; c<GetSurfaceCount(); c=c+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if((GetSurfaceFlags(c) & 0x200) || (GetSurfaceFlags(c) & 0x400))
        {
        //-Check to see if the surface is flat and aiming down...
        if(VectorZ(GetSurfaceNormal(c)) == -1.0)
          {
          //-Get the surfaces center vec...
          surf_sec03 = GetSurfaceSector(c);
          surf_vec03 = GetSurfaceCenter(c);
          surf_Vx03 = VectorX(surf_vec03);
          surf_Vy03 = VectorY(surf_vec03);
          surf_Vz03 = VectorZ(surf_vec03);
          surf_Vz03 = surf_Vz03 - 0.025;
          //-Make the amount of rain_drips for each surface...
          for(f=0; f<rain_drips; f=f+1)
            {
            //-Randomize the vector...
            rand_Svec03 = VectorSet(((surf_Vx03 + (Rand() - 0.5) * x_maxr)), ((surf_Vy03 + (Rand() - 0.5) * y_maxr)), surf_Vz03);
            //-Check to see if the rand_Svec is within the range...
            if((VectorDist(rand_Svec03, GetThingPos(player)) <= range))
              {
              CreateThingAtPos(rain_tpl, surf_sec03, rand_Svec03, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset the random timer...
    delay3 = Rand();
    if(delay3 > maxrain_delay)
      delay3 = maxrain_delay;
    SetTimerEx(delay3, 3, 0, 0);
    return;
    }
  //-TIMER - (4)
  //-Backup timer incase we missed one of the rain timers...
  else
  if(GetSenderID() == 4)
    {
//	Print("killing timers...");
    KillTimerEx(1);
    KillTimerEx(2);
    KillTimerEx(3);
    is_raining = 0;
    return;
    }
  //-TIMER - (5)
  else
  if(GetSenderID() == 5)
    {
//	Print("CLEARED BUSY");
    is_busy = 0;
    return;
    }
return;
#=====
end

i dont know what else to do to them to make them work. [http://forums.massassi.net/html/frown.gif]
you can try playing around with them and see if you have more luck, or you can ask somone else.

------------------
Famous last words - "It seemed like a good idea at the time."
Famous last words - "It seemed like a good idea at the time."
2003-06-28, 12:34 AM #14
:'(
well....
what if we made several cogs?
one for eatch wether conditoun, one for the day and night. and sutch
so we could have a fog cog, and a lightning cog. forget the thunder. a rain cog, and snow cog.
that and a day, and a seperate night cog
that way, if a erorr ocoured with one, it could be corrected without messing up the other ones.

should i attempt this insanity on my own? or will you help me?

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-06-28, 8:32 AM #15
ill help, but cant promise that ill be able to get it to work.
so you wanna try to have a separate weather cog for each weather condition? k, is there any more weather conditions you want besides the ones already in the cogs?
ill start working on the separate cogs.

are these cogs ment for MP games or SP or both?

------------------
Famous last words - "It seemed like a good idea at the time."

[This message has been edited by DSLS_DeathSythe (edited June 28, 2003).]
Famous last words - "It seemed like a good idea at the time."
2003-06-29, 11:34 PM #16
well, there are no mroe weather condituons needed.

an its for MP, but if it could be used in SP as well, that would rock.

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-06-30, 9:22 AM #17
ok, i got it to work and it wasnt as hard as i thought it would be.
i did it with three cogs and i had to completely rewrite all the cogs we had before.
heres the daynight cog:
Code:
######
# Jedi Knight Cog Script  (JK)
#-----
# WEATHER_DAYNIGHT00.COG
# Makes all sectors with the flag 0x100 fade in and out
#  between their normal light and an added light that
#  varies depending on what the weather is like.
# It also changes all surfaces flaged 0x200 or 0x400
#  so that they match the light of the sectors.
#-----
# Written By DSLS_DeathSythe
# This COG is NOT supported by LucasArts Entertainment Co.
######
symbols
#-----
message    startup
message    timer

sector     a     local
surface    b     local

flex       dayNight=10.0
flex       snyWthr_lite=0.8
flex       drkWthr_lite=0.5
flex       addLight=0.0     local
flex       sec_lite=0.0     local

int        cur_mat=1     local
material   new_mat     local
material   day_mat
material   dusk_mat
material   night_mat
material   dawn_mat
int        is_day=1     local

flex       randNum=0.0     local
int        weather_type=0     local
# Trig Ints
int        changeweather_trig=1
#-----
end
#=====
code
#-----
startup:
  if(IsServer() || !IsMulti())
    {
    //-Make it start out as day...
    addLight = snyWthr_lite;
    for(a=0; a<GetSectorCount(); a=a+1)
      {
      //-look for the special sector flag...
      if(GetSectorFlags(a) & 0x100)
        {
        sec_lite = GetSectorLight(a);
        sec_lite = sec_lite + addLight;
        SetSectorLight(a, sec_lite, 0.0);
        }
      }
    for(b=0; b<GetSurfaceCount(); b=b+1)
      {
      //-look for the two types of sky flags...
      if(GetSurfaceFlags(b) & 0x200 || GetSurfaceFlags(b) & 0x400)
        {
        SetSurfaceMat(b, day_mat);
        }
      }
    is_day = 1;
    cur_mat = 1;
    SetTimerEx((dayNight * 0.25), 1, 0, 0);
    SetTimerEx(dayNight, 2, 0, 0);
    return;
    }
return;
#-----
timer:
  //-TIMER - (1) -
  //-Makes the light fade in and out...
  if(GetSenderID() == 1)
    {
    //-It is NIGHT, Make it go to DAY...
    if(is_day == 0)
      {
//    Print("Going to DAY...");
      Call choose_weather;
      for(a=0; a<GetSectorCount(); a=a+1)
        {
        //-look for the special sector flag...
        if(GetSectorFlags(a) & 0x100)
          {
          sec_lite = GetSectorLight(a);
          sec_lite = sec_lite + addLight;
          SetSectorLight(a, sec_lite, (dayNight * 1.75));
          }
        }
      is_day = 1;
      SetTimerEx((dayNight * 2), 1, 0, 0);
      return;
      }
    //-It is DAY, Make it go to NIGHT...
    else
    if(is_day == 1)
      {
//    Print("Going to NIGHT...");
      for(a=0; a<GetSectorCount(); a=a+1)
        {
        //-look for the special sector flag...
        if(GetSectorFlags(a) & 0x100)
          {
          sec_lite = GetSectorLight(a);
          sec_lite = sec_lite - addLight;
          SetSectorLight(a, sec_lite, (dayNight * 1.75));
          }
        }
      is_day = 0;
      SetTimerEx((dayNight * 2), 1, 0, 0);
      return;
      }
    return;
    }
  //-TIMER - (2) -
  //-Changes the sky to match the light fade...
  else
  if(GetSenderID() == 2)
    {
    //-Sky MAT is currently DAY...
    if(cur_mat == 1)
      {
      new_mat = dusk_mat;
      for(b=0; b<GetSurfaceCount(); b=b+1)
        {
        //-look for the two types of sky flags...
        if(GetSurfaceFlags(b) & 0x200 || GetSurfaceFlags(b) & 0x400)
          {
          SetSurfaceMat(b, new_mat);
          }
        }
      cur_mat = 2;
      SetTimerEx(dayNight, 2, 0, 0);
      return;
      }
    //-Sky MAT is currently DUSK...
    else
    if(cur_mat == 2)
      {
      new_mat = night_mat;
      for(b=0; b<GetSurfaceCount(); b=b+1)
        {
        //-look for the two types of sky flags...
        if(GetSurfaceFlags(b) & 0x200 || GetSurfaceFlags(b) & 0x400)
          {
          SetSurfaceMat(b, new_mat);
          }
        }
      cur_mat = 3;
      SetTimerEx(dayNight, 2, 0, 0);
      return;
      }
    //-Sky MAT is currently NIGHT...
    else
    if(cur_mat == 3)
      {
      new_mat = dawn_mat;
      for(b=0; b<GetSurfaceCount(); b=b+1)
        {
        //-look for the two types of sky flags...
        if(GetSurfaceFlags(b) & 0x200 || GetSurfaceFlags(b) & 0x400)
          {
          SetSurfaceMat(b, new_mat);
          }
        }
      cur_mat = 4;
      SetTimerEx(dayNight, 2, 0, 0);
      return;
      }
    //-Sky MAT is currently DAWN...
    else
    if(cur_mat == 4)
      {
      new_mat = day_mat;
      for(b=0; b<GetSurfaceCount(); b=b+1)
        {
        //-look for the two types of sky flags...
        if(GetSurfaceFlags(b) & 0x200 || GetSurfaceFlags(b) & 0x400)
          {
          SetSurfaceMat(b, new_mat);
          }
        }
      cur_mat = 1;
      SetTimerEx(dayNight, 2, 0, 0);
      return;
      }
    return;
    }
return;
#-----
choose_weather:
//  Print("choosing weather...");
  randNum = Rand();
  #=================#
  #- SUNNY weather -#
  #=================#
  if(randNum >= 0.9)
    {
    addLight = snyWthr_lite;
    weather_type = 0;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  #=================#
  #- RAINY weather -#
  #=================#
  else
  if(randNum < 0.9 && randNum >= 0.8)
    {
    addLight = drkWthr_lite;
    weather_type = 1;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  #=================#
  #- SNOWY weather -#
  #=================#
  else
  if(randNum < 0.8 && randNum >= 0.7)
    {
    addLight = drkWthr_lite;
    weather_type = 2;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  #=================#
  #- FOGGY weather -#
  #=================#
  else
  if(randNum < 0.7 && randNum >= 0.6)
    {
    addLight = drkWthr_lite;
    weather_type = 3;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  #===================#
  #- THUNDER weather -#
  #===================#
  else
  if(randNum < 0.6 && randNum >= 0.5)
    {
    addLight = drkWthr_lite;
    weather_type = 4;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  #=====================#
  #- LIGHTNING weather -#
  #=====================#
  else
  if(randNum < 0.5 && randNum >= 0.4)
    {
    addLight = drkWthr_lite;
    weather_type = 5;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  else
  if(randNum < 0.4 && randNum >= 0.3)
    {
    addLight = snyWthr_lite;
    weather_type = 0;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  else
  if(randNum < 0.3 && randNum >= 0.2)
    {
    addLight = snyWthr_lite;
    weather_type = 1;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  else
  if(randNum < 0.2 && randNum >= 0.1)
    {
    addLight = snyWthr_lite;
    weather_type = 0;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
  else
  if(randNum < 0.1)
    {
    addLight = snyWthr_lite;
    weather_type = 1;
    if(IsServer())
      {
      SendTrigger(-1, changeweather_trig, weather_type, 0, 0, 0);
      }
//  PrintInt(weather_type);
    return;
    }
return;
######
end

it works almost the same as the others that i made. the difference is the snywthr_lite flex and the drkwthr_lite. snywthr_lite is the light that it adds to the sectors when the weather is sunny. drkwthr_lite is the light that it adds to the sectors when the weather is a darker.
it does the random weather selecting every night, it has to change at night because it would mess up the sector light if you changed it while it was already fading.

heres the surface rain cog:
Code:
######
# Jedi Knight Cog Script  (JK)
#-----
# WEATHER_SURFRAIN00.COG
# Creates rain under all the surfaces that are facing
#  straight down and flaged as either 0x200 or 0x400.
#-----
# Written By DSLS_DeathSythe
# This COG is NOT supported by LucasArts Entertainment Co.
######
flags=0x240
symbols
#-----
message    startup
message    trigger
message    timer

flex       rainRange=4.0

flex       max_rainDelay=0.8

int        drops_prSrf=1

flex       max_XRdus=1.0
flex       max_YRdus=1.0

template   rain_tpl=+repeaterball

flex       ptch=-90.0
flex       yaw=0.0
vector     pyr_vec			local

int        weather_type=0

int        is_raining=0			local

thing      player=-1			local

surface    surf_A				local
int        drpCnt_A=0			local
vector     surf_centrA			local
sector     surf_secA			local
vector     rand_SvecA			local
flex       surf_VxA=0.0			local
flex       surf_VyA=.0.			local
flex       surf_VzA=0.0			local
flex       dalay01=0.0			local

surface    surf_B				local
int        drpCnt_B=0			local
vector     surf_centrB			local
sector     surf_secB			local
vector     rand_SvecB			local
flex       surf_VxB=0.0			local
flex       surf_VyB=.0.			local
flex       surf_VzB=0.0			local
flex       dalay02=0.0			local

surface    surf_C				local
int        drpCnt_C=0			local
vector     surf_centrC			local
sector     surf_secC			local
vector     rand_SvecC			local
flex       surf_VxC=0.0			local
flex       surf_VyC=.0.			local
flex       surf_VzC=0.0			local
flex       dalay03=0.0			local

surface    surf_D				local
int        drpCnt_D=0			local
vector     surf_centrD			local
sector     surf_secD			local
vector     rand_SvecD			local
flex       surf_VxD=0.0			local
flex       surf_VyD=.0.			local
flex       surf_VzD=0.0			local
flex       dalay04=0.0			local
# Trig Int
int        changeweather_trig=1
#-----
end
#=====
code
#-----
startup:
  player = GetLocalPlayerThing();
  pyr_vec = VectorSet(ptch, yaw, 0.0);
  is_raining = 0;
return;
#-----
trigger:
  if(GetSourceRef() == changeweather_trig)
    {
    //-Check to see if the trigger is for this cog...
    if(GetParam(0) == weather_type)
      {
      if(is_raining == 0)
        {
        //-Start the rain...
//      Print("starting the rain...");
        is_raining = 1;
        SetTimerEx(0.25, 1, 0, 0);
        SetTimerEx(0.5, 2, 0, 0);
        SetTimerEx(0.75, 3, 0, 0);
        SetTimerEx(1.0, 4, 0, 0);
        }
      return;
      }
    else
      {
      //-Stop the rain...
      is_raining = 0;
      KillTimerEx(1);
      KillTimerEx(2);
      KillTimerEx(3);
      KIllTimerEx(4);
      return;
      }
    return;
    }
return;
#-----
timer:
  //-TIMER - (1) -
  if(GetSenderID() == 1)
    {
    for(surf_A=0; surf_A<GetSurfaceCount(); surf_A=surf_A+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if(GetSurfaceFlags(surf_A) & 0x200 || GetSurfaceFlags(surf_A) & 0x400)
        {
        if(VectorZ(GetSurfaceNormal(surf_A)) == -1.0)
          {
          //-Get the surfaces center and sector...
          surf_centrA = GetSurfaceCenter(surf_A);
          surf_secA = GetSurfaceSector(surf_A);
          surf_VxA = VectorX(surf_centrA);
          surf_VyA = VectorY(surf_centrA);
          surf_VzA = VectorZ(surf_centrA);
          surf_VzA = surf_VzA - 0.025;
          for(drpCntA=0; drpCntA<drops_prSrf; drpCntA=drpCntA+1)
            {
            //-Randomize the surface vector...
            rand_SvecA = VectorSet(((surf_VxA + (Rand() - 0.5) * max_XRdus)), ((surf_VyA + (Rand() - 0.5) * max_YRdus)), surf_VzA);
            //-Check to see if the new vector is close enough to the player...
            if(VectorDist(rand_SvecA, GetThingPos(player)) <= rainRange)
              {
              CreateThingAtPos(rain_tpl, surf_secA, rand_SvecA, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset this timer...
    delay01 = Rand();
    if(delay01 > max_rainDelay)
      {
      delay01 = max_rainDelay;
      }
    SetTimerEx(delay01, 1, 0, 0);
    return;
    }
  else
  //-TIMER - (2) -
  if(GetSenderID() == 2)
    {
    for(surf_B=0; surf_B<GetSurfaceCount(); surf_B=surf_B+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if(GetSurfaceFlags(surf_B) & 0x200 || GetSurfaceFlags(surf_B) & 0x400)
        {
        if(VectorZ(GetSurfaceNormal(surf_B)) == -1.0)
          {
          //-Get the surfaces center and sector...
          surf_centrB = GetSurfaceCenter(surf_B);
          surf_secB = GetSurfaceSector(surf_B);
          surf_VxB = VectorX(surf_centrB);
          surf_VyB = VectorY(surf_centrB);
          surf_VzB = VectorZ(surf_centrB);
          surf_VzB = surf_VzB - 0.025;
          for(drpCntB=0; drpCntB<drops_prSrf; drpCntB=drpCntB+1)
            {
            //-Randomize the surface vector...
            rand_SvecB = VectorSet(((surf_VxB + (Rand() - 0.5) * max_XRdus)), ((surf_VyB + (Rand() - 0.5) * max_YRdus)), surf_VzB);
            //-Check to see if the new vector is close enough to the player...
            if(VectorDist(rand_SvecB, GetThingPos(player)) <= rainRange)
              {
              CreateThingAtPos(rain_tpl, surf_secB, rand_SvecB, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset this timer...
    delay02 = Rand();
    if(delay02 > max_rainDelay)
      {
      delay02 = max_rainDelay;
      }
    SetTimerEx(delay02, 2, 0, 0);
    return;
    }
  else
  //-TIMER - (3) -
  if(GetSenderID() == 3)
    {
    for(surf_C=0; surf_C<GetSurfaceCount(); surf_C=surf_C+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if(GetSurfaceFlags(surf_C) & 0x200 || GetSurfaceFlags(surf_C) & 0x400)
        {
        if(VectorZ(GetSurfaceNormal(surf_C)) == -1.0)
          {
          //-Get the surfaces center and sector...
          surf_centrC = GetSurfaceCenter(surf_C);
          surf_secC = GetSurfaceSector(surf_C);
          surf_VxC = VectorX(surf_centrC);
          surf_VyC = VectorY(surf_centrC);
          surf_VzC = VectorZ(surf_centrC);
          surf_VzC = surf_VzC - 0.025;
          for(drpCntC=0; drpCntC<drops_prSrf; drpCntC=drpCntC+1)
            {
            //-Randomize the surface vector...
            rand_SvecC = VectorSet(((surf_VxC + (Rand() - 0.5) * max_XRdus)), ((surf_VyC + (Rand() - 0.5) * max_YRdus)), surf_VzC);
            //-Check to see if the new vector is close enough to the player...
            if(VectorDist(rand_SvecC, GetThingPos(player)) <= rainRange)
              {
              CreateThingAtPos(rain_tpl, surf_secC, rand_SvecC, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset this timer...
    delay03 = Rand();
    if(delay03 > max_rainDelay)
      {
      delay03 = max_rainDelay;
      }
    SetTimerEx(delay03, 3, 0, 0);
    return;
    }
  else
  //-TIMER - (4) -
  if(GetSenderID() == 4)
    {
    for(surf_D=0; surf_D<GetSurfaceCount(); surf_D=surf_D+1)
      {
      //-Look for all surfaces that are flaged as SKY...
      if(GetSurfaceFlags(surf_D) & 0x200 || GetSurfaceFlags(surf_D) & 0x400)
        {
        if(VectorZ(GetSurfaceNormal(surf_D)) == -1.0)
          {
          //-Get the surfaces center and sector...
          surf_centrD = GetSurfaceCenter(surf_D);
          surf_secD = GetSurfaceSector(surf_D);
          surf_VxD = VectorX(surf_centrD);
          surf_VyD = VectorY(surf_centrD);
          surf_VzD = VectorZ(surf_centrD);
          surf_VzD = surf_VzA - 0.025;
          for(drpCntD=0; drpCntD<drops_prSrf; drpCntD=drpCntD+1)
            {
            //-Randomize the surface vector...
            rand_SvecD = VectorSet(((surf_VxD + (Rand() - 0.5) * max_XRdus)), ((surf_VyD + (Rand() - 0.5) * max_YRdus)), surf_VzD);
            //-Check to see if the new vector is close enough to the player...
            if(VectorDist(rand_SvecD, GetThingPos(player)) <= rainRange)
              {
              CreateThingAtPos(rain_tpl, surf_secD, rand_SvecD, pyr_vec);
              }
            }
          }
        }
      }
    //-Reset this timer...
    delay04 = Rand();
    if(delay04 > max_rainDelay)
      {
      delay04 = max_rainDelay;
      }
    SetTimerEx(delay04, 1, 0, 0);
    return;
    }
return;
######
end

add one of these cogs for each weather type.
the weather_type int is the important part it tells the cog when it's its turn to make its rain/snow/lightning/whatever...
the int is a 1-5 number.
-----
1 = rain
2 = snow
3 = fog
4 = thunder
5 = lightning
-----
the day night sends a trigger with the random weather_type int in it, the surf rain cogs check to see if the number is theirs. if it is then that cog starts its weather effect, if its not then it stops it weather effect. the day night cog uses 0 as the weather_type that makes it sunny so dont set any of the surf rain cogs weather_type ints to 0.

heres the cog that makes the fog effect.
Code:
######
# Jedi Knight Cog Script  (JK)
#-----
# WEATHER_FOG00.COG
# Creates a fog like effect.
#-----
# Written By DSLS_DeathSythe
# This COG is NOT supported by LucasArts Entertainment Co.
######
flags=0x240
symbols
#-----
message    startup
message    trigger

flex       fog_red=0.0
flex       fog_grn=0.0
flex       fog_blu=0.0

thing      player=-1     local

int        effectHandle=-1     local

int        weather_type=0
int        is_on=0     local
# Trig Ints
int        changeweather_trig=1
#-----
end
#=====
code
#-----
startup:
  player = GetLocalPlayerThing();
  is_on = 0;
return;
#-----
trigger:
  if(GetSourceRef() == changeweather_trig)
    {
    if(GetParam(0) == weather_type)
      {
//    Print("making FOG");
      if(is_on == 0)
        {
//      Print("FOG on...");
        is_on = 1;
        effectHandle = newColorEffect(0, 0, 0, 0, 0, 0, fog_red, fog_grn, fog_blu, 1.0);
        }
      return;
      }
    else
      {
      is_on = 0;
      if(effectHandle != -1)
        {
        freeColorEffect(effectHandle);
        effectHandle = -1;
        }
      return;
      }
    return;
    }
return;
######
end

set the weather_type of this cog to what ever weather condition you want it to be foggy. 3 is the normal one.
it does turn off and isnt too thick like it was before.
if there is a surf rain cog that has the same weather_type as the fog cog then both cogs will go at the same time.

they should work in both MP and SP but i didnt do any tests with more than myself in the level.

hope you understood all that im not the best at explaining stuff, enjoy.

------------------
Famous last words - "It seemed like a good idea at the time."

[This message has been edited by DSLS_DeathSythe (edited June 30, 2003).]

[This message has been edited by DSLS_DeathSythe (edited June 30, 2003).]
Famous last words - "It seemed like a good idea at the time."
2003-07-13, 9:11 AM #18
oh thank the gods. its perfect thanks [http://forums.massassi.net/html/biggrin.gif]

------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?

↑ Up to the top!