当前位置: 首页>>代码示例>>C++>>正文


C++ GameObject::CreateFromProto方法代码示例

本文整理汇总了C++中GameObject::CreateFromProto方法的典型用法代码示例。如果您正苦于以下问题:C++ GameObject::CreateFromProto方法的具体用法?C++ GameObject::CreateFromProto怎么用?C++ GameObject::CreateFromProto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameObject的用法示例。


在下文中一共展示了GameObject::CreateFromProto方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

GameObject *MapManagerScript::SpawnGameObject( uint32 pEntry, float pX, float pY, float pZ, float pO )
{
    GameObject* pGameObject = _manager->CreateGameObject(pEntry);
    if(pGameObject == NULL || !pGameObject->CreateFromProto(pEntry, _manager->GetMapId(), pX, pY, pZ, pO))
        return NULLGOB;

    pGameObject->SetInstanceID(_manager->GetInstanceID());
    pGameObject->PushToWorld(_manager);
    return pGameObject;
}
开发者ID:Sandshroud,项目名称:Sandshroud-Prodigy,代码行数:10,代码来源:MapManagerScript.cpp

示例2: SpawnCrates

		void SpawnCrates(uint32 id, MapMgr* pMapMgr)
		{
			uint32 entry = 190094;
			float x = 0.0f, y = 0.0f, z = 0.0f, o = 0.0f;
			switch(id)
			{
				case 0:
					{
						x = 1570.92f;
						y = 669.933f;
						z = 102.309f;
						o = -1.64061f;
					}
					break;
				case 1:
					{
						x = 1579.42f;
						y = 621.446f;
						z = 99.7329f;
						o = 2.9845f;
					}
					break;
				case 2:
					{
						x = 1629.68f;
						y = 731.367f;
						z = 112.847f;
						o = -0.837757f;
					}
					break;
				case 3:
					{
						x = 1674.39f;
						y = 872.307f;
						z = 120.394f;
						o = -1.11701f;
					}
					break;
				case 4:
					{
						x = 1628.98f;
						y = 812.142f;
						z = 120.689f;
						o = 0.436332f;
					}
					break;
			}
			GameObject* crate = pMapMgr->GetInterface()->GetGameObjectNearestCoords(x, y, z, 190094);
			if(crate)
				crate->Despawn(0, 0);
			GameObject* go = pMapMgr->CreateGameObject(entry);
			go->CreateFromProto(entry, pMapMgr->GetMapId(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f);
			go->PushToWorld(pMapMgr);
		}
开发者ID:Antares84,项目名称:arcemu,代码行数:54,代码来源:Instance_CullingOfStratholme.cpp

示例3: CreateAndSpawnGameObject

// Spawns the object too, without which you can not interact with the object
GameObject* MapMgr::CreateAndSpawnGameObject(uint32 entryID, float x, float y, float z, float o, float scale)
{
	GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(entryID);
	if(!goi)
	{
		LOG_DEBUG("Error looking up entry in CreateAndSpawnGameObject");
		return NULL;
	}

	LOG_DEBUG("CreateAndSpawnGameObject: By Entry '%u'", entryID);

	GameObject* go = CreateGameObject(entryID);

	//Player *chr = m_session->GetPlayer();
	uint32 mapid = GetMapId();
	// Setup game object
	go->CreateFromProto(entryID, mapid, x, y, z, o);
	go->SetScale(scale);
	go->InitAI();
	go->PushToWorld(this);

	// Create spawn instance
	GOSpawn* gs = new GOSpawn;
	gs->entry = go->GetEntry();
	gs->facing = go->GetOrientation();
	gs->faction = go->GetFaction();
	gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
	gs->id = objmgr.GenerateGameObjectSpawnID();
	gs->o = 0.0f;
	gs->o1 = go->GetParentRotation(0);
	gs->o2 = go->GetParentRotation(2);
	gs->o3 = go->GetParentRotation(3);
	gs->scale = go->GetScale();
	gs->x = go->GetPositionX();
	gs->y = go->GetPositionY();
	gs->z = go->GetPositionZ();
	gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0);
	//gs->stateNpcLink = 0;
	gs->overrides = go->GetOverrides();

	uint32 cx = GetPosX(x);
	uint32 cy = GetPosY(y);

	GetBaseMap()->GetSpawnsListAndCreate(cx, cy)->GOSpawns.push_back(gs);
	go->m_spawn = gs;

	MapCell* mCell = GetCell(cx, cy);

	if(mCell != NULL)
		mCell->SetLoaded();

	return go;
}
开发者ID:Thomas195,项目名称:arcemu,代码行数:54,代码来源:MapMgr.cpp

