Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hook.Add("UpdateAnimation","sg", function( ply, velocity, maxseqgroundspeed )
- local eye = ply:EyeAngles()
- // correct player angles
- ply:SetLocalAngles( eye )
- if CLIENT then
- // set rendering angles for zombie
- ply:SetRenderAngles( eye )
- end
- local estyaw = math.Clamp( math.atan2(velocity.y, velocity.x) * 180 / math.pi, -180, 180 )
- local myaw = math.NormalizeAngle(math.NormalizeAngle(eye.y) - estyaw)
- // set the move_yaw (because it's not an hl2mp model)
- //ply:SetPoseParameter("move_yaw", -myaw)
- local len2d = velocity:Length2D()
- local rate = 1.0
- if len2d > 0.5 then
- rate = ( ( len2d * 0.8 ) / maxseqgroundspeed )
- end
- rate = math.Clamp(rate, 0, 1.5)
- // you can obviously set your own playback rate
- ply:SetPlaybackRate( rate )
- end)
- hook.Add("CalcMainActivity","sg", function( ply, velocity )
- ply.CalcIdeal = ACT_MP_STAND_IDLE
- ply.CalcSeqOverride = -1
- // if self:HandlePlayerDriving( ply ) ||
- // self:HandlePlayerJumping( ply ) ||
- // 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._InternalHoldType == "knife" || weapon._InternalHoldType == "melee2" ) then
- ply.CalcSeqOverride = ply:LookupSequence("cidle_" .. weapon._InternalHoldType)
- end
- if( ply.m_iPunchAttack and CurTime() < ply.m_iPunchAttack ) then
- return ply.CalcIdeal, ply:LookupSequence( "sit" )
- end
- return ply.CalcIdeal, ply.CalcSeqOverride
- end)
- hook.Add("DoAnimationEvent","sg", function( ply, event, data )
- if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
- ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MELEE_ATTACK_SWING_GESTURE )
- return ACT_VM_PRIMARYATTACK
- elseif event == PLAYERANIMEVENT_JUMP then
- ply.m_bJumping = true
- ply.m_bFirstJumpFrame = true
- ply.m_flJumpStartTime = CurTime()
- ply:AnimRestartMainSequence()
- return ACT_INVALID
- end
- return nil
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement