Ejemplo n.º 1
0
 void AIUpdate() override
 {
     if (_isTimerFinished(mSummonTimer))
     {
         spawnCreature(SKELETON_ADD, getCreature()->GetPositionX() + 6, getCreature()->GetPositionY() + 4, getCreature()->GetPositionZ(), 0);
         spawnCreature(SKELETON_ADD, getCreature()->GetPositionX() - 6, getCreature()->GetPositionY() + 4, getCreature()->GetPositionZ(), 0);
         _resetTimer(mSummonTimer, 15000);
     }
 }
CreatureObject* CreatureManagerImplementation::spawnCreature(uint32 templateCRC, uint32 objectCRC, float x, float z, float y, uint64 parentID, bool persistent) {
	CreatureTemplate* creoTempl = creatureTemplateManager->getTemplate(templateCRC);

	if (creoTempl == NULL)
		return spawnCreature(objectCRC, x, z, y, parentID);

	CreatureObject* creature = NULL;

	String templateToSpawn;

	if (objectCRC == 0) {
		templateToSpawn = getTemplateToSpawn(templateCRC);
		objectCRC = templateToSpawn.hashCode();
	}

	creature = createCreature(objectCRC, persistent, templateCRC);

	if (creature != NULL && creature->isAiAgent()) {
		AiAgent* npc = cast<AiAgent*>(creature);
		npc->loadTemplateData(creoTempl);
	} else if (creature == NULL) {
		error("could not spawn template " + templateToSpawn);
	}

	placeCreature(creature, x, z, y, parentID);

	return creature;
}
CreatureObject* CreatureManagerImplementation::spawnCreatureWithLevel(unsigned int mobileTemplateCRC, int level, float x, float z, float y, uint64 parentID ) {
	CreatureObject* creature = spawnCreature(mobileTemplateCRC, 0, x, z, y, parentID);

	if (creature != NULL)
		creature->setLevel(level);

	return creature;
}
Ejemplo n.º 4
0
    void S0_SpawnIntroMobs()
    {
        if (isTimerFinished(S0_SpawnIntroMobsTimer))
        {
            S0_SpawnIntroMobsTimer = 0; // This forces a new timer to be started below
            
            spawnCreature(GetRandomIntroMob(), IntroPortals[0].x, IntroPortals[0].y, IntroPortals[0].z, IntroPortals[0].o);
            spawnCreature(GetRandomIntroMob(), IntroPortals[1].x, IntroPortals[1].y, IntroPortals[1].z, IntroPortals[1].o);
            spawnCreature(GetRandomIntroMob(), IntroPortals[2].x, IntroPortals[2].y, IntroPortals[2].z, IntroPortals[2].o);
        }

        // Start another 15s timer
        if (getTimeForTimer(S0_SpawnIntroMobsTimer) <= 0)
        {
            S0_SpawnIntroMobsTimer = addTimer(VH_TIMER_SPAWN_INTRO_MOB);
        }
    }
CreatureObject* CreatureManagerImplementation::spawnCreatureWithAi(uint32 templateCRC, float x, float z, float y, uint64 parentID, bool persistent) {
	CreatureObject* creature = spawnCreature(templateCRC, 0, x, z, y, parentID, persistent);

	if (creature != NULL && creature->isAiAgent())
		cast<AiAgent*>(creature)->activateLoad("");
	else {
		error("could not spawn template " + String::valueOf(templateCRC) + " with AI.");
		creature = NULL;
	}

	return creature;
}
Ejemplo n.º 6
0
 void Ectoplasm()
 {
     spawnCreature(5763, 134.249207f, 242.194839f, -98.375496f, 3.325373f);
     spawnCreature(5763, 124.917931f, 255.066635f, -97.796837f, 4.176745f);
     spawnCreature(5763, 113.077148f, 258.880157f, -97.190590f, 4.688039f);
     spawnCreature(5763, 138.794693f, 228.224976f, -100.174332f, 2.471645f);
     spawnCreature(5763, 128.170364f, 225.190247f, -99.392830f, 2.411169f);
     spawnCreature(5763, 136.762009f, 242.685669f, -98.564545f, 3.344223f);
     spawnCreature(5763, 122.403961f, 259.438354f, -98.153984f, 4.366811f);
 }
Ejemplo n.º 7
0
    void Split()
    {
        CurrentHealth = getCreature()->getHealth();
        _setDisplayId(24144);
        getCreature()->setHealth(240000);
        getCreature()->setMaxHealth(240000);

        mLynx = spawnCreature(CN_LYNX_SPIRIT, getCreature()->GetPosition());
        if (mLynx)
        {
            mLynx->GetAIInterface()->AttackReaction(getCreature()->GetAIInterface()->getNextTarget(), 1);
            mLynx->m_noRespawn = true;
        }

        setScriptPhase(2);
    }
