static void WPN_Boom(Shot& shot, std::vector<Player>& players, Player* playerThatWasHit, SpriteList& spriteList, FireList& fireList) { std::vector<Player*> killedPlayers; std::vector<Player*> hittedPlayers; Player& author = shot.getPlayer(); Float32 range = shot.getExplosionRange(); Float32 power = shot.getExplosionPower(); const Vector shotCentre = shot.getCentre(); bool shit = shot.getWeapon().shit; if (!shit) { fireList.check(shotCentre, range, spriteList); } for (Player& player : players) { bool directHit = (playerThatWasHit != nullptr && player.is(*playerThatWasHit)); Vector playerCentre = player.getCentre(); Float32 dist = directHit ? 0 : (playerCentre - shotCentre).length(); if (directHit || dist < range) { hittedPlayers.push_back(&player); if (shit) { player.useTemporarySkin(*brownSkin); } else { if (player.hitByShot(directHit ? power : ((range - dist) * power) / range, shot, directHit)) { killedPlayers.push_back(&player); } } } } author.processHits(shot, hittedPlayers); author.processKills(shot, killedPlayers); }
static Hit WPN_ShotPlayerCollision(Shot& shot, std::vector<Player>& players) { const Rectangle shotBox = shot.getCollisionRect(); for (Player& player : players) { if (!player.isInGame() || player.getBonus() == D6_BONUS_INVIS || player.is(shot.getPlayer())) { continue; } if (Collision::rectangles(player.getCollisionRect(), shotBox)) { return {true, &player}; } } return { false, nullptr }; }