MCPcopy Create free account
hub / github.com/JACoders/OpenJK / AnimateVehicle

Function AnimateVehicle

code/game/FighterNPC.cpp:1570–1671  ·  view source on GitHub ↗

This function makes sure that the vehicle is properly animated.

Source from the content-addressed store, hash-verified

1568
1569// This function makes sure that the vehicle is properly animated.
1570static void AnimateVehicle( Vehicle_t *pVeh )
1571{
1572 int Anim = -1;
1573 int iFlags = SETANIM_FLAG_NORMAL, iBlend = 300;
1574 qboolean isLanding = qfalse, isLanded = qfalse;
1575#ifdef _JK2MP
1576 playerState_t *parentPS = pVeh->m_pParentEntity->playerState;
1577#else
1578 playerState_t *parentPS = &pVeh->m_pParentEntity->client->ps;
1579#endif
1580#ifndef _JK2MP//SP
1581 //nothing
1582#elif defined QAGAME//MP GAME
1583 int curTime = level.time;
1584#elif defined CGAME//MP CGAME
1585 //FIXME: pass in ucmd? Not sure if this is reliable...
1586 int curTime = pm->cmd.serverTime;
1587#endif
1588
1589#ifdef _JK2MP
1590 if ( parentPS->hyperSpaceTime
1591 && curTime - parentPS->hyperSpaceTime < HYPERSPACE_TIME )
1592 {//Going to Hyperspace
1593 //close the wings (FIXME: makes sense on X-Wing, not Shuttle?)
1594 if ( pVeh->m_ulFlags & VEH_WINGSOPEN )
1595 {
1596 pVeh->m_ulFlags &= ~VEH_WINGSOPEN;
1597 Anim = BOTH_WINGS_CLOSE;
1598 }
1599 }
1600 else
1601#endif
1602 {
1603 isLanding = FighterIsLanding( pVeh, parentPS );
1604 isLanded = FighterIsLanded( pVeh, parentPS );
1605
1606 // if we're above launch height (way up in the air)...
1607 if ( !isLanding && !isLanded )
1608 {
1609 if ( !( pVeh->m_ulFlags & VEH_WINGSOPEN ) )
1610 {
1611 pVeh->m_ulFlags |= VEH_WINGSOPEN;
1612 pVeh->m_ulFlags &= ~VEH_GEARSOPEN;
1613 Anim = BOTH_WINGS_OPEN;
1614 }
1615 }
1616 // otherwise we're below launch height and still taking off.
1617 else
1618 {
1619 if ( (pVeh->m_ucmd.forwardmove < 0 || pVeh->m_ucmd.upmove < 0||isLanded)
1620 && pVeh->m_LandTrace.fraction <= 0.4f
1621 && pVeh->m_LandTrace.plane.normal[2] >= MIN_LANDING_SLOPE )
1622 {//already landed or trying to land and close to ground
1623 // Open gears.
1624 if ( !( pVeh->m_ulFlags & VEH_GEARSOPEN ) )
1625 {
1626#ifdef _JK2MP
1627 if ( pVeh->m_pVehicleInfo->soundLand )

Callers

nothing calls this directly

Calls 5

G_EntitySoundFunction · 0.85
BG_SetAnimFunction · 0.85
FighterIsLandingFunction · 0.70
FighterIsLandedFunction · 0.70
NPC_SetAnimFunction · 0.70

Tested by

no test coverage detected