Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class WalkTracer : LineTracer
- {
- Line lastLine; //unused right now
- Sector LastSector; //store last found sector
- double LastStepHeight; //last sector height
- vector3 HitPoint; //place where I found a ledge
- bool HitLedge; //did I find a ledge?
- actor owner; //caller
- int hitcount; //count the number of times there's an intersection
- double MaxStepHeight; //gotten from actor
- override ETraceStatus TraceCallback()
- {
- sector NextSector = Results.HitSector;
- if (!NextSector) return TRACE_skip; //if sector has not changed, continue tracing
- if(NextSector != LastSector) //sector has changed
- {
- //count the number of times i encounter a new sector
- hitcount++;
- console.printf('HIT %i', hitcount);
- vector3 hitpos = Results.HitPos;
- //get the floor height at this point
- double NextStepHeight = NextSector.floorplane.ZatPoint(hitpos.XY);
- //difference between current and last floor height
- double stepDifference = NextStepHeight - LastStepHeight;
- //store last sector
- LastSector = NextSector;
- //store last step height
- LastStepHeight = NextStepHeight;
- if ( stepDifference > MaxStepHeight ) {
- HitLedge = true;
- return TRACE_Stop;
- } else if (stepDifference < -MaxStepHeight ) {
- HitLedge = true;
- return TRACE_Stop;
- } else {
- return TRACE_skip;
- }
- } else {
- return TRACE_skip;
- }
- if(Results.HitType == TRACE_HitActor)
- {
- return TRACE_skip;
- }
- return TRACE_Stop;
- }
- bool TraceFrom (actor caller, vector3 start, Sector sec, vector3 direction, double maxDist, ETraceFlags traceFlags)
- {
- self.hitcount = 0; //reset count
- self.owner = caller; //the thing that is doing the trace
- self.MaxStepHeight = caller.MaxStepHeight; //the maximum vertical movement we consider a blocking height
- self.LastSector = sec; //record sector
- self.lastLine = null; //unused
- self.HitLedge = false; //reset hit
- self.LastStepHeight = sec.floorplane.ZatPoint(start.XY); //get starting floor height
- return Trace (start, sec, direction, maxDist, traceFlags);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement