SRL Archive - SRL Archives

SetFightMode?


tarajunky

2006-05-25 12:19:57

I'm concerned that SetFightMode is not generic enough.

If you're weilding a Scimmy, then fightmode 3 is 'controlled'. If you're weilding a 2h then it's 'Aggressive'. If you're unarmed, then again there are only 3 buttons in different places, and the third button is 'Defensive'.

If you're training a pure character with a script, having it accidentally select the wrong button can ruin days or weeks of time and ruin a character.

The way I do it in my scripts is to base the clicking on the presence of the text for 'Accurate', 'Aggressive', or 'Defensive'. The bitmaps detect those words and if the button to the left of that word is not red, it will click it. The bitmaps aren't necessary if one could use a FindText type procedure to detect the text reliably.

Also, since SRL seems to have a problem properly selecting the button every time, I added a repeat loop to make sure that the button actually gets selected before moving on.

Gametab(1);
Wait(950);
Status('Selecting Combat Mode');
If (StatToTrain='Attack')And(getcolor(570, 294) = 4803916)Then
begin
Repeat
Mouse(random(30) + 570, random(5) + 280, 0, 0, true);
Wait(750+random(250));
i:=i+1;
Until (Not(getcolor(570, 294) = 4803916)) or (i>=4);
end else If (StatToTrain='Range')And(getcolor(570,324) = 5067346)Then
begin
Repeat
Mouse(random(30) + 570, random(5) + 324, 0, 0, true);
Wait(750+random(250));
i:=i+1;
Until (Not(getcolor(570,324) = 5067346)) or (i>=4);
end;
begin
If (StatToTrain='Strength')Then
begin
CombatBmp := BitmapFromString(25, 11, 'z78DA33300001372030C' +
'0027089D31A10E31EFABB0DD3C6C1106E94BB0A228EDFCDF8D560' +
'C60B2E57E12249F511F122F8D30CF16135B02243CB55B8629C543' +
'5B4CE5FC49843EBBC4CDDB8A085DB2829193001004D2D4C20');
If FindBitMapIn(CombatBmp,x,y,555,205,740,465) then
If Not(SimilarColors(1908611,GetColor(x-20,y+10),50)) then
begin
Repeat
Mouse(x-60+random(30), y+10+random(5), 0, 0, true);
Wait(750+random(250));
i:=i+1;
Until (SimilarColors(1908611,GetColor(x-20,y+10),50)) or (i>=4);
Freebitmap(CombatBmp);
end;
end else
If (StatToTrain='Defense')Then
begin
CombatBmp := BitmapFromString(20, 11, 'z78DA333000013720308' +
'002081B99A405C034991811FAD84B2DDB314395127B8989115CF1' +
'489EBD03AB17BF7F71A9A1AE9B294FBDC4E726E27D4D8BB44AAA7' +
'FE903E86F2F2E1B01BD8C0918');
If FindBitMapIn(CombatBmp,x,y,555,205,740,465) then
If Not(SimilarColors(1908611,GetColor(x-20,y+10),50)) then
begin
Repeat
Mouse(x-60+random(30), y+10+random(5), 0, 0, true);
Wait(750+random(250));
i:=i+1;
Until (SimilarColors(1908611,GetColor(x-20,y+10),50)) or (i>=4);
Freebitmap(CombatBmp);
end;
end;
end;
If (i>=4) Then
begin
Writeln('Unexpected Error');
begin
repeat
Wait(1000);
FindNormalRandoms;
until(not(LoggedIn));
NextPlayer(True);
end;
end;

XxKanexX

2006-05-25 12:27:01

or you could get the co-ords of all 4 buttons and it can be something like:

procedure SetFightMode(Button: integer);
;\ That way the user can check and set it.

tarajunky

2006-05-25 12:40:00

No, that's the problem with the current procedure.

There aren't always 4 buttons. Sometimes there are only 3 buttons. And sometimes button 3 will be defensive, when other time button 4 will be defensive.

The current procedure is fine if you never expect to get a weapon certed, or lose your weapon, or change to a different type of weapon, or don't mind if it accidentally doesn't click the button correctly when you call the setfightmode procedure. It is already set up for the correct coordinates of 4 buttons.

XxKanexX

2006-05-25 13:06:45

Ah, i see.

Good job, you even did range and all ;) But just a tip, if someone dosn't do the exact string that it needs (Say that do it in a different case), then it won't work.

Change:

If (StatToTrain='Attack')
to:

If ([B]Lowercase([/B]StatToTrain[b])[/b]='[B]attack[/B]')
And just do that to all of them. That way no matter what case they do, It'll still work ;)