vwxz
12-23-2013, 05:19 PM
Hey guys. Quick tip here. Just some stuff I figured out while working on my current script, and I hope that it will be useful to others. Not too sure if this should go into the beginner or intermediate section, so feel free to move it.
Thanks to the people on IRC who helped work out the details! Especially to Millenium who gave me the tip about clothes (because I originally thought the opposite by accident)!
What is Pixel Shift?
Pixel shift is a measure of how many pixels in a given region have changed from the beginning and the end of a time period. Average pixel shift is the average over time of many samples of pixel shift.
You can view the SRL6 docs for pixel shift here (http://docs.villavu.com/srl-6/pixelshift.html). Flight has an in-depth tutorial for pixel shift in the context of OSRS here (http://villavu.com/forum/showthread.php?t=74090).
What is different in EOC?
I recommend you go read Flight's tutorial for a more general overview. Here are differences you need to account for in RS3.
The biggest difference is that your character has more details and more significant idle animations. This will cause a lot of noise and false positives in pixel shift if you do not account for it.
1. Your character has frequent, significant idle animations.
2. Your character's clothes will shift significantly during idle animation.
Here are some potential mitigation strategies.
1. You should sample pixel shift over a much larger time region to capture time in between idle animations.
2. You should do some sort of removal of outliers, whether by medians, sampling, etc. since idle animations are not completely avoidable and will cause you some proportion of skew and/or false positives if left in. Just averaging is not enough, because the outliers can be pretty large spikes causing pretty significant skew.
3. You should dress your character as close to solid colors as possible. This minimizes the effect of idle animations on pixel shift at least over the main portion of your character's body.
Example
Here is the script I was using to debug pixel shift. It is similar to Flight's example but expanded to take into account RS3 idle animations etc.
This script periodically prints out whether your character is performing a skilling animation. I've tweaked it to be reasonably accurate, but I hope to improve it before I release my current script.
Notes:
This is approximately equivalent to taking a median of average pixel shift. Note that the median is important since it is less affected by outliers.
I picked a threshold which works well for a mostly solid color outfit character doing woodcutting. This value is by no means universal.
program PixelShiftPrinter;
{$define smart}
{$i srl-6/srl.simba}
var
PixelShiftBox: TBox;
procedure DeclarePlayers
begin
Players.Setup(['zee'], 'default');
Players[0].World := 0;
Players[0].IsActive := True;
end;
procedure SetUpResources
begin
PixelShiftBox := IntToBox(275, 175, 300, 210);
end;
function IsPlayerAnimating: Boolean
var
PixelShiftResult, IX, CX: Integer;
begin
CX := 0;
for IX := 1 to 5 do
begin
PixelShiftResult := GetPixelShiftAverage(PixelShiftBox, 200, 1000);
if (PixelShiftResult > 200) then
begin
CX := CX + 1;
end;
end;
Result := CX > 3;
end;
begin
SetUpSRL;
SetUpResources;
DeclarePlayers;
Players[0].Login;
ExitSquealOfFortune;
MiniMap.ClickCompass;
Mainscreen.SetAngle(MS_ANGLE_HIGH);
repeat
WriteLn(BoolToStr(IsPlayerAnimating));
until False;
end.
Thanks to the people on IRC who helped work out the details! Especially to Millenium who gave me the tip about clothes (because I originally thought the opposite by accident)!
What is Pixel Shift?
Pixel shift is a measure of how many pixels in a given region have changed from the beginning and the end of a time period. Average pixel shift is the average over time of many samples of pixel shift.
You can view the SRL6 docs for pixel shift here (http://docs.villavu.com/srl-6/pixelshift.html). Flight has an in-depth tutorial for pixel shift in the context of OSRS here (http://villavu.com/forum/showthread.php?t=74090).
What is different in EOC?
I recommend you go read Flight's tutorial for a more general overview. Here are differences you need to account for in RS3.
The biggest difference is that your character has more details and more significant idle animations. This will cause a lot of noise and false positives in pixel shift if you do not account for it.
1. Your character has frequent, significant idle animations.
2. Your character's clothes will shift significantly during idle animation.
Here are some potential mitigation strategies.
1. You should sample pixel shift over a much larger time region to capture time in between idle animations.
2. You should do some sort of removal of outliers, whether by medians, sampling, etc. since idle animations are not completely avoidable and will cause you some proportion of skew and/or false positives if left in. Just averaging is not enough, because the outliers can be pretty large spikes causing pretty significant skew.
3. You should dress your character as close to solid colors as possible. This minimizes the effect of idle animations on pixel shift at least over the main portion of your character's body.
Example
Here is the script I was using to debug pixel shift. It is similar to Flight's example but expanded to take into account RS3 idle animations etc.
This script periodically prints out whether your character is performing a skilling animation. I've tweaked it to be reasonably accurate, but I hope to improve it before I release my current script.
Notes:
This is approximately equivalent to taking a median of average pixel shift. Note that the median is important since it is less affected by outliers.
I picked a threshold which works well for a mostly solid color outfit character doing woodcutting. This value is by no means universal.
program PixelShiftPrinter;
{$define smart}
{$i srl-6/srl.simba}
var
PixelShiftBox: TBox;
procedure DeclarePlayers
begin
Players.Setup(['zee'], 'default');
Players[0].World := 0;
Players[0].IsActive := True;
end;
procedure SetUpResources
begin
PixelShiftBox := IntToBox(275, 175, 300, 210);
end;
function IsPlayerAnimating: Boolean
var
PixelShiftResult, IX, CX: Integer;
begin
CX := 0;
for IX := 1 to 5 do
begin
PixelShiftResult := GetPixelShiftAverage(PixelShiftBox, 200, 1000);
if (PixelShiftResult > 200) then
begin
CX := CX + 1;
end;
end;
Result := CX > 3;
end;
begin
SetUpSRL;
SetUpResources;
DeclarePlayers;
Players[0].Login;
ExitSquealOfFortune;
MiniMap.ClickCompass;
Mainscreen.SetAngle(MS_ANGLE_HIGH);
repeat
WriteLn(BoolToStr(IsPlayerAnimating));
until False;
end.