SRL Archive - OSR Help

How to Detect Player's Location


dragx55

2011-02-03 14:45:24

I am working on my first script that will be buying and banking kebabs from Karim in Al-Kharid. I have my script "laid out" right here(like a blueprint):
begin
SetupSRL;
repeat
if not(invFull)then
if not(isAtKarim)then
WalkToKarim;
else
BuyKebabs;
else
if not(isAtBank)then
WalkToBank;
else
BankKebabs;
until(false);
end.

My problem is that, how would I get the Simba to detect whether the character is at the bank or not? I'm sure I could use a FindColorTolerance color detection, but I don't think it's an effective way to detect a character's location. Umm, like how would isAtBank look like in an actual working script.

Rich

2011-02-03 14:48:48

You could use colour, and determine how far your character is away from the bank symbol on the minimap. You could perhaps search for a unique colour if there is one. However, what I'd recommend is to use Reflection by comparing tiles.

Main

2011-02-03 14:49:40

Am sure you can check for ground color with tpa. But for kebab, if you can just find the seller then its all good cause there is no door Or color around your character on the minimap..

RISK

2011-02-03 15:01:37

Check the distance between a symbol and the character on the minimap. Something like:
procedure DetermineLocation;
var
CX, CY, Dist : Integer;
begin
if FindSymbolIn(CX, CY, 'symbol', MMX1, MMY1, MMX2, MMY2) then
begin
Dist := Distance(CX, CY, MMCX, MMCY);
end;
end;

You would of course check for the distance amount, with something like: "if Dist > 10 then" and then you would continue on as you wish.
PS: Distance is by pixels, if I remember it correctly. So keep that in mind.

dragx55

2011-02-03 15:11:17

From: RISK
Check the distance between a symbol and the character on the minimap. Something like:
procedure DetermineLocation;
var
CX, CY, Dist : Integer;
begin
if FindSymbolIn(CX, CY, 'symbol', MMX1, MMY1, MMX2, MMY2) then
begin
Dist := Distance(CX, CY, MMCX, MMCY);
end;
end;

You would of course check for the distance amount, with something like: "if Dist > 10 then" and then you would continue on as you wish.
PS: Distance is by pixels, if I remember it correctly. So keep that in mind.

So what do I replace 'symbol', MMX1, MMY1, MMX2, MMY2, MMCX, and MMCY with?

Rich

2011-02-03 15:13:22

Change 'symbol' to 'bank' (there's a list of different symbol strings in symbol.scar), and leave the MM co-ords.

RISK

2011-02-03 15:14:28

You don't replace the coordinates with anything. They are good as they are.
You replace 'symbol' with something from the symbol file. Here is the valid symbols:

{*******************************************************************************
Valid Arguments are:
- agility - furnace - rare trees, tree
- altar - gem stall - rest, resting spot
- anvil - guide - sandpit
- apothecary - hair dresser - saw mill
- archery shop - herbalist - scimitar shop
- arrow - house - shield
- axe shop - hunter store - shop, store
- bar - hunter training - short cut
- bank - jewelery - silk stall
- candle shop - kebab shop - silver stall
- churn - mace shop - slayer master
- clothes shop - magic shop - spice stall
- cookery shop - makeover mage - spinning wheel, spin
- cookery, cook - mill - staff shop
- crafing shop - minigame - summoning store
- dungeon - mining shop - sword shop
- farming shop - pet shop - tanner
- farming spot - platebody shop - training dummy
- fishing shop, fish store - plateskirt shop - underground
- fishing spot, fish - portal (to player owned houses) - water source, water
- food shop - pottery, pot - weave
- fur trader - quest - windmill

*******************************************************************************}

{ var SymbolAccuracy: Extended;
Description: How accurate it must be, in %, to find symbols or icons on the minimap. }

PS: To use SymbolAccuracy, you must use it like this:
"SymbolAccuracy := 0.5;" – When you are done using it, revert it back to "0.7". It is in %. 0.5 = 50% out of 100%. It will help find the symbol if people or another symbol is on it. It is very useful. I suggest you use it before the FindSymbol in the procedure I gave you.

dragx55

2011-02-03 15:25:23

Ok, I got now. Thank you.

Boreas

2011-02-03 17:23:27

DTM of banker dots worked great bank in the day.