Core/Commands: Improve .damage command, now can damage destructible gameobjects => ".damage go <guid> <damage>"
This commit is contained in:
1 parent
16074667c0
commit
e858057eff
3 files changed
+72
-1
No files matched your search
@@ -2042,6 +2042,70 @@ public:
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* str = strtok((char*)args, " ");
|
||||
|
||||
if (strcmp(str, "go") == 0)
|
||||
{
|
||||
char* guidStr = strtok(NULL, " ");
|
||||
if (!guidStr)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 guid = atoi(guidStr);
|
||||
if (!guid)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* damageStr = strtok(NULL, " ");
|
||||
if (!damageStr)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 damage = atoi(damageStr);
|
||||
if (!damage)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Player* player = handler->GetSession()->GetPlayer())
|
||||
{
|
||||
GameObject* go = NULL;
|
||||
|
||||
if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
|
||||
go = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guid, goData->id);
|
||||
|
||||
if (!go)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!go->IsDestructibleBuilding())
|
||||
{
|
||||
handler->SendSysMessage(LANG_INVALID_GAMEOBJECT_TYPE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
go->ModifyHealth(-damage, player);
|
||||
handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), guid, -damage, go->GetGOValue()->Building.Health);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (!target || !handler->GetSession()->GetPlayer()->GetSelection())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user