mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-16 02:10:28 +00:00
Item spell coverage calculation
This commit is contained in:
@@ -172,6 +172,7 @@ public:
|
||||
creators["naxx chat shortcut"] = &ChatActionContext::naxx_chat_shortcut;
|
||||
creators["bwl chat shortcut"] = &ChatActionContext::bwl_chat_shortcut;
|
||||
creators["tell expected dps"] = &ChatActionContext::tell_expected_dps;
|
||||
creators["calc"] = &ChatActionContext::calc;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -268,6 +269,7 @@ private:
|
||||
static Action* naxx_chat_shortcut(PlayerbotAI* ai) { return new NaxxChatShortcutAction(ai); }
|
||||
static Action* bwl_chat_shortcut(PlayerbotAI* ai) { return new BwlChatShortcutAction(ai); }
|
||||
static Action* tell_expected_dps(PlayerbotAI* ai) { return new TellExpectedDpsAction(ai); }
|
||||
static Action* calc(PlayerbotAI* ai) { return new TellCalculateItemAction(ai); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,10 +4,16 @@
|
||||
*/
|
||||
|
||||
#include "TellLosAction.h"
|
||||
#include <istream>
|
||||
#include <sstream>
|
||||
|
||||
#include "ChatHelper.h"
|
||||
#include "DBCStores.h"
|
||||
#include "Event.h"
|
||||
#include "ItemTemplate.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Playerbots.h"
|
||||
#include "StatsWeightCalculator.h"
|
||||
#include "World.h"
|
||||
|
||||
bool TellLosAction::Execute(Event event)
|
||||
@@ -130,3 +136,21 @@ bool TellExpectedDpsAction::Execute(Event event)
|
||||
botAI->TellMaster("Expected Group DPS: " + std::to_string(dps));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TellCalculateItemAction::Execute(Event event)
|
||||
{
|
||||
std::string const text = event.getParam();
|
||||
ItemIds ids = chat->parseItems(text);
|
||||
StatsWeightCalculator calculator(bot);
|
||||
for (const uint32 &id : ids)
|
||||
{
|
||||
const ItemTemplate* proto = sObjectMgr->GetItemTemplate(id);
|
||||
if (!proto)
|
||||
continue;
|
||||
float score = calculator.CalculateItem(id);
|
||||
std::ostringstream out;
|
||||
out << "Calculated score of " << chat->FormatItem(proto) << " : " << score;
|
||||
botAI->TellMasterNoFacing(out.str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -37,4 +37,13 @@ public:
|
||||
|
||||
virtual bool Execute(Event event);
|
||||
};
|
||||
|
||||
class TellCalculateItemAction : public Action
|
||||
{
|
||||
public:
|
||||
TellCalculateItemAction(PlayerbotAI* ai) : Action(ai, "calculate item") {}
|
||||
|
||||
virtual bool Execute(Event event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -157,4 +157,5 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
|
||||
supported.push_back("guild leave");
|
||||
supported.push_back("rtsc");
|
||||
supported.push_back("drink");
|
||||
supported.push_back("calc");
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ public:
|
||||
creators["bwl"] = &ChatTriggerContext::bwl;
|
||||
creators["dps"] = &ChatTriggerContext::dps;
|
||||
creators["disperse"] = &ChatTriggerContext::disperse;
|
||||
creators["calc"] = &ChatTriggerContext::calc;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -221,6 +222,7 @@ private:
|
||||
static Trigger* bwl(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "bwl"); }
|
||||
static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); }
|
||||
static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); }
|
||||
static Trigger* calc(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "calc"); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user