From 24944a810cc2c09764c408022bf21b461ffbb88a Mon Sep 17 00:00:00 2001 From: Mathieu Laprise Date: Tue, 6 Jan 2015 14:47:13 -0500 Subject: [PATCH] Add a new achievement : Mosquito Hunter --- data/achievements.xml | 5 ++++- src/achievements/achievement_info.hpp | 3 ++- src/items/swatter.cpp | 12 +++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/data/achievements.xml b/data/achievements.xml index f3025e8ec..f2c94caa8 100644 --- a/data/achievements.xml +++ b/data/achievements.xml @@ -51,5 +51,8 @@ - + + + diff --git a/src/achievements/achievement_info.hpp b/src/achievements/achievement_info.hpp index 367d3ca8b..677170b17 100644 --- a/src/achievements/achievement_info.hpp +++ b/src/achievements/achievement_info.hpp @@ -51,7 +51,8 @@ public: ACHIEVE_GOLD_DRIVER = 6, ACHIEVE_POWERUP_LOVER = 7, ACHIEVE_UNSTOPPABLE = 8, - ACHIEVE_BANANA = 9 + ACHIEVE_BANANA = 9, + ACHIEVE_MOSQUITO = 11 }; /** Achievement check type: diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index 7e85f3a62..ebdfc172d 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -25,10 +25,11 @@ // TODO: move some constants to KartProperties, use all constants from KartProperties #include "items/swatter.hpp" - +#include "achievements/achievement_info.hpp" #include "audio/music_manager.hpp" #include "audio/sfx_base.hpp" #include "audio/sfx_manager.hpp" +#include "config/player_manager.hpp" #include "graphics/explosion.hpp" #include "graphics/irr_driver.hpp" #include "io/file_manager.hpp" @@ -296,6 +297,15 @@ void Swatter::squashThingsAround() kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(), kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown()); + //Handle achievement if the swatter is used by the current player + const StateManager::ActivePlayer *const ap = m_kart->getController() + ->getPlayer(); + if (ap && ap->getConstProfile() == PlayerManager::getCurrentPlayer()) + { + PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_MOSQUITO, + "swatter", 1); + } + if (kart->getAttachment()->getType()==Attachment::ATTACH_BOMB) { // make bomb explode kart->getAttachment()->update(10000);