mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
feat(Core/Conditions): Implement CONDITION_AI_DATA and support for st… (#22879)
This commit is contained in:
@@ -74,6 +74,8 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
|
||||
|
||||
_chaseOnInterrupt = false;
|
||||
|
||||
aiDataSet.clear();
|
||||
|
||||
// Xinef: Vehicle conditions
|
||||
m_ConditionsTimer = 0;
|
||||
if (me->GetVehicleKit())
|
||||
@@ -778,6 +780,7 @@ void SmartAI::JustRespawned()
|
||||
mFollowArrivedEntry = 0;
|
||||
mFollowCreditType = 0;
|
||||
mFollowArrivedAlive = true;
|
||||
aiDataSet.clear();
|
||||
}
|
||||
|
||||
void SmartAI::JustReachedHome()
|
||||
@@ -963,8 +966,12 @@ void SmartAI::DoAction(int32 param)
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_ACTION_DONE, nullptr, param);
|
||||
}
|
||||
|
||||
uint32 SmartAI::GetData(uint32 /*id*/) const
|
||||
uint32 SmartAI::GetData(uint32 id) const
|
||||
{
|
||||
auto const& itr = aiDataSet.find(id);
|
||||
if (itr != aiDataSet.end())
|
||||
return itr->second;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -980,6 +987,7 @@ void SmartAI::SetData(uint32 id, uint32 value, WorldObject* invoker)
|
||||
gob = invoker->ToGameObject();
|
||||
}
|
||||
|
||||
aiDataSet[id] = value;
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, unit, id, value, false, nullptr, gob);
|
||||
}
|
||||
|
||||
|
||||
@@ -262,6 +262,7 @@ private:
|
||||
uint32 m_ConditionsTimer;
|
||||
|
||||
bool _chaseOnInterrupt;
|
||||
std::unordered_map<uint32, uint32> aiDataSet;
|
||||
};
|
||||
|
||||
class SmartGameObjectAI : public GameObjectAI
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "ConditionMgr.h"
|
||||
#include "AchievementMgr.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GameObject.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Pet.h"
|
||||
@@ -576,6 +578,14 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
|
||||
condMeets = sWorldState->IsConditionFulfilled(ConditionValue1, ConditionValue2);
|
||||
break;
|
||||
}
|
||||
case CONDITION_AI_DATA:
|
||||
{
|
||||
if (Creature* creature = object->ToCreature())
|
||||
condMeets = creature->AI() && creature->AI()->GetData(ConditionValue1) == ConditionValue2;
|
||||
else if (GameObject* go = object->ToGameObject())
|
||||
condMeets = go->AI() && go->AI()->GetData(ConditionValue1) == ConditionValue2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
condMeets = false;
|
||||
break;
|
||||
@@ -779,6 +789,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition()
|
||||
case CONDITION_WORLD_SCRIPT:
|
||||
mask |= GRID_MAP_TYPE_MASK_ALL;
|
||||
break;
|
||||
case CONDITION_AI_DATA:
|
||||
mask |= GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_GAMEOBJECT;
|
||||
break;
|
||||
default:
|
||||
ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!");
|
||||
break;
|
||||
|
||||
@@ -87,8 +87,9 @@ enum ConditionTypes
|
||||
CONDITION_QUEST_SATISFY_EXCLUSIVE = 101, // quest_id 0 0 true if satisfied exclusive group
|
||||
CONDITION_HAS_AURA_TYPE = 102, // aura_type 0 0 true if has aura type
|
||||
CONDITION_WORLD_SCRIPT = 103, // conditionId state 0 true if WorldState::IsConditionFulfilled returns true
|
||||
CONDITION_AI_DATA = 104, // dataId value 0 true if AI::GetData returns value
|
||||
|
||||
CONDITION_AC_END = 104 // placeholder
|
||||
CONDITION_AC_END = 105 // placeholder
|
||||
};
|
||||
|
||||
/*! Documentation on implementing a new ConditionSourceType:
|
||||
|
||||
Reference in New Issue
Block a user