0 Members and 1 Guest are viewing this topic.
var d: single; c: array[1..4] of single;function xsplit(const source: string; const delimiter: string):TStringArray; // by KeYDoN, fixed according to forums.soldat.plvar i,x,d: integer; s: string;begin d := length(delimiter); x := 0; i := 1; SetArrayLength(Result,0); SetArrayLength(Result,1); while(i <= length(source)) do begin s := Copy(source,i,d); if(s = delimiter) then begin inc(i,d); inc(x,1); SetArrayLength(result,x+1); end else begin result[x] := result[x]+Copy(s,1,1); inc(i,1); end; end;end;procedure rayit(x1,y1,x2,y2: single);var i: integer; win: boolean;begin writeln(''); writeln(inttostr(round(x1))+':'+inttostr(round(y1))); writeln(inttostr(round(x2))+':'+inttostr(round(y2))); // CreateBullet(x1,y1,0,-1,0,5,32);// CreateBullet(x2,y2,0,1,0,5,32); WorldImage(0,1,28,x1,y1,1.0); WorldText(0,2,'1: '+inttostr(round(x1))+','+inttostr(round(y1)),x1+20,y1,$FFFFFF,1,1); WorldImage(0,3,28,x2,y2,1.0); WorldText(0,4,'2: '+inttostr(round(x2))+','+inttostr(round(y2)),x2+20,y2,$FFFFFF,1,1); win := RayCast(x1,y1,x2,y2,d,9001); if win then writeln(inttostr(round(d))) else writeln(inttostr(round(-d))); WorldText(0,5,inttostr(round(d))+#13#10+inttostr(round(distance(x1,y1,x2,y2))),x1+(x2-x1)/2,y1+(y2-y1)/2,iif(win,$00FF00,$FF0000),5,1); end; function OnCommand(ID: Byte; Text: string): boolean;var a: tstringarray;begin a := xsplit(text,' '); case a[0] of '/t': WorldText(1,6,'bahoonas',0,0,$FFFFFF,strtoint(a[1]),strtofloat(a[2])); '/ray','/r': rayit(strtofloat(a[1]),strtofloat(a[2]),strtofloat(a[3]),strtofloat(a[4])); '/use','/revive': rayit(c[1],c[2],c[3],c[4]); '/r1': begin c[1] := strtofloat(a[1]); c[2] := strtofloat(a[2]); rayit(c[1],c[2],c[3],c[4]); end; '/r2': begin c[3] := strtofloat(a[1]); c[4] := strtofloat(a[2]); rayit(c[1],c[2],c[3],c[4]); end; '/ray1','/heal','/cc1','/cmmd1','/def','/cc2','/cmmd2': begin c[1] := getplayerstat(id,'x'); c[2] := getplayerstat(id,'y'); rayit(c[1],c[2],c[3],c[4]); end; '/ray2','/ofs','/cc3','/cmmd3','/smn','/summon','/cc4','/cmmd4': begin c[3] := getplayerstat(id,'x'); c[4] := getplayerstat(id,'y'); rayit(c[1],c[2],c[3],c[4]); end; end; end;
It may be slow, but you could approximate it by a loopy loop of RayCast.