mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-16 02:10:28 +00:00
Dynamic delay
This commit is contained in:
@@ -409,26 +409,26 @@ ActionResult Engine::ExecuteAction(std::string const name, Event event, std::str
|
||||
return result ? ACTION_RESULT_OK : ACTION_RESULT_FAILED;
|
||||
}
|
||||
|
||||
void Engine::addStrategy(std::string const name)
|
||||
void Engine::addStrategy(std::string const name, bool init)
|
||||
{
|
||||
removeStrategy(name);
|
||||
removeStrategy(name, init);
|
||||
|
||||
if (Strategy* strategy = aiObjectContext->GetStrategy(name))
|
||||
{
|
||||
std::set<std::string> siblings = aiObjectContext->GetSiblingStrategy(name);
|
||||
for (std::set<std::string>::iterator i = siblings.begin(); i != siblings.end(); i++)
|
||||
removeStrategy(*i);
|
||||
removeStrategy(*i, init);
|
||||
|
||||
LogAction("S:+%s", strategy->getName().c_str());
|
||||
strategies[strategy->getName()] = strategy;
|
||||
}
|
||||
|
||||
Init();
|
||||
if (init)
|
||||
Init();
|
||||
}
|
||||
|
||||
void Engine::addStrategies(std::string first, ...)
|
||||
{
|
||||
addStrategy(first);
|
||||
addStrategy(first, false);
|
||||
|
||||
va_list vl;
|
||||
va_start(vl, first);
|
||||
@@ -438,13 +438,34 @@ void Engine::addStrategies(std::string first, ...)
|
||||
{
|
||||
cur = va_arg(vl, const char*);
|
||||
if (cur)
|
||||
addStrategy(cur);
|
||||
addStrategy(cur, false);
|
||||
} while (cur);
|
||||
|
||||
Init();
|
||||
|
||||
va_end(vl);
|
||||
}
|
||||
|
||||
void Engine::addStrategiesNoInit(std::string first, ...)
|
||||
{
|
||||
addStrategy(first, false);
|
||||
|
||||
va_list vl;
|
||||
va_start(vl, first);
|
||||
|
||||
const char* cur;
|
||||
do
|
||||
{
|
||||
cur = va_arg(vl, const char*);
|
||||
if (cur)
|
||||
addStrategy(cur, false);
|
||||
} while (cur);
|
||||
|
||||
va_end(vl);
|
||||
}
|
||||
|
||||
bool Engine::removeStrategy(std::string const name)
|
||||
|
||||
bool Engine::removeStrategy(std::string const name, bool init)
|
||||
{
|
||||
std::map<std::string, Strategy*>::iterator i = strategies.find(name);
|
||||
if (i == strategies.end())
|
||||
@@ -452,7 +473,8 @@ bool Engine::removeStrategy(std::string const name)
|
||||
|
||||
LogAction("S:-%s", name.c_str());
|
||||
strategies.erase(i);
|
||||
Init();
|
||||
if (init)
|
||||
Init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -65,9 +65,10 @@ public:
|
||||
Engine(PlayerbotAI* botAI, AiObjectContext* factory);
|
||||
|
||||
void Init();
|
||||
void addStrategy(std::string const name);
|
||||
void addStrategy(std::string const name, bool init = true);
|
||||
void addStrategies(std::string first, ...);
|
||||
bool removeStrategy(std::string const name);
|
||||
void addStrategiesNoInit(std::string first, ...);
|
||||
bool removeStrategy(std::string const name, bool init = true);
|
||||
bool HasStrategy(std::string const name);
|
||||
void removeAllStrategies();
|
||||
void toggleStrategy(std::string const name);
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
creators["emote"] = &StrategyContext::emote;
|
||||
creators["passive"] = &StrategyContext::passive;
|
||||
// creators["conserve mana"] = &StrategyContext::conserve_mana;
|
||||
creators["auto save mana"] = &StrategyContext::auto_save_mana;
|
||||
creators["smana"] = &StrategyContext::auto_save_mana;
|
||||
creators["food"] = &StrategyContext::food;
|
||||
creators["chat"] = &StrategyContext::chat;
|
||||
creators["default"] = &StrategyContext::world_packet;
|
||||
@@ -112,9 +112,9 @@ public:
|
||||
creators["group"] = &StrategyContext::group;
|
||||
creators["guild"] = &StrategyContext::guild;
|
||||
creators["grind"] = &StrategyContext::grind;
|
||||
creators["avoid aoe"] = &StrategyContext::avoid_aoe;
|
||||
creators["aaoe"] = &StrategyContext::avoid_aoe;
|
||||
creators["move random"] = &StrategyContext::move_random;
|
||||
creators["combat formation"] = &StrategyContext::combat_formation;
|
||||
creators["formation"] = &StrategyContext::combat_formation;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
creators["reach party member to resurrect"] = &ActionContext::reach_party_member_to_resurrect;
|
||||
creators["flee"] = &ActionContext::flee;
|
||||
creators["flee with pet"] = &ActionContext::flee_with_pet;
|
||||
creators["avoid aoe"] = &ActionContext::avoid_aoe;
|
||||
creators["aaoe"] = &ActionContext::avoid_aoe;
|
||||
creators["combat formation move"] = &ActionContext::combat_formation_move;
|
||||
creators["disperse set"] = &ActionContext::disperse_set;
|
||||
creators["gift of the naaru"] = &ActionContext::gift_of_the_naaru;
|
||||
@@ -158,10 +158,8 @@ public:
|
||||
creators["berserking"] = &ActionContext::berserking;
|
||||
creators["use trinket"] = &ActionContext::use_trinket;
|
||||
creators["auto talents"] = &ActionContext::auto_talents;
|
||||
creators["auto learn spell"] = &ActionContext::auto_learn_spell;
|
||||
creators["auto share quest"] = &ActionContext::auto_share_quest;
|
||||
creators["auto teleport for level"] = &ActionContext::auto_teleport_for_level;
|
||||
creators["auto upgrade equip"] = &ActionContext::auto_upgrade_equip;
|
||||
creators["auto maintenance on levelup"] = &ActionContext::auto_maintenance_on_levelup;
|
||||
creators["xp gain"] = &ActionContext::xp_gain;
|
||||
creators["invite nearby"] = &ActionContext::invite_nearby;
|
||||
creators["invite guild"] = &ActionContext::invite_guild;
|
||||
@@ -331,10 +329,8 @@ private:
|
||||
static Action* berserking(PlayerbotAI* botAI) { return new CastBerserkingAction(botAI); }
|
||||
static Action* use_trinket(PlayerbotAI* botAI) { return new UseTrinketAction(botAI); }
|
||||
static Action* auto_talents(PlayerbotAI* botAI) { return new AutoSetTalentsAction(botAI); }
|
||||
static Action* auto_learn_spell(PlayerbotAI* botAI) { return new AutoLearnSpellAction(botAI); }
|
||||
static Action* auto_share_quest(PlayerbotAI* ai) { return new AutoShareQuestAction(ai); }
|
||||
static Action* auto_teleport_for_level(PlayerbotAI* botAI) { return new AutoTeleportForLevelAction(botAI); }
|
||||
static Action* auto_upgrade_equip(PlayerbotAI* botAI) { return new AutoUpgradeEquipAction(botAI); }
|
||||
static Action* auto_maintenance_on_levelup(PlayerbotAI* botAI) { return new AutoMaintenanceOnLevelupAction(botAI); }
|
||||
static Action* xp_gain(PlayerbotAI* botAI) { return new XpGainAction(botAI); }
|
||||
static Action* invite_nearby(PlayerbotAI* botAI) { return new InviteNearbyToGroupAction(botAI); }
|
||||
static Action* invite_guild(PlayerbotAI* botAI) { return new InviteGuildToGroupAction(botAI); }
|
||||
|
||||
@@ -70,7 +70,7 @@ AvoidAoeStrategy::AvoidAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) {}
|
||||
|
||||
NextAction** AvoidAoeStrategy::getDefaultActions()
|
||||
{
|
||||
return NextAction::array(0, new NextAction("avoid aoe", ACTION_EMERGENCY), nullptr);
|
||||
return NextAction::array(0, new NextAction("aaoe", ACTION_EMERGENCY), nullptr);
|
||||
}
|
||||
|
||||
void AvoidAoeStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
|
||||
@@ -23,7 +23,7 @@ class AvoidAoeStrategy : public Strategy
|
||||
{
|
||||
public:
|
||||
explicit AvoidAoeStrategy(PlayerbotAI* ai);
|
||||
const std::string getName() override { return "avoid aoe"; }
|
||||
const std::string getName() override { return "aaoe"; }
|
||||
NextAction** getDefaultActions() override;
|
||||
void InitMultipliers(std::vector<Multiplier*>& multipliers) override;
|
||||
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
|
||||
@@ -33,7 +33,7 @@ class CombatFormationStrategy : public Strategy
|
||||
{
|
||||
public:
|
||||
CombatFormationStrategy(PlayerbotAI* ai) : Strategy(ai) {}
|
||||
const std::string getName() override { return "combat formation"; }
|
||||
const std::string getName() override { return "formation"; }
|
||||
NextAction** getDefaultActions() override;
|
||||
};
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class PlayerbotAI;
|
||||
class HealerAutoSaveManaMultiplier : public Multiplier
|
||||
{
|
||||
public:
|
||||
HealerAutoSaveManaMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "auto save mana") {}
|
||||
HealerAutoSaveManaMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "smana") {}
|
||||
|
||||
float GetValue(Action* action) override;
|
||||
};
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
HealerAutoSaveManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) {}
|
||||
|
||||
void InitMultipliers(std::vector<Multiplier*>& multipliers) override;
|
||||
std::string const getName() override { return "auto save mana"; }
|
||||
std::string const getName() override { return "smana"; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user