PDA

View Full Version : TTile vs TPoint



Fitta
08-28-2014, 02:03 PM
We should turn all tile functions into TTile. Partly for clearifications but also for future reference.
There's a lot of things that could need a change.. Who is developing it now a days? Why arent we looking at the two-three year old reflection include? The code is exactly the same(95% of the cases).

I see so many changes that wouldn't be needed..


EDIT:

Why change the function name???
function R_GetMyPos: TTile;
var
Me: Integer;
begin
Me := SmartGetFieldObject(0, hook_static_MyPlayer);
Result.x := SmartGetFieldInt(0, hook_static_BaseX) + SmartGetFieldInt(Me, hook_animable_PixelX) / 512;
Result.y := SmartGetFieldInt(0, hook_static_BaseY) + SmartGetFieldInt(Me, hook_animable_PixelY) / 512;
SmartFreeObject(Me);
end;

function R_GetTileGlobal: TPoint;
var
Me: Integer;
begin
Me := SmartGetFieldObject(SmartCurrentTarget, 0, client_player);
Result.X := (SmartGetFieldInt(SmartCurrentTarget, 0, client_baseX) * client_baseX_Multiplier) + (SmartGetFieldInt(SmartCurrentTarget, Me, Actor_localX) * Actor_localX_Multiplier) div 128;
Result.Y := (SmartGetFieldInt(SmartCurrentTarget, 0, client_baseY) * client_baseY_Multiplier) + (SmartGetFieldInt(SmartCurrentTarget, Me, Actor_localY) * Actor_localY_Multiplier) div 128;
SmartFreeObject(SmartCurrentTarget, Me);
end;


Edit2:
Also going back to the old CONSTANT file we had in the reflection include would do wonders.
And same Types for that matter as well..

Edit3:
I should make a list lol..

Here is the constant file, devs will get the idea.
So much more efficent to fix the functions if something was to change..
(*=====================================

Constants for the Reflection include

=====================================*)
const
NULL_INT = -1;
NULL_STRING = '';

{Gametab constants}
INTERFACE_GAMETAB = 548;
INTERFACE_GAMETAB_FACENORTH = 178;

RTAB_FRIENDSLIST = 100;
RTAB_CHAT = 101;
RTAB_CLANCHAT = 102;
RTAB_OPTIONS = 103;
RTAB_EMOTES = 104;
RTAB_MUSIC = 105;
RTAB_NOTES = 106;
RTAB_COMBAT = 129;
RTAB_TASKS = 130;
RTAB_STATS = 131;
RTAB_QUESTS = 132;
RTAB_INVENTORY = 133;
RTAB_EQUIPMENT = 134;
RTAB_PRAYER = 135;
RTAB_SPELLBOOK = 136;

INTERFACE_HITPOINTS = 748;
INTERFACE_PRAYER = 749;
INTERFACE_RUN = 750;
INTERFACE_SUMMONING = 747;
INTERFACE_WORLDMAP = 755;
INTERFACE_WORLDMAP_CLOSE = 44;

SETTING_RUN = 173;

{Inventory Constants}
INTERFACE_INVENTORY = 679;
INTERFACE_BANKINVENTORY = 763;

{Equipment Constants}
INTERFACE_EQUIPMENT = 387;

EQUIPMENT_HELMET = 8;
EQUIPMENT_CAPE = 11;
EQUIPMENT_NECKLACE = 14;
EQUIPMENT_WEAPON = 17;
EQUIPMENT_TORSO = 20;
EQUIPMENT_SHIELD = 23;
EQUIPMENT_LEGS = 26;
EQUIPMENT_GLOVES = 29;
EQUIPMENT_BOOTS = 32;
EQUIPMENT_RING = 35;
EQUIPMENT_AMMO = 38;

