This is a function that returns what sector a flag is in out of these sectors:
Example = Sector 1 is from 0 - 45 degrees, 0 being east (according to Unit Circle)Code:// - // \ 3 ! 2 / // \ ! / // 4 \ ! / 1 // !---------------! <---- MiniMap // 5 / ! \ 8 // / ! \ // / 6 ! 7 \ // -
Here is the function:
It still needs testing but it should be useful.Code:var FlagDTM: integer; procedure LoadFlag; begin FlagDTM := DTMFromString('78DA6314616060906400034608C5702C8C858' + '109CAFF0F048CFC408610AA9AFF40CC84C4670499C343408D2090' + '1020C21C02760100683F09E7'); end; function RCos(Radius, Angle: Longint): Longint; //used in InSector begin result := Round(Radius * Cose(Angle)) end; function RSin(Radius, Angle: Longint): Longint; //used in InSector begin result := Round(Radius * Sine(Angle)) end; function InSector(fx, fy: integer): Integer; // elite function to find what // B - A sector the flag is in // \ 3 ! 2 / // \ ! / // 4 \ ! / 1 // !---------------! <---- MiniMap // 5 / ! \ 8 // / ! \ // / 6 ! 7 \ // C - D var Sector : integer; Radius, R : Longint; begin Radius := 80; R := Radius; //Radius of MM ; big for a reason if (InAbstractBox((MMCX + RCos(R, 45)),(MMCY - RSin(R, 45)),MMCX + R,MMCY,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 1 if (InAbstractBox((MMCX + RCos(R, 45)),(MMCY - RSin(R, 45)),MMCX,MMCY + R,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 2 if (InAbstractBox((MMCX + RCos(R,135)),(MMCY - RSin(R,135)),MMCX,MMCY + R,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 3 if (InAbstractBox((MMCX + RCos(R,135)),(MMCY - RSin(R,135)),MMCX - R,MMCY,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 4 if (InAbstractBox((MMCX + RCos(R,225)),(MMCY - RSin(R,225)),MMCX - R,MMCY,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 5 if (InAbstractBox((MMCX + RCos(R,225)),(MMCY - RSin(R,225)),MMCX,MMCY - R,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 6 if (InAbstractBox((MMCX + RCos(R,315)),(MMCY - RSin(R,315)),MMCX,MMCY - R,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 7 if (InAbstractBox((MMCX + RCos(R,315)),(MMCY - RSin(R,315)),MMCX + R,MMCY,MMCX,MMCY,MMCX,MMCY,fx,fy))then Sector := 8 Result := Sector end;
Example When a script clicks on an object, say a tree, that is not next to the player a flag appears. Where the flag appears depends on the sector of the object. For Ex. If the object was in sector 1 or 8 the flag would appear to the left of the object. So for ent finding procedures where the result is affected by the positioning of the mouse (the mouse needs to be on the correct tree), and the position is change since the mouse doen't move with the tree, procedures like this are useful:
It moves to the tree color according to parameters that search for the color according to the sector.Code:var xFlag,yFlag:integer; procedure MovetoSpot; // using insector() moves the mouse to the tree begin // accordingly so my ent finding functions work LoadFlag; if (FindMMDtm(xFlag,yFlag,FlagDTM)) then begin if (InSector(xFlag,yFlag)=1) or (InSector(xFlag,yFlag)=8) then begin Flag; if (FindColorSpiralTolerance(xyy,yxx,TreeColor1,MMCX-5,MMCY-15,MMCX+25,MMCY+15,5)) then MMouse(xyy,yxx,2,2) end; if (InSector(xFlag,yFlag)=2) or (InSector(xFlag,yFlag)=3) then begin Flag; if (FindColorSpiralTolerance(xyy,yxx,TreeColor1,MMCX-15,MMCY-25,MMCX+15,MMCY+5,5)) then MMouse(xyy,yxx,2,2) end; if (InSector(xFlag,yFlag)=4) or (InSector(xFlag,yFlag)=5) then begin Flag; if (FindColorSpiralTolerance(xyy,yxx,TreeColor1,MMCX-25,MMCY-15,MMCX+5,MMCY+15,5)) then MMouse(xyy,yxx,2,2) end; if (InSector(xFlag,yFlag)=6) or (InSector(xFlag,yFlag)=7) then begin Flag; if (FindColorSpiralTolerance(xyy,yxx,TreeColor1,MMCX-15,MMCY-5,MMCX+15,MMCY+25,5)) then MMouse(xyy,yxx,2,2) end; end; end;
I am doing my best to explain it. It is hard to grasp. Post any questions.



Reply With Quote