示例4: SpawnCrystal

 void SpawnCrystal(uint32 id)
 {
     uint32 entry = 0;
     float x = 0.0f, y = 0.0f, z = 0.0f, o = 0.0f;
     switch (id)
     {
         case 0:
         {
             entry = GO_RITUAL_CRYSTAL_ENTRY_1;
             x = -392.416f;
             y = -724.865f;
             z = 29.4156f;
             o = M_PI_FLOAT;
         }
         break;
         case 1:
         {
             entry = GO_RITUAL_CRYSTAL_ENTRY_2;
             x = -365.279f;
             y = -751.087f;
             z = 29.4156f;
             o = M_PI_FLOAT;
         }
         break;
         case 2:
         {
             entry = GO_RITUAL_CRYSTAL_ENTRY_3;
             x = -365.41f;
             y = -724.865f;
             z = 29.4156f;
             o = M_PI_FLOAT;
         }
         break;
         case 3:
         {
             entry = GO_RITUAL_CRYSTAL_ENTRY_4;
             x = -392.286f;
             y = -751.087f;
             z = 29.4156f;
             o = M_PI_FLOAT;
         }
         break;
     }
     GameObject* go = _unit->GetMapMgr()->CreateGameObject(entry);
     go->CreateFromProto(entry, _unit->GetMapMgr()->GetMapId(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f);
     go->PushToWorld(_unit->GetMapMgr());
     _unit->m_ObjectSlots[id] = go->GetUIdFromGUID();
 }
开发者ID:TheGhostGroup,项目名称:AscEmu,代码行数:48,代码来源:Instance_DrakTharonKeep.cpp

示例5: SpawnGameObject

GameObject* MapScriptInterface::SpawnGameObject(uint32 Entry, float cX, float cY, float cZ, float cO, bool AddToWorld, uint32 Misc1, uint32 Misc2)
{
   
	GameObject *pGameObject = mapMgr.CreateGameObject(Entry);
	if(!pGameObject->CreateFromProto(Entry, mapMgr.GetMapId(), cX, cY, cZ, cO))
	{
		delete pGameObject;
		return NULL;
	}
	pGameObject->SetInstanceID(mapMgr.GetInstanceID());

	if(AddToWorld)
		pGameObject->PushToWorld(&mapMgr);

	return pGameObject;
}
开发者ID:Centraly,项目名称:SummitEmu,代码行数:16,代码来源:MapScriptInterface.cpp

示例6: SpawnGameObject

GameObject* CBattleground::SpawnGameObject(uint32 entry, uint32 MapId , float x, float y, float z, float o, uint32 flags, uint32 faction, float scale)
{
	GameObject* go = m_mapMgr->CreateGameObject(entry);

	Arcemu::Util::ArcemuAssert( go != NULL );

	go->CreateFromProto(entry, MapId, x, y, z, o);

	go->SetFaction(faction);
	go->SetScale(scale);
	go->SetUInt32Value(GAMEOBJECT_FLAGS, flags);
	go->SetPosition(x, y, z, o);
	go->SetInstanceID(m_mapMgr->GetInstanceID());

	return go;
}
开发者ID:lev1976g,项目名称:NoxicCore,代码行数:16,代码来源:Battleground.cpp

示例7:

GameObject * CBattleground::SpawnGameObject(uint32 entry,uint32 MapId , float x, float y, float z, float o, uint32 flags, uint32 faction, float scale)
{
	GameObject *go = m_mapMgr->CreateGameObject(entry);

	go->CreateFromProto(entry, MapId, x, y, z, o);

	go->SetUInt32Value(GAMEOBJECT_FACTION,faction);
	go->SetFloatValue(OBJECT_FIELD_SCALE_X,scale);	
	go->SetUInt32Value(GAMEOBJECT_FLAGS, flags);
	go->SetFloatValue(GAMEOBJECT_POS_X, x);
	go->SetFloatValue(GAMEOBJECT_POS_Y, y);
	go->SetFloatValue(GAMEOBJECT_POS_Z, z);
	go->SetFloatValue(GAMEOBJECT_FACING, o);
	go->SetInstanceID(m_mapMgr->GetInstanceID());
	go->m_battleground = this;

	return go;
}
开发者ID:Chero,项目名称:abcwow,代码行数:18,代码来源:BattlegroundMgr.cpp

示例8: SpawnGameObject

GameObject* MapScriptInterface::SpawnGameObject(uint32 Entry, float cX, float cY, float cZ, float cO, bool AddToWorld, uint32 Misc1, uint32 Misc2)
{
	if( mapMgr._shutdown == true )
		return NULL;
   
	GameObject *pGameObject = mapMgr.CreateGameObject(Entry);
	if(!pGameObject->CreateFromProto(Entry, mapMgr.GetMapId(), cX, cY, cZ, cO))
	{
		sGarbageCollection.AddObject( pGameObject );
		pGameObject = NULL;
		return NULL;
	}
	pGameObject->SetInstanceID(mapMgr.GetInstanceID());

	if(AddToWorld)
		pGameObject->PushToWorld(&mapMgr);

	return pGameObject;
}
开发者ID:AtVirus,项目名称:Descent-core,代码行数:19,代码来源:MapScriptInterface.cpp

示例9: OnDamageTaken

 void OnDamageTaken(Unit* mAttacker, uint32 fAmount)
 {
     if (_unit->HasAura(52723))    //handling a dummy :)
     {
         _unit->Heal(_unit, 52723, fAmount / 2);
     }
     if (_unit->GetHealthPct() < 2)
     {
         //lala
         _unit->Root();
         _unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2);
         for (uint8 i = 0; i < 7; i++)
             _unit->SchoolImmunityList[i] = 1;
         RemoveAIUpdateEvent();
         _unit->SendScriptTextChatMessage(SAY_MALGANIS_17);
         //spawn a chest and go
         GameObject* go = _unit->GetMapMgr()->CreateGameObject(190663);
         go->CreateFromProto(190663, _unit->GetMapMgr()->GetMapId(), _unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), _unit->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f);
         go->PushToWorld(_unit->GetMapMgr());
         _unit->Despawn(1, 0);
     }
 }
