Jump to content
faguss

Fwatch General Scripting

Recommended Posts

Continuing from this topic.

You can also use Fwatch 1.1 to detect & set player animation.

I can't think of any other method. Finding unit structure and acquiring any stance value is beyond my reach.

Edited by Faguss

Share this post


Link to post
Share on other sites
You can also use Fwatch 1.1 to detect & set player animation.

I can't think of any other method. Finding unit structure and acquiring stance value is beyond my reach.

Do you mean mem getplayeranim command?

Sorry if I misunderstood this command, but does it return the name of animation that is currently being played? :confused:

If so could this be used to check unit stance by checking what kind of stance (animation group of some stance) the currently played animation belongs to?

Edited by Icarus

Share this post


Link to post
Share on other sites

It returns a number. Details are in the documentation. Usage is quite problematic. Example:

;only original config
_lying=false
_animCODE = call loadFile ":mem getplayeranim"
? _animCODE in [0,14,32,36,39,40,41,252] || _animCODE>=71 && _animCODE<=82 || _animCODE>=165 && _animCODE<=236 : _lying=true

Edited by Faguss

Share this post


Link to post
Share on other sites

Is there any way to change what number the certain animation has? :butbut:

Share this post


Link to post
Share on other sites

Yes, that depends on \res\config and configurations in addons. See the doc.

Extending last example. Now it includes animations from o.pbo (handgun).

Initalization

player switchMove "handguncrouchbase"
_base = call loadFile ":mem getplayeranim"
player switchMove "combat"

LyingCodes = [0,14,15,32,36,39,40,41,252, _base+3, _base+138]
_ranges = [71,82,165,236,_base+8,_base+12,_base+14,_base+33,_base+65,_base+68,_base+103,_base+110,_base+130,_base+135]
_i = 0
_j = _ranges select _i
#loop
? _j <= (_ranges select _i+1) : LyingCodes=LyingCodes+[_j]; _j=_j+1; goto "loop"
? _i < (count _ranges -2) : _i=_i+2; _j=_ranges select _i; goto "loop"

Check

_lying=false
_animCODE = call loadFile ":mem getplayeranim"
? _animCODE in LyingCodes : _lying=true

Works for OFP with standard config.

Edited by Faguss
added link

Share this post


Link to post
Share on other sites

@Faguss

Thank you so much!!!

If it is possible to change animation codes, than I would like to line up animations so each stance corresponds to one interval of animations.

Then (at least in theory) detecting player stance would not be difficult, and CPU intensive.

If I misunderstood something, please correct me. :confused:

Edited by Icarus

Share this post


Link to post
Share on other sites

It's not a good idea because it will work only for you and nobody else. Not mentioning how much work it would be.

It's not difficult and not CPU intensive.

Share this post


Link to post
Share on other sites

@Faguss

It took some time to learn something about those examples you showed. :o

Using those Logical Operators ( ? : Ternary (shorthand for if-then-else statement)) really saves space in script that only allows 122 characters per line.

Having this limitation is it still possible to make script, that using Fwatch v1.1, would distinguish standing, crouch and prone stances, not just prone/not prone stance? :confused:

P.S. Isn't this example you showed better than that stance check script that uses "Dummy bullet"?

Thanks again for your expertise :notworthy:

Icarus

Share this post


Link to post
Share on other sites

You misunderstood, it's the Fwatch commands that are limited to 127 characters. 122 is a text limit for

which usage is optional. Personally I write scripts in Notepad++ and use IGSE when testing.
Isn't this example you showed better than that stance check script that uses "Dummy bullet"?

Depends. For example you can use "Check Stance" on AI.

Edited by Faguss

Share this post


Link to post
Share on other sites

So is the mem getplayeranim command only for player use?

Can it be used for bots too? :confused:

Share this post


Link to post
Share on other sites

@DanAK47

There was (and still is?) no way to detect if the player was standing, kneeling, or lying down consistently.

Not anymore... :cool:

I am proud to present you Stance Check script:

? localize "STR_USRACT_CHEAT_1" != "FWATCH" : hint "Cannot detect Fwatch"; exit

;Compatible with original Arma:CWA (v1.99) and OFP (v1.96),  Fwatch v1.1 required

; All credit goes to Faguss
; Loop displaying stance(from animation code)
; Pistol animations are included. Dying and being dead is treated as lying stance.


player switchMove "handguncrouchbase"
_base = call loadFile ":mem getplayeranim"
player switchMove "combat"

CrouchCodes = [27,28,30,31,33,34,37,38,234,235,251,_base,_base+1,_base+36];
_ranges2 = [116,139,237,248,_base+4,_base+13,_base+69,_base+86,_base+99,_base+102,_base+111,_base+114]
LyingCodes = [0,14,15,32,36,39,40,41,252, _base+3, _base+138]
_ranges = [71,82,165,236,_base+8,_base+12,_base+14,_base+33,_base+65,_base+68,_base+103,_base+110,_base+130,_base+135]

