mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Conditions: Implemented new condition source type CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE
This commit is contained in:
@@ -95,7 +95,8 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX_D
|
||||
"Object Visibility (by ID)",
|
||||
"Spawn Group",
|
||||
"Player Condition",
|
||||
"Skill Line Ability"
|
||||
"Skill Line Ability",
|
||||
"Player Choice Response"
|
||||
};
|
||||
|
||||
ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] =
|
||||
@@ -1228,6 +1229,17 @@ bool ConditionMgr::IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConditionMgr::IsObjectMeetingPlayerChoiceResponseConditions(uint32 playerChoiceId, int32 playerChoiceResponseId, Player const* player) const
|
||||
{
|
||||
auto itr = ConditionStore[CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE].find({ .SourceGroup = playerChoiceId, .SourceEntry = playerChoiceResponseId, .SourceId = 0 });
|
||||
if (itr != ConditionStore[CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE].end())
|
||||
{
|
||||
TC_LOG_DEBUG("condition", "GetConditionsForNpcVendor: found conditions for creature entry {} item {}", playerChoiceId, playerChoiceResponseId);
|
||||
return IsObjectMeetToConditions(player, *itr->second);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConditionMgr::IsSpellUsedInSpellClickConditions(uint32 spellId) const
|
||||
{
|
||||
return SpellsUsedInSpellClickConditions.find(spellId) != SpellsUsedInSpellClickConditions.end();
|
||||
@@ -2093,6 +2105,21 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE:
|
||||
{
|
||||
PlayerChoice const* playerChoice = sObjectMgr->GetPlayerChoice(cond->SourceGroup);
|
||||
if (!playerChoice)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "{} SourceGroup in `condition` table, does not exist in `playerchoice`, ignoring.", cond->ToString());
|
||||
return false;
|
||||
}
|
||||
if (!playerChoice->GetResponse(cond->SourceEntry))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "{} SourceEntry in `condition` table, does not exist in `playerchoice_response`, ignoring.", cond->ToString());
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||
case CONDITION_SOURCE_TYPE_SMART_EVENT:
|
||||
|
||||
@@ -188,6 +188,7 @@ enum ConditionSourceType
|
||||
CONDITION_SOURCE_TYPE_SPAWN_GROUP = 33,
|
||||
CONDITION_SOURCE_TYPE_PLAYER_CONDITION = 34,
|
||||
CONDITION_SOURCE_TYPE_SKILL_LINE_ABILITY = 35,
|
||||
CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE = 36,
|
||||
|
||||
CONDITION_SOURCE_TYPE_MAX_DB_ALLOWED,
|
||||
CONDITION_SOURCE_TYPE_REFERENCE_CONDITION = CONDITION_SOURCE_TYPE_MAX_DB_ALLOWED, // internal, not set in db
|
||||
@@ -327,6 +328,7 @@ class TC_GAME_API ConditionMgr
|
||||
bool IsObjectMeetingVehicleSpellConditions(uint32 creatureId, uint32 spellId, Player const* player, Unit const* vehicle) const;
|
||||
bool IsObjectMeetingSmartEventConditions(int64 entryOrGuid, uint32 eventId, uint32 sourceType, Unit const* unit, WorldObject const* baseObject) const;
|
||||
bool IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player const* player, Creature const* vendor) const;
|
||||
bool IsObjectMeetingPlayerChoiceResponseConditions(uint32 playerChoiceId, int32 playerChoiceResponseId, Player const* player) const;
|
||||
|
||||
bool IsSpellUsedInSpellClickConditions(uint32 spellId) const;
|
||||
|
||||
|
||||
@@ -29797,7 +29797,7 @@ void Player::SendPlayerChoice(ObjectGuid sender, int32 choiceId)
|
||||
if (playerChoiceLocale)
|
||||
ObjectMgr::GetLocaleString(playerChoiceLocale->Question, locale, displayPlayerChoice.Question);
|
||||
|
||||
displayPlayerChoice.Responses.resize(playerChoice->Responses.size());
|
||||
displayPlayerChoice.Responses.reserve(playerChoice->Responses.size());
|
||||
displayPlayerChoice.InfiniteRange = false;
|
||||
displayPlayerChoice.HideWarboardHeader = playerChoice->HideWarboardHeader;
|
||||
displayPlayerChoice.KeepOpenAfterChoice = playerChoice->KeepOpenAfterChoice;
|
||||
@@ -29805,7 +29805,10 @@ void Player::SendPlayerChoice(ObjectGuid sender, int32 choiceId)
|
||||
for (std::size_t i = 0; i < playerChoice->Responses.size(); ++i)
|
||||
{
|
||||
PlayerChoiceResponse const& playerChoiceResponseTemplate = playerChoice->Responses[i];
|
||||
WorldPackets::Quest::PlayerChoiceResponse& playerChoiceResponse = displayPlayerChoice.Responses[i];
|
||||
if (!sConditionMgr->IsObjectMeetingPlayerChoiceResponseConditions(choiceId, playerChoiceResponseTemplate.ResponseId, this))
|
||||
continue;
|
||||
|
||||
WorldPackets::Quest::PlayerChoiceResponse& playerChoiceResponse = displayPlayerChoice.Responses.emplace_back();
|
||||
playerChoiceResponse.ResponseID = playerChoiceResponseTemplate.ResponseId;
|
||||
playerChoiceResponse.ResponseIdentifier = playerChoiceResponseTemplate.ResponseIdentifier;
|
||||
playerChoiceResponse.ChoiceArtFileID = playerChoiceResponseTemplate.ChoiceArtFileId;
|
||||
@@ -29847,8 +29850,7 @@ void Player::SendPlayerChoice(ObjectGuid sender, int32 choiceId)
|
||||
playerChoiceResponse.Reward->Xp = playerChoiceResponseTemplate.Reward->Xp;
|
||||
for (PlayerChoiceResponseRewardItem const& item : playerChoiceResponseTemplate.Reward->Items)
|
||||
{
|
||||
playerChoiceResponse.Reward->Items.emplace_back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->Items.back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->Items.emplace_back();
|
||||
rewardEntry.Item.ItemID = item.Id;
|
||||
rewardEntry.Quantity = item.Quantity;
|
||||
if (!item.BonusListIDs.empty())
|
||||
@@ -29859,22 +29861,19 @@ void Player::SendPlayerChoice(ObjectGuid sender, int32 choiceId)
|
||||
}
|
||||
for (PlayerChoiceResponseRewardEntry const& currency : playerChoiceResponseTemplate.Reward->Currency)
|
||||
{
|
||||
playerChoiceResponse.Reward->Items.emplace_back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->Items.back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->Items.emplace_back();
|
||||
rewardEntry.Item.ItemID = currency.Id;
|
||||
rewardEntry.Quantity = currency.Quantity;
|
||||
}
|
||||
for (PlayerChoiceResponseRewardEntry const& faction : playerChoiceResponseTemplate.Reward->Faction)
|
||||
{
|
||||
playerChoiceResponse.Reward->Items.emplace_back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->Items.back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->Items.emplace_back();
|
||||
rewardEntry.Item.ItemID = faction.Id;
|
||||
rewardEntry.Quantity = faction.Quantity;
|
||||
}
|
||||
for (PlayerChoiceResponseRewardItem const& item : playerChoiceResponseTemplate.Reward->ItemChoices)
|
||||
{
|
||||
playerChoiceResponse.Reward->ItemChoices.emplace_back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->ItemChoices.back();
|
||||
WorldPackets::Quest::PlayerChoiceResponseRewardEntry& rewardEntry = playerChoiceResponse.Reward->ItemChoices.emplace_back();
|
||||
rewardEntry.Item.ItemID = item.Id;
|
||||
rewardEntry.Quantity = item.Quantity;
|
||||
if (!item.BonusListIDs.empty())
|
||||
|
||||
Reference in New Issue
Block a user