All pastes #717541 Raw Edit

Anonymous

public text v1 · immutable
#717541 ·published 2007-09-27 18:30 UTC
rendered paste body
class SpawnerAI : public CreatureAIScript
{
public:
	ADD_CREATURE_FACTORY_FUNCTION(SpawnerAI);
	SpawnerAI(Creature *pCreature) : CreatureAIScript(pCreature) {}
	void AIUpdate(const char *args, Creature* pThis)
{
	uint32 entry = 100;
	
	CreatureProto * proto = CreatureProtoStorage.LookupEntry(entry);
	CreatureInfo * info = CreatureNameStorage.LookupEntry(entry);

	CreatureSpawn * sp = new CreatureSpawn;
	//sp->displayid = info->DisplayID;
	info->GenerateModelId(&sp->displayid);
	sp->entry = entry;
	sp->form = 0;
	sp->id = objmgr.GenerateCreatureSpawnID();
	sp->movetype = 0;
	sp->x = pThis->GetPositionX();
	sp->y = pThis->GetPositionY();
	sp->z = pThis->GetPositionZ();
	sp->o = pThis->GetOrientation();
	sp->emote_state =0;
	sp->flags = 0;
	sp->factionid = proto->Faction;
	sp->bytes=0;
	sp->bytes2=0;
	sp->respawnNpcLink = 0;


	Creature * p = pThis->GetMapMgr()->CreateCreature();
	ASSERT(p);
	p->Load(sp, (uint32)NULL, NULL);
	p->PushToWorld(pThis->GetMapMgr());
	
	uint32 x = pThis->GetMapMgr()->GetPosX(pThis->GetPositionX());
	uint32 y = pThis->GetMapMgr()->GetPosY(pThis->GetPositionY());

	// Add spawn to map
	pThis->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(
		x,
		y)->CreatureSpawns.insert(sp);
	}
};