Comrades in Arms Discussion Board

Full Version: [DONE] Animation Set Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

This function is still in a sort of beta phase, so if you want to participate, provide feedback and/or hints, I will welcome your help and will credit you once the function completed and published.

Function header:
Quote: Author: HKFlash

Description:
Plays a set of animations on the desired unit while allowing it to leave such state when the user desires.

Overview:
* Can handle several different animations and automatically switches between them.
* Allows for several equipment levels, including automatic randomization if multiple units near each other have the same gear.
* Detects nearby units with the same animation set and tries to select different animations.
* Prevents units performing the animation set from being pushed around by the player(s).
* The unit can be attached to a custom or nearest snap point to prevent the game from repositioning it.

Parameter(s):
0: OBJECT
Unit the animation set and gear changes are going to be applied to.
1: STRING
(optional, default "STAND_A1")
Animation set identification, describing the unit's action.
>> STANDING...
...slightly turning to the sides, armed with primary weapon.
> "STAND_A1"
> "STAND_A2"
...slightly turning to the sides, unarmed.
> "STAND_T_U1"
> "STAND_T_U2"
> "STAND_T_U3"
...idle and unarmed.
> "STAND_U1"
> "STAND_U2"
> "STAND_U3"

...and turning around, armed with primary weapon.
> "WATCH_A1"
> "WATCH_A2"
...as if on guard with hands behind the back, unarmed.
> "GUARD_U"
>> LEANING...
...while leaning on a table, unarmed.
> "LEAN_TABLE_U"
...while leaning against a wall, armed with primary weapon.
> "LEAN_WALL_A"
>> BRIEFING...
...standing, playing ambient briefing loop with occasional random moves, unarmed.
> "BRIEFING_U"
...with extra pointing animation, pointing left and high, unarmed.
> "BRIEFING_POINT_LEFT_U"
...with extra pointing animation, pointing right and high, unarmed.
> "BRIEFING_POINT_RIGHT_U"
...with extra pointing animation, pointing front and low, such as at a table, unarmed.
> "BRIEFING_POINT_TABLE_U"
...standing, hands behind the back, receiving briefing / commands, unarmed.
> "LISTEN_BRIEFING_U"
>> SITTING...
...on a table, hands on table, unarmed.
> "SIT_TABLE_U"
...on tall objects like a table or wall, feet not touching the ground armed with primary weapon.
> "SIT_HIGH_A1"
> "SIT_HIGH_A2"
...on a chair or bench, armed with primary weapon.
> "SIT_CHAIR_A1"
> "SIT_CHAIR_A2"
> "SIT_CHAIR_A3"
...on a chair or bench, unarmed.
> "SIT_CHAIR_U1"
> "SIT_CHAIR_U2"
> "SIT_CHAIR_U3"
...on the ground, armed with primary weapon.
> "SIT_GROUND_A"
...on the ground, unarmed.
> "SIT_GROUND_U"
...on a chair, sad/nervous looking, armed with primary weapon.
> "SIT_SAD_A1"
> "SIT_SAD_A2"
>> KNEELING...
...with primary weapon.
> "KNEEL_A"
...and treating injuries of wounded on the ground, armed with primary weapon.
> "KNEEL_TREATING_A"
>> INJURED...
...laying on the ground, unarmed.
> "PRONE_INJURED_U1"
> "PRONE_INJURED_U2"
...laying on the ground, with primary weapon or unarmed.
> "PRONE_INJURED_AU"
>> REPAIRING...
...vehicle while laying on the ground (under the vehicle), unarmed.
> "REPAIR_V_PRONE_U"
...vehicle while kneeling (like changing a wheel), unarmed.
> "REPAIR_V_KNEEL_U"
...and cleaning a vehicle while standing, unarmed.
> "REPAIR_V_STAND_U"
>> SHOOTING RANGE...
...prone, performing occasional weapon checks.
> "RANGE_P_A"

2: STRING
(optional, default "RANDOM")
Equipment level identification, describing how is the unit equipped.
3: OBJECT
(optional)
Object defined as the unit's snap-point (function won't select the closest snap-point, instead it will use the defined object).
4: BOOL
(optional, default {false})
Function will try to interpolate into the ambient animation, if the interpolateTo link exists (limited to certain animation sets).
5: CODE or STRING
(optional, default {false})
Condition that when true, releases the unit from the animation set.
6: STRING
(optional, default "SAFE")
Behaviour the unit will adopt, when released.

