aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp53
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h4
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp10
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h11
4 files changed, 38 insertions, 40 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index d4161a13ec8..d26918f6876 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -47,6 +47,7 @@ SmartScript::SmartScript()
mLastTextID = 0;
mTextGUID = 0;
mUseTextTimer = false;
+ talker = NULL;
mTemplate = SMARTAI_TEMPLATE_BASIC;
meOrigGUID = 0;
goOrigGUID = 0;
@@ -101,18 +102,28 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
switch (e.GetActionType())
{
case SMART_ACTION_TALK:
- if (!me) return;
- mLastTextID = e.action.talk.textGroupID1;
- mTextTimer = sCreatureTextMgr.SendChat(me, uint8(e.action.talk.textGroupID1), IsPlayer(unit)? unit->GetGUID() : NULL);
- mTextGUID = IsPlayer(unit)? unit->GetGUID() : NULL;
- if (e.action.talk.textGroupID2) mTextIDs.push_back(e.action.talk.textGroupID2);
- if (e.action.talk.textGroupID3) mTextIDs.push_back(e.action.talk.textGroupID3);
- if (e.action.talk.textGroupID4) mTextIDs.push_back(e.action.talk.textGroupID4);
- if (e.action.talk.textGroupID5) mTextIDs.push_back(e.action.talk.textGroupID5);
- if (e.action.talk.textGroupID6) mTextIDs.push_back(e.action.talk.textGroupID6);
- if (!mTextIDs.empty())
+ {
+ ObjectList* targets = GetTargets(e, unit);
+ talker = me;
+ if (targets)
+ {
+ for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); itr++)
+ {
+ if (IsCreature((*itr)))
+ {
+ talker = (*itr)->ToCreature();
+ break;
+ }
+ }
+ }
+ mLastTextID = e.action.talk.textGroupID;
+ mTextTimer = e.action.talk.duration;
+ mTextGUID = IsPlayer(unit)? unit->GetGUID() : NULL;//invoker, used for $vars in texts
mUseTextTimer = true;
- break;
+ sCreatureTextMgr.SendChat(talker, uint8(e.action.talk.textGroupID), mTextGUID);
+ return;
+ break;
+ }
case SMART_ACTION_PLAY_EMOTE:
if (me)
me->HandleEmoteCommand(e.action.emote.emote);
@@ -1605,7 +1616,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder &e, Unit* unit, uint32 var0, ui
}
case SMART_EVENT_TEXT_OVER:
{
- if (e.event.textOver.textGroupID && var0 != e.event.textOver.textGroupID)
+ if (var0 != e.event.textOver.textGroupID || (e.event.textOver.creatureEntry && e.event.textOver.creatureEntry != var1))
return;
ProcessAction(e, unit, var0);
break;
@@ -1743,17 +1754,13 @@ void SmartScript::OnUpdate(const uint32 diff)
{
if (mTextTimer < diff)
{
- ProcessEventsFor(SMART_EVENT_TEXT_OVER, NULL, mLastTextID);
- if (!mTextIDs.empty())
- {
- mLastTextID = (*mTextIDs.begin());
- mTextIDs.erase(mTextIDs.begin());
- mTextTimer = sCreatureTextMgr.SendChat(me, (uint8)mLastTextID, mTextGUID);
- }else{
- mLastTextID = 0;
- mTextTimer = 0;
- mUseTextTimer = false;
- }
+ uint32 temp = mLastTextID;
+ mLastTextID = 0;
+ mTextTimer = 0;
+ mUseTextTimer = false;
+ uint32 tempEntry = talker?talker->GetEntry():0;
+ talker = NULL;
+ ProcessEventsFor(SMART_EVENT_TEXT_OVER, NULL, temp, tempEntry);
} else mTextTimer -= diff;
}
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index 85bd5a7faa1..89f2f2c5a45 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -153,7 +153,6 @@ class SmartScript
}
ObjectListMap* mTargetStorage;
- void ResetTexts() { mTextIDs.clear(); }
void OnReset();
void ResetBaseObject()
@@ -205,11 +204,12 @@ class SmartScript
SmartAIEventList mStoredEvents;
std::list<uint32>mRemIDs;
- std::vector<uint32>mTextIDs;
uint32 mTextTimer;
uint32 mLastTextID;
uint64 mTextGUID;
+ Creature* talker;
bool mUseTextTimer;
+
SMARTAI_TEMPLATE mTemplate;
void InstallEvents();
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 111805a1dba..70adaf864b9 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -426,7 +426,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder e)
break;
}
case SMART_EVENT_TEXT_OVER:
- if (e.event.textOver.textGroupID && !IsTextValid(e, e.event.textOver.textGroupID)) return false;
+ //if (e.event.textOver.textGroupID && !IsTextValid(e, e.event.textOver.textGroupID)) return false;// 0 is a valid text group!
break;
case SMART_EVENT_LINK:
{
@@ -476,13 +476,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder e)
switch (e.GetActionType())
{
case SMART_ACTION_TALK:
- if (!IsTextValid(e, e.action.talk.textGroupID1)) return false;
- if (e.action.talk.textGroupID2 && !IsTextValid(e, e.action.talk.textGroupID2)) return false;
- if (e.action.talk.textGroupID3 && !IsTextValid(e, e.action.talk.textGroupID3)) return false;
- if (e.action.talk.textGroupID4 && !IsTextValid(e, e.action.talk.textGroupID4)) return false;
- if (e.action.talk.textGroupID5 && !IsTextValid(e, e.action.talk.textGroupID5)) return false;
- if (e.action.talk.textGroupID6 && !IsTextValid(e, e.action.talk.textGroupID6)) return false;
-
+ //if (!IsTextValid(e, e.action.talk.textGroupID)) return false;//can use other creatures texts too!
break;
case SMART_ACTION_SET_FACTION:
if (e.action.faction.factionID && !sFactionStore.LookupEntry(e.action.faction.factionID))
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 885bdd42fd3..b8244f60f6b 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -136,7 +136,7 @@ enum SMART_EVENT
SMART_EVENT_QUEST_COMPLETION = 49, //1 // none
SMART_EVENT_QUEST_REWARDED = 50, //1 // none
SMART_EVENT_QUEST_FAIL = 51, //1 // none
- SMART_EVENT_TEXT_OVER = 52, //1 // GroupId from creature_text (0 any)
+ SMART_EVENT_TEXT_OVER = 52, //1 // GroupId from creature_text, creature entry who talks (0 any)
SMART_EVENT_RECEIVE_HEAL = 53, //1 // MinHeal, MaxHeal, CooldownMin, CooldownMax
SMART_EVENT_JUST_SUMMONED = 54, //1 // none
SMART_EVENT_WAYPOINT_PAUSED = 55, //1 // PointId(0any), pathID(0any)
@@ -310,6 +310,7 @@ struct SmartEvent
struct
{
uint32 textGroupID;
+ uint32 creatureEntry;
} textOver;
struct
@@ -436,12 +437,8 @@ struct SmartAction
{
struct
{
- uint32 textGroupID1;
- uint32 textGroupID2;
- uint32 textGroupID3;
- uint32 textGroupID4;
- uint32 textGroupID5;
- uint32 textGroupID6;
+ uint32 textGroupID;
+ uint32 duration;
} talk;
struct