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:
@@ -228,6 +228,9 @@ ElunaRegister<WorldObject> WorldObjectMethods[] =
|
|||||||
{ "RegisterEvent", &LuaWorldObject::RegisterEvent },
|
{ "RegisterEvent", &LuaWorldObject::RegisterEvent },
|
||||||
{ "RemoveEventById", &LuaWorldObject::RemoveEventById },
|
{ "RemoveEventById", &LuaWorldObject::RemoveEventById },
|
||||||
{ "RemoveEvents", &LuaWorldObject::RemoveEvents },
|
{ "RemoveEvents", &LuaWorldObject::RemoveEvents },
|
||||||
|
{ "PlayMusic", &LuaWorldObject::PlayMusic },
|
||||||
|
{ "PlayDirectSound", &LuaWorldObject::PlayDirectSound },
|
||||||
|
{ "PlayDistanceSound", &LuaWorldObject::PlayDistanceSound },
|
||||||
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
@@ -381,8 +384,6 @@ ElunaRegister<Unit> UnitMethods[] =
|
|||||||
{ "CastSpell", &LuaUnit::CastSpell },
|
{ "CastSpell", &LuaUnit::CastSpell },
|
||||||
{ "CastCustomSpell", &LuaUnit::CastCustomSpell },
|
{ "CastCustomSpell", &LuaUnit::CastCustomSpell },
|
||||||
{ "CastSpellAoF", &LuaUnit::CastSpellAoF },
|
{ "CastSpellAoF", &LuaUnit::CastSpellAoF },
|
||||||
{ "PlayDirectSound", &LuaUnit::PlayDirectSound },
|
|
||||||
{ "PlayDistanceSound", &LuaUnit::PlayDistanceSound },
|
|
||||||
{ "Kill", &LuaUnit::Kill },
|
{ "Kill", &LuaUnit::Kill },
|
||||||
{ "StopSpellCast", &LuaUnit::StopSpellCast },
|
{ "StopSpellCast", &LuaUnit::StopSpellCast },
|
||||||
{ "InterruptSpell", &LuaUnit::InterruptSpell },
|
{ "InterruptSpell", &LuaUnit::InterruptSpell },
|
||||||
@@ -651,7 +652,6 @@ ElunaRegister<Player> PlayerMethods[] =
|
|||||||
{ "RemoveItem", &LuaPlayer::RemoveItem },
|
{ "RemoveItem", &LuaPlayer::RemoveItem },
|
||||||
{ "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills },
|
{ "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills },
|
||||||
{ "ResurrectPlayer", &LuaPlayer::ResurrectPlayer },
|
{ "ResurrectPlayer", &LuaPlayer::ResurrectPlayer },
|
||||||
{ "PlaySoundToPlayer", &LuaPlayer::PlaySoundToPlayer },
|
|
||||||
{ "EquipItem", &LuaPlayer::EquipItem },
|
{ "EquipItem", &LuaPlayer::EquipItem },
|
||||||
{ "ResetSpellCooldown", &LuaPlayer::ResetSpellCooldown },
|
{ "ResetSpellCooldown", &LuaPlayer::ResetSpellCooldown },
|
||||||
{ "ResetTypeCooldowns", &LuaPlayer::ResetTypeCooldowns },
|
{ "ResetTypeCooldowns", &LuaPlayer::ResetTypeCooldowns },
|
||||||
@@ -733,6 +733,8 @@ ElunaRegister<Player> PlayerMethods[] =
|
|||||||
{ "SaveToDB", &LuaPlayer::SaveToDB },
|
{ "SaveToDB", &LuaPlayer::SaveToDB },
|
||||||
{ "GroupInvite", &LuaPlayer::GroupInvite },
|
{ "GroupInvite", &LuaPlayer::GroupInvite },
|
||||||
{ "GroupCreate", &LuaPlayer::GroupCreate },
|
{ "GroupCreate", &LuaPlayer::GroupCreate },
|
||||||
|
{ "SendCinematicStart", &LuaPlayer::SendCinematicStart },
|
||||||
|
{ "SendMovieStart", &LuaPlayer::SendMovieStart },
|
||||||
#ifdef CLASSIC
|
#ifdef CLASSIC
|
||||||
{ "UpdateHonor", &LuaPlayer::UpdateHonor },
|
{ "UpdateHonor", &LuaPlayer::UpdateHonor },
|
||||||
{ "ResetHonor", &LuaPlayer::ResetHonor },
|
{ "ResetHonor", &LuaPlayer::ResetHonor },
|
||||||
|
|||||||
@@ -3713,24 +3713,6 @@ namespace LuaPlayer
|
|||||||
return 0;
|
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
|
* Attempts to start the taxi/flying to the given pathID
|
||||||
*
|
*
|
||||||
@@ -3944,6 +3926,32 @@ namespace LuaPlayer
|
|||||||
return 1;
|
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)
|
/*int BindToInstance(Eluna* E, lua_State* L, Player* player)
|
||||||
{
|
{
|
||||||
player->BindToInstance();
|
player->BindToInstance();
|
||||||
|
|||||||
@@ -2455,49 +2455,6 @@ namespace LuaUnit
|
|||||||
return 0;
|
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].
|
* Adds the given unit state for the [Unit].
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -834,5 +834,81 @@ namespace LuaWorldObject
|
|||||||
|
|
||||||
return 1;
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user