Beispiel #1
0
    //move selected object
    static bool HandleGameObjectMoveCommand(ChatHandler* handler, char const* args)
    {
        uint32 guidLow = GetGuidLowFromArgsOrLastTargetedGo(handler, args);

        if (!guidLow)
            return false;

        GameObject* object = NULL;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* toX = strtok(NULL, " ");
        char* toY = strtok(NULL, " ");
        char* toZ = strtok(NULL, " ");

        if (!toX)
        {
            Player* player = handler->GetSession()->GetPlayer();
            object->Relocate(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), object->GetOrientation());
            object->DestroyForNearbyPlayers();
            object->UpdateObjectVisibility();
        }
        else
        {
            if (!toY || !toZ)
                return false;

            float x = (float)atof(toX);
            float y = (float)atof(toY);
            float z = (float)atof(toZ);

            if (!MapManager::IsValidMapCoord(object->GetMapId(), x, y, z))
            {
                handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, object->GetMapId());
                handler->SetSentErrorMessage(true);
                return false;
            }

            object->Relocate(x, y, z, object->GetOrientation());
            object->DestroyForNearbyPlayers();
            object->UpdateObjectVisibility();
        }

        object->SaveToDB();
        object->Refresh();

        handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow());

        return true;
    }
    //turn selected object
    static bool HandleGameObjectTurnCommand(ChatHandler* handler, char const* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
        char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
        if (!id)
            return false;

        uint32 guidLow = atoi(id);
        if (!guidLow)
            return false;

        GameObject* object = nullptr;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* orientation = strtok(nullptr, " ");
        float oz = 0.f, oy = 0.f, ox = 0.f;

        if (orientation)
        {
            oz = float(atof(orientation));
            orientation = strtok(nullptr, " ");
            if (orientation)
            {
                oy = float(atof(orientation));
                orientation = strtok(nullptr, " ");
                if (orientation)
                    ox = float(atof(orientation));
            }
        }
        else
        {
            Player* player = handler->GetSession()->GetPlayer();
            oz = player->GetOrientation();
        }

        object->SetWorldRotationAngles(oz, oy, ox);
        object->DestroyForNearbyPlayers();
        object->UpdateObjectVisibility();

        object->SaveToDB();
        object->Refresh();

        handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow(), oz, oy, ox);

        return true;
    }
Beispiel #3
0
    static bool HandleGameObjectSetScaleCommand(ChatHandler* handler, char const* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
        char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
        if (!id)
            return false;

        uint32 guidLow = atoi(id);
        if (!guidLow)
            return false;

        GameObject* object = NULL;

        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* scale_temp = strtok(NULL, " ");
        if (!scale_temp)
        {
            handler->SendSysMessage(LANG_BAD_VALUE);
            handler->SetSentErrorMessage(true);
            return false;
        }

        float scale = atof(scale_temp);

        if (scale <= 0.0f)
        {
            scale = object->GetGOInfo()->size;
            const_cast<GameObjectData*>(object->GetGOData())->size = -1.0f;
        }
        else
        {
            const_cast<GameObjectData*>(object->GetGOData())->size = scale;
        }

        object->SetObjectScale(scale);
        object->DestroyForNearbyPlayers();
        object->UpdateObjectVisibility();
        object->SaveToDB();

        handler->PSendSysMessage("Set %s scale to %f", object->GetGUID().ToString(), scale);
        return true;
    }
Beispiel #4
0
    //turn selected object
    static bool HandleGameObjectTurnCommand(ChatHandler* handler, const char* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
        char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
        if (!cId)
            return false;

        uint32 lowguid = atoi(cId);
        if (!lowguid)
            return false;

        GameObject* obj = NULL;

        // by DB guid
        if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid))
            obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);

        if (!obj)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* po = strtok(NULL, " ");
        float o;

        if (po)
        {
            o = (float)atof(po);
        }
        else
        {
            Player *chr = handler->GetSession()->GetPlayer();
            o = chr->GetOrientation();
        }

        obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o);
        obj->UpdateRotationFields();
        obj->DestroyForNearbyPlayers();
        obj->UpdateObjectVisibility();

        obj->SaveToDB();
        obj->Refresh();

        handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow(), o);

        return true;
    }
