当前位置: 首页>>代码示例>>C++>>正文


C++ Respawn函数代码示例

本文整理汇总了C++中Respawn函数的典型用法代码示例。如果您正苦于以下问题:C++ Respawn函数的具体用法?C++ Respawn怎么用?C++ Respawn使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Respawn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Respawn

void CreatureGroup::RespawnAll(Creature* except)
{
    for (std::map<ObjectGuid, CreatureGroupMember*>::iterator itr = _members.begin(); itr != _members.end(); ++itr)
        if (itr->first != except->GetObjectGuid())
            if (Creature* otherMember = except->GetMap()->GetCreature(itr->first))
                Respawn(otherMember, itr->second);

    if (except->GetObjectGuid() != GetLeaderGuid())
        if (Creature* otherMember = except->GetMap()->GetCreature(GetLeaderGuid()))
            Respawn(otherMember, NULL);
}
开发者ID:Maduse,项目名称:server,代码行数:11,代码来源:CreatureGroups.cpp

示例2: MESSAGE_BEGIN

BOOL CHealthKit::MyTouch( CBasePlayer *pPlayer )
{
	if ( pPlayer->pev->deadflag != DEAD_NO )
	{
		return FALSE;
	}

	if ( pPlayer->TakeHealth( gSkillData.healthkitCapacity, DMG_GENERIC ) )
	{
		MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
			WRITE_STRING( STRING(pev->classname) );
		MESSAGE_END();

		EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", 1, ATTN_NORM);

		if ( g_pGameRules->ItemShouldRespawn( this ) )
		{
			Respawn();
		}
		else
		{
			UTIL_Remove(this);	
		}

		return TRUE;
	}

	return FALSE;
}
开发者ID:NonPIayerCharacter,项目名称:hlsdk-xash3d,代码行数:29,代码来源:healthkit.cpp

示例3: user

//=========================================================
// Se activa cuando el usuario toca el objeto.
//=========================================================
bool CHealthKit::MyTouch(CBasePlayer *pPlayer)
{
	// En modo Survival esto solo se puede usar desde el inventario.
	if ( InGameRules()->IsSurvival() )
		return false;

	if ( pPlayer->TakeHealth(sk_healthkit.GetFloat(), DMG_GENERIC) )
	{
		CSingleUserRecipientFilter user(pPlayer);
		user.MakeReliable();

		UserMessageBegin(user, "ItemPickup");
			WRITE_STRING(GetClassname());
		MessageEnd();

		CPASAttenuationFilter filter(pPlayer, "HealthKit.Touch");
		EmitSound(filter, pPlayer->entindex(), "HealthKit.Touch");

		if ( g_pGameRules->ItemShouldRespawn(this) )
			Respawn();
		else
			Remove();

		return true;
	}

	return false;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:31,代码来源:item_healthkit.cpp

示例4: SUB_UseTargets

//-----------------------------------------------------------------------------
// Purpose: Touch function that calls the virtual touch function
//-----------------------------------------------------------------------------
void CItem::ItemTouch( CBaseEntity *pOther )
{
	// if it's not a player, ignore
	if ( !pOther->IsPlayer() )
	{
		return;
	}

	CBasePlayer *pPlayer = (CBasePlayer *)pOther;

	// ok, a player is touching this item, but can he have it?
	if ( !g_pGameRules->CanHaveItem( pPlayer, this ) )
	{
		// no? Ignore the touch.
		return;
	}

	if (MyTouch( pPlayer ))
	{
		SUB_UseTargets( pOther, USE_TOGGLE, 0 );
		SetTouch( NULL );
		
		// player grabbed the item. 
		g_pGameRules->PlayerGotItem( pPlayer, this );
		if ( g_pGameRules->ItemShouldRespawn( this ) == GR_ITEM_RESPAWN_YES )
		{
			Respawn(m_flRespawnTime); 
		}
		else
		{
			UTIL_Remove( this );
		}
	}
}
开发者ID:mittorn,项目名称:hlwe_src,代码行数:37,代码来源:items.cpp

示例5: DefaultTouch

void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther )
{
	if ( !pOther->IsPlayer() )
	{
		return;
	}

	if (AddAmmo( pOther ))
	{
		if ( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES )
		{
			Respawn();
		}
		else
		{
			SetTouch( NULL );
			SetThink(SUB_Remove);
			pev->nextthink = gpGlobals->time + .1;
		}
	}
	else if (gEvilImpulse101)
	{
		// evil impulse 101 hack, kill always
		SetTouch( NULL );
		SetThink(SUB_Remove);
		pev->nextthink = gpGlobals->time + .1;
	}
}
开发者ID:vermagav,项目名称:mechmod,代码行数:28,代码来源:weapons.cpp

示例6: UTIL_FireTargets

void CItem::ItemTouch( CBaseEntity *pOther )
{
	//removed this limitation for monsters
	if ( !pOther->IsPlayer() ) return;
	CBasePlayer *pPlayer = (CBasePlayer *)pOther;
	if (!UTIL_IsMasterTriggered(m_sMaster, pPlayer)) return;
	if (pPlayer->pev->deadflag != DEAD_NO) return;

	if (AddItem( pPlayer ) != -1 )
	{
		UTIL_FireTargets( pev->target, pOther, this, USE_TOGGLE );
		SetTouch( NULL );
                  
		if( IsItem() && gmsg.ItemPickup )
		{
			//show icon for item
			MESSAGE_BEGIN( MSG_ONE, gmsg.ItemPickup, NULL, pPlayer->pev );
				WRITE_STRING( STRING(pev->classname) );
			MESSAGE_END();
		}
		
		// play pickup sound
		EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, (char *)PickSound(), 1, ATTN_NORM );
		
		// tell the owner item was taken
 		if (!FNullEnt( pev->owner )) pev->owner->v.impulse = 0;
		
		// enable respawn in multiplayer
		if ( g_pGameRules->IsMultiplayer() && !FBitSet( pev->spawnflags, SF_NORESPAWN ))
			Respawn(); 
		else UTIL_Remove( this );
	}
	else if ( gEvilImpulse101 ) UTIL_Remove( this );
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:34,代码来源:baseitem.cpp

