diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/ScriptMgr.cpp | 146 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/creature/mob_event_ai.cpp | 117 | ||||
-rw-r--r-- | src/bindings/scripts/scripts/creature/mob_event_ai.h | 2 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 3 |
4 files changed, 236 insertions, 32 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index 4920b5f99a3..f6e450283ab 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -902,6 +902,18 @@ void LoadDatabase() outstring_log(">> Loaded 0 EventAI Summon definitions. DB table `eventai_summons` is empty."); } + //Drop Existing EventAI List + EventAI_Event_List.clear(); + uint64 uiEAICreatureCount = 0; + + result = TScriptDB.PQuery("SELECT COUNT(creature_id) FROM eventai_scripts GROUP BY creature_id"); + if (result) + { + uiEAICreatureCount = result->GetRowCount(); + delete result; + } + + //Gather event data result = TScriptDB.PQuery("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, " "event_param1, event_param2, event_param3, event_param4, " @@ -910,10 +922,7 @@ void LoadDatabase() "action3_type, action3_param1, action3_param2, action3_param3 " "FROM eventai_scripts"); - //Drop Existing EventAI List - EventAI_Event_List.clear(); - - outstring_log("TSCR: Loading EventAI scripts..."); + outstring_log("SD2: Loading EventAI scripts for %u creature(s)...", uiEAICreatureCount); if (result) { barGoLink bar(result->GetRowCount()); @@ -940,11 +949,17 @@ void LoadDatabase() //Creature does not exist in database if (!GetCreatureTemplateStore(temp.creature_id)) + { error_db_log("TSCR: Event %u has script for non-existing creature.", i); + continue; + } //Report any errors in event if (temp.event_type >= EVENT_T_END) + { error_db_log("TSCR: Event %u has incorrect event type. Maybe DB requires updated version of SD2.", i); + continue; + } //No chance of this event occuring if (temp.event_chance == 0) @@ -1025,8 +1040,19 @@ void LoadDatabase() case EVENT_T_RANGE: case EVENT_T_FRIENDLY_HP: case EVENT_T_FRIENDLY_IS_CC: + { + if (temp.event_param4 < temp.event_param3) + error_db_log("SD2: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } + break; case EVENT_T_FRIENDLY_MISSING_BUFF: { + if (!GetSpellStore()->LookupEntry(temp.event_param1)) + { + error_db_log("SD2: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.event_param1, i); + continue; + } + if (temp.event_param4 < temp.event_param3) error_db_log("TSCR: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } @@ -1051,6 +1077,16 @@ void LoadDatabase() } break; + case EVENT_T_SUMMONED_UNIT: + { + if (!GetCreatureTemplateStore(temp.event_param1)) + { + error_db_log("SD2: Creature %u has non-existant creature entry (%u) defined in event %u.", temp.creature_id, temp.event_param1, i); + continue; + } + } + break; + case EVENT_T_AGGRO: case EVENT_T_DEATH: case EVENT_T_EVADE: @@ -1063,6 +1099,108 @@ void LoadDatabase() } } break; + + case EVENT_T_RECEIVE_EMOTE: + { + //no good way to check for valid textEmote (enum TextEmotes) + + switch(temp.event_param2) + { + case CONDITION_AURA: + if (!GetSpellStore()->LookupEntry(temp.event_param3)) + { + error_db_log("SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid.",temp.creature_id, i, temp.event_param3); + continue; + } + break; + case CONDITION_TEAM: + if (temp.event_param3 != HORDE || temp.event_param3 != ALLIANCE) + { + error_db_log("SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid.",temp.creature_id, i, temp.event_param3); + continue; + } + break; + case CONDITION_QUESTREWARDED: + case CONDITION_QUESTTAKEN: + if (!GetQuestTemplateStore(temp.event_param3)) + { + error_db_log("SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid.",temp.creature_id, i, temp.event_param3); + continue; + } + break; + case CONDITION_ACTIVE_EVENT: + if (temp.event_param3 != + (HOLIDAY_FIREWORKS_SPECTACULAR | HOLIDAY_FEAST_OF_WINTER_VEIL | HOLIDAY_NOBLEGARDEN | + HOLIDAY_CHILDRENS_WEEK | HOLIDAY_CALL_TO_ARMS_AV | HOLIDAY_CALL_TO_ARMS_WG | + HOLIDAY_CALL_TO_ARMS_AB | HOLIDAY_FISHING_EXTRAVAGANZA | HOLIDAY_HARVEST_FESTIVAL | + HOLIDAY_HALLOWS_END | HOLIDAY_LUNAR_FESTIVAL | HOLIDAY_LOVE_IS_IN_THE_AIR | + HOLIDAY_FIRE_FESTIVAL | HOLIDAY_CALL_TO_ARMS_ES | HOLIDAY_BREWFEST | + HOLIDAY_DARKMOON_FAIRE_ELWYNN | HOLIDAY_DARKMOON_FAIRE_THUNDER | HOLIDAY_DARKMOON_FAIRE_SHATTRATH | + HOLIDAY_CALL_TO_ARMS_SA | HOLIDAY_WOTLK_LAUNCH)) + { + error_db_log("SD2: Creature %u using event %u: param3 (CondValue1: %u) are not valid.",temp.creature_id, i, temp.event_param3); + continue; + } + break; + case CONDITION_REPUTATION_RANK: + if (!temp.event_param3) + { + error_db_log("SD2: Creature %u using event %u: param3 (CondValue1: %u) are missing.",temp.creature_id, i, temp.event_param3); + continue; + } + if (temp.event_param4 > REP_EXALTED) + { + error_db_log("SD2: Creature %u using event %u: param4 (CondValue2: %u) are not valid.",temp.creature_id, i, temp.event_param4); + continue; + } + break; + case CONDITION_ITEM: + case CONDITION_ITEM_EQUIPPED: + case CONDITION_SKILL: + if (!temp.event_param3) + { + error_db_log("SD2: Creature %u using event %u: param3 (CondValue1: %u) are missing.",temp.creature_id, i, temp.event_param3); + continue; + } + if (!temp.event_param4) + { + error_db_log("SD2: Creature %u using event %u: param4 (CondValue2: %u) are missing.",temp.creature_id, i, temp.event_param4); + continue; + } + break; + case CONDITION_ZONEID: + if (!temp.event_param3) + { + error_db_log("SD2: Creature %u using event %u: param3 (CondValue1: %u) are missing.",temp.creature_id, i, temp.event_param3); + continue; + } + break; + case CONDITION_NONE: + break; + default: + { + error_db_log("SD2: Creature %u using event %u: param2 (Condition: %u) are not valid/not implemented for script.",temp.creature_id, i, temp.event_param3); + continue; + } + } + + if (!(temp.event_flags & EFLAG_REPEATABLE)) + { + error_db_log("SD2: Creature %u using event %u: EFLAG_REPEATABLE not set. Event must always be repeatable. Flag applied.", temp.creature_id, i); + temp.event_flags |= EFLAG_REPEATABLE; + } + + } + break; + + case EVENT_T_QUEST_ACCEPT: + case EVENT_T_QUEST_COMPLETE: + { + error_db_log("SD2: Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i); + continue; + } + break; + } for (uint32 j = 0; j < MAX_ACTIONS; j++) diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index 15dfd922679..af5f47634e0 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "precompiled.h" #include "mob_event_ai.h" #include "ObjectMgr.h" +#include "GameEventMgr.h" #define EVENT_UPDATE_TIME 500 #define SPELL_RUN_AWAY 8225 @@ -459,6 +460,10 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI { } break; + case EVENT_T_RECEIVE_EMOTE: + { + } + break; default: if (EAI_ErrorLevel > 0) error_db_log("SD2: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); @@ -1373,11 +1378,11 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI } }; -CreatureAI* GetAI_Mob_EventAI(Creature *_Creature) +CreatureAI* GetAI_mob_eventai(Creature* pCreature) { //Select events by creature id std::list<EventHolder> EventList; - uint32 ID = _Creature->GetEntry(); + uint32 ID = pCreature->GetEntry(); std::list<EventAI_Event>::iterator i; @@ -1390,30 +1395,12 @@ CreatureAI* GetAI_Mob_EventAI(Creature *_Creature) if ((*i).event_flags & EFLAG_DEBUG_ONLY) continue; #endif - if( _Creature->GetMap()->IsDungeon() ) + if (pCreature->GetMap()->IsDungeon()) { - if( _Creature->GetMap()->IsHeroic() ) - { - if( (*i).event_flags & EFLAG_HEROIC ) - { - EventList.push_back(EventHolder(*i)); - continue; - }else if( (*i).event_flags & EFLAG_NORMAL ) - continue; - } - else - { - if( (*i).event_flags & EFLAG_NORMAL ) - { - EventList.push_back(EventHolder(*i)); - continue; - }else if( (*i).event_flags & EFLAG_HEROIC ) - continue; - } - - if (EAI_ErrorLevel > 1) + if ((pCreature->GetMap()->IsHeroic() && (*i).event_flags & EFLAG_HEROIC) || + (!pCreature->GetMap()->IsHeroic() && (*i).event_flags & EFLAG_NORMAL)) { - error_db_log("SD2: Creature %u Event %u. Creature are in instance but neither EFLAG_NORMAL or EFLAG_HEROIC are set.", _Creature->GetEntry(), (*i).event_id); + //event flagged for instance mode EventList.push_back(EventHolder(*i)); } @@ -1428,12 +1415,87 @@ CreatureAI* GetAI_Mob_EventAI(Creature *_Creature) if (EventList.empty()) { if (EAI_ErrorLevel > 1) - error_db_log("SD2: Eventlist for Creature %u is empty but creature is using Mob_EventAI. Preventing EventAI on this creature.", _Creature->GetEntry()); + error_db_log("SD2: Eventlist for Creature %u is empty but creature is using Mob_EventAI (missing instance mode flags?). Preventing EventAI on this creature.", pCreature->GetEntry()); return NULL; } - return new Mob_EventAI (_Creature, EventList); + return new Mob_EventAI(pCreature, EventList); +} + +bool ReceiveEmote_mob_eventai(Player* pPlayer, Creature* pCreature, uint32 uiEmote) +{ + Mob_EventAI* pTmpCreature = (Mob_EventAI*)(pCreature->AI()); + + if (pTmpCreature->EventList.empty()) + return true; + + for (std::list<EventHolder>::iterator itr = pTmpCreature->EventList.begin(); itr != pTmpCreature->EventList.end(); ++itr) + { + if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE) + { + if ((*itr).Event.event_param1 != uiEmote) + return true; + + bool bProcess = false; + + switch((*itr).Event.event_param2) + { + //enum ConditionType + case CONDITION_NONE: // 0 0 + bProcess = true; + break; + case CONDITION_AURA: // spell_id effindex + if (pPlayer->HasAura((*itr).Event.event_param3,(*itr).Event.event_param4)) + bProcess = true; + break; + case CONDITION_ITEM: // item_id count + if (pPlayer->HasItemCount((*itr).Event.event_param3,(*itr).Event.event_param4)) + bProcess = true; + break; + case CONDITION_ITEM_EQUIPPED: // item_id count + if (pPlayer->HasItemOrGemWithIdEquipped((*itr).Event.event_param3,(*itr).Event.event_param4)) + bProcess = true; + break; + case CONDITION_ZONEID: // zone_id 0 + if (pPlayer->GetZoneId() == (*itr).Event.event_param3) + bProcess = true; + break; + case CONDITION_REPUTATION_RANK: // faction_id min_rank + if (pPlayer->GetReputationRank((*itr).Event.event_param3) >= (*itr).Event.event_param4) + bProcess = true; + break; + case CONDITION_TEAM: // player_team 0, (469 - Alliance 67 - Horde) + if (pPlayer->GetTeam() == (*itr).Event.event_param3) + bProcess = true; + break; + case CONDITION_SKILL: // skill_id min skill_value + if (pPlayer->HasSkill((*itr).Event.event_param3) && pPlayer->GetSkillValue((*itr).Event.event_param3) >= (*itr).Event.event_param4) + bProcess = true; + break; + case CONDITION_QUESTREWARDED: // quest_id 0 + if (pPlayer->GetQuestRewardStatus((*itr).Event.event_param3)) + bProcess = true; + break; + case CONDITION_QUESTTAKEN: // quest_id 0, for condition true while quest active. + if (pPlayer->GetQuestStatus((*itr).Event.event_param3) == QUEST_STATUS_INCOMPLETE) + bProcess = true; + break; + case CONDITION_ACTIVE_EVENT: // event_id 0 + if (IsHolidayActive(HolidayIds((*itr).Event.event_param3))) + bProcess = true; + break; + } + + if (bProcess) + { + debug_log("SD2: ReceiveEmote EventAI: Condition ok, processing"); + pTmpCreature->ProcessEvent(*itr, pPlayer); + } + } + } + + return true; } void AddSC_mob_event() @@ -1441,7 +1503,8 @@ void AddSC_mob_event() Script *newscript; newscript = new Script; newscript->Name = "mob_eventai"; - newscript->GetAI = &GetAI_Mob_EventAI; + newscript->GetAI = &GetAI_mob_eventai; + newscript->pReceiveEmote = &ReceiveEmote_mob_eventai; newscript->RegisterSelf(); } diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.h b/src/bindings/scripts/scripts/creature/mob_event_ai.h index a9834a7d125..8793e143a87 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.h +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.h @@ -29,7 +29,9 @@ enum Event_Types EVENT_T_SUMMONED_UNIT = 17, //CreatureId, RepeatMin, RepeatMax EVENT_T_TARGET_MANA = 18, //ManaMax%, ManaMin%, RepeatMin, RepeatMax EVENT_T_QUEST_ACCEPT = 19, //QuestID + EVENT_T_QUEST_COMPLETE = 20, // EVENT_T_REACHED_HOME = 21, //NONE + EVENT_T_RECEIVE_EMOTE = 22, //EmoteId, Condition, CondValue1, CondValue2 EVENT_T_END, }; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 0a1b764a4d1..48555e6a0a4 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1623,7 +1623,8 @@ void Spell::EffectDummy(uint32 i) // Divine Storm if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) { - m_caster->CastCustomSpell(unitTarget, 54172, m_currentBasePoints[0] * damage /100, 0, 0, true); + int32 damage=m_currentBasePoints[0] * damage /100; + m_caster->CastCustomSpell(unitTarget, 54172, &damage , 0, 0, true); return; } case 156: // Holy Shock |