Changeset 257 for trunk/src/bindings
- Timestamp:
- 11/19/08 13:51:33 (17 years ago)
- Location:
- trunk/src/bindings/scripts
- Files:
-
- 14 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bindings/scripts/include/sc_creature.cpp
r229 r257 680 680 } 681 681 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); 689 687 } 690 688 … … 721 719 ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); 722 720 } 721 722 void 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 723 735 724 736 Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) -
trunk/src/bindings/scripts/include/sc_creature.h
r203 r257 147 147 //Teleports a player without dropping threat (only teleports to same map) 148 148 void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o); 149 void DoTeleportAll(float x, float y, float z, float o); 149 150 150 151 //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 221 221 if ( DrawnShadows_Timer < diff) 222 222 { 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); 235 224 m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 236 225 DoCast(m_creature,SPELL_DRAWN_SHADOWS,true); -
trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp
r229 r257 251 251 //remove old tainted cores to prevent cheating in phase 2 252 252 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()) 257 257 { 258 (*i)->DestroyItemCount(31088, 1, true);258 i_pl->DestroyItemCount(31088, 1, true); 259 259 } 260 260 } -
trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp
r229 r257 755 755 { 756 756 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) 759 759 { 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 } 770 773 } 771 774 Earthshock_Timer = 8000 + rand()%7000; -
trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp
r141 r257 119 119 void SetData(uint32 type, uint32 data) 120 120 { 121 Player *player = GetPlayer();122 if(!player) return;123 124 121 switch(type) 125 122 { … … 130 127 if(data != IN_PROGRESS) 131 128 { 132 if(GameObject *Door = GameObject::GetGameObject(*player,DoorGUID))129 if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 133 130 Door->SetGoState(0); 134 131 } … … 143 140 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 144 141 { 145 if(Creature *Channeler = (Creature*)Unit::GetUnit(*player,*i))142 if(Creature *Channeler = instance->GetCreatureInMap(*i)) 146 143 { 147 144 if(Channeler->isAlive()) … … 152 149 } 153 150 CageTimer = 0; 154 if(GameObject *Door = GameObject::GetGameObject(*player,DoorGUID))151 if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 155 152 Door->SetGoState(0); 156 153 }break; … … 162 159 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 163 160 { 164 Creature *Channeler = (Creature*)Unit::GetUnit(*player,*i);161 Creature *Channeler = instance->GetCreatureInMap(*i); 165 162 if(Channeler && Channeler->isAlive()) 166 163 { … … 171 168 } 172 169 // Release Magtheridon after two minutes. 173 Creature *Magtheridon = (Creature*)Unit::GetUnit(*player,MagtheridonGUID);170 Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); 174 171 if(Magtheridon && Magtheridon->isAlive()) 175 172 { … … 177 174 CageTimer = 120000; 178 175 } 179 if(GameObject *Door = GameObject::GetGameObject(*player,DoorGUID))176 if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 180 177 Door->SetGoState(1); 181 178 }break; … … 183 180 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 184 181 { 185 Unit *Channeler = Unit::GetUnit(*player,*i);182 Creature *Channeler = instance->GetCreatureInMap(*i); 186 183 if(Channeler && Channeler->isAlive()) 187 184 { … … 198 195 for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i) 199 196 { 200 if(GameObject *Column = GameObject::GetGameObject(*player,*i))197 if(GameObject *Column = instance->GetGameObjectInMap(*i)) 201 198 Column->SetGoState(!data); 202 199 } … … 214 211 } 215 212 216 Player* GetPlayer()217 {218 if(((InstanceMap*)instance)->GetPlayers().size())219 return ((InstanceMap*)instance)->GetPlayers().front();220 return NULL;221 }222 223 213 void AttackNearestTarget(Creature *creature) 224 214 { … … 226 216 float range; 227 217 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; 230 220 for(i = PlayerList.begin(); i != PlayerList.end(); ++i) 231 221 { 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 } 240 233 } 241 234 } … … 249 242 if(CageTimer <= diff) 250 243 { 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); 259 249 } 260 250 CageTimer = 0; … … 266 256 if(RespawnTimer <= diff) 267 257 { 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(); 279 266 } 280 267 } -
trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp
r90 r257 286 286 if(!map->IsDungeon()) return; 287 287 288 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();289 if(PlayerList. empty())288 Map::PlayerList const &PlayerList = map->GetPlayers(); 289 if(PlayerList.isEmpty()) 290 290 return; 291 291 292 292 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) 294 294 { 295 if ((*i)->isAlive() && !(*i)->isGameMaster())295 if (i->getSource()->isAlive() && !i->getSource()->isGameMaster()) 296 296 { 297 297 RaidWiped = false; -
trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp
r137 r257 232 232 m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0); 233 233 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; 236 236 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 237 237 { 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 } 245 245 } 246 246 DoCast(m_creature, SPELL_TELEPORT_CENTER, true); … … 250 250 { 251 251 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; 254 254 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()) 257 258 // 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()); 259 260 } 260 261 } … … 263 264 { 264 265 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; 267 293 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 268 294 { 269 if((*i) && (*i)->isAlive())295 if(Player* i_pl = i->getSource()) 270 296 { 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); 295 299 WorldPacket data(12); 296 300 data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); 297 data.append( (*i)->GetPackGUID());301 data.append(i_pl->GetPackGUID()); 298 302 data << uint32(0); 299 (*i)->SendMessageToSet(&data, true);303 i_pl->SendMessageToSet(&data, true); 300 304 } 301 305 } -
trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp
r122 r257 296 296 break; 297 297 case 2: 298 if( Player* target = SelectRandomPlayer(150))298 if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 299 299 { 300 300 Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000); … … 312 312 DespawnSummons(MOB_VAPOR_TRAIL); 313 313 //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)) 315 315 { 316 316 //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support … … 331 331 break; 332 332 case 5: 333 if( Player* target = SelectRandomPlayer(150))333 if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 334 334 { 335 335 BreathX = target->GetPositionX(); … … 434 434 break; 435 435 case EVENT_ENCAPSULATE: 436 if(Unit* target = Select RandomPlayer(150))436 if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 437 437 { 438 438 m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false); … … 516 516 } 517 517 } 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 else534 PlayerList.erase(i);535 }536 return NULL;537 }538 518 }; 539 519 -
trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp
r239 r257 369 369 Map *map = m_creature->GetMap(); 370 370 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); 378 377 } 379 378 -
trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp
r206 r257 578 578 if(!map->IsDungeon()) return; 579 579 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()) 585 584 { 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 } 594 597 } 595 598 } -
trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp
r202 r257 372 372 if(SiphonSoul_Timer < diff) 373 373 { 374 Player* target = SelectRandomPlayer(50);374 Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true); 375 375 Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); 376 376 if(!target || !trigger) EnterEvadeMode(); … … 436 436 m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false); 437 437 } 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 else454 PlayerList.erase(i);455 }456 return NULL;457 }458 438 }; 459 439 -
trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp
r90 r257 398 398 Map *map = m_creature->GetMap(); 399 399 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); 405 406 } 406 407 //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 140 140 void OpenDoor(uint64 DoorGUID, bool open) 141 141 { 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); 146 144 } 147 145 148 146 void SummonHostage(uint8 num) 149 147 { 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 } 157 164 } 158 165