Core/Commands: The .setskill command is now usable even if the player doesn't already have the skill learned.

This commit is contained in:
Discover-
2014-01-18 01:05:03 +01:00
parent bbd84d211d
commit 735cebf7a3
2 changed files with 10 additions and 12 deletions

View File

@@ -5072,6 +5072,7 @@ void Spell::EffectResurrectPet(SpellEffIndex /*effIndex*/)
hadPet = false;
}
// TODO: Better to fail Hunter's "Revive Pet" at cast instead of here when casting ends
Pet* pet = player->GetPet(); // Attempt to get current pet
if (!pet || pet->IsAlive())
return;

View File

@@ -1337,23 +1337,20 @@ public:
return false;
}
std::string tNameLink = handler->GetNameLink(target);
bool targetHasSkill = target->GetSkillValue(skill);
if (!target->GetSkillValue(skill))
{
handler->PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, skillLine->name[handler->GetSessionDbcLocale()]);
handler->SetSentErrorMessage(true);
return false;
}
uint16 max = maxPureSkill ? atol (maxPureSkill) : target->GetPureMaxSkillValue(skill);
// If our target does not yet have the skill they are trying to add to them, the chosen level also becomes
// the max level of the new profession.
uint16 max = maxPureSkill ? atol (maxPureSkill) : targetHasSkill ? target->GetPureMaxSkillValue(skill) : uint16(level);
if (level <= 0 || level > max || max <= 0)
return false;
target->SetSkill(skill, target->GetSkillStep(skill), level, max);
handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->name[handler->GetSessionDbcLocale()], tNameLink.c_str(), level, max);
// If the player has the skill, we get the current skill step. If they don't have the skill, we
// add the skill to the player's book with step 1 (which is the first rank, in most cases something
// like 'Apprentice <skill>'.
target->SetSkill(skill, targetHasSkill ? target->GetSkillStep(skill) : 1, level, max);
handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->name[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max);
return true;
}