Skip to content

Commit

Permalink
[12750] Allow script command 16 to Play Music using the additional flag
Browse files Browse the repository at this point in the history
  • Loading branch information
xfurry committed Oct 26, 2014
1 parent 95db807 commit 869ec0d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Where "A -> B" means that the command is executed from A with B as target.
* datalong = sound_id
* datalong2 (bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide;
so 1|2 = 3 is target with distance dependent)
* data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: play music instead of sound

17 SCRIPT_COMMAND_CREATE_ITEM source or target must be player
* datalong = item entry
Expand Down
10 changes: 10 additions & 0 deletions src/game/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,16 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL
SendMessageToSet(&data, true);
}

void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) const
{
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(sound_id);
if (target)
target->SendDirectMessage(&data);
else
SendMessageToSet(&data, true);
}

void WorldObject::UpdateVisibilityAndView()
{
GetViewPoint().Call_UpdateVisibilityForOwner();
Expand Down
1 change: 1 addition & 0 deletions src/game/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object

void PlayDistanceSound(uint32 sound_id, Player const* target = NULL) const;
void PlayDirectSound(uint32 sound_id, Player const* target = NULL) const;
void PlayMusic(uint32 sound_id, Player const* target = NULL) const;

void SendObjectDeSpawnAnim(ObjectGuid guid);
void SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId = 0);
Expand Down
16 changes: 10 additions & 6 deletions src/game/ScriptMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,13 +1468,17 @@ bool ScriptAction::HandleScriptStep()
break;
}

if (m_script->playSound.flags & 2)
pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget);
else if (m_script->playSound.flags & (4 | 8))
m_map->PlayDirectSoundToMap(m_script->playSound.soundId, m_script->playSound.flags & 8 ? pSource->GetZoneId() : 0);
if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL)
pSource->PlayMusic(m_script->playSound.soundId, pSoundTarget);
else
pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget);

{
if (m_script->playSound.flags & 2)
pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget);
else if (m_script->playSound.flags & (4 | 8))
m_map->PlayDirectSoundToMap(m_script->playSound.soundId, m_script->playSound.flags & 8 ? pSource->GetZoneId() : 0);
else
pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget);
}
break;
}
case SCRIPT_COMMAND_CREATE_ITEM: // 17
Expand Down
1 change: 1 addition & 0 deletions src/game/ScriptMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ struct ScriptInfo
case SCRIPT_COMMAND_MOVE_TO:
case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE:
case SCRIPT_COMMAND_CAST_SPELL:
case SCRIPT_COMMAND_PLAY_SOUND:
case SCRIPT_COMMAND_MOVEMENT:
case SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL:
case SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL:
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12749"
#define REVISION_NR "12750"
#endif // __REVISION_NR_H__

0 comments on commit 869ec0d

Please sign in to comment.