SRL Archive - Help and Support

Again: A nice little function request...


WT-Fakawi

2011-02-21 06:54:42

I need a function that autosets fightmode to the lowest of these three skills:

Players[CurrentPlayer].Level[0] ATK
Players[CurrentPlayer].Level[1] DEF
Players[CurrentPlayer].Level[2] STR

The one I have is ugly and uses temp vars and a temparray. I am sure you can make me a better one for me? :)

Rich

2011-02-21 07:25:42

procedure SortSkills;
var
Skills : TIntegerArray;

begin
Skills:= [Players[CurrentPlayer].Level[0], Players[CurrentPlayer].Level[1], Players[CurrentPlayer].Level[2]];
QuickSort(Skills);
case Skills[0] of
Players[CurrentPlayer].Level[0] : SetFightMode(1);
Players[CurrentPlayer].Level[1] : SetFightMode(4);
Players[CurrentPlayer].Level[2] : SetFightMode(2);
end;
end;

Naum

2011-02-21 07:44:10

From: Rich
procedure SortSkills;
var
Skills : TIntegerArray;

begin
Skills:= [Players[CurrentPlayer].Level[0], Players[CurrentPlayer].Level[1], Players[CurrentPlayer].Level[2]];
QuickSort(Skills);
case Skills[0] of
Players[CurrentPlayer].Level[0] : SetFightMode(1);
Players[CurrentPlayer].Level[1] : SetFightMode(2);
Players[CurrentPlayer].Level[2] : SetFightMode(4);
end;
end;


Setting the fight mode to 4 (aka defense) doesn't seem to be working for me. Also Rich, you need to switch Level[1] and Level[2]'s FightModes; since [1] is Defense and [2] is Strength.

Rich

2011-02-21 07:48:01

From: Naum
Setting the fight mode to 4 (aka defense) doesn't seem to be working for me. Also Rich, you need to switch Level[1] and Level[2]'s FightModes; since [1] is Defense and [2] in Strength.
Thanks. I'm going to look at the SRL function now. Maybe 3 is defence?

EDIT: Nope. 4 is definitely defence. Not sure why it doesn't work…

EDIT2: Looks like when they updated the tabs, SetFightMode didn't get updated. Colours and co-ords are off. Changing them now.

_ChArMz

2011-02-21 08:05:34

if Players[CurrentPlayer].Level[2] < Players[CurrentPlayer].Level[1] then
begin
if Players[CurrentPlayer].Level[3] < Players[CurrentPlayer].Level[2] then
SetFightMode(4) //def
else
SetFightMode(2); //str
end else if Players[CurrentPlayer].Level[3] < Players[CurrentPlayer].Level[1] then
SetFightMode(4) //def
else
SetFightMode(1); //att

lookin for something simple like that?

Rich

2011-02-21 08:09:08

{function SetFightMode(oFightMode: Integer): Boolean;
By: Nielsie95 & Nava2, fixed by Quickmarch, fixed by Rich
Description: Sets fight mode. Returns false if failed to set desired mode.
*******************************************************************************}
function SetFightMode(oFightMode: Integer): Boolean;
var
i, x, y: Integer;
b: TBox;
cmbBoxes: TBoxArray;
begin
Result := False;
if not(Loggedin)then Exit;
GameTab(tab_Combat);
Wait(200 + Random(100));

cmbBoxes := [IntToBox(575, 255, 630, 290), IntToBox(660, 255, 710, 290),
IntToBox(575, 310, 630, 345), IntToBox(660, 310, 710, 345)];
b := cmbBoxes[oFightMode - 1];
if (not(GetColor(657, 345) = 5791325)) and (oFightMode = 4) then
b := cmbBoxes[2];
i := 0;
while (i < 4) do
begin
Result := FindColorTolerance(x, y, 1777020, b.x1, b.y1, b.x2, b.y2, 2);
if (Result) then Exit;
Mouse(RandomRange(b.x1, b.x2), RandomRange(b.y1, b.y2), 0, 0, True);
Wait(500 + Random(300));
Inc(i);
end;
end;
Could someone commit that? It should work now.
core\gametab.scar

Gu3st...

2011-02-21 08:12:03

Aren't there constants for this kind of stuff? We should have

atkType_Attack
atkType_Strength
arkType_Defence

and so on

Quickmarch

2011-02-21 08:34:41

From: Zyt3x
Aren't there constants for this kind of stuff? We should have

atkType_Attack
atkType_Strength
arkType_Defence

and so on


I did make a thread about this but it never got much attention.

Naum

2011-02-21 08:40:48

Committed a fix for it.

R1ch's function should work now

Rich

2011-02-21 10:47:10

Thanks Naum.

EDIT: Played with the function a bit, and came up with this.

WT-Fakawi

2011-02-21 14:35:58

Haha, thanks again for all your input. Still hesitating which one to pick :).. and thanks for the repair in SRL, naum and rich!

Wanted

2011-02-21 16:57:57

Save some lines ;)

function SetFightModeByLevel(LowNotHigh: Boolean): Boolean;
var
Skills, bSkills, AttModes: TIntegerArray;
I: Integer;
begin
Skills := [GetSkillLevel(Skill_Attack), GetSkillLevel(Skill_Strength), GetSkillLevel(Skill_Defence)];
bSkills := Skills;
AttModes := [1, 2, 4];
QuickSort(bSkills);
InIntArrayEx(Skills, I, bSkills[2 - (Integer(LowNotHigh) * 2)])
Result := SetFightMode(AttModes[I]);
end;

YoHoJo

2011-02-21 17:01:48

I love SRL!

Rich

2011-02-21 17:04:24

From: IceFire908
Save some lines ;)

function SetFightModeByLevel(LowNotHigh: Boolean): Boolean;
var
Skills, bSkills, AttModes: TIntegerArray;
I: Integer;
begin
Skills := [GetSkillLevel(Skill_Attack), GetSkillLevel(Skill_Strength), GetSkillLevel(Skill_Defence)];
bSkills := Skills;
AttModes := [1, 2, 4];
QuickSort(bSkills);
InIntArrayEx(Skills, I, bSkills[2 - (Integer(LowNotHigh) * 2)])
Result := SetFightMode(AttModes[I]);
end;
These two emoticons display my emotions and feelings of your post perfectly, no words needed:

:( :p

Gu3st...

2011-02-21 17:24:17

From: IceFire908
Save some lines ;)
Elegant :)

Wanted

2011-02-21 19:30:48

Eh not so elegant until there is a better way to do this http://villavu.com/forum/showthread.php?p=782025#post782025

const
cb_Attack = 1;
cb_Strength = 2;
cb_Controlled = 3;
cb_Defence = 4;

function SetFightModeByLevel(LowNotHigh: Boolean): Boolean;
var
Skills, bSkills, AttModes: TIntegerArray;
I: Integer;
begin
Skills := [GetSkillLevel(Skill_Attack), GetSkillLevel(Skill_Strength), GetSkillLevel(Skill_Defence)];
bSkills := Skills;
SetLength(bSkills, Length(bSkills));
AttModes := [cb_Attack, cb_Strength, cb_Defence];
QuickSort(bSkills);
InIntArrayEx(Skills, I, bSkills[2 - (Integer(LowNotHigh) * 2)])
Result := SetFightMode(AttModes[I]);
end;