Page 1 of 2 12 LastLast
Results 1 to 10 of 15

  Click here to go to the first Developer post in this thread.  

Thread: Polling a unit's stance

  1. #1

    Polling a unit's stance

    I'm looking for a command that returns a unit's stance/posture. unitPos comes close, but according to biki: "the return value is always "Auto" unless the unit has gotten a setUnitPos command." Since I want to poll a player's stance, this isn't going to help me, I don't think.

    The idea is to script some pressure-activated IEDs that blow if a unit is moving in anything besides a crawl.

    Thanks!

  2. #2
    I needed to be able to do this some time ago. Came across this thread:
    http://forums.bistudio.com/showthread.php?t=81801
    where Big Dawg KS explains how to figure it out. From that I produced the following function:

    Code:
    /*
    UP DOWN OR MIDDLE, defaults to UP
    */
    getStance = {  
        private ["_result","_unit","_animState","_animStateChars","_animP"];
        _unit = _this;
        _animState = animationState _unit;
        _animStateChars = toArray _animState;
        _animP = toUpper (toString [_animStateChars select 5,_animStateChars select 6,_aniMStateChars select 7]);
        _result = "UP";
        switch (_animP) do {
            case "ERC": {_result = "UP"};
            case "KNL": {_result = "MIDDLE"};
            case "PNE": {_result = "DOWN"};
            default {_result = "UP"};
        };
        _result
    };
    You may want to change the default or do something else instead. I just needed a stance for a less...... volatile setting

  3. #3
    Can anyone get this to work, I suck at getting functions to work so I can't tell if it's me or the script not working.

  4. #4
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    Since it returns a result, use call.

    Code:
    _return = _unit1 call getStance;
    hint format ["unit1 stance is %1",_return];
    you will get(_return) either UP, MIDDLE OR DOWN

    EDIT: there is also the boundingbox command that can be used, but i remember a long time ago that there was some talk about issues getting lying down units with that.
    NOTE: a long time ago.
    Last edited by Demonized; Jul 20 2011 at 00:14.
    My scripts:
    Spoiler:

    what to do when posting any kind of code dammit!!

    Any new mission editor or scripter in Arma2 should have read Mr Murrays Editing Guide Deluxe at least once, it still applies for A2 even though it was made for Armed Assault.

  5. #5
    Since there is a high quality anim mod around and some prone animations don't have "pne" in their name anyway, I find that the most reliable way is:
    (_unit selectionPosition "launcher" select 2)<1.2 == unit is prone

  6. #6
    Cheers, I have used the bounding box before but thought this would be more use since it gives you the middle position.

    I tried using call and just get a generic error _return #= _unit1 call getStance;

    I'll take a look at that one Celery.


    Someone else on another forum was asking about it and I remembered I needed it for something as well. I just can't get functions to work, well some do but most don't as people never include their correct usage.


    I got the call working now, it seems that I didn't need the compile stuff in the init.
    Last edited by F2k Sel; Jul 20 2011 at 02:28.

  7. #7
    Sergeant Major ])rStrangelove's Avatar
    Join Date
    Jan 24 2002
    Location
    Rainy, foggy, begins with G
    Posts
    1,760
    Quote Originally Posted by Celery View Post
    Since there is a high quality anim mod around and some prone animations don't have "pne" in their name anyway, I find that the most reliable way is:
    (_unit selectionPosition "launcher" select 2)<1.2 == unit is prone
    Wow, thats a quality tip. Thx

    Spoiler:

  8. #8
    Having fiddled with animation name strings, unitPos, boundingBox and selectionPosition, I'm using this;

    Code:
    (_unit selectionPosition "Neck" select 2)
    It returns the altitude of the players neck. When prone it's 0.3, kneeling it's 1.0 and standing it's 1.5.

    The problem with launcher as Celery suggests in #5 is that it's a proxy, so cant be relied on. Also, it changes depending on other things, if the unit is holding a weapon or not, for example. Head is also a proxy so shouldn't be used. Neck, on the other hand, is a selection within the unit model.

    I've tried it with BAF, OPFOR TK and USMC units, it will work with all units that have the "Neck" named selection.

    Thanks to Celery for help here and F2k Sel and Soul_Assassin over on Armastack
    Last edited by Tankbuster; Jul 25 2011 at 06:48.
    Documentation is not a dirty word.
    : TeamSPAFF : PRACS : RKSL : Stella Artois : Creme Eggs : GITS :

  9. #9
    Cool find with the neck, personally I just looked at the "Man" class config and looked for a reasonably stable and unmoving selection, launcher being the only one I found.

  10. #10
    I can't take the credit, Soul_Assassin knows much more about models than me and he suggested using "Neck" after I found launcher gave odd results. Interestingly, I found using "head" as the selection name was really wacky. It consistently reported an altitude 2 metres higher than expected.

    Just one little proviso though. When the player does that prone sideways roll, the neck momentarily goes as low as 0.1.
    Last edited by Tankbuster; Jul 25 2011 at 06:46.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •