SRL Archive - RS3 Help

[OGL] cleaning up Loot script


Clutch

2015-04-27 14:27:20

Okay so below I have my main loot function. You'll see at the top I have my right-click strings labeled "LOOT_ITEM_STRINGS =". This works fine…
If you look at the "procedure loot" you'll see it calls on iLoot - this picks up the models so it will right-click them. This also works just fine…
If you look even further below in my "procedure mainLoop" you'll see iLoot again - with a list of the Models. Again, all of these are correct no problems there.. BUT when I try to use anything but 50 different or statements for my reaction it will never detect them. The way it is setup now, it works, and it works well but I would like to shorten that up and make it look more clean.

I've tried everything I could think of so far, length(iLoot) … length(ogl.getModels(iLoot) … adding iLoot as it's own const/var opposed to how I have it as a glModelArray so it'd be iLoot:=(TCardinalArray([1234, 4567, 7890]) etc. etc. I just can't understand why when I try all these other options it won't ever detect the models and call on my loot procedure. Yet the sloppy way I have it below, it works fine. Any insight on this would be appreciated!

program ClutchRorarii;
{$include_once ogLib/lib/core/core.simba}

var
LOOT_ITEM_STRINGS = ['Take Ascension KeyStone', 'Take Ascension Grips', 'Take Sirenic'];
Mob := 3227299924;
iLoot, allModels, funcModelArray: glModelArray;
restore, pouch, Food: glTextureArray;
funcPointArray: tPointArray;
funcPointArrayIndex: uInt32=0;
clientCenter: TPoint;
canThreshold, canRotateCamera, canEscape, canSummon, canRestore, canLoot, canEat, canTerminate, canOvl, canFight: countDown = [0];

procedure doNothing;
begin
if actionBar.getLifePoints() > 90 then {this is just here to be here}
actionBar.setQuickPrayer(False)
else if actionBar.getLifePoints() < 90 then
actionBar.setQuickPrayer(True)
else if actionBar.setRegenerate(False) then
actionBar.setRegenerate(True);
end;

procedure Loot;
var
clickPoint: TPoint;
begin
if inventory.isFull() then {eats food if inventory is full}
inventory.clickItem(112710)
else
begin {detects my models for loot and picks them up}
clickPoint := clientCenter.closest(iLoot)[0].randomizePointEllipse(15);
mouse.rightClickOption(clickPoint, LOOT_ITEM_STRINGS);
canLoot.setTime(random(1000, 2000));
canFight.setTime(random(2000, 5000));
end;
end;

Procedure mainLoop;
var
Reaction : Procedure() =@doNothing;
begin
food := ogl.getTextures([72420, 112710]);
pouch := ogl.getTextures(133365);
iLoot := ogl.getModels(TCardinalArray([1327173775, 744893591, 416945094, 2425121800, 3058172354, 1850752908]));

if (actionBar.getLifePoints()< 20) or (food.isEmpty()) then
Reaction:=@Escape
{else if canTerminate.isFinished() then
Reaction:=@Terminate}
else if (actionBar.getSummoningPoints() > 10) and (length(ogl.getTextures(133365))) and (canSummon.isFinished()) then
Reaction:=@Summon
else if length(ogl.getModels(1327173775)) or length(ogl.getModels(744893591)) or length(ogl.getModels(416945094)) or length(ogl.getModels(2425121800)) or length(ogl.getModels(3058172354)) or length(ogl.getModels(1850752908)) then
Reaction:=@Loot

Reaction();
end;

begin
ogl.setup();
ogl.setDebugMode('models');
writeLN(ogl.GetModels());
Initialize;
repeat
{writeLN(ogl.GetModels());}
mainLoop;
until False;
end.

Yes, Clarity mentioned in other threads about just grabbing the loot Beam ID's but this has proven more difficult and time consuming then expected even with WriteLn it doesn't always pick up the loot beams and instead shows the coords as x=0 y=0 cuz there's too many items on top of it. Regardless I plan on eventually implementing this but in the meantime would like to have a better understanding on whats going on here with what I currently have.

Brotein

2015-04-27 14:42:47

I'm not entirely sure what the issue is but I'm guessing that one of those model IDs isn't showing up in the TCardinalArray, and for whatever reason if one doesn't show up it'll never return true like you want. I mean it could be something else, I'm not really sure I'm just going off my own experimenting.

Try this, make a constant like so…
const
ID_BEAM : array of uInt32 = [1327173775, 744893591, 416945094, 2425121800,
3058172354, 1850752908];

Later down in your logic just call
else if not ogl.getModels(ID_BEAM).isEmpty() then

*Edit*
So it's like saying, hey if I find any of the IDs in that array than I know there's a beam and I can loot which can be achieved if the array is not empty. That's how I have been doing it in my scripts, works fine.
Here's an example

const
ID_CHOPPING : array of uInt32 = [3311376887, 1327225593, 4059101093];

function isChopping() : Boolean;
begin
result := not ogl.getModels(ID_CHOPPING).isEmpty();
end;

So that returns true if any of the IDs exist, which in this case is the ID of the chopping using different axes.

Clutch

2015-04-27 14:54:38

From: Brotein
I'm not entirely sure what the issue is but I'm guessing that one of those model IDs isn't showing up in the TCardinalArray, and for whatever reason if one doesn't show up it'll never return true like you want. I mean it could be something else, I'm not really sure I'm just going off my own experimenting.

Try this, make a constant like so…
const
ID_BEAM : array of uInt32 = [1327173775, 744893591, 416945094, 2425121800,
3058172354, 1850752908];

Later down in your logic just call
else if not ogl.getModels(ID_BEAM).isEmpty() then

*Edit*
So it's like saying, hey if I find any of the IDs in that array than I know there's a beam and I can loot which can be achieved if the array is not empty. That's how I have been doing it in my scripts, works fine.
Here's an example

const
ID_CHOPPING : array of uInt32 = [3311376887, 1327225593, 4059101093];

function isChopping() : Boolean;
begin
result := not ogl.getModels(ID_CHOPPING).isEmpty();
end;

So that returns true if any of the IDs exist, which in this case is the ID of the chopping using different axes.


I'll give that a shot thanks for the suggestion!

Ross

2015-04-27 17:30:33

else if (not iLoot.isEmpty()) then
Reaction:=@Loot