bool C_SDKPlayer::ShouldDraw( void ) { // If we're dead, our ragdoll will be drawn for us instead. if ( !IsAlive() ) return false; if( GetTeamNumber() == TEAM_SPECTATOR ) return false; if ( State_Get() == STATE_WELCOME ) return false; #if defined ( SDK_USE_TEAMS ) if ( State_Get() == STATE_PICKINGTEAM ) return false; #endif #if defined ( SDK_USE_PLAYERCLASSES ) if ( State_Get() == STATE_PICKINGCLASS ) return false; #endif if( IsLocalPlayer() && IsRagdoll() ) return true; return BaseClass::ShouldDraw(); }
bool CSDKPlayer::CanMove( void ) const { bool bValidMoveState = (State_Get() == STATE_ACTIVE || State_Get() == STATE_OBSERVER_MODE); if ( !bValidMoveState ) { return false; } return true; }
bool CBliinkPlayer::CanMove( void ) const { bool bValidMoveState = (State_Get() == STATE_BLIINK_SURVIVOR || State_Get() == STATE_BLIINK_STALKER || State_Get() == STATE_BLIINK_SPECTATE || State_Get() == STATE_BLIINK_SPECTATE_PREGAME); if ( !bValidMoveState ) { return false; } return true; }
//----------------------------------------------------------------------------- // Purpose: Update this client's target entity //----------------------------------------------------------------------------- void C_SDKPlayer::UpdateIDTarget() { if ( !IsLocalPlayer() ) return; // Clear old target and find a new one m_iIDEntIndex = 0; // don't show id's in any state but active. if ( State_Get() != PLAYER_STATE_ACTIVE ) return; trace_t tr; Vector vecStart, vecEnd; VectorMA( MainViewOrigin(), 1500, MainViewForward(), vecEnd ); VectorMA( MainViewOrigin(), 10, MainViewForward(), vecStart ); UTIL_TraceLine( vecStart, vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); if ( !tr.startsolid && tr.DidHitNonWorldEntity() ) { C_BaseEntity *pEntity = tr.m_pEnt; if ( pEntity && (pEntity != this) ) { m_iIDEntIndex = pEntity->entindex(); } } }
void CPlayerBall::Touched(bool isShot, body_part_t bodyPart, const Vector &oldVel) { BallTouchInfo *info = new BallTouchInfo; info->m_pPl = m_pPl; info->m_nTeam = m_pPl->GetTeamNumber(); info->m_bIsShot = isShot; info->m_eBodyPart = bodyPart; info->m_eBallState = State_Get(); info->m_vBallPos = m_vPos; info->m_vBallVel = m_vVel; info->m_flTime = gpGlobals->curtime; m_Touches.AddToTail(info); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CSDKPlayer::CommitSuicide( bool bExplode /* = false */, bool bForce /*= false*/ ) { // Don't suicide if we haven't picked a class for the first time, or we're not in active state if ( #if defined ( SDK_USE_PLAYERCLASSES ) m_Shared.PlayerClass() == PLAYERCLASS_UNDEFINED || #endif State_Get() != STATE_ACTIVE ) return; m_iSuicideCustomKillFlags = SDK_DMG_CUSTOM_SUICIDE; BaseClass::CommitSuicide( bExplode, bForce ); }
void CSDKPlayer::Spawn() { SetModel( SDK_PLAYER_MODEL ); //Tony; basically, leave this alone ;) unless you're not using classes or teams, then you can change it to whatever. SetBloodColor( BLOOD_COLOR_RED ); SetMoveType( MOVETYPE_WALK ); RemoveSolidFlags( FSOLID_NOT_SOLID ); //Tony; if we're spawning in active state, equip the suit so the hud works. -- Gotta love base code ! if ( State_Get() == STATE_ACTIVE ) { EquipSuit( false ); //Tony; bleh, don't do this here. // GiveDefaultItems(); } m_hRagdoll = NULL; BaseClass::Spawn(); #if defined ( SDK_USE_STAMINA ) || defined ( SDK_USE_SPRINTING ) m_Shared.SetStamina( 100 ); #endif #if defined ( SDK_USE_TEAMS ) m_bTeamChanged = false; #endif #if defined ( SDK_USE_PRONE ) InitProne(); #endif #if defined ( SDK_USE_SPRINTING ) InitSprinting(); #endif // update this counter, used to not interp players when they spawn m_bSpawnInterpCounter = !m_bSpawnInterpCounter; InitSpeeds(); //Tony; initialize player speeds. SetArmorValue(SpawnArmorValue()); SetContextThink( &CSDKPlayer::SDKPushawayThink, gpGlobals->curtime + PUSHAWAY_THINK_INTERVAL, SDK_PUSHAWAY_THINK_CONTEXT ); pl.deadflag = false; }
//Tony; this is where default items go when not using playerclasses! void CSDKPlayer::GiveDefaultItems() { #if !defined ( SDK_USE_PLAYERCLASSES ) if ( State_Get() == STATE_ACTIVE ) { CBasePlayer::GiveAmmo( 30, "pistol"); CBasePlayer::GiveAmmo( 30, "mp5"); CBasePlayer::GiveAmmo( 12, "shotgun"); CBasePlayer::GiveAmmo( 5, "grenades" ); GiveNamedItem( "weapon_pistol" ); GiveNamedItem( "weapon_mp5" ); GiveNamedItem( "weapon_shotgun" ); GiveNamedItem( "weapon_crowbar" ); GiveNamedItem( "weapon_grenade" ); } #endif }
//Tony; we don't have to check anything special for SDK_USE_TEAMS here; it's all pretty generic, except for the one assert. bool CSDKPlayer::HandleCommand_JoinClass( int iClass ) { Assert( GetTeamNumber() != TEAM_SPECTATOR ); #if defined ( SDK_USE_TEAMS ) Assert( GetTeamNumber() != TEAM_UNASSIGNED ); #endif if( GetTeamNumber() == TEAM_SPECTATOR ) return false; if( iClass == PLAYERCLASS_UNDEFINED ) return false; //they typed in something weird int iOldPlayerClass = m_Shared.DesiredPlayerClass(); // See if we're joining the class we already are if( iClass == iOldPlayerClass ) return true; if( !SDKGameRules()->IsPlayerClassOnTeam( iClass, GetTeamNumber() ) ) return false; const char *classname = SDKGameRules()->GetPlayerClassName( iClass, GetTeamNumber() ); if( SDKGameRules()->CanPlayerJoinClass( this, iClass ) ) { m_Shared.SetDesiredPlayerClass( iClass ); //real class value is set when the player spawns //Tony; don't do this until we have a spawn timer!! // if( State_Get() == STATE_PICKINGCLASS ) // State_Transition( STATE_OBSERVER_MODE ); if( iClass == PLAYERCLASS_RANDOM ) { if( IsAlive() ) { ClientPrint(this, HUD_PRINTTALK, "#game_respawn_asrandom" ); } else { ClientPrint(this, HUD_PRINTTALK, "#game_spawn_asrandom" ); } } else { if( IsAlive() ) { ClientPrint(this, HUD_PRINTTALK, "#game_respawn_as", classname ); } else { ClientPrint(this, HUD_PRINTTALK, "#game_spawn_as", classname ); } } IGameEvent * event = gameeventmanager->CreateEvent( "player_changeclass" ); if ( event ) { event->SetInt( "userid", GetUserID() ); event->SetInt( "class", iClass ); gameeventmanager->FireEvent( event ); } } else { ClientPrint(this, HUD_PRINTTALK, "#game_class_limit", classname ); ShowClassSelectMenu(); } // Incase we don't get the class menu message before the spawn timer // comes up, fake that we've closed the menu. SetClassMenuOpen( false ); //Tony; TODO; this is temp, I may integrate with the teamplayroundrules; If I do, there will be wavespawn too. if ( State_Get() == STATE_PICKINGCLASS /*|| IsDead()*/ ) //Tony; undone, don't transition if dead; only go into active state at this point if we were picking class. State_Transition( STATE_ACTIVE ); //Done picking stuff and we're in the pickingclass state, or dead, so we can spawn now. return true; }