//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CBaseHLCombatWeapon::WeaponShouldBeLowered( void )
{
	// Can't be in the middle of another animation
  	if ( GetIdealActivity() != ACT_VM_IDLE_LOWERED && GetIdealActivity() != ACT_VM_IDLE &&
		 GetIdealActivity() != ACT_VM_IDLE_TO_LOWERED && GetIdealActivity() != ACT_VM_LOWERED_TO_IDLE )
  		return false;

	if ( m_bLowered )
		return true;
	
#if !defined( CLIENT_DLL )

	if ( GlobalEntity_GetState( "friendly_encounter" ) == GLOBAL_ON )
		return true;

#endif

	return false;
}
示例#2
0
//-----------------------------------------------------------------------------
// Purpose: Called shortly after level spawn. Checks the global state and fires
//			targets if the global state is set or if there is not global state
//			to check.
//-----------------------------------------------------------------------------
void CLogicAuto::Think(void)
{
	if (!m_globalstate || GlobalEntity_GetState(m_globalstate) == GLOBAL_ON)
	{
		if (gpGlobals->eLoadType == MapLoad_Transition)
		{
			m_OnMapTransition.FireOutput(NULL, this);
		}
		else if (gpGlobals->eLoadType == MapLoad_NewGame)
		{
			m_OnNewGame.FireOutput(NULL, this);
		}
		else if (gpGlobals->eLoadType == MapLoad_LoadGame)
		{
			m_OnLoadGame.FireOutput(NULL, this);
		}
		else if (gpGlobals->eLoadType == MapLoad_Background)
		{
			m_OnBackgroundMap.FireOutput(NULL, this);
		}

		m_OnMapSpawn.FireOutput(NULL, this);

		if ( g_pGameRules->IsMultiplayer() )
		{
			// In multiplayer, fire the new map / round events.
			if ( g_pGameRules->InRoundRestart() )
			{
				m_OnMultiNewRound.FireOutput(NULL, this);
			}
			else
			{
				m_OnMultiNewMap.FireOutput(NULL, this);
			}
		}

		if (m_spawnflags & SF_AUTO_FIREONCE)
		{
			UTIL_Remove(this);
		}
	}
}
示例#3
0
int CPropVehicleManhack::UpdateManhackDistance(CBaseEntity *pOrigin) 
{
	CNPC_Manhack *pManhack=GetManhack();
	
	if (pManhack != NULL && pOrigin) //!GetDriver()) 
	{
		if (GlobalEntity_GetState("manhacks_use_short_distances") == GLOBAL_ON)
		{
			Vector vecDistance = (pManhack->GetAbsOrigin() - pOrigin->GetAbsOrigin());
			float flHeight	= vecDistance.z / manhack_small_distances_max_height.GetFloat();
			vecDistance.z	= 0.0f;
			vecDistance		= vecDistance / manhack_small_distances_max_distance.GetFloat();		
			vecDistance.z	= flHeight;
			m_iManhackDistance	= (int)( vecDistance.Length() * 100.0f );
		}
		else
		{
			m_iManhackDistance = (int)( (float) (pManhack->GetAbsOrigin() - pOrigin->GetAbsOrigin()).Length() / manhack_max_distance.GetFloat() * 100.0f);
		}

		return m_iManhackDistance;
	}
	return -1;
}
示例#4
0
void CPropVehicleManhack::UpdateManhackView( CBasePlayer *pPlayer )
{
	CNPC_Manhack *pManhack=GetManhack();
	
	if (pManhack != NULL) 
	{


		m_angManhackEye = pManhack->GetAbsAngles(); //vehicleEyeAngles;
		
		m_vecManhackEye = pManhack->GetManhackView(); //vehicleEyeOrigin;

		m_iManhackHealth	= pManhack->m_iHealth;

		Vector vecDir = pManhack->GetAbsVelocity();
		VectorNormalize(vecDir);
		m_vecFlyingDirection = vecDir;

		UpdateHead();
		
		if (GlobalEntity_GetState("manhacks_use_short_distances") == GLOBAL_ON)
		{
			Vector vecDistance = (pManhack->GetAbsOrigin() - GetAbsOrigin());
			float flHeight	= vecDistance.z / manhack_small_distances_max_height.GetFloat();
			vecDistance.z	= 0.0f;
			vecDistance		= vecDistance / manhack_small_distances_max_distance.GetFloat();		
			vecDistance.z	= flHeight;
			m_iManhackDistance	= (int)( vecDistance.Length() * 100.0f );
		}
		else
		{
			m_iManhackDistance = (int)( (float) (pManhack->GetAbsOrigin() - GetAbsOrigin()).Length() / manhack_max_distance.GetFloat() * 100.0f);
		}

		if (m_iManhackDistance >= 90 && m_flLastWarningSound < gpGlobals->curtime )
		{
			pManhack->EmitSound("NPC_Turret.Retire");
			m_flLastWarningSound = gpGlobals->curtime + 1.00f;
			
		}

		//

		Vector vecForward;
		m_hPlayer->GetVectors(&vecForward, NULL, NULL);

		trace_t	tr;
		UTIL_TraceLine( m_vecManhackEye, m_vecManhackEye + (vecForward * 1024), MASK_SHOT, pManhack, COLLISION_GROUP_NONE, &tr );

		//NDebugOverlay::Line( m_vecManhackEye, tr.endpos, 255, 255, 0, true, 1.0f );

		if (tr.m_pEnt && pPlayer && pPlayer->IRelationType( tr.m_pEnt ) == D_HT)
		{
			m_hTarget = tr.m_pEnt;
		}
		else 
		{
			m_hTarget = pManhack->GetEnemy();
		}

		m_iTargetType = HLSS_SelectTargetType(m_hTarget);

	} else 
	{	
		DevMsg("NULL Manhack\n");
		m_hManhack = NULL;
		SetLocator( NULL );
	}
}
示例#5
0
bool CPropVehicleManhack::FindNextManhack(bool bRemoveIfNone)
{
	int manhackIndex=-1;
	CNPC_Manhack *newManhack;

	bool bFound = false;

	for (int i=1; i<NUMBER_OF_MAX_CONTROLLABLE_MANHACKS; i++)
	{
		manhackIndex = (m_iCurrentManhackIndex + i) % NUMBER_OF_MAX_CONTROLLABLE_MANHACKS;
		
		if (m_hSetOfManhacks[manhackIndex] != NULL)
		{
			newManhack = dynamic_cast<CNPC_Manhack*>((CBaseEntity*)m_hSetOfManhacks[manhackIndex]);

			int iDistance = -1;

			if (newManhack != NULL )
			{
				if (GlobalEntity_GetState("manhacks_use_short_distances") == GLOBAL_ON)
				{
					Vector vecDistance = (newManhack->GetAbsOrigin() - GetAbsOrigin());
					float flHeight	= vecDistance.z / manhack_small_distances_max_height.GetFloat();
					vecDistance.z	= 0.0f;
					vecDistance		= vecDistance / manhack_small_distances_max_distance.GetFloat();		
					vecDistance.z	= flHeight;
					iDistance	= (int)( vecDistance.Length() * 100.0f );
				}
				else
				{
					iDistance = (int)( (float) (newManhack->GetAbsOrigin() - GetAbsOrigin()).Length() / manhack_max_distance.GetFloat() * 100.0f);
				}
			}

			if (newManhack != NULL && newManhack->m_iHealth > 0 )//(newManhack->GetAbsOrigin() - GetAbsOrigin()).Length() < manhack_max_distance.GetFloat() )
			{
				if (iDistance <= 100)
				{
					m_iCurrentManhackIndex = manhackIndex;
					m_hManhack = m_hSetOfManhacks[manhackIndex];
					SetLocator( m_hManhack );

					m_iManhackHealth = newManhack->m_iHealth;

					if (GetDriver())
					{
						newManhack->SetControllable(true);
						if (manhack_dont_draw.GetBool())
						{
							newManhack->AddEffects( EF_NODRAW );
							newManhack->ShowRedGlow(false);
						}
					}
					return true;
				}
			}
			else 
			{
				m_hSetOfManhacks[manhackIndex] = NULL;
			}
		}
	}

	if (!bFound && bRemoveIfNone)
	{
		SetLocator( NULL );
		ForcePlayerOut();
		DestroyAllManhacks();
		UTIL_Remove(this);

		return true;
	}

	return false;
}
示例#6
0
bool CPropVehicleManhack::CreateControllableManhack( const Vector &position, const QAngle &angles, CBaseEntity *pOwner )
{
	int manhackIndex=-1;
	for (int i=0; i<NUMBER_OF_MAX_CONTROLLABLE_MANHACKS; i++)
	{
		if (m_hSetOfManhacks[i] == NULL)
		{
			manhackIndex = i;
			break;
		}
	}

	if (manhackIndex<0)
		return false;

	CNPC_Manhack *pManhack = (CNPC_Manhack *)CBaseEntity::Create( "npc_manhack", position, angles, pOwner );

	if (pManhack == NULL)
		return false;
	
	pManhack->KeyValue( "squadname", "controllable_manhack_squad" );
	pManhack->Spawn();
	pManhack->Activate();
	pManhack->AddSpawnFlags( SF_MANHACK_PACKED_UP);
	pManhack->ShouldFollowPlayer(true);

	pManhack->KeyValue( "targetname", "controllable_manhack" );

	//TERO: commented out because otherwise you would have to set the last one free before setting this controllable
	//pManhack->SetControllable(true);

	m_hManhack = pManhack;

	m_iManhackHealth = pManhack->m_iHealth;

	if (GlobalEntity_GetState("manhacks_use_short_distances") == GLOBAL_ON)
	{
		Vector vecDistance = (pManhack->GetAbsOrigin() - GetAbsOrigin());
		float flHeight	= vecDistance.z / manhack_small_distances_max_height.GetFloat();
		vecDistance.z	= 0.0f;
		vecDistance		= vecDistance / manhack_small_distances_max_distance.GetFloat();		
		vecDistance.z	= flHeight;
		m_iManhackDistance	= (int)( vecDistance.Length() * 100.0f );
	}
	else
	{
		m_iManhackDistance	= (int)(( (float)(pManhack->GetAbsOrigin() - GetAbsOrigin()).Length()) / manhack_max_distance.GetFloat() * 100.0f);
	}

	m_iCurrentManhackIndex = manhackIndex;

	m_hSetOfManhacks[m_iCurrentManhackIndex] = pManhack;

	//TERO: this is the same as SetLocator but with the difference of pOwner
	CBasePlayer *pPlayer = ToBasePlayer( pOwner );
	if (pPlayer)
	{
		CHL2_Player *pHL2Player = dynamic_cast<CHL2_Player*>( pPlayer );
		if (pHL2Player)
		{
			DevMsg("Setting locator\n");
			pHL2Player->SetLocatorTargetEntity( m_hManhack );
		}
	}

	//This is normally in Spawn but we don't want to think before we have a manhack
	//SetNextThink( gpGlobals->curtime );
		
	return true;
}
示例#7
0
void CWeapon_Manhack::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );

	switch( pEvent->event )
	{
		case EVENT_WEAPON_SEQUENCE_FINISHED:
			m_bIsDrawing = false;
			m_bIsDoingShit = false;
			m_bIsDoingShitToo = false;

			if (m_bRedraw)
			{
				m_bRedraw=false;
				Deploy();
			}
			break;

		case EVENT_WEAPON_THROW:
			if (CPropVehicleManhack::GetManhackVehicle()!=NULL)
			{
				if (m_bHasFreeSlot)	
				{
					if (CreateControllableNPCManhack( pOwner))
					{
						DecrementAmmo( pOwner );
						EnableManhackSubModel(false);
						m_bRedraw=true;

						CBasePlayer *pPlayer = ToBasePlayer( pOwner );
						if ( pPlayer != NULL && m_iManhackHintTimeShown < 2)
						{
							if (GlobalEntity_GetState("manhacks_not_controllable") == GLOBAL_ON )
								UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackSend" );
							else
								UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackControl" );

							m_iManhackHintTimeShown++;
						}
//						fSpawnedManhack = true;
					}
				}
			}
			else if (CreateControllableVehicleManhack( pOwner))
			{
				DecrementAmmo( pOwner );	
				EnableManhackSubModel(false);	
				m_bRedraw=true;
//				fSpawnedManhack = true;

				//CBasePlayer *pPlayer = ToBasePlayer( pOwner );
				if ( pOwner != NULL && m_iManhackHintTimeShown <2)
				{
					if (GlobalEntity_GetState("manhacks_not_controllable") == GLOBAL_ON )
						UTIL_HudHintText( pOwner, "#HLSS_Hint_ManhackSend" );
					else
						UTIL_HudHintText( pOwner, "#HLSS_Hint_ManhackControl" );

					m_iManhackHintTimeShown++;
				}
			}

			m_bToggleCallback = true;

			if (!m_bHoldingSpawn)
			{
				m_bSpawnSomeMore = false;
				m_bIsDoingController = true;
			}
			else
			{
				m_bSpawnSomeMore = true;
				m_bIsDoingController = false;
				m_bRedraw = true;
			}

			break;
		case EVENT_WEAPON_THROW2:
			if ( pOwner != NULL && pOwner->GetFlags() & FL_ONGROUND )
			{
				if (CPropVehicleManhack::GetManhackVehicle() != NULL) 
				{
					if (GlobalEntity_GetState("manhacks_not_controllable") == GLOBAL_OFF)
					{
						m_bShouldShowPanel = false;
						DriveControllableManhack();
					}
					else
					{
						if (m_bToggleCallback)
						{
							TellManhacksToGoThere();
							m_bToggleCallback = false;
						}
						else
						{
							CallManhacksBack();
							m_bToggleCallback = true;
						}

					}
				}
				else
				{
					//TERO: Lets do an error sound
				}
			}
			break;
		case EVENT_WEAPON_THROW3:
			if (m_bToggleCallback)
			{
				TellManhacksToGoThere();
				m_bToggleCallback = false;
			}
			else
			{
				CallManhacksBack();
				m_bToggleCallback = true;
			}
			break;
		default:
			BaseClass::Operator_HandleAnimEvent( pEvent, pOperator );
			break;
	}

