void Reset()
        {
            uiVenganceTimer = 10000;
            uiRadianceTimer = 16000;
            uiHammerJusticeTimer = 25000;
            uiResetTimer = 5000;

            bDone = false;
            Map* pMap = me->GetMap();
            if (hasBeenInCombat && pMap && pMap->IsDungeon())
            {
                Map::PlayerList const &players = pMap->GetPlayers();
                for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                {
                     if(itr->GetSource() && itr->GetSource()->IsAlive() && !itr->GetSource()->IsGameMaster())
                        return; //se almeno un player ¡§¡§ vivo, esce						
                }
                
                if(instance)
                {
                   GameObject* GO = GameObject::GetGameObject(*me, instance->GetData64(DATA_MAIN_GATE1));
                   if(GO)
                      instance->HandleGameObject(GO->GetGUID(),true);
                   Creature* announcer=pMap->GetCreature(instance->GetData64(DATA_ANNOUNCER));
                   instance->SetData(DATA_ARGENT_SOLDIER_DEFEATED,0);
                   announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                 }
                 me->RemoveFromWorld();

                 //ResetEncounter();
            }
        }
Exemple #2
0
bool OutdoorPvPObjectiveZM_GraveYard::HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid)
{
    std::map<uint64,uint32>::iterator itr = m_CreatureTypes.find(guid);
    if(itr != m_CreatureTypes.end())
    {
        Map* map = m_PvP->GetMap();
        Creature * cr = map->GetCreature(guid);
        if(!cr)
            return true;
        // if the flag is already taken, then return
        if(m_FlagCarrierGUID)
            return true;
        if(itr->second == ZM_ALLIANCE_FIELD_SCOUT)
        {
            cr->CastSpell(plr,ZM_BATTLE_STANDARD_A,true);
            m_FlagCarrierGUID = plr->GetGUID();
        }
        else if(itr->second == ZM_HORDE_FIELD_SCOUT)
        {
            cr->CastSpell(plr,ZM_BATTLE_STANDARD_H,true);
            m_FlagCarrierGUID = plr->GetGUID();
        }
        UpdateTowerState();
        plr->PlayerTalkClass->CloseGossip();
        return true;
    }
    return false;
}
Exemple #3
0
bool GossipSelect_npc_taretha(Player *player, Creature *creature, uint32 sender, uint32 action)
{
    ScriptedInstance* pInstance = (creature->GetInstanceData());
    uint8 Parts = 4;

    if (action == GOSSIP_ACTION_INFO_DEF+1)
    {
        player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_EPOCH2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
        player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH2, creature->GetGUID());
    }

    if (action == GOSSIP_ACTION_INFO_DEF+2)
    {
        player->CLOSE_GOSSIP_MENU();

        if (pInstance)
        {
            pInstance->SetData(TYPE_THRALL_EVENT, IN_PROGRESS);
            pInstance->SetData(TYPE_THRALL_PART4,IN_PROGRESS);
        }

        Map* tmpMap = creature->GetMap();

        if (!tmpMap)
            return true;

        if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL)))
        {
            if(Thrall)
                CAST_AI(npc_thrall_old_hillsbradAI, Thrall->AI())->StartEscort(player, Parts);
        }
    }

    return true;
}
Exemple #4
0
bool OutdoorPvPObjectiveEP_PWT::HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid)
{
    std::map<uint64,uint32>::iterator itr = m_CreatureTypes.find(guid);
    if(itr != m_CreatureTypes.end())
    {
        Map* map = m_PvP->GetMap();
        Creature * cr = map->GetCreature(guid);
        if(!cr)
            return true;
        if(itr->second == EP_PWT_FLIGHTMASTER)
        {
            uint32 curloc = EP_PWT_Taxi;

            WorldPacket data( SMSG_SHOWTAXINODES, (4+8+4+8*4) );
            data << uint32( 1 );
            data << uint64( cr->GetGUID() );
            data << uint32( curloc );

            for (uint8 i=0; i<TaxiMaskSize; i++)
                data << uint32(m_taximask[i]);                  // known nodes

            plr->GetSession()->SendPacket( &data );
        }
        return true;
    }
    return false;
}
Exemple #5
0
bool OutdoorPvPObjective::DelCapturePoint()
{
    Map* map = m_PvP->GetMap();

    if (m_CapturePoint)
    {
        GameObject *obj = map->GetGameObject(m_CapturePoint);
        if (obj)
        {
            obj->SetRespawnTime(0);                                 // not save respawn time
            obj->Delete();
        }

        m_CapturePoint = 0;
    }
    if (m_CapturePointCreature)
    {
        Creature *cr = map->GetCreature(m_CapturePointCreature);
        if (cr)
            cr->AddObjectToRemoveList();

        m_CapturePointCreature = 0;
    }
    return true;
}
Exemple #6
0
void OutdoorPvPObjective::HandlePlayerActivityChanged(Player * plr)
{
    Map* map = m_PvP->GetMap();
    if(m_CapturePointCreature)
        if(Creature * c = map->GetCreature(m_CapturePointCreature))
            if(c->AI())
                c->AI()->MoveInLineOfSight(plr);
}
Exemple #7
0
    int32 NextStep(uint32 Steps)
    {       
       Map* tmpMap = me->GetMap();

       if (!tmpMap)
           return true;

       if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL)))
       {
           switch (Steps)
           {
               case 1:
                   me->SetFacingToObject(Thrall);
                   return 2000;
               case 2:
                   DoScriptText(SAY_IMAGE_1, me);
                   return 15000;
               case 3:
                   if (pInstance)
                   {
                       if (pInstance->GetData(TYPE_THRALL_PART1) == NOT_STARTED)
                           me->SummonCreature(NPC_THRALL, 2231.51f, 119.84f, 82.297f, 4.15f,TEMPSUMMON_DEAD_DESPAWN,15000);

                       if (pInstance->GetData(TYPE_THRALL_PART1) == DONE && pInstance->GetData(TYPE_THRALL_PART2) == NOT_STARTED)
                       {
                           me->SummonCreature(NPC_THRALL, 2063.40f, 229.512f, 64.488f, 2.18f,TEMPSUMMON_DEAD_DESPAWN,15000);
                           me->SummonCreature(NPC_SKARLOC_MOUNT,2047.90f, 254.85f, 62.822f, 5.94f, TEMPSUMMON_DEAD_DESPAWN, 15000);
                       }

                       if (pInstance->GetData(TYPE_THRALL_PART2) == DONE && pInstance->GetData(TYPE_THRALL_PART3) == NOT_STARTED)
                           me->SummonCreature(NPC_THRALL, 2486.91f, 626.357f, 58.076f, 4.66f,TEMPSUMMON_DEAD_DESPAWN,15000);

                       if (pInstance->GetData(TYPE_THRALL_PART3) == DONE && pInstance->GetData(TYPE_THRALL_PART4) == NOT_STARTED)
                       {
                           me->SummonCreature(NPC_THRALL, 2660.48f, 659.409f, 61.937f, 5.83f,TEMPSUMMON_DEAD_DESPAWN,15000);
                           if (uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA))
                           {
                               if (Unit *Taretha = me->GetUnit(TarethaGUID))
                               Taretha->SetStandState(UNIT_STAND_STATE_STAND);
                           }
                        }
                    }
                    return 5000;
                case 4:
                    DoScriptText(SAY_IMAGE_2, me);
                    return 15000;
                 case 5:
                     me->CastSpell(me, SPELL_TELEPORT, false);
                     me->ForcedDespawn(1500);
                 default:
                     return 0;
            }
        }
        return true;
    }
    void UpdateEntry()
    {
        Map* tmpMap = me->GetMap();

        if (!tmpMap)
            return;

        if (!attackers.empty())
        {
            for (std::list<uint64>::iterator itr = attackers.begin(); itr != attackers.end(); ++itr)
            {
                if (Creature* attacker = tmpMap->GetCreature((*itr)))
                {
                    attacker->CastSpell(attacker, SPELL_TRANSFORM, true);

                    switch (attacker->GetEntry())
                    {
                        case NPC_TARREN_MILL_GUARDSMAN:
                            attacker->UpdateEntry(NPC_INFINITE_SLAYER);
                            break;
                        case NPC_TARREN_MILL_PROTECTOR:
                            attacker->UpdateEntry(NPC_INFINITE_DEFILER);

                            switch (Wave)
                            {
                                case 2:
                                    DoScriptText(SAY_INFINITE_AGGRO_3, attacker);
                                    break;
                                case 4:
                                    DoScriptText(SAY_INFINITE_AGGRO_1, attacker);
                                    break;
                                case 6:
                                    DoScriptText(SAY_INFINITE_AGGRO_2, attacker);
                                break;
                            }
                            break;
                        case NPC_TARREN_MILL_LOOKOUT:
                            attacker->UpdateEntry(NPC_INFINITE_SABOTEUR);
                            break;
                    }
                            
                    attacker->SetReactState(REACT_AGGRESSIVE);
                    attacker->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

                    if (Creature* Thrall = me->GetMap()->GetCreature(ThrallGUID))
                        attacker->AI()->AttackStart(Thrall);
                    else if (Creature* Thrall = me->FindNearestCreature(17876, 150.0f, true)) 
                        attacker->AI()->AttackStart(Thrall);
                }
            }
        }
    }
