Make Mosquito Hunter use a generic counter

This commit is contained in:
Alayan 2018-10-03 03:43:27 +02:00 committed by auriamg
parent 5144984fd5
commit bdbd66dbb7
4 changed files with 16 additions and 5 deletions

View File

@ -62,7 +62,7 @@
name="It's secret" description="Really ... a secret.">
</achievement>
<achievement id="11" check-type="all-at-least" reset-type="race"
name="Mosquito Hunter" description="Take your opponents for mosquitos! With the swatter, squash at least 5 of them in a race.">
name="Mosquito Hunter" description="Take your opponents for mosquitos! With the swatter, squash them at least 5 times in a race.">
<swatter goal="5"/>
</achievement>
<achievement id="12" check-type="all-at-least" reset-type="never"

View File

@ -319,6 +319,13 @@ void AchievementsStatus::updateAchievementsProgress(unsigned int achieve_data_id
strike->increase("ball", "ball", m_variables[BOWLING_HIT].counter);
}
Achievement *mosquito = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_MOSQUITO);
if (!mosquito->isAchieved())
{
mosquito->reset();
mosquito->increase("swatter", "swatter", m_variables[SWATTER_HIT_1RACE].counter);
}
Achievement *columbus = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_COLUMBUS);
if (!columbus->isAchieved())
{
@ -386,6 +393,7 @@ void AchievementsStatus::onRaceEnd(bool aborted)
m_variables[ACHIEVE_BANANA_1RACE].counter = 0;
m_variables[ACHIEVE_SKIDDING_1RACE].counter = 0;
m_variables[BOWLING_HIT_1RACE].counter = 0;
m_variables[SWATTER_HIT_1RACE].counter = 0;
// Prevent restart from being abused to get consecutive wins achievement

View File

@ -78,8 +78,11 @@ public :
// Count how many times a bowling ball from the player hit a kart
BOWLING_HIT = 21,
BOWLING_HIT_1RACE = 22,
// Count how many times a swatter from the player hit a kart
SWATTER_HIT = 23,
SWATTER_HIT_1RACE = 24,
ACHIEVE_DATA_NUM = 23
ACHIEVE_DATA_NUM = 25
};
private:

View File

@ -25,7 +25,7 @@
// TODO: move some constants to KartProperties, use all constants from KartProperties
#include "items/swatter.hpp"
#include "achievements/achievement_info.hpp"
#include "achievements/achievements_status.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
@ -362,8 +362,8 @@ void Swatter::squashThingsAround()
// Handle achievement if the swatter is used by the current player
if (m_kart->getController()->canGetAchievements())
{
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_MOSQUITO,
"swatter", 1);
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT, 1);
PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT_1RACE, 1);
}
if (m_closest_kart->getAttachment()->getType()==Attachment::ATTACH_BOMB)