_i = 0
_i2 = 0
_j = _ranges select _i
_j2 = _ranges2 select _i2

#loop
? _j <= (_ranges select _i+1) : LyingCodes=LyingCodes+[_j]; _j=_j+1; goto "loop"
? _i < (count _ranges -2 ) : _i=_i+2; _j=_ranges select _i; goto "loop"
#loop2
? _j2 <= (_ranges2 select _i2+1) : CrouchCodes=CrouchCodes+[_j2]; _j2=_j2+1; goto "loop2"
? _i2 < (count _ranges2 -2) : _i2=_i2+2; _j2=_ranges2 select _i2; goto "loop2"

#checkloop
~0.5
_stance="Standing"
_animCODE = call loadFile ":mem getplayeranim"
? _animCODE in LyingCodes : _stance="Lying";
? _animCODE in CrouchCodes : _stance="Crouch";
player globalchat format ["Stance: %1",_stance]
goto "checkloop"

http://www.gamefront.com/files/21612117/Stance_check_script_example_missions_zip

All credit goes to Faguss. :notworthy: He did 95% of all work. I just did some editing and testing.

It is capable of detecting all three stances (standing, crouch and prone).

Works with both original Arma:CWA (v1.99) and original OFP (v1.96) Config (ww4 mod version will be released in future)

Requires Fwatch v1.1. You can download installer (easy way) at webiste of Faguss: http://ofp-faguss.com/files/fwatch_install.exe

Or if you are familiar with Fwatch, then follow this link

Take care, Icarus :bounce3:

Edited by Icarus
Updated Fwatch v1.1 compatibility (now Arma: CWA capable)

Share this post


Link to post
Share on other sites

Following my promise to release Stance Check script for ww4 mod v2.5:

? localize "STR_USRACT_CHEAT_1" != "FWATCH" : hint "Cannot detect Fwatch"; exit

; For ww4mod v2.5 Config ONLY! 
; Compatible with Arma:CWA (v1.99) and OFP (v1.96), Fwatch v1.1 required

; All credit goes to Faguss
; Loop displaying stance(from animation code)
; Pistol animations are included. Dying and being dead is treated as lying stance.

CrouchCodes = [40,41,43,44,46,47,51,323,347,451,477,478,855,857,860,861]
_ranges2 = [152,183,308,310,313,316,381,398,439,442,500,509]
LyingCodes = [0,45,209,280,312,313,429,481,852,854]
_ranges = [19,22,52,54,89,100,211,275,317,322,324,343,377,380,443,450,471,476,481,483,872,875]
_i = 0
_i2 = 0
_j = _ranges select _i
_j2 = _ranges2 select _i2

#loop
? _j <= (_ranges select _i+1) : LyingCodes=LyingCodes+[_j]; _j=_j+1; goto "loop"
? _i < (count _ranges -2 ) : _i=_i+2; _j=_ranges select _i; goto "loop"
#loop2
? _j2 <= (_ranges2 select _i2+1) : CrouchCodes=CrouchCodes+[_j2]; _j2=_j2+1; goto "loop2"
? _i2 < (count _ranges2 -2) : _i2=_i2+2; _j2=_ranges2 select _i2; goto "loop2"

#checkloop
~0.5
_stance="Standing"
_animCODE = call loadFile ":mem getplayeranim"
? _animCODE in LyingCodes : _stance="Lying";
? _animCODE in CrouchCodes : _stance="Crouch";
player globalchat format ["Stance: %1",_stance]
goto "checkloop"

http://www.gamefront.com/files/21612120/Stance_check_script_ww4mod2_5_examples_zip

All credit goes to Faguss. :notworthy: He did 95% of all work. I just did some editing and testing.

It is capable of detecting all three stances (standing, crouch and prone).

Works with ww4 mod v2.5 for both Arma:CWA (v1.99) and OFP (v1.96)

Requires Fwatch v1.1. You can download installer (easy way) at webiste of Faguss: http://ofp-faguss.com/files/fwatch_install.exe

Or if you are familiar with Fwatch, then follow this link

Take care, Icarus :bounce3:

Edited by Icarus
Updated Fwatch v1.1 compatibility (now Arma: CWA capable)

Share this post


Link to post
Share on other sites

I changed download links if anyone is wondering...

Icarus :j:

Share this post


Link to post
Share on other sites
So is the mem getplayeranim command only for player use?

Can it be used for bots too? :confused:


Negative and there won't be such method. I don't know how to find other units in the memory. Player is constant so his values are easily accessible.

-----------------------

(This is an old code. For something more recent go here)

Creating a hotkey is the the most common usage of Fwatch. Here are simple examples:

