diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index f2ee5ca..ad99c32 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -228,6 +228,9 @@ ElunaRegister WorldObjectMethods[] = { "RegisterEvent", &LuaWorldObject::RegisterEvent }, { "RemoveEventById", &LuaWorldObject::RemoveEventById }, { "RemoveEvents", &LuaWorldObject::RemoveEvents }, + { "PlayMusic", &LuaWorldObject::PlayMusic }, + { "PlayDirectSound", &LuaWorldObject::PlayDirectSound }, + { "PlayDistanceSound", &LuaWorldObject::PlayDistanceSound }, { NULL, NULL } }; @@ -381,8 +384,6 @@ ElunaRegister UnitMethods[] = { "CastSpell", &LuaUnit::CastSpell }, { "CastCustomSpell", &LuaUnit::CastCustomSpell }, { "CastSpellAoF", &LuaUnit::CastSpellAoF }, - { "PlayDirectSound", &LuaUnit::PlayDirectSound }, - { "PlayDistanceSound", &LuaUnit::PlayDistanceSound }, { "Kill", &LuaUnit::Kill }, { "StopSpellCast", &LuaUnit::StopSpellCast }, { "InterruptSpell", &LuaUnit::InterruptSpell }, @@ -651,7 +652,6 @@ ElunaRegister PlayerMethods[] = { "RemoveItem", &LuaPlayer::RemoveItem }, { "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills }, { "ResurrectPlayer", &LuaPlayer::ResurrectPlayer }, - { "PlaySoundToPlayer", &LuaPlayer::PlaySoundToPlayer }, { "EquipItem", &LuaPlayer::EquipItem }, { "ResetSpellCooldown", &LuaPlayer::ResetSpellCooldown }, { "ResetTypeCooldowns", &LuaPlayer::ResetTypeCooldowns }, @@ -733,6 +733,8 @@ ElunaRegister PlayerMethods[] = { "SaveToDB", &LuaPlayer::SaveToDB }, { "GroupInvite", &LuaPlayer::GroupInvite }, { "GroupCreate", &LuaPlayer::GroupCreate }, + { "SendCinematicStart", &LuaPlayer::SendCinematicStart }, + { "SendMovieStart", &LuaPlayer::SendMovieStart }, #ifdef CLASSIC { "UpdateHonor", &LuaPlayer::UpdateHonor }, { "ResetHonor", &LuaPlayer::ResetHonor }, diff --git a/PlayerMethods.h b/PlayerMethods.h index 013bed3..839f288 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -3713,24 +3713,6 @@ namespace LuaPlayer return 0; } - /** - * Plays sound to [Player] - * - * See [Unit:PlayDirectSound] - * - * @param uint32 sound : entry of a sound - */ - int PlaySoundToPlayer(Eluna* /*E*/, lua_State* L, Player* player) - { - uint32 soundId = Eluna::CHECKVAL(L, 2); - SoundEntriesEntry const* soundEntry = sSoundEntriesStore.LookupEntry(soundId); - if (!soundEntry) - return 0; - - player->PlayDirectSound(soundId, player); - return 0; - } - /** * Attempts to start the taxi/flying to the given pathID * @@ -3944,6 +3926,32 @@ namespace LuaPlayer return 1; } + /** + * Starts a cinematic for the [Player] + * + * @param uint32 CinematicSequenceId : entry of a cinematic + */ + int SendCinematicStart(Eluna* /*E*/, lua_State* L, Player* player) + { + uint32 CinematicSequenceId = Eluna::CHECKVAL(L, 2); + + player->SendCinematicStart(CinematicSequenceId); + return 0; + } + + /** + * Starts a movie for the [Player] + * + * @param uint32 MovieId : entry of a movie + */ + int SendMovieStart(Eluna* /*E*/, lua_State* L, Player* player) + { + uint32 MovieId = Eluna::CHECKVAL(L, 2); + + player->SendMovieStart(MovieId); + return 0; + } + /*int BindToInstance(Eluna* E, lua_State* L, Player* player) { player->BindToInstance(); diff --git a/UnitMethods.h b/UnitMethods.h index 2433f63..b7bf8bb 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -2454,49 +2454,6 @@ namespace LuaUnit unit->RemoveAllAuras(); return 0; } - - /** - * The [Unit] plays a sound to a [Player], if no [Player] it will play the sound to everyone near - * - * @param uint32 sound : entry of a sound - * @param [Player] player : [Player] to play the sound to - */ - int PlayDirectSound(Eluna* /*E*/, lua_State* L, Unit* unit) - { - uint32 soundId = Eluna::CHECKVAL(L, 2); - Player* player = Eluna::CHECKOBJ(L, 3, false); - if (!sSoundEntriesStore.LookupEntry(soundId)) - return 0; - - if (player) - unit->PlayDirectSound(soundId, player); - else - unit->PlayDirectSound(soundId); - return 0; - } - - /** - * The [Unit] plays a sound to a [Player] - * - * If no [Player] it will play the sound to everyone near - * Sound will fade the further you are - * - * @param uint32 sound : entry of a sound - * @param [Player] player : [Player] to play the sound to - */ - int PlayDistanceSound(Eluna* /*E*/, lua_State* L, Unit* unit) - { - uint32 soundId = Eluna::CHECKVAL(L, 2); - Player* player = Eluna::CHECKOBJ(L, 3, false); - if (!sSoundEntriesStore.LookupEntry(soundId)) - return 0; - - if (player) - unit->PlayDistanceSound(soundId, player); - else - unit->PlayDistanceSound(soundId); - return 0; - } /** * Adds the given unit state for the [Unit]. diff --git a/WorldObjectMethods.h b/WorldObjectMethods.h index 9ecf9c5..dca2584 100644 --- a/WorldObjectMethods.h +++ b/WorldObjectMethods.h @@ -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(L, 2); + Player* player = Eluna::CHECKOBJ(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(L, 2); + Player* player = Eluna::CHECKOBJ(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(L, 2); + Player* player = Eluna::CHECKOBJ(L, 3, false); + if (!sSoundEntriesStore.LookupEntry(soundId)) + return 0; + + if (player) + obj->PlayDistanceSound(soundId, player); + else + obj->PlayDistanceSound(soundId); + return 0; + } }; #endif