Core/SmartScripts: SMART_ACTION_TALK - added action param 3 to set target as talk target (used for $vars in texts and whisper target)

* by default (action param 3 is 0), it will try to trigger talk of the target

(cherry picked from commit 7b491046e9)
This commit is contained in:
MitchesD
2015-08-14 22:50:28 +02:00
parent 1403d5d0bb
commit 02d014c69d
2 changed files with 9 additions and 3 deletions

View File

@@ -123,13 +123,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
ObjectList* targets = GetTargets(e, unit);
Creature* talker = me;
Player* targetPlayer = NULL;
Unit* talkTarget = NULL;
if (targets)
{
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
if (IsCreature(*itr) && !(*itr)->ToCreature()->IsPet()) // Prevented sending text to pets.
{
talker = (*itr)->ToCreature();
if (e.action.talk.useTalkTarget)
talkTarget = (*itr)->ToCreature();
else
talker = (*itr)->ToCreature();
break;
}
else if (IsPlayer(*itr))
@@ -148,7 +153,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
mTalkerEntry = talker->GetEntry();
mLastTextID = e.action.talk.textGroupID;
mTextTimer = e.action.talk.duration;
Unit* talkTarget = NULL;
if (IsPlayer(GetLastInvoker())) // used for $vars in texts and whisper target
talkTarget = GetLastInvoker();
else if (targetPlayer)

View File

@@ -426,7 +426,7 @@ enum SMART_SCRIPT_RESPAWN_CONDITION
enum SMART_ACTION
{
SMART_ACTION_NONE = 0, // No action
SMART_ACTION_TALK = 1, // groupID from creature_text, duration to wait before TEXT_OVER event is triggered
SMART_ACTION_TALK = 1, // groupID from creature_text, duration to wait before TEXT_OVER event is triggered, useTalkTarget (0/1) - use target as talk target
SMART_ACTION_SET_FACTION = 2, // FactionId (or 0 for default)
SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL = 3, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to demorph)
SMART_ACTION_SOUND = 4, // SoundId, onlySelf
@@ -553,6 +553,7 @@ struct SmartAction
{
uint32 textGroupID;
uint32 duration;
uint32 useTalkTarget;
} talk;
struct