Bixby Sayz Posted May 21, 2012 Share Posted May 21, 2012 Wrote this for my own use. Thought I'd share in case others might find it useful. [sCAR]const // Constants for home teleport. HOME_ALK = 0; // Al kharid. [Non-members] HOME_DRA = 1; // Draynor village. [Non-members] HOME_EDG = 2; // Edgeville. [Non-members] HOME_FAL = 3; // Falador. [Non-members] HOME_LUM = 4; // Lumbridge. [Non-members] HOME_SAR = 5; // Port sarim. [Non-members] HOME_VAR = 6; // Varrock. [Non-members] HOME_ARD = 7; // Ardougne. [Members] HOME_BUR = 8; // Burthorpe. [Members] HOME_CAT = 9; // Catherby. [Members] HOME_SEE = 10; // Seers' village. [Members] HOME_TAV = 11; // Taverly. [Members] HOME_YAN = 12; // Yanille. [Members] HOME_LUN = 13; // Lunar isle. [Members, quest required] HOME_BAN = 14; // Bandit camp (kharidian desert). [Members, quest required] {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function HomeTeleport(Loc: Integer): Boolean; Contributors: Bixby Sayz Description: Cast home teleport. Returns true on success. Date Created: May 16th, 2012. By Bixby Sayz. RS2 Build 716. Last Modification: May 18th, 2012. By Bixby Sayz. RS2 Build 716. Note: Spell icon must be visible in spellbook. Does not scroll spellbook. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} function HomeTeleport(Loc: Integer): Boolean; var HomeDTM: Integer; // Home teleport spell icon. LockDTM: Integer; // Teleport locked icon. P: TPoint; // Location to click. B: TBox; // Boundaries of map icon. T: Integer; // Time counter. begin Result := False; // Allocate dtms. HomeDTM := DTMFromString('78DA63B463626078CA8002F61DF904A619A17C46909A3BA86ADAE6DC4055E38E690E861A9039EF08A831256C0E00FD281020'); LockDTM := DTMFromString('78DA63DCC7C0C030950105FCFAF58781114883F07F206004A9998EAA465444844108AA0604C06A16A2AA3133D0656082AA01E35D40621AAA9AB7EFDF31B023990300598F1003'); // Wrap in try...finally to ensure we free dtms. try // If map isn't already up then display it. if (CountColor(12378347, 177, 29, 340, 41) < 500) then begin // Switch to magic tab. if not SetGameTab(Tab_Magic) then Exit; // Locate home teleport spell icon and click on it. T := GetSystemTime + RR(25000, 30000); repeat WaitRR(25, 50); if (GetSystemTime > T) then Exit; until FindDTM(HomeDTM, P.X, P.Y, MIX1, MIY1, MIX2, MIY2); Mouse(P.X, P.Y, 10, 10, True); // Wait for home teleport map to appear. T := GetSystemTime + RR(25000, 30000); repeat WaitRR(25, 50); if (GetSystemTime > T) then Exit; until (CountColor(12378347, 177, 29, 340, 41) > 500); end; // Get boundaries of map icon. case Loc of HOME_DRA: B := Box(296, 194, 319, 225); HOME_EDG: B := Box(280, 140, 303, 171); HOME_ALK: B := Box(346, 213, 377, 239); HOME_FAL: B := Box(265, 188, 288, 218); HOME_LUM: B := Box(314, 226, 337, 256); HOME_SAR: B := Box(263, 231, 286, 260); HOME_VAR: B := Box(333, 166, 356, 196); HOME_ARD: B := Box(155, 196, 178, 226); HOME_BUR: B := Box(239, 129, 262, 159); HOME_CAT: B := Box(208, 166, 233, 197); HOME_SEE: B := Box(179, 143, 202, 173); HOME_TAV: B := Box(239, 164, 264, 194); HOME_YAN: B := Box(147, 246, 170, 277); HOME_LUN: B := Box(30, 61, 59, 90); HOME_BAN: B := Box(309, 279, 340, 306); else Exit; end; // Check if map icon is unlocked. Make sure mouse isn't hovering over // target icon (making it larger). if MouseInBox(B) then MouseBox(MMX1, MMY1, MMX2, MMY2, MoveTo); if FindDTM(LockDTM, P.X, P.Y, B.X1, B.Y1, B.X2, B.Y2) then begin MouseBox(493, 29, 501, 37, ClickLeft); Exit; end; // Click on map icon. MouseBox(B.X1, B.Y1, B.X2, B.Y2, ClickLeft); // Wait for map to disappear. If it fails to disapear we are on a f2p server // trying to teleport to a p2p location. T := GetSystemTime + RR(25000, 30000); repeat WaitRR(25, 50); if (GetSystemTime > T) then begin // Close map. MouseBox(493, 29, 501, 37, ClickLeft); Exit; end; until (CountColor(12378347, 177, 29, 340, 41) < 500); // Wait for teleport to end. This is cheap i know but it works. WaitRR(16000, 17000); // Success. Result := True; finally // Free dtms on the way out. FreeDTM(HomeDTM); FreeDTM(LockDTM); end; end; [/sCAR] Quote Link to comment Share on other sites More sharing options...
Wanted Posted May 21, 2012 Share Posted May 21, 2012 I need to do Magic.scar This information and precode will for sure help save me a lot of time and I'll be sure to put you in contrib/creation credit Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted May 21, 2012 Author Share Posted May 21, 2012 That was the idea: We all share what we have and if something makes it way into the includes even better. I have few others but they are so specialized I can't figure out how to break them out into standalone functions nor what purpose others would have for them. Quote Link to comment Share on other sites More sharing options...