[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
+3 -3
View File
@@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`required_8050_02_mangos_spell_bonus_data` bit(1) default NULL
`required_8053_01_mangos_command` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@@ -460,12 +460,12 @@ INSERT INTO `command` VALUES
('reload config',3,'Syntax: .reload config\r\n\r\nReload config settings (by default stored in mangosd.conf). Not all settings can be change at reload: some new setting values will be ignored until restart, some values will applied with delay or only to new objects/maps, some values will explicitly rejected to change at reload.'),
('repairitems',2,'Syntax: .repairitems\r\n\r\nRepair all selected player''s items.'),
('reset achievements',3,'Syntax: .reset achievements [$playername]\r\n\r\nReset achievements data for selected or named (online or offline) character. Achievements for persistance progress data like completed quests/etc re-filled at reset. Achievements for events like kills/casts/etc will lost.'),
('reset all',3,'Syntax: .reset all spells\r\n\r\nSyntax: .reset all talents\r\n\r\nRequest reset spells or talents at next login each existed character.'),
('reset all',3,'Syntax: .reset all spells\r\n\r\nSyntax: .reset all talents\r\n\r\nRequest reset spells or talents (including talents for all character\'s pets if any) at next login each existed character.'),
('reset honor',3,'Syntax: .reset honor [Playername]\r\n Reset all honor data for targeted character.'),
('reset level',3,'Syntax: .reset level [Playername]\r\n Reset level to 1 including reset stats and talents. Equipped items with greater level requirement can be lost.'),
('reset spells',3,'Syntax: .reset spells [Playername]\r\n Removes all non-original spells from spellbook.\r\n. Playername can be name of offline character.'),
('reset stats',3,'Syntax: .reset stats [Playername]\r\n Resets(recalculate) all stats of the targeted player to their original VALUESat current level.'),
('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents of the targeted player. Playername can be name of offline character.'),
('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents of the targeted player or pet or named player. Playername can be name of offline character. With player talents also will be reset talents for all character\'s pets if any.'),
('respawn',3,'Syntax: .respawn\r\n\r\nRespawn selected creature or respawn all nearest creatures (if none selected) and GO without waiting respawn time expiration.'),
('revive',3,'Syntax: .revive\r\n\r\nRevive the selected player. If no player is selected, it will revive you.'),
('save',0,'Syntax: .save\r\n\r\nSaves your character.'),
+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());