SRL Archive - OSR Help

How to script a safespot?


shadowmarkus

2011-12-25 16:11:07

Well, I'm trying to modify a script, so it remains at the same spot, and if it accidently moves, it should move back to that spot, how would one go about coding that?

Sir R. M8gic1an

2011-12-25 16:27:56

Well, first and foremost you'll want to make a function that can identify the spot, and whether you are in it / close to it. That can usually be done with a DTM, and you can then define whether you are in the safespot by distance to the main point.

After that, you'll want to make another procedure that moves you to the safespot if you aren't in it.

Then you'll want to call these functions in your fighting loop, such as
if not InSafeSpot then Relocate;
if HP_Percent < 100 then if not InSafeSpot then Relocate

that should be about enough :)

-RM

shadowmarkus

2011-12-25 16:31:33

From: Sir R. M8gic1an
Well, first and foremost you'll want to make a function that can identify the spot, and whether you are in it / close to it. That can usually be done with a DTM, and you can then define whether you are in the safespot by distance to the main point.

After that, you'll want to make another procedure that moves you to the safespot if you aren't in it.

Then you'll want to call these functions in your fighting loop, such as
if not InSafeSpot then Relocate;
if HP_Percent < 100 then if not InSafeSpot then Relocate

that should be about enough :)

-RM


It's the "identify the spot" part that confuses me. Since all the different squares in the area are basically the same. :O

But thanks alot for your help! :)

Sir R. M8gic1an

2011-12-25 16:32:57

post a pic ;)

-RM

shadowmarkus

2011-12-25 16:36:21

From: Sir R. M8gic1an
post a pic ;)

-RM


Give me a few minutes, then I'll update this post with a picture of the location. It's the ogre cage by the way, if you you happen to be familiar with that.

YoHoJo

2011-12-25 16:36:44

Can you show us picture if minimap and identify the safespot?
Basically you should make a ddtm (read tutorial about them) with thr main point being the safespot. Would be a bit hard, but fun, to make it. If the spot is literally one tile it's kind of hard to click exactly specifically one tile but still possible.

As for knowing when to recalibrate (when to walk to it) I'd assume you don't get hit at it, so I would have a check for HP bar above your head, if it's there you're not in spot and need to click the ddtm.

shadowmarkus

2011-12-25 16:38:37

From: YoHoJo
Can you show us picture if minimap and identify the safespot?
Basically you should make a ddtm (read tutorial about them) with thr main point being the safespot. Would be a bit hard, but fun, to make it. If the spot is literally one tile it's kind of hard to click exactly specifically one tile but still possible.

As for knowing when to recalibrate (when to walk to it) I'd assume you don't get hit at it, so I would have a check for HP bar above your head, if it's there you're not in spot and need to click the ddtm.


Well, the thing is, when you leave the safespot, you don't get hit, it's not a real "safespot" but, you can't attack the Ogres unless you're within a certain range, and your character tend to run around and bug out, getting stuck, if you just leave it.

I Am Legend

2011-12-25 16:38:44

i used a dtm and used rotated dtm to walk to safe spot

shadowmarkus

2011-12-25 16:43:36


The white outline is the places he should aim to be in.

And the blue on the minimap is the place he sometimes ends. It has nothing to do with the script walking off or anything. But sometimes when he attack one of the ogres, and it's blocked or something, he will run to the back of the cage.

YoHoJo

2011-12-25 16:49:47

Oh I see. Hmm maybe solve that when searching for ogres fund the closest one to players first that way they are always in range.

As for detecting when to move back, move up to the bad spot on purpose and see if anything in the minimap exists only when you're up there. Then script can sear for it, if found, move down.
Or other way around look for something on minimap when you're in proper spot and not visible when you move up. Then search for lack of it, and move down if not found.

shadowmarkus

2011-12-25 16:57:07

From: YoHoJo
Oh I see. Hmm maybe solve that when searching for ogres fund the closest one to players first that way they are always in range.

As for detecting when to move back, move up to the bad spot on purpose and see if anything in the minimap exists only when you're up there. Then script can sear for it, if found, move down.
Or other way around look for something on minimap when you're in proper spot and not visible when you move up. Then search for lack of it, and move down if not found.


Well, when he's behind the ogres, he can see another building on his minimap, that could be the trigger for "being stuck"

And getting to the right spot could be clicking between the 2 white lines on minimap (The part where you enter, it looks unique on the minpmap) Then he'd be somewhat In position I guess..

BraK

2011-12-25 17:00:38

Since the other 2 mod+ guys posting here didn't catch it I'll go ahead and move you thread to the correct section. For future reference please post for help in the Scripting help section. ;)

shadowmarkus

2011-12-25 17:01:10

From: BraK
Since the other 2 mod+ guys posting here didn't catch it I'll go ahead and move you thread to the correct section. For future reference please post for help in the Scripting help section. ;)


Thanks for that! My bad! :)

cause

2011-12-25 18:04:42

http://villavu.com/forum/showthread.php?t=68112
this is exactly what you need to solve your problem.
You kinda have to figure it out as you go, there isn't a tutorial for it yet. this is the code I use when creating an objectDTM:
program objectdtmer;
{$DEFINE SMART}
{$DEFINE PAINT}
{$i srl/srl.scar}
{$i SRL\SRL\MISC\Paintsmart.scar}
{$i ObjectDTM\ObjDTMInclude.simba}

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := 'asdf';
Players[0].Pass := 'asdf';
Players[0].Nick := 'asdf';
Players[0].Pin := '';
Players[0].Active := true;
end;

procedure paintupobjects; //paints on smart objects on minimap
begin
ObjectDebug(1);
end;

begin
smart_server := 1;
smart_members := false;
smart_signed := true;
smart_superDetail := false;
clearDebug();
setupSRL();
DeclarePlayers;
if not LoggedIn then LogInPlayer;
wait(1000);
ObjDTM_Setup;
MakeCompass('n');
paintupobjects;
wait(1000);
GenerateObjDTM([MM_TREE, MM_TREE, MM_TREE], 630, 121, True, True);


end.

Also if you use his Lumbridge walker file, along with reading his very accurate and helpful documentation within the include itself, you should be able to figure it out.