Timer iznogoud.
This commit is contained in:
@@ -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;
|
||||
//}
|
||||
|
@@ -20,13 +20,13 @@ public:
|
||||
void Transpose(int& x, int& z);
|
||||
Vector3f getPos() const;
|
||||
Vector3f getVel() const;
|
||||
uint64_t getTeamID();
|
||||
//uint64_t getTeamID();
|
||||
|
||||
private:
|
||||
Vector3f m_startpos,
|
||||
m_currentpos,
|
||||
m_velocity;
|
||||
uint64_t m_tid = 0;
|
||||
uint64_t m_shooter_id = 0;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -447,7 +447,7 @@ void netprot::Serialize(BulletAdd* bull, char* buf[], uint32_t* buflen) {
|
||||
|
||||
memcpy(*buf + 1, ts8, sizeof(uint64_t));
|
||||
|
||||
uint64_t tid = bull->tid;
|
||||
uint64_t tid = bull->id;
|
||||
uint8_t tid8[sizeof(uint64_t)] = {
|
||||
(uint8_t)((tid >> 56) & 0xFF),
|
||||
(uint8_t)((tid >> 48) & 0xFF),
|
||||
@@ -964,7 +964,7 @@ bool netprot::Deserialize(BulletAdd* bull, char* buf, uint32_t* buflen) {
|
||||
(uint64_t)tst[7];
|
||||
|
||||
memcpy(tst, &buf[1 + sizeof(uint64_t)], sizeof(uint64_t));
|
||||
bull->tid =
|
||||
bull->id =
|
||||
(uint64_t)tst[0] << 56 |
|
||||
(uint64_t)tst[1] << 48 |
|
||||
(uint64_t)tst[2] << 40 |
|
||||
|
@@ -282,20 +282,17 @@ bool Player::AmIDead()
|
||||
}
|
||||
|
||||
|
||||
void Player::InflictDamage(float hitPoints)
|
||||
{
|
||||
|
||||
void Player::InflictDamage(float hitPoints) {
|
||||
m_hp -= hitPoints;
|
||||
|
||||
|
||||
if (AmIDead())
|
||||
{ // Quand le joueur est mort.
|
||||
|
||||
|
||||
|
||||
}
|
||||
//if (AmIDead())
|
||||
//{ // Quand le joueur est mort.
|
||||
//}
|
||||
}
|
||||
|
||||
int Player::getScore() const { return m_score; }
|
||||
|
||||
void Player::addPoint() { ++m_score; }
|
||||
|
||||
|
||||
uint64_t Player::getId() const { return id; }
|
||||
|
||||
|
@@ -37,6 +37,9 @@ public:
|
||||
|
||||
bool AmIDead();
|
||||
void InflictDamage(float hitPoints);
|
||||
int getScore() const;
|
||||
void addPoint();
|
||||
uint64_t Killer = 0;
|
||||
|
||||
private:
|
||||
uint64_t getId() const;
|
||||
@@ -48,6 +51,7 @@ protected:
|
||||
|
||||
std::string m_username;
|
||||
uint64_t id = 0;
|
||||
int m_score = 0;
|
||||
|
||||
float m_rotX = 0;
|
||||
float m_rotY = 0;
|
||||
|
Reference in New Issue
Block a user