float GetNodeYaw( void )
	{
		CBaseEntity *pTarget = GetTarget();

		if ( pTarget )
		{
			if ( pTarget->GetAbsAngles().y != 0 )
				 return pTarget->GetAbsAngles().y;
		}
		
		return GetAbsAngles().y;
	}
Exemplo n.º 2
0
void CHLTVDirector::StartFixedCameraShot(int iCamera, int iTarget)
{
	CBaseEntity *pCamera = m_pFixedCameras[iCamera];
	

	Vector vCamPos = pCamera->GetAbsOrigin();
	QAngle aViewAngle = pCamera->GetAbsAngles();

	m_iPVSEntity = 0;	// don't use camera entity, since it may not been transmitted
	m_vPVSOrigin = vCamPos;

	IGameEvent *shot = gameeventmanager->CreateEvent( "hltv_fixed", true );

	if ( shot )
	{
		shot->SetInt("posx", static_cast<int>(vCamPos.x) );
		shot->SetInt("posy", static_cast<int>(vCamPos.y) );
		shot->SetInt("posz", static_cast<int>(vCamPos.z) );
		shot->SetInt("theta", static_cast<int>(aViewAngle.x) );
		shot->SetInt("phi", static_cast<int>(aViewAngle.y) );
		shot->SetInt("target", iTarget );
		shot->SetFloat("fov", RandomFloat(50,110) );
	
		// send spectators the HLTV director command as a game event
		m_pHLTVServer->BroadcastEvent( shot );
		gameeventmanager->FreeEvent( shot );
	}
}
Exemplo n.º 3
0
void TransferChildren( CBaseEntity *pOldParent, CBaseEntity *pNewParent )
{
	CBaseEntity *pChild = pOldParent->FirstMoveChild();
	while ( pChild )
	{
		// NOTE: Have to do this before the unlink to ensure local coords are valid
		Vector vecAbsOrigin = pChild->GetAbsOrigin();
		QAngle angAbsRotation = pChild->GetAbsAngles();
		Vector vecAbsVelocity = pChild->GetAbsVelocity();
//		QAngle vecAbsAngVelocity = pChild->GetAbsAngularVelocity();

		UnlinkChild( pOldParent, pChild );
		LinkChild( pNewParent, pChild );

		// FIXME: This is a hack to guarantee update of the local origin, angles, etc.
		pChild->m_vecAbsOrigin.Init( FLT_MAX, FLT_MAX, FLT_MAX );
		pChild->m_angAbsRotation.Init( FLT_MAX, FLT_MAX, FLT_MAX );
		pChild->m_vecAbsVelocity.Init( FLT_MAX, FLT_MAX, FLT_MAX );

		pChild->SetAbsOrigin(vecAbsOrigin);
		pChild->SetAbsAngles(angAbsRotation);
		pChild->SetAbsVelocity(vecAbsVelocity);
//		pChild->SetAbsAngularVelocity(vecAbsAngVelocity);

		pChild  = pOldParent->FirstMoveChild();
	}
}
Exemplo n.º 4
0
void COsprey::UpdateGoal( )
{
	if (m_pGoalEnt)
	{
		m_pos1 = m_pos2;
		m_ang1 = m_ang2;
		m_vel1 = m_vel2;
		m_pos2 = m_pGoalEnt->GetAbsOrigin();
		m_ang2 = m_pGoalEnt->GetAbsAngles();
		UTIL_MakeAimVectors( Vector( 0, m_ang2.y, 0 ) );
		m_vel2 = gpGlobals->v_forward * m_pGoalEnt->pev->speed;

		m_startTime = m_startTime + m_dTime;
		m_dTime = 2.0 * (m_pos1 - m_pos2).Length() / (m_vel1.Length() + m_pGoalEnt->pev->speed);

		if (m_ang1.y - m_ang2.y < -180)
		{
			m_ang1.y += 360;
		}
		else if (m_ang1.y - m_ang2.y > 180)
		{
			m_ang1.y -= 360;
		}

		if (m_pGoalEnt->pev->speed < 400)
			m_flIdealtilt = 0;
		else
			m_flIdealtilt = -90;
	}
	else
	{
		ALERT( at_console, "osprey missing target");
	}
}
Exemplo n.º 5
0
bool CMapzoneData::MapZoneSpawned(CMapzone *mZone)
{
    bool toReturn = false;
    if (!mZone) return false;

    char name[128];
    if ( !ZoneTypeToClass( mZone->GetType(), name ) ) return false;


    CBaseEntity *pEnt = gEntList.FindEntityByClassname(NULL, name);
    while (pEnt)
    {
        if (pEnt->GetAbsOrigin() == *mZone->GetPosition()
            && pEnt->GetAbsAngles() == *mZone->GetRotation()
            && pEnt->WorldAlignMaxs() == *mZone->GetScaleMaxs()
            && pEnt->WorldAlignMins() == *mZone->GetScaleMins())
        {
            DevLog("Already found a %s spawned on the map! Not spawning it from zone file...\n", name);
            toReturn = true;
            break;
        }

        pEnt = gEntList.FindEntityByClassname(pEnt, name);
    }

    return toReturn;
}
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CPointTeleport::Activate( void )
{
	CBaseEntity *pTarget = GetNextTarget();
	if (pTarget)
	{
		if ( pTarget->GetMoveParent() != NULL )
		{
			Warning("ERROR: (%s) can't teleport object (%s) as it has a parent!\n",GetDebugName(),pTarget->GetDebugName());

			return;
		}
		if (m_spawnflags & SF_TELEPORT_TO_SPAWN_POS)
		{
			m_vSaveOrigin = pTarget->GetAbsOrigin();
			m_vSaveAngles = pTarget->GetAbsAngles();
		}
		else
		{
			m_vSaveOrigin = GetAbsOrigin();
			m_vSaveAngles = GetAbsAngles();
		}
	}
	else
	{
		Warning("ERROR: (%s) given no target.  Deleting.\n",GetDebugName());
		UTIL_Remove(this);
		return;
	}
	BaseClass::Activate();
}
Exemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: Spawn an instance of the entity
//-----------------------------------------------------------------------------
void CEnvEntityMaker::SpawnEntityAtEntityOriginFromScript( HSCRIPT hEntity )
{
	CBaseEntity *pTargetEntity = ToEnt( hEntity );
	if ( pTargetEntity )
	{
		SpawnEntity( pTargetEntity->GetAbsOrigin(), pTargetEntity->GetAbsAngles() );
	}
}
Exemplo n.º 8
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CEnvEntityMaker::InputForceSpawnAtEntityOrigin( inputdata_t &inputdata )
{
	CBaseEntity *pTargetEntity = gEntList.FindEntityByName( NULL, inputdata.value.String(), this, inputdata.pActivator, inputdata.pCaller );
		
	if( pTargetEntity )
	{
		SpawnEntity( pTargetEntity->GetAbsOrigin(), pTargetEntity->GetAbsAngles() );
	}
}
Exemplo n.º 9
0
//-----------------------------------------------------------------------------
// Purpose: Spawn an instance of the entity
//-----------------------------------------------------------------------------
void CEnvEntityMaker::SpawnEntityAtNamedEntityOriginFromScript( const char *pszName )
{
	CBaseEntity *pTargetEntity = gEntList.FindEntityByName( NULL, pszName, this, NULL, NULL );

	if( pTargetEntity )
	{
		SpawnEntity( pTargetEntity->GetAbsOrigin(), pTargetEntity->GetAbsAngles() );
	}
}
Exemplo n.º 10
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CScriptIntro::InputSetCameraViewEntity( inputdata_t &inputdata )
{
	// Find the specified entity
	string_t iszEntityName = inputdata.value.StringID();
	if ( iszEntityName == NULL_STRING )
		return;

	CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, iszEntityName, NULL, inputdata.pActivator, inputdata.pCaller );
	if ( !pEntity )
	{
		Warning("script_intro %s couldn't find SetCameraViewEntity named %s\n", STRING(GetEntityName()), STRING(iszEntityName) );
		return;
	}

	m_hCameraEntity = pEntity;
	m_vecCameraView = pEntity->GetAbsOrigin();
	m_vecCameraViewAngles = pEntity->GetAbsAngles();
}
Exemplo n.º 11
0
//=========================================================
//=========================================================
edict_t *CGameRules :: GetPlayerSpawnSpot( CBasePlayer *pPlayer )
{
	edict_t *pentSpawnSpot = EntSelectSpawnPoint( pPlayer );
	CBaseEntity *pSpawnSpot = CBaseEntity::Instance( pentSpawnSpot );

	pPlayer->SetAbsOrigin( pSpawnSpot->GetAbsOrigin() + Vector(0,0,1) );
	pPlayer->pev->v_angle  = g_vecZero;
	pPlayer->SetAbsVelocity( g_vecZero );
	pPlayer->SetAbsAngles( pSpawnSpot->GetAbsAngles() );
	pPlayer->pev->punchangle = g_vecZero;
	pPlayer->pev->fixangle = TRUE;

	if( pSpawnSpot->pev->spawnflags & 1 ) // the START WITH SUIT flag
	{
		pPlayer->pev->weapons |= BIT( WEAPON_SUIT );
	}
	
	return pentSpawnSpot;
}
Exemplo n.º 12
0
void CASW_Arena::TeleportPlayersToSpawn()
{
	if ( !ASWGameRules() )
		return;

	CBaseEntity *pSpot = NULL;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	for (int i=0;i<pGameResource->GetMaxMarineResources();i++)
	{
		if (pGameResource->GetMarineResource(i) != NULL && pGameResource->GetMarineResource(i)->GetMarineEntity())
		{
			CASW_Marine *pMarine = pGameResource->GetMarineResource(i)->GetMarineEntity();
			if ( pMarine->GetHealth() > 0 )
			{
				pSpot = ASWGameRules()->GetMarineSpawnPoint( pSpot );
				if ( pSpot )
				{
					pMarine->Teleport( &pSpot->GetAbsOrigin(), &pSpot->GetAbsAngles(), &vec3_origin );
				}
			}
		}
	}
}
Exemplo n.º 13
0
void CGstringInteraction::OnBodyAnimationFinished()
{
	CDynamicProp *pInteractiveObject = dynamic_cast< CDynamicProp* >( m_hInteractiveObject.Get() );
	if ( pInteractiveObject != NULL )
	{
		pInteractiveObject->ClearInteractionEntity();
	}

	CGstringPlayer *pPlayer = m_hPlayer;
	if ( pPlayer != NULL )
	{
		pPlayer->EndInteraction();

		CBaseEntity *pFinalPosition = m_hFinalPosition;
		if ( pFinalPosition != NULL )
		{
			pPlayer->Teleport( &pFinalPosition->GetAbsOrigin(),
				&pFinalPosition->GetAbsAngles(), &vec3_origin );
		}
	}
	m_bInteractionActive = false;
	m_InteractionEndEvent.FireOutput( this, this );
}
Exemplo n.º 14
0
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CPointTeleport::Activate( void )
{
	// Start with our origin point
	m_vSaveOrigin = GetAbsOrigin();
	m_vSaveAngles = GetAbsAngles();

	// Save off the spawn position of the target if instructed to do so
	if ( m_spawnflags & SF_TELEPORT_TO_SPAWN_POS )
	{
		CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, m_target );
		if ( pTarget )
		{
			// If teleport object is in a movement hierarchy, remove it first
			if ( EntityMayTeleport( pTarget ) )
			{
				// Save the points
				m_vSaveOrigin = pTarget->GetAbsOrigin();
				m_vSaveAngles = pTarget->GetAbsAngles();
			}
			else
			{
				Warning("ERROR: (%s) can't teleport object (%s) as it has a parent (%s)!\n",GetDebugName(),pTarget->GetDebugName(),pTarget->GetMoveParent()->GetDebugName());
				BaseClass::Activate();
				return;
			}
		}
		else
		{
			Warning("ERROR: (%s) target '%s' not found. Deleting.\n", GetDebugName(), STRING(m_target));
			UTIL_Remove( this );
			return;
		}
	}

	BaseClass::Activate();
}
//-----------------------------------------------------------------------------
// Purpose:
// Input  : *pTask -
//-----------------------------------------------------------------------------
void CAI_OperatorBehavior::StartTask( const Task_t *pTask )
{
    switch( pTask->iTask )
    {
    case TASK_OPERATOR_OPERATE:
    {
        // Fire the appropriate output!
        switch( GetGoalEntity()->GetState() )
        {
        case OPERATOR_STATE_NOT_READY:
            GetGoalEntity()->m_OnMakeReady.FireOutput(NULL, NULL, 0);
            break;

        case OPERATOR_STATE_READY:
            GetGoalEntity()->m_OnBeginOperating.FireOutput(NULL, NULL, 0);
            break;

        default:
            //!!!HACKHACK
            Assert(0);
            break;
        }
    }
    TaskComplete();
    break;

    case TASK_OPERATOR_START_PATH:
    {
        ChainStartTask(TASK_WALK_PATH);
    }
    break;

    case TASK_OPERATOR_GET_PATH_TO_POSITION:
    {
        CBaseEntity *pGoal = m_hPositionEnt;

        if( !pGoal )
        {
            TaskFail("ai_goal_operator has no location entity\n");
            break;
        }

        AI_NavGoal_t goal( pGoal->GetAbsOrigin() );
        goal.pTarget = pGoal;

        if ( GetNavigator()->SetGoal( goal ) == false )
        {
            TaskFail( "Can't build path\n" );
            /*
            // Try and get as close as possible otherwise
            AI_NavGoal_t nearGoal( GOALTYPE_LOCATION_NEAREST_NODE, m_hTargetObject->GetAbsOrigin(), AIN_DEF_ACTIVITY, 256 );
            if ( GetNavigator()->SetGoal( nearGoal, AIN_CLEAR_PREVIOUS_STATE ) )
            {
            	//FIXME: HACK! The internal pathfinding is setting this without our consent, so override it!
            	ClearCondition( COND_TASK_FAILED );
            	GetNavigator()->SetArrivalDirection( m_hTargetObject->GetAbsAngles() );
            	TaskComplete();
            	return;
            }
            */
        }

        GetNavigator()->SetArrivalDirection( pGoal->GetAbsAngles() );
    }
    break;

    default:
        BaseClass::StartTask( pTask );
        break;
    }
}
Exemplo n.º 16
0
static void saveZonFile(const char* szMapName)
{
    KeyValues* zoneKV = new KeyValues(szMapName);
    CBaseEntity* pEnt = gEntList.FindEntityByClassname(NULL, "trigger_momentum_*");
    while (pEnt)
    {
        KeyValues* subKey = NULL;
        if (pEnt->ClassMatches("trigger_momentum_timer_start"))
        {
            CTriggerTimerStart* pTrigger = dynamic_cast<CTriggerTimerStart*>(pEnt);
            subKey = new KeyValues("start");
            if (pTrigger)
            {
                subKey->SetFloat("leavespeed", pTrigger->GetMaxLeaveSpeed());
                subKey->SetBool("limitingspeed", pTrigger->IsLimitingSpeed());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_timer_stop"))
        {
            subKey = new KeyValues("end");
        }
        else if (pEnt->ClassMatches("trigger_momentum_timer_checkpoint"))
        {
            CTriggerCheckpoint* pTrigger = dynamic_cast<CTriggerCheckpoint*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("checkpoint");
                subKey->SetInt("number", pTrigger->GetCheckpointNumber());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_onehop"))
        {
            CTriggerOnehop* pTrigger = dynamic_cast<CTriggerOnehop*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("onehop");
                //subKey->SetInt("destination", pTrigger->GetDestinationIndex());
                subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
                subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
                subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime());
                subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_resetonehop"))
        {
            subKey = new KeyValues("resetonehop");
        }
        else if (pEnt->ClassMatches("trigger_momentum_teleport_checkpoint"))
        {

            CTriggerTeleportCheckpoint* pTrigger = dynamic_cast<CTriggerTeleportCheckpoint*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("checkpoint_teleport");
                //subKey->SetInt("destination", pTrigger->GetDestinationCheckpointNumber());
                subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
                subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
                subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_multihop"))
        {
            CTriggerMultihop* pTrigger = dynamic_cast<CTriggerMultihop*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("multihop");
                //subKey->SetInt("destination", pTrigger->GetDestinationIndex());
                subKey->SetBool("stop", pTrigger->ShouldStopPlayer());
                subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime());
                subKey->SetBool("resetang", pTrigger->ShouldResetAngles());
                subKey->SetString("destinationname", pTrigger->m_target.ToCStr());
            }
        }
        else if (pEnt->ClassMatches("trigger_momentum_timer_stage"))
        {
            CTriggerStage *pTrigger = dynamic_cast<CTriggerStage*>(pEnt);
            if (pTrigger)
            {
                subKey = new KeyValues("stage");
                subKey->SetInt("number", pTrigger->GetStageNumber());
            }
        }
        if (subKey)
        {
            subKey->SetFloat("xPos", pEnt->GetAbsOrigin().x);
            subKey->SetFloat("yPos", pEnt->GetAbsOrigin().y);
            subKey->SetFloat("zPos", pEnt->GetAbsOrigin().z);
            subKey->SetFloat("xRot", pEnt->GetAbsAngles().x);
            subKey->SetFloat("yRot", pEnt->GetAbsAngles().y);
            subKey->SetFloat("zRot", pEnt->GetAbsAngles().z);
            subKey->SetFloat("xScaleMins", pEnt->WorldAlignMins().x);
            subKey->SetFloat("yScaleMins", pEnt->WorldAlignMins().y);
            subKey->SetFloat("zScaleMins", pEnt->WorldAlignMins().z);
            subKey->SetFloat("xScaleMaxs", pEnt->WorldAlignMaxs().x);
            subKey->SetFloat("yScaleMaxs", pEnt->WorldAlignMaxs().y);
            subKey->SetFloat("zScaleMaxs", pEnt->WorldAlignMaxs().z);
            zoneKV->AddSubKey(subKey);
        }
        pEnt = gEntList.FindEntityByClassname(pEnt, "trigger_momentum_*");
    }
    if (zoneKV->GetFirstSubKey())//not empty 
    {
        char zoneFilePath[MAX_PATH];
        Q_strcpy(zoneFilePath, "maps/");
        Q_strcat(zoneFilePath, szMapName, MAX_PATH);
        Q_strncat(zoneFilePath, ".zon", MAX_PATH);
        zoneKV->SaveToFile(filesystem, zoneFilePath, "MOD");
        zoneKV->deleteThis();
    }
}
Exemplo n.º 17
0
void CWeaponGravityGun::ItemPostFrame( void )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
	if (!pOwner)
		return;

#ifdef ARGG
	// adnan
	// this is where we check if we're orbiting the object
	
	// if we're holding something and pressing use,
	//  then set us in the orbiting state
	//  - this will indicate to OverrideMouseInput that we should zero the input and update our delta angles
	//  UPDATE: not anymore.  now this just sets our state variables.
	CBaseEntity *pObject = m_hObject;
	if( pObject ) {

		if((pOwner->m_nButtons & IN_ATTACK) && (pOwner->m_nButtons & IN_USE) ) {
			m_gravCallback.m_bHasRotatedCarryAngles = true;
			
			// did we JUST hit use?
			//  if so, grab the current angles to begin with as the rotated angles
			if( !(pOwner->m_afButtonLast & IN_USE) ) {
				m_gravCallback.m_vecRotatedCarryAngles = pObject->GetAbsAngles();
			}

			m_bIsCurrentlyRotating = true;
		} else {
			m_gravCallback.m_bHasRotatedCarryAngles = false;

			m_bIsCurrentlyRotating = false;
		}
	} else {
		m_bIsCurrentlyRotating = false;

		m_gravCallback.m_bHasRotatedCarryAngles = false;
	}
	// end adnan
#endif

	if ( pOwner->m_nButtons & IN_ATTACK )
	{
#if defined( ARGG )
		if( (pOwner->m_nButtons & IN_USE) ) {
			pOwner->m_vecUseAngles = pOwner->pl.v_angle;
		}
#endif
		if ( pOwner->m_afButtonPressed & IN_ATTACK2 )
		{
			SecondaryAttack();
		}
		else if ( pOwner->m_nButtons & IN_ATTACK2 )
		{
			if ( m_active )
			{
				EffectDestroy();
				SoundDestroy();
			}
			WeaponIdle( );
			return;
		}
		PrimaryAttack();
	}
	else 
	{
		if ( m_active )
		{
			EffectDestroy();
			SoundDestroy();
		}
		WeaponIdle( );
		return;
	}
	if ( pOwner->m_afButtonPressed & IN_RELOAD )
	{
		Reload();
	}
}
Exemplo n.º 18
0
void CC4::PrimaryAttack()
{
	bool	PlaceBomb = false;
	CCSPlayer *pPlayer = GetPlayerOwner();
	if ( !pPlayer )
		return;

	int onGround = FBitSet( pPlayer->GetFlags(), FL_ONGROUND );
	CBaseEntity *groundEntity = (onGround) ? pPlayer->GetGroundEntity() : NULL;
	if ( groundEntity )
	{
		// Don't let us stand on players, breakables, or pushaway physics objects to plant
		if ( groundEntity->IsPlayer() ||
			IsPushableEntity( groundEntity ) ||
#ifndef CLIENT_DLL
			IsBreakableEntity( groundEntity ) ||
#endif // !CLIENT_DLL
			IsPushAwayEntity( groundEntity ) )
		{
			onGround = false;
		}
	}

	if( m_bStartedArming == false && m_bBombPlanted == false )
	{
		if( pPlayer->m_bInBombZone && onGround )
		{
			m_bStartedArming = true;
			m_fArmedTime = gpGlobals->curtime + WEAPON_C4_ARM_TIME;
			m_bBombPlacedAnimation = false;


#if !defined( CLIENT_DLL )			
			// init the beep flags
			int i;
			for( i=0;i<NUM_BEEPS;i++ )
				m_bPlayedArmingBeeps[i] = false;

			// freeze the player in place while planting
			pPlayer->SetMaxSpeed( 1 );

			// player "arming bomb" animation
			pPlayer->SetAnimation( PLAYER_ATTACK1 );
	
			pPlayer->SetNextAttack( gpGlobals->curtime );

			IGameEvent * event = gameeventmanager->CreateEvent( "bomb_beginplant" );
			if( event )
			{
				event->SetInt("userid", pPlayer->GetUserID() );
				event->SetInt("site", pPlayer->m_iBombSiteIndex );
				event->SetInt( "priority", 8 );
				gameeventmanager->FireEvent( event );
			}
#endif

			SendWeaponAnim( ACT_VM_PRIMARYATTACK );

			FX_PlantBomb( pPlayer->entindex(), pPlayer->Weapon_ShootPosition() );
		}
		else
		{
			if ( !pPlayer->m_bInBombZone )
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_At_Bomb_Spot");
			}
			else
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground");
			}

			m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
			return;
		}
	}
	else
	{
		if ( !onGround || !pPlayer->m_bInBombZone )
		{
			if( !pPlayer->m_bInBombZone )
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Arming_Cancelled" );
			}
			else
			{
				ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Plant_Must_Be_On_Ground" );
			}

			m_flNextPrimaryAttack = gpGlobals->curtime + 1.5;
			m_bStartedArming = false;

#if !defined( CLIENT_DLL )
			// release the player from being frozen, we've somehow left the bomb zone
			pPlayer->ResetMaxSpeed();

			pPlayer->SetProgressBarTime( 0 );

			//pPlayer->SetAnimation( PLAYER_HOLDBOMB );

			IGameEvent * event = gameeventmanager->CreateEvent( "bomb_abortplant" );
			if( event )
			{
				event->SetInt("userid", pPlayer->GetUserID() );
				event->SetInt("site", pPlayer->m_iBombSiteIndex );
				event->SetInt( "priority", 8 );
				gameeventmanager->FireEvent( event );
			}

#endif
			if(m_bBombPlacedAnimation == true) //this means the placement animation is canceled
			{
				SendWeaponAnim( ACT_VM_DRAW );
			}
			else
			{
				SendWeaponAnim( ACT_VM_IDLE );
			}
			
			return;
		}
		else
		{
#ifndef CLIENT_DLL
			PlayArmingBeeps();
#endif

			if( gpGlobals->curtime >= m_fArmedTime ) //the c4 is ready to be armed
			{
				//check to make sure the player is still in the bomb target area
				PlaceBomb = true;
			}
			else if( ( gpGlobals->curtime >= (m_fArmedTime - 0.75) ) && ( !m_bBombPlacedAnimation ) )
			{
				//call the c4 Placement animation 
				m_bBombPlacedAnimation = true;

				SendWeaponAnim( ACT_VM_SECONDARYATTACK );
				
#if !defined( CLIENT_DLL )
				// player "place" animation
				//pPlayer->SetAnimation( PLAYER_HOLDBOMB );
#endif
			}
		}
	}

	if ( PlaceBomb && m_bStartedArming )
	{
		m_bStartedArming = false;
		m_fArmedTime = 0;
		
		if( pPlayer->m_bInBombZone )
		{
#if !defined( CLIENT_DLL )

			CPlantedC4 *pC4 = CPlantedC4::ShootSatchelCharge( pPlayer, pPlayer->GetAbsOrigin(), pPlayer->GetAbsAngles() );

			if ( pC4 )
			{
				pC4->SetBombSiteIndex( pPlayer->m_iBombSiteIndex );

				trace_t tr;
				UTIL_TraceEntity( pC4, GetAbsOrigin(), GetAbsOrigin() + Vector(0,0,-200), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
				pC4->SetAbsOrigin( tr.endpos );

				CBombTarget *pBombTarget = (CBombTarget*)UTIL_EntityByIndex( pPlayer->m_iBombSiteIndex );
				
				if ( pBombTarget )
				{
					CBaseEntity *pAttachPoint = gEntList.FindEntityByName( NULL, pBombTarget->GetBombMountTarget() );

					if ( pAttachPoint )
					{
						pC4->SetAbsOrigin( pAttachPoint->GetAbsOrigin() );
						pC4->SetAbsAngles( pAttachPoint->GetAbsAngles() );
						pC4->SetParent( pAttachPoint );
					}

					variant_t emptyVariant;
					pBombTarget->AcceptInput( "BombPlanted", pC4, pC4, emptyVariant, 0 );
				}
			}

			IGameEvent * event = gameeventmanager->CreateEvent( "bomb_planted" );
			if( event )
			{
				event->SetInt("userid", pPlayer->GetUserID() );
				event->SetInt("site", pPlayer->m_iBombSiteIndex );
				event->SetInt("posx", pPlayer->GetAbsOrigin().x );
				event->SetInt("posy", pPlayer->GetAbsOrigin().y );
				event->SetInt( "priority", 8 );
				gameeventmanager->FireEvent( event );
			}

			// Fire a beep event also so the bots have a chance to hear the bomb
			event = gameeventmanager->CreateEvent( "bomb_beep" );

			if ( event )
			{
				event->SetInt( "entindex", entindex() );
				gameeventmanager->FireEvent( event );
			}

			pPlayer->SetProgressBarTime( 0 );

			CSGameRules()->m_bBombDropped = false;
			CSGameRules()->m_bBombPlanted = true;

			// Play the plant sound.
			Vector plantPosition = pPlayer->GetAbsOrigin() + Vector( 0, 0, 5 );
			CPASAttenuationFilter filter( plantPosition );
			EmitSound( filter, entindex(), "c4.plant" );

			// release the player from being frozen
			pPlayer->ResetMaxSpeed();

			// No more c4!
			pPlayer->Weapon_Drop( this, NULL, NULL );
			UTIL_Remove( this );
#endif
			//don't allow the planting to start over again next frame.
			m_bBombPlanted = true;

			return;
		}
		else
		{
			ClientPrint( pPlayer, HUD_PRINTCENTER, "#C4_Activated_At_Bomb_Spot" );

#if !defined( CLIENT_DLL )
			//pPlayer->SetAnimation( PLAYER_HOLDBOMB );

			// release the player from being frozen
			pPlayer->ResetMaxSpeed();

			IGameEvent * event = gameeventmanager->CreateEvent( "bomb_abortplant" );
			if( event )
			{
				event->SetInt("userid", pPlayer->GetUserID() );
				event->SetInt("site", pPlayer->m_iBombSiteIndex );
				event->SetInt( "priority", 8 );
				gameeventmanager->FireEvent( event );
			}
#endif

			m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
			return;
		}
	}

	m_flNextPrimaryAttack = gpGlobals->curtime + 0.3;
	SetWeaponIdleTime( gpGlobals->curtime + SharedRandomFloat("C4IdleTime", 10, 15 ) );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool CGrabController::UpdateObject( CBasePlayer *pPlayer, float flError )
{
 	CBaseEntity *pEntity = GetAttached();
	if ( !pEntity || ComputeError() > flError || pPlayer->GetGroundEntity() == pEntity || !pEntity->VPhysicsGetObject() )
	{
		return false;
	}

	//Adrian: Oops, our object became motion disabled, let go!
	IPhysicsObject *pPhys = pEntity->VPhysicsGetObject();
	if ( pPhys && pPhys->IsMoveable() == false )
	{
		return false;
	}

	Vector forward, right, up;
	QAngle playerAngles = pPlayer->EyeAngles();
	AngleVectors( playerAngles, &forward, &right, &up );
	
	float pitch = AngleDistance(playerAngles.x,0);

	if( !m_bAllowObjectOverhead )
	{
		playerAngles.x = clamp( pitch, -75, 75 );
	}
	else
	{
		playerAngles.x = clamp( pitch, -90, 75 );
	}

	
	
	// Now clamp a sphere of object radius at end to the player's bbox
	Vector radial = physcollision->CollideGetExtent( pPhys->GetCollide(), vec3_origin, pEntity->GetAbsAngles(), -forward );
	Vector player2d = pPlayer->CollisionProp()->OBBMaxs();
	float playerRadius = player2d.Length2D();
	float radius = playerRadius + fabs(DotProduct( forward, radial ));

	float distance = 24 + ( radius * 2.0f );

	// Add the prop's distance offset
	distance += m_flDistanceOffset;

	Vector start = pPlayer->Weapon_ShootPosition();
	Vector end = start + ( forward * distance );

	trace_t	tr;
	CTraceFilterSkipTwoEntities traceFilter( pPlayer, pEntity, COLLISION_GROUP_NONE );
	Ray_t ray;
	ray.Init( start, end );
	enginetrace->TraceRay( ray, MASK_SOLID_BRUSHONLY, &traceFilter, &tr );

	if ( tr.fraction < 0.5 )
	{
		end = start + forward * (radius*0.5f);
	}
	else if ( tr.fraction <= 1.0f )
	{
		end = start + forward * ( distance - radius );
	}
	Vector playerMins, playerMaxs, nearest;
	pPlayer->CollisionProp()->WorldSpaceAABB( &playerMins, &playerMaxs );
	Vector playerLine = pPlayer->CollisionProp()->WorldSpaceCenter();
	CalcClosestPointOnLine( end, playerLine+Vector(0,0,playerMins.z), playerLine+Vector(0,0,playerMaxs.z), nearest, NULL );

	if( !m_bAllowObjectOverhead )
	{
		Vector delta = end - nearest;
		float len = VectorNormalize(delta);
		if ( len < radius )
		{
			end = nearest + radius * delta;
		}
	}

	//Show overlays of radius
	if ( g_debug_physcannon.GetBool() )
	{
		NDebugOverlay::Box( end, -Vector( 2,2,2 ), Vector(2,2,2), 0, 255, 0, true, 0 );

		NDebugOverlay::Box( GetAttached()->WorldSpaceCenter(), 
							-Vector( radius, radius, radius), 
							Vector( radius, radius, radius ),
							255, 0, 0,
							true,
							0.0f );
	}

	QAngle angles = TransformAnglesFromPlayerSpace( m_attachedAnglesPlayerSpace, pPlayer );
	
	// If it has a preferred orientation, update to ensure we're still oriented correctly.
	Pickup_GetPreferredCarryAngles( pEntity, pPlayer, pPlayer->EntityToWorldTransform(), angles );

	// We may be holding a prop that has preferred carry angles
	if ( m_bHasPreferredCarryAngles )
	{
		matrix3x4_t tmp;
		ComputePlayerMatrix( pPlayer, tmp );
		angles = TransformAnglesToWorldSpace( m_vecPreferredCarryAngles, tmp );
	}

	matrix3x4_t attachedToWorld;
	Vector offset;
	AngleMatrix( angles, attachedToWorld );
	VectorRotate( m_attachedPositionObjectSpace, attachedToWorld, offset );

	SetTargetPosition( end - offset, angles );

	return true;
}
Exemplo n.º 20
0
void CASW_Arena::SpawnArenaWave()
{
	if ( !ASWSpawnManager() )
		return;

	if ( ASWGameRules() )
	{
		ASWGameRules()->BroadcastSound( "Spawner.Horde" );
	}

	// find the 4 corridor spawn points
	CUtlVector<CBaseEntity*> arenaSpawns[4];
	int arenaSpawnsUsed[4];
	memset( arenaSpawnsUsed, 0, sizeof( arenaSpawnsUsed ) );

	CBaseEntity* pEntity = NULL;
	while ((pEntity = gEntList.FindEntityByClassname( pEntity, "info_target" )) != NULL)
	{
		if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Front" ) )
		{
			arenaSpawns[0].AddToTail( pEntity );
		}
		else if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Right" ) )
		{
			arenaSpawns[1].AddToTail( pEntity );
		}
		else if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Below" ) )
		{
			arenaSpawns[2].AddToTail( pEntity );
		}
		else if ( !stricmp( STRING( pEntity->GetEntityName() ), "Spawn_Left" ) )
		{
			arenaSpawns[3].AddToTail( pEntity );
		}
	}
	Msg( "Found arena spawns: N:%d E:%d S:%d W:%d\n", arenaSpawns[0].Count(), arenaSpawns[1].Count(), arenaSpawns[2].Count(), arenaSpawns[3].Count() );

	// decide how many alien types we're going to spawn
	int iAlienTypes = 2;
	float fRandom = RandomFloat();
	if ( fRandom < 0.1f )
	{
		iAlienTypes = 4;
	}
	else if ( fRandom < 0.30f )
	{
		iAlienTypes = 3;
	}

	for ( int i=0 ; i<iAlienTypes; i++ )
	{
		// decide on a direction
		int iDirection = RandomInt( 0, 3 );
		// decide on an alien type
		int iAlienType = RandomInt( 0, m_ArenaAliens.Count() - 1 );
		int iQuantity = asw_arena_quantity_scale.GetFloat() * RandomInt( m_ArenaAliens[iAlienType]->m_iQuantityMin, m_ArenaAliens[iAlienType]->m_iQuantityMax );
		int iArenaLevel = m_iArenaWave / asw_arena_waves_per_difficulty.GetInt();
		iQuantity += iArenaLevel;

		for ( int k=0 ; k < iQuantity ; k++ )
		{
			if ( arenaSpawnsUsed[iDirection] < arenaSpawns[iDirection].Count() )
			{
				CBaseEntity *pSpawnPoint = arenaSpawns[iDirection][arenaSpawnsUsed[iDirection]];
				if ( !pSpawnPoint )
					continue;

				if ( ASWSpawnManager()->SpawnAlienAt( m_ArenaAliens[iAlienType]->m_szAlienClass, pSpawnPoint->GetAbsOrigin(), pSpawnPoint->GetAbsAngles() ) )
				{
					arenaSpawnsUsed[iDirection]++;
				}
			}
		}
	}

	m_iArenaWave++;
}