示例7: user

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pPlayer - 
// Output : 
//-----------------------------------------------------------------------------
bool CHealthKit::MyTouch( CBasePlayer *pPlayer )
{
	if ( pPlayer->TakeHealth( sk_healthkit.GetFloat(), DMG_GENERIC ) )
	{
		CSingleUserRecipientFilter user( pPlayer );
		user.MakeReliable();

		UserMessageBegin( user, "ItemPickup" );
			WRITE_STRING( GetClassname() );
		MessageEnd();

		CPASAttenuationFilter filter( pPlayer, "HealthKit.Touch" );
		EmitSound( filter, pPlayer->entindex(), "HealthKit.Touch" );

		if ( g_pGameRules->ItemShouldRespawn( this ) )
		{
			Respawn();
		}
		else
		{
			UTIL_Remove(this);	
		}

		return true;
	}

	return false;
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:33,代码来源:item_healthkit.cpp

示例8: GetInPlayer

//=========================================================
// Se activa cuando el usuario toca el objeto.
//=========================================================
bool CSoda::MyTouch(CBasePlayer *pPlayer)
{
	// En modo Survival esto solo se puede usar desde el inventario.
	if ( g_pGameRules->IsMultiplayer() )
		return false;

	CIN_Player *pInPlayer = GetInPlayer(pPlayer);

	if ( !pPlayer )
		return false;

	if ( pInPlayer->TakeThirst(sk_soda.GetFloat()) != 0 )
	{
		CSingleUserRecipientFilter user(pInPlayer);
		user.MakeReliable();

		UserMessageBegin(user, "ItemPickup");
			WRITE_STRING(GetClassname());
		MessageEnd();

		CPASAttenuationFilter filter(pInPlayer, "Player.Drink");
		EmitSound(filter, entindex(), "Player.Drink");

		if ( g_pGameRules->ItemShouldRespawn(this) )
			Respawn();
		else
			Remove();

		return true;
	}

	return false;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:36,代码来源:item_soda.cpp

示例9: SUB_UseTargets

//-----------------------------------------------------------------------------
// Purpose: Touch function that calls the virtual touch function
//-----------------------------------------------------------------------------
void CQuakeItem::ItemTouch( CBaseEntity *pOther )
{
	// if it's not a player, ignore
	if ( !pOther->IsPlayer() )
		return;

	//Dead?
	if (pOther->pev->health <= 0)
		return;

	CBasePlayer *pPlayer = (CBasePlayer *)pOther;

	// Call the virtual touch function
	if ( MyTouch( pPlayer ) )
	{
		SUB_UseTargets( pOther, USE_TOGGLE, 0 );

		// Respawn if it's not DM==2
		if (gpGlobals->deathmatch != 2)
		{
			Respawn( m_flRespawnTime );
		}
		else
		{
			UTIL_Remove( this );
		}
	}
}
开发者ID:bmk10,项目名称:sing-engine,代码行数:31,代码来源:quake_items.cpp

示例10: CheckForIdleRespawn

void CVehicle::Process(float fElapsedTime)
{
	CPlayerPool* pPlayerPool = pNetGame->GetPlayerPool();
	
	// Check for an idle vehicle.. but don't do this
	// every ::Process because it would be too CPU intensive.
	if(!m_bDeathHasBeenNotified && m_SpawnInfo.iRespawnDelay != (-1) && ((rand() % 20) == 0)) {
		CheckForIdleRespawn();
		return;
	}
	
	// we'll check for a dead vehicle.
	if(m_bDead)
	{
		if (!m_bDeathHasBeenNotified)
		{
			m_bDeathHasBeenNotified = true;
			m_szNumberPlate[0] = 0;

			if(pNetGame->GetGameMode() && pNetGame->GetFilterScripts()) {
				pNetGame->GetFilterScripts()->OnVehicleDeath(m_VehicleID, 255);
				pNetGame->GetGameMode()->OnVehicleDeath(m_VehicleID, 255);
			}
			m_dwLastSeenOccupiedTick = GetTickCount();
		}
		if(!(rand() % 20) && GetTickCount() - m_dwLastSeenOccupiedTick > 10000)
		{
			Respawn();
		}
	}
}
开发者ID:jovazxc,项目名称:samp,代码行数:31,代码来源:vehicle.cpp

示例11: Respawn

void Player::OnBombCollision()
{
	if (m_canBeDamaged)
	{
		Respawn();
	}
}
开发者ID:PiGames,项目名称:Bomberman,代码行数:7,代码来源:Player.cpp

示例12: Respawn

void PlayerVehicle::SetRidden(bool bRidden)
{

	if (bRidden)
	{
		g_pCommonLT->GetObjectFlags(m_hObject, OFT_Flags, m_dwSavedFlags);

		bool bRH = !!(m_dwSavedFlags & FLAG_RAYHIT);

		// Remove flags that cause the vehicle to go through extensive moveobjects.  It will
		// reset its own flags under the respawn.
		g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_FORCEOPTIMIZEOBJECT, FLAG_GRAVITY | FLAG_SOLID | FLAG_RAYHIT | FLAG_TOUCH_NOTIFY | FLAG_FORCEOPTIMIZEOBJECT);

		g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, USRFLG_ATTACH_HIDE1SHOW3, USRFLG_ATTACH_HIDE1SHOW3);

		// We have now been ridden.
		m_bVirgin = false;
	}
	else
	{
		g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, 0, USRFLG_ATTACH_HIDE1SHOW3);
		g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, m_dwSavedFlags, FLAGMASK_ALL);

		uint32 dwFlags;
		g_pCommonLT->GetObjectFlags(m_hObject, OFT_Flags, dwFlags);
		bool bRH = !!(dwFlags & FLAG_RAYHIT);

		// Record the last time this vehicle has been ridden.
		m_fLastRideTime = g_pLTServer->GetTime( );

		Respawn();
	}

	m_bRidden = bRidden;
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:35,代码来源:PlayerVehicle.cpp