{Quest Constants}
INTERFACE_QUESTS = 190;
INTERFACE_QUESTINFO = 275;
INTERFACE_QUESTSTART = 178;
QUEST_INFO_NAME = 2;
QUEST_INFO_CLOSE = 8;
QUEST_START_YES = 78;
QUEST_POINTS = 2;
QUEST_LIST = 18;
QUEST_SCROLL = 17;
QUEST_FILTER = 10;
QUEST_DONE = 12;
QUEST_CHECKED = 699;
QUEST_STARTED = 65535;
QUEST_UNSTARTED = 16711680;
QUEST_COMPLETE = 65280;
QUEST_FILTERED = 2236962;
QUEST_UNKNOWN = -1;

{Player Model Constants}
MODEL_EQUIPMENT_CONSTANT = 1073741824;

MODEL_EQUIPMENT_HEAD = 0;
MODEL_EQUIPMENT_CAPE = 1;
MODEL_EQUIPMENT_NECK = 2;
MODEL_EQUIPMENT_WEAPON = 3;
MODEL_EQUIPMENT_BODY = 4;
MODEL_EQUIPMENT_SHIELD = 5;
MODEL_EQUIPMENT_LEGS = 7;
MODEL_EQUIPMENT_HANDS = 9;
MODEL_EQUIPMENT_BOOTS = 10;

{Object Constants}
OBJ_INTERACTABLE = 1;
OBJ_WALLOBJECT = 2;
OBJ_WALLDECORATION = 3;
OBJ_FLOORDECORATION = 4;

{Bank Constants}
INTERFACE_BANK = 762;
INTERFACE_BANK_BTN_CLOSE = 43;
INTERFACE_BANK_BTN_DEPOSITBAG = 33;
INTERFACE_BANK_BTN_DEPOSITEQUIP = 35;
INTERFACE_BANK_BTN_DEPOSITBEAST = 37;
INTERFACE_BANK_BTN_NOTE = 19;

INTERFACE_BANK_SLOTS = 93;
INTERFACE_BANK_SLOTS_MAX = 515;

INTERFACE_BANK_SCROLLBAR = 114;
INTERFACE_BANK_SCROLLBAR_BAR = 1;
INTERFACE_BANK_SCROLLBAR_BARTOP = 2;
INTERFACE_BANK_SCROLLBAR_BARBOT = 3;
INTERFACE_BANK_SCROLLBAR_UP = 4;
INTERFACE_BANK_SCROLLBAR_DOWN = 5;

INTERFACE_PINSCREEN = 13;

INTERFACE_DEPOSITBOX = 11;

TEXTURE_BANKTABSELECTED = 1419;
TEXTURE_WITHDRAWMODE_NOTED = 1433;

{Chat Constants}
INTERFACE_CHAT = 137;
INTERFACE_CHAT_OPTIONS = 751;
INTERFACE_CHAT_SCROLL = 59;

RCHAT_GAME = 31;
RCHAT_PUBLIC = 28;
RCHAT_PRIVATE = 25;
RCHAT_FRIENDS = 8;
RCHAT_CLAN = 22;
RCHAT_TRADE = 19;
RCHAT_ASSIST = 16;

{Misc Constants}
CROSSHAIR_NONE = 0;
CROSSHAIR_YELLOW = 1;
CROSSHAIR_RED = 2;
INTERFACE_LOGIN_SCREEN = 596;
INTERFACE_LOBBY_SCREEN = 907;

{Interface Constants}
INDEX_PARENT = 0;
INDEX_CHILD = 1;
INDEX_COMP = 2;

SCROLLBAR_UP = 4;
SCROLLBAR_DOWN = 5;

(*=====================================

Types for the Reflection include

=====================================*)
type
{Essentially a TPoint, a tile is a global coordinace on the runescape grid.}
TTile = TPoint;
TTileArray = TPointArray;

{Stores the rotation matrix used by the client to render to the main
screen, along with offsets.}
TRenderData = record
xOff,xX,xY,xZ : extended;
yOff,yX,yY,yZ : extended;
zOff,zX,zY,zZ : extended;
end;

{Stores information about the rendered world including ranges
for acceptable values, and scaling factors.}
TRender = record
xScale,yScale : extended;
xMin,xMax : extended;
yMin,ymax : extended;
zMax,zMin : extended;
end;

