Skip to content

Commit

Permalink
Spell casting
Browse files Browse the repository at this point in the history
  • Loading branch information
liyunfan1223 committed Mar 12, 2024
1 parent 00e48c7 commit aab51a8
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/strategy/druid/BearTankDruidStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ void BearTankDruidStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
FeralDruidStrategy::InitTriggers(triggers);
triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("feral charge - bear", ACTION_NORMAL + 8), nullptr)));
triggers.push_back(new TriggerNode("thorns", NextAction::array(0, new NextAction("thorns", ACTION_HIGH + 9), nullptr)));
// triggers.push_back(new TriggerNode("thorns", NextAction::array(0, new NextAction("thorns", ACTION_HIGH + 9), nullptr)));
triggers.push_back(new TriggerNode("bear form", NextAction::array(0, new NextAction("dire bear form", ACTION_HIGH + 8), nullptr)));
triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("frenzied regeneration", ACTION_HIGH + 7), nullptr)));
triggers.push_back(new TriggerNode("faerie fire (feral)", NextAction::array(0, new NextAction("faerie fire (feral)", ACTION_HIGH + 7), nullptr)));
triggers.push_back(new TriggerNode("lose aggro", NextAction::array(0, new NextAction("growl", ACTION_HIGH + 8), nullptr)));
triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("demoralizing roar", ACTION_HIGH + 6), new NextAction("swipe (bear)", ACTION_HIGH + 6), nullptr)));
Expand Down
7 changes: 7 additions & 0 deletions src/strategy/druid/DruidActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ class CastSurvivalInstinctsAction : public CastBuffSpellAction
CastSurvivalInstinctsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "survival instincts") { }
};

class CastFrenziedRegenerationAction : public CastBuffSpellAction
{
public:
CastFrenziedRegenerationAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "frenzied regeneration") { }
};


class CastThornsAction : public CastBuffSpellAction
{
public:
Expand Down
2 changes: 2 additions & 0 deletions src/strategy/druid/DruidAiObjectContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class DruidAiObjectContextInternal : public NamedObjectContext<Action>
creators["rip"] = &DruidAiObjectContextInternal::rip;
creators["cower"] = &DruidAiObjectContextInternal::cower;
creators["survival instincts"] = &DruidAiObjectContextInternal::survival_instincts;
creators["frenzied regeneration"] = &DruidAiObjectContextInternal::frenzied_regeneration;
creators["thorns"] = &DruidAiObjectContextInternal::thorns;
creators["thorns on party"] = &DruidAiObjectContextInternal::thorns_on_party;
creators["thorns on main tank"] = &DruidAiObjectContextInternal::thorns_on_main_tank;
Expand Down Expand Up @@ -258,6 +259,7 @@ class DruidAiObjectContextInternal : public NamedObjectContext<Action>
static Action* rip(PlayerbotAI* botAI) { return new CastRipAction(botAI); }
static Action* cower(PlayerbotAI* botAI) { return new CastCowerAction(botAI); }
static Action* survival_instincts(PlayerbotAI* botAI) { return new CastSurvivalInstinctsAction(botAI); }
static Action* frenzied_regeneration(PlayerbotAI* botAI) { return new CastFrenziedRegenerationAction(botAI); }
static Action* thorns(PlayerbotAI* botAI) { return new CastThornsAction(botAI); }
static Action* thorns_on_party(PlayerbotAI* botAI) { return new CastThornsOnPartyAction(botAI); }
static Action* thorns_on_main_tank(PlayerbotAI* botAI) { return new CastThornsOnMainTankAction(botAI); }
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/hunter/DpsHunterStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void DpsHunterStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
triggers.push_back(new TriggerNode("hunter's mark", NextAction::array(0, new NextAction("hunter's mark", 31.0f), nullptr)));
triggers.push_back(new TriggerNode("concussive shot on snare target", NextAction::array(0, new NextAction("concussive shot", 20.0f), nullptr)));
// triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("call pet", 21.0f), NULL)));
triggers.push_back(new TriggerNode("hunters pet low health", NextAction::array(0, new NextAction("mend pet", 21.0f), NULL)));
// triggers.push_back(new TriggerNode("hunters pet low health", NextAction::array(0, new NextAction("mend pet", 21.0f), NULL)));
triggers.push_back(new TriggerNode("has aggro", NextAction::array(0, new NextAction("concussive shot", 20.0f), nullptr)));
}

