bool UTIL_KickBotFromTeam(TeamName kickTeam) { int i; // try to kick a dead bot first for (i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); if (player == NULL) continue; if (FNullEnt(player->pev)) continue; const char *name = STRING(player->pev->netname); if (FStrEq(name, "")) continue; if (!player->IsBot()) continue; if (!player->IsAlive() && player->m_iTeam == kickTeam) { // its a bot on the right team - kick it SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(player->pev->netname))); return true; } } // no dead bots, kick any bot on the given team for (i = 1; i <= gpGlobals->maxClients; ++i) { CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i)); if (player == NULL) continue; if (FNullEnt(player->pev)) continue; const char *name = STRING(player->pev->netname); if (FStrEq(name, "")) continue; if (!player->IsBot()) continue; if (player->m_iTeam == kickTeam) { // its a bot on the right team - kick it SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(player->pev->netname))); return true; } } return false; }
void CASW_Arena::UpdateArena() { // has arena mode just been turned on? if ( !m_bStartedArenaMode ) { for ( int i=0; i< m_ArenaAliens.Count(); i++ ) { UTIL_PrecacheOther( m_ArenaAliens[i]->m_szAlienClass ); } m_bStartedArenaMode = true; m_ArenaRestTimer.Start( 3.0f ); } if ( m_ArenaShuffleWallsTimer.HasStarted() && m_ArenaShuffleWallsTimer.IsElapsed() ) { TeleportPlayersToSpawn(); ShuffleArenaWalls(); m_ArenaShuffleWallsTimer.Invalidate(); m_ArenaRestTimer.Start( 2.5f ); } if ( m_ArenaRestTimer.HasStarted() && m_ArenaRestTimer.IsElapsed() ) { SpawnArenaWave(); m_ArenaRestTimer.Invalidate(); } if ( m_ArenaCheckTimer.HasStarted() && m_ArenaCheckTimer.IsElapsed() ) { // count live aliens CBaseEntity* pEntity = NULL; int iAliens = 0; while ((pEntity = gEntList.NextEnt( pEntity )) != NULL) { if ( pEntity && pEntity->IsNPC() && pEntity->Classify() != CLASS_ASW_MARINE && pEntity->GetHealth() > 0 ) iAliens++; } if ( iAliens <= 0 && !m_ArenaRestTimer.HasStarted() && !m_ArenaShuffleWallsTimer.HasStarted() ) { RefillMarineAmmo(); if ( asw_arena_shuffle_walls.GetInt() > 0 && ( m_iArenaWave % asw_arena_shuffle_walls.GetInt() ) == 0 && ( m_iArenaWave != 0 ) ) { UTIL_CenterPrintAll( UTIL_VarArgs("Wave %d clear!\nThe arena is changing...", m_iArenaWave ) ); m_ArenaShuffleWallsTimer.Start( 5.0f ); } else { UTIL_CenterPrintAll( UTIL_VarArgs("Wave %d clear!", m_iArenaWave ) ); m_ArenaRestTimer.Start( RandomFloat( 8, 12 ) ); } m_ArenaCheckTimer.Invalidate(); } } }
int DotaObjective::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { if ( m_bMet ) return 0; if ( !(inputInfo.GetDamageType() & DMG_BULLET) ) { CHL2MP_Player * playerAttacker = ToHL2MPPlayer( inputInfo.GetAttacker() ); CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); if ( !maker ) AssertMsg( false, "Objective can't find its creepmaker!\n" ); CAI_BaseNPC * guardian = (CAI_BaseNPC*)gEntList.FindEntityByName( NULL, m_guardianName ); if( guardian && guardian->IsAlive() ) { if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("The guradian is alive in this lane, you can't hurt the gate.\n") ); } else { m_timesHit++; m_timesHit = min(m_timesHit, OBJECTIVE_HEALTHI); // make sure times hit never goes above the maximum times an objective can be hit! CRecipientFilter user; user.AddRecipientsByTeam( this->GetTeam() ); user.MakeReliable(); char szText[200]; Q_snprintf( szText, sizeof(szText), "Your ally gate is under attack from an enemy!" ); UTIL_ClientPrintFilter( user, HUD_PRINTCENTER, szText ); if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("Gate has %i health left.\n", OBJECTIVE_HEALTHI - m_timesHit) ); if (m_timesHit >= OBJECTIVE_HEALTHI) { TakeAction(DOBJ_ACTION_CLOSE); } else { IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_attacked" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); pEvent->SetFloat( "health", (OBJECTIVE_HEALTHF - m_timesHit)/OBJECTIVE_HEALTHF ); gameeventmanager->FireEvent( pEvent ); } } } } return 0; }
void CPointServerCommand::Execute(const char *command) { if (!IS_DEDICATED_SERVER()) { // potentially dangerous for untrusted maps // so try to use it for passing through filtered svc_stufftext CLIENT_COMMAND(INDEXENT(1), UTIL_VarArgs("%s\n", command)); return; } SERVER_COMMAND(UTIL_VarArgs("%s\n", command)); }
/* ======================== ClientUserInfoChanged called after the player changes userinfo - gives dll a chance to modify it before it gets sent into the rest of the engine. ======================== */ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) { // Is the client spawned yet? if ( !pEntity->pvPrivateData ) return; // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) if ( pEntity->v.netname && STRING(pEntity->v.netname)[0] != 0 && !FStrEq( STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" )) ) { char sName[256]; char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ); strncpy( sName, pName, sizeof(sName) - 1 ); sName[ sizeof(sName) - 1 ] = '\0'; // First parse the name and remove any %'s for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ ) { // Replace it with a space if ( *pApersand == '%' ) *pApersand = ' '; } // Set the name g_engfuncs.pfnSetClientKeyValue( ENTINDEX(pEntity), infobuffer, "name", sName ); char text[256]; sprintf( text, "* %s changed name to %s\n", STRING(pEntity->v.netname), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX(pEntity) ); WRITE_STRING( text ); MESSAGE_END(); UTIL_LogPrintf( "\"%s<%i><%s><%i>\" changed name to \"%s\"\n", STRING( pEntity->v.netname ), GETPLAYERUSERID( pEntity ), GETPLAYERAUTHID( pEntity ), GETPLAYERUSERID( pEntity ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); } g_pGameRules->ClientUserInfoChanged( GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer ); // Override model if ( (!strcmp( "models/player/female/female.mdl", g_engfuncs.pfnInfoKeyValue( infobuffer, "model" ) )) )//&& (!strcmp( "models/player/hgrunt/hgrunt.mdl" )) ) SET_MODEL( pEntity, "models/player/male/male.mdl" ); g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "model", "male" ); // Set colors int iHue = GetHueFromRGB( g_iaDiscColors[ pEntity->v.team][0] / 255, g_iaDiscColors[pEntity->v.team][1] / 255, g_iaDiscColors[pEntity->v.team][2] / 255 ); g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "topcolor", UTIL_VarArgs("%d", iHue) ); g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "bottomcolor", UTIL_VarArgs("%d", iHue - 10) ); }
void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) { // notify other clients of player joining the game UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", ( pl->pev->netname && STRING(pl->pev->netname)[0] != 0 ) ? STRING(pl->pev->netname) : "unconnected" ) ); UTIL_LogPrintf( "%s entered the game\n", GetLogStringForPlayer( pl->edict() ).c_str() ); pl->EffectivePlayerClassChanged(); SendMOTDToClient( pl->edict() ); // loop through all active players and send their score info to the new client for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex( i ); if ( plr ) { plr->EffectivePlayerClassChanged(); } } if ( g_fGameOver ) { MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, NULL, pl->edict() ); MESSAGE_END(); } }
void CNPC_Monster::DeathSound(const CTakeDamageInfo &info ) { if ( !( info.GetDamageType() & ( DMG_BLAST | DMG_ALWAYSGIB) ) ) { EmitSound(UTIL_VarArgs("NPC_%s.Die", cSoundScript.ToCStr())); } }
//----------------------------------------------------------------------------- // Purpose: Sound of a footstep //----------------------------------------------------------------------------- void CNPC_Monster::FootstepSound( bool fRightFoot ) { if( fRightFoot ) { EmitSound(UTIL_VarArgs("NPC_%s.FootstepRight", cSoundScript.ToCStr())); } else { EmitSound(UTIL_VarArgs("NPC_%s.FootstepLeft", cSoundScript.ToCStr())); } if( ShouldPlayFootstepMoan() ) { m_flNextMoanSound = gpGlobals->curtime; } }
/** * Kick a bot from the given team. If no bot exists on the team, return false. */ bool UTIL_KickBotFromTeam( int kickTeam ) { int i; // try to kick a dead bot first for ( i = 1; i <= gpGlobals->maxClients; ++i ) { CBasePlayer *player = static_cast<CBasePlayer *>( UTIL_PlayerByIndex( i ) ); if (player == NULL) continue; if (!player->IsBot()) continue; if (!player->IsAlive() && player->GetTeamNumber() == kickTeam) { // its a bot on the right team - kick it engine->ServerCommand( UTIL_VarArgs( "kick \"%s\"\n", player->GetPlayerName() ) ); return true; } } // no dead bots, kick any bot on the given team for ( i = 1; i <= gpGlobals->maxClients; ++i ) { CBasePlayer *player = static_cast<CBasePlayer *>( UTIL_PlayerByIndex( i ) ); if (player == NULL) continue; if (!player->IsBot()) continue; if (player->GetTeamNumber() == kickTeam) { // its a bot on the right team - kick it engine->ServerCommand( UTIL_VarArgs( "kick \"%s\"\n", player->GetPlayerName() ) ); return true; } } return false; }
void CReplayManager::AddMatchEvent(match_event_t type, int team, CSDKPlayer *pPlayer1, CSDKPlayer *pPlayer2/* = NULL*/, CSDKPlayer *pPlayer3/* = NULL*/) { MatchEvent *pMatchEvent = new MatchEvent; if (type == MATCH_EVENT_GOAL || type == MATCH_EVENT_OWNGOAL || type == MATCH_EVENT_MISS || type == MATCH_EVENT_KEEPERSAVE || type == MATCH_EVENT_REDCARD) { float replayStartTime = GetReplayStartTime() + 1.0f; for (int i = 0; i < m_Snapshots.Count(); i++) { if (m_Snapshots[i]->snaptime >= replayStartTime) { pMatchEvent->snapshots.AddToTail(m_Snapshots[i]); m_Snapshots[i]->replayCount += 1; } } pMatchEvent->snapshotEndTime = gpGlobals->curtime + 1.0f; } else pMatchEvent->snapshotEndTime = 0; pMatchEvent->matchPeriod = SDKGameRules()->State_Get(); pMatchEvent->matchEventType = type; pMatchEvent->second = SDKGameRules()->GetMatchDisplayTimeSeconds(); pMatchEvent->team = team; pMatchEvent->atMinGoalPos = GetMatchBall()->GetPos().y < SDKGameRules()->m_vKickOff.GetY(); pMatchEvent->pPlayer1Data = pPlayer1 ? pPlayer1->GetPlayerData() : NULL; pMatchEvent->pPlayer2Data = pPlayer2 ? pPlayer2->GetPlayerData() : NULL; pMatchEvent->pPlayer3Data = pPlayer3 ? pPlayer3->GetPlayerData() : NULL; m_MatchEvents.AddToTail(pMatchEvent); if (type == MATCH_EVENT_GOAL || type == MATCH_EVENT_OWNGOAL || type == MATCH_EVENT_YELLOWCARD || type == MATCH_EVENT_SECONDYELLOWCARD || type == MATCH_EVENT_REDCARD) { char matchEventPlayerNames[MAX_MATCH_EVENT_PLAYER_NAME_LENGTH] = {}; if (pPlayer1 && !pPlayer2 && !pPlayer3) Q_strncpy(matchEventPlayerNames, UTIL_VarArgs("%s", pPlayer1->GetPlayerName()), MAX_MATCH_EVENT_PLAYER_NAME_LENGTH); else if (pPlayer1 && pPlayer2 && !pPlayer3) Q_strncpy(matchEventPlayerNames, UTIL_VarArgs("%.15s (%.15s)", pPlayer1->GetPlayerName(), pPlayer2->GetPlayerName()), MAX_MATCH_EVENT_PLAYER_NAME_LENGTH); else if (pPlayer1 && pPlayer2 && pPlayer3) Q_strncpy(matchEventPlayerNames, UTIL_VarArgs("%.10s (%.10s, %.10s)", pPlayer1->GetPlayerName(), pPlayer2->GetPlayerName(), pPlayer3->GetPlayerName()), MAX_MATCH_EVENT_PLAYER_NAME_LENGTH); GetGlobalTeam(pMatchEvent->team)->AddMatchEvent(pMatchEvent->matchPeriod, pMatchEvent->second, pMatchEvent->matchEventType, matchEventPlayerNames); } }
qboolean OnClientConnectPost( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) { if( Initialized && sv_allowdownload->value > 0 ) { if( cvar_enable_debug->value > 0 ) { ModuleDebug.append( UTIL_VarArgs( "\n\"%s\" (index = %d, address = %s) is connecting.\n", pszName, ENTINDEX( pEntity ), pszAddress ) ); } if( rm_enable_downloadfix.value <= 0 ) { NotifyClientDisconnectHook->Restore(); RETURN_META_VALUE( MRES_IGNORED, TRUE ); } else { NotifyClientDisconnectHook->Patch(); } char ip[ 16 ]; uint32 player = ENTINDEX( pEntity ); time_t timeSystem = getSysTime(); time_t* nextReconnectTime = &PlayerNextReconnectTime[ player ]; String* currentPlayerIp = &PlayerCurrentIp[ player ]; // Retrieve server IP one time from there because // we need to let server.cfg be executed in case // a specific ip is provided and because I have not // found forward to use to put this call at this time. retrieveServerIp( &ServerInternetIp ); // Retrieve the current client's IP without the port. retrieveClientIp( ip, pszAddress ); // Sanity IP address check to make sure the index // is our expected player. If not, we consider it // as a new player and we reset variables to the default. if( currentPlayerIp->compare( ip ) ) { *nextReconnectTime = 0; currentPlayerIp->clear(); currentPlayerIp->assign( ip ); } // We are allowed to reconnect the player. // We put a cool down of 3 seconds minimum to avoid possible // infinite loop since depending where it will download resources, // it can connect/disconnect several times. if( *nextReconnectTime < timeSystem ) { *nextReconnectTime = timeSystem + 3; CLIENT_COMMAND( pEntity, "Connect %s %d\n", isLocalIp( ip ) ? ServerLocalIp.c_str() : ServerInternetIp.c_str(), RANDOM_LONG( 1, 9999 ) ); } } RETURN_META_VALUE( MRES_IGNORED, TRUE ); }
void CHalfLifeMultiplay :: InitHUD( CBasePlayer *pl ) { // notify other clients of player joining the game UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", ( pl->pev->netname && STRING(pl->pev->netname)[0] != 0 ) ? STRING(pl->pev->netname) : "unconnected" ) ); #if !defined( THREEWAVE ) UTIL_LogPrintf( "\"%s<%i><%s><%i>\" entered the game\n", STRING( pl->pev->netname ), GETPLAYERUSERID( pl->edict() ), GETPLAYERAUTHID( pl->edict() ), GETPLAYERUSERID( pl->edict() ) ); #else UTIL_LogPrintf( "\"%s<%i><%s><%s>\" entered the game\n", STRING( pl->pev->netname ), GETPLAYERUSERID( pl->edict() ), GETPLAYERAUTHID( pl->edict() ), GetTeamName( pl->pev->team ) ); #endif UpdateGameMode( pl ); // sending just one score makes the hud scoreboard active; otherwise // it is just disabled for single play MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); WRITE_BYTE( ENTINDEX(pl->edict()) ); WRITE_SHORT( 0 ); WRITE_SHORT( 0 ); WRITE_SHORT( 0 ); MESSAGE_END(); SendMOTDToClient( pl->edict() ); // loop through all active players and send their score info to the new client for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex( i ); if ( plr ) { MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); WRITE_BYTE( i ); // client number WRITE_SHORT( plr->pev->frags ); WRITE_SHORT( plr->m_iDeaths ); WRITE_SHORT( plr->pev->team ); MESSAGE_END(); } } if ( g_fGameOver ) { MESSAGE_BEGIN( MSG_ONE, SVC_INTERMISSION, NULL, pl->edict() ); MESSAGE_END(); } }
//----------------------------------------------------------------------------- // Purpose: Play a random idle sound. //----------------------------------------------------------------------------- void CNPC_Monster::IdleSound( void ) { // HACK: base zombie code calls IdleSound even when not idle! if ( m_NPCState != NPC_STATE_COMBAT ) { BreatheOffShort(); EmitSound(UTIL_VarArgs("NPC_%s.Idle", cSoundScript.ToCStr())); } }
static int sourceop_saytextall(lua_State *L) { const char *pText = luaL_checkstring(L, 1); int playerIndex = luaL_optinteger(L, 2, 0); pAdminOP.SetSayTextPlayerIndex(playerIndex); pAdminOP.SayTextAllChatHud(UTIL_VarArgs("[%s] %s", pAdminOP.adminname, pText)); return 0; }
//----------------------------------------------------------------------------- // Purpose: Play a random pain sound. //----------------------------------------------------------------------------- void CNPC_Monster::PainSound( const CTakeDamageInfo &info ) { // Don't make pain sounds too often. if ( m_flNextPainSoundTime <= gpGlobals->curtime ) { //BreatheOffShort(); EmitSound(UTIL_VarArgs("NPC_%s.Pain", cSoundScript.ToCStr())); m_flNextPainSoundTime = gpGlobals->curtime + random->RandomFloat( 4.0, 7.0 ); } }
// Display all the Team Scores void TeamFortress_TeamShowScores(BOOL bLong, CBasePlayer *pPlayer) { for (int i = 1; i < g_Teams.Count(); i++) { if (!bLong) { // Dump short scores UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs("%s: %d\n", g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) ); } else { // Dump long scores if (pPlayer == NULL) UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs("Team %d (%s): %d\n", i, g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) ); else // Print to just one client ClientPrint( pPlayer, HUD_PRINTNOTIFY, UTIL_VarArgs("Team %d (%s): %d\n", i, g_szTeamColors[i], GetGlobalTeam(i)->GetScore()) ); } } }
void CBaseCombatWeapon::MakeWeaponNameFromEntity( CBaseEntity *pOther ) { // If I have a name, make my weapon match it with "_weapon" appended if ( pOther->GetEntityName() != NULL_STRING ) { const char *pMarineName = STRING( pOther->GetEntityName() ); const char *pError = UTIL_VarArgs( "%s_weapon", pMarineName ); string_t pooledName = AllocPooledString( pError ); SetName( pooledName ); } }
//----------------------------------------------------------------------------- // Purpose: Return data about the npc, if found. //----------------------------------------------------------------------------- KeyValues *CNPC_Monster::pkvNPCData( const char *szScript ) { KeyValues *pkvData = new KeyValues( "NPCDATA" ); if ( pkvData->LoadFromFile( filesystem, UTIL_VarArgs( "resource/data/npcs/%s.txt", szScript ), "MOD" ) ) { return pkvData; } pkvData->deleteThis(); return NULL; }
//========================================================= //========================================================= BOOL CHalfLifeMultiplay :: ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) { g_VoiceGameMgr.ClientConnected(pEntity); // Increase their speed to the Discwar speed MESSAGE_BEGIN( MSG_ONE, SVC_STUFFTEXT, NULL, pEntity ); WRITE_STRING( UTIL_VarArgs("cl_forwardspeed %d\ncl_backspeed %d\ncl_sidespeed %d\n", 320, 320, 320) ); MESSAGE_END(); return TRUE; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPointDevShotCamera::DevShotThink_TakeShot( void ) { // Take the screenshot CBasePlayer *pPlayer = UTIL_GetLocalPlayerOrListenServerHost(); if ( !pPlayer ) return; engine->ClientCommand( pPlayer->edict(), UTIL_VarArgs( "devshots_screenshot \"%s\"", STRING(m_iszCameraName) ) ); // Now take the shot next frame SetThink( &CPointDevShotCamera::DevShotThink_PostShot ); SetNextThink( gpGlobals->curtime + (DEVSHOT_INTERVAL - 1) ); }
void DebugThink( void ) { Vector vecRadius( m_flLightRadius, m_flLightRadius, m_flLightRadius ); NDebugOverlay::Box( GetAbsOrigin(), -vecRadius, vecRadius, 255,255,255, 8, 0.1 ); NDebugOverlay::Box( GetAbsOrigin(), -Vector(5,5,5), Vector(5,5,5), 255,0,0, 8, 0.1 ); SetNextThink( gpGlobals->curtime + 0.1 ); int textoffset = 0; EntityText( textoffset, UTIL_VarArgs("Org: %.2f %.2f %.2f", GetAbsOrigin().x, GetAbsOrigin().y, GetAbsOrigin().z ), 0.1 ); textoffset++; EntityText( textoffset, UTIL_VarArgs("Radius %.2f", m_flLightRadius), 0.1 ); textoffset++; if ( m_bIgnoreLOS ) { EntityText( textoffset, "Ignoring LOS", 0.1 ); textoffset++; } if ( m_bDisabled ) { EntityText( textoffset, "DISABLED", 0.1 ); textoffset++; } }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void AvHLUA_OnError(const char *errorMsg) { std::string msg; #ifdef AVH_CLIENT msg = "[LUA CLIENT] Error: "; msg += errorMsg; msg += "\n"; gEngfuncs.pfnConsolePrint(msg.c_str()); #else msg += "[LUA] Error: "; msg += errorMsg; msg += "\n"; ALERT(at_console, UTIL_VarArgs("%s", msg.c_str())); #endif }
//----------------------------------------------------------------------------- // Purpose: Read in the chance of firing each output //----------------------------------------------------------------------------- bool CLogicRandomOutputs::KeyValue( const char *szKeyName, const char *szValue ) { if ( szValue && szValue[0] ) { for ( int i=0; i < NUM_RANDOM_OUTPUTS; i++ ) { if ( FStrEq( szKeyName, UTIL_VarArgs( "OnTriggerChance%d", i ) ) ) { m_flOnTriggerChance[i] = atof( szValue ); return true; } } } return BaseClass::KeyValue( szKeyName, szValue ); }
//----------------------------------------------------------------------------- // Purpose: // Input : *filename - //----------------------------------------------------------------------------- void *CBaseFlex::FindSceneFile( const char *filename ) { // See if it's already loaded int i; for ( i = 0; i < m_FileList.Size(); i++ ) { CFacialExpressionFile *file = m_FileList[ i ]; if ( file && !stricmp( file->filename, filename ) ) { return file->buffer; } } // Load file into memory FileHandle_t file = filesystem->Open( UTIL_VarArgs( "expressions/%s.vfe", filename ), "rb" ); if ( !file ) return NULL; int len = filesystem->Size( file ); // read the file byte *buffer = new unsigned char[ len ]; Assert( buffer ); filesystem->Read( buffer, len, file ); filesystem->Close( file ); // Create scene entry CFacialExpressionFile *pfile = new CFacialExpressionFile(); // Remember filename Q_strncpy( pfile->filename, filename ,sizeof(pfile->filename)); // Remember data pointer pfile->buffer = buffer; // Add to list m_FileList.AddToTail( pfile ); // Fill in translation table flexsettinghdr_t *pSettinghdr = ( flexsettinghdr_t * )pfile->buffer; Assert( pSettinghdr ); for (i = 0; i < pSettinghdr->numkeys; i++) { *(pSettinghdr->pLocalToGlobal(i)) = FindFlexController( pSettinghdr->pLocalName( i ) ); } // Return data return pfile->buffer; }
//----------------------------------------------------------------------------- // Purpose: loads per-map manifest! //----------------------------------------------------------------------------- void ParseParticleEffectsMap( const char *pMapName, bool bLoadSheets ) { MEM_ALLOC_CREDIT(); g_pParticleSystemMgr->ShouldLoadSheets( bLoadSheets ); CUtlVector<CUtlString> files; const char *mapManifestFilename = NULL; if ( pMapName && *pMapName ) { #ifdef CLIENT_DLL #define UTIL_VarArgs VarArgs //Tony; goddamnit. #endif mapManifestFilename = UTIL_VarArgs( "particles/particles_%s.txt", pMapName ); } // Open the manifest file, and read the particles specified inside it KeyValues *manifest = new KeyValues( mapManifestFilename ); if ( manifest->LoadFromFile( filesystem, mapManifestFilename, "GAME" ) ) { for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() ) { if ( !Q_stricmp( sub->GetName(), "file" ) ) { files.AddToTail( sub->GetString() ); continue; } Warning( "CParticleMgr::LevelInit: Manifest '%s' with bogus file type '%s', expecting 'file'\n", mapManifestFilename, sub->GetName() ); } } else //Tony; don't print a warning, and don't proceed any further if the file doesn't exist! return; int nCount = files.Count(); for ( int i = 0; i < nCount; ++i ) { g_pParticleSystemMgr->ReadParticleConfigFile( files[i], true, true ); } g_pParticleSystemMgr->DecommitTempMemory(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_Monster::Precache( void ) { PrecacheModel( cModel.ToCStr() ); PrecacheScriptSound( UTIL_VarArgs( "NPC_%s.Die", cSoundScript.ToCStr() ) ); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.Idle", cSoundScript.ToCStr())); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.Pain", cSoundScript.ToCStr())); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.Alert", cSoundScript.ToCStr())); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.FootstepRight", cSoundScript.ToCStr())); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.FootstepLeft", cSoundScript.ToCStr())); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.Attack", cSoundScript.ToCStr())); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.FastBreath", cSoundScript.ToCStr())); PrecacheScriptSound(UTIL_VarArgs("NPC_%s.Moan1", cSoundScript.ToCStr())); // Default Zombie Precaching PrecacheScriptSound("Zombie.FootstepRight"); PrecacheScriptSound("Zombie.FootstepLeft"); PrecacheScriptSound("Zombie.ScuffRight"); PrecacheScriptSound("Zombie.ScuffLeft"); PrecacheScriptSound("Zombie.Pain"); PrecacheScriptSound("Zombie.Die"); PrecacheScriptSound("Zombie.Alert"); PrecacheScriptSound("Zombie.Idle"); PrecacheScriptSound("Zombie.Attack"); PrecacheScriptSound("NPC_BaseZombie.Moan1"); PrecacheScriptSound("NPC_BaseZombie.Moan2"); PrecacheScriptSound("NPC_BaseZombie.Moan3"); PrecacheScriptSound("NPC_BaseZombie.Moan4"); PrecacheScriptSound( "Zombie.AttackHit" ); PrecacheScriptSound( "Zombie.AttackMiss" ); BaseClass::Precache(); }
void CEnvDeferredLight::Spawn() { BaseClass::Spawn(); // Always on! AddSpawnFlags( DEFLIGHT_ENABLED|DEFLIGHT_SHADOW_ENABLED ); KeyValue( "light_type", "0" ); KeyValue( "diffuse", UTIL_VarArgs( "%f %f %f %f", m_vLightColor.x, m_vLightColor.y, m_vLightColor.z, 255.0f * m_fIntensity ) ); KeyValue( "ambient", "10 10 10 255" ); KeyValue( "power", UTIL_VarArgs( "%f", m_fStartFalloff ) ); KeyValue( "vis_dist", UTIL_VarArgs( "%d", 1024 ) ); KeyValue( "vis_range", UTIL_VarArgs( "%d", 512 ) ); KeyValue( "shadow_dist", UTIL_VarArgs( "%d", 1024 ) ); KeyValue( "shadow_range", UTIL_VarArgs( "%d", 512 ) ); KeyValue( "spot_cone_inner", UTIL_VarArgs( "%f", 35.0 ) ); KeyValue( "spot_cone_outer", UTIL_VarArgs( "%f", 45.0 ) ); }
void CPointClientCommand::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { edict_t *pClient = nullptr; if (gpGlobals->maxClients == 1) { pClient = INDEXENT(1); } else if (pActivator && pActivator->IsPlayer() && pActivator->IsNetClient() && !pActivator->IsDormant()) { // In multiplayer, send it back to the activator pClient = pActivator->edict(); } if (pClient) { for (size_t cmd = 0; cmd < m_uiCommandsCount; cmd++) { CLIENT_COMMAND(pClient, UTIL_VarArgs("%s\n", m_iszCommands[cmd].str())); } } }
// Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. void ClientCommand( edict_t *pEntity ) { const char *pcmd = CMD_ARGV(0); const char *pstr; // Is the client spawned yet? if ( !pEntity->pvPrivateData ) return; entvars_t *pev = &pEntity->v; if ( FStrEq(pcmd, "say" ) ) { Host_Say( pEntity, 0 ); } else if ( FStrEq(pcmd, "say_team" ) ) { Host_Say( pEntity, 1 ); } else if ( FStrEq(pcmd, "fullupdate" ) ) { GetClassPtr((CBasePlayer *)pev)->ForceClientDllUpdate(); } else if ( FStrEq(pcmd, "give" ) ) { if ( g_flWeaponCheat != 0.0) { int iszItem = ALLOC_STRING( CMD_ARGV(1) ); // Make a copy of the classname GetClassPtr((CBasePlayer *)pev)->GiveNamedItem( STRING(iszItem) ); } } else if ( FStrEq(pcmd, "fire") ) { if ( g_flWeaponCheat != 0.0) { CBaseEntity *pPlayer = CBaseEntity::Instance(pEntity); if (CMD_ARGC() > 1) { FireTargets(CMD_ARGV(1), pPlayer, pPlayer, USE_TOGGLE, 0); } else { TraceResult tr; UTIL_MakeVectors(pev->v_angle); UTIL_TraceLine( pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 1000, dont_ignore_monsters, pEntity, &tr ); if (tr.pHit) { CBaseEntity *pHitEnt = CBaseEntity::Instance(tr.pHit); if (pHitEnt) { pHitEnt->Use(pPlayer, pPlayer, USE_TOGGLE, 0); ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Fired %s \"%s\"\n", STRING(pHitEnt->pev->classname), STRING(pHitEnt->pev->targetname) ) ); } } } } } else if ( FStrEq(pcmd, "drop" ) ) { // player is dropping an item. GetClassPtr((CBasePlayer *)pev)->DropPlayerItem((char *)CMD_ARGV(1)); } else if ( FStrEq(pcmd, "fov" ) ) { if ( g_flWeaponCheat && CMD_ARGC() > 1) { GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) ); } else { CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) ); } } else if ( FStrEq(pcmd, "use" ) ) { GetClassPtr((CBasePlayer *)pev)->SelectItem((char *)CMD_ARGV(1)); } else if (((pstr = strstr(pcmd, "weapon_")) != NULL) && (pstr == pcmd)) { GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd); } else if (FStrEq(pcmd, "lastinv" )) { GetClassPtr((CBasePlayer *)pev)->SelectLastItem(); } else if ( FStrEq( pcmd, "spectate" ) && (pev->flags & FL_PROXY) ) // added for proxy support { CBasePlayer * pPlayer = GetClassPtr((CBasePlayer *)pev); edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); pPlayer->StartObserver( pev->origin, VARS(pentSpawnSpot)->angles); } else if ( g_pGameRules->ClientCommand( GetClassPtr((CBasePlayer *)pev), pcmd ) ) { // MenuSelect returns true only if the command is properly handled, so don't print a warning } else if ( FStrEq(pcmd, "VModEnable") ) { // clear 'Unknown command: VModEnable' in singleplayer return; } else { // tell the user they entered an unknown command char command[128]; // check the length of the command (prevents crash) // max total length is 192 ...and we're adding a string below ("Unknown command: %s\n") strncpy( command, pcmd, 127 ); command[127] = '\0'; // tell the user they entered an unknown command ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) ); } }
//----------------------------------------------------------------------------- // Purpose: Play a random alert sound. //----------------------------------------------------------------------------- void CNPC_Monster::AlertSound( void ) { BreatheOffShort(); EmitSound(UTIL_VarArgs("NPC_%s.Alert", cSoundScript.ToCStr())); }