SRL Archive - Reflection Development

a few functions i use frequently


Feroc1ty

2011-03-10 18:45:30

function IsNearbyPoint(point:TPoint;tiles:integer):boolean;
begin
result := DistanceFrom(point) <= tiles;
end;

function PickupItemNear(id:integer;name:string;area:integer;var count:integer):boolean;
var ground:TGroundItemArray;
item:TInvItem;
index,num:integer;
begin
ground := GetItemsNear(area);
R_ItemExists(id,item);
num := item.StackSize;
for index := 0 to high(ground) do
begin
if (ground[index].ID = id) then
begin
ClickBox(PtToBox(TileToMS(ground[index].tile,30),8),false);
result := R_WaitOption(name,300);
wait(100+random(75));
r_Flag;
R_ItemExists(id,item);
count := count + item.stacksize - num;
break;
end;
end;
wait(random(50));
end;

function InteractWithTile(action:string;offset:TPoint;tile:TTile):boolean;
var pt:TPoint;
begin
result := false;
fDebug('InteractWithOBJ','Attempting to '+action+'.');
if not TileOnMS(tile,30) then WalkToTile(tile,1,0);
pt := TileToMS(tile,0);
pt.x := pt.x + offset.x;
pt.y := pt.y + offset.y;
MoveBox(PtToBox(pt,8));
Wait(100+random(125));
if R_IsUpText(action) then
begin
ClickMouse2(true);
result := true;
end else
begin
ClickMouse2(false);
result := R_ChooseOption(action);
end;
wait(500+random(150));
r_Flag;
end;

function InteractWithNPC(action:string;npc:TNPC):boolean;
var t:TNPC;
begin
fDebug('InteractWithNPC','Attempting to '+action+' (to) a '+npc.name+'.');
if not TileOnMS(npc.tile,30) then
begin
WalkToTile(npc.tile,1,1);
R_Flag;
end;
MoveBox(PtToBox(TileToMS(npc.tile,30),10));
Wait(100+random(125));
if R_IsUpText(action+' '+npc.name) then
begin
ClickMouse2(true);
result := true;
end else
begin
ClickMouse2(false);
if R_ChooseOption(action+' '+npc.name) then result := true;
end;
end;

procedure FinishFight(delay:integer);
var i:integer;
mob:TNPC;
begin
r_Flag;
wait(delay);
for i := 0 to 30 do
begin
if CharacterAnimating then i := 0;
wait(50);
if AreWeInteracting(mob) = false then break;
end;
end;

function FightNPC(name:string):boolean;
var mobs:TNPCArray;
index:integer;
begin
index := 0;
mobs := SortNPCs(GetNPCs(name));
for index := 0 to high(mobs) do
begin

if mobs[index].fighting or mobs[index].moving then
continue;

result := InteractWithNPC('attack',mobs[index]);

if result then FinishFight(200);

fDebug('FightNPC','Finished fighting.');
break;
end;
end;

Here are the box functions I use which I think all of these functions use, I use my own due to them having a higher chance of clicking the center point, and decreasing as you go out.

function PtToBox(tile:TPoint;size:integer):TBox;
begin
Result.X1 := Round(tile.x - size/2);
Result.X2 := Round(tile.x + size/2);
Result.Y1 := Round(tile.y - size/2);
Result.Y2 := Round(tile.y + size/2);
end;

function MouseInBox(box:TBox):boolean;
var pt:TPoint;
begin
GetMousePos(pt.x,pt.y);
result := PointInBox(pt, box);
end;

procedure ClickBox(box:TBox;left:boolean);
var x,y:integer;
begin
x := (box.x2 - box.x1)/2;
y := (box.y2 - box.y1)/2;
if not MouseInBox(box) then
MMouse(box.x1 + x + Random(RandomRange(-x,x)), box.y1 + y + Random(RandomRange(-y,y)), 0, 0);
ClickMouse2(left);
end;

procedure MoveBox(box:TBox);
var x,y:integer;
begin
x := (box.x2 - box.x1)/2;
y := (box.y2 - box.y1)/2;
if not MouseInBox(box) then
MMouse(box.x1 + x + Random(RandomRange(-x,x)), box.y1 + y + Random(RandomRange(-y,y)), 0, 0);
end;

Train

2011-03-10 18:49:13

Useless, useless, and more useless.