{ type TInterfaceChild;
Contains informations pertaining to Interface Children}
TInterfaceChild = record
Actions: TStringArray;
ID, ComponentID, ParentID, Stack: Integer;
TextureID, ModelID, ModelZoom, TextColor: Integer;
RelativeX, RelativeY, Width, Height: Integer;
X, Y: Integer;
Bounds: TBox;
Text, Name: String;
IsHidden: Boolean;
VScrollSize, VScrollPosition, VThumbSize: Integer;
HScrollSize, HScrollPosition, HThumbSize: Integer;
BoundsArrayIndex: Integer;
Indices: TIntegerArray;
end;

{ type TInterfaceComponent;
Contains informations pertaining to Interface Children Components. Same as
TRSChild but different name for referencing purposes.}
type
TInterfaceComponent = TInterfaceChild;

{A record that holds the information regarding to NPC's in the game.}
TNPC = record
Tile: TTile;
TileArea: TBox;
Name: String;
Index, Level, ID, Height: Integer;
Animation, Motion, HPRatio: Integer;
InCombat: Boolean;
WalkQueueX, WalkQueueY: Integer;
Interacting, Orientation: integer;
Actions: TStringArray;
end;
TNPCArray = array of TNPC;

{A record that holds the information regarding to players (including yours)
in the game.}
TPlayer = record
Tile: TTile;
Name: String;
Index, Level, Team, Height: Integer;
Animation, Motion, HPRatio: Integer;
InCombat: Boolean;
WalkQueueX, WalkQueueY: Integer;
Interacting, Orientation: Integer;
end;
TPlayerArray = array of TPlayer;

{Contains informations pertaining to Objects}
TRSObject = record
ObjType: integer;
ID: Integer;
ModelID: Integer;
Tile: TTile;
TileArea: TBox;
end;
TRSObjectArray = array of TRSObject;

{Holds information pertaining to a ground item}
TGroundItem = record
ID: Integer;
Stack: Integer;
Tile: TTile;
end;
TGroundItemArray = array of TGroundItem;

{Holds information pertaining to an inventory slot}
TInvItem = record
ID, StackSize, Slot: integer;
Name: String;
Actions: TStringArray;
end;
TInvItemArray = array of TInvItem;

{Holds information about an equipment slot}
TEquipmentItem = record
ID: Integer;
Name: string;
IsAmmo: Boolean;
Count: Integer;
Actions: TStringArray;
end;
TEquipmentSet = array of TEquipmentItem;

{Holds informations pertaining to bank items}
TBankItem = Record
ID, Slot, StackSize: Integer;
Name: String;
end;
TBankItemArray = array of TBankItem;

(*=====================================

Vars for the Reflection include

=====================================*)
var
R_SuppressDebug, R_ContinueIfOutdated, R_ExitOnRandoms: Boolean;

(*=====================================

Nulling functions

=====================================*)
function NULL_TILE: TTile;
begin
Result.X := NULL_INT;
Result.Y := NULL_INT;
end;

function NULL_BOX: TBox;
begin
Result.X1 := -1;
Result.Y1 := -1;
Result.X2 := -1;
Result.Y2 := -1;
end;

function NULL_NPC: TNPC;
begin
with Result do
begin
Tile := NULL_TILE;
Name := NULL_STRING;
Index := NULL_INT;
Level := NULL_INT;
ID := NULL_INT;
Height := NULL_INT;
Animation := NULL_INT;
Motion := NULL_INT;
HPRatio := NULL_INT;
InCombat := False;
WalkQueueX := NULL_INT;
WalkQueueY := NULL_INT;
Interacting := NULL_INT;
Orientation := NULL_INT;
Actions := [];
end;
end;

function NULL_PLAYER: TPlayer;
begin
with Result do
begin
Tile := NULL_TILE;
Name := NULL_STRING;
Index := NULL_INT;
Level := NULL_INT;
Team := NULL_INT;
Height := NULL_INT;
Animation := NULL_INT;
Motion := NULL_INT;
HPRatio := NULL_INT;
InCombat := False;
WalkQueueX := NULL_INT;
WalkQueueY := NULL_INT;
Interacting := NULL_INT;
Orientation := NULL_INT;
end;
end;

function NULL_RSOBJECT: TRSObject;
begin
Result.ID := NULL_INT;
Result.ObjType := NULL_INT;
Result.Tile := NULL_TILE;
Result.TileArea := NULL_BOX;
end;

function NULL_GROUNDITEM: TGroundItem;
begin
Result.ID := NULL_INT;
Result.Stack := NULL_INT;
Result.Tile := NULL_TILE;
end;

function NULL_INVITEM: TInvItem;
begin
Result.ID := NULL_INT;
Result.StackSize := NULL_INT;
Result.Slot := NULL_INT;
Result.Name := NULL_STRING;
Result.Actions := [];
end;

function NULL_EQUIPMENT: TEquipmentItem;
begin
Result.ID := NULL_INT;
Result.Name := NULL_STRING;
Result.IsAmmo := False;
Result.Count := Null_INT;
Result.Actions := [];
end;

function NULL_BANKITEM: TBankItem;
begin
Result.ID := NULL_INT;
Result.Slot := NULL_INT;
Result.StackSize := NULL_INT;
Result.Name := NULL_STRING;
end;

EDit5:

In case someone doesn't understand..

This is the current r_IsRunOn, look at the change.

function R_IsRunOn: Boolean;
begin
Result := R_GetSetting(173) = 1;
end;



function R_IsRunOn: Boolean;
begin
Result := R_GetSetting(SETTING_RUN) = 1;
end;

tls
08-28-2014, 02:46 PM
The current include is just an "unofficial" reboot that is available for use while something better is developed. If you want to see what stage my include is at go to github.com/tlsdude/osr-reflection. If you have any suggestions for me there, then you should make it an Issue and I'll look at each one and respond.

Fitta
08-28-2014, 06:33 PM
The current include is just an "unofficial" reboot that is available for use while something better is developed. If you want to see what stage my include is at go to github.com/tlsdude/osr-reflection. If you have any suggestions for me there, then you should make it an Issue and I'll look at each one and respond.

NOW THATS WHAT I'M TALKING ABOUT. NICE!

When is it ready do you think? Also, don't mind antirandoms as it's going to be somewhat removed :)