示例13: DefaultTouch

void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther )
{
	if ( !pOther->IsPlayer() )
	{
		return;
	}

	if (!UTIL_IsMasterTriggered(m_sMaster, m_pPlayer))	//
		return ;										// AJH allows for locked weapons

	if (AddAmmo( pOther ))
	{
		if ( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES )
		{
			Respawn();
		}
		else
		{
			SetTouch( NULL );
			SetThink(&CBasePlayerAmmo ::SUB_Remove);
			SetNextThink( 0.1 );
		}
		SUB_UseTargets( pOther, USE_TOGGLE, 0 );	//AJH now ammo can trigger stuff too
	}
	else if (gEvilImpulse101)
	{
		// evil impulse 101 hack, kill always
		SetTouch( NULL );
		SetThink(&CBasePlayerAmmo ::SUB_Remove);
		SetNextThink( 0.1 );
	}
}
开发者ID:fmoraw,项目名称:SpiritOfHalfLife,代码行数:32,代码来源:weapons.cpp

示例14: Respawn

void Player::OnKeyDown(const CL_InputEvent &key, const CL_InputState &state)
{
	if (m_flags[eDead]) {
		//TODO: I was a bit lazy here, maybe introduce respawn key as a keybind?
		if (key.id == CL_KEY_F1) {
			Respawn();
		}
		return;
	}

	//TODO: can this be turned into a switch-case without breaking logic?

	if (key.id == m_moveLeftKey) {
		m_moveLeftKeyPressed = true;
		StartMoving(eLeft);
	} 

	if (key.id == m_moveRightKey) {
		m_moveRightKeyPressed = true;
		StartMoving(eRight);
	}

	if (key.id == m_jumpKey && !m_jumpKeyPressed) {
		m_jumpKeyPressed = true;
		StartJump();
	}

	if (key.id == m_attackKey && !m_attackKeyPressed) {
		m_attackKeyPressed = true;
		StartAttack();
	}
}
开发者ID:rkolev,项目名称:diplomna-igra,代码行数:32,代码来源:Player.cpp

示例15: SetTouch

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pOther - 
//-----------------------------------------------------------------------------
void CItem::ItemTouch( CBaseEntity *pOther )
{
	// Vehicles can touch items + pick them up
	if ( pOther->GetServerVehicle() )
	{
		pOther = pOther->GetServerVehicle()->GetPassenger();
		if ( !pOther )
			return;
	}

	// if it's not a player, ignore
	if ( !pOther->IsPlayer() )
		return;

	CBasePlayer *pPlayer = (CBasePlayer *)pOther;

	// Must be a valid pickup scenario (no blocking). Though this is a more expensive
	// check than some that follow, this has to be first Obecause it's the only one
	// that inhibits firing the output OnCacheInteraction.
	if ( ItemCanBeTouchedByPlayer( pPlayer ) == false )
		return;

	m_OnCacheInteraction.FireOutput(pOther, this);

	// Can I even pick stuff up?
	if ( !pPlayer->IsAllowedToPickupWeapons() )
		return;

	// ok, a player is touching this item, but can he have it?
	if ( !g_pGameRules->CanHaveItem( pPlayer, this ) )
	{
		// no? Ignore the touch.
		return;
	}

	if ( MyTouch( pPlayer ) )
	{
		m_OnPlayerTouch.FireOutput(pOther, this);

		SetTouch( NULL );
		SetThink( NULL );

		// player grabbed the item. 
		g_pGameRules->PlayerGotItem( pPlayer, this );
		if ( g_pGameRules->ItemShouldRespawn( this ) == GR_ITEM_RESPAWN_YES )
		{
			Respawn(); 
		}
		else
		{
			UTIL_Remove( this );

		}
	}
	else if (gEvilImpulse101)
	{
		UTIL_Remove( this );
	}
}
开发者ID:Randdalf,项目名称:bliink,代码行数:63,代码来源:item_world.cpp


注:本文中的Respawn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。