diff options
46 files changed, 417 insertions, 350 deletions
diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index 8c7277bdbd8..04faa776a9f 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -1099,7 +1099,9 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* player) for (uint8 i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) if (m_Nodes[i].Owner == player->GetTeam() && m_Nodes[i].State == POINT_CONTROLED) - if (entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[i])) + { + entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[i]); + if (entry) { dist = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y); if (dist < minDist) @@ -1108,6 +1110,7 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* player) pGraveyard = entry; } } + } return pGraveyard; } diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 828c71bee4c..44d8c2c7ee7 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -106,7 +106,9 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) if (instanceId) bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId); - if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId))) + if (!bg) + bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); + if (!bg) return; // expected bracket entry diff --git a/src/game/BattleGroundSA.cpp b/src/game/BattleGroundSA.cpp index d11076bab4a..04eb9b3b567 100644 --- a/src/game/BattleGroundSA.cpp +++ b/src/game/BattleGroundSA.cpp @@ -488,7 +488,7 @@ void BattleGroundSA::DestroyGate(uint32 i, Player* pl) if (g->GetGOValue()->building.health == 0) { GateStatus[i] = BG_SA_GATE_DESTROYED; - uint32 uws; + uint32 uws = 0; switch(i) { case 0: diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 9971dbdc937..a8aa99b74f0 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -374,9 +374,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 target = owner; } } - else if ((target = me->getVictim())) + else { - if (target->GetTypeId() != TYPEID_PLAYER) + target = me->getVictim(); + if (target && target->GetTypeId() != TYPEID_PLAYER) if (Unit* owner = target->GetOwner()) if (owner->GetTypeId() == TYPEID_PLAYER) target = owner; diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 3f7c5cb7134..490fe034fd7 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -77,7 +77,7 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z) y = owner.GetPositionY(); z = owner.GetPositionZ(); - float temp_x, temp_y, angle; + float temp_x, temp_y, angle = 0; const Map * _map = owner.GetBaseMap(); //primitive path-finding for (uint8 i = 0; i < 18; ++i) diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 5bb9ab28145..488649b2e78 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -913,7 +913,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers) uint8 maxresul = 0; uint64 maxguid = (*roll->playerVote.begin()).first; Player *player; - RollVote rollvote; + RollVote rollvote = NOT_VALID; Roll::PlayerVote::iterator itr; for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr) diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 48901452cb4..6803fe63a86 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -972,7 +972,7 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket & recv_data) uint8 BankTab, BankTabSlot, AutoStore; uint8 PlayerSlot = NULL_SLOT; uint8 PlayerBag = NULL_BAG; - uint8 BankTabDst, BankTabSlotDst, unk2; + uint8 BankTabDst = 0, BankTabSlotDst = 0, unk2; uint8 ToChar = 1; uint32 ItemEntry, unk1; uint32 AutoStoreCount = 0; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 79affaca6bf..3d5c6d7a9d8 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -6902,13 +6902,13 @@ bool ChatHandler::HandleServerSetClosedCommand(const char *args) { std::string arg = args; - if (args == "on") + if (strncmp(args, "on", 3) == 0) { SendSysMessage(LANG_WORLD_CLOSED); sWorld.SetClosed(true); return true; } - if (args == "off") + else if (strncmp(args, "off", 4) == 0) { SendSysMessage(LANG_WORLD_OPENED); sWorld.SetClosed(false); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index f069d2d6fe4..2f73fb2ca16 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -2628,7 +2628,7 @@ void InstanceMap::CreateInstanceData(bool load) { Field* fields = result->Fetch(); const char* data = fields[0].GetString(); - if (data && data != "") + if (data && (strncmp(data, "", 1) == 0)) { sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId); i_data->Load(data); diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index 3fe5d1b8b0b..0736bfa6fb3 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -150,8 +150,12 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player) InstanceGroupBind *groupBind = NULL; Group *group = player->GetGroup(); // use the player's difficulty setting (it may not be the same as the group's) - if (group && (groupBind = group->GetBoundInstance(this))) - pSave = groupBind->save; + if (group) + { + groupBind = group->GetBoundInstance(this); + if (groupBind) + pSave = groupBind->save; + } } if (pSave) { diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index d4de7d6515e..9a76f78f209 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -252,7 +252,7 @@ void ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, } } -Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia) +Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool /*insignia*/) { Corpse* corpse = GetCorpseForPlayerGUID(player_guid); if (!corpse) @@ -266,7 +266,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia DEBUG_LOG("Deleting Corpse and spawning bones."); - Map* map = corpse->FindMap(); + //Map* map = corpse->FindMap(); // remove corpse from player_guid -> corpse map RemoveCorpse(corpse); @@ -285,6 +285,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia delete corpse; return NULL; + /* Corpse* bones = NULL; // create the bones only if the map and the grid is loaded at the corpse's location // ignore bones creating option in case insignia @@ -323,9 +324,10 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia delete corpse; return bones; + */ } -void ObjectAccessor::Update(uint32 diff) +void ObjectAccessor::Update(uint32 /*diff*/) { UpdateDataMapType update_players; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 0090f6dd6b2..0ce50659fb1 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -3392,7 +3392,7 @@ void ObjectMgr::LoadArenaTeams() do { - Field *fields = result->Fetch(); + //Field *fields = result->Fetch(); bar.step(); ++count; @@ -5308,7 +5308,7 @@ void ObjectMgr::LoadAreaTriggerScripts() uint32 ObjectMgr::GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 team) { bool found = false; - float dist; + float dist = 10000; uint32 id = 0; for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) @@ -5394,7 +5394,8 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt CreatureInfo const *mount_info = GetCreatureTemplate(mount_entry); if (mount_info) { - if (! (mount_id = mount_info->GetRandomValidModelId())) + mount_id = mount_info->GetRandomValidModelId(); + if (!mount_id) { sLog.outErrorDb("No displayid found for the taxi mount with the entry %u! Can't load it!", mount_entry); return false; @@ -5539,12 +5540,12 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float // at corpse map bool foundNear = false; - float distNear; + float distNear = 10000; WorldSafeLocsEntry const* entryNear = NULL; // at entrance map for corpse map bool foundEntr = false; - float distEntr; + float distEntr = 10000; WorldSafeLocsEntry const* entryEntr = NULL; // some where other diff --git a/src/game/OutdoorPvPHP.cpp b/src/game/OutdoorPvPHP.cpp index b15c85a5936..f4f73d015ce 100644 --- a/src/game/OutdoorPvPHP.cpp +++ b/src/game/OutdoorPvPHP.cpp @@ -113,8 +113,8 @@ void OutdoorPvPHP::HandlePlayerLeaveZone(Player * plr, uint32 zone) bool OutdoorPvPHP::Update(uint32 diff) { - bool changed = false; - if (changed = OutdoorPvP::Update(diff)) + bool changed = OutdoorPvP::Update(diff); + if (changed) { if (m_AllianceTowersControlled == 3) TeamApplyBuff(TEAM_ALLIANCE, AllianceBuff, HordeBuff); diff --git a/src/game/OutdoorPvPTF.cpp b/src/game/OutdoorPvPTF.cpp index ee9d6a4a651..1d8b60da1d0 100644 --- a/src/game/OutdoorPvPTF.cpp +++ b/src/game/OutdoorPvPTF.cpp @@ -120,9 +120,9 @@ void OPvPCapturePointTF::HandlePlayerLeave(Player *plr) bool OutdoorPvPTF::Update(uint32 diff) { - bool changed = false; + bool changed = OutdoorPvP::Update(diff); - if (changed = OutdoorPvP::Update(diff)) + if (changed) { if (m_AllianceTowersControlled == TF_TOWER_NUM) { diff --git a/src/game/OutdoorPvPZM.cpp b/src/game/OutdoorPvPZM.cpp index ca7543ff1b2..fb548816c3a 100644 --- a/src/game/OutdoorPvPZM.cpp +++ b/src/game/OutdoorPvPZM.cpp @@ -126,8 +126,8 @@ void OPvPCapturePointZM_Beacon::SendChangePhase() bool OutdoorPvPZM::Update(uint32 diff) { - bool changed = false; - if (changed = OutdoorPvP::Update(diff)) + bool changed = OutdoorPvP::Update(diff); + if (changed) { if (m_AllianceTowersControlled == ZM_NUM_BEACONS) m_GraveYard->SetBeaconState(ALLIANCE); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7a287a3dc4b..4405da3b7ef 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1600,7 +1600,8 @@ bool Player::BuildEnumData(QueryResult_AutoPtr result, WorldPacket * p_data) if (!enchantId) continue; - if ((enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId))) + enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId); + if (enchant) break; } @@ -7262,7 +7263,8 @@ void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool appl // If set dpsMod in ScalingStatValue use it for min (70% from average), max (130% from average) damage if (ssv) { - if ((extraDPS = ssv->getDPSMod(proto->ScalingStatValue))) + extraDPS = ssv->getDPSMod(proto->ScalingStatValue); + if (extraDPS) { float average = extraDPS * proto->Delay / 1000.0f; minDamage = 0.7f * average; @@ -12172,7 +12174,7 @@ void Player::SwapItem(uint16 src, uint16 dst) { uint8 msg; ItemPosCountVec sDest; - uint16 eDest; + uint16 eDest = 0; if (IsInventoryPos(dst)) msg = CanStoreItem(dstbag, dstslot, sDest, pSrcItem, false); else if (IsBankPos (dst)) @@ -12216,7 +12218,7 @@ void Player::SwapItem(uint16 src, uint16 dst) } // impossible merge/fill, do real swap - uint8 msg; + uint8 msg = EQUIP_ERR_OK; // check src->dest move possibility ItemPosCountVec sDest; @@ -20707,11 +20709,8 @@ void Player::resetSpells(bool myClassOnly) if (!clsEntry) return; family = clsEntry->spellfamily; - } - for (PlayerSpellMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) - { - if (myClassOnly) + for (PlayerSpellMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(iter->first); if (!spellInfo) @@ -20738,8 +20737,10 @@ void Player::resetSpells(bool myClassOnly) if (!SpellMgr::IsSpellValid(spellInfo,this,false)) continue; } - removeSpell(iter->first,false,false); // only iter->first can be accessed, object by iter->second can be deleted already } + else + for (PlayerSpellMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) + removeSpell(iter->first,false,false); // only iter->first can be accessed, object by iter->second can be deleted already learnDefaultSpells(); learnQuestRewardedSpells(); diff --git a/src/game/ScriptedCreature.cpp b/src/game/ScriptedCreature.cpp index 1dc8934a511..1a2060f330c 100644 --- a/src/game/ScriptedCreature.cpp +++ b/src/game/ScriptedCreature.cpp @@ -709,12 +709,14 @@ void LoadOverridenSQLData() GameObjectInfo *goInfo; // Sunwell Plateau : Kalecgos : Spectral Rift - if (goInfo = GOBJECT(187055)) + goInfo = GOBJECT(187055); + if (goInfo) if (goInfo->type == GAMEOBJECT_TYPE_GOOBER) goInfo->goober.lockId = 57; // need LOCKTYPE_QUICK_OPEN // Naxxramas : Sapphiron Birth - if (goInfo = GOBJECT(181356)) + goInfo = GOBJECT(181356); + if (goInfo) if (goInfo->type == GAMEOBJECT_TYPE_TRAP) goInfo->trap.radius = 50; } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 8a50bbda609..f432d73767b 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1335,7 +1335,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool } // Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add - if (m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo,m_triggeredByAuraSpell)) + m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo,m_triggeredByAuraSpell); + if (m_diminishGroup) { m_diminishLevel = unit->GetDiminishing(m_diminishGroup); DiminishingReturnsType type = GetDiminishingReturnsGroupType(m_diminishGroup); @@ -1372,8 +1373,9 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool if (m_originalCaster) { - if (m_spellAura = Aura::TryCreate(aurSpellInfo, effectMask, unit, - m_originalCaster,(aurSpellInfo == m_spellInfo)? &m_currentBasePoints[0] : &basePoints[0], m_CastItem)) + m_spellAura = Aura::TryCreate(aurSpellInfo, effectMask, unit, + m_originalCaster,(aurSpellInfo == m_spellInfo)? &m_currentBasePoints[0] : &basePoints[0], m_CastItem); + if (m_spellAura) { // Now Reduce spell duration using data received at spell hit int32 duration = m_spellAura->GetMaxDuration(); @@ -4584,7 +4586,8 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_targets.getTargetMask() == TARGET_FLAG_SELF && m_spellInfo->EffectImplicitTargetA[1] == TARGET_UNIT_TARGET_ENEMY) { - if (target = m_caster->GetUnit(*m_caster, m_caster->ToPlayer()->GetSelection())) + target = m_caster->GetUnit(*m_caster, m_caster->ToPlayer()->GetSelection()); + if (target) m_targets.setUnitTarget(target); else return SPELL_FAILED_BAD_TARGETS; diff --git a/src/game/SpellAuraEffects.cpp b/src/game/SpellAuraEffects.cpp index 38e819f6021..cb417e50804 100644 --- a/src/game/SpellAuraEffects.cpp +++ b/src/game/SpellAuraEffects.cpp @@ -504,15 +504,18 @@ int32 AuraEffect::CalculateAmount(Unit * caster) AuraEffect const* pAurEff; // Borrowed Time - if (pAurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_PRIEST, 2899, 1)) + pAurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_PRIEST, 2899, 1); + if (pAurEff) bonus += (float)pAurEff->GetAmount() / 100.0f; // Twin Disciplines - if (pAurEff = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_PRIEST, 0x400000, 0, 0, caster->GetGUID())) + pAurEff = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_PRIEST, 0x400000, 0, 0, caster->GetGUID()); + if (pAurEff) bonus += (float)pAurEff->GetAmount() / 100.0f; // Focused Power - if (pAurEff = caster->GetAuraEffect(SPELL_AURA_MOD_HEALING_DONE_PERCENT, SPELLFAMILY_PRIEST, 2210, 2)) + pAurEff = caster->GetAuraEffect(SPELL_AURA_MOD_HEALING_DONE_PERCENT, SPELLFAMILY_PRIEST, 2210, 2); + if (pAurEff) bonus += (float)pAurEff->GetAmount() / 100.0f; DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(GetSpellProto())) * bonus; @@ -2053,7 +2056,7 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const if (target->GetPower(POWER_MANA) >= 10) { target->ModifyPower(POWER_MANA, -10); - target->SendEnergizeSpellLog(caster, 27746, -10, POWER_MANA); + target->SendEnergizeSpellLog(caster, 27746, 10, POWER_MANA); } else target->RemoveAurasDueToSpell(27746); @@ -3039,7 +3042,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const * aurApp, uint8 mode, } else { - uint32 model_id; + uint32 model_id = 0; if (uint32 modelid = ci->GetRandomValidModelId()) model_id = modelid; // Will use the default model here diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 1828a3ec37f..eddbb230b16 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -557,9 +557,12 @@ void Aura::UpdateOwner(uint32 diff, WorldObject * owner) Spell * modSpell = NULL; Player * modOwner = NULL; if (caster) - if ((modOwner = caster->GetSpellModOwner()) - && (modSpell = modOwner->FindCurrentSpellBySpellId(GetId()))) - modOwner->SetSpellModTakingSpell(modSpell, true); + { + modOwner = caster->GetSpellModOwner(); + modSpell = modOwner->FindCurrentSpellBySpellId(GetId()); + if (modOwner && modSpell) + modOwner->SetSpellModTakingSpell(modSpell, true); + } Update(diff, caster); diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 0b7698369f1..7bc3877afc0 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -937,13 +937,15 @@ bool Guardian::UpdateStats(Stats stat) // Ravenous Dead AuraEffect const *aurEff; // Check just if owner has Ravenous Dead since it's effect is not an aura - if (aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0)) + aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0); + if (aurEff) { SpellEntry const* sProto = aurEff->GetSpellProto(); // Then get the SpellProto and add the dummy effect value mod += mod * (sProto->EffectBasePoints[1] / 100.0f); // Ravenous Dead edits the original scale } // Glyph of the Ghoul - if (aurEff = owner->GetAuraEffect(58686, 0)) + aurEff = owner->GetAuraEffect(58686, 0); + if (aurEff) mod += (aurEff->GetAmount() / 100.0f); // Glyph of the Ghoul adds a flat value to the scale mod value += float(owner->GetStat(stat)) * mod; } diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 8005a6cb37d..11652460fc5 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -249,16 +249,10 @@ void TempSummon::RemoveFromWorld() return; if (m_Properties) - { if (uint32 slot = m_Properties->Slot) - { if (Unit* owner = GetSummoner()) - { - if (owner->m_SummonSlot[slot] = GetGUID()) + if (owner->m_SummonSlot[slot] == GetGUID()) owner->m_SummonSlot[slot] = 0; - } - } - } //if (GetOwnerGUID()) // sLog.outError("Unit %u has owner guid when removed from world", GetEntry()); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 397a6ffccc5..566112eacd3 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3631,8 +3631,8 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMo } bool auraStateFound = false; - AuraState auraState; - if (auraState = GetSpellAuraState(aura->GetSpellProto())) + AuraState auraState = GetSpellAuraState(aura->GetSpellProto()); + if (auraState) { bool canBreak = false; // Get mask of all aurastates from remaining auras @@ -5950,7 +5950,8 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger if ((*i)->GetEffIndex() != 0) continue; basepoints0 = int32((*i)->GetAmount()); - if (target = GetGuardianPet()) + target = GetGuardianPet(); + if (target) { // regen mana for pet CastCustomSpell(target,54607,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); @@ -12111,10 +12112,10 @@ Unit* Creature::SelectVictim() const AuraEffectList& tauntAuras = GetAuraEffectsByType(SPELL_AURA_MOD_TAUNT); if (!tauntAuras.empty()) { - Unit* caster; + Unit* caster = tauntAuras.back()->GetCaster(); // The last taunt aura caster is alive an we are happy to attack him - if ((caster = tauntAuras.back()->GetCaster()) && caster->isAlive()) + if (caster && caster->isAlive()) return getVictim(); else if (tauntAuras.size() > 1) { @@ -12126,8 +12127,8 @@ Unit* Creature::SelectVictim() do { --aura; - if ((caster = (*aura)->GetCaster()) && - caster->IsInMap(this) && canAttack(caster) && caster->isInAccessiblePlaceFor(this->ToCreature())) + caster = (*aura)->GetCaster(); + if (caster && caster->IsInMap(this) && canAttack(caster) && caster->isInAccessiblePlaceFor(this->ToCreature())) { target = caster; break; @@ -12194,9 +12195,11 @@ Unit* Creature::SelectVictim() // search nearby enemy before enter evade mode if (HasReactState(REACT_AGGRESSIVE)) - if (target = SelectNearestTarget()) - if (_IsTargetAcceptable(target)) + { + target = SelectNearestTarget(); + if (target && _IsTargetAcceptable(target)) return target; + } if (m_invisibilityMask) { @@ -13221,7 +13224,7 @@ void CharmInfo::InitCharmCreateSpells() { m_charmspells[x].SetActionAndType(spellId,ACT_DISABLED); - ActiveStates newstate; + ActiveStates newstate = ACT_PASSIVE; if (spellInfo) { if (!IsAutocastableSpell(spellId)) diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 876fb7ec057..e0ab491f2e1 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -68,7 +68,7 @@ bool WaypointMovementGenerator<Player>::GetDestination(float & /*x*/, float & /* } template<> -void WaypointMovementGenerator<Creature>::Reset(Creature & /*unit*/unit) +void WaypointMovementGenerator<Creature>::Reset(Creature & /*unit*/) { StopedByPlayer = true; i_nextMoveTime.Reset(0); diff --git a/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp b/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp index 7ab783e6e93..f6e94307f2f 100644 --- a/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp +++ b/src/scripts/eastern_kingdoms/blackwing_lair/boss_vaelastrasz.cpp @@ -173,8 +173,8 @@ struct boss_vaelAI : public ScriptedAI while (i < 3) // max 3 tries to get a random target with power_mana { ++i; - if (pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true)) //not aggro leader - if (pTarget->getPowerType() == POWER_MANA) + pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); //not aggro leader + if (pTarget && pTarget->getPowerType() == POWER_MANA) i = 3; } if (pTarget) // cast on self (see below) diff --git a/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp b/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp index 79af5c3030c..3b0ce186592 100644 --- a/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp +++ b/src/scripts/eastern_kingdoms/scarlet_enclave/chapter5.cpp @@ -1511,7 +1511,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI // Death for (uint8 i = 0; i < ENCOUNTER_GHOUL_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiGhoulGUID[i]))) + pTemp = Unit::GetCreature(*me, uiGhoulGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_ACHERUS_GHOUL, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1520,7 +1521,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_ABOMINATION_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiAbominationGUID[i]))) + pTemp = Unit::GetCreature(*me, uiAbominationGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_WARRIOR_OF_THE_FROZEN_WASTES, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1529,7 +1531,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_WARRIOR_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiWarriorGUID[i]))) + pTemp = Unit::GetCreature(*me, uiWarriorGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_RAMPAGING_ABOMINATION, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1538,7 +1541,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_BEHEMOTH_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiBehemothGUID[i]))) + pTemp = Unit::GetCreature(*me, uiBehemothGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_FLESH_BEHEMOTH, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2084); @@ -1549,7 +1553,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI // Dawn for (uint8 i = 0; i < ENCOUNTER_DEFENDER_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiDefenderGUID[i]))) + pTemp = Unit::GetCreature(*me, uiDefenderGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_DEFENDER_OF_THE_LIGHT, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2089); @@ -1559,7 +1564,8 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI } for (uint8 i = 0; i < ENCOUNTER_EARTHSHATTER_NUMBER; ++i) { - if (!(pTemp = Unit::GetCreature(*me, uiEarthshatterGUID[i]))) + pTemp = Unit::GetCreature(*me, uiEarthshatterGUID[i]); + if (!pTemp) { pTemp = me->SummonCreature(NPC_RIMBLAT_EARTHSHATTER, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2089); @@ -1567,28 +1573,32 @@ struct npc_highlord_darion_mograineAI : public npc_escortAI uiEarthshatterGUID[i] = pTemp->GetGUID(); } } - if (!(pTemp = Unit::GetCreature(*me, uiKorfaxGUID))) + pTemp = Unit::GetCreature(*me, uiKorfaxGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_KORFAX_CHAMPION_OF_THE_LIGHT, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); pTemp->setFaction(2089); me->AddThreat(pTemp, 0.0f); uiKorfaxGUID = pTemp->GetGUID(); } - if (!(pTemp = Unit::GetCreature(*me, uiMaxwellGUID))) + pTemp = Unit::GetCreature(*me, uiMaxwellGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_LORD_MAXWELL_TYROSUS, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); pTemp->setFaction(2089); me->AddThreat(pTemp, 0.0f); uiMaxwellGUID = pTemp->GetGUID(); } - if (!(pTemp = Unit::GetCreature(*me, uiEligorGUID))) + pTemp = Unit::GetCreature(*me, uiEligorGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_COMMANDER_ELIGOR_DAWNBRINGER, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 600000); pTemp->setFaction(2089); me->AddThreat(pTemp, 0.0f); uiEligorGUID = pTemp->GetGUID(); } - if (!(pTemp = Unit::GetCreature(*me, uiRayneGUID))) + pTemp = Unit::GetCreature(*me, uiRayneGUID); + if (!pTemp) { pTemp = me->SummonCreature(NPC_RAYNE, LightofDawnLoc[0].x+rand()%30, LightofDawnLoc[0].y+rand()%30, LightofDawnLoc[0].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); pTemp->setFaction(2089); diff --git a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp index 32555a550c2..6b6efa0f934 100644 --- a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp +++ b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_azshir_the_sleepless.cpp @@ -60,7 +60,7 @@ struct boss_azshir_the_sleeplessAI : public ScriptedAI DoCast(me->getVictim(), SPELL_SOULSIPHON); return; - SoulSiphon_Timer = 20000; + //SoulSiphon_Timer = 20000; } else SoulSiphon_Timer -= diff; } diff --git a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp index b3f250769b2..34d6d1bf295 100644 --- a/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp +++ b/src/scripts/eastern_kingdoms/scarlet_monastery/boss_headless_horseman.cpp @@ -116,12 +116,7 @@ static Locations Spawn[]= {1765.28,1347.46,17.55} //spawn point for smoke }; -struct Summon -{ - const std::string text; -}; - -static Summon Text[]= +static const char* Text[]= { {"Horseman rise..."}, {"Your time is nigh..."}, @@ -615,14 +610,14 @@ struct boss_headless_horsemanAI : public ScriptedAI if (count < 3) { if (plr) - plr->Say(Text[count].text,0); + plr->Say(Text[count],0); } else { DoCast(me, SPELL_RHYME_BIG); if (plr) { - plr->Say(Text[count].text,0); + plr->Say(Text[count],0); plr->HandleEmoteCommand(ANIM_EMOTE_SHOUT); } wp_reached = true; diff --git a/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp b/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp index 17ab1f3c5b1..7baa9292142 100644 --- a/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp +++ b/src/scripts/eastern_kingdoms/zulaman/boss_hexlord.cpp @@ -559,11 +559,10 @@ struct boss_alyson_antilleAI : public boss_hexlord_addAI else { if (urand(0,1)) - { - if (pTarget = DoSelectLowestHpFriendly(50, 0)) - DoCast(pTarget, SPELL_DISPEL_MAGIC, false); - } - else if (pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0)) + pTarget = DoSelectLowestHpFriendly(50, 0); + else + pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (pTarget) DoCast(pTarget, SPELL_DISPEL_MAGIC, false); } flashheal_timer = 2500; diff --git a/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp b/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp index 21a7630018b..77e9f9b929f 100644 --- a/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp +++ b/src/scripts/eastern_kingdoms/zulgurub/boss_marli.cpp @@ -167,8 +167,8 @@ struct boss_marliAI : public ScriptedAI while (i < 3) // max 3 tries to get a random target with power_mana { ++i; - if (pTarget = SelectTarget(SELECT_TARGET_RANDOM,1, 100, true)) // not aggro leader - if (pTarget->getPowerType() == POWER_MANA) + pTarget = SelectTarget(SELECT_TARGET_RANDOM,1, 100, true); // not aggro leader + if (pTarget && pTarget->getPowerType() == POWER_MANA) i = 3; } if (pTarget) diff --git a/src/scripts/kalimdor/silithus.cpp b/src/scripts/kalimdor/silithus.cpp index d7495b4187e..c2c356692f1 100644 --- a/src/scripts/kalimdor/silithus.cpp +++ b/src/scripts/kalimdor/silithus.cpp @@ -688,15 +688,19 @@ struct npc_anachronos_the_ancientAI : public ScriptedAI Fandral->CastSpell(-8127,1525,17.5,33806,true); break; case 51: - while (mob = plr->FindNearestCreature(15423,50,me)) - mob->RemoveFromWorld(); - while (mob = plr->FindNearestCreature(15424,50,me)) - mob->RemoveFromWorld(); - while (mob = plr->FindNearestCreature(15414,50,me)) - mob->RemoveFromWorld(); - while (mob = plr->FindNearestCreature(15422,50,me)) - mob->RemoveFromWorld(); + { + uint32 entries[4] = { 15423, 15424, 15414, 15422 }; + for (uint8 i = 0; i < 4; ++i) + { + mob = plr->FindNearestCreature(entries[i],50,me); + while (mob) + { + mob->RemoveFromWorld(); + mob = plr->FindNearestCreature(15423,50,me); + } + } break; + } case 52: Fandral->GetMotionMaster()->MoveCharge(-8028.75, 1538.795, 2.61,4); DoScriptText(ANACHRONOS_SAY_9, me,Fandral); diff --git a/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp b/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp index fa035693008..9cbc514b468 100644 --- a/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp +++ b/src/scripts/northrend/azjol_nerub/azjol_nerub/boss_krikthir_the_gatewatcher.cpp @@ -182,18 +182,26 @@ struct boss_krik_thirAI : public ScriptedAI { DoScriptText(SAY_DEATH, me); - if (pInstance) - { - pInstance->SetData(DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, DONE); - //Achievement: Watch him die - Creature *pAdd1, *pAdd2, *pAdd3; - if ((pAdd1 = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_GASHRA))) && pAdd1->isAlive() && - (pAdd2 = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_SILTHIK))) && pAdd2->isAlive() && - (pAdd3 = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_NARJIL))) && pAdd3->isAlive() && - IsHeroic()) - pInstance->DoCompleteAchievement(ACHIEV_WATH_HIM_DIE); - } + if (!pInstance) + return; + + pInstance->SetData(DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, DONE); + //Achievement: Watch him die + Creature *pAdd = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_GASHRA)); + if (!pAdd || !pAdd->isAlive()) + return; + + pAdd = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_SILTHIK)); + if (!pAdd || !pAdd->isAlive()) + return; + + pAdd = Unit::GetCreature(*me, pInstance->GetData64(DATA_WATCHER_NARJIL)); + if (!pAdd || !pAdd->isAlive()) + return; + + pInstance->DoCompleteAchievement(ACHIEV_WATH_HIM_DIE); } + void KilledUnit(Unit * victim) { if (victim == me) diff --git a/src/scripts/northrend/borean_tundra.cpp b/src/scripts/northrend/borean_tundra.cpp index b36463b581f..728e065e14a 100644 --- a/src/scripts/northrend/borean_tundra.cpp +++ b/src/scripts/northrend/borean_tundra.cpp @@ -647,6 +647,13 @@ enum eNesingwaryTrapper SPELL_TRAPPED = 46104, }; +#define CaribouTrapsNum 15 +const uint32 CaribouTraps[CaribouTrapsNum] = +{ + GO_CARIBOU_TRAP_1, GO_CARIBOU_TRAP_2, GO_CARIBOU_TRAP_3, GO_CARIBOU_TRAP_4, GO_CARIBOU_TRAP_5, + GO_CARIBOU_TRAP_6, GO_CARIBOU_TRAP_7, GO_CARIBOU_TRAP_8, GO_CARIBOU_TRAP_9, GO_CARIBOU_TRAP_10, + GO_CARIBOU_TRAP_11, GO_CARIBOU_TRAP_12, GO_CARIBOU_TRAP_13, GO_CARIBOU_TRAP_14, GO_CARIBOU_TRAP_15, +}; //#define SAY_NESINGWARY_1 -1571008 struct npc_nesingwary_trapperAI : public ScriptedAI @@ -725,24 +732,15 @@ struct npc_nesingwary_trapperAI : public ScriptedAI case 7: { GameObject *go_caribou = NULL; - if ((go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_1, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_2, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_3, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_4, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_5, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_6, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_7, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_8, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_9, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_10, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_11, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_12, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_13, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_14, 5.0f)) || - (go_caribou = me->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f))) + for (uint8 i = 0; i < CaribouTrapsNum; ++i) { - go_caribou->SetGoState(GO_STATE_ACTIVE); - go_caribouGUID = go_caribou->GetGUID(); + go_caribou = me->FindNearestGameObject(CaribouTraps[i], 5.0f); + if (go_caribou) + { + go_caribou->SetGoState(GO_STATE_ACTIVE); + go_caribouGUID = go_caribou->GetGUID(); + break; + } } Phase = 8; uiPhaseTimer = 1000; @@ -2029,6 +2027,16 @@ enum eHelpThemselves GO_MAMMOTH_TRAP_22 = 188044, }; +#define MammothTrapsNum 22 +const uint32 MammothTraps[MammothTrapsNum] = +{ + GO_MAMMOTH_TRAP_1, GO_MAMMOTH_TRAP_2, GO_MAMMOTH_TRAP_3, GO_MAMMOTH_TRAP_4, GO_MAMMOTH_TRAP_5, + GO_MAMMOTH_TRAP_6, GO_MAMMOTH_TRAP_7, GO_MAMMOTH_TRAP_8, GO_MAMMOTH_TRAP_9, GO_MAMMOTH_TRAP_10, + GO_MAMMOTH_TRAP_11, GO_MAMMOTH_TRAP_12, GO_MAMMOTH_TRAP_13, GO_MAMMOTH_TRAP_14, GO_MAMMOTH_TRAP_15, + GO_MAMMOTH_TRAP_16, GO_MAMMOTH_TRAP_17, GO_MAMMOTH_TRAP_18, GO_MAMMOTH_TRAP_19, GO_MAMMOTH_TRAP_20, + GO_MAMMOTH_TRAP_21, GO_MAMMOTH_TRAP_22 +}; + struct npc_trapped_mammoth_calfAI : public ScriptedAI { npc_trapped_mammoth_calfAI(Creature* c) : ScriptedAI(c) {} @@ -2038,34 +2046,19 @@ struct npc_trapped_mammoth_calfAI : public ScriptedAI void Reset() { - GameObject *pTrap; - uiTimer = 1500; bStarted = false; - if ((pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_1,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_2,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_3,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_4,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_5,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_6,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_7,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_8,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_9,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_10,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_11,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_12,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_13,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_14,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_15,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_16,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_17,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_18,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_19,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_20,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_21,1.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_22,1.0f))) - pTrap->SetGoState(GO_STATE_ACTIVE); + GameObject* pTrap; + for (uint8 i = 0; i < MammothTrapsNum; ++i) + { + pTrap = me->FindNearestGameObject(MammothTraps[i],11.0f); + if (pTrap) + { + pTrap->SetGoState(GO_STATE_ACTIVE); + return; + } + } } void UpdateAI(const uint32 diff) @@ -2091,34 +2084,20 @@ struct npc_trapped_mammoth_calfAI : public ScriptedAI void MovementInform(uint32 uiType, uint32 /*uiId*/) { - GameObject* pTrap; + if (uiType != POINT_MOTION_TYPE) return; me->DisappearAndDie(); - - if ((pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_1,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_2,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_3,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_4,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_5,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_6,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_7,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_8,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_9,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_10,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_11,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_12,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_13,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_14,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_15,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_16,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_17,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_18,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_19,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_20,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_21,11.0f)) || - (pTrap = me->FindNearestGameObject(GO_MAMMOTH_TRAP_22,11.0f))) - pTrap->SetLootState(GO_JUST_DEACTIVATED); + GameObject* pTrap; + for (uint8 i = 0; i < MammothTrapsNum; ++i) + { + pTrap = me->FindNearestGameObject(MammothTraps[i],11.0f); + if (pTrap) + { + pTrap->SetLootState(GO_JUST_DEACTIVATED); + return; + } + } } }; @@ -2233,8 +2212,10 @@ struct npc_valiance_keep_cannoneerAI : public ScriptedAI if (uiTimer <= diff) { me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); - GameObject* pCannon; - if ((pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_1,10)) || (pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_2,10))) + GameObject* pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_1,10); + if (!pCannon) + pCannon = me->FindNearestGameObject(GO_VALIANCE_KEEP_CANNON_2,10); + if (pCannon) pCannon->Use(me); uiTimer = urand(13000,18000); } diff --git a/src/scripts/northrend/icecrown.cpp b/src/scripts/northrend/icecrown.cpp index 5c47f22f825..84bc655ac22 100644 --- a/src/scripts/northrend/icecrown.cpp +++ b/src/scripts/northrend/icecrown.cpp @@ -301,29 +301,32 @@ struct npc_alorah_and_grimminAI : public ScriptedAI { npc_alorah_and_grimminAI(Creature* pCreature) : ScriptedAI(pCreature) {} - uint8 uiCast; + bool uiCast; void Reset() { - uiCast = 1; + uiCast = false; } void UpdateAI(const uint32 /*uiDiff*/) { - if (uiCast = 1) + if (uiCast) + return; + uiCast = true; + Creature* pTarget = NULL; + + switch(me->GetEntry()) { - Creature* pTarget1 = me->FindNearestCreature(NPC_EYDIS_DARKBANE, 10.0f); - Creature* pTarget2 = me->FindNearestCreature(NPC_FJOLA_LIGHTBANE, 10.0f); - switch(me->GetEntry()) - { - case NPC_PRIESTESS_ALORAH: - DoCast(pTarget1, SPELL_CHAIN); - uiCast = 0; - case NPC_PRIEST_GRIMMIN: - DoCast(pTarget2, SPELL_CHAIN); - uiCast = 0; - } + case NPC_PRIESTESS_ALORAH: + pTarget = me->FindNearestCreature(NPC_EYDIS_DARKBANE, 10.0f); + break; + case NPC_PRIEST_GRIMMIN: + pTarget = me->FindNearestCreature(NPC_FJOLA_LIGHTBANE, 10.0f); + break; } + if (pTarget) + DoCast(pTarget, SPELL_CHAIN); + if (!UpdateVictim()) return; } diff --git a/src/scripts/northrend/naxxramas/instance_naxxramas.cpp b/src/scripts/northrend/naxxramas/instance_naxxramas.cpp index 15b3aecace0..706789a73f1 100644 --- a/src/scripts/northrend/naxxramas/instance_naxxramas.cpp +++ b/src/scripts/northrend/naxxramas/instance_naxxramas.cpp @@ -286,7 +286,7 @@ struct instance_naxxramas : public InstanceData } } - bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* source, Unit const* target = NULL, uint32 miscvalue1 = 0) + bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target = NULL*/, uint32 /*miscvalue1 = 0*/) { switch(criteria_id) { diff --git a/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp b/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp index 378f2633907..3e24aaeb6c0 100644 --- a/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp +++ b/src/scripts/northrend/obsidian_sanctum/boss_sartharion.cpp @@ -1072,7 +1072,7 @@ struct mob_acolyte_of_shadronAI : public ScriptedAI if (pInstance) { Unit *pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 0, 999, true); - Creature* pShadron = NULL; + Creature* pSartharion = Unit::GetCreature(*me, pInstance->GetData64(DATA_SARTHARION)); if (Creature* pShadron = Unit::GetCreature(*me, pInstance->GetData64(DATA_SHADRON))) //if not solo figth, buff main boss, else place debuff on mini-boss. both spells TARGET_SCRIPT diff --git a/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp b/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp index b365de8996f..d69f0eee846 100644 --- a/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp +++ b/src/scripts/northrend/utgarde_keep/utgarde_keep/boss_keleseth.cpp @@ -197,7 +197,8 @@ struct boss_kelesethAI : public ScriptedAI DoScriptText(SAY_SKELETONS, me); for (uint8 i = 0; i < 5; ++i) { - if (Skeleton = me->SummonCreature(CREATURE_SKELETON, SkeletonSpawnPoint[i][0], SkeletonSpawnPoint[i][1] , SKELETONSPAWN_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000)) + Skeleton = me->SummonCreature(CREATURE_SKELETON, SkeletonSpawnPoint[i][0], SkeletonSpawnPoint[i][1] , SKELETONSPAWN_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000); + if (Skeleton) { Skeleton->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); Skeleton->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY() , me->GetPositionZ()); diff --git a/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp b/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp index 74a94d99dc0..297fe37b7d8 100644 --- a/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp +++ b/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_palehoof.cpp @@ -103,17 +103,24 @@ struct boss_palehoofAI : public ScriptedAI { pInstance->SetData(DATA_GORTOK_PALEHOOF_EVENT, NOT_STARTED); - Creature* pTemp; - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FRENZIED_WORGEN))) && !pTemp->isAlive()) + Creature* pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FRENZIED_WORGEN)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FEROCIOUS_RHINO))) && !pTemp->isAlive()) + + pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_FEROCIOUS_RHINO)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_MASSIVE_JORMUNGAR))) && !pTemp->isAlive()) + + pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_MASSIVE_JORMUNGAR)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if ((pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_RAVENOUS_FURBOLG))) && !pTemp->isAlive()) + + pTemp = Unit::GetCreature((*me), pInstance->GetData64(DATA_MOB_RAVENOUS_FURBOLG)); + if (pTemp && !pTemp->isAlive()) pTemp->Respawn(); - if (GameObject* pGo = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GORTOK_PALEHOOF_SPHERE))) + GameObject* pGo = pInstance->instance->GetGameObject(pInstance->GetData64(DATA_GORTOK_PALEHOOF_SPHERE)); + if (pGo) { pGo->SetGoState(GO_STATE_READY); pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1); diff --git a/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp b/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp index 250238f1c12..092339be6d5 100644 --- a/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp +++ b/src/scripts/northrend/vault_of_archavon/boss_toravon.cpp @@ -233,21 +233,24 @@ struct mob_frozen_orb_stalkerAI : public Scripted_NoMovementAI void UpdateAI(const uint32 /*diff*/) { - if (!spawned) + if (spawned) + return; + + spawned = true; + if (!pInstance) + return; + + Unit* pToravon = me->GetCreature(*me, pInstance->GetData64(DATA_TORAVON)); + if (!pToravon) + return; + + uint8 num_orbs = RAID_MODE(1, 3); + for (uint8 i=0; i<num_orbs; ++i) { - Unit* pToravon; - if (pInstance && (pToravon = me->GetCreature(*me, pInstance->GetData64(DATA_TORAVON)))) - { - uint8 num_orbs = RAID_MODE(1, 3); - for (uint8 i=0; i<num_orbs; ++i) - { - Position pos; - me->GetNearPoint(pToravon, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 0.0f, 10.0f, 0.0f); - me->SetPosition(pos, true); - DoCast(me, SPELL_FROZEN_ORB_SUMMON); - } - } - spawned = true; + Position pos; + me->GetNearPoint(pToravon, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 0.0f, 10.0f, 0.0f); + me->SetPosition(pos, true); + DoCast(me, SPELL_FROZEN_ORB_SUMMON); } } }; diff --git a/src/scripts/northrend/violet_hold/instance_violet_hold.cpp b/src/scripts/northrend/violet_hold/instance_violet_hold.cpp index 4d993eccd27..d124404610f 100644 --- a/src/scripts/northrend/violet_hold/instance_violet_hold.cpp +++ b/src/scripts/northrend/violet_hold/instance_violet_hold.cpp @@ -274,7 +274,8 @@ struct instance_violet_hold : public ScriptedInstance { case BOSS_MORAGG: HandleGameObject(uiMoraggCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiMoragg)) + pBoss = instance->GetCreature(uiMoragg); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_EREKEM: @@ -282,7 +283,8 @@ struct instance_violet_hold : public ScriptedInstance HandleGameObject(uiErekemRightGuardCell, bForceRespawn); HandleGameObject(uiErekemLeftGuardCell, bForceRespawn); - if (pBoss = instance->GetCreature(uiErekem)) + pBoss = instance->GetCreature(uiErekem); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); if (Creature* pGuard1 = instance->GetCreature(uiErekemGuard[0])) @@ -303,22 +305,26 @@ struct instance_violet_hold : public ScriptedInstance break; case BOSS_ICHORON: HandleGameObject(uiIchoronCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiIchoron)) + instance->GetCreature(uiIchoron); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_LAVANTHOR: HandleGameObject(uiLavanthorCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiLavanthor)) + pBoss = instance->GetCreature(uiLavanthor); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_XEVOZZ: HandleGameObject(uiXevozzCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiXevozz)) + pBoss = instance->GetCreature(uiXevozz); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; case BOSS_ZURAMAT: HandleGameObject(uiZuramatCell,bForceRespawn); - if (pBoss = instance->GetCreature(uiZuramat)) + pBoss = instance->GetCreature(uiZuramat); + if (pBoss) pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE); break; } diff --git a/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp b/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp index c4fe561a3aa..14bf249c3b5 100644 --- a/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp +++ b/src/scripts/outland/auchindoun/shadow_labyrinth/boss_murmur.cpp @@ -88,7 +88,7 @@ struct boss_murmurAI : public ScriptedAI // Sonic Boom instant damage (needs core fix instead of this) void SpellHitTarget(Unit *pTarget, const SpellEntry *spell) { - if (pTarget && pTarget->isAlive() && spell && spell->Id == SPELL_SONIC_BOOM_EFFECT) + if (pTarget && pTarget->isAlive() && spell && spell->Id == uint32(SPELL_SONIC_BOOM_EFFECT)) me->DealDamage(pTarget,(pTarget->GetHealth()*90)/100,NULL,SPELL_DIRECT_DAMAGE,SPELL_SCHOOL_MASK_NATURE,spell); } diff --git a/src/scripts/outland/black_temple/illidari_council.cpp b/src/scripts/outland/black_temple/illidari_council.cpp index cb3ac18be70..82cc2876b5a 100644 --- a/src/scripts/outland/black_temple/illidari_council.cpp +++ b/src/scripts/outland/black_temple/illidari_council.cpp @@ -220,15 +220,16 @@ struct mob_illidari_councilAI : public ScriptedAI Creature* pMember = NULL; for (uint8 i = 0; i < 4; ++i) { - if (pMember = (Unit::GetCreature((*me), Council[i]))) + pMember = Unit::GetCreature((*me), Council[i]); + if (!pMember) + continue; + + if (!pMember->isAlive()) { - if (!pMember->isAlive()) - { - pMember->RemoveCorpse(); - pMember->Respawn(); - } - pMember->AI()->EnterEvadeMode(); + pMember->RemoveCorpse(); + pMember->Respawn(); } + pMember->AI()->EnterEvadeMode(); } if (pInstance) diff --git a/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp b/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp index 0df1e2b5653..61c9ed9d527 100644 --- a/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp +++ b/src/scripts/outland/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp @@ -204,7 +204,7 @@ struct boss_leotheras_the_blindAI : public ScriptedAI pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, NOT_STARTED); } - void CheckChannelers(bool DoEvade = true) + void CheckChannelers(/*bool DoEvade = true*/) { for (uint8 i = 0; i < 3; ++i) { @@ -646,7 +646,7 @@ struct mob_greyheart_spellbinderAI : public ScriptedAI pInstance->SetData64(DATA_LEOTHERAS_EVENT_STARTER, 0); Creature *leotheras = Unit::GetCreature(*me, leotherasGUID); if (leotheras && leotheras->isAlive()) - CAST_AI(boss_leotheras_the_blindAI, leotheras->AI())->CheckChannelers(false); + CAST_AI(boss_leotheras_the_blindAI, leotheras->AI())->CheckChannelers(/*false*/); } } diff --git a/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp b/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp index 649f0382468..181911f77a4 100644 --- a/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp +++ b/src/scripts/outland/hellfire_citadel/hellfire_ramparts/boss_vazruden_the_herald.cpp @@ -98,7 +98,7 @@ struct boss_nazanAI : public ScriptedAI void SpellHitTarget(Unit *pTarget, const SpellEntry* entry) { - if (pTarget && entry->Id == SPELL_FIREBALL) + if (pTarget && entry->Id == uint32(SPELL_FIREBALL)) me->SummonCreature(ENTRY_LIQUID_FIRE,pTarget->GetPositionX(),pTarget->GetPositionY(),pTarget->GetPositionZ(),pTarget->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,30000); } @@ -260,13 +260,18 @@ struct boss_vazruden_the_heraldAI : public ScriptedAI if (summoned) { Creature *Nazan = Unit::GetCreature(*me, NazanGUID); - Creature *Vazruden = Unit::GetCreature(*me, VazrudenGUID); - if (Nazan || (Nazan = me->FindNearestCreature(ENTRY_NAZAN, 5000))) + if (!Nazan) + Nazan = me->FindNearestCreature(ENTRY_NAZAN, 5000); + if (Nazan) { Nazan->DisappearAndDie(); NazanGUID = 0; } - if (Vazruden || (Vazruden = me->FindNearestCreature(ENTRY_VAZRUDEN, 5000))) + + Creature *Vazruden = Unit::GetCreature(*me, VazrudenGUID); + if (!Vazruden) + Vazruden = me->FindNearestCreature(ENTRY_VAZRUDEN, 5000); + if (Vazruden) { Vazruden->DisappearAndDie(); VazrudenGUID = 0; diff --git a/src/scripts/world/go_scripts.cpp b/src/scripts/world/go_scripts.cpp index 4cc377984ad..28ba7b47e97 100644 --- a/src/scripts/world/go_scripts.cpp +++ b/src/scripts/world/go_scripts.cpp @@ -635,35 +635,37 @@ enum eJotunheimCage bool GOHello_go_jotunheim_cage(Player* pPlayer, GameObject* pGO) { - Creature* pPrisoner; - pPrisoner = NULL; - - if ((pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_HUMAN, 5.0f, true)) || - (pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_TROLL, 5.0f, true)) || - (pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_ORC, 5.0f, true)) || - (pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_NE, 5.0f, true))) + Creature* pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_HUMAN, 5.0f, true); + if (!pPrisoner) { - if (pPrisoner && pPrisoner->isAlive()) + pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_TROLL, 5.0f, true); + if (!pPrisoner) { - pPrisoner->DisappearAndDie(); - pPlayer->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN, 0); - switch(pPrisoner->GetEntry()) - { - case NPC_EBON_BLADE_PRISONER_HUMAN: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_H,true); - break; - case NPC_EBON_BLADE_PRISONER_NE: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_NE,true); - break; - case NPC_EBON_BLADE_PRISONER_TROLL: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_TROLL,true); - break; - case NPC_EBON_BLADE_PRISONER_ORC: - pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_ORC,true); - break; - } + pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_ORC, 5.0f, true); + if (!pPrisoner) + pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_NE, 5.0f, true); } } + if (!pPrisoner || !pPrisoner->isAlive()) + return false; + + pPrisoner->DisappearAndDie(); + pPlayer->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN, 0); + switch(pPrisoner->GetEntry()) + { + case NPC_EBON_BLADE_PRISONER_HUMAN: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_H,true); + break; + case NPC_EBON_BLADE_PRISONER_NE: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_NE,true); + break; + case NPC_EBON_BLADE_PRISONER_TROLL: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_TROLL,true); + break; + case NPC_EBON_BLADE_PRISONER_ORC: + pPlayer->CastSpell(pPlayer,SPELL_SUMMON_BLADE_KNIGHT_ORC,true); + break; + } return true; } enum eTableTheka @@ -758,14 +760,26 @@ enum ePrisonersOfWyrmskull bool GOHello_go_dragonflayer_cage(Player *pPlayer, GameObject *pGO) { - Creature *pPrisoner = NULL; - Quest const* qInfo = objmgr.GetQuestTemplate(QUEST_PRISONERS_OF_WYRMSKULL); + if (pPlayer->GetQuestStatus(QUEST_PRISONERS_OF_WYRMSKULL) != QUEST_STATUS_INCOMPLETE) + return true; + + Creature* pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PRIEST, 2.0f); + if (!pPrisoner) + { + pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_MAGE, 2.0f); + if (!pPrisoner) + { + pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_WARRIOR, 2.0f); + if (!pPrisoner) + pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PALADIN, 2.0f); + } + } + + if (!pPrisoner || !pPrisoner->isAlive()) + return true; - if (pPlayer->GetQuestStatus(QUEST_PRISONERS_OF_WYRMSKULL) == QUEST_STATUS_INCOMPLETE && - ((pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PRIEST,2.0f)) || - (pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_MAGE,2.0f)) || - (pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_WARRIOR,2.0f)) || - (pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PALADIN,2.0f))) && pPrisoner->isAlive()) + Quest const* qInfo = objmgr.GetQuestTemplate(QUEST_PRISONERS_OF_WYRMSKULL); + if (qInfo) { //TODO: prisoner should help player for a short period of time pPlayer->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0],0); @@ -787,15 +801,17 @@ enum eTadpoles bool GOHello_go_tadpole_cage(Player *pPlayer, GameObject *pGO) { - Creature *pTadpole; - if (pPlayer->GetQuestStatus(QUEST_OH_NOES_THE_TADPOLES) == QUEST_STATUS_INCOMPLETE && - (pTadpole = pGO->FindNearestCreature(NPC_WINTERFIN_TADPOLE,1.0f))) + if (pPlayer->GetQuestStatus(QUEST_OH_NOES_THE_TADPOLES) == QUEST_STATUS_INCOMPLETE) + { + Creature *pTadpole = pGO->FindNearestCreature(NPC_WINTERFIN_TADPOLE,1.0f); + if (pTadpole) { pGO->UseDoorOrButton(); pTadpole->DisappearAndDie(); pPlayer->KilledMonsterCredit(NPC_WINTERFIN_TADPOLE,0); //FIX: Summon minion tadpole } + } return true; } @@ -814,14 +830,18 @@ enum eReallyDoneItThisTime bool GOHello_go_black_cage(Player *pPlayer, GameObject *pGO) { - Creature *pPrisoner; - if (((pPlayer->GetTeamId() == TEAM_ALLIANCE && pPlayer->GetQuestStatus(QUEST_ALLIANCE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE) || - (pPlayer->GetTeamId() == TEAM_HORDE && pPlayer->GetQuestStatus(QUEST_HORDE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE)) && - ((pPrisoner = pGO->FindNearestCreature(NPC_CAPTIVE_ASPIRANT,1.0f)) || (pPrisoner = pGO->FindNearestCreature(NPC_KUL,1.0f)))) + if ((pPlayer->GetTeamId() == TEAM_ALLIANCE && pPlayer->GetQuestStatus(QUEST_ALLIANCE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE) || + (pPlayer->GetTeamId() == TEAM_HORDE && pPlayer->GetQuestStatus(QUEST_HORDE_YOU_VE_REALLY_DONE_IT_THIS_TIME_KUL) == QUEST_STATUS_INCOMPLETE)) { - pGO->UseDoorOrButton(); - pPrisoner->DisappearAndDie(); - pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); + Creature *pPrisoner = pGO->FindNearestCreature(NPC_CAPTIVE_ASPIRANT,1.0f); + if (!pPrisoner) + pPrisoner = pGO->FindNearestCreature(NPC_KUL,1.0f); + if (pPrisoner) + { + pGO->UseDoorOrButton(); + pPrisoner->DisappearAndDie(); + pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); + } } return true; } @@ -893,14 +913,13 @@ enum eProphecy bool GOHello_go_stillpine_cage(Player *pPlayer, GameObject *pGO) { - Creature *pPrisoner; - if (pPlayer->GetQuestStatus(QUEST_PROPHECY_OF_AKIDA) == QUEST_STATUS_INCOMPLETE && - (pPrisoner = pGO->FindNearestCreature(NPC_STILLPINE_CAPTIVE,1.0f))) - { - pGO->UseDoorOrButton(); - pPrisoner->DisappearAndDie(); - pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); - } + if (pPlayer->GetQuestStatus(QUEST_PROPHECY_OF_AKIDA) == QUEST_STATUS_INCOMPLETE) + if (Creature *pPrisoner = pGO->FindNearestCreature(NPC_STILLPINE_CAPTIVE,1.0f)) + { + pGO->UseDoorOrButton(); + pPrisoner->DisappearAndDie(); + pPlayer->KilledMonsterCredit(pPrisoner->GetEntry(),0); + } return true; } diff --git a/src/scripts/world/item_scripts.cpp b/src/scripts/world/item_scripts.cpp index 85866c0ed43..241f6020caa 100644 --- a/src/scripts/world/item_scripts.cpp +++ b/src/scripts/world/item_scripts.cpp @@ -253,36 +253,40 @@ enum ePileFakeFur GO_HIGH_QUALITY_FUR = 187983, NPC_NESINGWARY_TRAPPER = 25835 }; + +#define CaribouTrapsNum 15 +const uint32 CaribouTraps[CaribouTrapsNum] = +{ + GO_CARIBOU_TRAP_1, GO_CARIBOU_TRAP_2, GO_CARIBOU_TRAP_3, GO_CARIBOU_TRAP_4, GO_CARIBOU_TRAP_5, + GO_CARIBOU_TRAP_6, GO_CARIBOU_TRAP_7, GO_CARIBOU_TRAP_8, GO_CARIBOU_TRAP_9, GO_CARIBOU_TRAP_10, + GO_CARIBOU_TRAP_11, GO_CARIBOU_TRAP_12, GO_CARIBOU_TRAP_13, GO_CARIBOU_TRAP_14, GO_CARIBOU_TRAP_15, +}; + + bool ItemUse_item_pile_fake_furs(Player *pPlayer, Item * /*pItem*/, SpellCastTargets const & /*targets*/) { - GameObject *pGo; - if ((pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_1, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_2, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_3, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_4, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_5, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_6, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_7, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_8, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_9, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_10, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_11, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_12, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_13, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_14, 5.0f)) || - (pGo = pPlayer->FindNearestGameObject(GO_CARIBOU_TRAP_15, 5.0f))) + GameObject *pGo = NULL; + for (uint8 i = 0; i < CaribouTrapsNum; ++i) { - if (pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || pGo->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f)) - return true; - float x, y, z; - pGo->GetClosePoint(x, y, z, pGo->GetObjectSize() / 3, 7.0f); - pGo->SummonGameObject(GO_HIGH_QUALITY_FUR, pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), 0, 0, 0, 0, 0, 1000); - if (TempSummon* summon = pPlayer->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, pGo->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000)) - { - summon->SetVisibility(VISIBILITY_OFF); - summon->SetReactState(REACT_PASSIVE); - summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); - } + pGo = pPlayer->FindNearestGameObject(CaribouTraps[i], 5.0f); + if (pGo) + break; + } + + if (!pGo) + return false; + + if (pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, true) || pGo->FindNearestCreature(NPC_NESINGWARY_TRAPPER, 10.0f, false) || pGo->FindNearestGameObject(GO_HIGH_QUALITY_FUR, 2.0f)) + return true; + + float x, y, z; + pGo->GetClosePoint(x, y, z, pGo->GetObjectSize() / 3, 7.0f); + pGo->SummonGameObject(GO_HIGH_QUALITY_FUR, pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), 0, 0, 0, 0, 0, 1000); + if (TempSummon* summon = pPlayer->SummonCreature(NPC_NESINGWARY_TRAPPER, x, y, z, pGo->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 1000)) + { + summon->SetVisibility(VISIBILITY_OFF); + summon->SetReactState(REACT_PASSIVE); + summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); } return false; } @@ -348,41 +352,38 @@ enum eHelpThemselves GO_MAMMOTH_TRAP_22 = 188044, }; +#define MammothTrapsNum 22 +const uint32 MammothTraps[MammothTrapsNum] = +{ + GO_MAMMOTH_TRAP_1, GO_MAMMOTH_TRAP_2, GO_MAMMOTH_TRAP_3, GO_MAMMOTH_TRAP_4, GO_MAMMOTH_TRAP_5, + GO_MAMMOTH_TRAP_6, GO_MAMMOTH_TRAP_7, GO_MAMMOTH_TRAP_8, GO_MAMMOTH_TRAP_9, GO_MAMMOTH_TRAP_10, + GO_MAMMOTH_TRAP_11, GO_MAMMOTH_TRAP_12, GO_MAMMOTH_TRAP_13, GO_MAMMOTH_TRAP_14, GO_MAMMOTH_TRAP_15, + GO_MAMMOTH_TRAP_16, GO_MAMMOTH_TRAP_17, GO_MAMMOTH_TRAP_18, GO_MAMMOTH_TRAP_19, GO_MAMMOTH_TRAP_20, + GO_MAMMOTH_TRAP_21, GO_MAMMOTH_TRAP_22 +}; + bool ItemUse_item_dehta_trap_smasher(Player* pPlayer, Item* /*pItem*/, const SpellCastTargets & /*pTargets*/) { + if (pPlayer->GetQuestStatus(QUEST_CANNOT_HELP_THEMSELVES) != QUEST_STATUS_INCOMPLETE) + return false; + Creature* pMammoth; - GameObject* pTrap; + pMammoth = pPlayer->FindNearestCreature(NPC_TRAPPED_MAMMOTH_CALF,5.0f); + if (!pMammoth) + return false; - if (pPlayer->GetQuestStatus(QUEST_CANNOT_HELP_THEMSELVES) == QUEST_STATUS_INCOMPLETE && - (pMammoth = pPlayer->FindNearestCreature(NPC_TRAPPED_MAMMOTH_CALF,5.0f)) && - ((pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_1,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_2,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_3,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_4,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_5,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_6,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_7,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_8,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_9,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_10,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_11,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_12,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_13,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_14,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_15,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_16,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_17,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_18,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_19,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_20,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_21,5.0f)) || - (pTrap = pPlayer->FindNearestGameObject(GO_MAMMOTH_TRAP_22,5.0f)))) + GameObject* pTrap; + for (uint8 i = 0; i < MammothTrapsNum; ++i) { - pMammoth->AI()->DoAction(1); - pTrap->SetGoState(GO_STATE_READY); - pPlayer->KilledMonsterCredit(NPC_TRAPPED_MAMMOTH_CALF,0); - } - + pTrap = pPlayer->FindNearestGameObject(MammothTraps[i],11.0f); + if (pTrap) + { + pMammoth->AI()->DoAction(1); + pTrap->SetGoState(GO_STATE_READY); + pPlayer->KilledMonsterCredit(NPC_TRAPPED_MAMMOTH_CALF,0); + return true; + } + } return false; } |