I've got this thermal goggles cog that I've been having some problems with.
Note use of code tags.
The problem is as this. The cog, activates and works fine. Then when you deactivate, it changes some surfaces to HOM (assuming a geomode of < 3, most likely 0). Then when you reactivate, it crashes the game. Any ideas on how to help?
------------------
The Sniper Missions. Current project, The Sniper Missions
The Magician Saber System.
The 2 riddle!
Code:
# Jedi Knight Cog Script # # ITEM_THGOGGLES.COG # # Thermal Goggles # This set the world to blue to red solid hues and adds fog. # This changes the models to their heat version. # # [DP] # symbols thing player int effectHandle=-1 int i int j flex distance material thmat=00_blue.mat message activated message pulse message killed message startup sound goggleActivate=activate01.wav sound goggleDeactivate=deactivate03.wav end # ======================================================================================== code Startup: player = GetLocalPlayerThing(); HeapFree(); Return; # ........................................................................................ Activated: If(GetInv(player, 135)) { If(IsInvActivated(player, 135) == 0) { If(GetInv(player, 13) > 0) { Print("Thermal Goggles ON"); SetInvActivated(player, 135, 1); PlaySoundThing(goggleActivate, player, 1, -1, -1, 0x80); effectHandle = newColorEffect(0, 0, 1, 0, 0, 2, 10, 0, 45, .5); HeapNew(0, GetSurfaceCount()*4); For(i=0; i<GetSurfaceCount(); i=i+1) { distance = 0; HeapSet(i, GetSurfaceMat(i)); HeapSet(GetSurfaceCount()+i, GetFaceGeoMode(i)); HeapSet(GetSurfaceCount()*2+i, GetFaceLightMode(i)); HeapSet(GetSurfaceCount()*3+i, GetSurfaceLight(i)); EnableIRMode(0, 1); // For(j=0; j<GetNumSurfaceVertices(i); j=j+1) // { // If(distance < VectorDist(GetThingPos(player), GetSurfaceVertexPos(i, j))) // distance = VectorDist(GetThingPos(player), GetSurfaceVertexPos(i, j)); // } distance = VectorDist(GetThingPos(player), GetSurfaceCenter(i)); // If(distance >= 5) distance = 5; SetSurfaceMat(i, thmat); If(GetFaceGeoMode(i) != 0) SetFaceGeoMode(i, 3); SetFaceLightMode(i, 3); SetSurfaceLight(i, 1-(distance/5), 0); } SetPulse(0.025); } Else { Print("Thermal Goggles Out Of Power"); PlaySoundThing(goggleDeactivate, player, 1, -1, -1, 0x80); } } Else { Print("Thermal Goggles OFF"); SetInvActivated(player, 135, 0); PlaySoundThing(goggleDeactivate, player, 1, -1, -1, 0x80); If(effectHandle != -1) freeColorEffect(effectHandle); DisableIRMode(); SetPulse(0); For(i=0; i<GetSurfaceCount(); i=i+1) { SetSurfaceMat(i, HeapGet(i)); SetFaceGeoMode(i, HeapGet(GetSurfaceCount() + i)); SetFaceLightMode(i, HeapGet(GetSurfaceCount()*2 + i)); SetSurfaceLight(i, HeapGet(GetSurfaceCount()*3 + i), 0); } HeapFree(); } } Return; # ........................................................................................ Pulse: ChangeInv(player, 13, -0.075); For(i=0; i<GetSurfaceCount(); i=i+1) { distance = 0; // For(j=0; j<GetNumSurfaceVertices(i); j=j+1) // { // If(distance < VectorDist(GetThingPos(player), GetSurfaceVertexPos(i, j))) // distance = VectorDist(GetThingPos(player), GetSurfaceVertexPos(i, j)); // } distance = VectorDist(GetThingPos(player), GetSurfaceCenter(i)); // If(distance >= 5) distance = 5; SetSurfaceLight(i, 1-(distance/5), 0); } If(GetInv(player, 13) <= 0) { Print("Thermal Goggles Out Of Power"); SetInvActivated(player, 135, 0); PlaySoundThing(goggleDeactivate, player, 1.0, -1, -1, 0x80); If(effectHandle != -1) freeColorEffect(effectHandle); DisableIRMode(); SetPulse(0); For(i=0; i<GetSurfaceCount(); i=i+1) { SetSurfaceMat(i, HeapGet(i)); SetFaceGeoMode(i, HeapGet(GetSurfaceCount() + i)); SetFaceLightMode(i, HeapGet(GetSurfaceCount()*2 + i)); SetSurfaceLight(i, HeapGet(GetSurfaceCount()*3 + i), 0); } HeapFree(); } Return; # ........................................................................................ Killed: If(GetSenderRef() != player) Return; If(IsInvActivated(player, 135) == 1) { SetPulse(0); SetInvActivated(player, 135, 0); If(effectHandle != -1) freeColorEffect(effectHandle); DisableIRMode(); For(i=0; i<GetSurfaceCount(); i=i+1) { SetSurfaceMat(i, HeapGet(i)); SetFaceGeoMode(i, HeapGet(GetSurfaceCount() + i)); SetFaceLightMode(i, HeapGet(GetSurfaceCount()*2 + i)); SetSurfaceLight(i, HeapGet(GetSurfaceCount()*3 + i), 0); } HeapFree(); } Return; end
Note use of code tags.
The problem is as this. The cog, activates and works fine. Then when you deactivate, it changes some surfaces to HOM (assuming a geomode of < 3, most likely 0). Then when you reactivate, it crashes the game. Any ideas on how to help?
------------------
The Sniper Missions. Current project, The Sniper Missions
The Magician Saber System.
The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms
Completed
Judgement Day (HLP), My level pack
SATNRT, JK Pistol Mod, Aliens TC, Firearms
Completed
Judgement Day (HLP), My level pack