コード例 #1
0
ファイル: c_dhl_player.cpp プロジェクト: dreckard/dhl2
void C_DHL_Player::ClientDeath( void )
{
	//This function should only be called for the local player, but just in case...
	if ( !IsLocalPlayer() )
		return;

	//Fix ragdolls getting borked because of the stunt sequence
	if ( m_bProne )
	{
		MDLCACHE_CRITICAL_SECTION();
		ResetSequence( SelectWeightedSequence( ACT_DHL_PRONE_GENERIC ) );
	}

	//Gotta go to first person for the ragdoll death cam
	if ( input->CAM_IsThirdPerson() )
	{
		engine->ClientCmd( "firstperson \n");
		m_bWantsThirdPerson = true;
	}

	if ( GetNightvisionEnabled() )
	{
		EnableNightvision( false );
		m_bWantsNV = true;
	}
	vieweffects->ClearAllFades(); //No screenfades after death
}
コード例 #2
0
ファイル: Player.cpp プロジェクト: jason-amju/amjulib
void Player::SetMenu(GuiMenu* menu)
{
  if (IsLocalPlayer())
  {
    // If carrying, drop is option
    if (m_carrying)
    {
      AddMenuItem("Put down", new CommandPickUp(m_carrying, false));
    }
  }
  else if (IsLoggedIn())
  {
    //menu->AddChild(new GuiMenuItem("Talk to " + GetName(), new CommandTalk(this)));

    AddMenuItem("Talk to " + GetName(), new CommandTalk(this));
    /*
    NO FIGHTING
    AddMenuItem("FIGHT!!", new CommandFight(this));
    */
  }
  else
  {
    // TODO put back leaving messages
    //menu->AddChild(new GuiMenuItem("Leave a message for " + GetName(), new CommandTalk(this)));
    //AddMenuItem("Leave a message for " + GetName(), new CommandTalk(this));
  }
}
コード例 #3
0
//-----------------------------------------------------------------------------
// 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();
		}
	}
}
コード例 #4
0
ファイル: baseplayer_shared.cpp プロジェクト: paralin/hl2sdk
//-----------------------------------------------------------------------------
// Actual Eye position + angles
//-----------------------------------------------------------------------------
Vector CBasePlayer::EyePosition( )
{
#ifdef CLIENT_DLL
	IClientVehicle *pVehicle = GetVehicle();
#else
	IServerVehicle *pVehicle = GetVehicle();
#endif
	if ( pVehicle )
	{
		Assert( pVehicle );
		int nRole = pVehicle->GetPassengerRole( this );

		Vector vecEyeOrigin;
		QAngle angEyeAngles;
		pVehicle->GetVehicleViewPosition( nRole, &vecEyeOrigin, &angEyeAngles );
		return vecEyeOrigin;
	}
	else
	{
#ifdef CLIENT_DLL
		if ( IsObserver() )
		{
			if ( m_iObserverMode == OBS_MODE_CHASE )
			{
				if ( IsLocalPlayer() )
				{
					return MainViewOrigin();
				}
			}
		}
#endif
		return BaseClass::EyePosition();
	}
}
コード例 #5
0
//-----------------------------------------------------------------------------
// Actual Eye position + angles
//-----------------------------------------------------------------------------
Vector CBasePlayer::EyePosition( )
{
	if ( GetVehicle() != NULL )
	{
		// Return the cached result
		CacheVehicleView();
		return m_vecVehicleViewOrigin;
	}
	else
	{
#ifdef CLIENT_DLL

		if ( IsObserver() )
		{
			if ( m_iObserverMode == OBS_MODE_CHASE )
			{
				if ( IsLocalPlayer() )
				{
					return MainViewOrigin();
				}
			}
		}
#endif
		return BaseClass::EyePosition();
	}
}
コード例 #6
0
void C_SDKPlayer::LookAtBall(void)
{
	const QAngle camAngles = IsLocalPlayer() ? ::input->GetCameraAngles() : m_angCamViewAngles;
	float yaw = camAngles[YAW] - EyeAngles()[YAW];
	float pitch = camAngles[PITCH];

	if (yaw > 180) yaw -= 360;
	if (yaw < -180) yaw += 360;
	if (pitch > 180) pitch -= 360;
	if (pitch < -180) pitch += 360;

	//if (yaw > 90) yaw = 180 - yaw;
	//if (yaw < -90) yaw = -180 - yaw;

	pitch = clamp(pitch, -60, 60);
	yaw = clamp(yaw, -120, 120);

	float neckVal = clamp(yaw, -50, 50);
	SetBoneController(2, neckVal); // Neck
	yaw -= neckVal;

	float upperSpineVal = clamp(yaw, -40, 40);
	SetBoneController(1, upperSpineVal); // Upper spine
	yaw -= upperSpineVal;

	float lowerSpineVal = clamp(yaw, -30, 30);
	SetBoneController(0, lowerSpineVal); // Lower spine

	SetBoneController(3, pitch);
}
コード例 #7
0
ファイル: c_hl2mp_player.cpp プロジェクト: uunx/quakelife2
//-----------------------------------------------------------------------------
// Purpose: Update this client's target entity
//-----------------------------------------------------------------------------
void C_HL2MP_Player::UpdateIDTarget()
{
	if ( !IsLocalPlayer() )
		return;

	// Clear old target and find a new one
	m_iIDEntIndex = 0;

	// don't show IDs in chase spec mode
	if ( GetObserverMode() == OBS_MODE_CHASE || 
		 GetObserverMode() == OBS_MODE_DEATHCAM )
		 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();
		}
	}
}
コード例 #8
0
ファイル: c_sdk_player.cpp プロジェクト: Au-heppa/swarm-sdk
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();
}
コード例 #9
0
ファイル: Player.cpp プロジェクト: jason-amju/amjulib
void Player::OnSpaceshipCollision(Spaceship* spaceship)
{
  // TODO Only process on first collision frame, ignore subsequently
  if (!IsLocalPlayer())
  {
    return;
  }

  FirstTimeMsgThisSession("This is your spaceship!", UNIQUE_MSG_ID, false); 

  if (m_isDead)
  {
    std::string str = "Your health is restored!";
    LurkMsg lm(GameLookup(str), LURK_FG, LURK_BG, AMJU_CENTRE);
    TheLurker::Instance()->Queue(lm);
    ChangeHeartCount(100);
    m_isDead = false;
  }

  int fc = GetLocalPlayerFuelCount();
  if (fc == 0)
  {
    FirstTimeMsgThisSession("Your spaceship needs fuel. Please find fuel cells and bring them back here!", UNIQUE_MSG_ID, false);
    return;
  }

std::cout << "Fuel cells: " << fc << "\n"; 

  // TODO Different bands
// TODO Needs better msg
  std::string str = "Thanks for bringing fuel to your spaceship, <p>!";
  LurkMsg lm(GameLookup(str), LURK_FG, LURK_BG, AMJU_CENTRE);
  TheLurker::Instance()->Queue(lm);

  spaceship->AddFuel(fc);

  // Add fc to server-based count of total fuel cells you have ever brought
  // Count goes up for this player: total num fuel cells ever brought to ship
  ChangePlayerCount(FUELCELL_KEY, fc);

  // Send system message that you brought fuel
  static const int BROADCAST = -2;
  if (fc == 1)
  {
    str = "<BROUGHT A FUEL CELL TO THE SHIP>";
  }
  else
  {
    str = "<BROUGHT " + ToString(fc) + " FUEL CELLS TO THE SHIP>";
  }
  TheMsgManager::Instance()->SendMsg(GetLocalPlayerId(), BROADCAST, str);

  static GSMain* gsm = TheGSMain::Instance();
  gsm->SetFuelCells(0);    

  ResetLocalPlayerFuelCount();
}
コード例 #10
0
ファイル: c_dhl_player.cpp プロジェクト: dreckard/dhl2
void C_DHL_Player::PostDataUpdate( DataUpdateType_t updateType )
{
	BaseClass::PostDataUpdate( updateType );

	if ( IsLocalPlayer() && input->CAM_IsThirdPerson() )
	{
		OnLatchInterpolatedVariables( LATCH_ANIMATION_VAR );
	}
}
コード例 #11
0
void C_HL2MP_Player::DoAnimationEvent(PlayerAnimEvent_t event, int nData)
{
	if (IsLocalPlayer())
		if ((prediction->InPrediction() && !prediction->IsFirstTimePredicted()))
			return;

	MDLCACHE_CRITICAL_SECTION();
	//m_PlayerAnimState->DoAnimationEvent(event, nData);
}
コード例 #12
0
ファイル: CNetworkPlayer.cpp プロジェクト: DarkKlo/maf2mp
CNetworkPlayer::~CNetworkPlayer( void )
{
	DEBUG_TRACE("CNetworkPlayer::~CNetworkPlayer");

	// Is this not the localplayer?
	if ( !IsLocalPlayer() )
	{
		// Destroy the playerped
		Destroy();
	}
}
コード例 #13
0
ファイル: c_cf_player.cpp プロジェクト: BSVino/Arcon
void C_CFPlayer::DoAnimationEvent( PlayerAnimEvent_t event, int mData, bool bSecondary )
{
	if ( IsLocalPlayer() )
	{
		if ( prediction->InPrediction() && !prediction->IsFirstTimePredicted() )
			return;
	}

	MDLCACHE_CRITICAL_SECTION();
	m_PlayerAnimState->DoAnimationEvent( event, mData, bSecondary );
}
コード例 #14
0
ファイル: c_cf_player.cpp プロジェクト: BSVino/Arcon
const QAngle& C_CFPlayer::EyeAngles()
{
	if ( IsLocalPlayer() && !g_nKillCamMode )
	{
		return BaseClass::EyeAngles();
	}
	else
	{
		return m_angEyeAngles;
	}
}
コード例 #15
0
ファイル: c_hl2mp_player.cpp プロジェクト: uunx/quakelife2
const QAngle &C_HL2MP_Player::EyeAngles()
{
	if( IsLocalPlayer() )
	{
		return BaseClass::EyeAngles();
	}
	else
	{
		return m_angEyeAngles;
	}
}
コード例 #16
0
ファイル: CNetworkPlayer.cpp プロジェクト: DarkKlo/maf2mp
CNetworkPlayer::CNetworkPlayer( bool bLocalPlayer )
{
	DEBUG_TRACE("CNetworkPlayer::CNetworkPlayer");

	// Reset variables
	m_bLocalPlayer = bLocalPlayer;
	m_playerId = INVALID_ENTITY_ID;
	m_pPlayerPed = NULL;
	m_pPlayerModelManager = NULL;
	m_pMoveObject = NULL;
	m_pAimObject = NULL;
	m_pShootObject = NULL;
	m_bCharacterSlot = -1;
	m_bIsDead = false;
	m_bSpawned = false;
	m_dwDeathTime = 0;
	m_bAiming = false;
	m_bShooting = false;
	m_iControlStyle = 0;
	m_usPing = 0;
	m_dwWeaponSelect = NULL;
	m_playerState = PLAYERSTATE_UNKNOWN;
	m_lastState = M2Enums::eEntityState::IDLE;
	m_bMoveStyle = 3;
	m_pVehicle = NULL;
	m_seat = INVALID_ENTITY_ID;
	m_uiModelIndex = -1;
	m_pAttachedBlip = NULL;
	m_bBlipAttached = false;
	
	// Reset enter vehicle stuff
	m_VehicleEnter.m_pEnterAICommand = NULL;
	SetEnteringVehicle( NULL, INVALID_ENTITY_ID );
	m_VehicleEnter.m_bIsEntering = false;

	// Reset exiting vehicle stuff
	m_VehicleExit.m_pExitAICommand = NULL;
	m_VehicleExit.m_ulExitStartTime = 0;
	m_VehicleExit.m_bIsExiting = false;

	// Is this the localplayer?
	if( IsLocalPlayer() )
	{
		// Get the player ped instance
		m_pPlayerPed = new CM2Ped( IE::GetGame()->m_pLocalPed );

		// Set the localplayer model manager instance
		m_pPlayerModelManager = *(M2ModelMgr **)( 0x1AACDAC );

		// Update the model index
		m_uiModelIndex = Game::GetIdFromPlayerModel ( m_pPlayerModelManager->GetModelName () );
	}
}
コード例 #17
0
void C_SDKPlayer::DoAnimationEvent(PlayerAnimEvent_t event)
{
	if ( IsLocalPlayer() )
	{
		if ( ( prediction->InPrediction() && !prediction->IsFirstTimePredicted() ) )
			return;
	}

	MDLCACHE_CRITICAL_SECTION();
	m_PlayerAnimState->DoAnimationEvent(event);
	//m_Shared.DoAnimationEvent(event);
}
コード例 #18
0
ファイル: c_sdk_player.cpp プロジェクト: Epic-xx/impending
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( IsLocalPlayer() && IsRagdoll() )
		return true;

	return BaseClass::ShouldDraw();
}
コード例 #19
0
ファイル: CNetworkPlayer.cpp プロジェクト: DarkKlo/maf2mp
void CNetworkPlayer::SetModel( unsigned int uiModelIndex, bool bRebuild )
{
	DEBUG_TRACE("CNetworkPlayer::SetModel");

	// Store the model index
	m_uiModelIndex = uiModelIndex;

	// Is the playerped valid?
	if( m_pPlayerPed && IsSpawned() && bRebuild )
	{
		// Get the model name and directory
		String strModel, strDirectory;
		Game::GetPlayerModelFromId ( uiModelIndex, &strModel, &strDirectory );

		// Get the player current vehicle
		CNetworkVehicle * pCurrentVehicle = GetVehicle ();
		EntityId iSeat = GetSeat ();

		// Remove from vehicle if we're in one
		if( pCurrentVehicle )
			RemoveFromVehicle ( pCurrentVehicle );

		// Is this the localplayer?
		if( IsLocalPlayer() )
		{
			// Change the localplayer model
			m_pPlayerModelManager->ChangeModel ( strDirectory.Get(), strModel.Get() );
		}
		else
		{
			// Get position and rotation
			CVector3 vecPosition, vecRotation;
			GetPosition ( &vecPosition );
			GetRotation ( &vecRotation );

			// Create the player ped
			Create ();

			// Restore position and rotation
			Teleport ( vecPosition );
			SetRotation ( vecRotation );
		}

		// Put the player back in the vehicle
		if ( pCurrentVehicle )
			PutInVehicle ( pCurrentVehicle, iSeat );
	}
}
コード例 #20
0
ファイル: baseplayer_shared.cpp プロジェクト: EspyEspurr/game
//-----------------------------------------------------------------------------
// Actual Eye position + angles
//-----------------------------------------------------------------------------
Vector CBasePlayer::EyePosition( )
{
#ifdef CLIENT_DLL
	if ( IsObserver() )
	{
		if ( GetObserverMode() == OBS_MODE_CHASE )
		{
			if ( IsLocalPlayer() )
			{
				return MainViewOrigin();
			}
		}
	}
#endif
	return BaseClass::EyePosition();
}
コード例 #21
0
ファイル: c_cf_player.cpp プロジェクト: BSVino/Arcon
bool C_CFPlayer::ShouldDraw( void )
{
	// If we're dead, our ragdoll will be drawn for us instead.
	if ( !IsAlive() && !IsKnockedOut() )
		return false;

	if( GetTeamNumber() == TEAM_SPECTATOR )
		return false;

	if( IsLocalPlayer() && IsRagdoll() )
		return true;

	if (m_hCameraCinematic != NULL)
		return false;

	// Skip C_BasePlayer::ShouldDraw() because it has a bunch of logic we don't care for.
	return C_BaseCombatCharacter::ShouldDraw();
}
コード例 #22
0
// Add support for CS:S player animations
void C_SO_Player::DoAnimationEvent( PlayerAnimEvent_t event, int nData )
{
	if ( IsLocalPlayer() )
	{
		if ( ( prediction->InPrediction() && !prediction->IsFirstTimePredicted() ) )
			return;
	}

	MDLCACHE_CRITICAL_SECTION();

	// Add support for CS:S player animations
	if ( event == PLAYERANIMEVENT_ATTACK_GRENADE )
	{
		// Let the server handle this event. It will update m_iThrowGrenadeCounter and the client will
		// pick up the event in CCSPlayerAnimState.
	}
	else
	{
		m_SOPlayerAnimState->DoAnimationEvent( event, nData );
	}
}
コード例 #23
0
ファイル: baseplayer_shared.cpp プロジェクト: EspyEspurr/game
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : eyeOrigin - 
//			eyeAngles - 
//			zNear - 
//			zFar - 
//			fov - 
//-----------------------------------------------------------------------------
void CBasePlayer::CalcView( Vector &eyeOrigin, QAngle &eyeAngles, float &zNear, float &zFar, float &fov )
{
#if defined( CLIENT_DLL )
	if( UseVR() )
		g_ClientVirtualReality.CancelTorsoTransformOverride();
#endif

	if ( IsObserver() )
	{
		CalcObserverView( eyeOrigin, eyeAngles, fov );
	}
	else
	{
		CalcPlayerView( eyeOrigin, eyeAngles, fov );
	}
	// NVNT update fov on the haptics dll for input scaling.
#if defined( CLIENT_DLL )
	if(IsLocalPlayer() && haptics)
		haptics->UpdatePlayerFOV(fov);
#endif
}
コード例 #24
0
ファイル: baseplayer_shared.cpp プロジェクト: EspyEspurr/game
void CBasePlayer::SharedSpawn()
{
	SetMoveType( MOVETYPE_WALK );
	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_NOT_STANDABLE );
	SetFriction( 1.0f );

	pl.deadflag	= false;
	m_lifeState	= LIFE_ALIVE;
	m_iHealth = 100;
	m_takedamage		= DAMAGE_YES;

	m_Local.m_bDrawViewmodel = true;
	m_Local.m_flStepSize = sv_stepsize.GetFloat();
	m_Local.m_bAllowAutoMovement = true;

	m_nRenderFX = kRenderFxNone;
	m_flNextAttack	= gpGlobals->curtime;
	m_flMaxspeed		= 0.0f;

	MDLCACHE_CRITICAL_SECTION();
	SetSequence( SelectWeightedSequence( ACT_IDLE ) );

	if ( GetFlags() & FL_DUCKING ) 
		SetCollisionBounds( VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX );
	else
		SetCollisionBounds( VEC_HULL_MIN, VEC_HULL_MAX );

	// dont let uninitialized value here hurt the player
	m_Local.m_flFallVelocity = 0;

	SetBloodColor( BLOOD_COLOR_RED );
	// NVNT inform haptic dll we have just spawned local player
