Awkwardsaw
2012-03-13 17:32:43
So, to maybe help push myself to actually finish a script(and to get help/ ideas along the way) I've decided to make a blog, to track my progress. I'll be making a fairly simple script, which is an MTA Enchanter. I've made one before(Although it was shitty, but whats new? ;)), as well as my AIO MTA script(But it was reflection). This time I plan on using the best techniques i can, and try not to be lazy with anything :)
Aside from my basic script skeleton, I already basicly know how it's going to be set up.
Script flow:
Ofcourse, any help/ suggestions would always be awesome :)
March 13, 2012:
To start the script off, I decided to make the location finding first.
First I made a DDTM of the center area(I'll get pics later), without adding any autocolor or tolerance just yet:
Then I made a simple grid-finding function
I need to go do some arrands now, so I'll probably be done for the day :)
Aside from my basic script skeleton, I already basicly know how it's going to be set up.
program Untitled;
{$DEFINE SMART}
{$I SRL/SRL.scar}
procedure DeclarePlayers;
begin
//Disguise('Windows Live Messenger');
HowManyPlayers:= 1;
CurrentPlayer:= 0;
NumberOfPlayers(HowManyPlayers);
Smart_Server := 132;
Smart_Members := false;
Smart_Signed := true;
Smart_SuperDetail := False;
writeln('calling names');
Players[0].Name := ''; // Username.
Players[0].Pass := ''; // Password.
Players[0].Nick := ''; // 2-4 letters of Username (that are not capital letters or numbers).
Players[0].Pin := '';
Players[0].Active := True;
end;
procedure A_Debug(text: string);
begin
writeln('[' + thetime + '] ' + players[currentplayer].nick + ' ' + text);
end;
function NumPerHour(i : extended) : extended;
begin
result := (3600 * i) / (1 + ((GetTimeRunning) / 1000));
end;
begin
SetupSRL;
end. Script flow:
o Check if in arena, if not then enter
o Find pizzaz points
o Find Location
o Find current bonus item
o Check if dragonstones are out
- If dragonstones, collect and start timer for next respawn
o Collect certain amount of shape, determined on bonus item
o Enchant shapes, and try to enchant the bonus items first
o Find center
o Deposit orbs
o Repeat
Ofcourse, any help/ suggestions would always be awesome :)
March 13, 2012:
To start the script off, I decided to make the location finding first.
First I made a DDTM of the center area(I'll get pics later), without adding any autocolor or tolerance just yet:
function CenterDDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..4] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 841;
dtmMainPoint.y := 195;
dtmMainPoint.AreaSize := 4;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 262913;
dtmMainPoint.Tolerance := 5;
dtmSubPoints[0].x := 841;
dtmSubPoints[0].y := 195;
dtmSubPoints[0].AreaSize := 4;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 262913;
dtmSubPoints[0].Tolerance := 5;
dtmSubPoints[1].x := 850;
dtmSubPoints[1].y := 206;
dtmSubPoints[1].AreaSize := 6;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := 15922409;
dtmSubPoints[1].Tolerance := 0;
dtmSubPoints[2].x := 824;
dtmSubPoints[2].y := 177;
dtmSubPoints[2].AreaSize := 6;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := 262913;
dtmSubPoints[2].Tolerance := 0;
dtmSubPoints[3].x := 831;
dtmSubPoints[3].y := 204;
dtmSubPoints[3].AreaSize := 5;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := 15922409;
dtmSubPoints[3].Tolerance := 0;
dtmSubPoints[4].x := 851;
dtmSubPoints[4].y := 190;
dtmSubPoints[4].AreaSize := 5;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := 15922409;
dtmSubPoints[4].Tolerance := 0;
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end; Then I made a simple grid-finding function
(*
MMToGrid
~~~~~~~~
.. code-block:: pascal
function MMToGrid(TP : TPoint) : Integer;
Converts a point on the minimap to a cartesian quadrant
.. note::
by Awkwardsaw
Last modified: 3/13/2012
Example:
.. code-block:: pascal
case MMToGrid(DTMPos) of
1 : loc := writeln('QI');
2 : loc := writeln('QII');
3 : loc := writeln('QIII');
4 : loc := writeln('QIV');
end;
*)
function MMToGrid(TP : TPoint) : Integer;
var
TBA : TBoxArray;
i : Integer;
begin
result := -1;
TBA := [PointToBox(point(mmcx, mmy1), point(mmx2, mmcy)), //QI
PointToBox(point(mmx1, mmy1), point(mmcx, mmcy)), //QII
PointToBox(point(mmx1, mmcy), point(mmcx, mmy2)), //QIII
PointToBox(point(mmcx, mmcy), point(mmx2, mmy2))] //QIV
if not rs_OnMinimap(tp.x, tp.y) then
begin
a_debug('MMToGrid - point not on map');
exit;
end;
if Distance(tp.x, tp.y, mmcx, mmcy) < 15 then //if center is on ms, exit
begin
result := 5;
exit;
end;
for i := 0 to 3 do
if PointInBox(TP, TBA[i]) then
begin
result := i + 1;
break;
end;
end;
I need to go do some arrands now, so I'll probably be done for the day :)