Special Ed
2007-06-04 18:46:26
Well… after a lot of FindFire functions failing, working, sometimes working, finding other things, and not working in the least bit I think I've found a very solid FindFire function. Me and Sky Scripter have been kind of "battling" to see who can make the best Findfire function. Because mine works for me and his works for him, but they both don't work good for each other, so we ended up remaking them over.. and over.. so I think I've finally got it.
It doesn't work at all angles because I was just testing it at square angles. N,S,E,W. But to make it work at all angles I think I'd just have to use FindDTMRotated oh well… Also remember to tell me how it worked, or any ideas you have on improving it.
Here it is!
*Also I think I am the first person to use "Array of Boolean" Lol :) .*
If all of the DTM's turn up False please let me know, I don't think I set the tolerance high enough…
EDIT: Apparently it does work at all angles, a few people that have tested it have gotten it to work at all angles and it does seems to work for me too XD. What a bonus!
It doesn't work at all angles because I was just testing it at square angles. N,S,E,W. But to make it work at all angles I think I'd just have to use FindDTMRotated oh well… Also remember to tell me how it worked, or any ideas you have on improving it.
Here it is!
*Also I think I am the first person to use "Array of Boolean" Lol :) .*
function FindFire(var FX, FY:Integer):Boolean;
var ZX, ZY, Fx1, Fx2, Fy1, Fy2, i:Integer;
var Slope:Extended;
var FireDTM:Array[0..3] of Integer;
var FireResult:Array[0..3] of Boolean;
var Coords:Array[0..3] of TPoint;
var Fire:TPoint;
begin
FireDTM[0]:= DTMFromString('78DA6374606460D8C98002ACF41818B880345' +
'086E13F10309A01599B70AB0101460F206B337E350032480838');
FireDTM[1]:= DTMFromString('78DA6334636460D8C48002ACF41818B880342' +
'394CFE801646D26A0C613C85A855B0D08030006B50437');
FireDTM[2]:= DTMFromString('78DA6334636460D8C48002ACF41818B880342' +
'394CFE801646D26A0C602C85A8D5F0D00047D0426');
FireDTM[3]:= DTMFromString('78DA63B467646058CC8002ACF41818B880345' +
'086E13F10309A0359AB71AB0101464F206B157E350026810813');
Fx1:= MSX1;
Fy1:= MSY1;
Fx2:= MSX2;
Fy2:= MSY2;
for i:= 0 to 3 do
begin
if(FindDTM(FireDTM[i], Fx, Fy, Fx1, Fy1, Fx2, Fy2))then
begin
Coords[i].x:= Fx;
Coords[i].y:= Fy;
ZX:= Fx;
ZY:= Fy;
Fx1:= (Fx - 30);
Fy1:= (Fy - 30);
Fx2:= (Fx + 30);
Fy2:= (Fy + 30);
FireResult[i]:= True;
Writeln('Fire[' + inttostr(i) + '] = True');
end else
begin
if(i = 0)then
begin
Coords[0].x:= 0;
Coords[0].y:= 0;
end else
begin
Coords[i].x:= Coords[(i - 1)].x;
Coords[i].y:= Coords[(i - 1)].y;
FireResult[i]:= False;
Writeln('Fire[' + inttostr(i) + '] = False');
end;
end;
end;
if(FireResult[0] or FireResult[1] or FireResult[2] or FireResult[3])then Result:= True else
Result:= False;
Fire:= MdPtOfArray(Slope,Coords);
Writeln('Fire[0].x:= ' + inttostr(Coords[0].x));
Writeln('Fire[0].y:= ' + inttostr(Coords[0].y));
Writeln('Fire[1].x:= ' + inttostr(Coords[1].x));
Writeln('Fire[1].y:= ' + inttostr(Coords[1].y));
Writeln('Fire[2].x:= ' + inttostr(Coords[2].x));
Writeln('Fire[2].y:= ' + inttostr(Coords[2].y));
Writeln('Fire[3].x:= ' + inttostr(Coords[3].x));
Writeln('Fire[3].y:= ' + inttostr(Coords[3].y));
FX:= Fire.x;
FY:= Fire.y;
FreeDTM(FireDTM[0]);
FreeDTM(FireDTM[1]);
FreeDTM(FireDTM[2]);
FreeDTM(FireDTM[3]);
end;If all of the DTM's turn up False please let me know, I don't think I set the tolerance high enough…
EDIT: Apparently it does work at all angles, a few people that have tested it have gotten it to work at all angles and it does seems to work for me too XD. What a bonus!