Returns:
-

Example:
[this,"GUARD_U","FULL",Nil,Nil,{(player distance _this) < 5}] call HK_fnc_animationSet;

So why help with this function? There's several reasons:
  • Allows for quick bugs fixes, unlike the official functions that take weeks and sometimes months to fix.
  • Allows for the quick creation of custom animation sets.
  • It's a great way to learn scripting.
  • Allows an animation set to be interrupted while at the same time providing numerous animation sets.

Red animation strings are user created.

Regards,
Flash
I've finished the function. It will still require alot of work to show its full potential but its still a great achievement for me personally since I always wanted to learn how to create one.

DOWNLOAD

The function works just like a script, i.e. you just insert the file into the mission folder but it must be defined in the description.ext of the mission. Insert the following in it:

Code:
class CfgFunctions
{
    class HK
    {
        class animations
        {
            class animationSet {file = "fn_animationSet.sqf";};
        };
    };
};

Insert the following code into an unit initialization field to fire animation (refer to the header in the first post for more information on how to use the function):

Code:
[this,"LEAN_WALL_A","FULL",Nil,Nil,{(player distance _this) < 5}] call HK_fnc_animationSet;

Notice how the character leaves the animation state once you are less than 5 meters from him.

Regards,
Flash
Hello again,

I've created my first custom animation set. It is named "RANGE_P_A":

[Image: animation.jpg]

Here's the code I inserted into the function:

Code:
    case "RANGE_P_A":
    {
        _anims =
        [
            "HubShootingRangeProne_move1",
            "HubShootingRangeProne_move2",
            "HubShootingRangeProne_move3"
        ];
    };

As you can see, its very easy to create your own custom animations sets. But enough for now, next time I'll post a tutorial on how to create these.

Regards,
Flash
Thanks for sharing, this looks very useful indeed !
Hello again,

Today it's time to learn how to create your own custom animation set, so let's delve right into it.

1) Preparing:
In the Editor place two units, one as the player and the other to test your animations and save the mission. Download my function, insert it into the mission folder, keep it open and then create a description.ext file and insert the following code:
Code:
class CfgFunctions
{
    class HK
    {
        class animations
        {
            class animationSet {file = "fn_animationSet.sqf";};
        };
    };
};

2) Animations viewer:
Preview the mission. Once in game, press Esc and select the Animations button as seen in the image below.
[Image: 2013_11_01_00005.jpg]

3) Select animations:
You are now inside the animations viewer. On the top left you can see a Graphical User Interface with six drop down menus. The first will select the unit in which you wish to preview the animations while the others will let you browse all the animations currently in game. Navigate and choose one or multiple animations. You can copy each animation classname with Ctrl + C.
[Image: 2013_11_01_00006.jpg]
4) Insert animations:
You can now start inserting the animations into the function. Because of the large amount of code, an advanced text editor is recommend such as NotePad++.

a) Function header:
Before creating the animation set itself, you should choose a name for it and add it to the list in the header with a short description of it.

Example:
Code:
        >> SHOOTING RANGE...
            ...prone, performing occasional weapon checks.
            > "RANGE_P_A"

Remember RANGE_P_A is the classname I gave the set but you can name it whatever you want.

b) Debugger:
Add your animation set name to the list of acceptable sets, skipping this step will prevent you from using what you are creating. Search for "Error Messages" to find the list.

c) Create set:

Insert your animations into a custom set. Search for "Animations Sets" to find the beginning of the list. Description is optional but recommended.

Example:
Code:
    //...prone, awaiting order to fire at targets.
case "RANGE_P_A":
{
    _anims =
    [
            "HubShootingRangeProne_move1",
            "HubShootingRangeProne_move2",
            "HubShootingRangeProne_move3"
    ];
    _noWeapon = false;
    _noBackpack = false;
};

If you want your animation set to be incompatible with primary weapons or backpacks change the corresponding field from false to true.

d)Save
Yup... I mentioned it.

5)Test the animation set:
Insert the following code into a unit init field...
Code:
[this,"MY_ANIMATION_SET"] call HK_fnc_animationSet;

Regards,
Flash