#define RETHROW_DELAY	0.5
/*	if( fSpawnedManhack )
	{
		m_flNextPrimaryAttack	= gpGlobals->curtime + RETHROW_DELAY;
		m_flNextSecondaryAttack	= gpGlobals->curtime + RETHROW_DELAY;
		m_flTimeWeaponIdle = FLT_MAX; //NOTE: This is set once the animation has finished up!

	}
	*/
}
示例#8
0
bool CWeapon_Manhack::Deploy( void )
{
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
	if ( !pOwner )
	{
		return false;
	}

	// ------------------------------
	// Pick the right draw animation
	// ------------------------------
	int iActivity;

	m_bHasFreeSlot = HasFreeSlot();

	bool bNoDrivable = true;

	CPropVehicleManhack *pManhack = CPropVehicleManhack::GetManhackVehicle();

	if (pManhack) //m_hManhack)
	{
		// = dynamic_cast<CPropVehicleManhack*>((CBaseEntity*)m_hManhack);

		if (pManhack->HasDrivableManhack(pOwner))
		{
			bNoDrivable = false;
		}
	}

	if ( m_bHasAmmo && m_bHasFreeSlot && (!m_bIsDoingController || bNoDrivable))
	{
		iActivity = ACT_VM_DRAW;
		//EnableManhackSubModel(true);

		CBasePlayer *pPlayer = ToBasePlayer( pOwner );
			if ( pPlayer != NULL)

		m_bIsDoingController = false;
		m_bSpawnSomeMore = true; //TERO: not sure about this
	} 
	else
	{
		m_bIsDoingController = true;
		m_bSpawnSomeMore = false;
		iActivity = ACT_SLAM_DETONATOR_DRAW;
	}

	m_bIsDrawing=true;

	m_bShouldShowPanel = true;


	//TERO: this next bit is to make sure the player gets the right hint message if the controllable state has changed
	if (GlobalEntity_GetState("manhacks_not_controllable") == GLOBAL_ON )
	{
		if (m_bHadControllable)
		{
			m_iManhackHintTimeShown=0;
			CBasePlayer *pPlayer = ToBasePlayer( pOwner );
			if ( pPlayer != NULL && (CPropVehicleManhack::GetManhackVehicle() != NULL) )
			{
				UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackSend" );
				m_iManhackHintTimeShown++;
			}
		}

		m_bHadControllable = false;
	} 
	else
	{
		if (!m_bHadControllable)
		{
			m_iManhackHintTimeShown=0;
			CBasePlayer *pPlayer = ToBasePlayer( pOwner );
			if ( pPlayer != NULL && (CPropVehicleManhack::GetManhackVehicle() != NULL) )
			{
				UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackControl" );
				m_iManhackHintTimeShown++;
			}
		}
		m_bHadControllable = true;
	}

	if (!m_hScreen)
	{
		/*CBaseViewModel *vm = pOwner->GetViewModel( m_nViewModelIndex );
		if (vm)
		{

			//vm->SpawnControlPanels();
			int nLLAttachmentIndex = vm->LookupAttachment("controlpanel0_ll");
			int nURAttachmentIndex = vm->LookupAttachment("controlpanel0_ur");

			matrix3x4_t	panelToWorld;
			vm->GetAttachment( nLLAttachmentIndex, panelToWorld );

			matrix3x4_t	worldToPanel;
			MatrixInvert( panelToWorld, worldToPanel );

			// Now get the lower right position + transform into panel space
			Vector lr, lrlocal;
			vm->GetAttachment( nURAttachmentIndex, panelToWorld );
			MatrixGetColumn( panelToWorld, 3, lr );
			VectorTransform( lr, worldToPanel, lrlocal );

			float flWidth = lrlocal.x;
			float flHeight = lrlocal.y;

			CVGuiScreen *pScreen = CreateVGuiScreen( "vgui_screen", "manhack_screen", this, this, 0 );
			pScreen->ChangeTeam( 69 );
			pScreen->SetActualSize( 128, 64 );
			pScreen->SetActive( true );
			pScreen->MakeVisibleOnlyToTeammates( true );
			pScreen->SetAttachedToViewModel(true);
			m_hScreen.Set( pScreen );
		}*/

		CVGuiScreen *pScreen = CreateVGuiScreen( "vgui_screen", "manhack_screen", this, this, 0 );
		//pScreen->SetActualSize( 128, 64 );
		pScreen->SetActive( true );
		pScreen->MakeVisibleOnlyToTeammates( true );
		pScreen->SetAttachedToViewModel(true);
		m_hScreen.Set( pScreen );

	}

	return DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), iActivity, (char*)GetAnimPrefix() );
}