/lib/gametab/gametab.simba
http://github.com/Drags111/Reflection_Dev · Unknown · 387 lines · 298 code · 89 blank · 0 comment · 0 complexity · 0f6966a7aa5b813bf34fe855e3b1a4e3 MD5 · raw file
- (*
- GameTab
- =======
-
- All the routines regarding game tab switching, world map, minimap levels, and
- things of that nature.
-
- {Gametab constants}
- RTAB_FRIENDSLIST = 99;
- RTAB_CHAT = 100;
- RTAB_CLANCHAT = 101;
- RTAB_OPTIONS = 102;
- RTAB_EMOTES = 103;
- RTAB_MUSIC = 104;
- RTAB_NOTES = 105;
- RTAB_COMBAT = 128;
- RTAB_TASKS = 129;
- RTAB_STATS = 130;
- RTAB_QUESTS = 131;
- RTAB_INVENTORY = 132;
- RTAB_EQUIPMENT = 133;
- RTAB_PRAYER = 134;
- RTAB_SPELLBOOK = 135;
-
- *)
-
- (*
- R_CurrentGameTab
- ~~~~~~~~~~~~~~~~
-
- .. code-block:: pascal
-
- function R_CurrentGameTab: Integer;
-
- Returns the gametab index (one of the constants) of the active game tab.
-
- .. note::
-
- by Drags111
-
- *)
- function R_CurrentGameTab: Integer;
- var
- GameTabs: TIntegerArray;
- I, Child, TextureID: Integer;
- begin
- Result := -1;
- GameTabs := [RTAB_FRIENDSLIST, RTAB_CHAT, RTAB_CLANCHAT, RTAB_OPTIONS,
- RTAB_EMOTES, RTAB_MUSIC, RTAB_NOTES, RTAB_COMBAT, RTAB_TASKS,
- RTAB_STATS, RTAB_QUESTS, RTAB_INVENTORY, RTAB_EQUIPMENT,
- RTAB_PRAYER, RTAB_SPELLBOOK];
- for I := 0 to High(GameTabs)do
- begin
- Child := R_GetInterfaceChildRef(INTERFACE_GAMETAB, GameTabs[I]);
- TextureID := SmartGetFieldInt(Child, hook_interface_TextureID);
- SmartFreeObject(Child);
- if(TextureID = 1836)then
- begin
- Result := GameTabs[I];
- Exit;
- end;
- end;
- end;
-
- (*
- R_GameTab
- ~~~~~~~~~
-
- .. code-block:: pascal
-
- function R_GameTab(Tab: Integer): Boolean;
-
- Clicks the specified GameTab (see constants.simba for a list of valid
- GameTab constants).
-
- .. note::
-
- by Drags111
-
- *)
- function R_GameTab(Tab: Integer): Boolean;
- var
- ChildObj, TextureID, T: Integer;
- GameTabs: TIntegerArray;
- Child: TInterfaceChild;
- begin
- Result := False;
- GameTabs := [RTAB_FRIENDSLIST, RTAB_CHAT, RTAB_CLANCHAT, RTAB_OPTIONS,
- RTAB_EMOTES, RTAB_MUSIC, RTAB_NOTES, RTAB_COMBAT, RTAB_TASKS,
- RTAB_STATS, RTAB_QUESTS, RTAB_INVENTORY, RTAB_EQUIPMENT,
- RTAB_PRAYER, RTAB_SPELLBOOK];
- if not InIntArray(GameTabs, Tab)then
- begin
- R_Debug('Invalid tab number', 'R_GameTab');
- Exit;
- end;
-
- if(R_CurrentGameTab = Tab)then
- begin
- Result := True;
- Exit;
- end;
-
- if not R_ValidInterface(INTERFACE_GAMETAB)then
- Exit;
-
- ChildObj := R_GetInterfaceChildRef(INTERFACE_GAMETAB, Tab);
- TextureID := SmartGetFieldInt(ChildObj, hook_interface_TextureID);
- SmartFreeObject(ChildObj);
-
- if(TextureID = 1836)then
- begin
- Result := True;
- Exit;
- end;
-
- Child := R_GetInterfaceChild(INTERFACE_GAMETAB, Tab);
-
- R_ClickInterface(Child, 1);
- MarkTime(T);
- while(TimeFromMark(T) < 2000)do
- begin
- Wait(50+RandoM(25));
- Child := R_GetInterfaceChild(INTERFACE_GAMETAB, Tab);
- if(Child.TextureID = 1836)then
- Break;
- end;
-
- Result := (TimeFromMark(T) < 2000);
- end;
-
- (*
- R_GetMMLevels
- ~~~~~~~~~~~~~
-
- .. code-block:: pascal
-
- function R_GetMMLevels(Which: string): Integer;
-
- Returns the current value at the designated minimap level.
-
- .. note::
-
- by lordsaturn, Drags111
-
- *)
- function R_GetMMLevels(Which: string): Integer;
- begin
- Result := -1;
- case LowerCase(Which) of
- 'hitpoints', 'hp', 'lp', 'lifepoints': Result := StrToInt(R_GetInterfaceText(INTERFACE_HITPOINTS, 8));
- 'prayer', 'pp' : Result := StrToInt(R_GetInterfaceText(INTERFACE_PRAYER, 4));
- 'run', 'energy' : Result := StrToInt(R_GetInterfaceText(INTERFACE_RUN, 5));
- 'sum', 'summoning': Result := StrToInt(R_GetInterfaceText(INTERFACE_SUMMONING, 5));
- else R_Debug('Invaild string.', 'R_GetMMLevels');
- end;
- end;
-
- (*
- R_ClickNorth
- ~~~~~~~~~~~~
-
- .. code-block:: pascal
-
- procedure R_ClickNorth;
-
- Clicks the compass icon next to the minimap to face the compass north.
-
- .. note::
-
- by Drags111
-
- *)
- procedure R_ClickNorth;
- var
- Compass: TInterfaceChild;
- begin
- if not R_ValidInterface(INTERFACE_GAMETAB)then
- Exit;
- Compass := R_GetInterfaceChild(INTERFACE_GAMETAB, INTERFACE_GAMETAB_FACENORTH);
- R_ClickInterface(Compass, 1);
- end;
-
- (*
- R_IsRunning
- ~~~~~~~~~~~
-
- .. code-block:: pascal
-
- function R_IsRunning: boolean;
-
- Returns true if you are running.
-
- .. note::
-
- by Drags111
-
- *)
- function R_IsRunning: boolean;
- begin
- Result := R_GetSetting(SETTING_RUN) = 1;
- end;
-
- (*
- R_SetRun
- ~~~~~~~~
-
- .. code-block:: pascal
-
- procedure R_SetRun(Run: Boolean);
-
- Sets the run to the condition specified.
-
- .. note::
-
- by Drags111
-
- *)
- procedure R_SetRun(Run: Boolean);
- var
- Button: TInterfaceChild;
- T: Integer;
- begin
- if not R_ValidInterface(INTERFACE_RUN)then
- Exit;
- if(Run = R_IsRunning)then
- Exit;
-
- Button := R_GetInterfaceChild(INTERFACE_RUN, 1);
- R_ClickInterface(Button, 1);
-
- MarkTime(T);
- while(TimeFromMark(T) < 1000)do
- begin
- Wait(25+Random(50));
- if(Run = R_IsRunning)then
- Break;
- end;
- end;
-
- (*
- R_IsResting
- ~~~~~~~~~~~
-
- .. code-block:: pascal
-
- function R_IsResting: boolean;
-
- Returns true if your player is performing the resting animation.
-
- .. note::
-
- by Drags111
-
- *)
- function R_IsResting: boolean;
- var
- Animations: TIntegerArray;
- begin
- SetLength(Animations, 5);
- Animations := [12108, 2033, 2716, 11786, 5713];
- Result := InIntArray(Animations, R_GetAnimation);
- end;
-
- (*
- R_Rest
- ~~~~~~
-
- .. code-block:: pascal
-
- function R_Rest(MaxEnergy: integer): boolean;
-
- Uses the rest ability until the desired energy is reached.
-
- .. note::
-
- by Drags111
-
- *)
- function R_Rest(MaxEnergy: integer): boolean;
- var
- T, MT, Energy: integer;
- RunIcon: TInterfaceChild;
- begin
- Result := True;
- MarkTime(MT);
- Energy := R_GetMMLevels('Run');
-
- if(Energy >= MaxEnergy)then
- Exit;
-
- Result := R_IsResting;
- while(not Result)do
- begin
- if not LoggedIn or (TimeFromMark(MT) > 9000)then
- Exit;
- RunIcon := R_GetInterfaceChild(INTERFACE_RUN, 1);
- R_ClickInterface(RunIcon, 2);
- Wait(25+Random(50));
- Result := R_ChooseOption('Rest');
- if(Result)then
- begin
- MarkTime(T);
- while((not R_IsResting) and (TimeFromMark(T) < 3000))do
- wait(100+Random(100));
- Result := (R_IsResting);
- end;
- end;
-
- Energy := R_GetMMLevels('run');
- while(Energy < MaxEnergy)do
- begin
- case Random(50) of
- 0..5: SleepAndMoveMouse(Random(1000));
- else wait(100+Random(400));
- end;
- Energy := R_GetMMLevels('run');
- end;
- end;
-
- (*
- R_WorldMapOpen
- ~~~~~~~~~~~~~~
-
- .. code-block:: pascal
-
- function R_WorldMapOpen : Boolean;
-
- Returns true if the World Map is open.
-
- .. note::
-
- by Drags111
-
- *)
- function R_WorldMapOpen : Boolean;
- var
- Map: TInterfaceChild;
- begin
- Result := R_ValidInterface(755);
- if not Result then
- Exit;
- Map := R_GetInterfaceChild(INTERFACE_WORLDMAP, 0);
- Result := (Map.Width <> 0);
- end;
-
- (*
- R_CloseWorldMap
- ~~~~~~~~~~~~~~~
-
- .. code-block:: pascal
-
- function R_CloseWorldMap : Boolean;
-
- Closes the World Map. Returns true if it is successful.
-
- .. note::
-
- by Drags111
-
- *)
- function R_CloseWorldMap : Boolean;
- var
- T: Integer;
- Button: TInterfaceChild;
- begin
- Result := False;
- if not R_WorldMapOpen then
- begin
- Result := True;
- Exit;
- end;
-
- Button := R_GetInterfaceChild(INTERFACE_WORLDMAP, INTERFACE_WORLDMAP_CLOSE);
- R_ClickInterface(Button, 1);
-
- MarkTime(T);
- while(TimeFromMark(T) < 5000)do
- begin
- wait(50+Random(50));
- if not R_WorldMapOpen then
- Break;
- end;
- Result := (TimeFromMark(T) < 5000);
- end;