[General] Implement sending of ActorSpeech packets from server scripts

pull/471/head
David Cernat 6 years ago
parent 338efdb705
commit 5fd4113978

@ -311,6 +311,11 @@ void ActorFunctions::SetActorFatigueModified(double value) noexcept
tempActor.creatureStats.mDynamic[2].mMod = value; tempActor.creatureStats.mDynamic[2].mMod = value;
} }
void ActorFunctions::SetActorSound(const char* sound) noexcept
{
tempActor.sound = sound;
}
void ActorFunctions::SetActorAIAction(unsigned int action) noexcept void ActorFunctions::SetActorAIAction(unsigned int action) noexcept
{ {
tempActor.aiAction = action; tempActor.aiAction = action;
@ -459,6 +464,25 @@ void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttac
} }
} }
void ActorFunctions::SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_SPEECH);
actorPacket->setActorList(&writeActorList);
if (!skipAttachedPlayer)
actorPacket->Send(writeActorList.guid);
if (sendToOtherVisitors)
{
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
if (serverCell != nullptr)
{
serverCell->sendToLoaded(actorPacket, &writeActorList);
}
}
}
void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{ {
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI); mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI);

@ -71,6 +71,8 @@
{"SetActorFatigueCurrent", ActorFunctions::SetActorFatigueCurrent},\ {"SetActorFatigueCurrent", ActorFunctions::SetActorFatigueCurrent},\
{"SetActorFatigueModified", ActorFunctions::SetActorFatigueModified},\ {"SetActorFatigueModified", ActorFunctions::SetActorFatigueModified},\
\ \
{"SetActorSound", ActorFunctions::SetActorSound},\
\
{"SetActorAIAction", ActorFunctions::SetActorAIAction},\ {"SetActorAIAction", ActorFunctions::SetActorAIAction},\
{"SetActorAITargetToPlayer", ActorFunctions::SetActorAITargetToPlayer},\ {"SetActorAITargetToPlayer", ActorFunctions::SetActorAITargetToPlayer},\
{"SetActorAITargetToObject", ActorFunctions::SetActorAITargetToObject},\ {"SetActorAITargetToObject", ActorFunctions::SetActorAITargetToObject},\
@ -89,6 +91,7 @@
{"SendActorPosition", ActorFunctions::SendActorPosition},\ {"SendActorPosition", ActorFunctions::SendActorPosition},\
{"SendActorStatsDynamic", ActorFunctions::SendActorStatsDynamic},\ {"SendActorStatsDynamic", ActorFunctions::SendActorStatsDynamic},\
{"SendActorEquipment", ActorFunctions::SendActorEquipment},\ {"SendActorEquipment", ActorFunctions::SendActorEquipment},\
{"SendActorSpeech", ActorFunctions::SendActorSpeech},\
{"SendActorAI", ActorFunctions::SendActorAI},\ {"SendActorAI", ActorFunctions::SendActorAI},\
{"SendActorCellChange", ActorFunctions::SendActorCellChange},\ {"SendActorCellChange", ActorFunctions::SendActorCellChange},\
\ \
@ -570,6 +573,14 @@ public:
*/ */
static void SetActorFatigueModified(double value) noexcept; static void SetActorFatigueModified(double value) noexcept;
/**
* \brief Set the sound of the temporary actor stored on the server.
*
* \param sound The sound.
* \return void
*/
static void SetActorSound(const char* sound) noexcept;
/** /**
* \brief Set the AI action of the temporary actor stored on the server. * \brief Set the AI action of the temporary actor stored on the server.
* *
@ -720,6 +731,17 @@ public:
*/ */
static void SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; static void SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorSpeech packet.
*
* \param sendToOtherVisitors Whether this packet should be sent to cell visitors other
* than the player attached to the packet (false by default).
* \param skipAttachedPlayer Whether the packet should skip being sent to the player attached
* to the packet (false by default).
* \return void
*/
static void SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/** /**
* \brief Send an ActorAI packet. * \brief Send an ActorAI packet.
* *

@ -82,7 +82,7 @@ public:
/** /**
* \brief Play a certain sound for a player as spoken by their character by sending * \brief Play a certain sound for a player as spoken by their character by sending
* a PlayerSound packet. * a PlayerSpeech packet.
* *
* \param pid The player ID of the character playing the sound. * \param pid The player ID of the character playing the sound.
* \param sound The path of the sound file. * \param sound The path of the sound file.

@ -233,6 +233,8 @@ void Cell::readEquipment(ActorList& actorList)
void Cell::readSpeech(ActorList& actorList) void Cell::readSpeech(ActorList& actorList)
{ {
initializeDedicatedActors(actorList);
for (const auto &baseActor : actorList.baseActors) for (const auto &baseActor : actorList.baseActors)
{ {
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor); std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);

Loading…
Cancel
Save