PDA

View Full Version : [oglib] Help determining if model has moved



rkroxpunk
11-17-2015, 10:51 AM
Sorry in advance for my horrible code, I haven't done anything like this for many years!

I'm creating a basic Barbarian fishing spot script using oglib and am trying to detect when the fishing spot has moved. An easy way would be just have it click the nearest fishing spot every x seconds but that's boring.

My problem is with the isVisible(); function and I think I'm using it incorrectly. When I load a model into a model array and output the index of the model array that I want (i.e. one fishing spot) then it outputs: {ID = 111111, TID = 222222, X = 123123, Y = 456456}. I assumed if I used isVisible() on this exact index of the model array it would return false if the model wasn't present at the above coordinates just outputted. It would appear I've got that wrong though, as it will return true as long as there is a model with the same ID in the area, is there a way to do this or another function to use?

code so far:

var
fishingSpot: glModelArray;
closestTemp : glModelArray;
clientCenter := ogl.getClientMidPoint();

begin
fishingSpot := ogl.getModels(2252653705); //load all fishing spots in area to array
closestTemp := clientCenter.closest(fishingSpot); //array to temporarily store the last closest fishing spot this stays out of the loop

repeat
fishingSpot := ogl.getModels(2252653705); //reload fishing spots again in the loop to get current locations
if closestTemp[0].isVisible() then //the line that's causing issues. I want it to give a false value if the spot has moved, this always continues to return true though. Wrong function?
begin
//this chunk works, clientCenter.closest updates when the closest spot changes. ClosestTemp[0] continues to return the old closest
writeln(clientCenter.closest(fishingSpot)[0], 'closest spot output');
writeln(closestTemp[0], 'closest temp output');
wait(5000);
end
else
begin
writeln('Spot moved');
writeln(clientCenter.closest(fishingSpot)[0], 'closest spot output');
writeln(closestTemp[0], 'closest temp output');
mouse.move(clientCenter.closest(fishingSpot)[0].randomizePointEllipse(16));
exit;
wait(20000);
end
until false;

I hope I haven't explained that as horribly as I think I have, any help is much appreciated! :)

riwu
11-17-2015, 11:45 AM
I dont use oglib, but if i have to determine if my current fishing spot is gone, there's 2 ways:
1.
wait till character stop moving/gained xp (i.e. coordinate of current fishing spot will no longer change), then store the (x,y) coordinate of the current spot.
then keep grabbing the model at the area [x,y,x,y] and check if it's empty

2.
keep grabbing the models and storing the difference between player position and the coordinate of the nearest model (which should be the one u clicked).
then once the new (x,y) is greater than the old (x,y) (can give the difference a bit of 'tolerance') you know the spot is gone.

If you want to determine whether your player is still fishing or has stopped, that's another story (;

rkroxpunk
11-17-2015, 12:07 PM
I dont use oglib, but if i have to determine if my current fishing spot is gone, there's 2 ways:
1.
wait till character stop moving/gained xp (i.e. coordinate of current fishing spot will no longer change), then store the (x,y) coordinate of the current spot.
then keep grabbing the model at the area [x,y,x,y] and check if it's empty

2.
keep grabbing the models and storing the difference between player position and the coordinate of the nearest model (which should be the one u clicked).
then once the new (x,y) is greater than the old (x,y) (can give the difference a bit of 'tolerance') you know the spot is gone.

If you want to determine whether your player is still fishing or has stopped, that's another story (;

Thanks for the response. Everything you've explained particularly in number two is exactly what I'm trying to do it's just a matter of not knowing the correct oglib function to do it with. I've stored the model and it's coordinates to an array and then I also have another array that updates with the new closest fishing spot co-ordinates straight away. I guess I could use an AND statement to determine if the x and y matches, I was hoping there would just be a function that can tell me if the model is not present at OldX and OldY though

Ross
11-17-2015, 02:44 PM
Why are you detecting when it has moved? Your character model changes when you're fishing, so just utilize that. It's what I do in all of my OGL scripts.

Obscurity
11-17-2015, 02:58 PM
What Ross said.

Get your player model standing still, not doing anything. Watch for that. If that ID exists, you've stopped.

However, sometimes you stop for a split second before starting again. So, I'd watch for your player's model ID. If any are found, keep checking over another ~1-2 seconds. If it disappears, you're still fishing. If it still exists at the end of that 1-2 seconds, the spot has moved.

Good luck! PM or message me on Skype if you need help or advice.

rkroxpunk
11-17-2015, 08:07 PM
Oh wow I had no idea that makes it a lot easier. Cheers!