Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // # Magitek Flan Farming v1.4
- // # by /u/Dystaxia
- // #
- // # New in this version...
- // # - Enhanced logging to let you know exactly what's going on.
- // # - Active detection of characters being ready to attack.
- // # - Some important values used for detecting the Hard button were corrected.
- // #
- // # Setup
- // # - This script was designed for Bluestacks in fullscreen mode.
- // # - Drag the crosshair (right-most button on the toolbar) to BlueStacks.
- // # - Keep Bladeblitz or Dragon in a character's first ability slot.
- // # - Ensure your inventory has some free space (no handling for that).
- // # - Click the event so that the Easy, Normal, Hard select menu is shown.
- // # - Click the play button on the toolbar or hit F9 to run.
- // # - Ctrl+F4 while the SCAR window is focused will stop execution.
- // #
- // # Enjoy!
- program MagitekFlanFarm;
- var countFlans, countTotal, countStamina: integer;
- var colorHard, colorGo, colorFlan, colorBattle, colorPart, colorNext, colorStamina: integer;
- var x1Hard, y1Hard, x2Hard, y2Hard, tolHard: integer;
- var x1Go, y1Go, x2Go, y2Go, tolGo: integer;
- var x1Part1, y1Part1, x2Part1, y2Part1, tolPart1: integer;
- var x1Part2, y1Part2, x2Part2, y2Part2, tolPart2: integer;
- var x1Flan, y1Flan, x2Flan, y2Flan, tolFlan: integer;
- var x1Battle, y1Battle, x2Battle, y2Battle, tolBattle: integer;
- var x1Next, y1Next, x2Next, y2Next, tolNext: integer;
- var x1Stamina, y1Stamina, x2Stamina, y2Stamina, tolStamina: integer;
- var xBegin, yBegin, xRetreat1, xRetreat2, yRetreat1, yRetreat2: integer;
- var xCamp, yCamp, xAbility, yAbility, xDefend, yDefend: integer;
- var xStamBack, yStamBack, timeWait: integer;
- var windowWidth, windowHeight: integer;
- var x, y: integer;
- procedure InitSettings;
- begin
- timeWait := 720000; // Default: 720000 ms (12 minutes)
- // # Below this are the colors that are used to search for various buttons.
- // # If you are having parrticular trouble, you can sample your own colors.
- // # Use the eye dropper on the toolbar to choose a color and change the value.
- colorHard := 987428; // Default: 987428
- colorGo := 16777215; // Default: 16777215
- colorPart := 7214848; // Default: 7214848
- colorFlan := 15119703; // Default: 15119703
- colorBattle := 16777215; // Default: 16777215
- colorNext := 16716032; // Default: 16716032
- colorStamina := 15778; // Default: 15778
- // # Below this are tolerance values for the color finding procedures.
- // # If you are having trouble finding a color, perhaps increase the tolerance.
- // # This may produce unexpected results.
- tolHard := 0; // Default: 0
- tolGo := 0; // Default: 0
- tolPart1 := 0; // Default: 0
- tolPart2 := 0; // Default: 0
- tolFlan := 5; // Default: 5
- tolBattle := 0; // Default: 0
- tolNext := 0; // Default: 0
- tolStamina := 0; // Default: 0
- // # Below this are the values that define the bounding box used to restrict the
- // # color search to a specific area. Widening the search area can solve issues
- // # where the target is not within the bounds of the search.
- x1Hard := 0;
- y1Hard := 700 * windowHeight div 1080;
- x2Hard := windowWidth;
- y2Hard := 800 * windowHeight div 1080;
- x1Go := 200 * windowWidth div 674;
- y1Go := 790 * windowHeight div 1080;
- x2Go := 475 * windowWidth div 674;
- y2Go := 900 * windowHeight div 1080;
- x1Part1 := 0;
- y1Part1 := 400 * windowHeight div 1080;
- x2Part1 := windowWidth;
- y2Part1 := 500 * windowHeight div 1080;
- x1Part2 := 0;
- y1Part2 := 500 * windowHeight div 1080;
- x2Part2 := windowWidth;
- y2Part2 := 600 * windowHeight div 1080;
- x1Flan := 100 * windowWidth div 674;
- y1Flan := 350 * windowHeight div 1080;
- x2Flan := 250 * windowWidth div 674;
- y2Flan := 450 * windowHeight div 1080;
- xBegin := 477 * windowWidth div 674;
- yBegin := 759 * windowHeight div 1080;
- x1Battle := 50 * windowWidth div 674;
- y1Battle := 850 * windowHeight div 1080;
- x2Battle := 400 * windowWidth div 674;
- y2Battle := 1000 * windowHeight div 1080;
- x1Next := 0;
- y1Next := 0;
- x2Next := 320 * windowWidth div 674;
- y2Next := windowHeight;
- x1Stamina := 0;
- y1Stamina := 565 * windowHeight div 1080;
- x2Stamina := windowWidth;
- y2Stamina := 650 * windowHeight div 1080;
- // # Below this are values of fixed coordinates that do not rely on color to be pressed.
- xBegin := 460 * windowWidth div 674;
- yBegin := 780 * windowHeight div 1080;
- xRetreat1 := 550 * windowWidth div 674;
- yRetreat1 := 900 * windowHeight div 1080;
- xRetreat2 := 550 * windowWidth div 674;
- yRetreat2 := 750 * windowHeight div 1080;
- xCamp := 590 * windowWidth div 674;
- yCamp := 215 * windowHeight div 1080;
- xAbility := 300 * windowWidth div 674;
- yAbility := 900 * windowHeight div 1080;
- xDefend := 200 * windowWidth div 674;
- yDefend := 900 * windowHeight div 1080;
- xStamBack := 333 * windowWidth div 674;
- yStamBack := 770 * windowHeight div 1080;
- end;
- // # Below this are the routines of the script. You shouldn't have to modify
- // # anything below this line to get things working.
- procedure ClickGo;
- begin
- if FindColorTol(x, y, colorGo, x1Go, y1Go, x2Go, y2Go, tolGo) = true then
- begin
- WriteLn('# - GO! located at ('+IntToStr(x)+','+IntToStr(y)+').');
- Wait(1000);
- ClickMouse(x, y, false);
- end;
- end;
- procedure ClickPartOne;
- begin
- WriteLn('# Awaiting Part 1 button. Searching for GO!...');
- while FindColorTol(x, y, colorPart, x1Part1, y1Part1, x2Part1, y2Part1, tolPart1) = false do
- begin
- ClickGo;
- Wait(1000);
- end;
- WriteLn('# - Part 1 button located at ('+IntToStr(x)+','+IntToStr(y)+').');
- Wait(1000);
- ClickMouse(x+100, y, false);
- end;
- function CheckPartTwo: boolean;
- begin
- Result := false;
- if FindColorTol(x, y, colorPart, x1Part2, y1Part2, x2Part2, y2Part2, tolPart2) then
- begin
- WriteLn('# - Part 2 button located at ('+IntToStr(x)+','+IntToStr(y)+').');
- Result := true;
- end;
- end;
- function CheckFlan: boolean;
- begin
- Result := false;
- if FindColorTol(x, y, colorFlan, x1Flan, y1Flan, x2Flan, y2Flan, tolFlan) then
- begin
- countFlans := countFlans + 1;
- WriteLn('# Flan located at ('+IntToStr(x)+','+IntToStr(y)+'). ('+IntToStr(countFlans)+'/'+IntToStr(countTotal-countStamina)+')');
- Result := true;
- end;
- end;
- procedure ClickAbilities;
- begin
- if FindColorTol(x, y, colorBattle, x1Battle, y1Battle, x2Battle, y2Battle, tolBattle) = true then
- begin
- WriteLn('# - Readied character detected at ('+IntToStr(x)+','+IntToStr(y)+').');
- Wait(1000);
- ClickMouse(xAbility, yAbility, false);
- Wait(500);
- ClickMouse(xDefend, yDefend, false);
- end;
- end;
- function CheckNext: boolean;
- begin
- Result := false;
- if FindColorTol(x, y, colorNext, x1Next, y1Next, x2Next, y2Next, tolNext) then
- begin
- WriteLn('# - Next button located at ('+IntToStr(x)+','+IntToStr(y)+').');
- Wait(1000);
- ClickMouse(x, y, false);
- Result := true;
- end;
- end;
- function CheckHard: boolean;
- begin
- Result := false;
- if FindColorTol(x, y, colorHard, x1Hard, y1Hard, x2Hard, y2Hard, 0) then
- begin
- WriteLn('# - Hard button located at ('+IntToStr(x)+','+IntToStr(y)+').');
- Result := true;
- end;
- end;
- procedure Retreat;
- begin
- ClickMouse(xRetreat1, yRetreat1, false);
- Wait(1000);
- ClickMouse(xRetreat2, yRetreat2, false);
- Wait(1000);
- WriteLn('# Awaiting Hard button. Searching for Next...');
- while CheckHard = false do
- begin
- Wait(2000);
- CheckNext;
- end;
- end;
- procedure CampRetreat;
- begin
- ClickMouse(xCamp, yCamp, false);
- WriteLn('# - Camp button has been clicked at ('+IntToStr(xCamp)+','+IntToStr(yCamp)+').');
- Wait(2000);
- Retreat;
- end;
- function CheckStamina: boolean;
- begin
- Result := false;
- if FindColorTol(x, y, colorStamina, x1Stamina, y1Stamina, x2Stamina, y2Stamina, tolStamina) then
- begin
- countStamina := countStamina + 1;
- WriteLn('# Out of stamina screen detected at ('+IntToStr(x)+','+IntToStr(y)+'). ('+IntToStr(countStamina)+')');
- Result := true;
- end;
- end;
- begin
- countTotal := 0;
- countStamina := 0;
- countFlans := 0;
- ClickMouse(1, 1, false);
- Wait(500);
- GetWindowSize(GetActiveWindow, windowWidth, windowHeight);
- WriteLn('');
- WriteLn('# Window size determined. (W: '+IntToStr(windowWidth)+', H: '+IntToStr(windowHeight)+')');
- InitSettings;
- while 1 <> 2 do
- begin
- countTotal := countTotal + 1;
- WriteLn('');
- WriteLn('# Run ' + IntToStr(countTotal) + ' initiating.');
- WriteLn('# Searching for Hard button...');
- while CheckHard = false do
- begin
- Wait(1000);
- end;
- Wait(1000);
- ClickMouse(x, y, false);
- ClickPartOne;
- Wait(2000);
- if CheckFlan then
- begin
- Wait(1000);
- WriteLn('# - Engaging...');
- ClickMouse(xBegin, yBegin, false);
- Wait(4000);
- while CheckNext = false do
- begin
- ClickAbilities;
- Wait(2000);
- end;
- WriteLn('# - Battle complete.');
- WriteLn('# Awaiting Part 2 button. Searching for Next...');
- while CheckPartTwo = false do
- begin
- CheckNext;
- Wait(1000);
- end;
- Wait(1000);
- WriteLn('# Retreating...');
- CampRetreat;
- WriteLn('# Run '+IntToStr(countTotal)+' completed.');
- end else
- begin
- if CheckStamina = false then
- begin
- WriteLn('# Flan was not found. ('+IntToStr(countTotal-countStamina-countFlans)+'/'+IntToStr(countTotal-countStamina)+')');
- WriteLn('# - Retreating...');
- Wait(2000);
- Retreat;
- WriteLn('# Run '+IntToStr(countTotal)+' completed.');
- end else
- begin
- ClickMouse(xStamBack, yStamBack, false);
- Wait(500);
- WriteLn('# - Retreating...');
- CampRetreat;
- WriteLn('# Run '+IntToStr(countTotal)+' completed.');
- WriteLn('');
- WriteLn('# Waiting'+IntToStr(timeWait div 60000)+' minutes.');
- Wait(timeWait);
- end;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement