本文整理汇总了C++中HL2MPRules函数的典型用法代码示例。如果您正苦于以下问题:C++ HL2MPRules函数的具体用法?C++ HL2MPRules怎么用?C++ HL2MPRules使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HL2MPRules函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFireRate
float GetFireRate(void) {
#ifdef MFS
#ifdef CLIENT_DLL
CHL2MPRules *pRules = HL2MPRules();
if (pRules->IsFlash() == true)
#else
if (HL2MPRules()->IsFlash() == true)
#endif
{
CHL2MP_Player *pOwner = ToHL2MPPlayer(GetOwner());
return KNIFE_REFIRE - KNIFE_REFIRE * (pOwner->speed_modifier / 2000 - pOwner->speed_modifier / 4000); //An insane Refire Rate
}
#endif
#ifdef CLIENT_DLL
#ifdef MFS
else
#endif
if (pRules->IsKnifeFight() == true)
#else
#ifdef MFS
else
#endif
if (HL2MPRules()->IsKnifeFight() == true)
#endif
return KNIFE_REFIRE*0.7;
else
return KNIFE_REFIRE;
}
示例2: SetNextThink
void CGameDomCaptureZone::SoundThink(void)
{
SetNextThink(gpGlobals->curtime + 0.1f);
// Si ça appartient à aucune équipe, pas de son (genre points neutres en début de map)
if(HL2MPRules()->m_iDomZones[m_iZoneID] != TEAM_PINK && HL2MPRules()->m_iDomZones[m_iZoneID] != TEAM_GREEN)
return;
// Score toutes les 5 secondes, faut synchroniser le son avec
// float flDomScoreTimer = (HL2MPRules()->GetForceDomScoreTimer() != -1)?HL2MPRules()->GetForceDomScoreTimer():mp_dom_scoretime.GetFloat();
if(gpGlobals->curtime < (m_flLastScore + 5))
return;
m_flLastScore = gpGlobals->curtime;
int iScoreLeft = mp_scorelimit_dom.GetInt() - g_Teams[HL2MPRules()->m_iDomZones[m_iZoneID]]->GetScore();
int pitch = (pow(1.019f,-iScoreLeft+260))+30;
pitch = clamp(pitch, 30, 163);
CPASAttenuationFilter filter( this, 0.8 );
EmitSound_t ep;
ep.m_nChannel = CHAN_STATIC;
ep.m_pSoundName = "gameplay/domscore.wav";
ep.m_flVolume = 1.0f;
ep.m_SoundLevel = SNDLVL_80dB;
ep.m_nPitch = pitch;
EmitSound( filter, entindex(), ep );
}
示例3: HL2MPRules
void CGameFortsInfoZone::AddPlayerToInfosList(CBasePlayer *pPlayer)
{
if(pPlayer == NULL)
return;
if(pPlayer->GetTeamNumber() == TEAM_PINK)
{
for(int i = 0; i < FORTS_MAX_INFOS; i++)
{
if(HL2MPRules()->m_apFortsInfosPink[i] == NULL)
{
HL2MPRules()->m_apFortsInfosPink[i] = pPlayer;
break;
}
}
}
else
{
for(int i = 0; i < FORTS_MAX_INFOS; i++)
{
if(HL2MPRules()->m_apFortsInfosGreen[i] == NULL)
{
HL2MPRules()->m_apFortsInfosGreen[i] = pPlayer;
break;
}
}
}
}
示例4: WorldSpaceCenter
void CFlechette::DoAOEDamage()
{
CBaseEntity *ppEnts[256];
Vector vecCenter = WorldSpaceCenter();
float flRadius = flechette_radius.GetFloat();
vecCenter.z -= flRadius * 0.8f;
int nEntCount = UTIL_EntitiesInSphere( ppEnts, 256, vecCenter, flRadius, 0 );
int i;
for ( i = 0; i < nEntCount; i++ )
{
if ( ppEnts[i] == NULL )
continue;
bool bDoDamage = true;
if(ppEnts[i]->IsPlayer() || ppEnts[i]->IsNPC())
{
CBasePlayer *pOtherPlayer = ToBasePlayer(ppEnts[i]);
CBasePlayer *pPlayer = ToBasePlayer(GetOwnerEntity());
if(pOtherPlayer != NULL && pPlayer != NULL)
{
if((HL2MPRules()->IsTeamplay() && (pPlayer->GetTeamNumber() == pOtherPlayer->GetTeamNumber()))
|| HL2MPRules()->GetGameType() == GAME_COOP)
{
const int oldHealth = pOtherPlayer->GetHealth();
pOtherPlayer->TakeHealth( HEAL_AMOUNT, DMG_GENERIC );
bDoDamage = false;
if(oldHealth <= HEAL_AMOUNT)
pOtherPlayer->PlayAutovocal(HEALED,0);
if(oldHealth != pOtherPlayer->GetHealth()) // Si on a vraiment heal
pOtherPlayer->EmitSound("Tranqu.Heal");
}
}
if(bDoDamage && ppEnts[i] != GetOwnerEntity())
{
int iApplyDamage = 0;
if(ppEnts[i]->IsNPC())
iApplyDamage = 70;
else
{
if(ppEnts[i]->GetHealth() < m_iDamage + 10)
iApplyDamage = 100;
else
iApplyDamage = ppEnts[i]->GetHealth() - m_iDamage;
}
CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), GetOwnerEntity(), iApplyDamage, DMG_POISON | DMG_NEVERGIB );
//CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f );
dmgInfo.SetDamagePosition( vecCenter );
ppEnts[i]->TakeDamage(dmgInfo);
//ppEnts[i]->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr );
}
}
ApplyMultiDamage();
}
}
示例5: Q_snprintf
void CHL2MP_Player::ChangeTeam( int iTeam )
{
/* if ( GetNextTeamChangeTime() >= gpGlobals->curtime )
{
char szReturnString[128];
Q_snprintf( szReturnString, sizeof( szReturnString ), "Please wait %d more seconds before trying to switch teams again.\n", (int)(GetNextTeamChangeTime() - gpGlobals->curtime) );
ClientPrint( this, HUD_PRINTTALK, szReturnString );
return;
}*/
#ifndef GE_DLL
bool bKill = false;
if ( HL2MPRules()->IsTeamplay() != true && iTeam != TEAM_SPECTATOR )
{
//don't let them try to join combine or rebels during deathmatch.
iTeam = TEAM_UNASSIGNED;
}
if ( HL2MPRules()->IsTeamplay() == true )
{
if ( iTeam != GetTeamNumber() && GetTeamNumber() != TEAM_UNASSIGNED )
{
bKill = true;
}
}
BaseClass::ChangeTeam( iTeam );
m_flNextTeamChangeTime = gpGlobals->curtime + TEAM_CHANGE_INTERVAL;
if ( HL2MPRules()->IsTeamplay() == true )
{
SetPlayerTeamModel();
}
else
{
SetPlayerModel();
}
if ( iTeam == TEAM_SPECTATOR )
{
RemoveAllItems( true );
State_Transition( STATE_OBSERVER_MODE );
}
if ( bKill == true )
{
CommitSuicide();
}
#else
BaseClass::ChangeTeam( iTeam );
#endif
}
示例6: HL2MPRules
void CPlayerFortsTimerProxy::OnBind( void *pC_BaseEntity )
{
if(HL2MPRules()->GetGameType() != GAME_FORTS)
return;
float flPhaseLimit = HL2MPRules()->GetLastFortsPhaseTime();
flPhaseLimit += HL2MPRules()->IsFortsBuildPhase() ? mp_forts_buildtime.GetFloat() * 60 : mp_forts_fighttime.GetFloat() * 60;
// Produit en croix
// ? | curtime
// 360 | phaselimit
SetFloatResult( ceil( gpGlobals->curtime * m_RangeMax.GetFloat() / flPhaseLimit ));
}
示例7: ToBasePlayer
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 );
}
}
示例8: GetOwner
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponTranquilizer::CreateLaserPointer( void )
{
#ifndef CLIENT_DLL
if ( m_hLaserDot != NULL )
return;
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return;
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return;
m_hLaserDot = CLaserDot::Create( GetAbsOrigin(), GetOwner() );
m_hLaserDot->TurnOff();
m_hLaserDot->SetRenderMode(kRenderWorldGlow);
if(HL2MPRules()->IsTeamplay())
{
if(pOwner->GetTeamNumber() == TEAM_PINK)
m_hLaserDot->SetRenderColor(255,100,255,255);
else
m_hLaserDot->SetRenderColor(153,255,153,255);
}
else
m_hLaserDot->SetRenderColor(255,0,0,255);
UpdateLaserPosition();
#endif
}
示例9: EmitSound
void CWeaponHL2MPBase::Materialize( void )
{
if ( IsEffectActive( EF_NODRAW ) )
{
// changing from invisible state to visible.
EmitSound( "AlyxEmp.Charge" );
RemoveEffects( EF_NODRAW );
DoMuzzleFlash();
}
if ( HasSpawnFlags( SF_NORESPAWN ) == false )
{
VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false );
SetMoveType( MOVETYPE_VPHYSICS );
HL2MPRules()->AddLevelDesignerPlacedObject( this );
}
if ( HasSpawnFlags( SF_NORESPAWN ) == false )
{
if ( GetOriginalSpawnOrigin() == vec3_origin )
{
m_vOriginalSpawnOrigin = GetAbsOrigin();
m_vOriginalSpawnAngles = GetAbsAngles();
}
}
SetPickupTouch();
SetThink (NULL);
}
示例10: EmitSound
//====================================================================================
// WEAPON SPAWNING
//====================================================================================
//-----------------------------------------------------------------------------
// Purpose: Make a weapon visible and tangible
//-----------------------------------------------------------------------------//
void CBaseCombatWeapon::Materialize( void )
{
if ( IsEffectActive( EF_NODRAW ) )
{
// changing from invisible state to visible.
#ifdef HL2MP
EmitSound( "AlyxEmp.Charge" );
#else
EmitSound( "BaseCombatWeapon.WeaponMaterialize" );
#endif
RemoveEffects( EF_NODRAW );
DoMuzzleFlash();
}
#ifdef HL2MP
if ( HasSpawnFlags( SF_NORESPAWN ) == false )
{
VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false );
SetMoveType( MOVETYPE_VPHYSICS );
HL2MPRules()->AddLevelDesignerPlacedObject( this );
}
#else
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_TRIGGER );
#endif
SetPickupTouch();
SetThink (NULL);
}
示例11: Q_strncpy
void CHL2MP_Player::CheckChatText( char *p, int bufsize )
{
//Look for escape sequences and replace
char *buf = new char[bufsize];
int pos = 0;
// Parse say text for escape sequences
for ( char *pSrc = p; pSrc != NULL && *pSrc != 0 && pos < bufsize-1; pSrc++ )
{
// copy each char across
buf[pos] = *pSrc;
pos++;
}
buf[pos] = '\0';
// copy buf back into p
Q_strncpy( p, buf, bufsize );
delete[] buf;
const char *pReadyCheck = p;
HL2MPRules()->CheckChatForReadySignal( this, pReadyCheck );
}
示例12: AddMultiDamage
void C_HL2MP_Player::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr )
{
Vector vecOrigin = ptr->endpos - vecDir * 4;
float flDistance = 0.0f;
if ( info.GetAttacker() )
{
flDistance = (ptr->endpos - info.GetAttacker()->GetAbsOrigin()).Length();
}
if ( m_takedamage )
{
AddMultiDamage( info, this );
int blood = BloodColor();
CBaseEntity *pAttacker = info.GetAttacker();
if ( pAttacker )
{
if ( HL2MPRules()->IsTeamplay() && pAttacker->InSameTeam( this ) == true )
return;
}
if ( blood != DONT_BLEED )
{
SpawnBlood( vecOrigin, vecDir, blood, flDistance );// a little surface blood.
TraceBleed( flDistance, vecDir, ptr, info.GetDamageType() );
}
}
}
示例13: SetNextThink
//-----------------------------------------------------------------------------
// Purpose: Items that have just spawned run this think to catch them when
// they hit the ground. Once we're sure that the object is grounded,
// we change its solid type to trigger and set it in a large box that
// helps the player get it.
//-----------------------------------------------------------------------------
void CItem::FallThink ( void )
{
SetNextThink( gpGlobals->curtime + 0.1f );
bool shouldMaterialize = false;
IPhysicsObject *pPhysics = VPhysicsGetObject();
if ( pPhysics )
{
shouldMaterialize = pPhysics->IsAsleep();
}
else
{
shouldMaterialize = (GetFlags() & FL_ONGROUND) ? true : false;
}
if ( shouldMaterialize )
{
SetThink ( NULL );
m_vOriginalSpawnOrigin = GetAbsOrigin();
m_vOriginalSpawnAngles = GetAbsAngles();
HL2MPRules()->AddLevelDesignerPlacedObject( this );
}
}
示例14: UTIL_GetNearestPlayer
bool CNPC_Zombine::AllowedToSprint( void )
{
if ( IsOnFire() )
return false;
//If you're sprinting then there's no reason to sprint again.
if ( IsSprinting() )
return false;
int iChance = SPRINT_CHANCE_VALUE;
//Secobmod FixMe ?? also changed to HL2MPRules
CHL2_Player *pPlayer = dynamic_cast <CHL2_Player*> ( UTIL_GetNearestPlayer(GetAbsOrigin() ));
//CHL2MP_Player *pPlayer = dynamic_cast<CHL2MP_Player *>( UTIL_GetNearestPlayer(GetAbsOrigin() );
if ( pPlayer )
{
#ifdef MFS
if ( HL2MPRules()->IsAlyxInDarknessMode() && pPlayer->FlashlightIsOn() == false )
#else
if (IsAlyxInDarknessMode() && pPlayer->FlashlightIsOn() == false)
#endif
{
iChance = SPRINT_CHANCE_VALUE_DARKNESS;
}
//Bigger chance of this happening if the player is not looking at the zombie
if ( pPlayer->FInViewCone( this ) == false )
{
iChance *= 2;
}
}
if ( HasGrenade() )
{
iChance *= 4;
}
//Below 25% health they'll always sprint
if ( ( GetHealth() > GetMaxHealth() * 0.5f ) )
{
if ( IsStrategySlotRangeOccupied( SQUAD_SLOT_ZOMBINE_SPRINT1, SQUAD_SLOT_ZOMBINE_SPRINT2 ) == true )
return false;
if ( random->RandomInt( 0, 100 ) > iChance )
return false;
if ( m_flSprintRestTime > gpGlobals->curtime )
return false;
}
float flLength = ( GetEnemy()->WorldSpaceCenter() - WorldSpaceCenter() ).Length();
if ( flLength > MAX_SPRINT_DISTANCE )
return false;
return true;
}
示例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;
// Can I even pick stuff up?
if ( pOther->IsEFlagSet( EFL_NO_WEAPON_PICKUP ) )
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;
}
// Must be a valid pickup scenario (no blocking)
if ( ItemCanBeTouchedByPlayer( pPlayer ) == false )
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 );
#ifdef HL2MP
HL2MPRules()->RemoveLevelDesignerPlacedObject( this );
#endif
}
}
else if (gEvilImpulse101)
{
UTIL_Remove( this );
}
}