Feroc1ty

2011-03-10 18:53:12

From: Train
Useless, useless, and more useless.


Thanks, but I don't care for your opinion as you have no interest in reflection development; oh and gl getting laid, must be a hard task knowing you have no life(lol virgin, u mad?).

THIS ISN'T GEARED TOWARDS ANYONE ON THIS FORUM, SO IF YOU FIND THIS OFFENSIVE JUST… I DUNNO LOL.

YoHoJo

2011-03-10 18:55:45

Stop the bickering, ignore it.
Thanks for sharing these functions, I'm sure people will find them useFUL.

Train

2011-03-10 19:00:02

Just stating the truth.
These functions are useless and I bet won't be added.

Yago

2011-03-10 19:07:33

I actually might use this thanks :)

Nava2

2011-03-10 19:13:40

Little too arbitrary for my liking. thanks for contributing though! :)

TomTuff

2011-03-10 20:57:57

From: Feroc1ty
Thanks, but I don't care for your opinion as you have no interest in reflection development; oh and gl getting laid, must be a hard task knowing you have no life(lol virgin, u mad?).

THIS ISN'T GEARED TOWARDS ANYONE ON THIS FORUM, SO IF YOU FIND THIS OFFENSIVE JUST… I DUNNO LOL.


It's ironic because he has developed an entire reflection include.

Gu3st...

2011-03-10 21:02:21

From: Feroc1ty
Thanks, but I don't care for your opinion as you have no interest in reflection development; oh and gl getting laid, must be a hard task knowing you have no life(lol virgin, u mad?).

THIS ISN'T GEARED TOWARDS ANYONE ON THIS FORUM, SO IF YOU FIND THIS OFFENSIVE JUST… I DUNNO LOL.
Funny how you quote someone, insult them and then later say that it's not directed at anyone…

Flight

2011-03-10 21:18:08

Erm I think it should be closed before it gets outta hand. It was nice of you to release a few of your own methods, there should be no penalty as he's just trying to help. If someone wants to put down your work then ignore them, that's just their opinion. I don't agree at all with Train for criticizing it, but you lowered yourself to his level by retaliating.

YoHoJo

2011-03-10 22:56:53

From: Nava2
Little too arbitrary for my liking. thanks for contributing though! :)


Yeah for mine too, but I like stuff like this. Although they do not fit everyone's tastes the can save a lot of people time by just copy/pasting and stuff like that if they want to make a quick easy script.

Sex

2011-03-10 22:57:07

From: Feroc1ty
Thanks, but I don't care for your opinion as you have no interest in reflection development; oh and gl getting laid, must be a hard task knowing you have no life(lol virgin, u mad?).

THIS ISN'T GEARED TOWARDS ANYONE ON THIS FORUM, SO IF YOU FIND THIS OFFENSIVE JUST… I DUNNO LOL.

Bruh, no point in posting that. Makes you look stupid. If you just stopped there and didn't post that it wouldn't make you look like a brat and keep Timer looking like one. Also, he made RRL so, I wouldn't even say that he don't gaf about Reflection development. Why do you care if he gets laid or not? He's like 13 anyways? Also, just don't trip off what he says if you have that bad of an opinion of him. Obviously it wouldn't matter to you. Um, yeah..I don't really know what I'm saying right now but I think you get what I'm sayin' ;).

i luffs yeww

2011-03-10 23:31:42

Can we stop with this stupid childish bullshit between you guys? I'm sick of reporting threads to get closed because nobody can keep their shit private and grow up. Some people dislike each other. That doesn't mean you get the privilege to just bash people. Especially you two, Timer and Kyle. You're both lucky you're allowed back. And you're really not proving yourself worthy by doing this stupid shit, even if it's a one-time thing.

Grow up. Be happy you have what you have. And take this stupid childish nonsense somewhere else.

Anyway, on topic.

You posted these because you use them frequently, yes? That shows me that they may at least possibly be valuable to add to reflection. I dunno what's already in reflection, so I won't say if I think these should be in or not.

Thank you for posting, though. :)

Sex

2011-03-10 23:40:49

Nothing I said was bashful :)? I don't get that. And I was already allowed back anyways my ban was not permanent unlike yours. It was for one year :p.

Nava2

2011-03-11 02:08:02

*sigh*

Closed, denied, if others want to use it, feel free. :)