fix(DB/Core): play event after quest "Hero of the Mag'har"; extend SAI to play music (#1570)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -308,6 +308,131 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
delete targets;
|
delete targets;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SMART_ACTION_MUSIC:
|
||||||
|
{
|
||||||
|
ObjectList* targets = NULL;
|
||||||
|
|
||||||
|
if (e.action.music.type > 0)
|
||||||
|
{
|
||||||
|
if (me && me->FindMap())
|
||||||
|
{
|
||||||
|
Map::PlayerList const &players = me->GetMap()->GetPlayers();
|
||||||
|
targets = new ObjectList();
|
||||||
|
|
||||||
|
if (!players.isEmpty())
|
||||||
|
{
|
||||||
|
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
||||||
|
if (Player* player = i->GetSource())
|
||||||
|
{
|
||||||
|
if (player->GetZoneId() == me->GetZoneId())
|
||||||
|
{
|
||||||
|
if (e.action.music.type > 1)
|
||||||
|
{
|
||||||
|
if (player->GetAreaId() == me->GetAreaId())
|
||||||
|
targets->push_back(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
targets->push_back(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
targets = GetTargets(e, unit);
|
||||||
|
|
||||||
|
if (targets)
|
||||||
|
{
|
||||||
|
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||||
|
{
|
||||||
|
if (IsUnit(*itr))
|
||||||
|
{
|
||||||
|
(*itr)->SendPlayMusic(e.action.music.sound, e.action.music.onlySelf > 0);
|
||||||
|
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||||
|
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_MUSIC: target: %s (GuidLow: %u), sound: %u, onlySelf: %u, type: %u",
|
||||||
|
(*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.music.sound, e.action.music.onlySelf, e.action.music.type);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete targets;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMART_ACTION_RANDOM_MUSIC:
|
||||||
|
{
|
||||||
|
ObjectList* targets = NULL;
|
||||||
|
|
||||||
|
if (e.action.randomMusic.type > 0)
|
||||||
|
{
|
||||||
|
if (me && me->FindMap())
|
||||||
|
{
|
||||||
|
Map::PlayerList const &players = me->GetMap()->GetPlayers();
|
||||||
|
targets = new ObjectList();
|
||||||
|
|
||||||
|
if (!players.isEmpty())
|
||||||
|
{
|
||||||
|
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
||||||
|
if (Player* player = i->GetSource())
|
||||||
|
{
|
||||||
|
if (player->GetZoneId() == me->GetZoneId())
|
||||||
|
{
|
||||||
|
if (e.action.randomMusic.type > 1)
|
||||||
|
{
|
||||||
|
if (player->GetAreaId() == me->GetAreaId())
|
||||||
|
targets->push_back(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
targets->push_back(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
targets = GetTargets(e, unit);
|
||||||
|
|
||||||
|
if (!targets)
|
||||||
|
break;
|
||||||
|
|
||||||
|
uint32 sounds[4];
|
||||||
|
sounds[0] = e.action.randomMusic.sound1;
|
||||||
|
sounds[1] = e.action.randomMusic.sound2;
|
||||||
|
sounds[2] = e.action.randomMusic.sound3;
|
||||||
|
sounds[3] = e.action.randomMusic.sound4;
|
||||||
|
uint32 temp[4];
|
||||||
|
uint32 count = 0;
|
||||||
|
for (uint8 i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (sounds[i])
|
||||||
|
{
|
||||||
|
temp[count] = sounds[i];
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
delete targets;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||||
|
{
|
||||||
|
if (IsUnit(*itr))
|
||||||
|
{
|
||||||
|
uint32 sound = temp[urand(0, count - 1)];
|
||||||
|
(*itr)->SendPlayMusic(sound, e.action.randomMusic.onlySelf > 0);
|
||||||
|
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||||
|
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_RANDOM_MUSIC: target: %s (GuidLow: %u), sound: %u, onlyself: %u, type: %u",
|
||||||
|
(*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), sound, e.action.randomMusic.onlySelf, e.action.randomMusic.type);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete targets;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SMART_ACTION_SET_FACTION:
|
case SMART_ACTION_SET_FACTION:
|
||||||
{
|
{
|
||||||
ObjectList* targets = GetTargets(e, unit);
|
ObjectList* targets = GetTargets(e, unit);
|
||||||
|
|||||||
@@ -793,6 +793,23 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
|||||||
if (e.action.randomSound.sound4 && !IsSoundValid(e, e.action.randomSound.sound4))
|
if (e.action.randomSound.sound4 && !IsSoundValid(e, e.action.randomSound.sound4))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
case SMART_ACTION_MUSIC:
|
||||||
|
if (!IsSoundValid(e, e.action.music.sound))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case SMART_ACTION_RANDOM_MUSIC:
|
||||||
|
if (e.action.randomMusic.sound1 && !IsSoundValid(e, e.action.randomMusic.sound1))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (e.action.randomMusic.sound2 && !IsSoundValid(e, e.action.randomMusic.sound2))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (e.action.randomMusic.sound3 && !IsSoundValid(e, e.action.randomMusic.sound3))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (e.action.randomMusic.sound4 && !IsSoundValid(e, e.action.randomMusic.sound4))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
case SMART_ACTION_SET_EMOTE_STATE:
|
case SMART_ACTION_SET_EMOTE_STATE:
|
||||||
case SMART_ACTION_PLAY_EMOTE:
|
case SMART_ACTION_PLAY_EMOTE:
|
||||||
if (!IsEmoteValid(e, e.action.emote.emote))
|
if (!IsEmoteValid(e, e.action.emote.emote))
|
||||||
|
|||||||
@@ -586,8 +586,10 @@ enum SMART_ACTION
|
|||||||
SMART_ACTION_NO_ENVIRONMENT_UPDATE = 213,
|
SMART_ACTION_NO_ENVIRONMENT_UPDATE = 213,
|
||||||
SMART_ACTION_ZONE_UNDER_ATTACK = 214,
|
SMART_ACTION_ZONE_UNDER_ATTACK = 214,
|
||||||
SMART_ACTION_LOAD_GRID = 215,
|
SMART_ACTION_LOAD_GRID = 215,
|
||||||
|
SMART_ACTION_MUSIC = 216, // SoundId, onlySelf, type
|
||||||
|
SMART_ACTION_RANDOM_MUSIC = 217, // SoundId1, SoundId2, SoundId3, SoundId4, onlySelf, type
|
||||||
|
|
||||||
SMART_ACTION_AC_END = 216, // placeholder
|
SMART_ACTION_AC_END = 218, // placeholder
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SmartAction
|
struct SmartAction
|
||||||
@@ -629,6 +631,23 @@ struct SmartAction
|
|||||||
uint32 onlySelf;
|
uint32 onlySelf;
|
||||||
} randomSound;
|
} randomSound;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32 sound;
|
||||||
|
uint32 onlySelf;
|
||||||
|
uint32 type;
|
||||||
|
} music;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32 sound1;
|
||||||
|
uint32 sound2;
|
||||||
|
uint32 sound3;
|
||||||
|
uint32 sound4;
|
||||||
|
uint32 onlySelf;
|
||||||
|
uint32 type;
|
||||||
|
} randomMusic;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32 emote;
|
uint32 emote;
|
||||||
|
|||||||
@@ -1825,6 +1825,16 @@ void WorldObject::SendPlaySound(uint32 Sound, bool OnlySelf)
|
|||||||
SendMessageToSet(&data, true); // ToSelf ignored in this case
|
SendMessageToSet(&data, true); // ToSelf ignored in this case
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldObject::SendPlayMusic(uint32 Music, bool OnlySelf)
|
||||||
|
{
|
||||||
|
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||||
|
data << Music;
|
||||||
|
if (OnlySelf && GetTypeId() == TYPEID_PLAYER)
|
||||||
|
this->ToPlayer()->GetSession()->SendPacket(&data);
|
||||||
|
else
|
||||||
|
SendMessageToSet(&data, true); // ToSelf ignored in this case
|
||||||
|
}
|
||||||
|
|
||||||
void Object::ForceValuesUpdateAtIndex(uint32 i)
|
void Object::ForceValuesUpdateAtIndex(uint32 i)
|
||||||
{
|
{
|
||||||
_changesMask.SetBit(i);
|
_changesMask.SetBit(i);
|
||||||
|
|||||||
@@ -920,6 +920,7 @@ class WorldObject : public Object, public WorldLocation
|
|||||||
|
|
||||||
// Low Level Packets
|
// Low Level Packets
|
||||||
void SendPlaySound(uint32 Sound, bool OnlySelf);
|
void SendPlaySound(uint32 Sound, bool OnlySelf);
|
||||||
|
void SendPlayMusic(uint32 Music, bool OnlySelf);
|
||||||
|
|
||||||
virtual void SetMap(Map* map);
|
virtual void SetMap(Map* map);
|
||||||
virtual void ResetMap();
|
virtual void ResetMap();
|
||||||
|
|||||||
Reference in New Issue
Block a user