开发者ID:lev1976g,项目名称:AscEmu,代码行数:22,代码来源:Instance_CullingOfStratholme.cpp

示例10: OnDamageTaken

		void OnDamageTaken(Unit* mAttacker, uint32 fAmount)
		{
			if(_unit->HasAura(52723))    //handling a dummy :)
			{
				_unit->Heal(_unit, 52723, fAmount / 2);
			}
			if(_unit->GetHealthPct() < 2)
			{
				//lala
				_unit->Root();
				_unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2);
				for(uint8 i = 0; i < 7; i++)
					_unit->SchoolImmunityList[i] = 1;
				RemoveAIUpdateEvent();
				_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Your journey has just begun, young prince. Gather your forces, and meet me in the arctic land of Northrend. It is there we shall settle the score between us. It is there that your true destiny will unfold.");
				_unit->PlaySoundToSet(14412);
				//spawn a chest and go
				GameObject* go = _unit->GetMapMgr()->CreateGameObject(190663);
				go->CreateFromProto(190663, _unit->GetMapMgr()->GetMapId(), _unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), _unit->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f);
				go->PushToWorld(_unit->GetMapMgr());
				_unit->Despawn(1, 0);
			}
		}
开发者ID:Antares84,项目名称:arcemu,代码行数:23,代码来源:Instance_CullingOfStratholme.cpp

示例11: HandleGOSpawn

