Gamemode.CalcMainActivity

From GMod Wiki

Revision as of 14:22, 7 November 2010 by Cube334 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameCalcMainActivity
SyntaxGM:CalcMainActivity( Player ply, Vector velocity )
DescriptionAnimation
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.CalcMainActivity]Gamemode.CalcMainActivity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Examples

DescriptionCalculates the main activity animation
Used onNewerShared.png
Code
 
function GM:CalcMainActivity( ply, velocity )    
    ply.CalcIdeal = ACT_MP_STAND_IDLE
    ply.CalcSeqOverride = -1
 
    if self:HandlePlayerDriving( ply ) ||
        self:HandlePlayerJumping( ply, velocity ) ||
        self:HandlePlayerDucking( ply, velocity ) ||
        self:HandlePlayerSwimming( ply ) then
 
    else
        local len2d = velocity:Length2D()
 
        if len2d > 210 then
            ply.CalcIdeal = ACT_MP_RUN
        elseif len2d > 0.5 then
            ply.CalcIdeal = ACT_MP_WALK
        end
    end
 
    // a bit of a hack because we're missing ACTs for a couple holdtypes
    local weapon = ply:GetActiveWeapon()
 
    if ply.CalcIdeal == ACT_MP_CROUCH_IDLE &&
        IsValid(weapon) &&
        ( weapon:GetHoldType() == "knife" || weapon:GetHoldType() == "melee2" ) then
 
        ply.CalcSeqOverride = ply:LookupSequence("cidle_" .. weapon:GetHoldType())
    end
 
    return ply.CalcIdeal, ply.CalcSeqOverride
end
 
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox