cw.animation class
Defines the cw.animation library, which assigns player models to animation classes and picks the animation for
each activity and weapon hold type.
It holds the animation tables for the Combine Overwatch, Civil Protection, male and female human and vortigaunt classes, and lets schemas assign models to a class or override single animations. It also decides which viewmodel hands a model uses.
Summary
Methods
cw.animation:AddModel.Methods
cw.animation:AddBlackModel(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:707Makes models whose path contains a string use the black skin on citizen and refugee hands.
Parameters
- model String Part of the model path, such as
'/male_01.mdl'
cw.animation:AddCivilProtectionModel(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:534Assigns a model to the Civil Protection animation class.
Parameters
- model String Model path
Returns
- String The lowercased model path
cw.animation:AddCombineHands(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:736Makes models whose path contains a string use the Combine viewmodel hands.
Parameters
- model String Part of the model path
cw.animation:AddCombineOverwatchModel(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:526Assigns a model to the Combine Overwatch animation class.
Parameters
- model String Model path
Returns
- String The lowercased model path
cw.animation:AddCSSHands(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:747Makes models whose path contains a string use the Counter-Strike: Source viewmodel hands.
Parameters
- model String Part of the model path
cw.animation:AddFemaleCivilProtectionModel(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:542Assigns a model to the female Civil Protection animation class.
Parameters
- model String Model path
Returns
- String The lowercased model path
cw.animation:AddFemaleHumanModel(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:550Assigns a model to the female human animation class.
Parameters
- model String Model path
Returns
- String The lowercased model path
cw.animation:AddHandsModel(model, hands)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:700Sets the viewmodel hands used for models whose path contains a string.
Parameters
- model String Part of the model path; case is ignored
- hands Map Hands info with
model,skinandbodykeys
See also
cw.animation:AddHEVHands(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:725Makes models whose path contains a string use the HEV suit viewmodel hands.
Parameters
- model String Part of the model path
cw.animation:AddMaleHumanModel(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:558Assigns a model to the male human animation class.
Parameters
- model String Model path
Returns
- String The lowercased model path
cw.animation:AddModel(class, model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:427Assigns a model to an animation class.
Parameters
- class String Animation class, a key of
cw.animation.storedsuch as'maleHuman'or'civilProtection' - model String Model path; case is ignored
Returns
- String The lowercased model path
cw.animation:AddOverride(model, key, value)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:440Overrides a model's animations for one hold type.
Overrides are checked by cw.animation:GetForModel before the model's animation class.
Parameters
- model String Model path; case is ignored
- key String Hold type to override, such as
'pistol' - value Map Animations keyed by activity (
ACT_MP_*) or by'attack'/'reload'
cw.animation:AddRefugeeHands(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:758Makes models whose path contains a string use the refugee viewmodel hands.
Parameters
- model String Part of the model path, such as
'/group03/'
cw.animation:AddVortigauntModel(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:518Assigns a model to the vortigaunt animation class.
Parameters
- model String Model path
Returns
- String The lowercased model path
cw.animation:AddZombieHands(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:714Makes models whose path contains a string use the citizen hands with the zombie skin.
Parameters
- model String Part of the model path
cw.animation:AddZombieRefugeeHands(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:769Makes models whose path contains a string use the refugee hands with the zombie skin.
Parameters
- model String Part of the model path
cw.animation:AdjustHandsInfo(model, info)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:820Adjusts hands info for a model in place.
Citizen and refugee hands get the black skin for models added with
cw.animation:AddBlackModel. Then runs the AdjustCModelHandsInfo hook (via hook.Run) with
the model and the info.
Parameters
- model String Lowercased model path
- info Map Hands info with
model,skinandbodykeys; changed in place
cw.animation:CheckHands(model, animTable)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:785Returns the viewmodel hands info for a model.
Starts from the citizen hands, then the animation table's hands, then the first matching
entry added with cw.animation:AddHandsModel, and applies cw.animation:AdjustHandsInfo.
Parameters
- model String Lowercased model path
- animTable Map optional, defaults to
nilThe model's animation table
Returns
- Map Hands info with
model,skinandbodykeys
cw.animation:GetForModel(model, holdType, key, bNoFallbacks)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:466Returns the animation a model uses for an activity and hold type.
Unknown hold types fall back to normal and unknown activities to ACT_MP_STAND_IDLE, unless
bNoFallbacks is set. Overrides from cw.animation:AddOverride take precedence. Returns nothing
for models without an animation table, and prints a stack trace when model is nil.
local attackAnimation = cw.animation:GetForModel(model, weaponHoldType, 'attack', true)
Parameters
- model String Model path
- holdType String Hold type, such as
'normal'or'smg' - key Any Activity (
ACT_MP_*), or'attack','reload'or'glide' - bNoFallbacks Boolean optional, defaults to
nilReturnnilinstead of falling back
Returns
- Any The animation: an activity Number, a sequence String, or a List of two of these for the lowered and raised states
cw.animation:GetHandsInfo(model)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:840Returns the viewmodel hands a model should use.
Parameters
- model String Model path
Returns
- Map Hands info with
model,skinandbodykeys
cw.animation:GetMenuSequence(model, bRandom)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:405Returns the sequence a model plays in the character menu.
Parameters
- model String Model path; case is ignored
- bRandom Boolean optional, defaults to
nilPick one sequence at random when a list is stored
Returns
- Any The sequence name, the stored List when
bRandomis not set, ornilif none is set
See also
cw.animation:GetModelClass(model, alwaysReal)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:502Returns the animation class a model was assigned with cw.animation:AddModel.
Parameters
- model String Model path; case is ignored
- alwaysReal Boolean optional, defaults to
nilReturnnilinstead of'maleHuman'for unassigned models
Returns
- String The animation class
Returns the animation table for a model.
Models without an assigned class use the female human table when their path contains female
and the male human table otherwise.
Parameters
- model String Model path
Returns
- Map Animations keyed by hold type, or
nilfor models in a/player/folder
cw.animation:GetWeaponHoldType(player, weapon)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:637Returns the hold type used to animate a weapon.
Known weapon classes have a fixed hold type. Otherwise the weapon's HoldType is used,
mapped to one of the hold types Catwork animates (for example ar2 becomes smg).
Parameters
- player Player The player holding the weapon, unused
- weapon Weapon The weapon
Returns
- String The lowercased hold type;
'normal'when the weapon has none
cw.animation:SetMenuSequence(model, sequence)
shared gamemodes/catwork/gamemode/core/libraries/sh_animation.lua:394Sets the sequence a model plays in the character menu.
Parameters
- model String Model path; case is ignored
- sequence Any Sequence name, or a List of sequence names to pick from at random