Show resources in wareffort info command.

This commit is contained in:
ratkosrb
2024-06-18 12:41:52 +03:00
parent 7ecb374691
commit ee00512fa9
3 changed files with 213 additions and 154 deletions
@@ -681,76 +681,6 @@ bool GetWarEffortStockInfo(uint32 resourceId, WarEffortStockInfo &info, TeamId t
return found;
}
bool ChatHandler::HandleWarEffortGetResource(char* args)
{
uint32 resourceId = 0;
uint32 team;
if (!ExtractUInt32(&args, resourceId))
return false;
if (!ExtractUInt32(&args, team))
team = 0;
if (team > 1)
return false;
auto PrintResources = [this](WarEffortStockInfo &info)
{
double Progress = (double)info.count / (double)info.required;
PSendSysMessage("\"%s\" [%u] Current [%u] Required [%u] Completed: %.03f", info.proto->Name1, info.proto->ItemId, info.count, info.required, Progress);
};
WarEffortStockInfo info;
if (!GetWarEffortStockInfo(resourceId, info, TeamId(team)))
{
PSendSysMessage("Error: resource with id \"%d\" not found", resourceId);
return false;
}
PrintResources(info);
return true;
}
bool ChatHandler::HandleWarEffortSetResource(char* args)
{
uint32 resourceId = 0;
uint32 resourceAmount = 0;
uint32 team = 0;
if (!ExtractUInt32(&args, resourceId))
{
PSendSysMessage("Usage example .wareffortset 3575 1245");
return false;
}
if (!ExtractUInt32(&args, resourceAmount))
{
PSendSysMessage("Usage example .wareffortset 3575 1245");
return false;
}
if (!ExtractUInt32(&args, team))
team = 0;
if (team > 1)
return false;
WarEffortStockInfo info;
if (!GetWarEffortStockInfo(resourceId, info, TeamId(team)))
{
PSendSysMessage("Error: resource with id \"%d\" not found", resourceId);
return false;
}
uint32 PreviousResourceCount = info.count;
sObjectMgr.SetSavedVariable(info.currentVar, resourceAmount, true);
double Progress = (double)resourceAmount / (double)info.required;
PSendSysMessage("\"%s\" Previous count [%u] New count [%u] Completed: %.03f", info.proto->Name1, PreviousResourceCount, resourceAmount, Progress);
return true;
}
CreatureAI *GetAI_npc_AQwar_collector(Creature *pCreature)
{
return new npc_AQwar_collectorAI(pCreature);