void CNPC_Hydra::Stab( CBaseEntity *pOther, const Vector &vecSpeed, trace_t &tr ) { if (pOther->m_takedamage == DAMAGE_YES && !pOther->IsPlayer()) { Vector dir = vecSpeed; VectorNormalize( dir ); if ( !sv_hydraTestSpike.GetInt() ) { ClearMultiDamage(); // FIXME: this is bogus CTakeDamageInfo info( this, this, pOther->m_iHealth+25, DMG_SLASH ); CalculateMeleeDamageForce( &info, dir, tr.endpos ); pOther->DispatchTraceAttack( info, dir, &tr ); ApplyMultiDamage(); } else { CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating *>(pOther); if ( pAnimating ) { AttachStabbedEntity( pAnimating, vecSpeed * 30, tr ); } } } else { Nudge( pOther, tr.endpos, vecSpeed ); } }
void Selection_NudgeZ (float amount) { std::stringstream command; command << "nudgeSelected -axis z -amount " << amount; UndoableCommand undo(command.str()); Nudge(2, amount); }
void CNPC_Hydra::MoveBody( ) { int i; int iFirst = 2; int iLast = m_body.Count() - 1; // clear stuck flags for (i = 0; i <= iLast; i++) { m_body[i].bStuck = false; } // try to move all the nodes for (i = iFirst; i <= iLast; i++) { trace_t tr; // check direct movement AI_TraceHull(m_body[i].vecPos, m_body[i].vecPos + m_body[i].vecDelta, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr); Vector direct = tr.endpos; Vector delta = Vector( 0, 0, 0 ); Vector slide = m_body[i].vecDelta; if (tr.fraction != 1.0) { // slow down and remove all motion in the direction of the plane direct += tr.plane.normal; Vector impactSpeed = (slide * tr.plane.normal) * tr.plane.normal; slide = (slide - impactSpeed) * 0.8; if (tr.m_pEnt) { if (i == iLast) { Stab( tr.m_pEnt, impactSpeed, tr ); } else { Nudge( tr.m_pEnt, direct, impactSpeed ); } } // slow down and remove all motion in the direction of the plane slide = (slide - (slide * tr.plane.normal) * tr.plane.normal) * 0.8; // try to move the remaining distance anyways AI_TraceHull(direct, direct + slide * (1 - tr.fraction), Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr); // NDebugOverlay::Line( m_body[i].vecPos, tr.endpos, 255, 255, 0, true, 1); direct = tr.endpos; m_body[i].bStuck = true; } // make sure the new segment doesn't intersect the world AI_TraceHull(direct, m_body[i-1].vecPos, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr); if (tr.fraction == 1.0) { if (i+1 < iLast) { AI_TraceHull(direct, m_body[i+1].vecPos, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr); } if (tr.fraction == 1.0) { m_body[i].vecPos = direct; delta = slide; } else { // FIXME: compute nudge force m_body[i].bStuck = true; //m_body[i+1].bStuck = true; } } else { // FIXME: compute nudge force m_body[i].bStuck = true; //m_body[i-1].bStuck = true; } // m_body[i-1].vecDelta += (m_body[i].vecDelta - delta) * 0.25; // m_body[i+1].vecDelta += (m_body[i].vecDelta - delta) * 0.25; m_body[i].vecDelta = delta; } }