There's a bullet without my name on it.
This commit is contained in:
parent
d3c6353f17
commit
18d6d58203
@ -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) : 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() {}
|
Bullet::~Bullet() {}
|
||||||
|
|
||||||
@ -23,7 +26,8 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
|
|||||||
hit = true;
|
hit = true;
|
||||||
}
|
}
|
||||||
if (hit && !player->AmIDead()) {
|
if (hit && !player->AmIDead()) {
|
||||||
player->InflictDamage(damage);
|
if (m_canhurt)
|
||||||
|
player->InflictDamage(damage);
|
||||||
player->m_hit = true;
|
player->m_hit = true;
|
||||||
|
|
||||||
if (player->AmIDead())
|
if (player->AmIDead())
|
||||||
|
@ -14,6 +14,7 @@ class Bullet {
|
|||||||
public:
|
public:
|
||||||
Bullet(Vector3f pos, Vector3f dir);
|
Bullet(Vector3f pos, Vector3f dir);
|
||||||
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
|
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
|
||||||
|
Bullet(Vector3f pos, Vector3f dir, uint64_t tid, bool canhurt);
|
||||||
~Bullet();
|
~Bullet();
|
||||||
|
|
||||||
bool Update(World* world, float elapsedtime, int perframe, std::unordered_map<uint64_t, Player*> m_mapPlayer, netprot::ChunkMod** chunkmod);
|
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_currentpos,
|
||||||
m_velocity;
|
m_velocity;
|
||||||
uint64_t m_shooter_id = 0;
|
uint64_t m_shooter_id = 0;
|
||||||
|
|
||||||
|
bool m_canhurt = true;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -147,7 +147,7 @@ Timestamp Connection::Run(World* world) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.states.jumping = player->GetIsAirborne();
|
out.states.jumping = player->GetIsAirborne();
|
||||||
out.states.running = player->GetVelocity().Length() > .5f;
|
out.states.running = player->GetVelocity().Length() > .2f;
|
||||||
out.states.still = !out.states.running && !out.states.jumping;
|
out.states.still = !out.states.running && !out.states.jumping;
|
||||||
out.states.hit = player->m_hit;
|
out.states.hit = player->m_hit;
|
||||||
player->m_hit = false;
|
player->m_hit = false;
|
||||||
|
@ -202,8 +202,8 @@ void Server::Run() {
|
|||||||
m_conns.erase(key);
|
m_conns.erase(key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1) - (CHUNK_SIZE_X * WORLD_SIZE_X / 2)) / 8,
|
int x = (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1) - (CHUNK_SIZE_X * WORLD_SIZE_X / 2)) / 16,
|
||||||
y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2)) / 8;
|
y = (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1) - (CHUNK_SIZE_Y * WORLD_SIZE_Y / 2)) / 16;
|
||||||
conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f));
|
conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f));
|
||||||
conn->player->m_username = conn->GetName();
|
conn->player->m_username = conn->GetName();
|
||||||
m_players[key] = conn->player;
|
m_players[key] = conn->player;
|
||||||
@ -280,11 +280,14 @@ void Server::Run() {
|
|||||||
/* Process */
|
/* Process */
|
||||||
|
|
||||||
if (conn->m_nsync) {
|
if (conn->m_nsync) {
|
||||||
|
if (conn->player->AmIDead())
|
||||||
|
conn->m_nsync = false;
|
||||||
|
|
||||||
Timestamp tstamp = conn->Run(m_world);
|
Timestamp tstamp = conn->Run(m_world);
|
||||||
|
|
||||||
if (conn->player->AmIDead()) {
|
if (conn->player->AmIDead()) {
|
||||||
Chat* chat = new Chat();
|
Chat* chat = new Chat();
|
||||||
chat->dest_id = chat->dest_team_id = chat->src_id = 0;
|
chat->dest_id = chat->dest_team_id = chat->src_id = 0;
|
||||||
|
|
||||||
std::string killer = m_conns.at(conn->player->Killer)->player->GetUsername();
|
std::string killer = m_conns.at(conn->player->Killer)->player->GetUsername();
|
||||||
|
|
||||||
@ -293,7 +296,6 @@ void Server::Run() {
|
|||||||
strcpy(chat->mess, 140, mess.c_str());
|
strcpy(chat->mess, 140, mess.c_str());
|
||||||
chatlog.emplace_back(chat);
|
chatlog.emplace_back(chat);
|
||||||
++deadplayers;
|
++deadplayers;
|
||||||
conn->m_nsync = false;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto& chmo : conn->ChunkDiffs)
|
for (auto& chmo : conn->ChunkDiffs)
|
||||||
|
@ -1512,7 +1512,8 @@ void Engine::Render(float elapsedTime) {
|
|||||||
|
|
||||||
std::cout << sync.hp << std::endl;
|
std::cout << sync.hp << std::endl;
|
||||||
m_otherplayerpos = sync.position;
|
m_otherplayerpos = sync.position;
|
||||||
m_player.InflictDamage(sync.hp - comp.hp);
|
|
||||||
|
m_player.InflictDamage(sync.hp - m_player.GetHP());
|
||||||
|
|
||||||
Vector3f diff = sync.position - comp.position;
|
Vector3f diff = sync.position - comp.position;
|
||||||
|
|
||||||
@ -1558,7 +1559,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
break;
|
break;
|
||||||
case BULLET:
|
case BULLET:
|
||||||
if (Deserialize(&bull, pck, &bsize)) {
|
if (Deserialize(&bull, pck, &bsize)) {
|
||||||
Bullet* bult = new Bullet(bull.pos, bull.dir);
|
Bullet* bult = new Bullet(bull.pos, bull.dir, bull.id, false);
|
||||||
for (int x = 0; x < MAX_BULLETS; ++x) // Ajouter une balle dans l'array (aussi connu sous le nom de "faire pow pow").
|
for (int x = 0; x < MAX_BULLETS; ++x) // Ajouter une balle dans l'array (aussi connu sous le nom de "faire pow pow").
|
||||||
if (!m_bullets[x]) {
|
if (!m_bullets[x]) {
|
||||||
m_bullets[x] = bult;
|
m_bullets[x] = bult;
|
||||||
@ -2333,6 +2334,12 @@ void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
|||||||
m_gamestate = GameState::MAIN_MENU;
|
m_gamestate = GameState::MAIN_MENU;
|
||||||
m_selectedPlayOptions = false;
|
m_selectedPlayOptions = false;
|
||||||
m_audio.ToggleMusicState(m_gamestate);
|
m_audio.ToggleMusicState(m_gamestate);
|
||||||
|
if (m_networkgame) {
|
||||||
|
if (m_conn.m_sock_udp)
|
||||||
|
closesocket(m_conn.m_sock_udp);
|
||||||
|
if (m_conn.m_sock_udp)
|
||||||
|
closesocket(m_conn.m_sock_udp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user