//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_Ichthyosaur::EnsnareVictim( CBaseEntity *pVictim ) { CBaseCombatCharacter* pBCC = (CBaseCombatCharacter *) pVictim; if ( pBCC && pBCC->DispatchInteraction( g_interactionBarnacleVictimGrab, NULL, this ) ) { if ( pVictim->IsPlayer() ) { CBasePlayer *pPlayer = dynamic_cast< CBasePlayer * >((CBaseEntity *) pVictim); if ( pPlayer ) { m_flHoldTime = MAX( gpGlobals->curtime+3.0f, pPlayer->PlayerDrownTime() - 2.0f ); } } else { m_flHoldTime = gpGlobals->curtime + 4.0f; } m_pVictim = pVictim; m_pVictim->AddSolidFlags( FSOLID_NOT_SOLID ); SetSchedule( SCHED_ICH_DROWN_VICTIM ); } }
//----------------------------------------------------------------------------- // Purpose: Input handler that converts our target to a physics object. //----------------------------------------------------------------------------- void CPhysConvert::InputConvertTarget( inputdata_t &inputdata ) { bool createAsleep = HasSpawnFlags(SF_CONVERT_ASLEEP); // Fire output m_OnConvert.FireOutput( inputdata.pActivator, this ); CBaseEntity *entlist[512]; CBaseEntity *pSwap = gEntList.FindEntityByName( NULL, m_swapModel, inputdata.pActivator ); CBaseEntity *pEntity = NULL; int count = 0; while ( (pEntity = gEntList.FindEntityByName( pEntity, m_target, inputdata.pActivator )) != NULL ) { entlist[count++] = pEntity; if ( count >= ARRAYSIZE(entlist) ) break; } // if we're swapping to model out, don't loop over more than one object // multiple objects with the same brush model will render, but the dynamic lights // and decals will be shared between the two instances... if ( pSwap && count > 0 ) { count = 1; } for ( int i = 0; i < count; i++ ) { pEntity = entlist[i]; // don't convert something that is already physics based if ( pEntity->GetMoveType() == MOVETYPE_VPHYSICS ) { Msg( "ERROR phys_convert %s ! Already MOVETYPE_VPHYSICS\n", STRING(pEntity->m_iClassname) ); continue; } UnlinkFromParent( pEntity ); if ( pSwap ) { // we can't reuse this physics object, so kill it pEntity->VPhysicsDestroyObject(); pEntity->SetModel( STRING(pSwap->GetModelName()) ); } CBaseEntity *pPhys = CreateSimplePhysicsObject( pEntity, createAsleep ); // created phys object, now move hierarchy over if ( pPhys ) { pPhys->SetName( pEntity->GetEntityName() ); TransferChildren( pEntity, pPhys ); pEntity->AddSolidFlags( FSOLID_NOT_SOLID ); pEntity->m_fEffects |= EF_NODRAW; UTIL_Relink( pEntity ); UTIL_Remove( pEntity ); } } }