Hello, I'm trying to create a script for a rsps which drinks brews by low hp. After 3 sips it should drink 1 restore sip.
for i := 0 to 3 do dosn't work because it would repeat 3 times regardless of if hp are low or not.
Thanks in advance ;)
Printable View
Hello, I'm trying to create a script for a rsps which drinks brews by low hp. After 3 sips it should drink 1 restore sip.
for i := 0 to 3 do dosn't work because it would repeat 3 times regardless of if hp are low or not.
Thanks in advance ;)
I'm not sure I really understand your requirement, but you would use mod to do something 'every n times'
Simba Code:var sips: integer;
begin
sips := 0;
while (true) do
begin
inc(sips)
if (sips mod 4) then
writeln('Im on my fourth sip again');
end;
I agree with bonsai, your post is unclear to me too. Sounds like you also want to check the amount of HP left on the character. You can do that like this:
Simba Code:// Check if HP is less than 80
if(actionbar.getHPPercent() < 80)
then begin
// Do your stuff here.
end;
Thanks for you reply. When I try to use if (sips mod 4) then this error comes up:"Type mismatch". What is mod? or were can I find someting bout it?
however you seem to want to check if hp is low first:Code:var sips: integer;
begin
sips := 0;
while True do
begin
inc(sips)
if sips mod 4 = 0 then
WriteLn('Sip: ',sips);
end;
end.
Simba Code:var i:Integer;
begin
if(actionbar.getHPPercent() < 30) then //if hp is less then 40%
begin
for i:=1 to 3 do
begin
//call proc to drink 1 brew (will be called 3 times) here
end;
//call proc to drink 1 restore sip here
end;
end;
Hi thanks for your help. Ok I'll try to explain it again. The script should check HP, if hp are under 80, like your example, it should drink a sip of saradomin brew. When he has drunk 3 sips [combat stats r low so he must drink 1 sip of restore so stats go up to 99 again], it should drink one sip of restoration pot and start at beginning. [3 brew sips then 1 restore sip]
General info on mod. In short it finds the remainder after dividing two numbers.
Ninja edit:
Then what you want is to keep track of how many sips of saradomin brew you have taken. Once that counter is >= 3 you can take your restore potion and wait until your health is below 80% again.
Simba Code:// Check if HP is less than 80
if(actionbar.getHPPercent() < 80)
then begin
drinkSaraPot();
saraPotCounter := saraPotCounter + 1;
end;
// Check how many times you drank sara.
if(saraPotCounter >= 3)
then begin
drinkRestorePot();
saraPotCounter := 0;
end
Make sure saraPotCounter is a global variable. Or depending on how much sara heals and makes you lose in stats you might want to go with slacky's version instead.
Haha you got it. That's exactly what I wanted :) Thanks everyone
hm, if i am trying to use if(actionbar.getHPPercent() < 80) it says "Unknown identifier 'actionbar'". Using osr include and pascal. How can I fix it?
Ok ty, tried to replace if(actionbar.getHPPercent() < 80) with if(HPPercent() < 80), "Invalid number of parameters". What am I doing wrong?
I've tried:
dosn't work. could someone help me? ;)Quote:
if (HPPercent() < 80)
and
if (HPPercent(true) < 80)
and
if (HPPercent(100) < 80)
Can you post at least part of your script in [simba] tags? It would really help to be able to see what it is that you've got in order to suggest changes.
Dosn't work.
Simba Code:// Check if HP is less than 80
if(HPPercent() < 80)
then begin
drinkSaraPot();
end;