There's a bullet without my name on it.

This commit is contained in:
MarcEricMartel
2023-12-13 13:47:34 -05:00
parent d3c6353f17
commit 18d6d58203
5 changed files with 25 additions and 9 deletions

View File

@@ -3,7 +3,10 @@
Bullet::Bullet(Vector3f pos, Vector3f dir) : m_startpos(pos), m_currentpos(pos), m_velocity(dir) {}
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(Vector3f pos, Vector3f dir, uint64_t shooter_id) : m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id) {}
Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t shooter_id, bool canhurt): m_startpos(pos), m_currentpos(pos), m_velocity(dir), m_shooter_id(shooter_id), m_canhurt(canhurt) {}
Bullet::~Bullet() {}
@@ -23,7 +26,8 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
hit = true;
}
if (hit && !player->AmIDead()) {
player->InflictDamage(damage);
if (m_canhurt)
player->InflictDamage(damage);
player->m_hit = true;
if (player->AmIDead())

View File

@@ -14,6 +14,7 @@ class Bullet {
public:
Bullet(Vector3f pos, Vector3f dir);
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
Bullet(Vector3f pos, Vector3f dir, uint64_t tid, bool canhurt);
~Bullet();
bool Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> m_mapPlayer, netprot::ChunkMod** chunkmod);
@@ -27,6 +28,8 @@ private:
m_currentpos,
m_velocity;
uint64_t m_shooter_id = 0;
bool m_canhurt = true;
};