Don't show an alert when the player uses an offensive powerup

This commit is contained in:
Alayan 2018-09-29 16:41:43 +02:00
parent 7b62947e08
commit 61df9c4b35
4 changed files with 16 additions and 5 deletions

View File

@ -225,6 +225,9 @@ public:
/** Returns the type of flyable. */
PowerupManager::PowerupType getType() const {return m_type;}
// ------------------------------------------------------------------------
/** Returns the owner's kart */
AbstractKart *getOwner() const { return m_owner;}
// ------------------------------------------------------------------------
/** Sets wether Flyable should update TerrainInfo as part of its update
* call, or if the inheriting object will update TerrainInfo itself
* (or perhaps not at all if it is not needed). */

View File

@ -201,7 +201,8 @@ bool ProjectileManager::projectileIsClose(const AbstractKart * const kart,
* \param type The type of projectile checked
*/
int ProjectileManager::getNearbyProjectileCount(const AbstractKart * const kart,
float radius, PowerupManager::PowerupType type)
float radius, PowerupManager::PowerupType type,
bool exclude_owned)
{
float r2 = radius * radius;
int projectile_count = 0;
@ -212,6 +213,9 @@ int ProjectileManager::getNearbyProjectileCount(const AbstractKart * const kart,
continue;
if (i->second->getType() == type)
{
if (exclude_owned && (i->second->getOwner() == kart))
continue;
float dist2 = i->second->getXYZ().distance2(kart->getXYZ());
if (dist2 < r2)
{

View File

@ -72,7 +72,8 @@ public:
float radius);
int getNearbyProjectileCount(const AbstractKart * const kart,
float radius, PowerupManager::PowerupType type);
float radius, PowerupManager::PowerupType type,
bool exclude_owned=false);
// ------------------------------------------------------------------------
/** Adds a special hit effect to be shown.
* \param hit_effect The hit effect to be added. */

View File

@ -841,11 +841,14 @@ void RaceGUI::drawMiscInfo(const AbstractKart *kart,
// and in most cases fly too quickly to make an alert useful
int projectile_types[3]; //[2] basket, [1] cakes, [0] bowling
projectile_types[0] = projectile_manager->getNearbyProjectileCount(kart, 15.0f /*alert radius*/,
PowerupManager::POWERUP_BOWLING);
PowerupManager::POWERUP_BOWLING,
true /* exclude if owned by the kart */);
projectile_types[1] = projectile_manager->getNearbyProjectileCount(kart, 25.0f /*alert radius*/,
PowerupManager::POWERUP_CAKE);
PowerupManager::POWERUP_CAKE,
true /* exclude if owned by the kart */);
projectile_types[2] = projectile_manager->getNearbyProjectileCount(kart, 50.0f /*alert radius*/,
PowerupManager::POWERUP_RUBBERBALL);
PowerupManager::POWERUP_RUBBERBALL,
true /* exclude if owned by the kart */);
int icon_to_use = 2;
int projectile_to_show = -1;