diff options
author | megamage <none@none> | 2009-06-27 15:37:33 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-06-27 15:37:33 -0500 |
commit | fe89fbfbdb00ab6e71a9a0ba00b4cc7d803dda0e (patch) | |
tree | bac9bd2c19018c4c5bc8be9cf13504aa79a5c7ca /src | |
parent | d401ede8f24fe8f733357c742e861b453c1794f8 (diff) |
[8057] Move code from Event AI to class Creature function for reuse in other scripting cases. Author: NoFantasy
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Creature.cpp | 37 | ||||
-rw-r--r-- | src/game/Creature.h | 2 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 11 | ||||
-rw-r--r-- | src/game/Level3.cpp | 1 | ||||
-rw-r--r-- | src/game/Pet.cpp | 13 |
5 files changed, 56 insertions, 8 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 50fa95337f6..c8dcd0d2414 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -2262,6 +2262,43 @@ void Creature::SendZoneUnderAttackMessage(Player* attacker) sWorld.SendGlobalMessage(&data,NULL,(enemy_team==ALLIANCE ? HORDE : ALLIANCE)); } +void Creature::SetInCombatWithZone() +{ + if (!CanHaveThreatList()) + { + error_log("Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry()); + return; + } + + Map* pMap = GetMap(); + + if (!pMap->IsDungeon()) + { + error_log("Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), pMap->GetId()); + return; + } + + Map::PlayerList const &PlList = pMap->GetPlayers(); + + if (PlList.isEmpty()) + return; + + for(Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) + { + if (Player* pPlayer = i->getSource()) + { + if (pPlayer->isGameMaster()) + continue; + + if (pPlayer->isAlive()) + { + pPlayer->SetInCombatWith(this); + AddThreat(pPlayer, 0.0f); + } + } + } +} + void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time) { m_CreatureSpellCooldowns[spell_id] = end_time; diff --git a/src/game/Creature.h b/src/game/Creature.h index d0bd7c7261f..4f749eec78c 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -692,6 +692,8 @@ class TRINITY_DLL_SPEC Creature : public Unit void SendZoneUnderAttackMessage(Player* attacker); + void SetInCombatWithZone(); + bool hasQuest(uint32 quest_id) const; bool hasInvolvedQuest(uint32 quest_id) const; diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 0393c30e7d3..c6fa47aaeac 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -746,15 +746,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); break; case ACTION_T_ZONE_COMBAT_PULSE: - if (!m_creature->isInCombat() || !m_creature->GetMap()->IsDungeon()) - { - - sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_ZONE_COMBAT_PULSE on creature out of combat or in non-dungeon map. Creature %d", EventId, m_creature->GetEntry()); - return; - } - - DoZoneInCombat(m_creature); + { + m_creature->SetInCombatWithZone(); break; + } case ACTION_T_CALL_FOR_HELP: { m_creature->CallForHelp(action.call_for_help.radius); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 6c5114420a7..647919379d8 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -5387,6 +5387,7 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args) } return true; } + SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); return false; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 3eb12b190bd..c116a22b9f6 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1602,13 +1602,18 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) do { Field *fields = resultPets->Fetch(); + uint32 id = fields[0].GetUInt32(); + if(need_comma) ss << ","; + ss << id; + need_comma = true; } while( resultPets->NextRow() ); + delete resultPets; ss << ") AND spell IN ("; @@ -1617,18 +1622,26 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) do { Field *fields = result->Fetch(); + uint32 spell = fields[0].GetUInt32(); + if(!GetTalentSpellCost(spell)) continue; + if(need_execute) ss << ","; + ss << spell; + need_execute = true; } while( result->NextRow() ); + delete result; + if(!need_execute) return; + ss << ")"; CharacterDatabase.Execute(ss.str().c_str()); |