Exemple #9
0
void OutdoorPvPObjectiveEP_PWT::SummonFlightMaster(uint32 team)
{
    DelCreature(EP_PWT_FLIGHTMASTER);
    AddCreature(EP_PWT_FLIGHTMASTER,EP_PWT_FlightMaster.entry,team,EP_PWT_FlightMaster.map,EP_PWT_FlightMaster.x,EP_PWT_FlightMaster.y,EP_PWT_FlightMaster.z,EP_PWT_FlightMaster.o);

    Map* map = m_PvP->GetMap();
    Creature * c = map->GetCreature(m_Creatures[EP_PWT_FLIGHTMASTER]);
    if(c)
    {
        GossipOption * gso = new GossipOption;
        gso->Action = GOSSIP_OPTION_OUTDOORPVP;
        gso->GossipId = 0;
        gso->OptionText.assign("As the breeze whips straight as an arrow, let her go over Kill Devil Hill!");
        gso->Id = 50;
        gso->Icon = 1;
        gso->NpcFlag = 0;
        c->addGossipOption(*gso);
    }
}
        void Reset()
        {
            me->RemoveAllAuras();

            uiHolyFireTimer     = urand(9000,12000);
            uiHolySmiteTimer    = urand(5000,7000);
            uiRenewTimer        = urand(2000,5000);

            uiResetTimer        = 7000;

            bHealth = false;
            bDone = false;
    		
            if (Creature* pMemory = Unit::GetCreature(*me, MemoryGUID))
                if (pMemory->IsAlive())
                    pMemory->RemoveFromWorld();

            Map* pMap = me->GetMap();
            if (hasBeenInCombat && pMap && pMap->IsDungeon())
            {
                Map::PlayerList const &players = pMap->GetPlayers();
                for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                {
                    if(itr->GetSource() && itr->GetSource()->IsAlive() && !itr->GetSource()->IsGameMaster())
                       return; //se almeno un player ¡§¡§ vivo, esce						
                }
    			 
                if(pInstance)
                {
                   GameObject* GO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1));
                   if(GO)
                      pInstance->HandleGameObject(GO->GetGUID(),true);
                   Creature* announcer = pMap->GetCreature(pInstance->GetData64(DATA_ANNOUNCER));
                   pInstance->SetData(DATA_ARGENT_SOLDIER_DEFEATED,0);
                   announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                }

                me->RemoveFromWorld();
                //ResetEncounter();
            }

        }
