TrinityCore/TrinityCore — Issue #4734: [Core][Fix] Achievement: Spore Loser
Author: Warpten
Created: 2012-01-09 05:38:34+00:00
State: open

```diff
diff --git a/sql/custom/achievement_spore_loser.sql b/sql/custom/achievement_spore_loser.sql
new file mode 100644
index 0000000..d147fd8
--- /dev/null
+++ b/sql/custom/achievement_spore_loser.sql
@@ -0,0 +1,4 @@
+﻿DELETE FROM `achievement_criteria_data` WHERE `criteria_id` IN (7612,7613);
+INSERT INTO `achievement_criteria_data` (`criteria_id`,`type`,`value1`,`value2`,`ScriptName`) VALUES
+(7612,11,0,0, 'achievement_spore_loser'),
+(7613,11,0,0, 'achievement_spore_loser');
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp
index 6db29be..da5c099 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp
@@ -36,19 +36,22 @@ enum Events
EVENT_DOOM,
};

+enum Achievement
+{
+ DATA_ACHIEVEMENT_SPORE_LOSER = 2182,
+};
+
class boss_loatheb : public CreatureScript
{
public:
boss_loatheb() : CreatureScript("boss_loatheb") { }

- CreatureAI* GetAI(Creature* creature) const
- {
- return new boss_loathebAI (creature);
- }
-
struct boss_loathebAI : public BossAI
{
- boss_loathebAI(Creature* c) : BossAI(c, BOSS_LOATHEB) {}
+ boss_loathebAI(Creature* creature) : BossAI(creature, BOSS_LOATHEB)
+ {
+ _sporeLoserData = true;
+ }

void EnterCombat(Unit* /*who*/)
{
@@ -58,6 +61,24 @@ public:
events.ScheduleEvent(EVENT_DOOM, 120000);
}

+ void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/)
+ {
+ _sporeLoserData = false;
+ }
+
+ void JustSummoned(Creature* summon)
+ {
+ summons.Summon(summon);
+ }
+
+ uint32 GetData(int32 id)
+ {
+ if (id != DATA_ACHIEVEMENT_SPORE_LOSER)
+ return 0;
+
+ return uint32(_sporeLoserData);
+ }
+
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
@@ -88,11 +109,33 @@ public:

DoMeleeAttackIfReady();
}
+
+ private:
+ bool _sporeLoserData;
};

+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return new boss_loathebAI (creature);
+ }
+};
+
+class achievement_spore_loser : public AchievementCriteriaScript
+{
+ public:
+ achievement_spore_loser() : AchievementCriteriaScript(" achievement_spore_loser") { }
+
+ bool OnCheck(Player* /*source*/, Unit* target)
+ {
+ if (!target)
+ return false;
+
+ return target->GetAI()->GetData(DATA_ACHIEVEMENT_SPORE_LOSER);
+ }
};

void AddSC_boss_loatheb()
{
new boss_loatheb();
+ new achievement_spore_loser();
}
```

Unable to test, please try it. Closes #4651