bool ChatHandler::HandleGOSpawn(const char *args, WorldSession *m_session)
{
	std::stringstream sstext;

	char* pEntryID = strtok((char*)args, " ");
	if (!pEntryID)
		return false;

	uint32 EntryID  = atoi(pEntryID);

	bool Save = false;
	char* pSave = strtok(NULL, " ");
	if (pSave)
		Save = (atoi(pSave)>0?true:false);

	GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(EntryID);
	if(!goi)
	{
		sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0';
		SystemMessage(m_session, sstext.str().c_str());
		return true;
	}

	sLog.outDebug("Spawning GameObject By Entry '%u'", EntryID);
	sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0';
	SystemMessage(m_session, sstext.str().c_str());

	GameObject *go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID);

	Player *chr = m_session->GetPlayer();
	uint32 mapid = chr->GetMapId();
	float x = chr->GetPositionX();
	float y = chr->GetPositionY();
	float z = chr->GetPositionZ();
	float o = chr->GetOrientation();

	go->SetInstanceID(chr->GetInstanceID());
	go->CreateFromProto(EntryID,mapid,x,y,z,o);

	/* fuck blizz coordinate system */
	go->SetFloatValue(GAMEOBJECT_ROTATION_02, sinf(o / 2));
	go->SetFloatValue(GAMEOBJECT_ROTATION_03, cosf(o / 2));
	go->PushToWorld(m_session->GetPlayer()->GetMapMgr());

	// Create sapwn instance
	GOSpawn * gs = new GOSpawn;
	gs->entry = go->GetEntry();
	gs->facing = go->GetOrientation();
	gs->faction = go->GetUInt32Value(GAMEOBJECT_FACTION);
	gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
	gs->id = objmgr.GenerateGameObjectSpawnID();
	gs->o = go->GetFloatValue(GAMEOBJECT_ROTATION);
	gs->o1 = go->GetFloatValue(GAMEOBJECT_ROTATION_01);
	gs->o2 = go->GetFloatValue(GAMEOBJECT_ROTATION_02);
	gs->o3 = go->GetFloatValue(GAMEOBJECT_ROTATION_03);
	gs->scale = go->GetFloatValue(OBJECT_FIELD_SCALE_X);
	gs->x = go->GetPositionX();
	gs->y = go->GetPositionY();
	gs->z = go->GetPositionZ();
	gs->state = go->GetUInt32Value(GAMEOBJECT_STATE);
	//gs->stateNpcLink = 0;

	uint32 cx = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
	uint32 cy = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());

	m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx,cy)->GOSpawns.push_back(gs);
	go->m_spawn = gs;

	//go->AddToWorld();

	if(Save == true)
	{
		// If we're saving, create template and add index
		go->SaveToDB();
	}
	sGMLog.writefromsession( m_session, "spawned gameobject %s, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, gs->entry, m_session->GetPlayer()->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "" );
	return true;
}
开发者ID:Chero,项目名称:abcwow,代码行数:78,代码来源:Level2.cpp

示例12: HandleGOSpawn

bool ChatHandler::HandleGOSpawn(const char* args, WorldSession* m_session)
{
	std::stringstream sstext;

	char* pEntryID = strtok((char*)args, " ");
	if(!pEntryID)
		return false;

	uint32 EntryID  = atoi(pEntryID);

	bool Save = false;
	char* pSave = strtok(NULL, " ");
	if(pSave)
		Save = (atoi(pSave) > 0 ? true : false);

	GameObjectInfo* goi = GameObjectNameStorage.LookupEntry(EntryID);
	if(!goi)
	{
		sstext << "GameObject Info '" << EntryID << "' Not Found" << '\0';
		SystemMessage(m_session, sstext.str().c_str());
		return true;
	}

	LOG_DEBUG("Spawning GameObject By Entry '%u'", EntryID);
	sstext << "Spawning GameObject By Entry '" << EntryID << "'" << '\0';
	SystemMessage(m_session, sstext.str().c_str());

	Player* chr = m_session->GetPlayer();

	GameObject* go = chr->GetMapMgr()->CreateGameObject(EntryID);

	uint32 mapid = chr->GetMapId();
	float x = chr->GetPositionX();
	float y = chr->GetPositionY();
	float z = chr->GetPositionZ();
	float o = chr->GetOrientation();

	go->CreateFromProto(EntryID, mapid, x, y, z, o);
	go->PushToWorld(chr->GetMapMgr());
	go->Phase(PHASE_SET, chr->GetPhase());
	// Create spawn instance
	GOSpawn* gs = new GOSpawn;
	gs->entry = go->GetEntry();
	gs->facing = go->GetOrientation();
	gs->faction = go->GetFaction();
	gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
	gs->id = objmgr.GenerateGameObjectSpawnID();
	gs->o = 0.0f;
	gs->o1 = go->GetParentRotation(0);
	gs->o2 = go->GetParentRotation(2);
	gs->o3 = go->GetParentRotation(3);
	gs->scale = go->GetScale();
	gs->x = go->GetPositionX();
	gs->y = go->GetPositionY();
	gs->z = go->GetPositionZ();
	gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0);
	//gs->stateNpcLink = 0;
	gs->phase = go->GetPhase();
	gs->overrides = go->GetOverrides();

	uint32 cx = chr->GetMapMgr()->GetPosX(chr->GetPositionX());
	uint32 cy = chr->GetMapMgr()->GetPosY(chr->GetPositionY());

	chr->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cx, cy)->GOSpawns.push_back(gs);
	go->m_spawn = gs;

	MapCell* mCell = chr->GetMapMgr()->GetCell(cx, cy);

	if(mCell != NULL)
		mCell->SetLoaded();

	if(Save == true)
	{
		// If we're saving, create template and add index
		go->SaveToDB();
		go->m_loadedFromDB = true;
	}
	sGMLog.writefromsession(m_session, "spawned gameobject %s, entry %u at %u %f %f %f%s", GameObjectNameStorage.LookupEntry(gs->entry)->Name, gs->entry, chr->GetMapId(), gs->x, gs->y, gs->z, Save ? ", saved in DB" : "");
	return true;
}
开发者ID:Ikesters,项目名称:ArcPro,代码行数:80,代码来源:Level2.cpp

