Hi there!
I took some functions from Chathandler and built it in player.cpp so a chest with displayid of a grave is spawned...
but how can i manipulate that spawned gameobject afterwards?
bool Player::SpawnGameObject(uint32 id, uint32 spawntimeSecs)
{
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
if(!id)
return false;
const GameObjectInfo *gInfo = ObjectMgr::GetGameObjectInfo(id);
if (!gInfo)
{
return false;
}
if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
{
// report to DB errors log as in loading case
sLog.outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.",id, gInfo->type, gInfo->displayId);
return false;
}
Player *chr = this;
float x = float(chr->GetPositionX());
float y = float(chr->GetPositionY());
float z = float(chr->GetPositionZ());
float o = float(chr->GetOrientation());
Map *map = chr->GetMap();
GameObject* pGameObj = new GameObject;
uint32 db_lowGUID = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if(!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{
delete pGameObj;
return false;
}
if( spawntimeSecs )
{
uint32 value = atoi((char*)spawntimeSecs);
pGameObj->SetRespawnTime(value);
//sLog.outDebug("*** spawntimeSecs: %d", value);
}
pGameObj->SetName("Testing!!!"); // <<<< THE SPOT I MEAN !!!
// fill the gameobject data and save to the db
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn());
// this will generate a new guid if the object is in an instance
if(!pGameObj->LoadFromDB(db_lowGUID, map))
{
delete pGameObj;
return false;
}
map->Add(pGameObj);
// TODO: is it really necessary to add both the real and DB table guid here ?
sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID));
return true;
}
It compiles well... Function is working well to...
pGameObj->SetName("Testing!!!"); // <<<< THE SPOT I MEAN !!!
doesnt take effect, the spawned object still has the name from gameobject_template...
P.s.:
Guess i got it... i have to modify the sql-tables every time !?