uint32 OutdoorPvPObjectiveNA::GetAliveGuardsCount()
{
    uint32 cnt = 0;
    for(std::map<uint32, uint64>::iterator itr = m_Creatures.begin(); itr != m_Creatures.end(); ++itr)
    {
        switch(itr->first)
        {
            case NA_NPC_GUARD_01:
            case NA_NPC_GUARD_02:
            case NA_NPC_GUARD_03:
            case NA_NPC_GUARD_04:
            case NA_NPC_GUARD_05:
            case NA_NPC_GUARD_06:
            case NA_NPC_GUARD_07:
            case NA_NPC_GUARD_08:
            case NA_NPC_GUARD_09:
            case NA_NPC_GUARD_10:
            case NA_NPC_GUARD_11:
            case NA_NPC_GUARD_12:
            case NA_NPC_GUARD_13:
            case NA_NPC_GUARD_14:
            case NA_NPC_GUARD_15:
                {
                    Map* map = m_PvP->GetMap();
                    if(Creature * cr = map->GetCreature(itr->second))
                    {
                        if(cr->isAlive())
                            ++cnt;
                    }
                    else if (CreatureData const * cd = objmgr.GetCreatureData(GUID_LOPART(itr->second)))
                    {
                        if(!cd->is_dead)
                            ++cnt;
                    }
                }
                break;
            default:
                break;
        }
    }
    return cnt;
}
void BattleGround::SpawnBGCreature(ObjectGuid guid, uint32 respawntime)
{
    Map* map = GetBgMap();

    Creature* obj = map->GetCreature(guid);
    if (!obj)
        return;
    if (respawntime == 0)
    {
        obj->Respawn();
        map->Add(obj);
    }
    else
    {
        map->Add(obj);
        obj->SetRespawnDelay(respawntime);
        obj->SetDeathState(JUST_DIED);
        obj->RemoveCorpse();
    }
}
Exemple #13
0
bool OutdoorPvPObjective::DelCreature(uint32 type)
{
    if (!m_Creatures[type])
    {
        sLog.outDebug("OutdoorPvP creature type %u was already deleted",type);
        return false;
    }

    Map* map = m_PvP->GetMap();
    Creature *cr = map->GetCreature(m_Creatures[type]);
    if (!cr)
    {
        sLog.outError("OutdoorPvPObjective: Can't find creature guid: %u", GUID_LOPART(m_Creatures[type]));
        return false;
    }
    cr->AddObjectToRemoveList();
    m_CreatureTypes[m_Creatures[type]] = 0;
    m_Creatures[type] = 0;
    return true;
}
 void ResetEncounter()
 {
     if(bReset)
     {      
         if(me)
         {
             Map* instance = me->GetMap();
             if(instance && pInstance)
             {
                 Creature* npc = instance->GetCreature(pInstance->GetData64(DATA_ANNOUNCER));
                 GameObject* door = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1));
                 if (door)
                     pInstance->HandleGameObject(door->GetGUID(),true);
                 if(npc)
                     npc->RemoveFromWorld();       
                 me->SummonCreature(35004, 742.835f, 639.134f, 411.571f, 0, TEMPSUMMON_CORPSE_DESPAWN);
                 me->RemoveFromWorld();
             }
         }
     }
 }
Exemple #15
0
    void Reset()
    {
        Intro = true;
        Next = true;
        Wave = 0;
        IntroTimer = 45000;
        NextTimer = 51000;
        SandBreath_Timer = 25000;
        ImpendingDeath_Timer = 30000;
        WingBuffet_Timer = 35000;
        Mda_Timer = 40000;
        attackers.clear();
        me->SetReactState(REACT_PASSIVE);
        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

        Map* tmpMap = me->GetMap();

        if (!tmpMap)
            return;

        if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL)))
            ThrallGUID = Thrall->GetGUID();
    }
Exemple #16
0
    void UpdateAI(const uint32 diff)
    {
        if (Intro)
        {
            if (IntroTimer < diff)
            {
                if (attackers.empty())
                    NextWave();

                Map* tmpMap = me->GetMap();

                if (!tmpMap)
                    return;

                if (!attackers.empty())
                {
                    bool alive = false;
                    for (std::list<uint64>::iterator itr = attackers.begin(); itr != attackers.end(); ++itr)
                    {
                        if (Creature* attacker = tmpMap->GetCreature((*itr)))
                        {
                            if (attacker->isAlive())
                            {
                                alive = true;
                                break;
                            }
                        }
                    }
                    
                    if (!alive)
                    {
                        NextWave();
                        NextTimer = 5000;
                    }
                }

                if (Creature* Thrall = tmpMap->GetCreature(ThrallGUID))
                {
                    if (!Thrall->isAlive())
                        me->ForcedDespawn();
                }

                IntroTimer = 5000;
            }
            else
                IntroTimer -= diff;

            if (Next)
            {
                if (NextTimer <= diff) 
                {
                    NextWave();
                }
                else NextTimer -= diff;
            }
        }

        //Return since we have no target
        if (!UpdateVictim() )
            return;

        //Sand Breath
        if (SandBreath_Timer < diff)
        {
            if (me->IsNonMeleeSpellCast(false))
                me->InterruptNonMeleeSpells(false);

            DoCast(me->getVictim(),SPELL_SAND_BREATH);

            DoScriptText(RAND(SAY_BREATH1, SAY_BREATH2), me);

            SandBreath_Timer = 25000+rand()%5000;
        }
        else
            SandBreath_Timer -= diff;

        if(ImpendingDeath_Timer < diff)
        {
            if(Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0 , GetSpellMaxRange(SPELL_IMPENDING_DEATH), true))
                DoCast(target,SPELL_IMPENDING_DEATH);
            ImpendingDeath_Timer = 30000+rand()%5000;
        }
        else
            ImpendingDeath_Timer -= diff;

        if(WingBuffet_Timer < diff)
        {
            DoCast(me,SPELL_WING_BUFFET);
            WingBuffet_Timer = 25000+rand()%10000;
        }
        else
            WingBuffet_Timer -= diff;

        if(Mda_Timer < diff)
        {
            DoCast(me,SPELL_MAGIC_DISRUPTION_AURA);
            Mda_Timer = 15000;
        }
        else
            Mda_Timer -= diff;

        DoMeleeAttackIfReady();
    }
Exemple #17
0
void ExclusivePoolMgr::ExecuteEvent(ExclusivePool& pool)
{
    sLog.outBasic("ExclusivePool: Shuffling pool %u...", pool.poolID);

    // Get the spawn points and shuffle them.
    std::vector<ExclusivePoolSpot> poolSpotList;
    poolSpotList.insert(poolSpotList.begin(), m_poolSpots[pool.poolID].begin(), m_poolSpots[pool.poolID].end());
    std::random_shuffle(poolSpotList.begin(), poolSpotList.end());
    
    for (std::pair<const uint32, std::list<ObjectGuid> >& poolPair : pool.m_objects)
    {
        // If we have run out of spawn positions we stop spawning creatures.
        if (poolSpotList.empty())
            break;
        
        std::list<ObjectGuid> poolObjectList = poolPair.second;

        // Check if any creatures in the current group are alive.
        // If they are the group should be skipped.
        bool foundAlive = false;
        for (ObjectGuid currentCreature : poolObjectList)
        {
            const CreatureData* pData = sObjectMgr.GetCreatureData(currentCreature.GetCounter());
            if (pData)
            {
                Map* pMap = sMapMgr.FindMap(pData->mapid);
                if (pMap)
                {
                    if (!pMap->IsLoaded(pData->posX, pData->posY))
                    {
                        MaNGOS::ObjectUpdater updater(0);
                        // for creature
                        TypeContainerVisitor<MaNGOS::ObjectUpdater, GridTypeMapContainer  > grid_object_update(updater);
                        // for pets
                        TypeContainerVisitor<MaNGOS::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);
                        // Make sure that the creature is loaded before checking its status.
                        CellPair cellPair = MaNGOS::ComputeCellPair(pData->posX, pData->posY);
                        Cell cell(cellPair);
                        pMap->Visit(cell, grid_object_update);
                        pMap->Visit(cell, world_object_update);
                    }


                    Creature* pCreature = pMap->GetCreature(currentCreature);
                    if (pCreature)
                    {
                        // If the creature is alive or being looted we don't include it in the randomisation.
                        if (pCreature->isAlive() || pCreature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE))
                        {
                            sLog.outBasic("ExclusivePool: Skipping creature with guid %u.", currentCreature.GetCounter());
                            auto itr = std::find_if(poolSpotList.begin(), poolSpotList.end(),
                            [&](const ExclusivePoolSpot& spot)
                            {
                                if (spot.x == pData->posX && spot.y == pData->posY && 
                                    spot.z == pData->posZ && spot.mapID == pData->mapid)
                                {
                                    return true;
                                }
                                else
                                    return false;
                            });

                            // If we found the spot on which the living creature is standing
                            // we remove that spot since it's occupied.
                            if (itr != poolSpotList.end())
                            {
                                poolSpotList.erase(itr);
                                foundAlive = true;
                            }
                            else
                            {
                                sLog.outBasic("ExclusivePool: Could not find the pool position for creature %u. Moving it to avoid double spawns!", currentCreature.GetCounter());
                            }

                            DespawnAllExcept(poolObjectList, currentCreature);

                            break;
                        }
                    }
                }
            }
        }

        // If a creature in the current group was alive we skip it.
        if (foundAlive)
            continue;

        
        // Pick a random creature from the current group.
        auto itr = poolObjectList.begin();
        std::advance(itr, urand(0, poolObjectList.size() - 1));
        
        // Get a spawn point for the creature.
        ExclusivePoolSpot spot = poolSpotList.back();
        poolSpotList.pop_back();

        CreatureData& rData = sObjectMgr.mCreatureDataMap[itr->GetCounter()];
        
        // If the creature is already in the correct spot we skip it.
        if (rData.posX == spot.x && rData.posY == spot.y && 
            rData.posZ == spot.z && rData.mapid == spot.mapID)
        {
            continue;
        }
        
        // Do the actual spawning.
        sObjectMgr.RemoveCreatureFromGrid(itr->GetCounter(), &rData);
        Creature::AddToRemoveListInMaps(itr->GetCounter(), &rData);
        
        rData.posX = spot.x;
        rData.posY = spot.y;
        rData.posZ = spot.z;
        rData.orientation = spot.orientation;
        rData.mapid = spot.mapID;
        
        // Update the creature entry in the database.
        WorldDatabase.PQuery("UPDATE creature SET map=%u, position_x=%f, position_y=%f, position_z=%f, orientation=%f WHERE guid=%u",
                             spot.mapID, spot.x, spot.y, spot.z, spot.orientation, itr->GetCounter());

        // Make sure that all other creatures in the group are despawned.
        DespawnAllExcept(poolObjectList, *itr);
    }
    
    SaveRespawnTime(pool);

    sLog.outBasic("ExclusivePool: Finished shuffling pool %u.", pool.poolID);
}
    void UpdateAI(const uint32 diff)
    {
        Map* pmap;
        pmap= m_creature->GetMap();


        if (CDO = pmap->GetCreature(cdo_GUID))
        {
            // ok !
        }
        else
        {
            CDO = (m_creature->SummonCreature(10814, 32.0f, -291.0f, 111.0f, 3.21f,TEMPSUMMON_MANUAL_DESPAWN, 0));
            cdo_GUID = CDO->GetGUID();
	    CDO->SetRespawnDelay(30000000);
        }

        if (CDT = pmap->GetCreature(cdt_GUID))
        {
            // ok !
        }
        else
        {
            CDT = (m_creature->SummonCreature(10814, 32.0f, -279.0f, 111.0f, 3.21f, TEMPSUMMON_MANUAL_DESPAWN, 0));
            cdt_GUID = CDT->GetGUID();
	    CDO->SetRespawnDelay(30000000);
        }



        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
        {
            return;
        }

        if (donnerknall_timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),donnerknall);
            donnerknall_timer = random(20000,30000);
        } else donnerknall_timer -= diff;

        if (flammenstoss_timer < diff)
        {
            DoCastSpellIfCan(m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0),flammenstoss);
            flammenstoss_timer = random(13000,20000);
        } else flammenstoss_timer -= diff;

        if (grossbrand_timer < diff)
        {
            DoCastSpellIfCan(m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0),grossbrand);
            grossbrand_timer = random(20000,30000);
        } else grossbrand_timer -= diff;

        if (ruestung_durchstechen_timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),ruestung_durchstechen);
            ruestung_durchstechen_timer = random(25000,30000);
        } else ruestung_durchstechen_timer -= diff;

        if (spalten_timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),spalten);
            spalten_timer = random(6000,10000);
        } else spalten_timer -= diff;

        if (wut_timer < diff)
        {
            DoCastSpellIfCan(m_creature,wut);
            wut_timer = random(30000,35000);
        } else wut_timer -= diff;

        DoMeleeAttackIfReady();
    }
/*
Tribute Event
*/
void instance_dire_maul::GordokTributeEvent(uint32 diff)
{
	if(1<2)return;
	Creature* pChoRush = instance->GetCreature(m_uiChoRushGUID);
	Creature* pMizzle = instance->GetCreature(m_uiMizzleGUID);
	Creature* pTrigger = instance->GetCreature(m_uiTributeTriggerGUID);

	Map* pMap;
	pMap = pChoRush->GetMap();

	Map::PlayerList const &PlayerList = pMap->GetPlayers();

	if ((GetData(TYPE_KING_GORDOK) == DONE) && pMap->GetCreature(m_uiChoRushGUID)->isAlive() && !pChoRushHome)
	{
		pChoRush->SetFlag(UNIT_NPC_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PASSIVE);
		pChoRush->setFaction(35);
		pChoRush->DeleteThreatList();
		pChoRush->CombatStop();
		pChoRush->SetCanAttackPlayer(false);
		pChoRush->AI()->EnterEvadeMode();

		pChoRushHome = true;
		GossipStepGordok = 1;
		Text_Timer_Event = 1000;
	}
	else if ((TYPE_KING_GORDOK == DONE) && pMap->GetCreature(m_uiChoRushGUID)->isDead())
	{
		for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
		{
			Player* pPlayer = itr->getSource();
			if (pPlayer->IsWithinDistInMap(pTrigger, 30.0f))
					pTrigger->CastSpell(pPlayer, SPELL_KING_OF_GORDOK, false);
		}
	}

	if(pChoRushHome)
	{
		if (Text_Timer_Event<diff)
		{
			switch (GossipStepGordok)
			{
				case 1:
				DoScriptText(ChoRush_SAY_1, pChoRush);
				pChoRush->HandleEmote(EMOTE_STATE_TALK);
				pChoRush->SummonCreature(NPC_MIZZLE_THE_CRAFTY, 817.666f, 478.371f, 37.3182f, 3.07057f, TEMPSUMMON_TIMED_DESPAWN, 9000000);
				Text_Timer_Event = 5000;
				break;

				case 2:
				pChoRush->HandleEmote(EMOTE_STATE_SIT);
				DoScriptText(Mizzle_SAY_1, pMizzle);
				pMizzle->HandleEmote(EMOTE_STATE_TALK);
				Text_Timer_Event = 5000;
				break;

				case 3:
				DoScriptText(Mizzle_SAY_2, pMizzle);
				pMizzle->HandleEmote(EMOTE_STATE_TALK);
				Text_Timer_Event = 8000;
				break;

				case 4:
				for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
				{
					Player* pPlayer = itr->getSource();
					if (pPlayer->IsWithinDistInMap(pMizzle, 50.0f))
							pMizzle->CastSpell(pPlayer, SPELL_KING_OF_GORDOK, false);
				}
				if (pMap->GetCreature(m_uiMoldarGUID)->isAlive() && pMap->GetCreature(m_uiMizzleGUID)->isAlive() && pMap->GetCreature(m_uiFengusGUID)->isAlive())
				{
					pMizzle->SummonObject(pMap, GO_GORDOK_TRIBUTE, 809.899719f, 482.306366f, 37.318359f, 0.212846f);
					pMizzle->HandleEmote(EMOTE_ONESHOT_APPLAUD);
				}
				pChoRushHome = false;
				break;
			}
		}
		else Text_Timer_Event -= diff;
	}
}
Exemple #20
0
    static bool HandleWpModifyCommand(ChatHandler* handler, const char* args)
    {
        if (!*args)
            return false;

        // first arg: add del text emote spell waittime move
        char* show_str = strtok((char*)args, " ");
        if (!show_str)
        {
            return false;
        }

        std::string show = show_str;
        // Check
        // Remember: "show" must also be the name of a column!
        if ((show != "delay") && (show != "action") && (show != "action_chance")
            && (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd")
            )
        {
            return false;
        }

        // Next arg is: <PATHID> <WPNUM> <ARGUMENT>
        char* arg_str = NULL;

        // Did user provide a GUID
        // or did the user select a creature?
        // -> variable lowguid is filled with the GUID of the NPC
        uint32 pathid = 0;
        uint32 point = 0;
        uint32 wpGuid = 0;
        Creature* target = handler->getSelectedCreature();

        if (!target || target->GetEntry() != VISUAL_WAYPOINT)
        {
            handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r");
            return false;
        }

        // The visual waypoint
        wpGuid = target->GetGUIDLow();

        // User did select a visual waypoint?

        // Check the creature
        PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID);
        stmt->setUInt32(0, wpGuid);
        PreparedQueryResult result = WorldDatabase.Query(stmt);

        if (!result)
        {
            handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
            // Select waypoint number from database
            // Since we compare float values, we have to deal with
            // some difficulties.
            // Here we search for all waypoints that only differ in one from 1 thousand
            // (0.001) - There is no other way to compare C++ floats with mySQL floats
            // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
            std::string maxDiff = "0.01";

            PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_POS);
            stmt->setFloat(0, target->GetPositionX());
            stmt->setString(1, maxDiff);
            stmt->setFloat(2, target->GetPositionY());
            stmt->setString(3, maxDiff);
            stmt->setFloat(4, target->GetPositionZ());
            stmt->setString(5, maxDiff);
            PreparedQueryResult result = WorldDatabase.Query(stmt);

            if (!result)
            {
                handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
                return true;
            }
        }

        do
        {
            Field* fields = result->Fetch();
            pathid = fields[0].GetUInt32();
            point  = fields[1].GetUInt32();
        }
        while (result->NextRow());

        // We have the waypoint number and the GUID of the "master npc"
        // Text is enclosed in "<>", all other arguments not
        arg_str = strtok((char*)NULL, " ");

        // Check for argument
        if (show != "del" && show != "move" && arg_str == NULL)
        {
            handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str);
            return false;
        }

        if (show == "del")
        {
            handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);

            // wpCreature
            Creature* wpCreature = NULL;

            if (wpGuid != 0)
            {
                wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
                if (wpCreature)
                {
                    wpCreature->CombatStop();
                    wpCreature->DeleteFromDB();
                    wpCreature->AddObjectToRemoveList();
                }
            }

            PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);

            stmt->setUInt32(0, pathid);
            stmt->setUInt32(1, point);

            WorldDatabase.Execute(stmt);

            stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POINT);

            stmt->setUInt32(0, pathid);
            stmt->setUInt32(1, point);

            WorldDatabase.Execute(stmt);

            handler->PSendSysMessage(LANG_WAYPOINT_REMOVED);
            return true;
        }                                                       // del

        if (show == "move")
        {
            handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid);

            Player* chr = handler->GetSession()->GetPlayer();
            Map* map = chr->GetMap();
            {
                // wpCreature
                Creature* wpCreature = NULL;
                // What to do:
                // Move the visual spawnpoint
                // Respawn the owner of the waypoints
                if (wpGuid != 0)
                {
                    wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
                    if (wpCreature)
                    {
                        wpCreature->CombatStop();
                        wpCreature->DeleteFromDB();
                        wpCreature->AddObjectToRemoveList();
                    }
                    // re-create
                    Creature* wpCreature2 = new Creature;
                    if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
                    {
                        handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
                        delete wpCreature2;
                        wpCreature2 = NULL;
                        return false;
                    }

                    wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
                    // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
                    //TODO: Should we first use "Create" then use "LoadFromDB"?
                    if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetDBTableGUIDLow(), map))
                    {
                        handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
                        delete wpCreature2;
                        wpCreature2 = NULL;
                        return false;
                    }
                    //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
                }

                PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION);

                stmt->setFloat(0, chr->GetPositionX());
                stmt->setFloat(1, chr->GetPositionY());
                stmt->setFloat(2, chr->GetPositionZ());
                stmt->setUInt32(3, pathid);
                stmt->setUInt32(4, point);

                WorldDatabase.Execute(stmt);

                handler->PSendSysMessage(LANG_WAYPOINT_CHANGED);
            }
            return true;
        }                                                       // move

        const char *text = arg_str;

        if (text == 0)
        {
            // show_str check for present in list of correct values, no sql injection possible
            WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", show_str, pathid, point); // Query can't be a prepared statement
        }
        else
        {
            // show_str check for present in list of correct values, no sql injection possible
            std::string text2 = text;
            WorldDatabase.EscapeString(text2);
            WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", show_str, text2.c_str(), pathid, point); // Query can't be a prepared statement
        }

        handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str);
        return true;
    }
