Timer iznogoud.

This commit is contained in:
MarcEricMartel
2023-12-06 11:16:39 -05:00
parent 9c1cd885cf
commit c975265901
12 changed files with 118 additions and 54 deletions

View File

@@ -3,7 +3,7 @@
Bullet::Bullet(Vector3f pos, Vector3f dir) : m_startpos(pos), m_currentpos(pos), m_velocity(dir) {}
Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t tid): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_tid(tid) {}
Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id) {}
Bullet::~Bullet() {}
@@ -14,8 +14,19 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
m_currentpos += m_velocity * elapsedtime;
for (auto& [key, player] : mapPlayer) {
if ((m_currentpos - player->GetPosition()).Length() < .4f) {
bool hit = false;
if ((m_currentpos - player->GetPosition()).Length() < .6f)
hit = true;
if ((m_currentpos - player->GetPOV()).Length() < .2f) {
damage *= 2; // HEADSHOT!
hit = true;
}
if (hit && !player->AmIDead()) {
player->InflictDamage(damage);
if (player->AmIDead())
player->Killer = m_shooter_id;
return true;
}
}
@@ -56,6 +67,6 @@ Vector3f Bullet::getVel() const {
return m_velocity;
}
uint64_t Bullet::getTeamID(){
return m_tid;
}
//uint64_t Bullet::getTeamID(){
// return m_tid;
//}