Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vector CheckTeleportConditions(float Dist, int TeleportationMethod)
- {
- local NavigationPoint N;
- local vector ViewPoint, Best;
- local Rotator Rot;
- local float Rating, NewRating;
- local Vector HitLocation, HitNormal, EndTrace;
- local Actor jActor;
- local int i, NumberOfIterations;
- local int TeleportDistNum;
- TeleportDistNum = 1024;
- Switch(TeleportationMethod)
- {
- /*
- //Teleports really close to enemy
- */
- Case(0) :
- if (Dist < TeleportDistNum || Controller.Enemy == None)
- return vect(0,0,0);
- Rot = Controller.Enemy.Rotation;
- NumberOfIterations = 4;
- for (i = 0; i <= NumberOfIterations; i++)
- {
- Rot.Yaw += Rand(32768) + 16384*i; //Randomly teleport around the enemy
- EndTrace = Controller.Enemy.Location + vector(Rot) * Clamp(GroundSpeed, 96, 256);
- Trace(HitLocation, HitNormal, EndTrace, Controller.Enemy.Location);
- //Do a FastTrace here to make sure we have some world geometry below us to hit.
- if (!FastTrace((HitLocation+vect(0,0,-10240)),HitLocation) )
- continue;
- else
- {
- if (!bool(HitLocation))
- HitLocation = EndTrace;
- HitLocation.Z += CollisionHeight * 0.5;
- return HitLocation;
- break;
- }
- }
- /*
- //Teleport to midpoint between enemy and self
- */
- Case(1) :
- if (Dist < TeleportDistNum || Controller.Enemy == None)
- return vect(0,0,0);
- Rot = Rotation;
- NumberOfIterations = 4;
- for (i = 0; i <= NumberOfIterations; i++)
- {
- Rot.Yaw += Rand(8192) + 16384*i; //Randomly teleport around the enemy
- EndTrace = Location + Controller.Enemy.Location;
- EndTrace *= 0.5;
- EndTrace = Location + vector(Rot) * VSize(EndTrace - Location);
- Trace(HitLocation, HitNormal, EndTrace, Controller.Enemy.Location);
- //Do a FastTrace here to make sure we have some world geometry below us to hit.
- if (!FastTrace((HitLocation+vect(0,0,-10240)),HitLocation) )
- continue;
- else
- {
- if (!bool(HitLocation))
- HitLocation = EndTrace;
- HitLocation.Z += CollisionHeight * 0.5;
- return HitLocation;
- break;
- }
- }
- /*
- //Teleport to a more distance location between enemy and self
- */
- Case(2) :
- if (Dist > TeleportDistNum || Controller.Enemy == None)
- return vect(0,0,0);
- Rot = Rotation;
- NumberOfIterations = 4;
- for (i = 0; i <= NumberOfIterations; i++)
- {
- Rot.Yaw += Rand(8192) + 16384*i; //Randomly teleport around the enemy
- EndTrace = Location + Controller.Enemy.Location;
- EndTrace *= 2.0;
- EndTrace = Location + vector(Rot) * VSize(EndTrace - Location);
- Trace(HitLocation, HitNormal, EndTrace, Controller.Enemy.Location);
- //Do a FastTrace here to make sure we have some world geometry below us to hit.
- if (!FastTrace((HitLocation+vect(0,0,-10240)),HitLocation) )
- continue;
- else
- {
- if (!bool(HitLocation))
- HitLocation = EndTrace;
- HitLocation.Z += CollisionHeight * 0.5;
- return HitLocation;
- break;
- }
- }
- /*
- //Teleport away from enemy using navigation points, set this as default in case we don't return from any of the
- */
- default :
- if (Dist > TeleportDistNum || Controller.Enemy == None)
- return vect(0,0,0);
- Best = Location;
- Rating = 0;
- for ( N=Level.NavigationPointList; N!=None; N=N.NextNavigationPoint )
- {
- NewRating = 0;
- ViewPoint = N.Location + vect(0,0,1)*CollisionHeight/2;
- if (VSize(ViewPoint - Location) > TeleportDistNum * 3 || !LineOfSightTo(N))
- NewRating -= 200000; //can't see player don't bother with this one
- NewRating += VSize(N.Location - Controller.Enemy.Location) + 1000 * FRand();
- foreach N.VisibleCollidingActors(class'Actor',jActor,CollisionRadius,ViewPoint)
- NewRating -= 30000;
- if ( NewRating > Rating )
- {
- Rating = NewRating;
- Best = N.Location;
- }
- }
- if (Best == Location)
- return Vect(0,0,0);
- else
- return Best;
- }
- return vect(0,0,0);
- }
Add Comment
Please, Sign In to add comment