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