# Jedi Knight Cog Script # # flicker.cog # # Makes it so that 3dos crossing more than one sector don't # flicker or disappear and also when the player looks at it # # Go go Hellcat for explaining this to me. =) # # Concept by Hellcat (and GBK?) # Raped for TDiR by Hell Raiser [Jon Harmon] # Some bug fixing modifications by Shred18 # Implemented sector finding code by Sige flags=0x240 symbols int ObjCount local thing ObjThng0 int running=0 local int sectorid local int sectorcount local int surfacecount local int s local int f local int x local flex dot1 local flex dot2 local vector testpt local template ObjTpl0 local vector ObjPos0 local vector ObjLook0 local message startup message pulse end code startup: //Sleep while the level loads sleep(0.25); player=GetLocalPlayerThing(); ObjCount=0; if(ObjThng0 != -1) ObjCount=ObjCount+1; //Get the rotation and position and template of the object ObjPos0=GetThingPos(ObjThng0); ObjLook0=GetThingLVec(ObjThng0); ObjTpl0=GetThingTemplate(ObjThng0); //Start our pulse SetPulse(0.01); return; pulse: if(GetThingSector(ObjThng0) == GetThingSector(Player)){return;} testpt = VectorAdd(GetThingPos(player), VectorSet(0,0,0.037)); //actual camera position vector sectorid = -1; sectorcount = GetSectorCount(); for (s = 0; s < sectorcount; s = s + 1) { surfacecount = GetNumSectorSurfaces(s); for (f = 0; f < surfacecount; f = f + 1) { dot1 = VectorDot(testpt, GetSurfaceNormal(GetSectorSurfaceRef(s, f))); dot2 = VectorDot(GetSurfaceVertexPos(GetSectorSurfaceRef(s, f), 0), GetSurfaceNormal(GetSectorSurfaceRef(s, f))); // outside of the sector if (dot1 < dot2) { f = 9999999; } } if (f != 10000000) { sectorid = s; s = 9999999; } } //Printint(GetThingSector(Player)); //Printint(sectorid); //Printint(ObjThng0); //Destroy the 3do DestroyThing(ObjThng0); //Recreate the 3do ObjThng0=CreateThingAtPos(ObjTpl0, sectorid, ObjPos0, ObjLook0); //SetThingLook(ObjThng0, ObjLook0); return; end