SRL Archive - Outdated Tutorials

[#40] Animation.SCAR


marpis

2009-12-07 09:32:41

[#40] Animation.SCAR
Includes functions that help you detect wheter some objects on screen are moving!

[php]
//—————————————————————–//
//– Scar Standard Resource Library –//
//– ยป Animation Routines –//
//—————————————————————–//
// * Function PixelShiftMulti(B: TBoxArray; T: Integer): TIntegerArray; // * by marpis
// * Function PixelShift(B: TBox; Time: Integer): Integer; // * by marpis
// * Function AnimatingMulti(B: TBoxArray; Time, MinCount: Integer): TBooleanArray; // * by marpis
// * Function Animating(B: TBox; Time, MinCount: Integer): Boolean; // * by marpis
// * Function IsMoving: Boolean; // * by marpis
[/php]

PixelShift(B: TBox; Time: Integer): Integer;
- Returns the number of pixels that have changed color in "Time"-milliseconds.
- Usage: Detect if many colors have changed in box "B" in "Time"-milliseconds.
- Example:

B := GetTPABounds(TPA);
If (PixelShift(B, 200) > 10) Then
WriteLn('Over 10 pixels in box "B" have changed color in 200ms!');

Function Animating(B: TBox; Time, MinCount: Integer): Boolean;
- Returns True if there is a constant animation in box B in "Time"-milliseconds and at least "MinCount"-pixels change every 50 milliseconds. The 50ms is built in the function, I think it's the best frequency.
- Usage: Detect wheter an object is an NPC/otherwise animating.

Function IsMoving: Boolean;
The old one didn't work, so here's a fixed one! :)

—
The "Multi"-versions of the functions are found in Animation.SCAR, but I made this tutorial userfriendly so I didn't explain those. They're bit more complicated.
Enjoy! :)

NCDS

2009-12-07 10:03:24

Nice work. :)

You just took all the fun out of everyone's "IsChopping" or "IsMining" functions, though.

marpis

2009-12-07 10:14:53

From: NCDS
Nice work. :)

You just took all the fun out of everyone's "IsChopping" or "IsMining" functions, though.


Yea, you're right! These are way too leet to be added in SRL! :p

Naum

2009-12-07 11:44:51

Great code, great capitalizing as well ;).

Just a mere suggestion, but maybe you could have the pixel shift of specific 'pre -defined' colors, with a 'pre-defined' tolerance. That way you can find out if a person is mining - using something like this:

If ColorAnimating(PickColors, 25 {TOL}, IntToBox(MSCX - 10, MSCY - HeightOfPlayer, MSCX + 10, MSCY + HeightOfPlayer), 900, 40) Then
WriteLn('Person IS Mining');

^ Just a suggestion,

Great work :D!

noidea

2009-12-07 14:51:09

From: Naum
Great code, great capitalizing as well ;).

Just a mere suggestion, but maybe you could have the pixel shift of specific 'pre -defined' colors, with a 'pre-defined' tolerance. That way you can find out if a person is mining - using something like this:

If ColorAnimating(PickColors, 25 {TOL}, IntToBox(MSCX - 10, MSCY - HeightOfPlayer, MSCX + 10, MSCY + HeightOfPlayer), 900, 40) Then
WriteLn('Person IS Mining);

^ Just a suggestion,

Great work :D!


And using tpa's to find a good pick colour and your idea that's a perfect ismining procedure :)

NCDS

2009-12-07 18:35:47

@Naum and marpis,

Why don't you guy's put your ideas together to make something. It seems like this is just like what MSI is looking for. Simple to use and effective.

TRiLeZ

2009-12-07 19:15:44

This should improve efficiency of a lot of scripts. :D

Error…

[Runtime Error] : Exception: Canvas does not allow drawing in line 33 in script C:\Program Files\SCAR 3.23\includes\srl\srl\core\Animation.scar

marpis

2009-12-08 03:52:31

From: Naum
Great code, great capitalizing as well ;).

Just a mere suggestion, but maybe you could have the pixel shift of specific 'pre -defined' colors, with a 'pre-defined' tolerance. That way you can find out if a person is mining - using something like this:

If ColorAnimating(PickColors, 25 {TOL}, IntToBox(MSCX - 10, MSCY - HeightOfPlayer, MSCX + 10, MSCY + HeightOfPlayer), 900, 40) Then
WriteLn('Person IS Mining');

^ Just a suggestion,

Great work :D!


I think waitcolorcount works for that :)

From: TRiLeZ
This should improve efficiency of a lot of scripts. :D

Error…

Which function? Did you try rebooting SCAR?

Dervish

2009-12-08 07:39:32

Add them, would be pretty damn ownage ! :)

marpis

2009-12-09 18:08:31

From: Dr D. Dervish
Add them, would be pretty damn ownage ! :)


Check open-dev :rolleyes:

Coh3n

2009-12-17 16:47:43

From: TRiLeZ
This should improve efficiency of a lot of scripts. :D

Error…

You can also just re-drag the cross hairs to get rid of that problem. :)