#ifdef CLIENT_DLL
	if(IsLocalPlayer() &&haptics)
		haptics->LocalPlayerReset();
#endif
}
コード例 #25
0
/*void C_SDKPlayer::OnPlayerClassChange( void )
{
	// Init the anim movement vars
	m_PlayerAnimState->SetRunSpeed( GetPlayerClass()->GetMaxSpeed() );
	m_PlayerAnimState->SetWalkSpeed( GetPlayerClass()->GetMaxSpeed() * 0.5 );
}
*/
void C_SDKPlayer::PostDataUpdate( DataUpdateType_t updateType )
{
	// C_BaseEntity assumes we're networking the entity's angles, so pretend that it
	// networked the same value we already have.
	SetNetworkAngles( GetLocalAngles() );
	
	BaseClass::PostDataUpdate( updateType );

	bool bIsLocalPlayer = IsLocalPlayer();

	if( m_bSpawnInterpCounter != m_bSpawnInterpCounterCache )
	{
		MoveToLastReceivedPosition( true );
		ResetLatched();

		if ( bIsLocalPlayer )
		{
			LocalPlayerRespawn();
		}
		m_bSpawnInterpCounterCache = m_bSpawnInterpCounter.m_Value;
	}

}
コード例 #26
0
ファイル: Player.cpp プロジェクト: 2mac/openspades
		void Player::Update(float dt) {
			SPADES_MARK_FUNCTION();
			auto* listener = world->GetListener();
			
			MovePlayer(dt);
			
			if(!IsAlive()) {
				// do death cleanup
				blockCursorDragging = false;
			}
			
			if(tool == ToolSpade){
				if(weapInput.primary){
					if(world->GetTime() > nextSpadeTime){
						UseSpade();
						nextSpadeTime = world->GetTime() + GetToolPrimaryDelay();
					}
				}else if(weapInput.secondary){
					if(world->GetTime() > nextDigTime){
						DigWithSpade();
						nextDigTime = world->GetTime() + GetToolSecondaryDelay();
						firstDig = false;
					}
				}
			}else if(tool == ToolBlock && IsLocalPlayer()){
				GameMap::RayCastResult result;
				auto *map = GetWorld()->GetMap();
				result = map->CastRay2(GetEye(), GetFront(), 12);
				canPending = false;
				
				if(blockCursorDragging) {
					// check the starting point is not floating
					auto start = blockCursorDragPos;
					if(map->IsSolidWrapped(start.x-1, start.y, start.z) ||
					   map->IsSolidWrapped(start.x, start.y-1, start.z) ||
					   map->IsSolidWrapped(start.x, start.y, start.z-1) ||
					   map->IsSolidWrapped(start.x+1, start.y, start.z) ||
					   map->IsSolidWrapped(start.x, start.y+1, start.z) ||
					   map->IsSolidWrapped(start.x, start.y, start.z+1)) {
						// still okay
					}else{
						// cannot build; floating
						if(listener &&
						   this == world->GetLocalPlayer()) {
							listener->
							LocalPlayerBuildError(BuildFailureReason::InvalidPosition);
						}
						blockCursorDragging = false;
					}
				}
				
				if(result.hit &&
				   (result.hitBlock + result.normal).z < 62 &&
				   (!OverlapsWithOneBlock(result.hitBlock + result.normal)) &&
				   BoxDistanceToBlock(result.hitBlock + result.normal) < 3.f &&
				   !pendingPlaceBlock){
					
					// Building is possible, and there's no delayed block placement.
					blockCursorActive = true;
					blockCursorPos = result.hitBlock + result.normal;
					
				}else if(pendingPlaceBlock){
					
					// Delayed Block Placement: When player attempts to place a block while jumping and
					// placing block is currently impossible, building will be delayed until it becomes
					// possible, as long as player is airborne.
					if(airborne == false || blockStocks <= 0){
						// player is no longer airborne, or doesn't have a block to place.
						pendingPlaceBlock = false;
						lastSingleBlockBuildSeqDone = true;
						if(blockStocks > 0) {
							// cannot build; invalid position.
						}
					}else if((!OverlapsWithOneBlock(pendingPlaceBlockPos)) &&
							 BoxDistanceToBlock(pendingPlaceBlockPos) < 3.f){
						// now building became possible.
						SPAssert(this == world->GetLocalPlayer());
						
						if(GetWorld()->GetListener())
							GetWorld()->GetListener()->LocalPlayerBlockAction(pendingPlaceBlockPos, BlockActionCreate);
						
						pendingPlaceBlock = false;
						lastSingleBlockBuildSeqDone = true;
						// blockStocks--; decrease when created
						
						nextBlockTime = world->GetTime() + GetToolPrimaryDelay();
					}
					
				}else{
					// Delayed Block Placement can be activated only when the only reason making placement
					// impossible is that block to be placed overlaps with the player's hitbox.
					canPending = result.hit &&
								 (result.hitBlock + result.normal).z < 62 &&
								 BoxDistanceToBlock(result.hitBlock + result.normal) < 3.f;
					
					blockCursorActive = false;
					int dist = 11;
					for(; dist >= 1 &&
						BoxDistanceToBlock(result.hitBlock + result.normal) > 3.f ; dist--) {
						result = GetWorld()->GetMap()->CastRay2(GetEye(),
																GetFront(),
																dist);
					}
					for(; dist < 12 &&
						BoxDistanceToBlock(result.hitBlock + result.normal) < 3.f ; dist++) {
						result = GetWorld()->GetMap()->CastRay2(GetEye(),
																GetFront(),
																dist);
					}
					
					blockCursorPos = result.hitBlock + result.normal;
				}
				
			}else if(tool == ToolWeapon){
			}else if(tool == ToolGrenade){
				if(holdingGrenade){
					if(world->GetTime() - grenadeTime > 2.9f){
						ThrowGrenade();
					}
				}
			}
		
			if(tool != ToolWeapon)
				weapon->SetShooting(false);
			if(weapon->FrameNext(dt)){
				FireWeapon();
			}
			
			if(weapon->IsReloading()) {
				lastReloadingTime = world->GetTime();
			}else if(reloadingServerSide) {
				// for some reason a server didn't return
				// WeaponReload packet.
				if(world->GetTime() + lastReloadingTime + .8f) {
					reloadingServerSide = false;
					weapon->ForceReloadDone();
				}
			}
		}
