//-----------------------------------------------------------------------------
// Purpose: think to accumulate and award points for escorting the train
//-----------------------------------------------------------------------------
void CBaseMultiplayerPlayer::EscortScoringThink( void )
{
	m_flAreaCaptureScoreAccumulator += ESCORT_SCORE_INTERVAL;

	if ( m_flCapPointScoreRate > 0 )
	{
		float flTimeForOnePoint = 1.0f / m_flCapPointScoreRate; 

		int iPoints = 0;

		while ( m_flAreaCaptureScoreAccumulator >= flTimeForOnePoint )
		{
			m_flAreaCaptureScoreAccumulator -= flTimeForOnePoint;
			iPoints++;
		}

		if ( iPoints > 0 )
		{
			IGameEvent *event = gameeventmanager->CreateEvent( "player_escort_score" );
			if ( event )
			{
				event->SetInt( "player", entindex() );
				event->SetInt( "points", iPoints );
				gameeventmanager->FireEvent( event, true /* only to server */ );
			}
		}
	}

	SetContextThink( &CBaseMultiplayerPlayer::EscortScoringThink, gpGlobals->curtime + ESCORT_SCORE_INTERVAL, ESCORT_SCORE_CONTEXT );	
}
Exemple #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 );
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::SendCapString( int iCapTeam, int iNumCappers, int *pCappingPlayers )
{
	if ( strlen( STRING(m_iszPrintName) ) <= 0 )
		return;

	IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_captured" );
	if ( event )
	{
		event->SetInt( "cp", m_iPointIndex );
		event->SetString( "cpname", STRING(m_iszPrintName) );
		event->SetInt( "team", iCapTeam );

		char cappers[9];	// pCappingPlayers is max length 8
		int i;
		for( i=0;i<iNumCappers;i++ )
		{
			cappers[i] = (char)pCappingPlayers[i];
		}

		cappers[i] = '\0';

		// pCappingPlayers is a null terminated list of player indices
		event->SetString( "cappers", cappers );
		event->SetInt( "priority", 9 );

		gameeventmanager->FireEvent( event );
	}
}
void CGameFortsInfoZone::HandleOtherTeam(CBasePlayer *pPlayer)
{
	if(pPlayer == NULL)
		return;

	// Si on a les infos, passer dans le trigger ne fait rien
	if(IsPlayerCarryingInfos(pPlayer))
		return;
	// Les places sont prises §
	if(AreInfosSlotsFilled(pPlayer->GetTeamNumber()))
		return;

	// Bah, on peut prendre maintenant non ?
	AddPlayerToInfosList(pPlayer);
	pPlayer->IncrementFragCount(2);
	pPlayer->EmitSound("Gameplay.Forts.StoleData");
	if(pPlayer->GetTeamNumber() == TEAM_PINK)
		pPlayer->m_nSkin = PLAYER_BONUS_NROSE;
	else
		pPlayer->m_nSkin = PLAYER_BONUS_NVERT;

	IGameEvent *event = gameeventmanager->CreateEvent( "player_death" );
	if( event )
	{
		event->SetInt("userid", 0 );
		event->SetInt("attacker", pPlayer->GetUserID() );
		event->SetString("weapon", "fortssteal" );
		gameeventmanager->FireEvent( event );
	}
}
void BonusMapChallengeUpdate( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest )
{
	CreateInterfaceFn gameUIFactory = g_GameUI.GetFactory();
	if ( gameUIFactory )
	{
		IGameUI *pGameUI = (IGameUI *) gameUIFactory(GAMEUI_INTERFACE_VERSION, NULL );
		if ( pGameUI )
		{
			int piNumMedals[ 3 ] = {0};

#if 0
			pGameUI->BonusMapChallengeUpdate( pchFileName, pchMapName, pchChallengeName, iBest );
			pGameUI->BonusMapNumMedals( piNumMedals );
#endif

			IGameEvent *event = gameeventmanager->CreateEvent( "challenge_map_complete" );
			if ( event )
			{
				event->SetInt( "numbronze", piNumMedals[ 0 ] );
				event->SetInt( "numsilver", piNumMedals[ 1 ] );
				event->SetInt( "numgold", piNumMedals[ 2 ] );
				gameeventmanager->FireEvent( event );
			}
		}	
	}
}
void CC4::OnPickedUp( CBaseCombatCharacter *pNewOwner )
{
	BaseClass::OnPickedUp( pNewOwner );

#if !defined( CLIENT_DLL )
	CCSPlayer *pPlayer = dynamic_cast<CCSPlayer *>( pNewOwner );

	IGameEvent * event = gameeventmanager->CreateEvent( "bomb_pickup" );
	if ( event )
	{
		event->SetInt( "userid", pPlayer->GetUserID() );
		event->SetInt( "priority", 6 );
		gameeventmanager->FireEvent( event );
	}

	if ( pPlayer->m_bShowHints && !(pPlayer->m_iDisplayHistoryBits & DHF_BOMB_RETRIEVED) )
	{
		pPlayer->m_iDisplayHistoryBits |= DHF_BOMB_RETRIEVED;
		pPlayer->HintMessage( "#Hint_you_have_the_bomb", false );
	}
	else
	{
		ClientPrint( pPlayer, HUD_PRINTCENTER, "#Got_bomb" );
	}
#endif
}
Exemple #7
0
void CMomRunEntity::OnZoneExit(CTriggerZone *pTrigger)
{
    CMomRunEntityData *pData = GetRunEntData();

    // Zone-specific things first
    switch (pTrigger->GetZoneType())
    {
    case ZONE_TYPE_START:
        break;
    case ZONE_TYPE_STOP:
        pData->m_iCurrentTrack = pData->m_iOldTrack;
        pData->m_iCurrentZone = pData->m_iOldZone;
        break;
    case ZONE_TYPE_CHECKPOINT:
        break;
    case ZONE_TYPE_STAGE:
    default:
        break;
    }

    pData->m_bMapFinished = false;
    pData->m_bIsInZone = false;

    IGameEvent *pEvent = gameeventmanager->CreateEvent("zone_exit");
    if (pEvent)
    {
        pEvent->SetInt("ent", GetEntIndex());
        pEvent->SetInt("zone_ent", pTrigger->entindex());
        pEvent->SetInt("num", pTrigger->GetZoneNumber());
        gameeventmanager->FireEvent(pEvent);
    }
}
//=========================================================
// Deathnotice. 
//=========================================================
void CTeamplayRules::DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info )
{
	if ( m_DisableDeathMessages )
		return;

	CBaseEntity *pKiller = info.GetAttacker();
	if ( pVictim && pKiller && pKiller->IsPlayer() )
	{
		CBasePlayer *pk = (CBasePlayer*)pKiller;

		if ( pk )
		{
			if ( (pk != pVictim) && (PlayerRelationship( pVictim, pk ) == GR_TEAMMATE) )
			{
				IGameEvent * event = gameeventmanager->CreateEvent( "player_death" );
				if ( event )
				{
					event->SetInt("killer", pk->GetUserID() );
					event->SetInt("victim", pVictim->GetUserID() );
					event->SetInt("priority", 7 );	// HLTV event priority, not transmitted
					
					gameeventmanager->FireEvent( event );
				}
				return;
			}
		}
	}

	BaseClass::DeathNotice( pVictim, info );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::CaptureStart( int iCapTeam, int iNumCappingPlayers, int *pCappingPlayers )
{
	int iNumCappers = iNumCappingPlayers;

	IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_startcapture" );
	if ( event )
	{
		event->SetInt( "cp", m_iPointIndex );
		event->SetString( "cpname", STRING( m_iszPrintName ) );
		event->SetInt( "team", m_iTeam );
		event->SetInt( "capteam", iCapTeam );

		// safety check
		if ( iNumCappers > 8 )
		{
			iNumCappers = 8;
		}

		char cappers[9];	// pCappingPlayers should be max length 8
		int i;
		for( i = 0 ; i < iNumCappers ; i++ )
		{
			cappers[i] = (char)pCappingPlayers[i];
		}

		cappers[i] = '\0';

		// pCappingPlayers is a null terminated list of player indices
		event->SetString( "cappers", cappers );
		event->SetInt( "priority", 7 );

		gameeventmanager->FireEvent( event );
	}
}
void CC4::Drop( const Vector &vecVelocity )
{
#if !defined( CLIENT_DLL )

	m_bStartedArming = false; // stop arming sequence

	if ( !CSGameRules()->m_bBombPlanted ) // its not dropped if its planted
	{
		// tell the bots about the dropped bomb
		TheCSBots()->SetLooseBomb( this );

		CBasePlayer *pPlayer = dynamic_cast<CBasePlayer *>(GetOwnerEntity());
		Assert( pPlayer );
		if ( pPlayer )
		{
			IGameEvent * event = gameeventmanager->CreateEvent("bomb_dropped" );
			if ( event )
			{
				event->SetInt( "userid", pPlayer->GetUserID() );
				event->SetInt( "priority", 6 );
				gameeventmanager->FireEvent( event );
			}
		}
	}
#endif
	BaseClass::Drop( vecVelocity );
}
Exemple #11
0
void CMomentumPlayer::Spawn()
{
    SetModel(ENTITY_MODEL);
    BaseClass::Spawn();
    AddFlag(FL_GODMODE);
    // do this here because we can't get a local player in the timer class
    ConVarRef gm("mom_gamemode");
    switch (gm.GetInt())
    {
    case MOMGM_BHOP:
    case MOMGM_SURF:
    case MOMGM_UNKNOWN:
    default:
        EnableAutoBhop();
        break;
    case MOMGM_SCROLL:
        DisableAutoBhop();
        break;
    }
    // Reset all bool gameevents 
    IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone");
    IGameEvent *runSaveEvent = gameeventmanager->CreateEvent("run_save");
    IGameEvent *timerStartEvent = gameeventmanager->CreateEvent("timer_started");
    IGameEvent *practiceModeEvent = gameeventmanager->CreateEvent("practice_mode");
    if (mapZoneEvent)
    {
        mapZoneEvent->SetBool("inside_startzone", false);
        mapZoneEvent->SetBool("inside_endzone", false);
        mapZoneEvent->SetBool("map_finished", false);
        mapZoneEvent->SetInt("current_stage", 0);
        mapZoneEvent->SetInt("stage_ticks", 0);
        gameeventmanager->FireEvent(mapZoneEvent);
    }
    if (runSaveEvent)
    {
        runSaveEvent->SetBool("run_saved", false);
        runSaveEvent->SetBool("run_posted", false);
        gameeventmanager->FireEvent(runSaveEvent);
    }
    if (timerStartEvent)
    {
        timerStartEvent->SetBool("timer_isrunning", false);
        gameeventmanager->FireEvent(timerStartEvent);
    }
    if (practiceModeEvent)
    {
        practiceModeEvent->SetBool("has_practicemode", false);
        gameeventmanager->FireEvent(practiceModeEvent);
    }
    RegisterThinkContext("THINK_EVERY_TICK");
    RegisterThinkContext("CURTIME");
    RegisterThinkContext("THINK_AVERAGE_STATS");
    RegisterThinkContext("CURTIME_FOR_START");
    SetContextThink(&CMomentumPlayer::UpdateRunStats, gpGlobals->curtime + gpGlobals->interval_per_tick, "THINK_EVERY_TICK");
    SetContextThink(&CMomentumPlayer::CheckForBhop, gpGlobals->curtime, "CURTIME");
    SetContextThink(&CMomentumPlayer::CalculateAverageStats, gpGlobals->curtime + AVERAGE_STATS_INTERVAL, "THINK_AVERAGE_STATS");
    SetContextThink(&CMomentumPlayer::LimitSpeedInStartZone, gpGlobals->curtime, "CURTIME_FOR_START");
    SetNextThink(gpGlobals->curtime);
}
int CASW_Barrel_Explosive::OnTakeDamage( const CTakeDamageInfo &info )
{
	int saveFlags = m_takedamage;

	// don't be destroyed by buzzers
	if ( info.GetAttacker() && info.GetAttacker()->Classify() == CLASS_ASW_BUZZER )
	{
		return 0;
	}

	// prevent barrel exploding when knocked around
	if ( info.GetDamageType() & DMG_CRUSH )
		return 0;
	
	CASW_Marine* pMarine = NULL;
	if ( info.GetAttacker() && info.GetAttacker()->Classify() == CLASS_ASW_MARINE )
	{
		m_hAttacker = info.GetAttacker();

		pMarine = assert_cast< CASW_Marine* >( info.GetAttacker() );
		// prevent AI marines blowing up barrels as it makes the player ANGRY ANGRY
		if ( pMarine && !pMarine->IsInhabited() )
			return 0;
	}

	// don't burst open if melee'd
	if ( info.GetDamageType() & ( DMG_CLUB | DMG_SLASH ) )
	{
		m_takedamage = DAMAGE_EVENTS_ONLY;

		if( !m_bMeleeHit )
		{
			if ( pMarine )
			{
				IGameEvent * event = gameeventmanager->CreateEvent( "physics_melee" );
				if ( event )
				{
					CASW_Player *pCommander = pMarine->GetCommander();
					event->SetInt( "attacker", pCommander ? pCommander->GetUserID() : 0 );
					event->SetInt( "entindex", entindex() );
					gameeventmanager->FireEvent( event );
				}
			}
			m_bMeleeHit = true;
		}
	}

	if ( pMarine )
	{
		pMarine->HurtJunkItem(this, info);
	}

	// skip the breakable prop's complex damage handling and just hurt us
	int iResult = CBaseEntity::OnTakeDamage(info);
	m_takedamage = saveFlags;

	return iResult;
}
// Ability to alter the objective:
//   DOBJ_ACTION_OPEN: Opens the objective door and starts spawning creeps (if round has started)
//   DOBJ_ACTION_CLOSE: Closes the objective door and stops spawning creeps (if this is the last door, the round will end)
int DotaObjective::TakeAction( int dobjAction ) { // Issue #24: AMP - 2013-10-04 - Lane manipulation
	if (dobjAction & DOBJ_ACTION_CLOSE) {
		PropSetAnim( "Close" );

		// Issue #35: JMS - 2013-10-27 - fire event to clients
		IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_close" );
		if ( pEvent )
		{
			pEvent->SetString( "lane", GetLane() );
			pEvent->SetInt( "team", this->GetTeamNumber() );
			gameeventmanager->FireEvent( pEvent );
		}

		m_bMet = true;			
				
		//turn off the maker
		CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName );
		if( maker )
			maker->m_enabled = false;

		//see if I'm the last one, if so, game over
		bool foundOne = false;
		for ( CBaseEntity *pEntity = gEntList.FirstEnt(); pEntity != NULL; pEntity = gEntList.NextEnt(pEntity) )
		{
			DotaObjective * obj = dynamic_cast<DotaObjective*>( pEntity );
			if ( obj && obj->GetTeamNumber() == this->GetTeamNumber() && !obj->m_bMet )
				foundOne = true;
		}
		if ( !foundOne )
		{
			CHL2MPRules *rules = (CHL2MPRules*)g_pGameRules;
			if ( rules && !rules->IsIntermission() )
			{
				rules->EndMultiplayerGame();
			}
		}
		return true;
	} else if (dobjAction & DOBJ_ACTION_OPEN) {

		// Issue #35: JMS - 2013-10-27 - fire event to clients
		IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_open" );
		if ( pEvent )
		{
			pEvent->SetString( "lane", GetLane() );
			pEvent->SetInt( "team", this->GetTeamNumber() );
			gameeventmanager->FireEvent( pEvent );
		}

		m_timesHit = 0;
		m_bMet = false;
		CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName );
		maker->m_enabled = true;
		PropSetAnim( "Open" );
		return true;
	}
	return false;
}
//---------------------------------------------------------------------------------
// Purpose: Player has said something we only want to ignore it x times
//---------------------------------------------------------------------------------
bool		ManiChatTriggers::ProcessIgnoreX
(
 player_t *player_ptr, 
 chat_trigger_t *chat_trigger_ptr,
 const	char *chat_string, 
 bool teamonly, 
 bool from_event
 )
{
	// This came from an event so just return true
	if (from_event) return true;

	// Check if we should let this one through or not based on this trigger count
	if (chat_trigger_ptr->ignore_count > 0)
	{
		if (chat_trigger_ptr->current_count == chat_trigger_ptr->ignore_count)
		{
			chat_trigger_ptr->current_count = 0;
			return true;
		}
	}

	chat_trigger_ptr->current_count ++;

	// Get CTeam pointer so we can use the proper team name in the log message
	// This will probably blow up on some mod when the CTeam header is changed :/
	// Yup this blows up on hl2mp so I've switched to using the gametypes.txt file
	// instead.

	if (!gpManiGameType->IsValidActiveTeam(player_ptr->team)) return false;

	char *team_name = gpManiGameType->GetTeamLogName(player_ptr->team);

	// Just log the chat in format HLstatsX can recognise

	if ( teamonly )
	{
		UTILLogPrintf( "\"%s<%i><%s><%s>\" say_team \"%s\"\n", player_ptr->name, player_ptr->user_id, player_ptr->steam_id, team_name , chat_string );
	}
	else
	{
		UTILLogPrintf( "\"%s<%i><%s><%s>\" say \"%s\"\n", player_ptr->name, player_ptr->user_id, player_ptr->steam_id, team_name, chat_string );
	}

	// Fire the event so other plugins can see it
	IGameEvent * event = gameeventmanager->CreateEvent( "player_say" );
	if ( event )	// will be null if there are no listeners!
	{
		event->SetInt("userid", player_ptr->user_id );
		event->SetString("text", chat_string );
		event->SetInt("priority", 1 );	// HLTV event priority, not transmitted
		gameeventmanager->FireEvent( event );
	}

	return false;
}
bool CL4DBaseBuiltinVote::UpdateVoteCounts(unsigned int items, CVector<unsigned int> votes, unsigned int totalClients)
{
	IGameEvent *changeEvent = events->CreateEvent("vote_changed");
	changeEvent->SetInt("yesVotes", votes.at(BUILTINVOTES_VOTE_YES));
	changeEvent->SetInt("noVotes", votes.at(BUILTINVOTES_VOTE_NO));
	changeEvent->SetInt("potentialVotes", totalClients);
	events->FireEvent(changeEvent);

	return true;
}
Exemple #16
0
//-----------------------------------------------------------------------------
// Purpose: Create the sparking effect if we're built and ready
//-----------------------------------------------------------------------------
void C_ObjectSapper::ClientThink( void )
{
	IGameEvent *event = gameeventmanager->CreateEvent( "building_info_changed" );
	if ( event )
	{
		event->SetInt( "building_type", OBJ_ATTACHMENT_SAPPER );
		event->SetInt( "object_mode", OBJECT_MODE_NONE );
		gameeventmanager->FireEventClientSide( event );
	}
}
Exemple #17
0
	bool CMultiplayRules::ClientCommand( CBaseEntity *pEdict, const CCommand &args )
	{
		CBasePlayer *pPlayer = ToBasePlayer( pEdict );

		const char *pcmd = args[0];
		if ( FStrEq( pcmd, "voicemenu" ) )
		{
			if ( args.ArgC() < 3 )
				return true;

			CBaseMultiplayerPlayer *pMultiPlayerPlayer = dynamic_cast< CBaseMultiplayerPlayer * >( pPlayer );

			if ( pMultiPlayerPlayer )
			{
				int iMenu = atoi( args[1] );
				int iItem = atoi( args[2] );

				VoiceCommand( pMultiPlayerPlayer, iMenu, iItem );
			}

			return true;
		}
		else if ( FStrEq( pcmd, "achievement_earned" ) )
		{
			CBaseMultiplayerPlayer *pPlayer = static_cast<CBaseMultiplayerPlayer*>( pEdict );
			if ( pPlayer && pPlayer->ShouldAnnounceAchievement() )
			{
				// let's check this came from the client .dll and not the console
				unsigned short mask = UTIL_GetAchievementEventMask();
				int iPlayerID = pPlayer->GetUserID();

				int iAchievement = atoi( args[1] ) ^ mask;
				int code = ( iPlayerID ^ iAchievement ) ^ mask;

				if ( code == atoi( args[2] ) )
				{
					IGameEvent * event = gameeventmanager->CreateEvent( "achievement_earned" );
					if ( event )
					{
						event->SetInt( "player", pEdict->entindex() );
						event->SetInt( "achievement", iAchievement );
						gameeventmanager->FireEvent( event );
					}

					pPlayer->OnAchievementEarned( iAchievement );
				}
			}

			return true;
		}

		return BaseClass::ClientCommand( pEdict, args );

	}
