This commit is contained in:
MarcEricMartel 2023-12-06 15:47:14 -05:00
parent 7077b617be
commit db854c77b2
3 changed files with 8 additions and 1 deletions

View File

@ -26,6 +26,7 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
} }
if (hit && !player->AmIDead()) { if (hit && !player->AmIDead()) {
player->InflictDamage(damage); player->InflictDamage(damage);
player->m_hit = true;
if (player->AmIDead()) if (player->AmIDead())
player->Killer = m_shooter_id; player->Killer = m_shooter_id;

View File

@ -41,6 +41,7 @@ public:
void addPoint(); void addPoint();
uint64_t Killer = 0; uint64_t Killer = 0;
std::string m_username; std::string m_username;
bool m_hit = false;
private: private:
uint64_t getId() const; uint64_t getId() const;

View File

@ -144,8 +144,11 @@ Timestamp Connection::Run(World* world) {
player->Killer = GetHash(true); player->Killer = GetHash(true);
} }
out.states.jumping = in.keys.jump; out.states.jumping = player->GetVelocity().y > 0.1f;
out.states.running = player->GetVelocity().Length() > .3f; out.states.running = player->GetVelocity().Length() > .3f;
out.states.still = !out.states.running;
out.states.hit = player->m_hit;
player->m_hit = false;
if (player->AmIDead()) { if (player->AmIDead()) {
in.keys.shoot = false; in.keys.shoot = false;
@ -171,6 +174,8 @@ Timestamp Connection::Run(World* world) {
if (in.keys.shoot && m_shoot_acc <= 0.) { if (in.keys.shoot && m_shoot_acc <= 0.) {
Bullets.emplace_back(new Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection(), GetHash(true))); Bullets.emplace_back(new Bullet(player->GetPOV() + player->GetDirection(), player->GetDirection(), GetHash(true)));
out.states.shooting = true; out.states.shooting = true;
if (out.states.jumping)
out.states.jumpshot = true;
m_shoot_acc = BULLET_TIME; m_shoot_acc = BULLET_TIME;
} }