void CNPC_Ichthyosaur::DragVictim( float moveDist ) { Vector mins, maxs; float width; mins = WorldAlignMins(); maxs = WorldAlignMaxs(); width = ( maxs.y - mins.y ) * 0.5f; Vector forward, up; GetVectors( &forward, NULL, &up ); Vector newPos = GetAbsOrigin() + ( (forward+(up*0.25f)) * ( moveDist + width + DRAG_OFFSET ) ); trace_t tr; AI_TraceEntity( this, m_pVictim->GetAbsOrigin(), newPos, MASK_NPCSOLID, &tr ); if ( ( tr.fraction == 1.0f ) && ( tr.m_pEnt != this ) ) { UTIL_SetOrigin( m_pVictim, tr.endpos ); } else { ReleaseVictim(); } }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ Vector CAI_BaseFlyingBot::VelocityToAvoidObstacles(float flInterval) { // -------------------------------- // Avoid banging into stuff // -------------------------------- trace_t tr; Vector vTravelDir = m_vCurrentVelocity*flInterval; Vector endPos = GetAbsOrigin() + vTravelDir; AI_TraceEntity( this, GetAbsOrigin(), endPos, GetAITraceMask()|CONTENTS_WATER, &tr ); if (tr.fraction != 1.0) { // Bounce off in normal Vector vBounce = tr.plane.normal * 0.5 * m_vCurrentVelocity.Length(); return (vBounce); } // -------------------------------- // Try to remain above the ground. // -------------------------------- float flMinGroundDist = MinGroundDist(); AI_TraceLine(GetAbsOrigin(), GetAbsOrigin() + Vector(0, 0, -flMinGroundDist), GetAITraceMask_BrushOnly()|CONTENTS_WATER, this, COLLISION_GROUP_NONE, &tr); if (tr.fraction < 1) { // Clamp veloctiy if (tr.fraction < 0.1) { tr.fraction = 0.1; } return Vector(0, 0, 50/tr.fraction); } return vec3_origin; }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ float CNPC_CombineDropship::GetAltitude( void ) { trace_t tr; Vector vecBottom = GetAbsOrigin(); // Uneven terrain causes us problems, so trace our box down AI_TraceEntity( this, vecBottom, vecBottom - Vector(0,0,4096), MASK_SHOT, &tr ); float flAltitude = ( 4096 * tr.fraction ); //Msg(" Altitude: %.3f\n", flAltitude ); return flAltitude; }
//------------------------------------------------------------------------------ // Purpose : Is cover node valid // Input : // Output : //------------------------------------------------------------------------------ bool CAI_BaseNPC::IsValidCover( const Vector &vecCoverLocation, CAI_Hint const *pHint ) { // firstly, limit choices to hint groups string_t iszHint = GetHintGroup(); char *pszHint = (char *)STRING(iszHint); if ((iszHint != NULL_STRING) && (pszHint[0] != '\0')) { if (!pHint || pHint->GetGroup() != GetHintGroup()) { return false; } } /* // If I'm in a squad don't pick cover node it other squad member // is already nearby if (m_pSquad) { return m_pSquad->IsValidCover( vecCoverLocation, pHint ); } */ // UNDONE: Do we really need this test? // ---------------------------------------------------------------- // Make sure my hull can fit at this node before accepting it. // Could be another NPC there or it could be blocked // ---------------------------------------------------------------- // FIXME: shouldn't this see that if I crouch behind it it'll be safe? Vector startPos = vecCoverLocation; startPos.z -= GetHullMins().z; // Move hull bottom up to node Vector endPos = startPos; endPos.z += 0.01; trace_t tr; AI_TraceEntity( this, vecCoverLocation, endPos, MASK_NPCSOLID, &tr ); if (tr.startsolid) { return false; } return true; }