Пример #1
0
bool cGhast::Attack(std::chrono::milliseconds a_Dt)
{
	m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;
	
	if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
	{
		// Setting this higher gives us more wiggle room for attackrate
		Vector3d Speed = GetLookVector() * 20;
		Speed.y = Speed.y + 1;
		cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
		if (GhastBall == nullptr)
		{
			return false;
		}
		if (!GhastBall->Initialize(*m_World))
		{
			delete GhastBall;
			GhastBall = nullptr;
			return false;
		}
		m_World->BroadcastSpawnEntity(*GhastBall);
		m_AttackInterval = 0.0;
		
		return true;
	}
	return false;
}
Пример #2
0
void cBlaze::Attack(std::chrono::milliseconds a_Dt)
{
	m_AttackInterval += (static_cast<float>(a_Dt.count()) / 1000) * m_AttackRate;

	if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
	{
		// Setting this higher gives us more wiggle room for attackrate
		Vector3d Speed = GetLookVector() * 20;
		Speed.y = Speed.y + 1;
		cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
		if (FireCharge == nullptr)
		{
			return;
		}
		if (!FireCharge->Initialize(*m_World))
		{
			delete FireCharge;
			FireCharge = nullptr;
			return;
		}
		m_World->BroadcastSpawnEntity(*FireCharge);
		m_AttackInterval = 0.0;
		// ToDo: Shoot 3 fireballs instead of 1.
	}
}
Пример #3
0
void cBlaze::Attack(float a_Dt)
{
	m_AttackInterval += a_Dt * m_AttackRate;

	if (m_Target != NULL && m_AttackInterval > 3.0)
	{
		// Setting this higher gives us more wiggle room for attackrate
		Vector3d Speed = GetLookVector() * 20;
		Speed.y = Speed.y + 1;
		cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
		if (FireCharge == NULL)
		{
			return;
		}
		if (!FireCharge->Initialize(*m_World))
		{
			delete FireCharge;
			FireCharge = NULL;
			return;
		}
		m_World->BroadcastSpawnEntity(*FireCharge);
		m_AttackInterval = 0.0;
		// ToDo: Shoot 3 fireballs instead of 1.
	}
}
Пример #4
0
bool cBlaze::Attack(std::chrono::milliseconds a_Dt)
{
	if ((m_Target != nullptr) && (m_AttackCoolDownTicksLeft == 0))
	{
		// Setting this higher gives us more wiggle room for attackrate
		Vector3d Speed = GetLookVector() * 20;
		Speed.y = Speed.y + 1;
		cFireChargeEntity * FireCharge = new cFireChargeEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
		if (FireCharge == nullptr)
		{
			return false;
		}
		if (!FireCharge->Initialize(*m_World))
		{
			delete FireCharge;
			FireCharge = nullptr;
			return false;
		}
		m_World->BroadcastSpawnEntity(*FireCharge);
		ResetAttackCooldown();
		// ToDo: Shoot 3 fireballs instead of 1.
		return true;
	}
	return false;
}
Пример #5
0
Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
{
	Vector3d res = GetLookVector();
	res.Normalize();
	
	// TODO: Add a slight random change (+-0.0075 in each direction)
	
	return res * a_SpeedCoeff;
}	
Пример #6
0
void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
{
	if (m_AttachedTo == NULL)
	{
		return;
	}
	if ((a_Forward != 0) || (a_Sideways != 0))
	{
		Vector3d LookVector = GetLookVector();
		double AddSpeedX = LookVector.x * a_Forward + LookVector.z * a_Sideways;
		double AddSpeedZ = LookVector.z * a_Forward - LookVector.x * a_Sideways;
		m_AttachedTo->AddSpeed(AddSpeedX, 0, AddSpeedZ);
	}
}
Пример #7
0
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	super::OnHitEntity(a_EntityHit, a_HitPos);

	int Damage = static_cast<int>(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
	if (m_IsCritical)
	{
		Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
	}

	unsigned int PowerLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPower);
	if (PowerLevel > 0)
	{
		int ExtraDamage = static_cast<int>(ceil(0.25 * (PowerLevel + 1)));
		Damage += ExtraDamage;
	}

	// int KnockbackAmount = 1;
	unsigned int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
	if (PunchLevel > 0)
	{
		Vector3d LookVector = GetLookVector();
		Vector3f FinalSpeed = Vector3f(0, 0, 0);
		switch (PunchLevel)
		{
			case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5); break;
			case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8); break;
			default: break;
		}
		a_EntityHit.SetSpeed(FinalSpeed);
	}

	// a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);  // TODO fix knockback.
	a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 0);  // Until knockback is fixed.

	if (IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming())
	{
		a_EntityHit.StartBurning(100);
	}

	// Broadcast successful hit sound
	GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));

	Destroy();
}
Пример #8
0
bool cBlaze::Attack(std::chrono::milliseconds a_Dt)
{
	if ((GetTarget() != nullptr) && (m_AttackCoolDownTicksLeft == 0))
	{
		// Setting this higher gives us more wiggle room for attackrate
		Vector3d Speed = GetLookVector() * 20;
		Speed.y = Speed.y + 1;

		auto FireCharge = cpp14::make_unique<cFireChargeEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
		auto FireChargePtr = FireCharge.get();
		if (!FireChargePtr->Initialize(std::move(FireCharge), *m_World))
		{
			return false;
		}

		ResetAttackCooldown();
		// ToDo: Shoot 3 fireballs instead of 1.

		return true;
	}
	return false;
}
Пример #9
0
void cSkeleton::Attack(float a_Dt)
{
	m_AttackInterval += a_Dt * m_AttackRate;

	if (m_Target != NULL && m_AttackInterval > 3.0)
	{
		// Setting this higher gives us more wiggle room for attackrate
		Vector3d Speed = GetLookVector() * 20;
		Speed.y = Speed.y + 1;
		cArrowEntity * Arrow = new cArrowEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
		if (Arrow == NULL)
		{
			return;
		}
		if (!Arrow->Initialize(*m_World))
		{
			delete Arrow;
			return;
		}
		m_World->BroadcastSpawnEntity(*Arrow);
		m_AttackInterval = 0.0;
	}
}
Пример #10
0
bool cGhast::Attack(std::chrono::milliseconds a_Dt)
{
	if ((m_Target != nullptr) && (m_AttackCoolDownTicksLeft == 0))
	{
		// Setting this higher gives us more wiggle room for attackrate
		Vector3d Speed = GetLookVector() * 20;
		Speed.y = Speed.y + 1;
		cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
		if (GhastBall == nullptr)
		{
			return false;
		}
		if (!GhastBall->Initialize(*m_World))
		{
			delete GhastBall;
			GhastBall = nullptr;
			return false;
		}
		m_World->BroadcastSpawnEntity(*GhastBall);
		ResetAttackCooldown();
		return true;
	}
	return false;
}
Пример #11
0
void Camera::RotateW(double angle) {
	Rotate(GetEyePoint(), GetLookVector(), angle);
}
Пример #12
0
void Camera::RotateU(double angle) {
	Rotate(GetEyePoint(), cross(GetLookVector(), GetUpVector()), angle);
}