Core/ConditionMgr: added CONDITION_SOURCE_TYPE_VEHICLE_SPELL, sourceGroup=creatureTemplate.entry, sourceEntry=spellEntry
--HG-- branch : trunk
This commit is contained in:
@@ -309,6 +309,22 @@ ConditionList ConditionMgr::GetConditionsForNotGroupedEntry(ConditionSourceType
|
|||||||
return spellCond;
|
return spellCond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID)
|
||||||
|
{
|
||||||
|
ConditionList cond;
|
||||||
|
VehicleSpellConditionMap::const_iterator itr = m_VehicleSpellConditions.find(creatureID);
|
||||||
|
if (itr != m_VehicleSpellConditions.end())
|
||||||
|
{
|
||||||
|
ConditionTypeMap::const_iterator i = (*itr).second.find(spellID);
|
||||||
|
if (i != (*itr).second.end())
|
||||||
|
{
|
||||||
|
cond = (*i).second;
|
||||||
|
sLog.outDebug("GetConditionsForVehicleSpell: found conditions for Vehicle entry %u spell %u", creatureID, spellID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cond;
|
||||||
|
}
|
||||||
|
|
||||||
void ConditionMgr::LoadConditions(bool isReload)
|
void ConditionMgr::LoadConditions(bool isReload)
|
||||||
{
|
{
|
||||||
Clean();
|
Clean();
|
||||||
@@ -482,6 +498,24 @@ void ConditionMgr::LoadConditions(bool isReload)
|
|||||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||||
bIsDone = addToGossipMenuItems(cond);
|
bIsDone = addToGossipMenuItems(cond);
|
||||||
break;
|
break;
|
||||||
|
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
|
||||||
|
{
|
||||||
|
//if no list for vehicle create one
|
||||||
|
if (m_VehicleSpellConditions.find(cond->mSourceGroup) == m_VehicleSpellConditions.end())
|
||||||
|
{
|
||||||
|
ConditionTypeMap cmap;
|
||||||
|
m_VehicleSpellConditions[cond->mSourceGroup] = cmap;
|
||||||
|
}
|
||||||
|
//if no list for vehicle's spell create one
|
||||||
|
if (m_VehicleSpellConditions[cond->mSourceGroup].find(cond->mSourceEntry) == m_VehicleSpellConditions[cond->mSourceGroup].end())
|
||||||
|
{
|
||||||
|
ConditionList clist;
|
||||||
|
m_VehicleSpellConditions[cond->mSourceGroup][cond->mSourceEntry] = clist;
|
||||||
|
}
|
||||||
|
m_VehicleSpellConditions[cond->mSourceGroup][cond->mSourceEntry].push_back(cond);
|
||||||
|
bIsDone = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -944,6 +978,21 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
|
||||||
|
{
|
||||||
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(cond->mSourceGroup))
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->mSourceGroup);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SpellEntry const* spellProto = sSpellStore.LookupEntry(cond->mSourceEntry);
|
||||||
|
if (!spellProto)
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->mSourceEntry);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
||||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||||
case CONDITION_SOURCE_TYPE_NONE:
|
case CONDITION_SOURCE_TYPE_NONE:
|
||||||
@@ -1321,6 +1370,20 @@ void ConditionMgr::Clean()
|
|||||||
|
|
||||||
m_ConditionMap.clear();
|
m_ConditionMap.clear();
|
||||||
|
|
||||||
|
|
||||||
|
for (VehicleSpellConditionMap::iterator itr = m_VehicleSpellConditions.begin(); itr != m_VehicleSpellConditions.end(); ++itr)
|
||||||
|
{
|
||||||
|
for (ConditionTypeMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
|
||||||
|
{
|
||||||
|
for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
|
||||||
|
delete *i;
|
||||||
|
it->second.clear();
|
||||||
|
}
|
||||||
|
itr->second.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_VehicleSpellConditions.clear();
|
||||||
|
|
||||||
// this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
|
// this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
|
||||||
for (std::list<Condition*>::const_iterator itr = m_AllocatedMemory.begin(); itr != m_AllocatedMemory.end(); ++itr)
|
for (std::list<Condition*>::const_iterator itr = m_AllocatedMemory.begin(); itr != m_AllocatedMemory.end(); ++itr)
|
||||||
delete *itr;
|
delete *itr;
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ enum ConditionSourceType
|
|||||||
CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET = 18,//DONE
|
CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET = 18,//DONE
|
||||||
CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19,//DONE
|
CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19,//DONE
|
||||||
CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK = 20,//DONE
|
CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK = 20,//DONE
|
||||||
CONDITION_SOURCE_TYPE_MAX = 21//MAX
|
CONDITION_SOURCE_TYPE_VEHICLE_SPELL = 21,//DONE
|
||||||
|
CONDITION_SOURCE_TYPE_MAX = 22//MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Condition
|
struct Condition
|
||||||
@@ -129,7 +130,8 @@ struct Condition
|
|||||||
|
|
||||||
typedef std::list<Condition*> ConditionList;
|
typedef std::list<Condition*> ConditionList;
|
||||||
typedef std::map<uint32, ConditionList > ConditionTypeMap;
|
typedef std::map<uint32, ConditionList > ConditionTypeMap;
|
||||||
typedef std::map<ConditionSourceType, ConditionTypeMap > ConditionMap;//used for all conditions, except references
|
typedef std::map<ConditionSourceType, ConditionTypeMap > ConditionMap;
|
||||||
|
typedef std::map<uint32, ConditionTypeMap > VehicleSpellConditionMap;
|
||||||
|
|
||||||
typedef std::map<uint32, ConditionList > ConditionReferenceMap;//only used for references
|
typedef std::map<uint32, ConditionList > ConditionReferenceMap;//only used for references
|
||||||
|
|
||||||
@@ -147,11 +149,13 @@ class ConditionMgr
|
|||||||
|
|
||||||
bool IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* invoker = NULL);
|
bool IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* invoker = NULL);
|
||||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
||||||
|
ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
ConditionMap m_ConditionMap;
|
ConditionMap m_ConditionMap;
|
||||||
ConditionReferenceMap m_ConditionReferenceMap;
|
ConditionReferenceMap m_ConditionReferenceMap;
|
||||||
|
VehicleSpellConditionMap m_VehicleSpellConditions;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -176,7 +180,8 @@ class ConditionMgr
|
|||||||
sourceType == CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE ||
|
sourceType == CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE ||
|
||||||
sourceType == CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE ||
|
sourceType == CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE ||
|
||||||
sourceType == CONDITION_SOURCE_TYPE_GOSSIP_MENU ||
|
sourceType == CONDITION_SOURCE_TYPE_GOSSIP_MENU ||
|
||||||
sourceType == CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION);
|
sourceType == CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION ||
|
||||||
|
sourceType == CONDITION_SOURCE_TYPE_VEHICLE_SPELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clean(); // free up resources
|
void Clean(); // free up resources
|
||||||
|
|||||||
@@ -19028,6 +19028,12 @@ void Player::VehicleSpellInitialize()
|
|||||||
if (!spellInfo)
|
if (!spellInfo)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
ConditionList conditions = sConditionMgr.GetConditionsForVehicleSpell(veh->ToCreature()->GetEntry(), spellId);
|
||||||
|
if (!sConditionMgr.IsPlayerMeetToConditions(this, conditions))
|
||||||
|
{
|
||||||
|
sLog.outDebug("VehicleSpellInitialize: conditions not met for Vehicle entry %u spell %u", veh->ToCreature()->GetEntry(), spellId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (IsPassiveSpell(spellId))
|
if (IsPassiveSpell(spellId))
|
||||||
{
|
{
|
||||||
veh->CastSpell(veh, spellId, true);
|
veh->CastSpell(veh, spellId, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user