SRL Archive - OSR Help

How does pixel shift work?


nen

2011-12-27 05:45:10

I have been reading over MSI's code but I have no idea what averagePixelShift. Could someone please explain exactly how it works?

function MSI_IsAnimating(Anim: TAnimation): Boolean;
var
avg: integer;
begin
with Anim do
begin
avg := averagePixelShift(pixelBox, interval, maxTime);
result := inRange(avg, minPixelShift, maxPixelShift);
MSI_SubDebug('Average pixel shift: ' + intToStr(avg));

if (result) then
MSI_SubDebug('Player animation: ' + anim.name);
end;
end;

^ Taken from MSI if someone wants to reference it.

Justin

2011-12-27 05:47:04

{*******************************************************************************
function PixelShift(B: TBox; Time: Integer): Integer;
By: marpis
Description: Calculates how many pixels change in box B during time T.
Date: Nov. 29, 2009
*******************************************************************************}

So what this would do is it would count how many pixels have changed in the box that you set in the time that you set. Used to detect movement in mining,woodcutting ect

Kasi

2011-12-27 06:00:14

im guessing by how it is used there, it calculates an average pixel shift. so it checks pixels at intervals until the max time is reached. it then calculates a average with the results. inrange checks if the average result given by averagepixelshift is in range of maybe the script's values. (minPixelShift, maxPixelShift)

BraK

2011-12-27 06:13:38

Moved to scripting help

Kyle Undefined

2011-12-27 09:45:15

As your player does various activities, or moves around in RS, your characters pixel turn on/off or "shifts". That function determines how many pixels are being turned on or off during a set amount of time in a given box.