void CASW_Button_Area::ActivateUnlockedButton(CASW_Marine* pMarine)
{
	// don't use the button if we're in the delay between using
	if ( m_fLastButtonUseTime != 0 && gpGlobals->curtime < m_fLastButtonUseTime + m_flWait )
		return;
	if ( !pMarine )
		return;

	if( !RequirementsMet( pMarine ) )
		return;

	if ( m_bIsDoorButton )
	{
		// if the door isn't sealed (or greater than a certain amount of damage?)
		//  then make it open
		CASW_Door* pDoor = GetDoor();
		if ( pDoor )
		{
			if (pDoor->GetSealAmount() > 0)
			{
				//Msg("Door mechanism not responding.  Maintenance Division has been notified of the problem.\n");
			}
			else
			{				
				//Msg("Toggling door...\n");
				variant_t emptyVariant;
				pDoor->AcceptInput("Toggle", pMarine, this, emptyVariant, 0);
			}
		}
	}

	// send our 'activated' output
	m_OnButtonActivated.FireOutput(pMarine, this);

	// Fire event
	IGameEvent * event = gameeventmanager->CreateEvent( "button_area_used" );
	if ( event )
	{
		CASW_Player *pPlayer = pMarine->GetCommander();

		event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
		event->SetInt( "entindex", entindex() );
		gameeventmanager->FireEvent( event );
	}

	m_fLastButtonUseTime = gpGlobals->curtime;

	UpdateWaitingForInput();

	if ( m_bDisableAfterUse )
	{
		UTIL_Remove(this);
	}
}
Exemple #19
0
int ASW_GiveAmmo( CASW_Marine *pMarine, float flCount, const char *pszAmmoName, CBaseEntity *pAmmoEntity, bool bSuppressSound = false )
{
	int iAmmoType = GetAmmoDef()->Index(pszAmmoName);
	if ( iAmmoType == -1 )
	{
		Msg("ERROR: Attempting to give unknown ammo type (%s)\n",pszAmmoName);
		return 0;
	}

	int amount = pMarine->GiveAmmo( flCount, iAmmoType, bSuppressSound );
	if ( amount == 0 )
		amount = pMarine->GiveAmmoToAmmoBag( flCount, iAmmoType, bSuppressSound );

	if ( amount > 0 )
	{
		pMarine->TookAmmoPickup( pAmmoEntity );

		// Check the ammo type... for some doing a spilling bullet effect isn't fictionally appropriate
		if ( iAmmoType != GetAmmoDef()->Index( "ASW_F" ) && iAmmoType != GetAmmoDef()->Index( "ASW_ML" ) && iAmmoType != GetAmmoDef()->Index( "ASW_TG" ) && iAmmoType != GetAmmoDef()->Index( "ASW_GL" ) )
		{
			// Do effects
			int iAmmoCost = CASW_Ammo_Drop_Shared::GetAmmoUnitCost( iAmmoType );

			if ( iAmmoCost < 20 )
			{
				pAmmoEntity->EmitSound( "ASW_Ammobag.Pickup_sml" );
				DispatchParticleEffect( "ammo_satchel_take_sml", pAmmoEntity->GetAbsOrigin() + Vector( 0, 0, 4 ), vec3_angle );
			}
			else if ( iAmmoCost < 75 )
			{
				pAmmoEntity->EmitSound( "ASW_Ammobag.Pickup_med" );
				DispatchParticleEffect( "ammo_satchel_take_med", pAmmoEntity->GetAbsOrigin() + Vector( 0, 0, 4 ), vec3_angle );
			}
			else
			{
				pAmmoEntity->EmitSound( "ASW_Ammobag.Pickup_lrg" );
				DispatchParticleEffect( "ammo_satchel_take_lrg", pAmmoEntity->GetAbsOrigin() + Vector( 0, 0, 4 ), vec3_angle );
			}
		}

		IGameEvent * event = gameeventmanager->CreateEvent( "ammo_pickup" );
		if ( event )
		{
			CASW_Player *pPlayer = pMarine->GetCommander();
			event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
			event->SetInt( "entindex", pMarine->entindex() );

			gameeventmanager->FireEvent( event );
		}
	}

	return amount;
}
void CHL2MP_Player::UpdateAchievement(char *name, int amount)
{
	if(sv_cheats->GetInt() != 0)
		return;
	IGameEvent* pEvent = gameeventmanager->CreateEvent("player_update_achiev", true);
	if(pEvent)
	{
		pEvent->SetInt("userid", this->GetUserID());
		pEvent->SetString("name", name);
		pEvent->SetInt("amount", amount);
		gameeventmanager->FireEvent(pEvent);
	}
}
void CGameDomCaptureZone::CaptureZoneTouch(CBaseEntity *pEntity)
{
	CBasePlayer *pPlayer = ToBasePlayer(pEntity);
	if(!pPlayer)
		return;
	if(pPlayer->m_lifeState != LIFE_ALIVE)
		return;
	if(m_iZoneID == -1)
		return;

	if(HL2MPRules()->m_iDomZones[m_iZoneID] == pPlayer->GetTeamNumber())
		return; // Déjà capturé par cette équipe

	if(gpGlobals->curtime < m_flLastCapture + 2.0f)
		return;
	m_flLastCapture = gpGlobals->curtime;
	HL2MPRules()->ResetDomTimer();
	EmitSound("Gameplay.Domambient");

	// Petite boucle moche pour reset toutes les zones
	CBaseEntity *pEntity2 = gEntList.FirstEnt();
	while( pEntity2 )
	{
		if(FClassnameIs(pEntity2, "game_dom_capturezone"))
		{
			CGameDomCaptureZone *pZone = dynamic_cast<CGameDomCaptureZone*>(pEntity2);
			pZone->ResetScoreTimer();
		}

		pEntity2 = gEntList.NextEnt( pEntity2 );
	}

	HL2MPRules()->m_iDomZones[m_iZoneID] = pPlayer->GetTeamNumber();
	if(pPlayer->GetTeamNumber() == TEAM_PINK)
		m_OnPinkCapture.FireOutput(pPlayer, this);
	else
		m_OnGreenCapture.FireOutput(pPlayer, this);

	DevMsg("Zone %d captured by team %d\n", m_iZoneID, pPlayer->GetTeamNumber());

	IGameEvent *event = gameeventmanager->CreateEvent( "player_death" );
	if( event )
	{
		event->SetInt("userid", 0 );
		event->SetInt("attacker", pPlayer->GetUserID() );
		event->SetString("weapon", "domcapture" );
		gameeventmanager->FireEvent( event );
	}
}
void CASW_Health_Regen::SetMarineHealth(CASW_Marine *pMarine, int iHealth)
{
	if (pMarine)
	{
		// Ch1ckensCoop: Fire event for statistics
		IGameEvent * pEvent = gameeventmanager->CreateEvent( "marine_regenerated" );
		if (pEvent)
		{
			pEvent->SetInt("marine", pMarine->entindex());
			pEvent->SetInt("amount", iHealth - pMarine->GetHealth());
		}

		pMarine->SetHealth(iHealth);
	}
}
bool CASW_Button_Area::WaitingForInputVismonCallback( CBaseEntity *pVisibleEntity, CBasePlayer *pViewingPlayer )
{
	CASW_Button_Area *pButtonArea = static_cast< CASW_Button_Area* >( pVisibleEntity );
	IGameEvent * event = gameeventmanager->CreateEvent( "button_area_active" );
	if ( event )
	{
		event->SetInt( "userid", pViewingPlayer->GetUserID() );
		event->SetInt( "entindex", pButtonArea->entindex() );
		event->SetInt( "prop", pButtonArea->m_hPanelProp.Get() ? pButtonArea->m_hPanelProp.Get()->entindex() : pButtonArea->entindex() );
		event->SetBool( "locked", pButtonArea->IsLocked() );
		gameeventmanager->FireEvent( event );
	}

	return false;
}
Exemple #24
0
//---------------------------------------------------------
//---------------------------------------------------------
void CInfoGameEventProxy::InputGenerateGameEvent( inputdata_t &inputdata )
{
	CBasePlayer *pActivator = ToBasePlayer( inputdata.pActivator );

	IGameEvent *event = gameeventmanager->CreateEvent( m_iszEventName.ToCStr() );
	if ( event )
	{
		if ( pActivator )
		{
			event->SetInt( "userid", pActivator->GetUserID() );
		}
		event->SetInt( "subject", entindex() );
		gameeventmanager->FireEvent( event );
	}
}
Exemple #25
0
void CGameRules::ClientSettingsChanged( CBasePlayer *pPlayer )
{
	const char *pszName = engine->GetClientConVarValue( pPlayer->entindex(), "name" );

	const char *pszOldName = pPlayer->GetPlayerName();

	// msg everyone if someone changes their name,  and it isn't the first time (changing no name to current name)
	// Note, not using FStrEq so that this is case sensitive
	if ( pszOldName[0] != 0 && Q_strcmp( pszOldName, pszName ) )
	{
		char text[256];
		Q_snprintf( text,sizeof(text), "%s changed name to %s\n", pszOldName, pszName );

		UTIL_ClientPrintAll( HUD_PRINTTALK, text );

		IGameEvent * event = gameeventmanager->CreateEvent( "player_changename" );
		if ( event )
		{
			event->SetInt( "userid", pPlayer->GetUserID() );
			event->SetString( "oldname", pszOldName );
			event->SetString( "newname", pszName );
			gameeventmanager->FireEvent( event );
		}
		
		pPlayer->SetPlayerName( pszName );
	}
} 
//-----------------------------------------------------------------------------
// Purpose: Input handler for showing the message and/or playing the sound.
//-----------------------------------------------------------------------------
void CPointEventProxy::InputGenerateEvent( inputdata_t &inputdata )
{
	IGameEvent * event = gameeventmanager->CreateEvent( m_iszEventName.ToCStr() );
	if ( event )
	{
		CBasePlayer *pActivator = NULL;

#ifdef INFESTED_DLL
		CASW_Marine *pMarine = dynamic_cast< CASW_Marine* >( inputdata.pActivator );
		if ( pMarine )
		{
			pActivator = pMarine->GetCommander();
		}
#else
		pActivator = dynamic_cast< CBasePlayer* >( inputdata.pActivator );
#endif

		if ( m_bActivatorAsUserID )
		{
			event->SetInt( "userid", ( pActivator ? pActivator->GetUserID() : 0 ) );
		}

		gameeventmanager->FireEvent( event );
	}
}
void CGameClient::Disconnect( const char *fmt, ... )
{
	va_list		argptr;
	char		reason[1024];

	if ( m_nSignonState == SIGNONSTATE_NONE )
		return;	// no recursion

	va_start (argptr,fmt);
	Q_vsnprintf (reason, sizeof( reason ), fmt,argptr);
	va_end (argptr);

	// notify other clients of player leaving the game
	// send the username and network id so we don't depend on the CBasePlayer pointer
	IGameEvent *event = g_GameEventManager.CreateEvent( "player_disconnect" );

	if ( event )
	{
		event->SetInt("userid", GetUserID() );
		event->SetString("reason", reason );
		event->SetString("name", GetClientName() );
		event->SetString("networkid", GetNetworkIDString() ); 
		g_GameEventManager.FireEvent( event );
	}

	m_Server->RemoveClientFromGame( this );

	CBaseClient::Disconnect( "%s", reason );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void Dota_Resupply::Spawn( void )
{
	Precache();

	BaseClass::Spawn();

	SetModel( STRING( GetModelName() ) );
	SetMoveType( MOVETYPE_NONE );
	SetSolid( SOLID_VPHYSICS );
	CreateVPhysics();

	ResetSequence( LookupSequence( "Idle" ) );
	SetBodygroup( 1, true );

	m_flCloseTime = gpGlobals->curtime;
	m_flAnimTime = gpGlobals->curtime;
	m_flPlaybackRate = 0.0;
	SetCycle( 0 );

	m_takedamage = DAMAGE_EVENTS_ONLY;

	// Issue #28: JMS - 2013-10-12 - ammobox needs to fire a new modevent letting all clients know that one is spawned
	IGameEvent *pEvent = gameeventmanager->CreateEvent( "ammobox_spawn" );
	if ( pEvent )
	{
		pEvent->SetInt( "entindex", entindex() );
		gameeventmanager->FireEvent( pEvent );
	}
}
Exemple #29
0
void CHLTVDirector::StartInstantBroadcastShot()
{
	m_nNextShotTick = m_nBroadcastTick + TIME_TO_TICKS( MAX_SHOT_LENGTH );

	if ( m_iCameraManIndex > 0 )
	{
		// camera man is still recording and live, resend camera man message
		IGameEvent *msg = gameeventmanager->CreateEvent( "hltv_cameraman", true );
		if ( msg )
		{
			msg->SetInt("index", m_iCameraManIndex );
			m_pHLTVServer->BroadcastEvent( msg );
			gameeventmanager->FreeEvent( msg );

			m_iPVSEntity = m_iCameraManIndex;
			m_nNextShotTick = m_nBroadcastTick+TIME_TO_TICKS( MIN_SHOT_LENGTH ); 
		}
	}
	else
	{
		RemoveEventsFromHistory(-1); // all

		AnalyzePlayers();

		AnalyzeCameras();

		StartRandomShot();
	}
}
Exemple #30
0
bool CHLTVDirector::SetCameraMan( int iPlayerIndex )
{
	if ( !tv_allow_camera_man.GetBool() )
		return false;

	if ( m_iCameraManIndex == iPlayerIndex )
		return true;

	// check if somebody else is already the camera man
	if ( m_iCameraManIndex != 0 && iPlayerIndex != 0 )
		return false;

	CBasePlayer *pPlayer = NULL;

	if ( iPlayerIndex > 0 )
	{
		pPlayer = UTIL_PlayerByIndex( iPlayerIndex );
		if ( !pPlayer || pPlayer->GetTeamNumber() != TEAM_SPECTATOR )
			return false;
	}

	m_iCameraManIndex = iPlayerIndex;

	// create event for director event history
	IGameEvent *event = gameeventmanager->CreateEvent( "hltv_cameraman" );
	if ( event )
	{
		event->SetInt("index", iPlayerIndex );
		gameeventmanager->FireEvent( event );
	}

	CRecipientFilter filter;

	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );

		if ( pPlayer && pPlayer->GetTeamNumber() == TEAM_SPECTATOR && !pPlayer->IsFakeClient() )
		{
			filter.AddRecipient( pPlayer );
		}
	}

	filter.MakeReliable();
	
	if ( iPlayerIndex > 0 )
	{
		// tell all spectators that the camera is avaliable again.
		char szText[200];
		Q_snprintf( szText, sizeof(szText), "SourceTV camera is now controlled by %s.", pPlayer->GetPlayerName() );
		UTIL_ClientPrintFilter( filter, HUD_PRINTTALK, szText );
	}
	else
	{
		// tell all spectators that the camera is avaliable again.
		UTIL_ClientPrintFilter( filter, HUD_PRINTTALK, "SourceTV camera switched to auto-director mode." );
	}
	
	return true;
}