Expand Down
2 changes: 1 addition & 1 deletion src/strategy/hunter/GenericHunterNonCombatStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ void HunterPetStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("call pet", 60.0f), nullptr)));
triggers.push_back(new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 60.0f), nullptr)));
triggers.push_back(new TriggerNode("pet not happy", NextAction::array(0, new NextAction("feed pet", 60.0f), nullptr)));
triggers.push_back(new TriggerNode("hunters pet low health", NextAction::array(0, new NextAction("mend pet", 60.0f), nullptr)));
triggers.push_back(new TriggerNode("hunters pet medium health", NextAction::array(0, new NextAction("mend pet", 60.0f), nullptr)));
triggers.push_back(new TriggerNode("hunters pet dead", NextAction::array(0, new NextAction("revive pet", 60.0f), nullptr)));
}
2 changes: 1 addition & 1 deletion src/strategy/hunter/GenericHunterStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void GenericHunterStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
new NextAction("mongoose bite", ACTION_HIGH),
nullptr)));
triggers.push_back(new TriggerNode("medium threat", NextAction::array(0, new NextAction("feign death", 35.0f), nullptr)));
triggers.push_back(new TriggerNode("hunters pet low health", NextAction::array(0, new NextAction("mend pet", ACTION_HIGH + 2), nullptr)));
triggers.push_back(new TriggerNode("hunters pet medium health", NextAction::array(0, new NextAction("mend pet", ACTION_HIGH + 2), nullptr)));
// triggers.push_back(new TriggerNode("no ammo", NextAction::array(0, new NextAction("switch to melee", ACTION_HIGH + 1), new NextAction("say::no ammo", ACTION_HIGH), nullptr)));
triggers.push_back(new TriggerNode("aspect of the viper", NextAction::array(0, new NextAction("aspect of the viper", ACTION_HIGH), NULL)));
triggers.push_back(new TriggerNode("enemy too close for shoot", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr)));
Expand Down
2 changes: 2 additions & 0 deletions src/strategy/hunter/HunterAiObjectContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class HunterTriggerFactoryInternal : public NamedObjectContext<Trigger>
creators["no stings"] = &HunterTriggerFactoryInternal::NoStings;
creators["hunters pet dead"] = &HunterTriggerFactoryInternal::hunters_pet_dead;
creators["hunters pet low health"] = &HunterTriggerFactoryInternal::hunters_pet_low_health;
creators["hunters pet medium health"] = &HunterTriggerFactoryInternal::hunters_pet_medium_health;
creators["hunter's mark"] = &HunterTriggerFactoryInternal::hunters_mark;
creators["freezing trap"] = &HunterTriggerFactoryInternal::freezing_trap;
creators["aspect of the pack"] = &HunterTriggerFactoryInternal::aspect_of_the_pack;
Expand Down Expand Up @@ -97,6 +98,7 @@ class HunterTriggerFactoryInternal : public NamedObjectContext<Trigger>
static Trigger* NoStings(PlayerbotAI* botAI) { return new HunterNoStingsActiveTrigger(botAI); }
static Trigger* hunters_pet_dead(PlayerbotAI* botAI) { return new HuntersPetDeadTrigger(botAI); }
static Trigger* hunters_pet_low_health(PlayerbotAI* botAI) { return new HuntersPetLowHealthTrigger(botAI); }
static Trigger* hunters_pet_medium_health(PlayerbotAI* botAI) { return new HuntersPetMediumHealthTrigger(botAI); }
static Trigger* hunters_mark(PlayerbotAI* botAI) { return new HuntersMarkTrigger(botAI); }
static Trigger* freezing_trap(PlayerbotAI* botAI) { return new FreezingTrapTrigger(botAI); }
static Trigger* aspect_of_the_pack(PlayerbotAI* botAI) { return new HunterAspectOfThePackTrigger(botAI); }
Expand Down
7 changes: 7 additions & 0 deletions src/strategy/hunter/HunterTriggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "HunterTriggers.h"
#include "GenericTriggers.h"
#include "HunterActions.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h"
#include "ServerFacade.h"
#include "SharedDefines.h"
Expand Down Expand Up @@ -39,6 +40,12 @@ bool HuntersPetLowHealthTrigger::IsActive()
return pet && AI_VALUE2(uint8, "health", "pet target") < 40 && !AI_VALUE2(bool, "dead", "pet target") && !AI_VALUE2(bool, "mounted", "self target");
}

bool HuntersPetMediumHealthTrigger::IsActive()
{
Unit* pet = AI_VALUE(Unit*, "pet target");
return pet && AI_VALUE2(uint8, "health", "pet target") < sPlayerbotAIConfig->mediumHealth && !AI_VALUE2(bool, "dead", "pet target") && !AI_VALUE2(bool, "mounted", "self target");
}

bool HunterPetNotHappy::IsActive()
{
return !AI_VALUE(bool, "pet happy") && !AI_VALUE2(bool, "mounted", "self target");
Expand Down
3 changes: 3 additions & 0 deletions src/strategy/hunter/HunterTriggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ END_TRIGGER()
BEGIN_TRIGGER(HuntersPetLowHealthTrigger, Trigger)
END_TRIGGER()

BEGIN_TRIGGER(HuntersPetMediumHealthTrigger, Trigger)
END_TRIGGER()

class BlackArrowTrigger : public DebuffTrigger
{
public:
Expand Down
5 changes: 3 additions & 2 deletions src/strategy/paladin/DpsPaladinStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DpsPaladinStrategyActionNodeFactory : public NamedObjectFactory<ActionNode
/*A*/ nullptr,
/*C*/ nullptr);
}

ACTION_NODE_A(repentance, "repentance", "hammer of justice");
ACTION_NODE_A(repentance_on_enemy_healer, "repentance on enemy healer", "hammer of justice on enemy healer");
ACTION_NODE_A(repentance_on_snare_target, "repentance on snare target", "hammer of justice on snare target");
Expand All @@ -83,7 +84,7 @@ NextAction** DpsPaladinStrategy::getDefaultActions()
new NextAction("judgement of wisdom", ACTION_DEFAULT + 0.4f),
new NextAction("crusader strike", ACTION_DEFAULT + 0.3f),
new NextAction("divine storm", ACTION_DEFAULT + 0.2f),
new NextAction("consecration", ACTION_DEFAULT + 0.1f),
new NextAction("melee consecration", ACTION_DEFAULT + 0.1f),
new NextAction("melee", ACTION_DEFAULT),
NULL);
}
Expand All @@ -105,7 +106,7 @@ void DpsPaladinStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
// triggers.push_back(new TriggerNode("repentance on enemy healer", NextAction::array(0, new NextAction("repentance on enemy healer", ACTION_INTERRUPT + 2), nullptr)));
// triggers.push_back(new TriggerNode("repentance on snare target", NextAction::array(0, new NextAction("repentance on snare target", ACTION_INTERRUPT + 2), nullptr)));
// triggers.push_back(new TriggerNode("repentance", NextAction::array(0, new NextAction("repentance", ACTION_INTERRUPT + 2), nullptr)));
triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("consecration", ACTION_HIGH + 3), nullptr)));
triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("melee consecration", ACTION_HIGH + 3), nullptr)));
triggers.push_back(new TriggerNode("art of war", NextAction::array(0, new NextAction("exorcism", ACTION_HIGH + 2), nullptr)));
triggers.push_back(new TriggerNode("target critical health", NextAction::array(0, new NextAction("hammer of wrath", ACTION_HIGH), nullptr)));
// triggers.push_back(new TriggerNode(
Expand Down
10 changes: 9 additions & 1 deletion src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class GenericPaladinStrategyActionNodeFactory : public NamedObjectFactory<Action
creators["taunt spell"] = &hand_of_reckoning;
creators["righteous defense"] = &righteous_defense;
creators["avenger's shield"] = &avengers_shield;
creators["melee consecration"] = &melee_consecration;
}
private:
static ActionNode* blessing_of_sanctuary(PlayerbotAI* ai)
Expand Down Expand Up @@ -217,7 +218,7 @@ class GenericPaladinStrategyActionNodeFactory : public NamedObjectFactory<Action
{
return new ActionNode ("holy wrath",
/*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("consecration"), NULL),
/*A*/ nullptr,
/*C*/ nullptr);
}
static ActionNode* hammer_of_wrath(PlayerbotAI* ai)
Expand All @@ -234,6 +235,13 @@ class GenericPaladinStrategyActionNodeFactory : public NamedObjectFactory<Action
/*A*/ NextAction::array(0, new NextAction("seal of righteousness"), NULL),
/*C*/ nullptr);
}
static ActionNode* melee_consecration([[maybe_unused]] PlayerbotAI* botAI)
{
return new ActionNode ("melee consecration",
/*P*/ NextAction::array(0, new NextAction("reach melee"), nullptr),
/*A*/ nullptr,
/*C*/ nullptr);
}
};

#endif
2 changes: 1 addition & 1 deletion src/strategy/paladin/TankPaladinStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void TankPaladinStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)

triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, new NextAction("avenger's shield", ACTION_HIGH + 5), nullptr)));
triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0,
new NextAction("consecration", ACTION_HIGH + 7),
new NextAction("melee consecration", ACTION_HIGH + 7),
new NextAction("avenger's shield", ACTION_HIGH + 6), nullptr)));
// triggers.push_back(new TriggerNode("avenger's shield", NextAction::array(0, new NextAction("avenger's shield", ACTION_HIGH + 7), nullptr)));
triggers.push_back(new TriggerNode("lose aggro", NextAction::array(0, new NextAction("hand of reckoning", ACTION_HIGH + 7), nullptr)));
Expand Down
4 changes: 2 additions & 2 deletions src/strategy/shaman/HealShamanStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ void HealShamanStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)

triggers.push_back(new TriggerNode(
"party member critical health",
NextAction::array(0, new NextAction("riptide on party", 24.0f), new NextAction("lesser healing wave on party", 23.0f), NULL)));
NextAction::array(0, new NextAction("riptide on party", 24.0f), new NextAction("healing wave on party", 23.0f), NULL)));

triggers.push_back(new TriggerNode(
"party member low health",
NextAction::array(0, new NextAction("riptide on party", 18.0f), new NextAction("lesser healing wave on party", 17.0f), NULL)));
NextAction::array(0, new NextAction("riptide on party", 18.0f), new NextAction("healing wave on party", 17.0f), NULL)));

triggers.push_back(new TriggerNode(
"party member medium health",
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/shaman/ShamanNonCombatStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void ShamanNonCombatStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)

triggers.push_back(new TriggerNode(
"party member almost full health",
NextAction::array(0, new NextAction("healing wave on party", 24.0f), NULL)));
NextAction::array(0, new NextAction("lesser healing wave on party", 24.0f), NULL)));

triggers.push_back(new TriggerNode(
"medium aoe heal",
Expand Down
3 changes: 3 additions & 0 deletions src/strategy/triggers/TriggerContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class TriggerContext : public NamedObjectContext<Trigger>
creators["critical aoe heal"] = &TriggerContext::critical_aoe_heal;
creators["low aoe heal"] = &TriggerContext::low_aoe_heal;
creators["medium aoe heal"] = &TriggerContext::medium_aoe_heal;
creators["almost full aoe heal"] = &TriggerContext::almost_full_aoe_heal;

creators["group heal occasion"] = &TriggerContext::group_heal_occasion;
creators["medium group heal occasion"] = &TriggerContext::medium_group_heal_occasion;
creators["invalid target"] = &TriggerContext::invalid_target;
Expand Down Expand Up @@ -219,6 +221,7 @@ class TriggerContext : public NamedObjectContext<Trigger>
static Trigger* critical_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "critical aoe heal", "critical", 2); }
static Trigger* low_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "low aoe heal", "low", 2); }
static Trigger* medium_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "medium aoe heal", "medium", 2); }
static Trigger* almost_full_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "almost full aoe heal", "almost full", 2); }
static Trigger* group_heal_occasion(PlayerbotAI* ai) { return new AoeInGroupTrigger(ai, "group heal occasion", "almost full", 0.6); }
static Trigger* medium_group_heal_occasion(PlayerbotAI* ai) { return new AoeInGroupTrigger(ai, "group heal occasion", "medium", 0.4); }
static Trigger* target_changed(PlayerbotAI* botAI) { return new TargetChangedTrigger(botAI); }
Expand Down
7 changes: 5 additions & 2 deletions src/strategy/warlock/GenericWarlockNonCombatStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ void GenericWarlockNonCombatStrategy::InitTriggers(std::vector<TriggerNode*>& tr
NonCombatStrategy::InitTriggers(triggers);

triggers.push_back(new TriggerNode("demon armor", NextAction::array(0, new NextAction("fel armor", 21.0f), nullptr)));
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr)));
// triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr)));
triggers.push_back(new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 60.0f), nullptr)));
triggers.push_back(new TriggerNode("no healthstone", NextAction::array(0, new NextAction("create healthstone", 15.0f), nullptr)));
triggers.push_back(new TriggerNode("no spellstone", NextAction::array(0, new NextAction("create spellstone", 13.0f), nullptr)));
triggers.push_back(new TriggerNode("spellstone", NextAction::array(0, new NextAction("spellstone", 13.0f), nullptr)));
}

void WarlockPetStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
{
triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("summon felguard", 60.0f), nullptr)));
// triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("summon felguard", 60.0f), nullptr)));
// TODO Warlock pets
}

Expand Down

0 comments on commit aab51a8

Please sign in to comment.