Trigger fixes and Warrior AI tweaks

This commit is contained in:
郑佩茹
2023-03-21 12:25:25 -06:00
parent f27ab459b1
commit aeeb37da78
11 changed files with 94 additions and 10 deletions

View File

@@ -184,6 +184,15 @@ bool SpellCanBeCastTrigger::IsActive()
return target && botAI->CanCastSpell(spell, target);
}
bool SpellNoCooldownTrigger::IsActive()
{
uint32 spellId = AI_VALUE2(uint32, "spell id", name);
if (!spellId)
return false;
return !bot->HasSpellCooldown(spellId);
}
RandomTrigger::RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability) : Trigger(botAI, name), probability(probability), lastCheck(time(nullptr))
{
}
@@ -202,7 +211,7 @@ bool RandomTrigger::IsActive()
bool AndTrigger::IsActive()
{
return ls->IsActive() && rs->IsActive();
return ls && rs && ls->IsActive() && rs->IsActive();
}
std::string const AndTrigger::getName()
@@ -213,6 +222,27 @@ std::string const AndTrigger::getName()
return name;
}
bool TwoTriggers::IsActive()
{
if (name1.empty() || name2.empty())
return false;
Trigger* trigger1 = botAI->GetAiObjectContext()->GetTrigger(name1);
Trigger* trigger2 = botAI->GetAiObjectContext()->GetTrigger(name2);
if (!trigger1 || !trigger2)
return false;
return trigger1->IsActive() && trigger2->IsActive();
}
std::string const TwoTriggers::getName()
{
std::string name;
name = name1 + " and " + name2;
return name;
}
bool BoostTrigger::IsActive()
{
return BuffTrigger::IsActive() && AI_VALUE(uint8, "balance") <= balance;

View File

@@ -5,6 +5,8 @@
#ifndef _PLAYERBOT_GENERICTRIGGERS_H
#define _PLAYERBOT_GENERICTRIGGERS_H
#include <utility>
#include "RangeTriggers.h"
#include "HealthTriggers.h"
@@ -133,6 +135,14 @@ class SpellCanBeCastTrigger : public SpellTrigger
bool IsActive() override;
};
class SpellNoCooldownTrigger : public SpellTrigger
{
public:
SpellNoCooldownTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {}
bool IsActive() override;
};
// TODO: check other targets
class InterruptSpellTrigger : public SpellTrigger
{
@@ -349,6 +359,21 @@ class AndTrigger : public Trigger
Trigger* rs;
};
class TwoTriggers : public Trigger
{
public:
explicit TwoTriggers(PlayerbotAI* botAI, std::string name1 = "", std::string name2 = "") : Trigger(botAI)
{
this->name1 = std::move(name1);
this->name2 = std::move(name2);
}
bool IsActive() override;
std::string const getName() override;
protected:
std::string name1;
std::string name2;
};
class SnareTargetTrigger : public DebuffTrigger
{
public: