示例#1
0
            void SpellHit(Unit* caster, SpellInfo const* spell)
            {
                if (caster->GetTypeId() == TYPEID_UNIT && spell->Id == SPELL_COUNTER)
                {
                    ++killCounter;
                    ZombieEvent* global;
                    ZombieAI* zombieAI;
                    Creature* zombie = me->FindNearestCreature(NPC_ZOMBIE, 200.0f, true);

                    if (zombie)
                        zombieAI = CAST_AI(ZombieAI, zombie->AI());

                    if (killCounter >= global->GetWaveTotalAmount()) // Wave End
                    {
                        ++waveCounter;
                        killCounter = 0; // Reset amount of zombies killed this wave
                        DespawnTurrets(true); // There shouldn't be any turrets but clear them anyway.

                        // Prepare next wave
                        // Amount of zombies we should spawn
                        if (waveCounter <= 5) // we should go easy on the players on wave 5 and below
                        {
                            global->SetAmountToSpawn(global->GetWaveTotalAmount() + ((waveCounter * urand(7,10)) * 2));
                            global->SetWaveTotalAmount(global->GetAmountToSpawn());
                        }
                        else
                        {
                            global->SetAmountToSpawn(global->GetWaveTotalAmount() + ((waveCounter * urand(9,12)) * 2));
                            global->SetWaveTotalAmount(global->GetAmountToSpawn());
                        }

                        if (zombieAI)
                            zombieAI->zombieMovementSpeed += 0.05f; // Slightly increase the movement speed of zombies in next wave

                        if (urand(0, 1) == 0) // 50% chance to spawn a turret on new wave
                        {
                            int8 t = urand(0, 2);
                            if (urand(0, 1) == 0)
                                me->SummonCreature(NPC_TURRET_P1, TurretPlacePoints[t].GetPositionX(), TurretPlacePoints[t].GetPositionY(), TurretPlacePoints[t].GetPositionZ(), TurretPlacePoints[t].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 30000);
                            else
                                me->SummonCreature(NPC_TURRET_P2, TurretPlacePoints[t].GetPositionX(), TurretPlacePoints[t].GetPositionY(), TurretPlacePoints[t].GetPositionZ(), TurretPlacePoints[t].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 30000);
                        }
                    }
                    else
                    {
                        // Don't spawn powerups when switching waves
                        if (zombieAI)
                            zombieAI->attemptSpawnPowerUp = true; 
                    }
                }
            }
示例#2
0
            void StartSpawningZombies()
            {
                for (uint8 i = 0; i < MAX_SPAWNPOINTS; i++)
                {
                    if (!canSpawn[i])
                        continue;
                    
                    if (global->GetAmountToSpawn() <= 0)
                        continue;
 
                    float x = ZombieSpawnPoints[i].GetPositionX() + irand(-4, 4);
                    float y = ZombieSpawnPoints[i].GetPositionY() + irand(-4, 4);
                    float z = ZombieSpawnPoints[i].GetPositionZ();
                    float ground_Z = me->GetMap()->GetHeight(x, y, z, true, MAX_FALL_DISTANCE);
                    if (fabs(ground_Z - z) < 0.1f)
                        z = ground_Z;

                    if (Creature* zombie = me->SummonCreature(NPC_ZOMBIE, x, y, z, ZombieSpawnPoints[i].GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN))
                    {
                        zombie->CastSpell(zombie, SPELL_EMERGE_VISUAL, false);
                        global->SetAmountToSpawn(global->GetAmountToSpawn() -1);
                    }
                }
            }