Beispiel #5
0
    //turn selected object
    static bool HandleGameObjectTurnCommand(ChatHandler* handler, char const* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
        char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
        if (!id)
            return false;

        ObjectGuid::LowType guidLow = strtoull(id, nullptr, 10);
        if (!guidLow)
            return false;

        GameObject* object = NULL;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* orientation = strtok(NULL, " ");
        float o;

        if (orientation)
            o = (float)atof(orientation);
        else
        {
            Player* player = handler->GetSession()->GetPlayer();
            o = player->GetOrientation();
        }

        object->Relocate(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), o);
        object->RelocateStationaryPosition(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), o);
        object->UpdateRotationFields();
        object->DestroyForNearbyPlayers();
        object->UpdateObjectVisibility();

        object->SaveToDB();

        handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str(), o);

        return true;
    }
Beispiel #6
0
    static bool HandleGameObjectScaleCommand(ChatHandler* handler, char const* args)
    {
        if (!*args)
            return false;

        char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
        if (!id)
            return false;

        uint32 guidLow = atoi(id);

        if (!guidLow)
            return false;

        GameObject* object = NULL;

        // by DB guid
        if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id);

        if (!object) {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* scale_temp = strtok(NULL, " ");
        float scale = scale_temp ? atof(scale_temp) : -1.0f;

        if (scale > 30.0f || scale < 0.0f)
        {
            handler->SendSysMessage(LANG_BAD_VALUE);
            handler->SetSentErrorMessage(true);
            return false;
        }

        // set scale
        object->SetObjectScale(scale);
        object->DestroyForNearbyPlayers();
        object->UpdateObjectVisibility();
        object->SaveToDB();

        return true;
    }
Beispiel #7
0
    //turn selected object
    static bool HandleGameObjectTurnCommand(ChatHandler* handler, char const* args)
    {
        uint32 guidLow = GetGuidLowFromArgsOrLastTargetedGo(handler, args);

        if (!guidLow)
            return false;

        GameObject* object = NULL;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* orientation = strtok(NULL, " ");
        float o;

        if (orientation)
            o = (float)atof(orientation);
        else
        {
            Player* player = handler->GetSession()->GetPlayer();
            o = player->GetOrientation();
        }

        object->Relocate(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), o);
        object->UpdateRotationFields();
        object->DestroyForNearbyPlayers();
        object->UpdateObjectVisibility();

        object->SaveToDB();
        object->Refresh();

        handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow(), o);

        return true;
    }
Beispiel #8
0
    //set scale for selected object spawn
    static bool HandleGameObjectScaleCommand(ChatHandler* handler, char const* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
        char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
        if (!id)
            return false;

        uint32 guidLow = atoi(id);
        if (!guidLow)
            return false;

        GameObject* object = NULL;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* scale = strtok (NULL, " ");
        float scaleDB = scale ? atof(scale) : 0;
        if (scaleDB == 0)
        {
            handler->SendSysMessage(LANG_BAD_VALUE);
            handler->SetSentErrorMessage(true);
            return false;
        }

        object->SetFloatValue(OBJECT_FIELD_SCALE_X, scaleDB);
        object->DestroyForNearbyPlayers();
        object->UpdateObjectVisibility();
        object->SaveToDB();
        object->Refresh();
        
        handler->PSendSysMessage("Set gobject GUID %u to scale %f", guidLow, scaleDB);
        return true;
    }