Turpinator
08-28-2014, 06:48 PM
The current include is just an "unofficial" reboot that is available for use while something better is developed. If you want to see what stage my include is at go to github.com/tlsdude/osr-reflection. If you have any suggestions for me there, then you should make it an Issue and I'll look at each one and respond.

This is basically what i was going to say. and yay for lape. Eventually Olly; wants to combine RS3 and OSR into one include... which means lape for everything! yay!



When is it ready do you think? Also, don't mind antirandoms as it's going to be somewhat removed :)
Somewhere in the depths of the forums there exists a post that says something to the effect of "Deadlines don't exist at SRL, if you want something done faster, help out"
So. you can always add a fork of tls's include and start adding your own funcs/etc and if he wants them... he can accept the changes. :)

Fitta
08-28-2014, 07:34 PM
I can't PM him, not enough posts.. and I have no knowledge of lape hmm..

Does he have skype or any other way of contact?

tls
08-28-2014, 07:38 PM
I idle in the IRC channel: irc.rizon.net #srl (https://villavu.com/forum/usertag.php?do=list&action=hash&hash=srl)

Cheddy
08-31-2014, 04:53 PM
The easy way to get random solvers (once tls has finished the api side of the include) is to port some working random solvers such as vInsert's (https://github.com/Cheddy/vInsert/tree/master/src/main/java/org/vinsert/api/random/impl). You could also port some of the useful functions off there such as a-star walking and djikstra object finding (I have yet to push that)

The official vInsert repo can be found here: https://github.com/constt/vInsert. I just linked you to my fork as it currently has the a-star pathfinding

tls
08-31-2014, 07:58 PM
I'm planning on putting djikstra/astar in a plugin or sneak it into simba.

Cheddy
08-31-2014, 08:13 PM
Looks like there will be no randoms anyways :D