Implemented some spell achievements

This commit is contained in:
arrai 2008-11-08 23:07:39 +01:00
parent 7a384e9374
commit 73e595ef87
4 changed files with 142 additions and 13 deletions

View file

@ -27,6 +27,61 @@
#include "GameEvent.h"
#include "World.h"
const CriteriaCastSpellRequirement* AchievementMgr::criteriaCastSpellRequirements[] =
{
new CriteriaCastSpellRequirement(5272, 3057, 0, 0),
new CriteriaCastSpellRequirement(5273, 2784, 0, 0),
new CriteriaCastSpellRequirement(5752, 9099, 0, 0),
new CriteriaCastSpellRequirement(5753, 8403, 0, 0),
new CriteriaCastSpellRequirement(5772, 0, 0, RACE_GNOME),
new CriteriaCastSpellRequirement(5774, 0, 0, RACE_BLOODELF),
new CriteriaCastSpellRequirement(5775, 0, 0, RACE_DRAENEI),
new CriteriaCastSpellRequirement(5776, 0, 0, RACE_DWARF),
new CriteriaCastSpellRequirement(5777, 0, 0, RACE_HUMAN),
new CriteriaCastSpellRequirement(5778, 0, 0, RACE_NIGHTELF),
new CriteriaCastSpellRequirement(5779, 0, 0, RACE_ORC),
new CriteriaCastSpellRequirement(5780, 0, 0, RACE_TAUREN),
new CriteriaCastSpellRequirement(5781, 0, 0, RACE_TROLL),
new CriteriaCastSpellRequirement(5782, 0, 0, RACE_UNDEAD_PLAYER),
new CriteriaCastSpellRequirement(6225, 5661, 0, 0),
new CriteriaCastSpellRequirement(6226, 26044, 0, 0),
new CriteriaCastSpellRequirement(6228, 739, 0, 0),
new CriteriaCastSpellRequirement(6229, 927, 0, 0),
new CriteriaCastSpellRequirement(6230, 1444, 0, 0),
new CriteriaCastSpellRequirement(6231, 8140, 0, 0),
new CriteriaCastSpellRequirement(6232, 5489, 0, 0),
new CriteriaCastSpellRequirement(6233,12336, 0, 0),
new CriteriaCastSpellRequirement(6234, 1351, 0, 0),
new CriteriaCastSpellRequirement(6235, 5484, 0, 0),
new CriteriaCastSpellRequirement(6236, 1182, 0, 0),
new CriteriaCastSpellRequirement(6237, 0, CLASS_DEATH_KNIGHT, RACE_ORC),
new CriteriaCastSpellRequirement(6238, 0, CLASS_WARRIOR, RACE_HUMAN),
new CriteriaCastSpellRequirement(6239, 0, CLASS_SHAMAN, RACE_TAUREN),
new CriteriaCastSpellRequirement(6240, 0, CLASS_DRUID, RACE_NIGHTELF),
new CriteriaCastSpellRequirement(6241, 0, CLASS_ROGUE, RACE_UNDEAD_PLAYER),
new CriteriaCastSpellRequirement(6242, 0, CLASS_HUNTER, RACE_TROLL),
new CriteriaCastSpellRequirement(6243, 0, CLASS_MAGE, RACE_GNOME),
new CriteriaCastSpellRequirement(6244, 0, CLASS_PALADIN, RACE_DWARF),
new CriteriaCastSpellRequirement(6245, 0, CLASS_WARLOCK, RACE_BLOODELF),
new CriteriaCastSpellRequirement(6246, 0, CLASS_PRIEST, RACE_DRAENEI),
new CriteriaCastSpellRequirement(6312, 0, CLASS_WARLOCK, RACE_GNOME),
new CriteriaCastSpellRequirement(6313, 0, CLASS_DEATH_KNIGHT, RACE_HUMAN),
new CriteriaCastSpellRequirement(6314, 0, CLASS_PRIEST, RACE_NIGHTELF),
new CriteriaCastSpellRequirement(6315, 0, CLASS_SHAMAN, RACE_ORC),
new CriteriaCastSpellRequirement(6316, 0, CLASS_DRUID, RACE_TAUREN),
new CriteriaCastSpellRequirement(6317, 0, CLASS_ROGUE, RACE_TROLL),
new CriteriaCastSpellRequirement(6318, 0, CLASS_WARRIOR, RACE_UNDEAD_PLAYER),
new CriteriaCastSpellRequirement(6319, 0, CLASS_MAGE, RACE_BLOODELF),
new CriteriaCastSpellRequirement(6320, 0, CLASS_PALADIN, RACE_DRAENEI),
new CriteriaCastSpellRequirement(6321, 0, CLASS_HUNTER, RACE_DWARF),
new CriteriaCastSpellRequirement(6662, 31261, 0, 0),
NULL};
AchievementMgr::AchievementMgr(Player *player)
{
m_player = player;
@ -187,7 +242,7 @@ void AchievementMgr::CheckAllAchievementCriteria()
/**
* this function will be called whenever the user might have done a criteria relevant action
*/
void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1, uint32 miscvalue2, uint32 time)
void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1, uint32 miscvalue2, Unit *unit, uint32 time)
{
sLog.outString("AchievementMgr::UpdateAchievementCriteria(%u, %u, %u, %u)", type, miscvalue1, miscvalue2, time);
AchievementCriteriaEntryList const& achievementCriteriaList = objmgr.GetAchievementCriteriaByType(type);
@ -334,11 +389,54 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
continue;
SetCriteriaProgress(achievementCriteria, miscvalue2, true);
break;
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
if (!miscvalue1 || miscvalue1 != achievementCriteria->be_spell_target.spellID)
continue;
SetCriteriaProgress(achievementCriteria, 1, true);
break;
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
if (!miscvalue1 || miscvalue1 != achievementCriteria->cast_spell.spellID)
continue;
SetCriteriaProgress(achievementCriteria, 1, true);
break;
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
if (!miscvalue1 || miscvalue1 != achievementCriteria->cast_spell.spellID)
continue;
// those requirements couldn't be found in the dbc
const CriteriaCastSpellRequirement *requirement = NULL;
for (uint32 i=0; criteriaCastSpellRequirements[i]; i++)
{
if (criteriaCastSpellRequirements[i]->achievementCriteriaId == achievementCriteria->ID)
{
requirement = criteriaCastSpellRequirements[i];
break;
}
}
if (requirement)
{
if (!unit)
continue;
if (requirement->creatureEntry && unit->GetEntry() != requirement->creatureEntry)
continue;
if (requirement->playerRace && (unit->GetTypeId() != TYPEID_PLAYER || unit->getRace()!=requirement->playerRace))
continue;
if (requirement->playerClass && (unit->GetTypeId() != TYPEID_PLAYER || unit->getClass()!=requirement->playerClass))
continue;
}
SetCriteriaProgress(achievementCriteria, 1, true);
break;
}
if(IsCompletedCriteria(achievementCriteria))
CompletedCriteria(achievementCriteria);
}
}
bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achievementCriteria)
{
AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement);
@ -412,6 +510,12 @@ bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achieve
return progress->counter >= achievementCriteria->own_item.itemCount;
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
return progress->counter >= achievementCriteria->loot_item.itemCount;
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
return progress->counter >= achievementCriteria->be_spell_target.spellCount;
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
return progress->counter >= achievementCriteria->cast_spell.castCount;
// handle all statistic-only criteria here
case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND: