mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Add new methods. Closes https://github.com/ElunaLuaEngine/Eluna/pull/176 and https://github.com/ElunaLuaEngine/Eluna/issues/171
This commit is contained in:
@@ -834,5 +834,81 @@ namespace LuaWorldObject
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The [WorldObject] plays music to a [Player]
|
||||
*
|
||||
* If no [Player] provided it will play the music to everyone near.
|
||||
* This method does not interrupt previously played music.
|
||||
*
|
||||
* See also [WorldObject:PlayDistanceSound], [WorldObject:PlayDirectSound]
|
||||
*
|
||||
* @param uint32 music : entry of a music
|
||||
* @param [Player] player = nil : [Player] to play the music to
|
||||
*/
|
||||
int PlayMusic(Eluna* /*E*/, lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint32 musicid = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 3, false);
|
||||
|
||||
WorldPacket data(SMSG_PLAY_MUSIC, 4);
|
||||
data << uint32(musicid);
|
||||
if (player)
|
||||
player->SendDirectMessage(&data);
|
||||
else
|
||||
obj->SendMessageToSet(&data, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The [WorldObject] plays a sound to a [Player]
|
||||
*
|
||||
* If no [Player] provided it will play the sound to everyone near.
|
||||
* This method will play sound and does not interrupt prvious sound.
|
||||
*
|
||||
* See also [WorldObject:PlayDistanceSound], [WorldObject:PlayMusic]
|
||||
*
|
||||
* @param uint32 sound : entry of a sound
|
||||
* @param [Player] player = nil : [Player] to play the sound to
|
||||
*/
|
||||
int PlayDirectSound(Eluna* /*E*/, lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint32 soundId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 3, false);
|
||||
if (!sSoundEntriesStore.LookupEntry(soundId))
|
||||
return 0;
|
||||
|
||||
if (player)
|
||||
obj->PlayDirectSound(soundId, player);
|
||||
else
|
||||
obj->PlayDirectSound(soundId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The [WorldObject] plays a sound to a [Player]
|
||||
*
|
||||
* If no [Player] it will play the sound to everyone near.
|
||||
* Sound will fade the further you are from the [WorldObject].
|
||||
* This method interrupts previously playing sound.
|
||||
*
|
||||
* See also [WorldObject:PlayDirectSound], [WorldObject:PlayMusic]
|
||||
*
|
||||
* @param uint32 sound : entry of a sound
|
||||
* @param [Player] player = nil : [Player] to play the sound to
|
||||
*/
|
||||
int PlayDistanceSound(Eluna* /*E*/, lua_State* L, WorldObject* obj)
|
||||
{
|
||||
uint32 soundId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 3, false);
|
||||
if (!sSoundEntriesStore.LookupEntry(soundId))
|
||||
return 0;
|
||||
|
||||
if (player)
|
||||
obj->PlayDistanceSound(soundId, player);
|
||||
else
|
||||
obj->PlayDistanceSound(soundId);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user