_pressed = ""

#Loop
~0.02
_keys = call loadfile ":input getkeys side"
_key = _keys select 0

? count _keys==0 : _pressed=""; goto "Loop"
? _key == _pressed : goto "Loop"
_pressed = _key

? _key == "K" : player globalchat "You've pressed K"
goto "Loop"

Only one pressed key is recognised. Variable _pressed prevents continous action so you won't execute code 300 times a second. Blue is the customizable part.

_pressed = ""

#Loop
~0.02
_keys = call loadfile ":input getkeys side"
? _pressed in _keys : goto "Loop"
_pressed = "null"

? "K" in _keys : player globalchat "You've pressed K"; _pressed="K"
goto "Loop"

This variation will recognise multiple strokes but you'll have to assign _pressed manually.

Code can be improved to eliminate weaknesses but I wanted to show only basic stuff. Edited by faguss
added info that it's old

Share this post


Link to post
Share on other sites

I tried to use this animation viewer, but with no luck. When I try to run it "ERROR READING FILE" and this is my firt time trying to run FWATCH, cheers

Share this post


Link to post
Share on other sites

Animation list is read from external file so make sure the directory "AnimationViewer" with all the files is in mission folder.

Script will only work from Mission Editor so copy mission to the "Users\...\missions" or "Users\...\MPmissions".

If it still doesn't work then check AV / FW whether they block Fwatch.

-----

EDIT: I forgot that there are problems in Fwatch 1.1 with reading current user from the registry. This was fixed in version 1.11 (still in the works).

Edited by Faguss

Share this post


Link to post
Share on other sites

Passing dialog position

Commands :mem getcursor and :input getkeys make it possible to create your own type of dialog controls. However, we need position of the controls for scripts. Typing it by hand is a chore so let's automate it.

We are going to use the Fwatch to save numbers from the dialog and then have a script read it.

__EXEC doesn't support brackets so __EVAL it is. The returned value must be assigned to something. Put it into any property:
 

a = __EVAL()

You can wrap it up in a class:
 

class fwatch_save
{
a = __EVAL()
};

Just in case I'm removing the file every time on the beginning:
 

a = __EVAL(loadFile format [":file delete %1", "filename"])

and then using qwrite to save coordinates:
 

b = __EVAL(loadFile Format[":file qwrite %1 %2 %3", "filename", "varnme", [X,Y,W,H]])

Here's a full example:
 

__EXEC(FCM_Background_X=0; FCM_Background_Y=0; FCM_TotalWidth=1; FCM_TotalHeight=1)

class FCM_Background : fcmTXT
{
x = __EVAL(FCM_Background_X)
y = __EVAL(FCM_Background_Y)
w = __EVAL(FCM_Background_W)
h = __EVAL(FCM_Background_H)
};

a = __EVAL(loadFile format [":file delete %1", "filename"])

fcm_save2 = __EVAL(loadFile Format[":file qwrite fcm_dialog.db back %1",[FCM_Background_X, FCM_Background_Y, FCM_TotalWidth, FCM_TotalHeight]])

With many calls to Fwatch there is a noticeable pause when you load the mission so don't go wild.

Now reading the data from a script:

_fwatch_error = [true,0,0,""]
_data = call loadFile ":file read fcm_dialog.db back"
? !(_fwatch_error select 0) : hint "ERROR:\nCannot read fcm_dialog.db back"; exit
FCM_BGX = (_data select 0)
FCM_BGY = (_data select 1)
FCM_BGW = (_data select 2)
FCM_BGH = (_data select 3)

In the Fwatch 1.13 :mem getcursor returns coordinates in the same format as in the dialogs.

Other application of this method could be to transfer data from addon configs or main configuration to scripts. Like vehicle capacity for example. Fwatch 1.13 now features commands for reading information from configs if they're unpacked.





Generating scripts

Use :igse write command to write text to a file.
 
_ok = call loadFile "\:IGSE WRITE  ""file:text.txt""  text:Hello World!"
_lines = ["this", "is", "a test"]
_file = "Numbers.txt"
_ok = call loadFile Format ["\:IGSE NEW  ""file:%1""  mode:recreate", _file]
? !(_ok select 0) : hint (_ok select 3); exit

{loadFile Format ["\:IGSE WRITE ""file:%1"" text:%2", _file, _lines select _i]} forEach _lines
Edited by faguss
updated code for 1.14

Share this post


Link to post
Share on other sites
On 4/10/2018 at 5:11 PM, prototype1479 said:

Is it possible to force AI to crouch in fwatch?

 

No

Share this post


Link to post
Share on other sites

Hey faguss, it seems that your website is down. Are there any chances for fixing this problem?

Share this post


Link to post
Share on other sites

Hosting issue. You just gotta wait.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×