SRL Archive - SRL Suggestions

TrainLowFightStyle - Fighting.scar


Rich

2011-02-21 11:35:21

{*******************************************************************************
function SetFightModeByLevel(TrainLowestSkill : Boolean) : Boolean;
By: Rich
Description: Changes fight style to train lowest or highest skill depending on
TrainLowestSkill.
Usage example: Attack = 31, Defense = 45, Strength = 26
TrainLowestSkill = True -> Strength will be trained
TrainLowestSkill = False -> Defense will be trained
Date: 21st Feb 2011
*******************************************************************************}
function SetFightModeByLevel(TrainLowestSkill : Boolean) : Boolean;
var
FM, HL : Integer;
S, Skills : TIntegerArray;

begin
Result:= False;
if (not LoggedIn) then
Exit;
Skills:= [GetSkillLevel('attack'), GetSkillLevel('strength'), GetSkillLevel('defence')];
S:= [Skills[0], Skills[1], Skills[2]];
QuickSort(Skills);
if TrainLowestSkill then
HL:= Low(Skills)
else
HL:= High(Skills);
case Skills[HL] of
S[0] : FM:= 1;
S[1] : FM:= 2;
S[2] : FM:= 4;
end;
Result:= SetFightMode(FM);
end;
Description: Changes fight style to train lowest or highest skill depending on
TrainLowestSkill.
Usage example: Attack = 31, Defense = 45, Strength = 26
TrainLowestSkill = True -> Strength will be trained
TrainLowestSkill = False -> Defense will be trained

Bobzilla69

2011-02-21 11:37:53

good job, will be very useful. Reflection counterpart?

Frement

2011-02-21 11:38:12

Name: SetLowestFightMode?

Rich

2011-02-21 11:41:59

From: Bobzilla69
good job, will be very useful. Reflection counterpart?
Erm…I'll have a look at Reflection later on.

From: Frement
Name: SetLowestFightMode?
I was thinking about something along those lines, but it can also set highest…HLFightMode?

EDIT: All I could change to Reflection would be R_GetSkillLevel…

Frement

2011-02-21 11:57:07

SetFightModeByLevel then?

Rich

2011-02-21 12:01:56

From: Frement
SetFightModeByLevel then?
Genius.

lordsaturn

2011-02-21 12:02:19

Good addition to a script, but not an include.

Gu3st...

2011-02-21 12:26:12

From: lordsaturn
Good addition to a script, but not an include.
/skills/fighting.scar ?

I think it's committable

Wanted

2011-02-21 14:23:22

Moved to skill.

lordsaturn

2011-02-21 14:46:30

From: Zyt3x
/skills/fighting.scar ?

I think it's committable


Yeah, it would work fine in /skills/ but not in /core/.

Baked0420

2011-02-21 14:47:20

it gets an error when setting it to defence, he wrote 'defense' change the 's' in defence to a 'c'.

also, I may be wrong, but I don't know if it'll work correctly. Because it quicksorts, Skills[0], [1], and [2] might not always be attack, strength, defence, in that order. So when it does the case skills[hl], I think it might mess up if quicksort changes the order.

Like say defence is the lowest skill, then defence becomes Skills[0], and if you want to train the lowest skill, it'll go to Low(Skills), or Skills[0]. The case says that skills[0] sets S:= 1. Then it calls SetFightMode(1), but if say attack was your lowest skill, it'd put attack as skills[0] and still do low(skills) which is still gonna make it SetFightMode(1);

If I'm wrong then I apologize, and please explain what I misunderstood if you can.

lordsaturn

2011-02-21 16:10:46

'Defense' in america, 'Defence' in england. GetSkillLevel should handle both, if it does not already.

Baked0420

2011-02-21 16:49:40

I'm from America, but the debug said:

"Warning in SkillToCoords: Invalid Skill Name/Number: 'defense' "

and when I looked in SkillsToCoord it says 'defence' in SkillArr.

Rich

2011-02-21 17:01:19

From: Baked0420
it gets an error when setting it to defence, he wrote 'defense' change the 's' in defence to a 'c'.

also, I may be wrong, but I don't know if it'll work correctly. Because it quicksorts, Skills[0], [1], and [2] might not always be attack, strength, defence, in that order. So when it does the case skills[hl], I think it might mess up if quicksort changes the order.

Like say defence is the lowest skill, then defence becomes Skills[0], and if you want to train the lowest skill, it'll go to Low(Skills), or Skills[0]. The case says that skills[0] sets S:= 1. Then it calls SetFightMode(1), but if say attack was your lowest skill, it'd put attack as skills[0] and still do low(skills) which is still gonna make it SetFightMode(1);

If I'm wrong then I apologize, and please explain what I misunderstood if you can.


1) I purposely checked gametab.scar to see how defence was spelled in it, and I could have sworn it was with an s, but apparently not…

2) You're right. I was going by what I made for Fawki (correct in that case), and this needed changing, so I've fixed that.

Rich

2011-05-10 11:01:14

Was randomly browsing the forums and came across.
Thought it deserved a bump, so…bump?

Coh3n

2011-12-12 19:39:46

From: Rich
Was randomly browsing the forums and came across.
Thought it deserved a bump, so…bump?
Added to SRL5's fighting.simba.