SRL Archive - OSR Help

Able to detect a Hp change?


Archaic

2012-02-19 00:02:09

I'm currently developing an agility script and I'm looking for a way to check if Hp has dropped (i.e. an obstacle has been failed) from a point prior to attempting the obstacle to after the attempt.

I've been using a set up using HPPercent such that checks the hp at the start of the procedure and sets that as a variable, then attempts the obstacle and then checks for changes in Hp to indicate if the obstacle has been failed. I'm not sure what I'm doing wrong but it just doesn't seem to work and I keep getting compiling errors.

my unfinished (read: without standards) code so far:



procedure Swing;
var
SwingColor: integer;
z: integer; //<----------Theoretically, what Hp is before an obstacle

begin
if FindObjTPA(x, y, SwingColor, 5, 2, 1, 20, 10, ['wing']) then
begin
HPPercent := z;
writeln('Yay we found it');
MMouse(x, y, 1, 2);
Mouse(x, y, 0, 0, True);
Wait(4000+random(800));
if HPPercent < z then //<------------------if Hp drops then eat food
begin
Heal;
end;
end;
end;


What would be a better, more efficient, and actually workable way to do this?

Er1k

2012-02-19 00:33:40

       HPPercent := z;
are you trying to do
      z:= HPPercent;
instead?

E: Btw which course are you working on?

smurg

2012-02-19 00:36:06

From: nosaj.421
Simba Code:
[LEFT]HPPercent := z;
[/LEFT]

are you trying to do Simba Code:
[LEFT]z:= HPPercent;
[/LEFT]

instead?

E: Btw which course are you working on?


No.

z: integer; //<———-Theoretically, what Hp is before an obstacle

Looks good to me.

You'll want to do a GetMousePos(x, y) after the MMouse or it was for nothing btw.

And a huge static wait isn't the best either but you start somewhere.

Archaic

2012-02-19 00:39:19

Ah. That should do it. Always simple mistakes haha. Thank you for your help:)

I'm currently working/attempting at creating a wilderness agility course script, but it will definitely take a good while to make haha. We'll see how it goes! I thought it would be a good starting script and give me some good practice in areas where colors often aren't the best. Why do you ask?

Edit: Ya, I'm looking to add anti-ban to the static waits, for now I'm just trying to get the guts working though!

Er1k

2012-02-19 00:41:17

I am interested in agility scripts too. For the record, I wanted to work on barb basic, but my only p2p main is tied to training thieving, hence it's on hold for a while.

For a wildy course you might need to decide what you're gonna do about pkers. It'll be interesting for you I suppose.

@smurg, yes and no. He also missed the x, y integer declares.

Brandon

2012-02-19 00:55:03

Why HP percent? Just do

Something:= GetMMLevels('HP');
FindObstacle and work it..
NewHP:= GetMMLevels('HP');

if ((NewHP = Something) or FindBlackChatMessage('we failed or whatever')) then
re-try obstacle because we failed..

Archaic

2012-02-19 00:59:40

That's awesome! There definitely seems to be a lack of solid agility scripts. I think I have a method of dealing with them, though it may be slightly defeatist haha. But we'll see. Thank you for your help–could I possibly contact you if I have any minor problems (like this) seeing as you're interest in agility scripts as well?

smurg

2012-02-19 08:59:34

Oh nevermind, sorry, it was late at night.

You don't need z, because you can always just find your current hp.

Take out "HPPercent := z" and change the HP check to:

if HPPercent < PercentHealthToEat Then ….

Nemesis3X

2012-02-19 12:57:21

From: smurg
Oh nevermind, sorry, it was late at night.

You don't need z, because you can always just find your current hp.

Take out "HPPercent := z" and change the HP check to:

if HPPercent < PercentHealthToEat Then ….


Hehe Thanks, You didn't just Help one Person, Now I am able to make My script Eat when it needs to :-)