Flux.Anim class
Part of Flow
Animations for player models that are not built on the player animation set of Garry's Mod,
such as the NPC models that roleplay schemas use for their characters. Every such model is
assigned a model class with Flux.Anim:set_model_class, and every class has an animation
table, registered with Flux.Anim:register, that maps movement states and weapon hold types
to the activities or sequences of that kind of model. 'player' (the male citizen animations)
and 'female' (the female citizen ones, which lack a few of the male activities) are the
built-in classes. A model without a class uses 'female' if its path contains 'female' and
'player' otherwise. The tables are compiled on first use into a flat form,
returned by Flux.Anim:get_table, from which the animation hooks of Flux pick the idle,
walk, run, crouch, jump, attack and reload animations of a player, depending on the weapon
they hold (Flux.Anim.get_weapon_hold_type) and on whether it is raised. Models from a
'player' folder keep the regular animations of Garry's Mod.
The library also adds the Player methods for one-off animations: Player:set_animation
makes a player play a sequence instead of their regular animations, and
Player:play_gesture plays a gesture on top of them. An animation that the server sets
is shown by every client, including the clients of players who join while it lasts; one
that a client sets is only seen on that client. Either kind is removed when the player
dies, spawns or gets another model, since the sequence belongs to the model and the pose
of the player they had before.
Summary
Functions
Methods
Functions
Returns the hold type of a weapon translated to one of the hold types used by the animation tables. The result is cached on the weapon until its HoldType changes.
Parameters
- _owner Player the player who holds the weapon, unused
- weapon Weapon
Returns
- String lower case hold type, 'normal' if the weapon is not valid
Methods
Returns all of the animation tables, as they were registered.
Returns
- Map animation tables by model class
Compiles the registered animation table of a class into the flat form used by the animation hooks: every hold type gets a complete table with the inherited entries filled in, the settings get their defaults and the vehicle entries are copied.
Parameters
- class String model class
Returns
- Map compiled animation table, nil if the class is not registered
Returns the animation class of a model. A model that none was set for gets the 'female' class if its path contains 'female' and the 'player' class otherwise.
Parameters
- model String path to the model
Returns
- String model class
Returns the compiled animation table of a model. Models from a 'player' folder do not get one, as they use the default player animations.
Parameters
- model String path to the model
Returns
- Map compiled animation table, or nil if the model does not need one
Drops all compiled animation tables so that they are rebuilt from the registered tables the next time they are needed.
Registers the animation table of a model class and drops anything compiled from the previous table of that class.
The table holds one sub-table per weapon hold type ('normal', 'pistol', 'smg', 'shotgun', 'ar2', 'rpg', 'grenade', 'melee' or any custom hold type) and an optional 'vehicle' table mapping vehicle classes to { animation, bone offset } pairs. Hold types inherit every entry they do not define from a parent hold type (ar2 and shotgun from smg, rpg from shotgun, everything else from normal), so a class only has to list what differs. Values placed directly in the class table (such as jump = ACT_JUMP) act as defaults for the normal hold type, except for the settings run_speed (units per second above which the run animation plays) and fidget_interval ({ min, max } seconds between idle fidgets).
Entries are activities (ACT_ enums) or sequence names. The movement keys ACT_MP_STAND_IDLE, ACT_MP_CROUCH_IDLE, ACT_MP_WALK, ACT_MP_CROUCHWALK and ACT_MP_RUN take a { lowered, raised } pair or a single value used for both weapon states. The other keys are: glide (airborne), jump (rising during a jump, glide if nil), swim, noclip (both glide if nil), land (gesture on landing, false disables it), attack, attack_low (crouched), attack_secondary, reload, reload_low (crouched), raise and lower (gestures played when the weapon is raised or lowered) and fidgets (a list of gestures played at random while standing still).
Parameters
- class String model class
- data Map animation table
Returns
- Map the registered table
Sets which animation table a model uses. Falls back to the 'player' class if the specified class does not exist.
Parameters
- model String path to the model
- class String model class, a key of the table returned by Flux.Anim#all