Ejemplo n.º 8
0
    void OnCombatStop(Unit* /*pTarget*/) override
    {
        if (pSkarvald != nullptr)
        {
            if (pSkarvald->isAlive())
                moveToSpawn();
            else
                spawnCreature(CN_DALRONN, pSkarvald->getCreature()->GetSpawnPosition());
        }

        if (pSkarvaldGhost != nullptr && pSkarvaldGhost->isAlive())
        {
            pSkarvaldGhost->despawn();
            pSkarvaldGhost = nullptr;
        }
    }
void CreatureManagerImplementation::spawnRandomCreature(int number, float x, float z, float y, uint64 parentID) {
	Locker locker(_this.get());

	if (reservePool.size() != 0) {
		int id = System::random(reservePool.size() - 1);
		ManagedReference<AiAgent*> aiAgent = reservePool.get(id);
		reservePool.remove(id);

		locker.release();

		placeCreature(aiAgent, x, z, y, parentID);

		//aiAgent->info("respawning from reserve Pool", true);

		++spawnedRandomCreatures;

		return;
	}

	locker.release();

	if (creatureTemplateManager->size() == 0)
		return;

	int max = creatureTemplateManager->size() - 1;

	uint32 randomCreature = System::random(max);
	uint32 randomTemplate = 0;
	Reference<CreatureTemplate*> creoTempl = NULL;

	HashTableIterator<uint32, Reference<CreatureTemplate*> > iterator = creatureTemplateManager->iterator();

	for (int i = 0; i < randomCreature; ++i) {
		iterator.getNextKeyAndValue(randomTemplate, creoTempl);
		//randomTemplate = iterator.getNextKey();
	}

	if (creoTempl == NULL || creoTempl->getLevel() > 100)
		return;

	for (int i = 0; i < number; ++i) {
		if (spawnCreature(randomTemplate, 0, x, z, y, parentID) != NULL)
			++spawnedRandomCreatures;
	}
}
Ejemplo n.º 10
0
    void OnDied(Unit* /*pKiller*/) override
    {
        if (pSkarvald != nullptr && pSkarvald->isAlive())
        {
            sendChatMessage(CHAT_MSG_MONSTER_YELL, 0, "See... you... soon.");
            pSkarvald->sendChatMessage(CHAT_MSG_MONSTER_YELL, 13233, "Pagh! What sort of necromancer lets death stop him? I knew you were worthless!");
            spawnCreature(CN_DALRONN_GHOST, getCreature()->GetPosition());
            getCreature()->addUnitFlags(UNIT_FLAG_NOT_SELECTABLE);
        }
        else if (pSkarvald != nullptr && !pSkarvald->isAlive())
        {
            sendChatMessage(CHAT_MSG_MONSTER_YELL, 13201, "There's no... greater... glory.");

            pSkarvaldGhost = getNearestCreatureAI(CN_SKARVALD_GHOST);

            if (pSkarvaldGhost != nullptr)
            {
                pSkarvaldGhost->despawn(1000, 0);
                pSkarvaldGhost = nullptr;
            }
        }
    }
Ejemplo n.º 11
0
    void OnDied(Unit* /*pKiller*/) override
    {
        if (pDalronn != nullptr && pDalronn->isAlive())
        {
            sendChatMessage(CHAT_MSG_MONSTER_YELL, 0, "Not... over... yet.");
            pDalronn->sendChatMessage(CHAT_MSG_MONSTER_YELL, 13203, "Skarvald, you incompetent slug! Return and make yourself useful!");
            spawnCreature(CN_SKARVALD_GHOST, getCreature()->GetPosition());
            getCreature()->addUnitFlags(UNIT_FLAG_NOT_SELECTABLE);
        }
        else if (pDalronn != nullptr && !pDalronn->isAlive())
        {
            sendChatMessage(CHAT_MSG_MONSTER_YELL, 13231, "A warrior's death.");

            pDalronnGhost = getNearestCreatureAI(CN_DALRONN_GHOST);

            if (pDalronnGhost != nullptr)
            {
                pDalronnGhost->despawn(1000, 0);
                pDalronnGhost = nullptr;
            }
        }
    }
Ejemplo n.º 12
0
 void OnDied(Unit* /*pKiller*/) override
 {
     //Ressurect event
     spawnCreature(CN_INGVAR_UNDEAD, getCreature()->GetPositionX(), getCreature()->GetPositionY(), getCreature()->GetPositionZ(), getCreature()->GetOrientation(), getCreature()->getFactionTemplate());
     despawn(1000, 0);
 }
Ejemplo n.º 13
0
 void BMutanus()
 {
     Mutanus = spawnCreature(CN_MUTANUS, 136.337006f, 263.769989f, -102.666000f, 4.002330f);
 }
Ejemplo n.º 14
0
 void Moccasin()
 {
     spawnCreature(5762, 134.249207f, 242.194839f, -98.375496f, 3.325373f);
     spawnCreature(5762, 124.917931f, 255.066635f, -97.796837f, 4.176745f);
     spawnCreature(5762, 113.077148f, 258.880157f, -97.190590f, 4.688039f);
 }