[11964] Implement new conditions system

Tree-like design idea by Faramir118, thanks for that!

* Add `conditions` table to store conditions.
* REPLACE current handling of conditions for the *_loot_template tables
  Convert the old conditions in *_loot_template to the new system by SQL-Queries
* ADD support for new conditions to gossip_menu and gossip_menu_option.
  If for these tables no condition_id (new system) is provided, the old conditions will still be used
* Add a small helper python script to contrib/convertConditions, see README there for details
* Add new command to reload the `conditions` table (.reload conditions)
* Add two Meta-Condition types CONDITION_AND (-1) and CONDITION_OR (-2) which are used as:
  value1 (as condition_entry) AND / OR value2 (as condition_entry)

  With these meta-conditions it is possible to create tree like and very complicated combined conditions (like HasAura && (HasItem || HasQuest))

NOTE about conversion:
For easier convertion all the old table data is still preserved, but will be removed eventually (within a circle of the moon approximately)
The python script will not create an optimal initial fill of the `conditions` table. You might want to tweak it manually or suggest some optimized algorithm :)

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Schmoozerd 2012-04-15 22:40:13 +02:00
parent f3b5e1e4bc
commit 8c29893310
18 changed files with 729 additions and 132 deletions

View file

@ -12969,6 +12969,14 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
bool hasMenuItem = true;
if (!isGameMaster()) // Let GM always see menu items regardless of conditions
{
if (itr->second.conditionId && !sObjectMgr.IsPlayerMeetToNEWCondition(this, itr->second.conditionId))
{
if (itr->second.option_id == GOSSIP_OPTION_QUESTGIVER)
canSeeQuests = false;
continue;
}
else if (!itr->second.conditionId)
{
if (itr->second.cond_1 && !sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1))
{
@ -12991,6 +12999,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
continue;
}
}
}
if (pSource->GetTypeId() == TYPEID_UNIT)
{
@ -13340,7 +13349,18 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource)
GossipMenusMapBounds pMenuBounds = sObjectMgr.GetGossipMenusMapBounds(menuId);
for(GossipMenusMap::const_iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
for (GossipMenusMap::const_iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
{
if (itr->second.conditionId && sObjectMgr.IsPlayerMeetToNEWCondition(this, itr->second.conditionId))
{
textId = itr->second.text_id;
// Start related script
if (itr->second.script_id)
GetMap()->ScriptsStart(sGossipScripts, itr->second.script_id, this, pSource);
break;
}
else if (!itr->second.conditionId)
{
if (sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1) && sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_2))
{
@ -13352,6 +13372,7 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource)
break;
}
}
}
return textId;
}