Core/Quests: Add new field RequiredClasses for quest_template Credits to
NoFantasy. * SkillOrClass is converted to RequiredSkill (and then field can contain skill id only) * Field ZoneOrSort has no longer a function in quest requirement, and RequiredClasses must be used instead where class limits are expected. To restrict a quest to one class or more, use bitmask of class in RequiredClasses. RequiredSkill works like before. Signed-off-by: NoFantasy <[email protected]> Signed-off-by: Stalker_Riddick <[email protected]>
This commit is contained in:
@@ -14515,7 +14515,7 @@ Quest const* Player::GetNextQuest(uint64 guid, Quest const* quest)
|
||||
|
||||
bool Player::CanSeeStartQuest(Quest const* quest)
|
||||
{
|
||||
if (SatisfyQuestRace(quest, false) && SatisfyQuestSkillOrClass(quest, false) &&
|
||||
if (SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) && SatisfyQuestSkill(quest, false) &&
|
||||
SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) &&
|
||||
SatisfyQuestPreviousQuest(quest, false) && SatisfyQuestNextChain(quest, false) &&
|
||||
SatisfyQuestPrevChain(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) &&
|
||||
@@ -14530,8 +14530,8 @@ bool Player::CanSeeStartQuest(Quest const* quest)
|
||||
bool Player::CanTakeQuest(Quest const* quest, bool msg)
|
||||
{
|
||||
return SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg)
|
||||
&& SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg)
|
||||
&& SatisfyQuestSkillOrClass(quest, msg) && SatisfyQuestReputation(quest, msg)
|
||||
&& SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg)
|
||||
&& SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg)
|
||||
&& SatisfyQuestPreviousQuest(quest, msg) && SatisfyQuestTimed(quest, msg)
|
||||
&& SatisfyQuestNextChain(quest, msg) && SatisfyQuestPrevChain(quest, msg)
|
||||
&& SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg)
|
||||
@@ -15062,47 +15062,21 @@ void Player::FailQuest(uint32 questId)
|
||||
}
|
||||
}
|
||||
|
||||
bool Player::SatisfyQuestSkillOrClass(Quest const* qInfo, bool msg)
|
||||
bool Player::SatisfyQuestSkill(Quest const* qInfo, bool msg) const
|
||||
{
|
||||
int32 zoneOrSort = qInfo->GetZoneOrSort();
|
||||
int32 skillOrClassMask = qInfo->GetSkillOrClassMask();
|
||||
uint32 skill = qInfo->GetRequiredSkill();
|
||||
|
||||
// skip zone zoneOrSort and 0 case skillOrClass
|
||||
if (zoneOrSort >= 0 && skillOrClassMask == 0)
|
||||
// skip 0 case RequiredSkill
|
||||
if (skill == 0)
|
||||
return true;
|
||||
|
||||
int32 questSort = -zoneOrSort;
|
||||
uint8 reqSortClass = ClassByQuestSort(questSort);
|
||||
|
||||
// check class sort cases in zoneOrSort
|
||||
if (reqSortClass != 0 && getClass() != reqSortClass)
|
||||
// check skill value
|
||||
if (GetSkillValue(skill) < qInfo->GetRequiredSkillValue())
|
||||
{
|
||||
if (msg)
|
||||
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check class
|
||||
if (skillOrClassMask < 0)
|
||||
{
|
||||
uint32 reqClassMask = -int32(skillOrClassMask);
|
||||
if (!(reqClassMask & getClassMask()))
|
||||
{
|
||||
if (msg)
|
||||
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// check skill
|
||||
else if (skillOrClassMask > 0)
|
||||
{
|
||||
uint32 reqSkill = skillOrClassMask;
|
||||
if (GetSkillValue(reqSkill) < qInfo->GetRequiredSkillValue())
|
||||
{
|
||||
if (msg)
|
||||
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -15230,6 +15204,24 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::SatisfyQuestClass(Quest const* qInfo, bool msg) const
|
||||
{
|
||||
uint32 reqClass = qInfo->GetRequiredClasses();
|
||||
|
||||
if (reqClass == 0)
|
||||
return true;
|
||||
|
||||
if ((reqClass & getClassMask()) == 0)
|
||||
{
|
||||
if (msg)
|
||||
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg)
|
||||
{
|
||||
uint32 reqraces = qInfo->GetRequiredRaces();
|
||||
@@ -16201,7 +16193,7 @@ void Player::SendQuestTimerFailed(uint32 quest_id)
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SendCanTakeQuestResponse(uint32 msg)
|
||||
void Player::SendCanTakeQuestResponse(uint32 msg) const
|
||||
{
|
||||
WorldPacket data(SMSG_QUESTGIVER_QUEST_INVALID, 4);
|
||||
data << uint32(msg);
|
||||
|
||||
@@ -1410,10 +1410,11 @@ class Player : public Unit, public GridObject<Player>
|
||||
void IncompleteQuest(uint32 quest_id);
|
||||
void RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool announce = true);
|
||||
void FailQuest(uint32 quest_id);
|
||||
bool SatisfyQuestSkillOrClass(Quest const* qInfo, bool msg);
|
||||
bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const;
|
||||
bool SatisfyQuestLevel(Quest const* qInfo, bool msg);
|
||||
bool SatisfyQuestLog(bool msg);
|
||||
bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg);
|
||||
bool SatisfyQuestClass(Quest const* qInfo, bool msg) const;
|
||||
bool SatisfyQuestRace(Quest const* qInfo, bool msg);
|
||||
bool SatisfyQuestReputation(Quest const* qInfo, bool msg);
|
||||
bool SatisfyQuestStatus(Quest const* qInfo, bool msg);
|
||||
@@ -1493,7 +1494,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SendQuestReward(Quest const* quest, uint32 XP, Object* questGiver);
|
||||
void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK);
|
||||
void SendQuestTimerFailed(uint32 quest_id);
|
||||
void SendCanTakeQuestResponse(uint32 msg);
|
||||
void SendCanTakeQuestResponse(uint32 msg) const;
|
||||
void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver);
|
||||
void SendPushToPartyResponse(Player* player, uint32 msg);
|
||||
void SendQuestUpdateAddItem(Quest const* quest, uint32 item_idx, uint16 count);
|
||||
|
||||
Reference in New Issue
Block a user