Make Arch Enemy use a generic counter, fix some wrong enum names
This commit is contained in:
@@ -300,21 +300,21 @@ void AchievementsStatus::updateAchievementsProgress(unsigned int achieve_data_id
|
||||
gold_driver->increase("follow_leader", "follow_leader", m_variables[WON_FTL_RACES].counter);
|
||||
}
|
||||
|
||||
Achievement *powerup_lover = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::POWERUP_LOVER);
|
||||
Achievement *powerup_lover = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_POWERUP_LOVER);
|
||||
if (!powerup_lover->isAchieved())
|
||||
{
|
||||
powerup_lover->reset();
|
||||
powerup_lover->increase("poweruplover", "poweruplover", m_variables[POWERUP_USED_1RACE].counter);
|
||||
}
|
||||
|
||||
Achievement *banana_lover = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::BANANA);
|
||||
Achievement *banana_lover = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_BANANA);
|
||||
if (!banana_lover->isAchieved())
|
||||
{
|
||||
banana_lover->reset();
|
||||
banana_lover->increase("banana", "banana", m_variables[BANANA_1RACE].counter);
|
||||
}
|
||||
|
||||
Achievement *skidding = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::SKIDDING);
|
||||
Achievement *skidding = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_SKIDDING);
|
||||
if (!skidding->isAchieved())
|
||||
{
|
||||
skidding->reset();
|
||||
@@ -335,6 +335,20 @@ void AchievementsStatus::updateAchievementsProgress(unsigned int achieve_data_id
|
||||
mosquito->increase("swatter", "swatter", m_variables[SWATTER_HIT_1RACE].counter);
|
||||
}
|
||||
|
||||
Achievement *arch_enemy = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_ARCH_ENEMY);
|
||||
if (!arch_enemy->isAchieved())
|
||||
{
|
||||
arch_enemy->reset();
|
||||
int max_hits = 0;
|
||||
for (unsigned int i=0;i<m_kart_hits.size();i++)
|
||||
{
|
||||
if (m_kart_hits[i] > max_hits)
|
||||
max_hits = m_kart_hits[i];
|
||||
}
|
||||
arch_enemy->increase("hit", "hit", max_hits);
|
||||
}
|
||||
|
||||
|
||||
Achievement *marathoner = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_MARATHONER);
|
||||
if (!marathoner->isAchieved())
|
||||
{
|
||||
@@ -421,7 +435,7 @@ void AchievementsStatus::onRaceEnd(bool aborted)
|
||||
m_variables[SKIDDING_1RACE].counter = 0;
|
||||
m_variables[BOWLING_HIT_1RACE].counter = 0;
|
||||
m_variables[SWATTER_HIT_1RACE].counter = 0;
|
||||
|
||||
m_variables[ALL_HITS_1RACE].counter = 0;
|
||||
|
||||
// Prevent restart from being abused to get consecutive wins achievement
|
||||
if (aborted)
|
||||
@@ -481,3 +495,17 @@ void AchievementsStatus::trackEvent(std::string track_ident, AchievementsStatus:
|
||||
else if (event==TR_EGG_HUNT_FINISHED)
|
||||
m_track_stats[track_id].egg_hunt_finished++;
|
||||
} // trackEvent
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void AchievementsStatus::resetKartHits(int num_karts)
|
||||
{
|
||||
m_kart_hits.clear();
|
||||
m_kart_hits.resize(num_karts);
|
||||
} // resetKartHits
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void AchievementsStatus::addKartHit(int kart_id)
|
||||
{
|
||||
m_kart_hits[kart_id]++;
|
||||
updateAchievementsProgress(0);
|
||||
} // addKartHit
|
||||
|
||||
@@ -81,8 +81,12 @@ public :
|
||||
// Count how many times a swatter from the player hit a kart
|
||||
SWATTER_HIT = 23,
|
||||
SWATTER_HIT_1RACE = 24,
|
||||
// Count how many times a swatter, bowling ball or cake from
|
||||
// the player hit a kart (excluding the player's own kart)
|
||||
ALL_HITS = 25,
|
||||
ALL_HITS_1RACE = 26,
|
||||
|
||||
ACHIEVE_DATA_NUM = 25
|
||||
ACHIEVE_DATA_NUM = 27
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -146,6 +150,11 @@ private:
|
||||
|
||||
// TODO : keep track of battle/soccer arenas
|
||||
|
||||
// Keeps track of hits inflicted to other karts,
|
||||
// identified by their world id.
|
||||
// Reset at the beginning of a race
|
||||
std::vector<int> m_kart_hits;
|
||||
|
||||
bool m_online;
|
||||
bool m_valid;
|
||||
|
||||
@@ -169,6 +178,8 @@ public :
|
||||
void onRaceEnd(bool aborted=false);
|
||||
void onLapEnd();
|
||||
void trackEvent(std::string track_ident, AchievementsStatus::TrackData event);
|
||||
void resetKartHits(int num_karts);
|
||||
void addKartHit(int kart_id);
|
||||
// ------------------------------------------------------------------------
|
||||
const std::map<uint32_t, Achievement *>& getAllAchievements()
|
||||
{
|
||||
|
||||
@@ -208,6 +208,18 @@ public:
|
||||
getCurrentAchievementsStatus()->trackEvent(track_ident, event);
|
||||
} // trackEvent
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
static void resetKartHits(int num_karts)
|
||||
{
|
||||
getCurrentAchievementsStatus()->resetKartHits(num_karts);
|
||||
} // resetKartHits
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
static void addKartHit(int kart_id)
|
||||
{
|
||||
getCurrentAchievementsStatus()->addKartHit(kart_id);
|
||||
} // addKartHit
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
}; // PlayerManager
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <IMeshManipulator.h>
|
||||
#include <IMeshSceneNode.h>
|
||||
|
||||
#include "achievements/achievements_status.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/explosion.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
@@ -34,6 +36,7 @@
|
||||
#include "io/xml_node.hpp"
|
||||
#include "items/projectile_manager.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/controller/controller.hpp"
|
||||
#include "karts/explosion_animation.hpp"
|
||||
#include "modes/linear_world.hpp"
|
||||
#include "network/compress_network_body.hpp"
|
||||
@@ -562,6 +565,14 @@ void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object,
|
||||
{
|
||||
world->kartHit(kart->getWorldKartId(),
|
||||
m_owner->getWorldKartId());
|
||||
|
||||
if (m_owner->getController()->canGetAchievements())
|
||||
{
|
||||
if (m_owner->getWorldKartId() != kart->getWorldKartId())
|
||||
PlayerManager::addKartHit(kart->getWorldKartId());
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS, 1);
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS_1RACE, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
// TODO: move some constants to KartProperties, use all constants from KartProperties
|
||||
|
||||
#include "items/swatter.hpp"
|
||||
|
||||
#include "achievements/achievements_status.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
@@ -344,7 +345,9 @@ void Swatter::squashThingsAround()
|
||||
AbstractKart* closest_kart = m_closest_kart;
|
||||
float duration = kp->getSwatterSquashDuration();
|
||||
float slowdown = kp->getSwatterSquashSlowdown();
|
||||
closest_kart->setSquash(duration, slowdown);
|
||||
// The squash attempt may fail because of invulnerability, shield, etc.
|
||||
// Making a bomb explode counts as a success
|
||||
bool success = closest_kart->setSquash(duration, slowdown);
|
||||
|
||||
// Locally add a event to replay the squash during rewind
|
||||
if (NetworkConfig::get()->isNetworking() &&
|
||||
@@ -359,13 +362,23 @@ void Swatter::squashThingsAround()
|
||||
}));
|
||||
}
|
||||
|
||||
// Handle achievement if the swatter is used by the current player
|
||||
if (m_kart->getController()->canGetAchievements())
|
||||
if (success)
|
||||
{
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT, 1);
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT_1RACE, 1);
|
||||
World::getWorld()->kartHit(m_closest_kart->getWorldKartId(),
|
||||
m_kart->getWorldKartId());
|
||||
|
||||
// Handle achievement if the swatter is used by the current player
|
||||
if (m_kart->getController()->canGetAchievements())
|
||||
{
|
||||
PlayerManager::addKartHit(m_closest_kart->getWorldKartId());
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT, 1);
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT_1RACE, 1);
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS, 1);
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::ALL_HITS_1RACE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME : setSquash also do a bomb check
|
||||
if (m_closest_kart->getAttachment()->getType()==Attachment::ATTACH_BOMB)
|
||||
{ // make bomb explode
|
||||
m_closest_kart->getAttachment()->update(10000);
|
||||
@@ -375,12 +388,6 @@ void Swatter::squashThingsAround()
|
||||
projectile_manager->addHitEffect(he);
|
||||
ExplosionAnimation::create(m_closest_kart);
|
||||
} // if kart has bomb attached
|
||||
if (m_closest_kart->isSquashed())
|
||||
{
|
||||
// The kart may not be squashed if it was protected by a bubblegum shield
|
||||
World::getWorld()->kartHit(m_closest_kart->getWorldKartId(),
|
||||
m_kart->getWorldKartId());
|
||||
}
|
||||
|
||||
// TODO: squash items
|
||||
} // squashThingsAround
|
||||
|
||||
@@ -272,9 +272,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Squashes this kart: it will scale the kart in up direction, and causes
|
||||
* a slowdown while this kart is squashed.
|
||||
* Returns true if the squash is successful, false otherwise.
|
||||
* \param time How long the kart will be squashed.
|
||||
* \param slowdown Reduction of max speed. */
|
||||
virtual void setSquash(float time, float slowdown) = 0;
|
||||
virtual bool setSquash(float time, float slowdown) = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Makes the kart unsquashed again. */
|
||||
virtual void unsetSquash() = 0;
|
||||
|
||||
@@ -1795,24 +1795,25 @@ void Kart::showZipperFire()
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Squashes this kart: it will scale the kart in up direction, and causes
|
||||
* a slowdown while this kart is squashed.
|
||||
* Returns true if the squash is successful, false otherwise.
|
||||
* \param time How long the kart will be squashed. A value of 0 will reset
|
||||
* the kart to be unsquashed.
|
||||
* \param slowdown Reduction of max speed.
|
||||
*/
|
||||
void Kart::setSquash(float time, float slowdown)
|
||||
bool Kart::setSquash(float time, float slowdown)
|
||||
{
|
||||
if (isInvulnerable()) return;
|
||||
if (isInvulnerable()) return false;
|
||||
|
||||
if (isShielded())
|
||||
{
|
||||
decreaseShieldTime();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_attachment->getType()==Attachment::ATTACH_BOMB && time>0)
|
||||
{
|
||||
ExplosionAnimation::create(this);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown,
|
||||
@@ -1842,6 +1843,7 @@ void Kart::setSquash(float time, float slowdown)
|
||||
m_squash_time = time;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
} // setSquash
|
||||
|
||||
void Kart::unsetSquash()
|
||||
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
virtual void reset () OVERRIDE;
|
||||
virtual void handleZipper (const Material *m=NULL,
|
||||
bool play_sound=false) OVERRIDE;
|
||||
virtual void setSquash (float time, float slowdown) OVERRIDE;
|
||||
virtual bool setSquash (float time, float slowdown) OVERRIDE;
|
||||
virtual void unsetSquash () OVERRIDE;
|
||||
|
||||
virtual void crashed (AbstractKart *k, bool update_attachments) OVERRIDE;
|
||||
|
||||
@@ -294,6 +294,7 @@ void World::reset(bool restart)
|
||||
(*i)->reset();
|
||||
if ((*i)->getController()->canGetAchievements())
|
||||
{
|
||||
PlayerManager::resetKartHits(getNumKarts());
|
||||
if (race_manager->isLinearRaceMode())
|
||||
{
|
||||
PlayerManager::trackEvent(race_manager->getTrackName(), AchievementsStatus::TR_STARTED);
|
||||
|
||||
@@ -331,11 +331,6 @@ void Physics::update(int ticks)
|
||||
// only the current player can get achievements.
|
||||
if (target_kart != kart && lpc && lpc->canGetAchievements())
|
||||
{
|
||||
// Compare the current value of hits with the 'hit' goal value
|
||||
// (otherwise it would be compared with the kart id goal value,
|
||||
// which doesn't exist.
|
||||
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_ARCH_ENEMY,
|
||||
target_kart->getIdent(), 1, "hit");
|
||||
if (type == PowerupManager::POWERUP_BOWLING)
|
||||
{
|
||||
PlayerManager::increaseAchievement(AchievementsStatus::BOWLING_HIT, 1);
|
||||
|
||||
Reference in New Issue
Block a user