mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-24 14:06:22 +00:00
cast time strategy & relieve memory leak
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include "Queue.h"
|
#include "Queue.h"
|
||||||
#include "PerformanceMonitor.h"
|
#include "PerformanceMonitor.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
#include "Strategy.h"
|
||||||
|
|
||||||
Engine::Engine(PlayerbotAI* botAI, AiObjectContext* factory) : PlayerbotAIAware(botAI), aiObjectContext(factory)
|
Engine::Engine(PlayerbotAI* botAI, AiObjectContext* factory) : PlayerbotAIAware(botAI), aiObjectContext(factory)
|
||||||
{
|
{
|
||||||
@@ -70,6 +71,14 @@ Engine::~Engine(void)
|
|||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
|
for (std::map<std::string, Strategy*>::iterator i = strategies.begin(); i != strategies.end(); i++)
|
||||||
|
{
|
||||||
|
Strategy* strategy = i->second;
|
||||||
|
if (strategy) {
|
||||||
|
delete strategy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
strategies.clear();
|
strategies.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +209,7 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal)
|
|||||||
if (actionExecuted)
|
if (actionExecuted)
|
||||||
{
|
{
|
||||||
LogAction("A:%s - OK", action->getName().c_str());
|
LogAction("A:%s - OK", action->getName().c_str());
|
||||||
MultiplyAndPush(actionNode->getContinuers(), 0, false, event, "cont");
|
MultiplyAndPush(actionNode->getContinuers(), relevance, false, event, "cont");
|
||||||
lastRelevance = relevance;
|
lastRelevance = relevance;
|
||||||
delete actionNode;
|
delete actionNode;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ float CastTimeMultiplier::GetValue(Action* action)
|
|||||||
|
|
||||||
Unit* target = action->GetTarget();
|
Unit* target = action->GetTarget();
|
||||||
if (!target || !target->IsAlive() || !target->IsInWorld()) {
|
if (!target || !target->IsAlive() || !target->IsInWorld()) {
|
||||||
return false;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (castTime > (1000 * target->GetHealth() / AI_VALUE(float, "expected group dps"))) {
|
if (castTime > (1000 * target->GetHealth() / AI_VALUE(float, "expected group dps"))) {
|
||||||
return 0.0f;
|
return 0.1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if (castTime >= 3000)
|
// if (castTime >= 3000)
|
||||||
|
|||||||
Reference in New Issue
Block a user