Пример #1
0
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
0
void Damagable::RegainHealth( int RestoreAmount )
{
	if( RestoreAmount < 0 )
		TakeDamage( RestoreAmount * -1, true );
	else
		HealthTarget = min( HealthMax, HealthTarget + RestoreAmount );
}
Пример #3
0
//-----------------------------------------------------------------------------
// 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
0
//-----------------------------------------------------------------------------
// 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
0
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
0
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
0
void CSentry::SentryTouch( CBaseEntity *pOther )
{
	if ( pOther && (pOther->IsPlayer() || (pOther->pev->flags & FL_MONSTER)) )
	{
		TakeDamage(pOther->pev, pOther->pev, 0, 0 );
	}
}
Пример #8
0
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
0
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
0
//-----------------------------------------------------------------------------
// 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
0
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
0
void CGEPropDynamic::InputDestroy(inputdata_t &inputdata)
{
	CTakeDamageInfo destroyinfo;

	destroyinfo.SetDamage(m_iHealth);
	destroyinfo.SetAttacker(inputdata.pActivator);
	destroyinfo.SetInflictor(this);

	TakeDamage(destroyinfo);
}
Пример #13
0
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;
	}
}
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
0
void cEntity::TickInVoid(cChunk & a_Chunk)
{
	if (m_TicksSinceLastVoidDamage == 20)
	{
		TakeDamage(dtInVoid, NULL, 2, 0);
		m_TicksSinceLastVoidDamage = 0;
	}
	else
	{
		m_TicksSinceLastVoidDamage++;
	}
}
Пример #16
0
void AGhost::NotifyActorBeginOverlap(AActor *OtherActor)
{
	Super::NotifyActorBeginOverlap(OtherActor);

	if (!IsPendingKill())
	{
		auto Player = static_cast<APacmanPlayer*>(OtherActor);
		
		// Timer is paused only when player is in hunt mode 
		if (Player->IsHunter())
		{
			TakeDamage(100.f, FDamageEvent(), Player->GetController(), Player);
		}
		else
		{
			Player->TakeDamage(100.f, FDamageEvent(), GetController(), this);
		}

		UGameplayStatics::PlaySound2D(this, CollisionSound);
	}
}
Пример #17
0
void T_Bat (objtype *ob)
{
	id0_long_t move;
	id0_long_t deltax,deltay,size;

	move = ob->speed*tics;
	size = (id0_long_t)ob->size + player->size + move;


	do
	{
		deltax = ob->x - player->x;
		deltay = ob->y - player->y;

		if (deltax <= size && deltax >= -size
		&& deltay <= size && deltay >= -size && !ob->temp1)
		{
			TakeDamage (4);
			ob->temp1 = 2;
		}

		if (move < ob->distance)
		{
			MoveObj (ob,move);
			break;
		}

		actorat[ob->tilex][ob->tiley] = 0;	// pick up marker from goal
		if (ob->dir == nodir)
			ob->dir = north;

		ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
		ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
		move -= ob->distance;

		if (ob->temp1)
		{
			Walk (ob);				// go straight
			if (!--ob->temp1)
			{
				ob->state = &s_batpast;
				ob->ticcount = ob->state->tictime;
			}
		}
		else
			BatChaseThink (ob);		// head towards player

		actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); // set down a new goal marker
		//actorat[ob->tilex][ob->tiley] = ob;	// set down a new goal marker
	} while (0);	// just once
	CalcBounds (ob);
}
Пример #18
0
void CNPC_Sentry::SentryTouch( CBaseEntity *pOther )
{
	//trigger the sentry to turn on if a monster or player touches it
	if ( pOther && (pOther->IsPlayer() || FBitSet ( pOther->GetFlags(), FL_NPC )) )
	{
		CTakeDamageInfo info;
		info.SetAttacker( pOther );
		info.SetInflictor( pOther );
		info.SetDamage( 0 );

		TakeDamage(info);
	}
}
Пример #19
0
void ASCharacter::IncrementHunger()
{
	Hunger = FMath::Clamp(Hunger + IncrementHungerAmount, 0.0f, GetMaxHunger());

	if (Hunger > CriticalHungerThreshold)
	{
		FDamageEvent DmgEvent;
		DmgEvent.DamageTypeClass = HungerDamageType;

		// Apply damage to self.
		TakeDamage(HungerDamagePerInterval, DmgEvent, GetController(), this);
	}
}
Пример #20
0
void cPlayer::HandleFood(void)
{
	// Ref.: http://www.minecraftwiki.net/wiki/Hunger

	if (IsGameModeCreative())
	{
		// Hunger is disabled for Creative
		return;
	}

	// Apply food exhaustion that has accumulated:
	if (m_FoodExhaustionLevel > 4.0)
	{
		m_FoodExhaustionLevel -= 4.0;

		if (m_FoodSaturationLevel > 0.0)
		{
			m_FoodSaturationLevel = std::max(m_FoodSaturationLevel - 1.0, 0.0);
		}
		else
		{
			SetFoodLevel(m_FoodLevel - 1);
		}
	}

	// Heal or damage, based on the food level, using the m_FoodTickTimer:
	if ((m_FoodLevel >= 18) || (m_FoodLevel <= 0))
	{
		m_FoodTickTimer++;
		if (m_FoodTickTimer >= 80)
		{
			m_FoodTickTimer = 0;

			if ((m_FoodLevel >= 18) && (GetHealth() < GetMaxHealth()))
			{
				// Regenerate health from food, incur 3 pts of food exhaustion:
				Heal(1);
				AddFoodExhaustion(3.0);
			}
			else if ((m_FoodLevel <= 0) && (m_Health > 1))
			{
				// Damage from starving
				TakeDamage(dtStarving, NULL, 1, 1, 0);
			}
		}
	}
	else
	{
		m_FoodTickTimer = 0;
	}
}
Пример #21
0
void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);

	// TODO take damage in rain

	// Take damage when touching water, drowning damage seems to be most appropriate
	if (IsSwimming())
	{
		EventLosePlayer();
		TakeDamage(dtDrowning, nullptr, 1, 0);
		// TODO teleport to a safe location
	}

}
Пример #22
0
void Enemy::BulletCollisionCheck()
{
	for (std::list<Bullet *>::iterator IT = BulletList.begin(); IT != BulletList.end(); ++IT)
	{
		if((*IT)->IsAlive())
		{
			if(m_Collider.CheckCollision((*IT)->m_Collider))
			{
				TakeDamage();
				((*IT)-> TakeDamage());
			}

		}
	}
}
Пример #23
0
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((int)floor(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()));
			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()));
		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, (int)floor(GetPosX()), (int)GetPosY() - 1, (int)floor(GetPosZ()), Damage /* Used as particle effect speed modifier */);
		}		

		m_LastGroundHeight = (float)GetPosY();
	}
}
Пример #24
0
void cEntity::DetectCacti(void)
{
	int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT;
	double w = m_Width / 2;
	if (
		((Y > 0) && (Y < cChunkDef::Height)) &&
		((((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) ||
		((GetPosX() - X < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) ||
		(((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) ||
		((GetPosZ() - Z < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) ||
		(((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))))
		)
	{
		TakeDamage(dtCactusContact, NULL, 1, 0);
	}
}
Пример #25
0
void cPlayer::SetTouchGround(bool a_bTouchGround)
{
	// If just
	m_bTouchGround = a_bTouchGround;

	if (!m_bTouchGround)
	{
		if (GetPosY() > m_LastJumpHeight)
		{
			m_LastJumpHeight = (float)GetPosY();
		}
		cWorld * World = GetWorld();
		if ((GetPosY() >= 0) && (GetPosY() < 256))
		{
			BLOCKTYPE BlockType = World->GetBlock( float2int(GetPosX()), float2int(GetPosY()), float2int(GetPosZ()) );
			if (BlockType != E_BLOCK_AIR)
			{
				// LOGD("TouchGround set to true by server");
				m_bTouchGround = true;
			}
			if (
				(BlockType == E_BLOCK_WATER) ||
				(BlockType == E_BLOCK_STATIONARY_WATER) ||
				(BlockType == E_BLOCK_LADDER) ||
				(BlockType == E_BLOCK_VINES)
			)
			{
				// LOGD("Water / Ladder / Torch");
				m_LastGroundHeight = (float)GetPosY();
			}
		}
	}

	if (m_bTouchGround)
	{
		float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
		int Damage = (int)(Dist - 3.f);
		if(m_LastJumpHeight > m_LastGroundHeight) Damage++;
		m_LastJumpHeight = (float)GetPosY();
		if (Damage > 0)
		{
			TakeDamage(dtFalling, NULL, Damage, Damage, 0);
		}

		m_LastGroundHeight = (float)GetPosY();
	}
}
Пример #26
0
void cMonster::HandleFalling()
{
	if (m_bOnGround)
	{
		int Damage = (m_LastGroundHeight - POSY_TOINT) - 3;

		if (Damage > 0)
		{
			TakeDamage(dtFalling, nullptr, Damage, Damage, 0);

			// Fall particles
			GetWorld()->BroadcastSoundParticleEffect(2006, POSX_TOINT, POSY_TOINT - 1, POSZ_TOINT, Damage /* Used as particle effect speed modifier */);
		}

		m_LastGroundHeight = POSY_TOINT;
	}
}
Пример #27
0
//=========================================================
// Touch
//=========================================================
void CRoach :: Touch ( CBaseEntity *pOther )
{
	Vector		vecSpot;
	TraceResult	tr;

	if ( pOther->pev->velocity == g_vecZero || !pOther->IsPlayer() )
	{
		return;
	}

	vecSpot = pev->origin + Vector ( 0 , 0 , 8 );//move up a bit, and trace down.
	UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -24 ),  ignore_monsters, ENT(pev), & tr);

	// This isn't really blood.  So you don't have to screen it out based on violence levels (UTIL_ShouldShowBlood())
	UTIL_DecalTrace( &tr, DECAL_YBLOOD1 +RANDOM_LONG(0,5) );

	TakeDamage( pOther->pev, pOther->pev, pev->health, DMG_CRUSH );
}
Пример #28
0
void CBreakable::BreakTouch( CBaseEntity *pOther )
{
	float flDamage;
	entvars_t*	pevToucher = pOther->pev;
	
	// only players can break these right now
	if ( !pOther->IsPlayer() || !IsBreakable() )
	{
        return;
	}

	if ( FBitSet ( pev->spawnflags, SF_BREAK_TOUCH ) )
	{// can be broken when run into 
		flDamage = pevToucher->velocity.Length() * 0.01;

		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 );
		}
	}

	if ( FBitSet ( pev->spawnflags, SF_BREAK_PRESSURE ) && pevToucher->absmin.z >= pev->maxs.z - 2 )
	{// can be broken when stood upon
		
		// play creaking sound here.
		DamageSound();

		SetThink ( &CBreakable::Die );
		SetTouch( NULL );
		
		if ( m_flDelay == 0 )
		{// !!!BUGBUG - why doesn't zero delay work?
			m_flDelay = 0.1;
		}

		pev->nextthink = pev->ltime + m_flDelay;

	}

}
Пример #29
0
bool CASW_Parasite::CheckInfestTarget( CBaseEntity *pOther )
{
	if (m_flDamageImmuneUntil >= gpGlobals->curtime)
	{
		// no fair infesting while we're invulnerable.
		return false;
	}

	CASW_Marine* pMarine = CASW_Marine::AsMarine( pOther );
	if ( pMarine )
	{
		// if marine has electrified armour on, that protects him from infestation
		if ( pMarine->IsElectrifiedArmorActive() )
		{
			CTakeDamageInfo info( NULL, NULL, Vector(0,0,0), GetAbsOrigin(), GetHealth() * 2, DMG_SHOCK );
			TakeDamage(info);
			return false;
		}

		if ( pMarine->m_takedamage == DAMAGE_NO )
		{
			// We're in the death cam... no fair infesting there
			return false;
		}

		if ( IsOnFire() )
		{
			// don't actually infest if we're on fire, since we'll die very shortly
			return false;
		}

		if ( pMarine->m_iJumpJetting.Get() != 0 )
		{
			// marine is in the middle of a jump jet or blink, don't infest him
			return false;
		}
		return true;
	}
	else if ( pOther->Classify() == CLASS_ASW_COLONIST )
	{
		return !IsOnFire();
	}
	return false;
}
Пример #30
0
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(float2int(GetPosX()), float2int(GetPosY()), float2int(GetPosZ()));
            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()));
        int Damage = (int)(Dist - 3.f);
        if (m_LastJumpHeight > m_LastGroundHeight) Damage++;
        m_LastJumpHeight = (float)GetPosY();

        if ((Damage > 0) && (!IsGameModeCreative()))
        {
            TakeDamage(dtFalling, NULL, Damage, Damage, 0);
        }

        m_LastGroundHeight = (float)GetPosY();
    }
}