SRL Archive - General

Reflection and MSI


Coh3n

2010-04-25 17:53:53

Hey guys,

I was looking through Camero and Sebo's Guild Miner and found it interesting how they implement reflection. IceFire also uses this method in his GE Arson and POMS. If you don't already know, they have only the hooks they need as variables and are automatically updated within the script; no reflection download required; no confusion with replacing hooks in Hooks.scar.

I know they update the hooks from a server (or something, I don't really know) that they control (unless that site autoupdates from wherever the hooks are found), but that's something we'd have to take into consideration.

What do you guys think?

Blumblebee

2010-04-25 19:26:00

well if we do implement reflection we would need our own parser and hook setter without having to manually upload hooks to a website (which it seems like that's how Camaro does it).

I guess we could use Widgets, in cooperation with something like that looks for keywords and go from there.

Coh3n

2010-04-25 19:31:43

Even if we have to upload them ourselves, I still don't think it would be a bad idea. I mean, there are enough of us active that they could be updated quick (until we figured out an alternative of course).

Wanted

2010-04-25 21:18:46

I have to update the hooks manually by editing my webserver page by logging into 000webhost and going to file manager, the script then does string functions by using Between() Explode() ect.. to update the hooks. I find the hooks at rs-hacking.com and then change them to SCAR format, test them, upload them to my web server.. then by comparing the manual override options in the script's client build number it knows whether or not the latest build is newer or not and can warn the user if the hooks are not updated while allowing them to try and find them themselves and manually override them.

http://icefire908.netai.net/Hooks

const                              // Don't change these
Script_Version = '1.12';
Ref_CurrentBuild = '602'; // Increase build # to current to overide server
Ref_MyPlayer = 'kk.i'; // Overrides
Ref_Animation = 'nc';

  WriteLn('Checking hooks...');
Wait(1000);
S := GetPage('http://icefire908.netai.net/Hooks');
if (not (Pos('RSBuild', S) > 0)) then
begin
WriteLn('********WARNING could not retrieve reflection hooks from server.');
WriteLn('Script will run improperly if you are not using up to date hooks.');
UseDefaultHooks := True;
Wait(4000);
end
else
if (StrToIntDef(Between('RSBuild = ', ';', S), 0) > StrToIntDef(Ref_CurrentBuild, 0)) then
begin
WriteLn('Hooks update available');
WriteLn('');
RSBuild := StrToIntDef(Between('RSBuild = ', ';', S), StrToIntDef(Ref_CurrentBuild, 0));
MyPlayer := Between('MyPlayer = ''', ''';', S);
CharAnim := Between('CharAnim = ''', ''';', S);
Animation_Fire := StrToIntDef(Between('Animation_Fire = ', ';', S), Ref_Animation_Fire);
WriteLn('RSBuild = ' + IntToStr(RSBuild) + ';');
WriteLn('MyPlayer = ''' + MyPlayer + ''';');
WriteLn('CharAnim = ''' + CharAnim + ''';');
WriteLn('Animation_Fire = ' + IntToStr(Animation_Fire) + ';');
WriteLn('');
WriteLn('Updated hooks! Hopefully they are up to date now.');
Wait(3000);
end
else
begin
UseDefaultHooks := True;
WriteLn('Your hooks are probably up to date.');
Wait(2000);
end;
if (UseDefaultHooks) then
begin
RSBuild := StrToIntDef(GetNumbers(Ref_CurrentBuild), -1);
MyPlayer := Ref_MyPlayer;
CharAnim := Ref_Animation;
Animation_Fire := Ref_Animation_Fire;
end;

it would be possible to do something like have the bots log out and pause until new hooks are uploaded, and when they are, resume the script…or even continue to bot while using color routine back ups (color backup is not a walk in the park though)

NCDS

2010-04-25 23:18:56

From: IceFire908
I have to update the hooks manually by editing my webserver page by logging into 000webhost and going to file manager, the script then does string functions by using Between() Explode() ect.. to update the hooks. I find the hooks at rs-hacking.com and then change them to SCAR format, test them, upload them to my web server.. then by comparing the manual override options in the script's client build number it knows whether or not the latest build is newer or not and can warn the user if the hooks are not updated while allowing them to try and find them themselves and manually override them.

http://icefire908.netai.net/Hooks

const                              // Don't change these
Script_Version = '1.12';
Ref_CurrentBuild = '602'; // Increase build # to current to overide server
Ref_MyPlayer = 'kk.i'; // Overrides
Ref_Animation = 'nc';

  WriteLn('Checking hooks...');
Wait(1000);
S := GetPage('http://icefire908.netai.net/Hooks');
if (not (Pos('RSBuild', S) > 0)) then
begin
WriteLn('********WARNING could not retrieve reflection hooks from server.');
WriteLn('Script will run improperly if you are not using up to date hooks.');
UseDefaultHooks := True;
Wait(4000);
end
else
if (StrToIntDef(Between('RSBuild = ', ';', S), 0) > StrToIntDef(Ref_CurrentBuild, 0)) then
begin
WriteLn('Hooks update available');
WriteLn('');
RSBuild := StrToIntDef(Between('RSBuild = ', ';', S), StrToIntDef(Ref_CurrentBuild, 0));
MyPlayer := Between('MyPlayer = ''', ''';', S);
CharAnim := Between('CharAnim = ''', ''';', S);
Animation_Fire := StrToIntDef(Between('Animation_Fire = ', ';', S), Ref_Animation_Fire);
WriteLn('RSBuild = ' + IntToStr(RSBuild) + ';');
WriteLn('MyPlayer = ''' + MyPlayer + ''';');
WriteLn('CharAnim = ''' + CharAnim + ''';');
WriteLn('Animation_Fire = ' + IntToStr(Animation_Fire) + ';');
WriteLn('');
WriteLn('Updated hooks! Hopefully they are up to date now.');
Wait(3000);
end
else
begin
UseDefaultHooks := True;
WriteLn('Your hooks are probably up to date.');
Wait(2000);
end;
if (UseDefaultHooks) then
begin
RSBuild := StrToIntDef(GetNumbers(Ref_CurrentBuild), -1);
MyPlayer := Ref_MyPlayer;
CharAnim := Ref_Animation;
Animation_Fire := Ref_Animation_Fire;
end;

it would be possible to do something like have the bots log out and pause until new hooks are uploaded, and when they are, resume the script…or even continue to bot while using color routine back ups

Thanks for the explanation. I was hoping you would post.
From: IceFire908

(color backup is not a walk in the park though)

The whole thing is color right now? or do you mean implementing it?

Nava2

2010-04-26 00:28:10

IceFire, why wouldn't you just setup the webpage like a dictionary.. or copy them *all* from the site into a file.. would be much simpler than all that parsing.

eg:

getX:::x.ys
getY:::x.y3
getZ:::asd.4

Much simpler parsing..

Wanted

2010-04-26 00:39:01

From: NCDS
The whole thing is color right now? or do you mean implementing it?


Actually having a way to switch over to color at any given moment with the script messing up and it have it run long enough for the hooks to be updated and re-implement reflection between game build changes… which is pretty hard to do.

From: Nava2
IceFire, why wouldn't you just setup the webpage like a dictionary.. or copy them *all* from the site into a file.. would be much simpler than all that parsing.

eg:

getX:::x.ys
getY:::x.y3
getZ:::asd.4

Much simpler parsing..


Yea what I'm doing is by no means the best way at all, it's makeshift because of the current state of a lot of things.

Sir R. M8gic1an

2010-04-26 03:35:05

I'd rather we didn't have MSI connecting to the internet when we could just simply push a new revision..

~RM

Coh3n

2010-04-26 11:01:39

From: Rasta Magician
I'd rather we didn't have MSI connecting to the internet when we could just simply push a new revision..

~RM

I thought of that too. Just having hooks constants in Globals or a new file (Hooks.scar) would be easier. I just think since we're only using reflection for walking, it would be better if everyone didn't have to download it and manually update they're hooks.

Blumblebee

2010-04-26 11:35:52

From: Rasta Magician
I'd rather we didn't have MSI connecting to the internet when we could just simply push a new revision..

~RM


I would rather that the script parses and collects/sets the hooks itself than us continually having to update. I think we could single handedly bring reflection back if we managed to properly implement the collection/setting of all the hooks in an easy procedure like SetUpReflection().

But that's just me.

Nava2

2010-04-26 11:37:02

Why not just have a branch for Hooks, then people can just pull from that branch.

Coh3n

2010-04-26 16:19:06

From: Nava2
Why not just have a branch for Hooks, then people can just pull from that branch.

That could work when we switch to git. :p

Wanted

2010-04-26 17:48:51

Pushing a new version would be a pain in the ass imo, the client updates a lot… usually is short periods of high activity then a week or two without notice will update 3 times within 24 hours.

Coh3n

2010-04-26 23:36:34

From: IceFire908
Pushing a new version would be a pain in the ass imo, the client updates a lot… usually is short periods of high activity then a week or two without notice will update 3 times within 24 hours.

We could always come up with an alternative like having a thread in MSI with updated hooks, and all the user has to do is replace the constants in the MSI core. We have 5 or 6 people that'll be able to update it with their mod capabilities anyway.

Trying to think of a way that pleases everyone. :p

Nava2

2010-04-26 23:44:24

I thought the system we had in reflection before worked very well…

It hardly interupted anyone and it was only necessary to fully update when public revs were committed.

Coh3n

2010-04-26 23:48:51

From: Nava2
I thought the system we had in reflection before worked very well…

It hardly interupted anyone and it was only necessary to fully update when public revs were committed.

I don't even know what that was. :p

But the way things are going, I don't see reflection being fully functional anytime soon anyway, so I see no point in getting people to download the whole include and having to change the hooks themselves. I can already see several threads being made on the subject…

Nava2

2010-04-27 00:16:32

It cross referenced the rev number with a file and downloaded otherwise

Sir R. M8gic1an

2010-04-27 05:54:47

I imagine there's a reason why the SRL include does not connect to the internet. I'm trying to find out what that reason is.

~RM

Coh3n

2010-05-07 10:08:39

Just to revive this a little, I was messing around with reflection walking the other day, and this is all that's required for it to work.


program ReflectionWalkingTest;
{$i SRL/SRL/misc/Smart.scar}
{$i SRL/SRL.scar}

const
HOOK_BASE_X = 'ut.a';
HOOK_BASE_Y = 'dq.N';
HOOK_PLAYER = 'cn.n';
HOOK_LOCAL_X = 'm';
HOOK_LOCAL_Y = 'q';

{******************************************************************************}
{ function GetMyPos: TPoint; }
{ By: BenLand100 }
{ Description: Calculates the player's tile position }
{******************************************************************************}
function GetMyPos: TPoint;
var
me: Integer;
begin
me := SmartGetFieldObject(0, HOOK_PLAYER);

Result.x := SmartGetFieldInt(0, HOOK_BASE_X) + SmartGetFieldInt(me, HOOK_LOCAL_X) shr 7;
Result.y := SmartGetFieldInt(0, HOOK_BASE_Y) + SmartGetFieldInt(me, HOOK_LOCAL_Y) shr 7;

SmartFreeObject(me);
end;

{******************************************************************************}
{ function TileToMM(Tile: TPoint): TPoint; }
{ By: BenLand100 }
{ Description: Converts the tile position to a minimap location }
{******************************************************************************}
function TileToMM(tile: TPoint): TPoint;
var
angle: Extended;
tX, tY: Integer;
tP: TPoint;
begin
angle:= rs_GetCompassAngleRadians;

tP := GetMyPos;
tX:= (tile.x - tP.x) * 4 - 2;
tY:= (tP.y - tile.y) * 4 - 2;

Result.x:= round(tX * cos(angle) - tY * sin(angle)) + 629;
Result.y:= round(tX * sin(angle) + tY * cos(angle)) + 85;
end;

{******************************************************************************}
{ function WalkToTile(tile: TPoint): Boolean; }
{ By: marpis, edited by Coh3n }
{ Description: Walks to a tile if it's on the minimap }
{******************************************************************************}
function WalkToTile(tile: TPoint): Boolean;
var
tP: TPoint;
begin
tP := TileToMM(tile);

if (InCircle(tP.X, tP.Y, MMCX, MMCY, 76)) then
begin
Writeln('Tile is on the minimap');
Mouse(tP.X, tP.Y, 4, 4, True);
Result := True;
FFlag(5);
end else
Writeln('Tile is not on the minimap');
end;

begin
Smart_Server := 152;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;

Wait(RandomRange(1000, 2000));
WalkToTile(Point(3265, 3428));
end.

You have to have the embedded_SMART.dll from reflection, obviously. Oh and I tested this in Simba. :)

RM, if it would be better for MSI to not connect to the internet, I don't see the harm in having constants for hooks. We could update them as needed, so just have a thread about it which is kept up to date by us or anyone else wanting to help. This could work at least until reflection is fully back up and running (which seems to be heading in the right direction anyway).

Sir R. M8gic1an

2010-05-07 12:20:23

Sorry for the very late reply. The reason I received was basically user safety and to balm suspicions, as a new user could feel suspicious for having to accept an internet connection.

I am also happier with the constants, considering there are quite a few SLs and reflection svn is not completely reliable for now.

~RM

Coh3n

2010-05-09 18:17:33

From: Rasta Magician
Sorry for the very late reply. The reason I received was basically user safety and to balm suspicions, as a new user could feel suspicious for having to accept an internet connection.

I am also happier with the constants, considering there are quite a few SLs and reflection svn is not completely reliable for now.

~RM

No problem, I was away for the weekend anyway. Any other thoughts? I can get this rolling if not…

E: Done in revision 100. :)