void HandleStormSequence(Unit *Cloud) // 1: begin, 2-9: tick, 10: end { if(StormCount < 10 && StormCount > 1) { // deal damage int32 bp0 = 800; for(uint8 i = 2; i < StormCount; ++i) bp0 *= 2; CellPair p(Ribon::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); std::list<Unit *> tempUnitMap; { Ribon::AnyAoETargetUnitInObjectRangeCheck u_check(m_creature, m_creature, 999); Ribon::UnitListSearcher<Ribon::AnyAoETargetUnitInObjectRangeCheck> searcher(m_creature, tempUnitMap, u_check); TypeContainerVisitor<Ribon::UnitListSearcher<Ribon::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<Ribon::UnitListSearcher<Ribon::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock<GridReadGuard> cell_lock(cell, p); cell_lock->Visit(cell_lock, world_unit_searcher, *(m_creature->GetMap())); cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap())); } //dealdamege for(std::list<Unit*>::iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i) { if(!Cloud->IsWithinDist(*i, 6, false)) { Cloud->CastCustomSpell(*i, 43137, &bp0, NULL, NULL, true, 0, 0, m_creature->GetGUID()); } } // visual float x,y,z; z = m_creature->GetPositionZ(); for(uint8 i = 0; i < 5+rand()%5; ++i) { x = 343+rand()%60; y = 1380+rand()%60; if(Unit *trigger = m_creature->SummonTrigger(x, y, z, 0, 2000)) { trigger->setFaction(35); trigger->SetMaxHealth(100000); trigger->SetHealth(100000); trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); if (Cloud) Cloud->CastCustomSpell(trigger, /*43661*/43137, &bp0, NULL, NULL,true, 0, 0, Cloud->GetGUID()); } } } StormCount++; if(StormCount > 10) { StormCount = 0; // finish SummonEagles_Timer = 5000; m_creature->InterruptNonMeleeSpells(false); CloudGUID = 0; if (Cloud) Cloud->DealDamage(Cloud, Cloud->GetHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); SetWeather(WEATHER_STATE_FINE, 0.0f); isRaining = false; } StormSequenceTimer = 1000; }
Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) { CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* pUnit = NULL; MaNGOS::MostHPMissingInRange u_check(m_creature, range, MinHPDiff); MaNGOS::UnitLastSearcher<MaNGOS::MostHPMissingInRange> searcher(m_creature, pUnit, u_check); /* typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; This means that if we only search grid then we cannot possibly return pets or players so this is safe */ TypeContainerVisitor<MaNGOS::UnitLastSearcher<MaNGOS::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock<GridReadGuard> cell_lock(cell, p); cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap())); return pUnit; }
void HandleStormSequence(Unit* Cloud) // 1: begin, 2-9: tick, 10: end { if (StormCount < 10 && StormCount > 1) { // deal damage int32 bp0 = 800; for (uint8 i = 2; i < StormCount; ++i) bp0 *= 2; CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); cell.SetNoCreate(); std::list<Unit*> tempUnitMap; { Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS); Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(me, tempUnitMap, u_check); TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, world_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS); cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS); } // deal damage for (std::list<Unit*>::const_iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i) { if (Unit* target = (*i)) { if (Cloud && !Cloud->IsWithinDist(target, 6, false)) Cloud->CastCustomSpell(target, SPELL_ZAP, &bp0, NULL, NULL, true, 0, 0, me->GetGUID()); } } // visual float x, y, z; z = me->GetPositionZ(); for (uint8 i = 0; i < 5+rand()%5; ++i) { x = 343.0f+rand()%60; y = 1380.0f+rand()%60; if (Unit* trigger = me->SummonTrigger(x, y, z, 0, 2000)) { trigger->setFaction(35); trigger->SetMaxHealth(100000); trigger->SetHealth(100000); trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); if (Cloud) Cloud->CastCustomSpell(trigger, /*43661*/SPELL_ZAP, &bp0, NULL, NULL, true, 0, 0, Cloud->GetGUID()); } } } ++StormCount; if (StormCount > 10) { StormCount = 0; // finish events.ScheduleEvent(EVENT_SUMMON_EAGLES, 5000); me->InterruptNonMeleeSpells(false); CloudGUID = 0; if (Cloud) Cloud->DealDamage(Cloud, Cloud->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); SetWeather(WEATHER_STATE_FINE, 0.0f); isRaining = false; } events.ScheduleEvent(EVENT_STORM_SEQUENCE, 1000); }
Unit* BossSpellWorker::SelectLowHPFriendly(float fRange, uint32 uiMinHPDiff) { CellPair p(Trinity::ComputeCellPair(boss->GetPositionX(), boss->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* pUnit = NULL; Trinity::MostHPMissingInRange u_check(boss, fRange, uiMinHPDiff); Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(boss, pUnit, u_check); TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, grid_unit_searcher, *(pMap), *boss, fRange); return pUnit; }
Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) { CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); Cell cell(p); cell.SetNoCreate(); Unit* unit = NULL; Trinity::MostHPMissingInRange u_check(me, range, minHPDiff); Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check); /* typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; This means that if we only search grid then we cannot possibly return pets or players so this is safe */ TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, range); return unit; }
bool OPvPCapturePoint::Update(uint32 diff) { if(!m_capturePoint) return false; float radius = m_capturePoint->GetGOInfo()->capturePoint.radius; for (uint32 team = 0; team < 2; ++team) { for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { Player *player = *itr; ++itr; if(!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive()) HandlePlayerLeave(player); } } std::list<Player*> players; std::list<Unit *> targets; CellPair p(MaNGOS::ComputeCellPair(m_capturePoint->GetPositionX(), m_capturePoint->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); { MaNGOS::AnyUnitInObjectRangeCheck u_check(m_capturePoint, radius); MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(targets, u_check); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, world_unit_searcher, *m_capturePoint->GetMap()); cell.Visit(p, grid_unit_searcher, *m_capturePoint->GetMap()); } for( std::list<Unit *>::iterator itr = targets.begin(); itr != targets.end(); ++itr ) if( (*itr)->GetTypeId() == TYPEID_PLAYER ) players.push_back((Player*)(*itr)); for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr) { if((*itr)->IsOutdoorPvPActive()) { if(m_activePlayers[(*itr)->GetTeamId()].insert(*itr).second) HandlePlayerEnter(*itr); } } // get the difference of numbers float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL; if(!fact_diff) return false; uint32 Challenger = 0; float maxDiff = m_maxSpeed * diff; if(fact_diff < 0) { // horde is in majority, but it's already horde-controlled -> no change if(m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue) return false; if(fact_diff < -maxDiff) fact_diff = -maxDiff; Challenger = HORDE; } else { // ally is in majority, but it's already ally-controlled -> no change if(m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue) return false; if(fact_diff > maxDiff) fact_diff = maxDiff; Challenger = ALLIANCE; } float oldValue = m_value; TeamId oldTeam = m_team; m_OldState = m_State; m_value += fact_diff; if(m_value < -m_minValue) // red { if(m_value < -m_maxValue) m_value = -m_maxValue; m_State = OBJECTIVESTATE_HORDE; m_team = TEAM_HORDE; } else if(m_value > m_minValue) // blue { if(m_value > m_maxValue) m_value = m_maxValue; m_State = OBJECTIVESTATE_ALLIANCE; m_team = TEAM_ALLIANCE; } else if(oldValue * m_value <= 0) // grey, go through mid point { // if challenger is ally, then n->a challenge if(Challenger == ALLIANCE) m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE; // if challenger is horde, then n->h challenge else if(Challenger == HORDE) m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } else // grey, did not go through mid point { // old phase and current are on the same side, so one team challenges the other if(Challenger == ALLIANCE && (m_OldState == OBJECTIVESTATE_HORDE || m_OldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE)) m_State = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE; else if(Challenger == HORDE && (m_OldState == OBJECTIVESTATE_ALLIANCE || m_OldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE)) m_State = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE; m_team = TEAM_NEUTRAL; } if(m_value != oldValue) SendChangePhase(); if(m_OldState != m_State) { //sLog.outError("%u->%u", m_OldState, m_State); if(oldTeam != m_team) ChangeTeam(oldTeam); ChangeState(); return true; } return false; }
void HandleStormSequence(Unit *Cloud) // 1: begin, 2-9: tick, 10: end { if(StormCount < 10 && StormCount > 1) { // deal damage int32 bp0 = 800; for(uint8 i = 2; i < StormCount; ++i) bp0 *= 2; CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); std::list<Unit *> tempUnitMap; { MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(m_creature, m_creature, 999); MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(tempUnitMap, u_check); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock<GridReadGuard> cell_lock(cell, p); cell_lock->Visit(cell_lock, world_unit_searcher, *(m_creature->GetMap())); cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap())); } for(std::list<Unit*>::iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i) { if(!Cloud->IsWithinDistInMap(*i, 15)) { float x, y, z; (*i)->GetPosition(x, y, z); x = rand()%2 ? x + rand()%5 : x - rand()%5; y = rand()%2 ? y + rand()%5 : y - rand()%5; z = Cloud->GetPositionZ() + 2 - rand()%4; if(Creature *trigger = m_creature->SummonCreature(MOB_TEMP_TRIGGER, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 2000)) { trigger->AddMonsterMoveFlag(MONSTER_MOVE_LEVITATING); trigger->StopMoving(); trigger->CastSpell(trigger, 37248, true); trigger->CastCustomSpell(*i, 43137, &bp0, NULL, NULL, true, 0, 0, m_creature->GetGUID()); } } } // visual float x, y, z; for(uint8 i = 0; i < StormCount; ++i) { Cloud->GetPosition(x, y, z); x = rand()%2 ? x + rand()%10 : x - rand()%10; y = rand()%2 ? y + rand()%10 : y - rand()%10; z = z + 2 - rand()%4; if(Creature *trigger = m_creature->SummonCreature(MOB_TEMP_TRIGGER, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 2000)) { trigger->AddMonsterMoveFlag(MONSTER_MOVE_LEVITATING); trigger->StopMoving(); trigger->CastSpell(trigger, 37248, true); } Cloud->GetPosition(x, y, z); x = rand()%2 ? x + 10 + rand()%10 : x - 10 - rand()%10; y = rand()%2 ? y + 10 + rand()%10 : y - 10 - rand()%10; if(Creature *trigger = m_creature->SummonCreature(MOB_TEMP_TRIGGER, x, y, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 2000)) { trigger->SetMaxHealth(9999999); trigger->SetHealth(9999999); trigger->CastSpell(trigger, 43661, true); } } } StormCount++; if(StormCount > 10) { StormCount = 0; // finish SummonEagles_Timer = 5000; m_creature->InterruptNonMeleeSpells(false); Cloud->RemoveAurasDueToSpell(45213); CloudGUID = 0; if(Unit* Cyclone = Unit::GetUnit(*m_creature, CycloneGUID)) Cyclone->RemoveAurasDueToSpell(25160); SetWeather(WEATHER_STATE_FINE, 0.0f); isRaining = false; } StormSequenceTimer = 1000; }
Unit* ScriptedAI::DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff) { CellPair p(Diamond::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* pUnit = NULL; Diamond::MostHPMissingInRange u_check(m_creature, fRange, uiMinHPDiff); Diamond::UnitLastSearcher<Diamond::MostHPMissingInRange> searcher(m_creature, pUnit, u_check); /* typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; This means that if we only search grid then we cannot possibly return pets or players so this is safe */ GridTypeVisitor<Diamond::UnitLastSearcher<Diamond::MostHPMissingInRange> >::Grid grid_unit_searcher(searcher); cell.Visit(p, grid_unit_searcher, *(m_creature->GetMap()), *m_creature, fRange); return pUnit; }
Unit* BSWScriptedAI::doSelectLowHPFriendly(float fRange, uint32 uiMinHPDiff) { CellPair p(Diamond::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Unit* pUnit = NULL; Diamond::MostHPMissingInRange u_check(m_creature, fRange, uiMinHPDiff); Diamond::UnitLastSearcher<Diamond::MostHPMissingInRange> searcher(m_creature, pUnit, u_check); TypeContainerVisitor<Diamond::UnitLastSearcher<Diamond::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, grid_unit_searcher, *(pMap), *m_creature, fRange); return pUnit; }