Show
Ignore:
Timestamp:
11/19/08 13:51:33 (17 years ago)
Author:
yumileroy
Message:

*Merge from Mangos. Add MapReference?. Author: hunuza.
*Also re-commit the patches reverted in 255.

Original author: megamage
Date: 2008-11-18 19:40:06-06:00

Location:
trunk/src/bindings/scripts
Files:
14 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/bindings/scripts/include/sc_creature.cpp

    r229 r257  
    680680    } 
    681681 
    682     InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    683     InstanceMap::PlayerList::const_iterator i; 
    684     for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    685     { 
    686         if((*i)->isAlive()) 
    687             pUnit->AddThreat(*i, 0.0f); 
    688     } 
     682    Map::PlayerList const &PlayerList = map->GetPlayers(); 
     683    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     684        if (Player* i_pl = i->getSource()) 
     685            if (!i_pl->isAlive()) 
     686                pUnit->AddThreat(i_pl, 0.0f); 
    689687} 
    690688 
     
    721719    ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); 
    722720} 
     721 
     722void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) 
     723{ 
     724    Map *map = m_creature->GetMap(); 
     725    if (!map->IsDungeon()) 
     726        return; 
     727 
     728    Map::PlayerList const &PlayerList = map->GetPlayers(); 
     729    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     730        if (Player* i_pl = i->getSource()) 
     731            if (!i_pl->isAlive()) 
     732                i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); 
     733} 
     734 
    723735 
    724736Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) 
  • trunk/src/bindings/scripts/include/sc_creature.h

    r203 r257  
    147147    //Teleports a player without dropping threat (only teleports to same map) 
    148148    void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o); 
     149    void DoTeleportAll(float x, float y, float z, float o); 
    149150 
    150151    //Returns friendly unit with the most amount of hp missing from max hp 
  • trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp

    r229 r257  
    221221        if ( DrawnShadows_Timer < diff) 
    222222        { 
    223             Map *map = m_creature->GetMap(); 
    224             if(map->IsDungeon()) 
    225             { 
    226                 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    227                 for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    228                 { 
    229                     if((*i)->isAlive()) 
    230                     { 
    231                         (*i)->TeleportTo(555,VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 
    232                     } 
    233                 } 
    234             } 
     223            DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 
    235224            m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 
    236225            DoCast(m_creature,SPELL_DRAWN_SHADOWS,true); 
  • trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp

    r229 r257  
    251251                        //remove old tainted cores to prevent cheating in phase 2 
    252252                        Map *map = m_creature->GetMap(); 
    253                         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    254                         for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
    255             { 
    256                 if((*i)) 
     253                        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     254                        for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
     255            { 
     256                if(Player* i_pl = i->getSource()) 
    257257                { 
    258                     (*i)->DestroyItemCount(31088, 1, true); 
     258                    i_pl->DestroyItemCount(31088, 1, true); 
    259259                } 
    260260            } 
  • trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp

    r229 r257  
    755755                { 
    756756                        Map *map = m_creature->GetMap(); 
    757                         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    758                         for(InstanceMap::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr) 
     757                        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     758                        for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr) 
    759759            { 
    760                                 bool isCasting = false; 
    761                                 for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) 
    762                                         if((*itr)->m_currentSpells[i]) 
    763                                                 isCasting = true; 
    764                                  
    765                                 if(isCasting) 
    766                                 { 
    767                                         DoCast((*itr), SPELL_EARTHSHOCK); 
    768                                         break; 
    769                                 } 
     760                if (Player* i_pl = itr->getSource()) 
     761                { 
     762                                    bool isCasting = false; 
     763                                    for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) 
     764                                            if(i_pl->m_currentSpells[i]) 
     765                                                    isCasting = true; 
     766                                 
     767                                    if(isCasting) 
     768                                    { 
     769                                            DoCast(i_pl, SPELL_EARTHSHOCK); 
     770                                            break; 
     771                                    } 
     772                } 
    770773                        } 
    771774                        Earthshock_Timer = 8000 + rand()%7000; 
  • trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp

    r141 r257  
    119119    void SetData(uint32 type, uint32 data) 
    120120    { 
    121         Player *player = GetPlayer(); 
    122         if(!player) return; 
    123  
    124121        switch(type) 
    125122        { 
     
    130127            if(data != IN_PROGRESS) 
    131128            { 
    132                 if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) 
     129                if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
    133130                    Door->SetGoState(0); 
    134131            } 
     
    143140                    for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    144141                    { 
    145                         if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i)) 
     142                        if(Creature *Channeler = instance->GetCreatureInMap(*i)) 
    146143                        { 
    147144                            if(Channeler->isAlive()) 
     
    152149                    } 
    153150                    CageTimer = 0; 
    154                     if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) 
     151                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
    155152                        Door->SetGoState(0); 
    156153                }break; 
     
    162159                    for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    163160                    { 
    164                         Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i); 
     161                        Creature *Channeler = instance->GetCreatureInMap(*i); 
    165162                        if(Channeler && Channeler->isAlive()) 
    166163                        { 
     
    171168                    } 
    172169                    // Release Magtheridon after two minutes. 
    173                     Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID); 
     170                    Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); 
    174171                    if(Magtheridon && Magtheridon->isAlive()) 
    175172                    { 
     
    177174                        CageTimer = 120000; 
    178175                    } 
    179                     if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) 
     176                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
    180177                        Door->SetGoState(1); 
    181178                }break; 
     
    183180                for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    184181                { 
    185                     Unit *Channeler = Unit::GetUnit(*player, *i); 
     182                    Creature *Channeler = instance->GetCreatureInMap(*i); 
    186183                    if(Channeler && Channeler->isAlive()) 
    187184                    { 
     
    198195            for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i) 
    199196            { 
    200                 if(GameObject *Column = GameObject::GetGameObject(*player, *i)) 
     197                if(GameObject *Column = instance->GetGameObjectInMap(*i)) 
    201198                    Column->SetGoState(!data); 
    202199            } 
     
    214211    } 
    215212 
    216     Player* GetPlayer() 
    217     { 
    218         if(((InstanceMap*)instance)->GetPlayers().size()) 
    219             return ((InstanceMap*)instance)->GetPlayers().front(); 
    220         return NULL; 
    221     } 
    222  
    223213    void AttackNearestTarget(Creature *creature) 
    224214    { 
     
    226216        float range; 
    227217        Player* target = NULL; 
    228         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)instance)->GetPlayers(); 
    229         InstanceMap::PlayerList::const_iterator i; 
     218        Map::PlayerList const &PlayerList = instance->GetPlayers(); 
     219        Map::PlayerList::const_iterator i; 
    230220        for(i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    231221        { 
    232             if((*i)->isTargetableForAttack()) 
    233             { 
    234                 range = (*i)->GetDistance(creature); 
    235                 if(range < minRange) 
    236                 { 
    237                     minRange = range; 
    238                     target = *i; 
    239                 }                 
     222            if(Player* i_pl = i->getSource()) 
     223            { 
     224                if(i_pl->isTargetableForAttack()) 
     225                { 
     226                    range = i_pl->GetDistance(creature); 
     227                    if(range < minRange) 
     228                    { 
     229                        minRange = range; 
     230                        target = i_pl; 
     231                    }                 
     232                } 
    240233            } 
    241234        } 
     
    249242            if(CageTimer <= diff) 
    250243            { 
    251                 if(Player *player = GetPlayer()) 
    252                 { 
    253                     Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID); 
    254                     if(Magtheridon && Magtheridon->isAlive()) 
    255                     { 
    256                         Magtheridon->clearUnitState(UNIT_STAT_STUNNED); 
    257                         AttackNearestTarget(Magtheridon); 
    258                     } 
     244                Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); 
     245                if(Magtheridon && Magtheridon->isAlive()) 
     246                { 
     247                    Magtheridon->clearUnitState(UNIT_STAT_STUNNED); 
     248                    AttackNearestTarget(Magtheridon); 
    259249                } 
    260250                CageTimer = 0; 
     
    266256            if(RespawnTimer <= diff) 
    267257            { 
    268                 if(Player *player = GetPlayer()) 
    269                 { 
    270                     for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    271                     { 
    272                         if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i)) 
    273                         { 
    274                             if(Channeler->isAlive()) 
    275                                 Channeler->AI()->EnterEvadeMode(); 
    276                             else 
    277                                 Channeler->Respawn(); 
    278                         } 
     258                for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
     259                { 
     260                    if(Creature *Channeler = instance->GetCreatureInMap(*i)) 
     261                    { 
     262                        if(Channeler->isAlive()) 
     263                            Channeler->AI()->EnterEvadeMode(); 
     264                        else 
     265                            Channeler->Respawn(); 
    279266                    } 
    280267                } 
  • trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp

    r90 r257  
    286286                    if(!map->IsDungeon()) return; 
    287287 
    288                     InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    289                     if(PlayerList.empty()) 
     288                    Map::PlayerList const &PlayerList = map->GetPlayers(); 
     289                    if(PlayerList.isEmpty()) 
    290290                        return; 
    291291 
    292292                    RaidWiped = true; 
    293                     for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
     293                    for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
    294294                    { 
    295                         if((*i)->isAlive() && !(*i)->isGameMaster()) 
     295                        if (i->getSource()->isAlive() && !i->getSource()->isGameMaster()) 
    296296                        { 
    297297                            RaidWiped = false; 
  • trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp

    r137 r257  
    232232        m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0); 
    233233                Map *map = m_creature->GetMap(); 
    234         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    235                 InstanceMap::PlayerList::const_iterator i; 
     234        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     235                Map::PlayerList::const_iterator i; 
    236236                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    237237                { 
    238                         //if(!(*i)->isGameMaster()) 
    239                         if((*i) && (*i)->isAlive()) 
    240                         { 
    241                                 (*i)->CastSpell((*i), SPELL_TELEPORT_CENTER, true); 
    242                                 m_creature->GetNearPoint(m_creature,x,y,z,5,5,0); 
    243                                 (*i)->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,(*i)->GetOrientation()); 
    244                         } 
     238                        if (Player* i_pl = i->getSource()) 
     239                            if(i_pl->isAlive()) 
     240                            { 
     241                                    i_pl->CastSpell(i_pl, SPELL_TELEPORT_CENTER, true); 
     242                                    m_creature->GetNearPoint(m_creature,x,y,z,5,5,0); 
     243                                    i_pl->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,i_pl->GetOrientation()); 
     244                            } 
    245245        } 
    246246        DoCast(m_creature, SPELL_TELEPORT_CENTER, true); 
     
    250250    { 
    251251                Map *map = m_creature->GetMap(); 
    252         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    253                 InstanceMap::PlayerList::const_iterator i; 
     252        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     253                Map::PlayerList::const_iterator i; 
    254254                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    255                 {             
    256                         if((*i) && (*i)->isAlive()) 
     255                { 
     256            if (Player* i_pl = i->getSource()) 
     257                            if(i_pl->isAlive()) 
    257258                // Knockback into the air 
    258                 (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); 
     259                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); 
    259260        } 
    260261    } 
     
    263264    { 
    264265                Map *map = m_creature->GetMap(); 
    265                 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    266                 InstanceMap::PlayerList::const_iterator i; 
     266                Map::PlayerList const &PlayerList = map->GetPlayers(); 
     267                Map::PlayerList::const_iterator i; 
     268                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     269                { 
     270            if (Player* i_pl = i->getSource()) 
     271            { 
     272                            if(i_pl->isAlive()) 
     273                { 
     274                    // Also needs an exception in spell system. 
     275                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); 
     276                    // Use packet hack 
     277                    WorldPacket data(12); 
     278                    data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); 
     279                    data.append(i_pl->GetPackGUID()); 
     280                    data << uint32(0); 
     281                    i_pl->SendMessageToSet(&data, true); 
     282                                    i_pl->SetSpeed(MOVE_FLY, 2.0f); 
     283                } 
     284            } 
     285        } 
     286    } 
     287 
     288    void RemoveGravityLapse() 
     289    { 
     290                Map *map = m_creature->GetMap(); 
     291        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     292                Map::PlayerList::const_iterator i; 
    267293                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    268294                {  
    269                         if((*i) && (*i)->isAlive()) 
     295            if(Player* i_pl = i->getSource()) 
    270296            { 
    271                 // Also needs an exception in spell system. 
    272                 (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); 
    273                 // Use packet hack 
    274                 WorldPacket data(12); 
    275                 data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); 
    276                 data.append((*i)->GetPackGUID()); 
    277                 data << uint32(0); 
    278                 (*i)->SendMessageToSet(&data, true); 
    279                                 (*i)->SetSpeed(MOVE_FLY, 2.0f); 
    280             } 
    281         } 
    282     } 
    283  
    284     void RemoveGravityLapse() 
    285     { 
    286                 Map *map = m_creature->GetMap(); 
    287         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    288                 InstanceMap::PlayerList::const_iterator i; 
    289                 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    290                 {  
    291             if((*i)) 
    292             { 
    293                 (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); 
    294                 (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); 
     297                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); 
     298                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); 
    295299                WorldPacket data(12); 
    296300                data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); 
    297                 data.append((*i)->GetPackGUID()); 
     301                data.append(i_pl->GetPackGUID()); 
    298302                data << uint32(0); 
    299                 (*i)->SendMessageToSet(&data, true); 
     303                i_pl->SendMessageToSet(&data, true); 
    300304            } 
    301305        } 
  • trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp

    r122 r257  
    296296            break; 
    297297        case 2: 
    298             if(Player* target = SelectRandomPlayer(150)) 
     298            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    299299            { 
    300300                Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000); 
     
    312312            DespawnSummons(MOB_VAPOR_TRAIL); 
    313313            //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support 
    314             if(Player* target = SelectRandomPlayer(150)) 
     314            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    315315            { 
    316316                //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support 
     
    331331            break; 
    332332        case 5: 
    333             if(Player* target = SelectRandomPlayer(150)) 
     333            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    334334            { 
    335335                BreathX = target->GetPositionX(); 
     
    434434                break; 
    435435            case EVENT_ENCAPSULATE: 
    436                 if(Unit* target = SelectRandomPlayer(150)) 
     436                if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    437437                { 
    438438                    m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false); 
     
    516516        } 
    517517    } 
    518  
    519     Player* SelectRandomPlayer(float range = 0.0f) 
    520     { 
    521         Map *map = m_creature->GetMap(); 
    522         if (!map->IsDungeon()) return NULL; 
    523  
    524         InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    525         InstanceMap::PlayerList::iterator i; 
    526         while(PlayerList.size()) 
    527         { 
    528             i = PlayerList.begin(); 
    529             advance(i, rand()%PlayerList.size()); 
    530             if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range)) 
    531                 && (*i)->isTargetableForAttack()) 
    532                 return *i; 
    533             else 
    534                 PlayerList.erase(i); 
    535         } 
    536         return NULL; 
    537     } 
    538518}; 
    539519 
  • trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp

    r239 r257  
    369369        Map *map = m_creature->GetMap(); 
    370370        if(!map->IsDungeon()) return; 
    371         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    372         InstanceMap::PlayerList::const_iterator i; 
    373         for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    374         { 
    375             if((*i)->HasAura(AURA_SPECTRAL_REALM,0)) 
    376                 (*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); 
    377         } 
     371        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     372        Map::PlayerList::const_iterator i; 
     373        for(i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     374            if(Player* i_pl = i->getSource()) 
     375                if(i_pl->HasAura(AURA_SPECTRAL_REALM,0)) 
     376                    i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); 
    378377    } 
    379378 
  • trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp

    r206 r257  
    578578                if(!map->IsDungeon()) return; 
    579579 
    580                 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    581                 for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    582                 { 
    583                     //Play random sound to the zone 
    584                     switch (rand()%8) 
     580                Map::PlayerList const &PlayerList = map->GetPlayers(); 
     581                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     582                { 
     583                    if (Player* i_pl = i->getSource()) 
    585584                    { 
    586                         case 0: (*i)->SendPlaySound(RND_WISPER_1, true); break; 
    587                         case 1: (*i)->SendPlaySound(RND_WISPER_2, true); break; 
    588                         case 2: (*i)->SendPlaySound(RND_WISPER_3, true); break; 
    589                         case 3: (*i)->SendPlaySound(RND_WISPER_4, true); break; 
    590                         case 4: (*i)->SendPlaySound(RND_WISPER_5, true); break; 
    591                         case 5: (*i)->SendPlaySound(RND_WISPER_6, true); break; 
    592                         case 6: (*i)->SendPlaySound(RND_WISPER_7, true); break; 
    593                         case 7: (*i)->SendPlaySound(RND_WISPER_8, true); break; 
     585                        //Play random sound to the zone 
     586                        switch (rand()%8) 
     587                        { 
     588                            case 0: i_pl->SendPlaySound(RND_WISPER_1, true); break; 
     589                            case 1: i_pl->SendPlaySound(RND_WISPER_2, true); break; 
     590                            case 2: i_pl->SendPlaySound(RND_WISPER_3, true); break; 
     591                            case 3: i_pl->SendPlaySound(RND_WISPER_4, true); break; 
     592                            case 4: i_pl->SendPlaySound(RND_WISPER_5, true); break; 
     593                            case 5: i_pl->SendPlaySound(RND_WISPER_6, true); break; 
     594                            case 6: i_pl->SendPlaySound(RND_WISPER_7, true); break; 
     595                            case 7: i_pl->SendPlaySound(RND_WISPER_8, true); break; 
     596                        } 
    594597                    } 
    595598                } 
  • trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp

    r202 r257  
    372372        if(SiphonSoul_Timer < diff) 
    373373        { 
    374             Player* target = SelectRandomPlayer(50); 
     374            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true); 
    375375            Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); 
    376376            if(!target || !trigger) EnterEvadeMode(); 
     
    436436        m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false); 
    437437    } 
    438  
    439     Player* SelectRandomPlayer(float range = 0.0f, bool alive = true) 
    440     { 
    441         Map *map = m_creature->GetMap(); 
    442         if (!map->IsDungeon()) return NULL; 
    443  
    444         InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    445         InstanceMap::PlayerList::iterator i; 
    446         while(PlayerList.size()) 
    447         { 
    448             i = PlayerList.begin(); 
    449             advance(i, rand()%PlayerList.size()); 
    450             if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range)) 
    451                 && (!alive || (*i)->isAlive())) 
    452                 return *i; 
    453             else 
    454                 PlayerList.erase(i); 
    455         } 
    456         return NULL; 
    457     } 
    458438}; 
    459439 
  • trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp

    r90 r257  
    398398            Map *map = m_creature->GetMap(); 
    399399            if(!map->IsDungeon()) return; 
    400             InstanceMap::PlayerList const &PlayerList =((InstanceMap*)map)->GetPlayers(); 
    401             for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    402             { 
    403                 if((*i)->isAlive()) 
    404                     DoTeleportPlayer(*i, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); 
     400            Map::PlayerList const &PlayerList = map->GetPlayers(); 
     401            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     402            { 
     403                if (Player* i_pl = i->getSource()) 
     404                    if(i_pl->isAlive()) 
     405                        DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); 
    405406            } 
    406407            //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far 
  • trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp

    r90 r257  
    140140    void OpenDoor(uint64 DoorGUID, bool open) 
    141141    { 
    142         if(((InstanceMap*)instance)->GetPlayers().size()) 
    143             if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) 
    144                 if(GameObject *Door = GameObject::GetGameObject(*first, DoorGUID)) 
    145                     Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); 
     142        if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
     143            Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); 
    146144    } 
    147145 
    148146    void SummonHostage(uint8 num) 
    149147    { 
    150         if(QuestMinute && ((InstanceMap*)instance)->GetPlayers().size()) 
    151             if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) 
    152                 if(Unit* Hostage = first->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) 
    153                 { 
    154                     Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 
    155                     Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); 
    156                 } 
     148        if(!QuestMinute) 
     149            return; 
     150 
     151        Map::PlayerList const &PlayerList = instance->GetPlayers(); 
     152        if (PlayerList.isEmpty()) 
     153            return; 
     154 
     155        Map::PlayerList::const_iterator i = PlayerList.begin(); 
     156        if(Player* i_pl = i->getSource()) 
     157        { 
     158            if(Unit* Hostage = i_pl->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) 
     159            { 
     160                Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 
     161                Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); 
     162            } 
     163        } 
    157164    } 
    158165