[8057] Move code from Event AI to class Creature function for reuse in other scripting cases. Author: NoFantasy

--HG--
branch : trunk
This commit is contained in:
megamage
2009-06-27 15:37:33 -05:00
parent d401ede8f2
commit fe89fbfbdb
6 changed files with 59 additions and 11 deletions
+37
View File
@@ -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;
+2
View File
@@ -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;
+3 -8
View File
@@ -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);
+1
View File
@@ -5387,6 +5387,7 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
}
return true;
}
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
+13
View File
@@ -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());