コード例 #27
0
ファイル: c_cf_player.cpp プロジェクト: BSVino/Arcon
void C_CFPlayer::Spawn()
{
	BaseClass::Spawn();

	if (GetTeamNumber() == TEAM_SPECTATOR || GetTeamNumber() == TEAM_UNASSIGNED)
		cfgui::CRootPanel::SetArmament(m_pArmament);
	else
		cfgui::CRootPanel::SetArmament(m_pCurrentArmament);

	if (IsLocalPlayer())
	{
		switch (cvar->FindVar("cl_thirdperson")->GetInt())
		{
		case 0:
			CFInput()->CAM_ToFirstPerson();
			break;
		case 1:
			CFInput()->CAM_ToThirdPerson();
			break;
		case 2:
			if (GetActiveArmament()->GetWeaponData(0) && GetActiveArmament()->GetWeaponData(0)->m_eWeaponType == WEAPONTYPE_MELEE)
				CFInput()->CAM_ToThirdPerson();
			else
				CFInput()->CAM_ToFirstPerson();
			break;
		}
	}

	m_flLastRespawn = gpGlobals->curtime;
	m_flLastEnemySeen = 0;

	m_flLastCameraTargetTime = 0;

	Instructor_Respawn();

	m_hDrawingDirectTarget = NULL;
	m_hDrawingRecursedTarget = NULL;
	m_flReceivedDirectTarget = 0;
	m_flReceivedRecursedTarget = 0;

	m_eLHEffectElementsOld = ELEMENT_TYPELESS;
	m_eRHEffectElementsOld = ELEMENT_TYPELESS;
	m_iLastCombo = 0;

	m_pLHChargeEffect = m_pRHChargeEffect = NULL;

	for (int i = 0; i < m_apLHComboEffects.Count(); i++)
	{
		ParticleProp()->StopEmission(m_apLHComboEffects[i]);
		ParticleProp()->StopEmission(m_apRHComboEffects[i]);
	}
	m_apLHComboEffects.RemoveAll();
	m_apRHComboEffects.RemoveAll();

	if (!m_pBarrier)
	{
		m_pBarrier = new C_BaseAnimatingOverlay();
		m_pBarrier->InitializeAsClientEntity( "models/magic/barrier.mdl", RENDER_GROUP_OPAQUE_ENTITY );
		m_pBarrier->UseClientSideAnimation();
		m_pBarrier->SetModel("models/magic/barrier.mdl");
		m_pBarrier->AddEffects( EF_NODRAW ); // don't let the renderer draw the model normally
		m_pBarrier->SetOwnerEntity(this);
	}

	m_flShieldTime = 0;
	m_flShieldStrength = 0;
}
コード例 #28
0
ファイル: Player.cpp プロジェクト: jason-amju/amjulib
void Player::Update()
{
  if (m_isLoggedIn)
  {
    Ve1ObjectChar::Update();
  }
  else if (m_sceneNode)
  {
    Matrix m;
    m.Translate(m_pos);
    m_sceneNode->SetLocalTransform(m);

    // Set shadow AABB to same as Scene Node so we don't cull it by mistake
    m_shadow->SetAABB(*(m_sceneNode->GetAABB()));

    static const float XSIZE = ROConfig()->GetFloat("player-aabb-x", 30.0f);
    static const float YSIZE = ROConfig()->GetFloat("player-aabb-y", 100.0f);

    GetAABB()->Set(
      m_pos.x - XSIZE, m_pos.x + XSIZE,
      m_pos.y, m_pos.y + YSIZE,
      m_pos.z - XSIZE, m_pos.z + XSIZE);

    /*
    DISABLED for 2D look and feel
    TurnToFaceDir();
    */
  }

  if (m_hidden)
  {
    return;
  }

  // Stop moving if we are close enough to the destination
  // TODO This ends up happening every frame, only do it if we are moving
  if (true) //m_isMoving)
  {
    Vec3f dir = GetPos() - m_newPos;
    dir.y = 0; // ignore y coord for now
    static const float STOP_DISTANCE = ROConfig()->GetFloat("stop-dist", 20.0f);
    if (dir.SqLen() < STOP_DISTANCE) 
    {
      SetVel(Vec3f(0, 0, 0));
      m_newPos = GetPos();
      SetArrowVis(false);
      m_isMoving = false;
    }
  }
  else
  {
    //Assert(GetVel().SqLen() == 0);
  }

  if (m_sceneNode)
  {
    // Set shadow AABB to same as Scene Node so we don't cull it by mistake
    m_nameTag->SetAABB(*(m_sceneNode->GetAABB()));
  }

  if (m_ignorePortalId != -1)
  {
    GameObject* g = TheGame::Instance()->GetGameObject(m_ignorePortalId);
    if (g)
    {
      const AABB& aabb = g->GetAABB();
      if (!GetAABB()->Intersects(aabb))
      {
        // No longer intersecting portal
        m_ignorePortalId = -1;
      }
    }
    else
    {
      m_ignorePortalId = -1; // ?
    }
  }

  if (IsLocalPlayer())
  {
    TheGSMain::Instance()->SetHeartNum(m_stamina);

    if (m_stamina <= 0)
    {
      // Player now has to go back to the spaceship to regenerate or something.
      if (!m_isDead)
      {
        LurkMsg lm("You need to return to your spaceship to recover from your injuries!", 
          Colour(1, 1, 1, 1), Colour(1, 0, 0, 1), AMJU_CENTRE); 
        TheLurker::Instance()->Queue(lm);
      }

      m_isDead = true;
    }
  }
}
コード例 #29
0
ファイル: Player.cpp プロジェクト: jason-amju/amjulib
void Player::SetKeyVal(const std::string& key, const std::string& val)
{
  Ve1ObjectChar::SetKeyVal(key, val);
  
  static ChatConsole* cc = TheChatConsole::Instance();
  static GSMain* gsm = TheGSMain::Instance();

  if (key == "loggedin")
  {
    bool isLoggedIn = (val == "y");
    SetLoggedIn(isLoggedIn);
    SetLoggedInPlayer(this, m_isLoggedIn);
    gsm->SetNumPlayersOnline(CountOnlinePlayers());

    // So we can notify if current recipient logs in or out
    cc->SetPlayerLoggedIn(this, isLoggedIn);
  }
  else if (key == "istyping")
  {
    int recipId = ToInt(val);
    bool isTyping = (recipId > 0);
    cc->SetPlayerIsTyping(isTyping, GetId(), recipId); 
  }
  else if (key == "beat_up_by")
  {
    if (val != "0" && IsLocalPlayer())
    {
      TheObjectUpdater::Instance()->SendUpdateReq(GetId(), "beat_up_by", "0");
      int oppId = ToInt(val);
      static int prevOpp = 0;
      Player* opp = dynamic_cast<Player*>(TheGame::Instance()->GetGameObject(oppId).GetPtr());
      std::string s = "You just got beat up!";
      if (opp && !opp->GetName().empty())
      {
        s = "You just got beat up by " + opp->GetName();
        if (oppId == prevOpp)
        {
          s += " again!";
        }
        else
        {
          s += "!";
        }
      }
      prevOpp = oppId; // remember previous opponent

      LurkMsg lm(s, LURK_FG, LURK_BG, AMJU_CENTRE); 
      TheLurker::Instance()->Queue(lm);
      ShowAttacked();
    }
  }
  else if (key == FUELCELL_KEY)
  {
    if (IsLocalPlayer())
    {
      int fc = ToInt(val);
      // Lurk msg - total number of fuel cells ever brought to ship
      std::string s;
      if (m_totalFuelCells != -1)
      {
        if (fc == 1)
        {
          s = "You brought a fuel cell to the ship!";
        }
        else
        {
          s = "You have brought a total of " + val + " fuel cells to the ship!";
        }
        LurkMsg lm(s, LURK_FG, LURK_BG, AMJU_CENTRE); 
        TheLurker::Instance()->Queue(lm);
      }
      m_totalFuelCells = fc;

      if (fc > 0 && !HasWonAchievement(ACH_FUEL_CELL_TO_SHIP_1))
      {
        OnWinAchievement(ACH_FUEL_CELL_TO_SHIP_1, "You brought your first fuel cell back to the ship!");
      }
      if (fc >= 5 && !HasWonAchievement(ACH_FUEL_CELL_TO_SHIP_5))
      {
        OnWinAchievement(ACH_FUEL_CELL_TO_SHIP_5, "You brought 5 fuel cells back to the ship!");
      }
      if (fc >= 10 && !HasWonAchievement(ACH_FUEL_CELL_TO_SHIP_10))
      {
        OnWinAchievement(ACH_FUEL_CELL_TO_SHIP_10, "You brought 10 fuel cells back to the ship!");
      }
      // etc
    }
  }
  else if (key == LAST_MSG_SENT_KEY)
  {
    TheMsgManager::Instance()->CheckForNewMsgs();
  }
}
コード例 #30
0
ファイル: CNetworkPlayer.cpp プロジェクト: DarkKlo/maf2mp
void CNetworkPlayer::PutInVehicle( CNetworkVehicle * pVehicle, EntityId seatId )
{
	DEBUG_TRACE("CNetworkPlayer::PutInVehicle");

	// Is the player spawned and the vehicle valid?
	if( m_pPlayerPed && pVehicle && IsSpawned() && pVehicle->IsSpawned() )
	{
		bool bOldControlState;

		// Is this the localplayer?
		if ( IsLocalPlayer() )
		{
			// Get the old control state
			bOldControlState = ((CLocalPlayer *)this)->AreControlsLocked();

			// Lock the player controls
			((CLocalPlayer *)this)->LockControls( true );
		}

		// Does the target vehicle already have a driver?
		if ( pVehicle->GetDriver() )
		{
			// Todo: some checks to check the last sync time from the driver. If he's timed out of not even connected anymore, reset the driver and put this player in the vehicle
			CLogFile::Printf ( "WARNING: Got tasked to put a player (%d) in vehicle (%d), but there's already a driver (%d) in that vehicle!", m_playerId, pVehicle->GetId(), pVehicle->GetDriver()->GetId() );
			CLogFile::Printf ( "Internal driver ped pointer: 0x%p, Internal driver ped vehicle pointer: 0x%p", pVehicle->GetDriver()->GetPlayerPed()->GetPed(), pVehicle->GetDriver()->GetPlayerPed()->GetPed()->m_pCurrentVehicle );

			// Is the driver still in the vehicle?
			if ( pVehicle->GetDriver()->InternalIsInVehicle ( pVehicle->GetVehicle() ) )
				return;

			// Clean the network vehicle data
			pVehicle->HandlePlayerExit ( pVehicle->GetDriver (), 0 );

			CLogFile::Printf ( "We still have a driver set, but he's no longer inside the vehicle. Cleaned network vehicle driver pointer and continuing code.." );
		}

		// Terminate any sync objects if this is not the localplayer
		if ( !IsLocalPlayer() )
			TerminateSyncObjects ();

		// Put the player in the vehicle
		m_pPlayerPed->GetInOutVehicle( pVehicle->GetVehicle()->GetVehicle(), seatId, true, true );

		// Handle with the vehicle
		pVehicle->HandlePlayerEnter ( this, (seatId - 1) );

		// Set the vehicle
		SetVehicle( pVehicle );

		// Set the seat
		SetSeat( seatId );

		// Reset the target data
		SetEnteringVehicle( NULL, INVALID_ENTITY_ID );

		// Set the player state
		m_playerState = (seatId == 1 ? ePlayerState::PLAYERSTATE_DRIVER : ePlayerState::PLAYERSTATE_PASSENGER);

		// Is this the localplayer?
		if ( IsLocalPlayer() )
		{
			// Lock the player controls
			((CLocalPlayer *)this)->LockControls( bOldControlState );
		}
	}
}