Exemple #21
0
void WorldSession::SendPetNameQuery( ObjectGuid petguid, uint32 petnumber)
{
    //Client asks for data before add to map (or we have wrong teleport sequence), so we cant use GetCreatureOrPetOrVehicle()
    Creature* pet = NULL;
    
    if(_player->IsBeingTeleported())
    {
        Map *map = sMapMgr.FindMap(_player->GetTeleportDest().mapid);
        if(map)
        {
            if (petguid.IsPet())
                pet = map->GetPet(petguid);
            else if(petguid.IsVehicle())
                pet = (Creature*)map->GetVehicle(petguid);
            else
                pet = map->GetCreature(petguid);
        }
    }
    else
        pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);

    if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
    {
        std::string name = "NoPetName";

        WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
        data << uint32(petnumber);
        data << name.c_str();
        data << uint32(time(0));
        data << uint8(0);

        _player->GetSession()->SendPacket(&data);

        // looking for errors
     /*   if (!pet)
            sLog.outError("SendPetNameQuery:: Pet not found, not exist or not in world"); <-------
        else if (!pet->GetCharmInfo())
            sLog.outError("SendPetNameQuery:: Pet CharmInfo() not found");
        else if (pet->GetCharmInfo()->GetPetNumber() != petnumber)
            sLog.outError("SendPetNameQuery:: Pet number is not equal to requested petnumber"); */
        return;
    }

    std::string name = pet->GetName();

    WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
    data << uint32(petnumber);
    data << name.c_str();
    data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));

    if ( pet->isPet() && ((Pet*)pet)->GetDeclinedNames() )
    {
        data << uint8(1);
        for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
            data << ((Pet*)pet)->GetDeclinedNames()->name[i];
    }
    else
        data << uint8(0);

    _player->GetSession()->SendPacket(&data);
}