I have designed a cog to create a translucent bridge. However, the flags are not all quite how I want them, and I wonder if anyone can help? I have two two main problems - how can I stop the walkplayer sinking into the bridge surface? And whycan any AI that crosses the bridge keep crossing even if you turn off the bridge while they are halfway?
Code:
#!/usr/bin/perl # # Jedi Knight Cog Script # # energy_bridge_basic.cog # # this script activates an energy bridge when a switch is activated or damaged. # It sets the surface to be a floor and translucent. # Shooting or activating switch will turn it off (but only when AIs shoot) # Adapted from 10_ffieldswitch.cog # # This COG is not supported by Lucasfilms Entertainment # # symbols message startup message damaged message activated message timer surface switch linkid=1 mask=0x448 surface energysurf mask=0x408 surface energysurf2 mask=0x408 surface energysurf3 mask=0x408 sound bridgeon=forcefieldon01.wav local sound bridgeoff=forcefieldoff01.wav local sound bridgehum=forcefieldhum01.wav local sound bridgehit=forcefieldhit01.wav local end code startup: SetWallCel(switch,0); //off SetAdjoinFlags(energysurf,0); //passable SetAdjoinFlags(energysurf2,0); SetAdjoinFlags(energysurf3,0); SetFaceGeoMode(energysurf,0); //see through SetFaceGeoMode(energysurf2,0); SetFaceGeoMode(energysurf3,0); PlaySoundPos(bridgehum, GetSurfaceCenter(energysurf), 1.0, 1, 10, 0x1); return; activated: if (GetSenderID() != 1) return; if (GetWallCel(switch) == 0) { SetWallCel(switch,1); //on SetAdjoinFlags(energysurf,0x10); //impassable SetAdjoinFlags(energysurf2,0x10); SetAdjoinFlags(energysurf3,0x10); PlaySoundLocal(bridgeon, 1, 0, 0); SetFaceGeoMode(energysurf,0x4); //translucent/shows texture SetFaceGeoMode(energysurf2,0x4); SetFaceGeoMode(energysurf3,0x4); SetFaceType(energysurf,0x6); // or maybe this makes translucent? SetFaceType(energysurf2,0x6); SetFaceType(energysurf3,0x6); SetSurfaceFlags(energysurf,0x5); // floor SetSurfaceFlags(energysurf2,0x5); SetSurfaceFlags(energysurf3,0x5); } else if (GetWallCel(switch) == 1) { PlaySoundLocal(bridgeoff, 1, 0, 0); SetWallCel(switch,0); //off ClearAdjoinFlags(energysurf,0x10); //passable ClearAdjoinFlags(energysurf2,0x10); ClearAdjoinFlags(energysurf3,0x10); SetFaceGeoMode(energysurf,0); //no texture SetFaceGeoMode(energysurf2,0); SetFaceGeoMode(energysurf3,0); SetSurfaceFlags(energysurf,0); //no floor SetSurfaceFlags(energysurf2,0); SetSurfaceFlags(energysurf3,0); } return; fieldflash: SetFaceGeoMode(energysurf,4); // Energy bridge reacts when hit by weapon SetFaceGeoMode(energysurf2,4); SetFaceGeoMode(energysurf3,4); SetFaceType(energysurf,0); // or maybe this makes it appear solid for a moment? SetFaceType(energysurf2,0); SetFaceType(energysurf3,0); KillTimerEx(1); SetTimerEx(0.5, 1, 0, 0); return; damaged: if (GetWallCel(switch) == 1) return; if (GetSenderID() == 1) { call activated; } else { call fieldflash; } return; timer: SetFaceGeoMode(energysurf,4); // Returns bridge to translucent SetFaceGeoMode(energysurf2,4); SetFaceGeoMode(energysurf3,4); SetFaceType(energysurf,0x6); // or maybe this makes translucent? SetFaceType(energysurf2,0x6); SetFaceType(energysurf3,0x6); Return; end