示例13: HandleGOSpawn

bool ChatHandler::HandleGOSpawn(const char *args, WorldSession *m_session)
{
    if(!args)
        return false;

    char* pEntryID = strtok((char*)args, " ");
    if (!pEntryID)
        return false;

    uint32 EntryID = atoi(pEntryID);
    if((GameObjectNameStorage.LookupEntry(EntryID) == NULL) || (objmgr.SQLCheckExists("gameobject_names", "entry", EntryID) == NULL))
    {
        RedSystemMessage(m_session, "Invalid Gameobject ID(%u).", EntryID);
        return true;
    }

    bool Save = m_session->HasGMPermissions() ? true : false;
    char* pSave = strtok(NULL, " ");
    if(pSave)
        Save = (atoi(pSave) > 0 ? true : false);

    GameObject* go = m_session->GetPlayer()->GetMapMgr()->CreateGameObject(EntryID);
    if(go == NULL)
    {
        RedSystemMessage(m_session, "Spawn of Gameobject(%u) failed.", EntryID);
        return true;
    }
    go->Init();

    Player* chr = m_session->GetPlayer();
    uint32 mapid = chr->GetMapId();
    float x = chr->GetPositionX();
    float y = chr->GetPositionY();
    float z = chr->GetPositionZ();
    float o = chr->GetOrientation();
    go->CreateFromProto(EntryID,mapid,x,y,z,o);
    BlueSystemMessage(m_session, "Spawning Gameobject(%u) at current position", EntryID);

    if(Save == true) // If we're saving, create template and add index
    {
        // Create spawn instance
        GOSpawn *gs = new GOSpawn;
        gs->entry = go->GetEntry();
        gs->facing = go->GetOrientation();
        gs->faction = go->GetUInt32Value(GAMEOBJECT_FACTION);
        gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
        gs->id = objmgr.GenerateGameObjectSpawnID();
        gs->scale = go->GetFloatValue(OBJECT_FIELD_SCALE_X);
        gs->x = x;
        gs->y = y;
        gs->z = z;
        gs->state = go->GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE);
        gs->phase = chr->GetPhaseMask();
        go->Load(gs);
        go->SaveToDB();
        uint32 cx = chr->GetMapMgr()->GetPosX(x);
        uint32 cy = chr->GetMapMgr()->GetPosY(y);
        chr->GetMapMgr()->AddGoSpawn(cx, cy, gs);
    }

    go->SetPhaseMask(chr->GetPhaseMask());
    go->SetInstanceID(chr->GetInstanceID());
    go->PushToWorld(m_session->GetPlayer()->GetMapMgr());

    sWorld.LogGM(m_session, "Spawned gameobject %u at %f %f %f (%s)", EntryID, x, y, z, Save ? "Saved" : "Not Saved");
    return true;
}
开发者ID:Refuge89,项目名称:Hearthstone,代码行数:67,代码来源:Level2.cpp

示例14: LuaGlobalFunctions_PerformIngameSpawn

