@@ -4,14 +4,35 @@ using namespace std;
44
55namespace ai
66{
7+ /* *
8+ * @brief Base class for loot strategies.
9+ */
710 class LootStrategy
811 {
912 public:
1013 LootStrategy () {}
14+ virtual ~LootStrategy () {} // Add a virtual destructor
15+
16+ /* *
17+ * @brief Determines if an item can be looted.
18+ *
19+ * @param proto The item prototype.
20+ * @param context The AI object context.
21+ * @return true if the item can be looted, false otherwise.
22+ */
1123 virtual bool CanLoot (ItemPrototype const *proto, AiObjectContext *context) = 0;
24+
25+ /* *
26+ * @brief Gets the name of the loot strategy.
27+ *
28+ * @return The name of the loot strategy.
29+ */
1230 virtual string GetName () = 0;
1331 };
1432
33+ /* *
34+ * @brief Represents a lootable object.
35+ */
1536 class LootObject
1637 {
1738 public:
@@ -20,17 +41,47 @@ namespace ai
2041 LootObject (const LootObject& other);
2142
2243 public:
44+ /* *
45+ * @brief Checks if the loot object is empty.
46+ *
47+ * @return true if the loot object is empty, false otherwise.
48+ */
2349 bool IsEmpty () { return !guid; }
50+
51+ /* *
52+ * @brief Checks if looting is possible.
53+ *
54+ * @param bot The player bot.
55+ * @return true if looting is possible, false otherwise.
56+ */
2457 bool IsLootPossible (Player* bot);
58+
59+ /* *
60+ * @brief Refreshes the loot object with a new GUID.
61+ *
62+ * @param bot The player bot.
63+ * @param guid The new GUID.
64+ */
2565 void Refresh (Player* bot, ObjectGuid guid);
66+
67+ /* *
68+ * @brief Gets the world object associated with the loot object.
69+ *
70+ * @param bot The player bot.
71+ * @return The world object.
72+ */
2673 WorldObject* GetWorldObject (Player* bot);
27- ObjectGuid guid;
2874
29- uint32 skillId;
30- uint32 reqSkillValue;
31- uint32 reqItem;
75+ public:
76+ ObjectGuid guid; // /< The GUID of the loot object.
77+ uint32 skillId; // /< The skill ID required to loot the object.
78+ uint32 reqSkillValue; // /< The required skill value to loot the object.
79+ uint32 reqItem; // /< The required item to loot the object.
3280 };
3381
82+ /* *
83+ * @brief Represents a loot target.
84+ */
3485 class LootTarget
3586 {
3687 public:
@@ -42,34 +93,81 @@ namespace ai
4293 bool operator < (const LootTarget& other) const ;
4394
4495 public:
45- ObjectGuid guid;
46- time_t asOfTime;
96+ ObjectGuid guid; // /< The GUID of the loot target.
97+ time_t asOfTime; // /< The time when the loot target was added.
4798 };
4899
100+ /* *
101+ * @brief Represents a list of loot targets.
102+ */
49103 class LootTargetList : public set <LootTarget>
50104 {
51105 public:
106+ /* *
107+ * @brief Shrinks the list by removing targets older than the specified time.
108+ *
109+ * @param fromTime The time threshold.
110+ */
52111 void shrink (time_t fromTime);
53112 };
54113
114+ /* *
115+ * @brief Represents a stack of loot objects.
116+ */
55117 class LootObjectStack
56118 {
57119 public:
58120 LootObjectStack (Player* bot) : bot(bot) {}
59121
60122 public:
123+ /* *
124+ * @brief Adds a loot object to the stack.
125+ *
126+ * @param guid The GUID of the loot object.
127+ * @return true if the loot object was added, false otherwise.
128+ */
61129 bool Add (ObjectGuid guid);
130+
131+ /* *
132+ * @brief Removes a loot object from the stack.
133+ *
134+ * @param guid The GUID of the loot object.
135+ */
62136 void Remove (ObjectGuid guid);
137+
138+ /* *
139+ * @brief Clears the stack of loot objects.
140+ */
63141 void Clear ();
142+
143+ /* *
144+ * @brief Checks if looting is possible within the specified distance.
145+ *
146+ * @param maxDistance The maximum distance to check.
147+ * @return true if looting is possible, false otherwise.
148+ */
64149 bool CanLoot (float maxDistance);
150+
151+ /* *
152+ * @brief Gets the loot object within the specified distance.
153+ *
154+ * @param maxDistance The maximum distance to check.
155+ * @return The loot object.
156+ */
65157 LootObject GetLoot (float maxDistance = 0 );
66158
67159 private:
160+ /* *
161+ * @brief Orders the loot objects by distance.
162+ *
163+ * @param maxDistance The maximum distance to check.
164+ * @return A vector of ordered loot objects.
165+ */
68166 vector<LootObject> OrderByDistance (float maxDistance = 0 );
69167
70168 private:
71- Player* bot;
72- LootTargetList availableLoot;
169+ Player* bot; // /< The player bot.
170+ LootTargetList availableLoot; // /< The list of available loot targets.
73171 };
74172
75173};
0 commit comments