From ff03b1fcd0f2ddab9942d44378a758e5918ee998 Mon Sep 17 00:00:00 2001 From: insider42 Date: Sat, 10 Apr 2010 03:01:39 +0400 Subject: [PATCH] [9715] Implement required basic elements for dual spec learn gossips. Required DB data for real work. This is final part required at core side for support. Also note that commit include * generic implementation money cost gossip menu items so let implement in DB many money cost gossip operations with _fixed_ cost. * useful CONDITION_SPELL that let implemtn menu item visible if specific spell known/don't known also wide used case for diff gossips. Signed-off-by: VladimirMangos --- src/game/ObjectMgr.cpp | 25 +++++++++++++++++++++++++ src/game/ObjectMgr.h | 3 ++- src/game/Player.cpp | 14 +++++++++++++- src/shared/revision_nr.h | 2 +- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 0e144e936..b79e4102e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7381,6 +7381,15 @@ bool PlayerCondition::Meets(Player const * player) const } case CONDITION_NOITEM: return !player->HasItemCount(value1, value2); + case CONDITION_SPELL: + { + switch(value2) + { + case 0: return player->HasSpell(value1); + case 1: return !player->HasSpell(value1); + } + return false; + } default: return false; } @@ -7578,6 +7587,22 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val break; } + case CONDITION_SPELL: + { + if(!sSpellStore.LookupEntry(value1)) + { + sLog.outErrorDb("Spell condition requires to have non existing spell (Id: %d), skipped", value1); + return false; + } + + if (value2 > 1) + { + sLog.outErrorDb("Spell condition has invalid argument %u (must be 0..1), skipped", value2); + return false; + } + + break; + } case CONDITION_NONE: break; } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 386fac241..a989f2627 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -314,9 +314,10 @@ enum ConditionType CONDITION_RACE_CLASS = 14, // race_mask class_mask CONDITION_LEVEL = 15, // player_level 0, 1 or 2 (0: equal to, 1: equal or higher than, 2: equal or less than) CONDITION_NOITEM = 16, // item_id count + CONDITION_SPELL = 17, // spell_id 0, 1 (0: has spell, 1: hasn't spell) }; -#define MAX_CONDITION 17 // maximum value in ConditionType enum +#define MAX_CONDITION 18 // maximum value in ConditionType enum struct PlayerCondition { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 97ee96273..2a1ab7909 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -12688,8 +12688,20 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me if (menuId != gossipmenu.GetMenuId()) return; - uint32 gossipOptionId = gossipmenu.GetItem(gossipListId).m_gOptionId; + GossipMenuItem const& menu_item = gossipmenu.GetItem(gossipListId); + + uint32 gossipOptionId = menu_item.m_gOptionId; uint64 guid = pSource->GetGUID(); + uint32 moneyTake = menu_item.m_gBoxMoney; + + // if this function called and player have money for pay MoneyTake or cheating, proccess both cases + if (moneyTake > 0) + { + if (GetMoney() >= moneyTake) + ModifyMoney(-int32(moneyTake)); + else + return; // cheating + } if (pSource->GetTypeId() == TYPEID_GAMEOBJECT) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 93d1f36ba..48a4e39aa 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9714" + #define REVISION_NR "9715" #endif // __REVISION_NR_H__ -- 2.11.4.GIT