Пример #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 Reset()
 {
     killCounter = 0;
     waveCounter = 0;
     global->SetWaveTotalAmount(20); // first wave should always start off with 20 zombies.
 }