Skip to content

Commit

Permalink
Add new methods. Closes ElunaLuaEngine#176 and ElunaLuaEngine#171
Browse files Browse the repository at this point in the history
  • Loading branch information
Rochet2 committed Jan 5, 2016
1 parent 972ff3d commit 086ad79
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 64 deletions.
8 changes: 5 additions & 3 deletions LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ ElunaRegister<WorldObject> WorldObjectMethods[] =
{ "RegisterEvent", &LuaWorldObject::RegisterEvent },
{ "RemoveEventById", &LuaWorldObject::RemoveEventById },
{ "RemoveEvents", &LuaWorldObject::RemoveEvents },
{ "PlayMusic", &LuaWorldObject::PlayMusic },
{ "PlayDirectSound", &LuaWorldObject::PlayDirectSound },
{ "PlayDistanceSound", &LuaWorldObject::PlayDistanceSound },

{ NULL, NULL }
};
Expand Down Expand Up @@ -381,8 +384,6 @@ ElunaRegister<Unit> 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 },
Expand Down Expand Up @@ -651,7 +652,6 @@ ElunaRegister<Player> PlayerMethods[] =
{ "RemoveItem", &LuaPlayer::RemoveItem },
{ "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills },
{ "ResurrectPlayer", &LuaPlayer::ResurrectPlayer },
{ "PlaySoundToPlayer", &LuaPlayer::PlaySoundToPlayer },
{ "EquipItem", &LuaPlayer::EquipItem },
{ "ResetSpellCooldown", &LuaPlayer::ResetSpellCooldown },
{ "ResetTypeCooldowns", &LuaPlayer::ResetTypeCooldowns },
Expand Down Expand Up @@ -733,6 +733,8 @@ ElunaRegister<Player> PlayerMethods[] =
{ "SaveToDB", &LuaPlayer::SaveToDB },
{ "GroupInvite", &LuaPlayer::GroupInvite },
{ "GroupCreate", &LuaPlayer::GroupCreate },
{ "SendCinematicStart", &LuaPlayer::SendCinematicStart },
{ "SendMovieStart", &LuaPlayer::SendMovieStart },
#ifdef CLASSIC
{ "UpdateHonor", &LuaPlayer::UpdateHonor },
{ "ResetHonor", &LuaPlayer::ResetHonor },
Expand Down
44 changes: 26 additions & 18 deletions PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32>(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
*
Expand Down Expand Up @@ -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<uint32>(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<uint32>(L, 2);

player->SendMovieStart(MovieId);
return 0;
}

/*int BindToInstance(Eluna* E, lua_State* L, Player* player)
{
player->BindToInstance();
Expand Down
43 changes: 0 additions & 43 deletions UnitMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32>(L, 2);
Player* player = Eluna::CHECKOBJ<Player>(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<uint32>(L, 2);
Player* player = Eluna::CHECKOBJ<Player>(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].
Expand Down
76 changes: 76 additions & 0 deletions WorldObjectMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 086ad79

Please sign in to comment.