RayCast

From Soldat Community Wiki
Jump to: navigation, search
function RayCast(P1X, P1Y, P2X, P2Y: single; var Distance: single; MaxDist: integer): boolean;

Parameter Info:
 P1X (Single): X coordinate of Point 1
 P1Y (Single): Y coordinate of Point 1
 P2X (Single): X coordinate of Point 2
 P2Y (Single): Y coordinate of Point 2
 Distance (Single): You must specify a variable that will hold the distance from Point1 to Point2
 MaxDist (Integer): Maximum distance that RayCast will scan.

Description:
 This function will check if Point 2 is visible from Point 1, meaning no player/bullet colliding   polygons in between the two points. 
 The main purpose of this is for use with CreateBullet, so it may   return true if there are "Only   Player Collides" polygons between the two points.

Examples

var
  Dist,x,y: Single;
begin
  x := GetPlayerStat(1,'x');
  y := GetPlayerStat(1,'y'); 
  if not RayCast(x,y,x,y - 700,Dist,800) then begin
    // Player 1 must be under cover! So we cant really drop da bomb.
    exit;
  // CreateBullet goes here.
  end
end;


External Links