test: ms_time

This commit is contained in:
Yunfan Li
2023-08-02 03:46:15 +08:00
parent b35b8ad997
commit fca4d17c97
26 changed files with 91 additions and 82 deletions

View File

@@ -8,6 +8,7 @@
#include "Playerbots.h"
#include "SharedDefines.h"
#include "TemporarySummon.h"
#include "Timer.h"
#include <string>
bool LowManaTrigger::IsActive()
@@ -224,16 +225,16 @@ bool SpellNoCooldownTrigger::IsActive()
return !bot->HasSpellCooldown(spellId);
}
RandomTrigger::RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability) : Trigger(botAI, name), probability(probability), lastCheck(time(nullptr))
RandomTrigger::RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability) : Trigger(botAI, name), probability(probability), lastCheck(getMSTime())
{
}
bool RandomTrigger::IsActive()
{
if (time(nullptr) - lastCheck < sPlayerbotAIConfig->repeatDelay / 1000)
if (getMSTime() - lastCheck < sPlayerbotAIConfig->repeatDelay)
return false;
lastCheck = time(nullptr);
lastCheck = getMSTime();
int32 k = (int32)(probability / sPlayerbotAIConfig->randomChangeMultiplier);
if (k < 1)
k = 1;