SRL Archive - Discussions and Debates

Determine if ability slot is active thread


slushpuppy

2012-12-01 08:33:29

I know a few members in this community is trying to make an AIO function to do just that, so I decided to make this thread. Hopefully consolidated efforts will result in a better solution for the community:sasmokin:


Here's mine which fails on slots with blue/greyish BG

function isAbilitySlotReady(slot : Integer) : Boolean;
var box : TBox;
tpa,tpa1 : TPointArray;
centerBox : TPoint;
I,R,G,B : Integer;
contrastAvg : Extended;
tia : TIntegerArray;
begin

Result := false;
box := AbilitySlotToBox(slot);
//DebugTPA([Point(box.X1,box.y1),Point(box.X2,box.y2)],'');
centerBox := MiddleBox(box);
if FindColorsPie(tpa,265229,40, 340,360,0,8,box.X1,box.Y1,box.X2,box.Y2, centerBox.x,centerBox.y) then
begin
writeln('||' + inttostr(Length(tpa)));

tpa1 := MergeATPA(FindGapsTPA(tpa,1));
CombineTPAWrap(tpa,tpa1,tpa);
tia := GetColors(tpa);
for I := 0 to High(tia) do
begin
ColorToRGB(tia[I],R,G,B);
contrastAvg := contrastAvg + sqrt(Sqr( 0.241 * R) + Sqr(0.691*G) + Sqr(0.068 *B));

end;
contrastAvg := contrastAvg / (I + 1);
writeln(floattostr(contrastAvg));

end else Result := True;
end;


You can grab AbilitySlotToBox from https://github.com/SRL/SRL-5/pull/125/commits

I am working using a contrast calculation method with different weightage


Also these screenshots will be helpful

http://i.imgur.com/w8mRj.png
http://i.imgur.com/DtufD.png