SRL Archive - OSR Help

Need help adding Overloads


jpwesemann

2012-10-29 14:48:16

Hello,
Im not a good scripter, but i want to improve myself.
I want to add Overload support to a fighting script.
Maybe someone could give me his way to add Overload.
Sorry for my bad English (German)

Regards

Gu3st...

2012-10-29 15:03:50

Are you scripting in PascalScript or La-pe?

PascalScript doesn't support overloads, but la-pe does

Nebula

2012-10-29 15:08:17

From: Zyt3x
Are you scripting in PascalScript or La-pe?

PascalScript doesn't support overloads, but la-pe does


Lol. He means overload potions (in rs), not overloads (numbers over 2.1b?).

It would be difficult to do this if you do not have any pascalscript knowledge. Is the script yours? Could you posts its code?

jpwesemann

2012-10-29 15:26:02

Oh yes i mean Overload in Rs.
Hmm okay. This is not my Script. Its called Based Bandits.
Hmm are there any tutourials that could be useful for me ?

Flight

2012-10-29 22:08:37

From: Zyt3x
Are you scripting in PascalScript or La-pe?

PascalScript doesn't support overloads, but la-pe does


Don't feel bad, I was thinking the same thing. :p


Ok let's see, adding potion-handling to a script will be done in this process (roughly):

1) Time to take a sip?
2) Find the potion in the inventory
3) Clicking the potion
4) Resetting a "potion timer"

I'll let you handle Step 1 & 4, but I'll show you how to do Step 2 & 3.

For finding an item in the inventory, your best bet is to use DTMs; these are commonly used as their accuracy and simplicity make them very practical. To learn how to make DTMs you can check out one of these tutorials:
Creating Accurate DTMs
Yohojo's DTM Tut 1(Item finding with DTMs)

Now that you've made your DTM of your potion we'll want to find it & click it. I constructed a small example script of how to do this. It's self-explanatory:

{$I SRL/SRL.Simba}

Var
Potion: Integer;

Procedure LoadOurVars;
begin
Potion := DTMFromString('YOUR DTM STRING GOES HEREEEEEEE'); //First, let's define our "Potion" DTM
end;

Procedure FreeOurDTMs;
begin
FreeDTM(Potion);
end;

Function ClickPotion: Boolean;
var
x,y,PotionSlot: Integer;
begin
Result := False; //By default, this function should result False

if FindDTM(Potion,x,y,MIX1,MIY1,MIX2,MIY2) then //If our "Potion" DTM is found in the inventory then...
begin
PotionSlot := CoordsToItem(X,Y); //Convert the X/Y coordinate (that we found the Potion DMT at) into an inventory slot
MouseItem(PotionSlot, mouse_left); //Click the 'PotionSlot' inventory slot with a left-click action
Result := True; //We found & clicked the potion, so let's make this function result True (success!)
end;
end;

begin
SetupSRL;

LoadOurVars; //We MUST load our Potion DTM or the script won't know what to look for!

if ClickPotion then
Writeln('Took a sip of our potion!')
else
Writeln('No potion found...');

FreeOurDTMs; //ALWAYS free the DTMs after we're done using them (usually this is called when a script is stopped
end.

I hope that helps.

Edit:
Also as a small reference, MIX1 = Inventory X1, MIY1 = Inventory Y1, MIX2 = Inventory X2, MIY2 = Inventory Y2. Just in case you were wondering.

Daniel

2012-10-30 09:56:47

From: Nebula
not overloads (numbers over 2.1b?).

That's overflow, not overload ;)

And yeah, I thought the same as Zyt3x too :p

jpwesemann

2012-11-02 04:11:14

@Flight ,
Thanks for your help.
I will have a try adding Overloads.
Best Regards

Edit: I had a look on yohojos Dtm Tutourial, and i have a Question.
When i want to add a potion like Overload flask to my script, there are six different items ( Overload flask (6),
Overload flask (5), Overload flask (4), Overload flask (3), Overload flask (2) and Overload flask (1)).

Do i have to make Dtms of all of them ? Or only of the Overload flask(1)

Thanks

jpwesemann

2012-11-02 04:41:16

Okay,
I now made a Dtm of an Overload flask (1) and if i try it on other overload Flasks like (2,3,4) it will always find it. So i guess it is right :)

Im now trying to add these to the script ;)