int LuaGlobalFunctions_PerformIngameSpawn(lua_State * L)
{
	uint32 spawntype = luaL_checkint(L, 1);
	uint32 entry = luaL_checkint(L, 2);
	uint32 map = luaL_checkint(L, 3);
	float x = CHECK_FLOAT(L, 4);
	float y = CHECK_FLOAT(L, 5);
	float z = CHECK_FLOAT(L, 6);
	float o = CHECK_FLOAT(L, 7);
	uint32 faction = luaL_checkint(L, 8); //also scale as percentage
	uint32 duration = luaL_checkint(L, 9);
	uint32 equip1 = luaL_optint(L, 10, 1);
	uint32 equip2 = luaL_optint(L, 11, 1);
	uint32 equip3 = luaL_optint(L, 12, 1);
	//13: instance id
	uint32 save = luaL_optint(L, 14, 0);
	if(x && y && z && entry)
	{
		if (spawntype == 1) //Unit
		{ 
			CreatureProto *p = CreatureProtoStorage.LookupEntry(entry);
			CreatureInfo *i = CreatureNameStorage.LookupEntry(entry);
			if (p == NULL || i == NULL)
				RET_NIL(true);

			MapMgr *mapMgr = sInstanceMgr.GetMapMgr(map);
			if (mapMgr == NULL)
				RET_NIL(true);

			int32 instanceid = luaL_optint(L, 13, mapMgr->GetInstanceID());
			CreatureSpawn * sp = new CreatureSpawn();
			sp->entry = entry;
			sp->id = objmgr.GenerateCreatureSpawnID();
			sp->x = x;
			sp->y = y;
			sp->z = z;
			sp->o = o;
			sp->emote_state = 0;
			sp->flags = 0;
			sp->factionid = faction;
			sp->stand_state = 0;
			sp->phase = 1;
			sp->vehicle = p->vehicle_entry > 0 ? true : false;
			sp->Bytes = NULL;
			sp->ChannelData = NULL;
			sp->MountedDisplay = NULL;

			Creature * pCreature = NULL;
			if(sp->vehicle)
			{
				pCreature = TO_CREATURE(mapMgr->CreateVehicle(entry));
				TO_VEHICLE(pCreature)->Load(sp, mapMgr->iInstanceMode, NULL);
			}
			else
			{
				pCreature = mapMgr->CreateCreature(entry);
				pCreature->Load(sp, mapMgr->iInstanceMode, NULL);
			}

			pCreature->m_loadedFromDB = true;
			pCreature->SetFaction(faction);
			pCreature->SetInstanceID(instanceid);
			pCreature->SetMapId(map);
			pCreature->m_noRespawn = true;
			pCreature->PushToWorld(mapMgr);
			if (duration>0) 
				pCreature->Despawn(duration,0);
			if (save)
				pCreature->SaveToDB();
			Lunar<Unit>::push(L,TO_UNIT(pCreature));
		}
		else if (spawntype == 2) //GO
		{ 
			GameObjectInfo *n = GameObjectNameStorage.LookupEntry(entry);
			if (n == NULL)
				RET_NIL(true);

			MapMgr *mapMgr = sInstanceMgr.GetMapMgr(map);
			if (mapMgr == NULL)
				RET_NIL(true);

			int32 instanceid = luaL_optint(L, 13, mapMgr->GetInstanceID());

			GameObject *go = mapMgr->CreateGameObject(entry);
			go->SetInstanceID(instanceid);
			go->CreateFromProto(entry,map,x,y,z,o);

			// Create spawn instance
			GOSpawn * gs = new GOSpawn;
			gs->entry = go->GetEntry();
			gs->facing = go->GetOrientation();
			gs->faction = go->GetFaction();
			gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
			gs->id = objmgr.GenerateGameObjectSpawnID();
			gs->scale = go->GetUInt32Value(OBJECT_FIELD_SCALE_X);
			gs->x = go->GetPositionX();
			gs->y = go->GetPositionY();
			gs->z = go->GetPositionZ();
			gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0);
			gs->phase = 0;
//.........这里部分代码省略.........
开发者ID:Refuge89,项目名称:Hearthstone,代码行数:101,代码来源:FunctionGlobal.cpp


注:本文中的GameObject::CreateFromProto方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。