Beispiel #9
0
    //move selected object
    static bool HandleGameObjectMoveCommand(ChatHandler* handler, const char* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
        char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
        if (!cId)
            return false;

        uint32 lowguid = atoi(cId);
        if (!lowguid)
            return false;

        GameObject* obj = NULL;

        // by DB guid
        if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid))
            obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);

        if (!obj)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* px = strtok(NULL, " ");
        char* py = strtok(NULL, " ");
        char* pz = strtok(NULL, " ");

        if (!px)
        {
            Player *chr = handler->GetSession()->GetPlayer();
            obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation());
            obj->DestroyForNearbyPlayers();
            obj->UpdateObjectVisibility();
        }
        else
        {
            if (!py || !pz)
                return false;

            float x = (float)atof(px);
            float y = (float)atof(py);
            float z = (float)atof(pz);

            if (!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z))
            {
                handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId());
                handler->SetSentErrorMessage(true);
                return false;
            }

            obj->Relocate(x, y, z, obj->GetOrientation());
            obj->DestroyForNearbyPlayers();
            obj->UpdateObjectVisibility();
        }

        obj->SaveToDB();
        obj->Refresh();

        handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow());

        return true;
    }
Beispiel #10
0
        static bool HandleGameObjectSetScaleCommand(ChatHandler* handler, char const* args)
        {

            GameObject* object = NULL;

            if(handler->GetSession()->GetPlayer()->HasSelectedGameObject() == true)
            {
                object = handler->GetSession()->GetPlayer()->GetSelectedGameObject();
                char* scale_temp = strtok((char*)args, " ");
                if(!scale_temp)
                {
                    handler->SendSysMessage("Please supply the scale.");
                    handler->SetSentErrorMessage(true);
                    return false;
                }
                handler->PSendSysMessage("Scaling object to: %u", scale_temp);

                float scale = scale_temp ?atof(scale_temp) : -1.0f;
                if(scale < 0.0f || scale > 50)
                {
                    handler->SendSysMessage(LANG_BAD_VALUE);
                    handler->SetSentErrorMessage(true);
                    return false;
                }

                //set scale
                object->SetObjectScale(scale);
                object->DestroyForNearbyPlayers();
                object->UpdateObjectVisibility();
                object->SaveToDB();

                return true;

            } else 
            {
                char* id = strtok((char*)args, " ");
                if (!id)
                    return false;


                uint32 guidLow = atoi(id);

                if (!guidLow)
                    return false;

                if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow))
                    object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id);

                if (!object)
                {
                    handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
                    handler->SetSentErrorMessage(true);
                    return false;
                }

                char* scale_temp = strtok(NULL, "\n");
                if (!scale_temp)
                {
                    handler->SendSysMessage("Please set the #guid and the #scale.");
                    handler->SetSentErrorMessage(true);
                    return false;
                }
                handler->SendSysMessage(scale_temp);
                float scale = scale_temp ? atof(scale_temp) : -1.0f;
                if (scale < 0.0f || scale > 50)
                {
                    handler->SendSysMessage(LANG_BAD_VALUE);
                    handler->SetSentErrorMessage(true);
                    return false;
                }

                //set scale
                object->SetObjectScale(scale);
                object->DestroyForNearbyPlayers();
                object->UpdateObjectVisibility();
                object->SaveToDB();

                return true;
            }
        }
    //move selected object
    static bool HandleGameObjectMoveCommand(ChatHandler* handler, char const* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
        char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
        if (!id)
            return false;

        uint32 guidLow = atoi(id);
        if (!guidLow)
            return false;

        GameObject* object = nullptr;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* toX = strtok(nullptr, " ");
        char* toY = strtok(nullptr, " ");
        char* toZ = strtok(nullptr, " ");

        if (!toX)
        {
            Player* player = handler->GetSession()->GetPlayer();
            object->GetMap()->GameObjectRelocation(object, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), object->GetOrientation());
            object->DestroyForNearbyPlayers();
            object->UpdateObjectVisibility();
        }
        else
        {
            if (!toY || !toZ)
                return false;

            float x = (float)atof(toX);
            float y = (float)atof(toY);
            float z = (float)atof(toZ);

            if (!MapManager::IsValidMapCoord(object->GetMapId(), x, y, z))
            {
                handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, object->GetMapId());
                handler->SetSentErrorMessage(true);
                return false;
            }

            object->GetMap()->GameObjectRelocation(object, x, y, z, object->GetOrientation());
            object->DestroyForNearbyPlayers();
            object->UpdateObjectVisibility();
        }

        object->SaveToDB();
        object->Refresh();

        handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow());

        return true;
    }