*Note some script id are changed. DB change may be needed.
[7518] Implement new script command SCRIPT_COMMAND_PLAY_SOUND (look in World.h for args) Author: VladimirMangos
* Also rewrite use SMSG_PLAY_OBJECT_SOUND/SMSG_PLAY_SOUND
Now WorldObject have 2 function for sound level dependent from distance (PlayDistanceSound)
and for not depednet (PlayDirectSound)
* Old Player::PlaySound function removed and uses need to be updated to WorldObject functions
Note: function called for _source_ of sound in different from old function.
* chat command .debug ps removed and .debug playsound can used for bother packects test:
if no selection used SMSG_PLAY_SOUND, if selection exist including self then SMSG_PLAY_OBJECT_SOUND.
--HG--
branch : trunk
This commit is contained in:
@@ -121,7 +121,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "sendopcode", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendOpcodeCommand, "", NULL },
|
||||
{ "spawnvehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpawnVehicle, "", NULL },
|
||||
{ "uws", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL },
|
||||
{ "ps", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugPlaySound2Command, "", NULL },
|
||||
{ "scn", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendChannelNotifyCommand, "", NULL },
|
||||
{ "scm", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendChatMsgCommand, "", NULL },
|
||||
{ "sps", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendSetPhaseShiftCommand, "", NULL },
|
||||
|
||||
@@ -467,7 +467,6 @@ class ChatHandler
|
||||
bool HandleDebugSellErrorCommand(const char* args);
|
||||
bool HandleDebugBuyErrorCommand(const char* args);
|
||||
bool HandleDebugUpdateWorldStateCommand(const char* args);
|
||||
bool HandleDebugPlaySound2Command(const char* args);
|
||||
bool HandleDebugSendChannelNotifyCommand(const char* args);
|
||||
bool HandleDebugSendChatMsgCommand(const char* args);
|
||||
bool HandleRenameCommand(const char * args);
|
||||
|
||||
+32
-4
@@ -243,13 +243,41 @@ bool ChatHandler::HandleDebugUpdateWorldStateCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleDebugPlaySound2Command(const char* args)
|
||||
//Play sound
|
||||
bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
|
||||
{
|
||||
if(!args)
|
||||
// USAGE: .debug playsound #soundid
|
||||
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
|
||||
if( !*args )
|
||||
{
|
||||
SendSysMessage(LANG_BAD_VALUE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 soundid = atoi(args);
|
||||
m_session->GetPlayer()->PlaySound(soundid, false);
|
||||
uint32 dwSoundId = atoi((char*)args);
|
||||
|
||||
if(!sSoundEntriesStore.LookupEntry(dwSoundId))
|
||||
{
|
||||
PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Unit* unit = getSelectedUnit();
|
||||
if(!unit)
|
||||
{
|
||||
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_session->GetPlayer()->GetSelection())
|
||||
unit->PlayDistanceSound(dwSoundId,m_session->GetPlayer());
|
||||
else
|
||||
unit->PlayDirectSound(dwSoundId,m_session->GetPlayer());
|
||||
|
||||
PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2383,35 +2383,6 @@ bool ChatHandler::HandleWhispersCommand(const char* args)
|
||||
return false;
|
||||
}
|
||||
|
||||
//Play sound
|
||||
bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
|
||||
{
|
||||
// USAGE: .debug playsound #soundid
|
||||
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
|
||||
// this file have about 5000 sounds.
|
||||
// In this realization only caller can hear this sound.
|
||||
if( *args )
|
||||
{
|
||||
uint32 dwSoundId = atoi((char*)args);
|
||||
|
||||
if( !sSoundEntriesStore.LookupEntry(dwSoundId) )
|
||||
{
|
||||
PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
|
||||
data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID();
|
||||
m_session->SendPacket(&data);
|
||||
|
||||
PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Save all players in the world
|
||||
bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
|
||||
{
|
||||
|
||||
@@ -1884,3 +1884,24 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||
if(update && IsInWorld())
|
||||
ObjectAccessor::UpdateObjectVisibility(this);
|
||||
}
|
||||
|
||||
void WorldObject::PlayDistanceSound( uint32 sound_id, Player* target /*= NULL*/ )
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
|
||||
data << uint32(sound_id);
|
||||
data << GetGUID();
|
||||
if (target)
|
||||
target->SendDirectMessage( &data );
|
||||
else
|
||||
SendMessageToSet( &data, true );
|
||||
}
|
||||
|
||||
void WorldObject::PlayDirectSound( uint32 sound_id, Player* target /*= NULL*/ )
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4);
|
||||
data << uint32(sound_id);
|
||||
if (target)
|
||||
target->SendDirectMessage( &data );
|
||||
else
|
||||
SendMessageToSet( &data, true );
|
||||
}
|
||||
|
||||
@@ -480,6 +480,9 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
void MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper = false);
|
||||
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 TargetGuid) const;
|
||||
|
||||
void PlayDistanceSound(uint32 sound_id, Player* target = NULL);
|
||||
void PlayDirectSound(uint32 sound_id, Player* target = NULL);
|
||||
|
||||
void SendObjectDeSpawnAnim(uint64 guid);
|
||||
|
||||
virtual void SaveRespawnTime() {}
|
||||
|
||||
@@ -16794,16 +16794,6 @@ void Player::SendAutoRepeatCancel()
|
||||
GetSession()->SendPacket( &data );
|
||||
}
|
||||
|
||||
void Player::PlaySound(uint32 Sound, bool OnlySelf)
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4);
|
||||
data << Sound;
|
||||
if (OnlySelf)
|
||||
GetSession()->SendPacket( &data );
|
||||
else
|
||||
SendMessageToSet( &data, true );
|
||||
}
|
||||
|
||||
void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
|
||||
{
|
||||
WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 );
|
||||
|
||||
@@ -1613,8 +1613,6 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
void SendDelayResponse(const uint32);
|
||||
void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
|
||||
|
||||
//Low Level Packets
|
||||
void PlaySound(uint32 Sound, bool OnlySelf);
|
||||
//notifiers
|
||||
void SendAttackSwingCantAttack();
|
||||
void SendAttackSwingCancelAttack();
|
||||
|
||||
@@ -1999,8 +1999,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
|
||||
m_target->CastSpell(m_target, 51581, true, NULL, this);
|
||||
return;
|
||||
case 43873: // Headless Horseman Laugh
|
||||
if(caster->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)caster)->PlaySound(11965, false);
|
||||
m_target->PlayDistanceSound(11965);
|
||||
return;
|
||||
case 46354: // Blood Elf Illusion
|
||||
if(caster)
|
||||
|
||||
+41
-9
@@ -2510,15 +2510,6 @@ void World::ScriptsProcess()
|
||||
return;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_PLAYSOUND:
|
||||
{
|
||||
if(!source)
|
||||
break;
|
||||
//datalong sound_id, datalong2 onlyself
|
||||
((WorldObject*)source)->SendPlaySound(step.script->datalong, step.script->datalong2);
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_KILL:
|
||||
{
|
||||
if(!source || ((Creature*)source)->isDead())
|
||||
@@ -2534,6 +2525,47 @@ void World::ScriptsProcess()
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_PLAY_SOUND:
|
||||
{
|
||||
if(!source)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for NULL creature.");
|
||||
break;
|
||||
}
|
||||
|
||||
WorldObject* pSource = dynamic_cast<WorldObject*>(source);
|
||||
if(!pSource)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for non-world object (TypeId: %u), skipping.",source->GetTypeId());
|
||||
break;
|
||||
}
|
||||
|
||||
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
|
||||
Player* pTarget = NULL;
|
||||
if(step.script->datalong2 & 1)
|
||||
{
|
||||
if(!target)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for NULL target.");
|
||||
break;
|
||||
}
|
||||
|
||||
if(target->GetTypeId()!=TYPEID_PLAYER)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for non-player (TypeId: %u), skipping.",target->GetTypeId());
|
||||
break;
|
||||
}
|
||||
|
||||
pTarget = (Player*)target;
|
||||
}
|
||||
|
||||
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
|
||||
if(step.script->datalong2 & 2)
|
||||
pSource->PlayDistanceSound(step.script->datalong,pTarget);
|
||||
else
|
||||
pSource->PlayDirectSound(step.script->datalong,pTarget);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sLog.outError("Unknown script command %u called.",step.script->command);
|
||||
break;
|
||||
|
||||
+4
-4
@@ -342,10 +342,10 @@ enum RealmZone
|
||||
#define SCRIPT_COMMAND_ACTIVATE_OBJECT 13 // source = unit, target=GO
|
||||
#define SCRIPT_COMMAND_REMOVE_AURA 14 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
|
||||
#define SCRIPT_COMMAND_CAST_SPELL 15 // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
|
||||
#define SCRIPT_COMMAND_LOAD_PATH 16 // source = unit, path = datalong, repeatable datalong2
|
||||
#define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 17 // datalong scriptid, lowguid datalong2, dataint table
|
||||
#define SCRIPT_COMMAND_PLAYSOUND 18 // datalong soundid, datalong2 play only self
|
||||
#define SCRIPT_COMMAND_KILL 19 // datalong removecorpse
|
||||
#define SCRIPT_COMMAND_PLAY_SOUND 16 // source = any object, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
|
||||
#define SCRIPT_COMMAND_LOAD_PATH 20 // source = unit, path = datalong, repeatable datalong2
|
||||
#define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 21 // datalong scriptid, lowguid datalong2, dataint table
|
||||
#define SCRIPT_COMMAND_KILL 22 // datalong removecorpse
|
||||
|
||||
/// Storage class for commands issued for delayed execution
|
||||
struct CliCommandHolder
|
||||
|
||||
Reference in New Issue
Block a user