[7672] Move ReceiveEmote from script API to AI API.

This is also fix triggering ReceiveEmote for EventAI broken at it move to mangos sources.
This commit is contained in:
VladimirMangos 2009-04-15 06:06:42 +04:00
parent 5020fcd3f1
commit 78dd259c38
9 changed files with 17 additions and 30 deletions

View file

@ -235,15 +235,6 @@ bool AreaTrigger ( Player *player, AreaTriggerEntry* atEntry )
return tmpscript->pAreaTrigger(player, atEntry); return tmpscript->pAreaTrigger(player, atEntry);
} }
MANGOS_DLL_EXPORT
bool ReceiveEmote ( Player *player, Creature *_Creature, uint32 emote )
{
Script *tmpscript = m_scripts[_Creature->GetScriptId()];
if(!tmpscript || !tmpscript->pReceiveEmote) return false;
return tmpscript->pReceiveEmote(player,_Creature, emote);
}
MANGOS_DLL_EXPORT MANGOS_DLL_EXPORT
bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets) bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets)
{ {

View file

@ -41,7 +41,7 @@ struct Script
pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL), pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL),
pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL), pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL),
pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL), pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL),
pGOChooseReward(NULL), pReceiveEmote(NULL), pItemUse(NULL), pEffectDummyGameObj(NULL), pEffectDummyCreature(NULL), pGOChooseReward(NULL), pItemUse(NULL), pEffectDummyGameObj(NULL), pEffectDummyCreature(NULL),
pEffectDummyItem(NULL), GetAI(NULL) pEffectDummyItem(NULL), GetAI(NULL)
{} {}
@ -63,7 +63,6 @@ struct Script
bool (*pItemQuestAccept )(Player *player, Item *_Item, Quest const*_Quest ); bool (*pItemQuestAccept )(Player *player, Item *_Item, Quest const*_Quest );
bool (*pGOQuestAccept )(Player *player, GameObject *_GO, Quest const*_Quest ); bool (*pGOQuestAccept )(Player *player, GameObject *_GO, Quest const*_Quest );
bool (*pGOChooseReward )(Player *player, GameObject *_GO, Quest const*_Quest, uint32 opt ); bool (*pGOChooseReward )(Player *player, GameObject *_GO, Quest const*_Quest, uint32 opt );
bool (*pReceiveEmote )(Player *player, Creature *_Creature, uint32 emote );
bool (*pItemUse )(Player *player, Item* _Item, SpellCastTargets const& targets); bool (*pItemUse )(Player *player, Item* _Item, SpellCastTargets const& targets);
bool (*pEffectDummyGameObj )(Unit*, uint32, uint32, GameObject* ); bool (*pEffectDummyGameObj )(Unit*, uint32, uint32, GameObject* );
bool (*pEffectDummyCreature )(Unit*, uint32, uint32, Creature* ); bool (*pEffectDummyCreature )(Unit*, uint32, uint32, Creature* );

View file

@ -587,8 +587,8 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit); GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit);
//Send scripted event call //Send scripted event call
if (unit && unit->GetTypeId()==TYPEID_UNIT && Script) if (unit && unit->GetTypeId()==TYPEID_UNIT && ((Creature*)unit)->AI())
Script->ReceiveEmote(GetPlayer(),(Creature*)unit,text_emote); ((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(),text_emote);
} }
void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data ) void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data )

View file

@ -25,9 +25,10 @@
#include "Dynamic/ObjectRegistry.h" #include "Dynamic/ObjectRegistry.h"
#include "Dynamic/FactoryHolder.h" #include "Dynamic/FactoryHolder.h"
class WorldObject;
class Unit; class Unit;
class Creature; class Creature;
class WorldObject; class Player;
struct SpellEntry; struct SpellEntry;
#define TIME_INTERVAL_LOOK 5000 #define TIME_INTERVAL_LOOK 5000
@ -88,6 +89,9 @@ class MANGOS_DLL_SPEC CreatureAI
// Called at waypoint reached or point movement finished // Called at waypoint reached or point movement finished
virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {} virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
// Called at text emote receive from player
virtual void ReceiveEmote(Player* pPlayer, uint32 text_emote) {}
///== Triggered Actions Requested ================== ///== Triggered Actions Requested ==================
// Called when creature attack expected (if creature can and no have current victim) // Called when creature attack expected (if creature can and no have current victim)

View file

@ -1629,19 +1629,17 @@ bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Trigge
return true; return true;
} }
bool CreatureEventAI::ReceiveEmote(Player* pPlayer, Creature* pCreature, uint32 uiEmote) void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
{ {
CreatureEventAI* pTmpCreature = (CreatureEventAI*)(pCreature->AI()); if (bEmptyList)
return;
if (pTmpCreature->bEmptyList) for (std::list<CreatureEventAIHolder>::iterator itr = CreatureEventAIList.begin(); itr != CreatureEventAIList.end(); ++itr)
return true;
for (std::list<CreatureEventAIHolder>::iterator itr = pTmpCreature->CreatureEventAIList.begin(); itr != pTmpCreature->CreatureEventAIList.end(); ++itr)
{ {
if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE) if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE)
{ {
if ((*itr).Event.event_param1 != uiEmote) if ((*itr).Event.event_param1 != text_emote)
return true; return;
bool bProcess = false; bool bProcess = false;
@ -1696,10 +1694,8 @@ bool CreatureEventAI::ReceiveEmote(Player* pPlayer, Creature* pCreature, uint32
if (bProcess) if (bProcess)
{ {
sLog.outDebug("CreatureEventAI: ReceiveEmote CreatureEventAI: Condition ok, processing"); sLog.outDebug("CreatureEventAI: ReceiveEmote CreatureEventAI: Condition ok, processing");
pTmpCreature->ProcessEvent(*itr, pPlayer); ProcessEvent(*itr, pPlayer);
} }
} }
} }
return true;
} }

View file

@ -265,6 +265,7 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
void SpellHit(Unit* pUnit, const SpellEntry* pSpell); void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
void UpdateAI(const uint32 diff); void UpdateAI(const uint32 diff);
bool IsVisible(Unit *) const; bool IsVisible(Unit *) const;
void ReceiveEmote(Player* pPlayer, uint32 text_emote);
static int Permissible(const Creature *); static int Permissible(const Creature *);
bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL); bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL);
@ -277,7 +278,6 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
void DoZoneInCombat(Unit* pUnit); void DoZoneInCombat(Unit* pUnit);
void DoMeleeAttackIfReady(); void DoMeleeAttackIfReady();
bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered); bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered);
bool ReceiveEmote(Player* pPlayer, Creature* pCreature, uint32 uiEmote);
Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff); Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff);
void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid); void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid);

View file

@ -72,7 +72,6 @@ bool LoadScriptingModule(char const* libName)
||!(testScript->scriptAreaTrigger =(scriptCallAreaTrigger )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"AreaTrigger" )) ||!(testScript->scriptAreaTrigger =(scriptCallAreaTrigger )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"AreaTrigger" ))
||!(testScript->ItemQuestAccept =(scriptCallItemQuestAccept )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"ItemQuestAccept" )) ||!(testScript->ItemQuestAccept =(scriptCallItemQuestAccept )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"ItemQuestAccept" ))
||!(testScript->GOQuestAccept =(scriptCallGOQuestAccept )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"GOQuestAccept" )) ||!(testScript->GOQuestAccept =(scriptCallGOQuestAccept )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"GOQuestAccept" ))
||!(testScript->ReceiveEmote =(scriptCallReceiveEmote )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"ReceiveEmote" ))
||!(testScript->ItemUse =(scriptCallItemUse )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"ItemUse" )) ||!(testScript->ItemUse =(scriptCallItemUse )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"ItemUse" ))
||!(testScript->EffectDummyGameObj =(scriptCallEffectDummyGameObj )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyGameObj" )) ||!(testScript->EffectDummyGameObj =(scriptCallEffectDummyGameObj )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyGameObj" ))
||!(testScript->EffectDummyCreature =(scriptCallEffectDummyCreature )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyCreature" )) ||!(testScript->EffectDummyCreature =(scriptCallEffectDummyCreature )MANGOS_GET_PROC_ADDR(testScript->hScriptsLib,"EffectDummyCreature" ))

View file

@ -54,7 +54,6 @@ typedef bool(MANGOS_IMPORT * scriptCallAreaTrigger)( Player *player, AreaTrigger
typedef bool(MANGOS_IMPORT * scriptCallItemQuestAccept)(Player *player, Item *, Quest const*); typedef bool(MANGOS_IMPORT * scriptCallItemQuestAccept)(Player *player, Item *, Quest const*);
typedef bool(MANGOS_IMPORT * scriptCallGOQuestAccept)(Player *player, GameObject *, Quest const*); typedef bool(MANGOS_IMPORT * scriptCallGOQuestAccept)(Player *player, GameObject *, Quest const*);
typedef bool(MANGOS_IMPORT * scriptCallGOChooseReward)(Player *player, GameObject *, Quest const*, uint32 opt ); typedef bool(MANGOS_IMPORT * scriptCallGOChooseReward)(Player *player, GameObject *, Quest const*, uint32 opt );
typedef bool(MANGOS_IMPORT * scriptCallReceiveEmote) ( Player *player, Creature *_Creature, uint32 emote );
typedef bool(MANGOS_IMPORT * scriptCallItemUse) (Player *player, Item *_Item, SpellCastTargets const& targets); typedef bool(MANGOS_IMPORT * scriptCallItemUse) (Player *player, Item *_Item, SpellCastTargets const& targets);
typedef bool(MANGOS_IMPORT * scriptCallEffectDummyGameObj) (Unit *caster, uint32 spellId, uint32 effIndex, GameObject *gameObjTarget); typedef bool(MANGOS_IMPORT * scriptCallEffectDummyGameObj) (Unit *caster, uint32 spellId, uint32 effIndex, GameObject *gameObjTarget);
typedef bool(MANGOS_IMPORT * scriptCallEffectDummyCreature) (Unit *caster, uint32 spellId, uint32 effIndex, Creature *crTarget); typedef bool(MANGOS_IMPORT * scriptCallEffectDummyCreature) (Unit *caster, uint32 spellId, uint32 effIndex, Creature *crTarget);
@ -83,7 +82,6 @@ typedef struct
scriptCallAreaTrigger scriptAreaTrigger; scriptCallAreaTrigger scriptAreaTrigger;
scriptCallItemQuestAccept ItemQuestAccept; scriptCallItemQuestAccept ItemQuestAccept;
scriptCallGOQuestAccept GOQuestAccept; scriptCallGOQuestAccept GOQuestAccept;
scriptCallReceiveEmote ReceiveEmote;
scriptCallItemUse ItemUse; scriptCallItemUse ItemUse;
scriptCallEffectDummyGameObj EffectDummyGameObj; scriptCallEffectDummyGameObj EffectDummyGameObj;
scriptCallEffectDummyCreature EffectDummyCreature; scriptCallEffectDummyCreature EffectDummyCreature;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7671" #define REVISION_NR "7672"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__