本文整理汇总了C++中TakeDamage函数的典型用法代码示例。如果您正苦于以下问题:C++ TakeDamage函数的具体用法?C++ TakeDamage怎么用?C++ TakeDamage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TakeDamage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GameServer
void CCharacter::TakeNinja()
{
if (m_ActiveWeapon != WEAPON_NINJA)
return;
m_aWeapons[WEAPON_NINJA].m_Got = false;
m_ActiveWeapon = m_LastWeapon;
if(m_ActiveWeapon == WEAPON_NINJA)
m_ActiveWeapon = WEAPON_HAMMER;
//SetWeapon(m_ActiveWeapon); //has no effect
// Vivid when unfreeze
if (g_Config.m_SvVivid)
{
m_Jumped = false;
GameServer()->CreateExplosion(m_Pos, 0, 0, true);
switch ((int)m_Pos.x+(int)m_Pos.y % 2)
{
case 0:
TakeDamage(vec2(-0.3,-1)*9, 0, 0, 0);
break;
case 1:
TakeDamage(vec2(0.3,-1)*9, 0, 0, 0);
}
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_SPAWN);
}
}
示例2: TakeDamage
void Damagable::RegainHealth( int RestoreAmount )
{
if( RestoreAmount < 0 )
TakeDamage( RestoreAmount * -1, true );
else
HealthTarget = min( HealthMax, HealthTarget + RestoreAmount );
}
示例3: info
//-----------------------------------------------------------------------------
// Purpose: Blows it up!
//-----------------------------------------------------------------------------
void CPropAPC::InputDestroy( inputdata_t &inputdata )
{
CTakeDamageInfo info( this, this, m_iHealth, DMG_BLAST );
info.SetDamagePosition( WorldSpaceCenter() );
info.SetDamageForce( Vector( 0, 0, 1 ) );
TakeDamage( info );
}
示例4: SetNextThink
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPropAPC::Think( void )
{
BaseClass::Think();
SetNextThink( gpGlobals->curtime );
if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake
{
m_bInitialHandbrake = true;
m_VehiclePhysics.SetHandbrake( true );
m_VehiclePhysics.Think();
}
StudioFrameAdvance();
if ( IsSequenceFinished() )
{
int iSequence = SelectWeightedSequence( ACT_IDLE );
if ( iSequence > ACTIVITY_NOT_AVAILABLE )
{
SetCycle( 0 );
m_flAnimTime = gpGlobals->curtime;
ResetSequence( iSequence );
ResetClientsideFrame();
}
}
if (m_debugOverlays & OVERLAY_NPC_KILL_BIT)
{
CTakeDamageInfo info( this, this, m_iHealth, DMG_BLAST );
info.SetDamagePosition( WorldSpaceCenter() );
info.SetDamageForce( Vector( 0, 0, 1 ) );
TakeDamage( info );
}
}
示例5: T_DoDamage
void T_DoDamage (objtype *ob)
{
id0_int_t points;
if (!CheckHandAttack (ob))
{
SD_PlaySound (MONSTERMISSSND);
}
else
{
points = 0;
switch (ob->obclass)
{
case orcobj:
points = 4;
break;
case trollobj:
points = 8;
break;
case demonobj:
points = 15;
break;
}
TakeDamage (points);
}
ob->state = ob->state->next;
}
示例6: SetContextThink
void CRagdollProp::FadeOutThink(void)
{
float dt = gpGlobals->curtime - m_flFadeOutStartTime;
if ( dt < 0 )
{
SetContextThink( &CRagdollProp::FadeOutThink, gpGlobals->curtime + 0.1, s_pFadeOutContext );
}
else if ( dt < m_flFadeTime )
{
float alpha = 1.0f - dt / m_flFadeTime;
int nFade = (int)(alpha * 255.0f);
m_nRenderMode = kRenderTransTexture;
SetRenderColorA( nFade );
NetworkStateChanged();
SetContextThink( &CRagdollProp::FadeOutThink, gpGlobals->curtime + TICK_INTERVAL, s_pFadeOutContext );
}
else
{
// Necessary to cause it to do the appropriate death cleanup
// Yeah, the player may have nothing to do with it, but
// passing NULL to TakeDamage causes bad things to happen
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
CTakeDamageInfo info( pPlayer, pPlayer, 10000.0, DMG_GENERIC );
TakeDamage( info );
UTIL_Remove( this );
}
}
示例7: TakeDamage
void CSentry::SentryTouch( CBaseEntity *pOther )
{
if ( pOther && (pOther->IsPlayer() || (pOther->pev->flags & FL_MONSTER)) )
{
TakeDamage(pOther->pev, pOther->pev, 0, 0 );
}
}
示例8: GetWorld
void cPlayer::SetTouchGround(bool a_bTouchGround)
{
m_bTouchGround = a_bTouchGround;
if (!m_bTouchGround)
{
if (GetPosY() > m_LastJumpHeight)
{
m_LastJumpHeight = (float)GetPosY();
}
cWorld * World = GetWorld();
if ((GetPosY() >= 0) && (GetPosY() < cChunkDef::Height))
{
BLOCKTYPE BlockType = World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT);
if (BlockType != E_BLOCK_AIR)
{
m_bTouchGround = true;
}
if (
(BlockType == E_BLOCK_WATER) ||
(BlockType == E_BLOCK_STATIONARY_WATER) ||
(BlockType == E_BLOCK_LADDER) ||
(BlockType == E_BLOCK_VINES)
)
{
m_LastGroundHeight = (float)GetPosY();
}
}
}
else
{
float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
if (Dist >= 2.0) // At least two blocks - TODO: Use m_LastJumpHeight instead of m_LastGroundHeight above
{
// Increment statistic
m_Stats.AddValue(statDistFallen, (StatValue)floor(Dist * 100 + 0.5));
}
int Damage = (int)(Dist - 3.f);
if (m_LastJumpHeight > m_LastGroundHeight)
{
Damage++;
}
m_LastJumpHeight = (float)GetPosY();
if (Damage > 0)
{
// cPlayer makes sure damage isn't applied in creative, no need to check here
TakeDamage(dtFalling, NULL, Damage, Damage, 0);
// Fall particles
GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, (int)GetPosY() - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
}
m_LastGroundHeight = (float)GetPosY();
}
}
示例9: TakeDamage
void Boss::NotifyCollision(GameObject &other, bool movement)
{
UNUSED_VAR movement;
if (other.Is("Bullet") || other.Is("Attack")) {
Bullet &bullet = (Bullet &)other;
if (!bullet.targetsPlayer)
TakeDamage(50);
}
}
示例10: SpawnSquashedGrub
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAntlionGrub::Squash( CBaseEntity *pOther, bool bDealDamage, bool bSpawnBlood )
{
// If we're already squashed, then don't bother doing it again!
if ( GetEffects() & EF_NODRAW )
return;
SpawnSquashedGrub();
AddEffects( EF_NODRAW );
AddSolidFlags( FSOLID_NOT_SOLID );
// Stop being attached to us
if ( m_hGlowSprite )
{
FadeGlow();
m_hGlowSprite->SetParent( NULL );
}
EmitSound( "NPC_Antlion_Grub.Die" );
EmitSound( "NPC_Antlion_Grub.Squish" );
// if vort stepped on me, maybe he wants to say something
if ( pOther && FClassnameIs( pOther, "npc_vortigaunt" ) )
{
Assert(dynamic_cast<CNPC_Vortigaunt *>(pOther));
static_cast<CNPC_Vortigaunt *>(pOther)->OnSquishedGrub(this);
}
SetTouch( NULL );
//if ( bSpawnBlood )
{
// Temp squash effect
Vector vecForward, vecUp;
AngleVectors( GetAbsAngles(), &vecForward, NULL, &vecUp );
// Start effects at either end of the grub
Vector vecSplortPos = GetAbsOrigin() + vecForward * 14.0f;
DispatchParticleEffect( "GrubSquashBlood", vecSplortPos, GetAbsAngles() );
vecSplortPos = GetAbsOrigin() - vecForward * 16.0f;
Vector vecDir = -vecForward;
QAngle vecAngles;
VectorAngles( vecDir, vecAngles );
DispatchParticleEffect( "GrubSquashBlood", vecSplortPos, vecAngles );
MakeSquashDecals( GetAbsOrigin() + vecForward * 32.0f );
MakeSquashDecals( GetAbsOrigin() - vecForward * 32.0f );
}
// Deal deadly damage to ourself
if ( bDealDamage )
{
CTakeDamageInfo info( pOther, pOther, Vector( 0, 0, -1 ), GetAbsOrigin(), GetHealth()+1, DMG_CRUSH );
TakeDamage( info );
}
}
示例11: Heal
void cPlayer::HandleFood(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
// Remember the food level before processing, for later comparison
int LastFoodLevel = m_FoodLevel;
// Heal or damage, based on the food level, using the m_FoodTickTimer:
if ((m_FoodLevel > 17) || (m_FoodLevel <= 0))
{
m_FoodTickTimer++;
if (m_FoodTickTimer >= 80)
{
m_FoodTickTimer = 0;
if (m_FoodLevel >= 17)
{
// Regenerate health from food, incur 3 pts of food exhaustion:
Heal(1);
m_FoodExhaustionLevel += 3;
}
else if (m_FoodLevel <= 0)
{
// Damage from starving
TakeDamage(dtStarving, NULL, 1, 1, 0);
}
}
}
// Apply food poisoning food exhaustion:
if (m_FoodPoisonedTicksRemaining > 0)
{
m_FoodPoisonedTicksRemaining--;
m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
}
// Apply food exhaustion that has accumulated:
if (m_FoodExhaustionLevel >= 4)
{
m_FoodExhaustionLevel -= 4;
if (m_FoodSaturationLevel >= 1)
{
m_FoodSaturationLevel -= 1;
}
else
{
m_FoodLevel = std::max(m_FoodLevel - 1, 0);
}
}
if (m_FoodLevel != LastFoodLevel)
{
SendHealth();
}
}
示例12: TakeDamage
void CGEPropDynamic::InputDestroy(inputdata_t &inputdata)
{
CTakeDamageInfo destroyinfo;
destroyinfo.SetDamage(m_iHealth);
destroyinfo.SetAttacker(inputdata.pActivator);
destroyinfo.SetInflictor(this);
TakeDamage(destroyinfo);
}
示例13: UTIL_MakeVectors
void CBreakable::BreakTouch(CBaseEntity *pOther)
{
float flDamage;
entvars_t *pevToucher = pOther->pev;
// only players can break these right now
if (!pOther->IsPlayer() || !IsBreakable())
{
if (pev->rendermode == kRenderNormal || !FClassnameIs(pOther->pev, "grenade"))
return;
pev->angles.y = m_angle;
UTIL_MakeVectors(pev->angles);
g_vecAttackDir = gpGlobals->v_forward;
pev->takedamage = DAMAGE_NO;
pev->deadflag = DEAD_DEAD;
pev->effects = EF_NODRAW;
Die();
}
// can be broken when run into
if (pev->spawnflags & SF_BREAK_TOUCH)
{
flDamage = pevToucher->velocity.Length() * 0.01f;
if (flDamage >= pev->health)
{
SetTouch(NULL);
TakeDamage(pevToucher, pevToucher, flDamage, DMG_CRUSH);
// do a little damage to player if we broke glass or computer
pOther->TakeDamage(pev, pev, flDamage / 4, DMG_SLASH);
}
}
// can be broken when stood upon
if ((pev->spawnflags & SF_BREAK_PRESSURE) && pevToucher->absmin.z >= pev->maxs.z - 2)
{
// play creaking sound here.
DamageSound();
SetThink(&CBreakable::Die);
SetTouch(NULL);
// BUGBUG: why doesn't zero delay work?
if (m_flDelay == 0.0f)
{
m_flDelay = 0.1f;
}
pev->nextthink = pev->ltime + m_flDelay;
}
}
示例14: GetMaxHunger
void ASCharacter::IncrementHunger()
{
Hunger = FMath::Clamp(Hunger + IncrementHungerAmount, 0.0f, GetMaxHunger());
if (Hunger > CriticalHungerThreshold)
{
// Apply damage to self.
// TODO: Set DamageType
TakeDamage(10.0f, FDamageEvent(), GetController(), this);
}
}
示例15: TakeDamage
void cEntity::TickInVoid(cChunk & a_Chunk)
{
if (m_TicksSinceLastVoidDamage == 20)
{
TakeDamage(dtInVoid, NULL, 2, 0);
m_TicksSinceLastVoidDamage = 0;
}
else
{
m_TicksSinceLastVoidDamage++;
}
}