# Jedi Knight Cog Script # # prl_10_FFieldSwitch.COG # 10_FFieldSwitch.cog imported into MOTS # modified by Sylvicolus [PRL] August 2001 # http://www.lactarius.com/sylvicolus/jk/ # # Two separate forcefields operated by the same switch. # Activating switch will turn both off. # damsurf_1a and 1b are one forcefield; 2a and 2b the optional 2nd forcefield. # The forcefields generate their own sounds so they don't need to be next to each other. # # Forcefield surfaces are only visible when hit. # Surfaces are set to be nomove, magsealed, invisible. # Shooting switch will also work if variable shootable is set to = 1 # Forcefield will be on at startup unless OffAtStart=1 # # This cog is not supported by LucasArts Entertainment Co. symbols message startup message damaged message activated message touched message timer surface switch linkid=1 mask=0x448 surface damsurf_1a linkid=11 mask=0x448 surface damsurf_1b linkid=11 mask=0x448 surface damsurf_2a linkid=12 mask=0x448 surface damsurf_2b linkid=12 mask=0x448 flex maxdamage=10.0 flex mindamage=5.0 flex damage=0.0 local flex HumVolume=1.0 flex HumMaxDistance=10 int shootable=1 int OffAtStart=0 sound powerup=forcefieldon01.wav local sound powerdown=forcefieldoff01.wav local sound wav0=forcefieldhum01.wav local sound wav1=forcefieldhit01.wav local int HumChannel_1 local int HumChannel_2 local flex FadeOut=0.3 local int garbage=0 local thing victim local end code startup: sleep(1); SetFaceGeoMode(damsurf_1a,0); //invisible SetFaceGeoMode(damsurf_1b,0); SetSurfaceFlags(damsurf_1a,16384); //magsealed SetSurfaceFlags(damsurf_1b,16384); if ((damsurf_2a) && (damsurf_2b)) //second force field { SetFaceGeoMode(damsurf_2a,0); SetFaceGeoMode(damsurf_2b,0); SetSurfaceFlags(damsurf_2a,16384); SetSurfaceFlags(damsurf_2b,16384); } if (OffAtStart==1) { SetWallCel(switch,1); // green = off return; } else { call fieldon; } return; activated: touched: if (GetSenderID() == 1) //player touches switch { if (GetWallCel(switch) == 0) { call fieldoff; } else if (GetWallCel(switch) == 1) { call fieldon; } return; } else if (GetSenderID() >= 11) //player touches a forcefield { if (GetSenderID() == 11) call fieldflash1; if (GetSenderID() ==12) call fieldflash2; victim = GetSourceRef(); damage = (Rand()*(maxdamage - mindamage))+mindamage; garbage = DamageThing(victim, damage, 0x4, victim); PlaySoundPos(wav1, GetThingPos(victim), 1.0, 1, 10, 0x80); } Return; fieldon: SetWallCel(switch,0); //red = on garbage = PlaySoundPos(powerup, GetSurfaceCenter(switch), 1, 1, 1, 0); HumChannel_1 = PlaySoundPos(wav0, GetSurfaceCenter(damsurf_1a), HumVolume, 1, HumMaxDistance, 0x1); ClearAdjoinFlags(damsurf_1a,10); //no move ClearAdjoinFlags(damsurf_1b,10); if ((damsurf_2a) && (damsurf_2b)) //second force field { HumChannel_2 = PlaySoundPos(wav0, GetSurfaceCenter(damsurf_2a), HumVolume, 1, HumMaxDistance, 0x1); ClearAdjoinFlags(damsurf_2a,10); ClearAdjoinFlags(damsurf_2b,10); } return; fieldoff: SetWallCel(switch,1); //off garbage = PlaySoundPos(powerdown, GetSurfaceCenter(switch), 1, 1, 1, 0); StopSound(HumChannel_1,FadeOut); SetAdjoinFlags(damsurf_1a,10); //move SetAdjoinFlags(damsurf_1b,10); if ((damsurf_2a) && (damsurf_2b)) //second force field { StopSound(HumChannel_2,FadeOut); SetAdjoinFlags(damsurf_2a,10); SetAdjoinFlags(damsurf_2b,10); } return; damaged: if ((GetSenderID() == 1) && (shootable)) call activated; return; if (GetSenderID() == 11) call fieldflash1; return; if (GetSenderID() == 12) call fieldflash2; return; return; fieldflash1: SetFaceGeoMode(damsurf_1a,4); SetFaceGeoMode(damsurf_1b,4); KillTimerEx(1); SetTimerEx(0.5, 1, 0, 0); return; fieldflash2: SetFaceGeoMode(damsurf_2a,4); SetFaceGeoMode(damsurf_2b,4); KillTimerEx(2); SetTimerEx(0.5, 2, 0, 0); return; timer: if (GetSenderID() == 1) // timer 1 { SetFaceGeoMode(damsurf_1a,0); SetFaceGeoMode(damsurf_1b,0); } else if (GetSenderID() == 2) // timer 2 { SetFaceGeoMode(damsurf_2a,0); SetFaceGeoMode(damsurf_2b,0); } Return; end