Skip to content

Instantly share code, notes, and snippets.

@DDuarte
Created October 30, 2011 14:28
Show Gist options
  • Save DDuarte/1325955 to your computer and use it in GitHub Desktop.
Save DDuarte/1325955 to your computer and use it in GitHub Desktop.
From 0b51b4ef0aad33f4c87d4d58c882fe039aedfb2b Mon Sep 17 00:00:00 2001
From: Nay <dnpd.dd@gmail.com>
Date: Sun, 30 Oct 2011 14:26:49 +0000
Subject: [PATCH] Core/SAI: SMART_ACTION_TALK, if our action target is a
player, use its guid as whisperGuid (used in whispers and
in text $vars)
---
src/server/game/AI/SmartScripts/SmartScript.cpp | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 6c2b8fe..353c97e 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -140,6 +140,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
ObjectList* targets = GetTargets(e, unit);
Creature* talker = me;
+ Player* targetPlayer;
if (targets)
{
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
@@ -149,14 +150,26 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
talker = (*itr)->ToCreature();
break;
}
+ else if (IsPlayer((*itr)))
+ {
+ targetPlayer = (*itr)->ToPlayer();
+ break;
+ }
}
delete targets;
}
+
mTalkerEntry = talker->GetEntry();
mLastTextID = e.action.talk.textGroupID;
mTextTimer = e.action.talk.duration;
- mTextGUID = IsPlayer(GetLastInvoker()) ? GetLastInvoker()->GetGUID() : 0;//invoker, used for $vars in texts
+ if (IsPlayer(GetLastInvoker())) // used for $vars in texts and whisper target
+ mTextGUID = GetLastInvoker()->GetGUID();
+ else if (targetPlayer)
+ mTextGUID = targetPlayer->GetGUID();
+ else
+ mTextGUID = 0;
+
mUseTextTimer = true;
sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), mTextGUID);
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: %s (GuidLow: %u), textGuid: %u",
--
1.7.6.msysgit.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment