[Server] Add script callback and getter functions for ActorEquipment

0.6.1
David Cernat 8 years ago
parent 311ce4119d
commit f47a10dd4a

@ -133,6 +133,21 @@ double ActorFunctions::GetActorFatigueCurrent(unsigned int i) noexcept
return readActorList->baseActors.at(i).creatureStats.mDynamic[2].mCurrent; return readActorList->baseActors.at(i).creatureStats.mDynamic[2].mCurrent;
} }
const char *ActorFunctions::GetActorEquipmentItemRefId(unsigned int i, unsigned short slot) noexcept
{
return readActorList->baseActors.at(i).equipedItems[slot].refId.c_str();
}
int ActorFunctions::GetActorEquipmentItemCount(unsigned int i, unsigned short slot) noexcept
{
return readActorList->baseActors.at(i).equipedItems[slot].count;
}
int ActorFunctions::GetActorEquipmentItemCharge(unsigned int i, unsigned short slot) noexcept
{
return readActorList->baseActors.at(i).equipedItems[slot].charge;
}
bool ActorFunctions::DoesActorHavePosition(unsigned int i) noexcept bool ActorFunctions::DoesActorHavePosition(unsigned int i) noexcept
{ {
return readActorList->baseActors.at(i).hasPositionData; return readActorList->baseActors.at(i).hasPositionData;

@ -2,60 +2,64 @@
#define OPENMW_ACTORAPI_HPP #define OPENMW_ACTORAPI_HPP
#define ACTORAPI \ #define ACTORAPI \
{"ReadLastActorList", ActorFunctions::ReadLastActorList},\ {"ReadLastActorList", ActorFunctions::ReadLastActorList},\
{"ReadCellActorList", ActorFunctions::ReadCellActorList},\ {"ReadCellActorList", ActorFunctions::ReadCellActorList},\
{"InitializeActorList", ActorFunctions::InitializeActorList},\ {"InitializeActorList", ActorFunctions::InitializeActorList},\
\ \
{"GetActorListSize", ActorFunctions::GetActorListSize},\ {"GetActorListSize", ActorFunctions::GetActorListSize},\
{"GetActorListAction", ActorFunctions::GetActorListAction},\ {"GetActorListAction", ActorFunctions::GetActorListAction},\
\ \
{"GetActorCell", ActorFunctions::GetActorCell},\ {"GetActorCell", ActorFunctions::GetActorCell},\
{"GetActorRefId", ActorFunctions::GetActorRefId},\ {"GetActorRefId", ActorFunctions::GetActorRefId},\
{"GetActorRefNumIndex", ActorFunctions::GetActorRefNumIndex},\ {"GetActorRefNumIndex", ActorFunctions::GetActorRefNumIndex},\
{"GetActorMpNum", ActorFunctions::GetActorMpNum},\ {"GetActorMpNum", ActorFunctions::GetActorMpNum},\
\ \
{"GetActorPosX", ActorFunctions::GetActorPosX},\ {"GetActorPosX", ActorFunctions::GetActorPosX},\
{"GetActorPosY", ActorFunctions::GetActorPosY},\ {"GetActorPosY", ActorFunctions::GetActorPosY},\
{"GetActorPosZ", ActorFunctions::GetActorPosZ},\ {"GetActorPosZ", ActorFunctions::GetActorPosZ},\
{"GetActorRotX", ActorFunctions::GetActorRotX},\ {"GetActorRotX", ActorFunctions::GetActorRotX},\
{"GetActorRotY", ActorFunctions::GetActorRotY},\ {"GetActorRotY", ActorFunctions::GetActorRotY},\
{"GetActorRotZ", ActorFunctions::GetActorRotZ},\ {"GetActorRotZ", ActorFunctions::GetActorRotZ},\
\ \
{"GetActorHealthBase", ActorFunctions::GetActorHealthBase},\ {"GetActorHealthBase", ActorFunctions::GetActorHealthBase},\
{"GetActorHealthCurrent", ActorFunctions::GetActorHealthCurrent},\ {"GetActorHealthCurrent", ActorFunctions::GetActorHealthCurrent},\
{"GetActorMagickaBase", ActorFunctions::GetActorMagickaBase},\ {"GetActorMagickaBase", ActorFunctions::GetActorMagickaBase},\
{"GetActorMagickaCurrent", ActorFunctions::GetActorMagickaCurrent},\ {"GetActorMagickaCurrent", ActorFunctions::GetActorMagickaCurrent},\
{"GetActorFatigueBase", ActorFunctions::GetActorFatigueBase},\ {"GetActorFatigueBase", ActorFunctions::GetActorFatigueBase},\
{"GetActorFatigueCurrent", ActorFunctions::GetActorFatigueCurrent},\ {"GetActorFatigueCurrent", ActorFunctions::GetActorFatigueCurrent},\
\ \
{"DoesActorHavePosition", ActorFunctions::DoesActorHavePosition},\ {"GetActorEquipmentItemRefId", ActorFunctions::GetActorEquipmentItemRefId},\
{"DoesActorHaveStatsDynamic", ActorFunctions::DoesActorHaveStatsDynamic},\ {"GetActorEquipmentItemCount", ActorFunctions::GetActorEquipmentItemCount},\
{"GetActorEquipmentItemCharge", ActorFunctions::GetActorEquipmentItemCharge},\
\ \
{"SetActorListCell", ActorFunctions::SetActorListCell},\ {"DoesActorHavePosition", ActorFunctions::DoesActorHavePosition},\
{"SetActorListAction", ActorFunctions::SetActorListAction},\ {"DoesActorHaveStatsDynamic", ActorFunctions::DoesActorHaveStatsDynamic},\
\ \
{"SetActorCell", ActorFunctions::SetActorCell},\ {"SetActorListCell", ActorFunctions::SetActorListCell},\
{"SetActorRefId", ActorFunctions::SetActorRefId},\ {"SetActorListAction", ActorFunctions::SetActorListAction},\
{"SetActorRefNumIndex", ActorFunctions::SetActorRefNumIndex},\
{"SetActorMpNum", ActorFunctions::SetActorMpNum},\
\ \
{"SetActorPosition", ActorFunctions::SetActorPosition},\ {"SetActorCell", ActorFunctions::SetActorCell},\
{"SetActorRotation", ActorFunctions::SetActorRotation},\ {"SetActorRefId", ActorFunctions::SetActorRefId},\
{"SetActorRefNumIndex", ActorFunctions::SetActorRefNumIndex},\
{"SetActorMpNum", ActorFunctions::SetActorMpNum},\
\ \
{"SetActorHealthBase", ActorFunctions::SetActorHealthBase},\ {"SetActorPosition", ActorFunctions::SetActorPosition},\
{"SetActorHealthCurrent", ActorFunctions::SetActorHealthCurrent},\ {"SetActorRotation", ActorFunctions::SetActorRotation},\
{"SetActorMagickaBase", ActorFunctions::SetActorMagickaBase},\
{"SetActorMagickaCurrent", ActorFunctions::SetActorMagickaCurrent},\
{"SetActorFatigueBase", ActorFunctions::SetActorFatigueBase},\
{"SetActorFatigueCurrent", ActorFunctions::SetActorFatigueCurrent},\
\ \
{"AddActor", ActorFunctions::AddActor},\ {"SetActorHealthBase", ActorFunctions::SetActorHealthBase},\
{"SetActorHealthCurrent", ActorFunctions::SetActorHealthCurrent},\
{"SetActorMagickaBase", ActorFunctions::SetActorMagickaBase},\
{"SetActorMagickaCurrent", ActorFunctions::SetActorMagickaCurrent},\
{"SetActorFatigueBase", ActorFunctions::SetActorFatigueBase},\
{"SetActorFatigueCurrent", ActorFunctions::SetActorFatigueCurrent},\
\ \
{"SendActorList", ActorFunctions::SendActorList},\ {"AddActor", ActorFunctions::AddActor},\
{"SendActorAuthority", ActorFunctions::SendActorAuthority},\ \
{"SendActorPosition", ActorFunctions::SendActorPosition},\ {"SendActorList", ActorFunctions::SendActorList},\
{"SendActorStatsDynamic", ActorFunctions::SendActorStatsDynamic},\ {"SendActorAuthority", ActorFunctions::SendActorAuthority},\
{"SendActorCellChange", ActorFunctions::SendActorCellChange} {"SendActorPosition", ActorFunctions::SendActorPosition},\
{"SendActorStatsDynamic", ActorFunctions::SendActorStatsDynamic},\
{"SendActorCellChange", ActorFunctions::SendActorCellChange}
class ActorFunctions class ActorFunctions
{ {
@ -87,6 +91,10 @@ public:
static double GetActorFatigueBase(unsigned int i) noexcept; static double GetActorFatigueBase(unsigned int i) noexcept;
static double GetActorFatigueCurrent(unsigned int i) noexcept; static double GetActorFatigueCurrent(unsigned int i) noexcept;
static const char *GetActorEquipmentItemRefId(unsigned int i, unsigned short slot) noexcept;
static int GetActorEquipmentItemCount(unsigned int i, unsigned short slot) noexcept;
static int GetActorEquipmentItemCharge(unsigned int i, unsigned short slot) noexcept;
static bool DoesActorHavePosition(unsigned int i) noexcept; static bool DoesActorHavePosition(unsigned int i) noexcept;
static bool DoesActorHaveStatsDynamic(unsigned int i) noexcept; static bool DoesActorHaveStatsDynamic(unsigned int i) noexcept;

@ -145,6 +145,7 @@ public:
{"OnObjectScale", Function<void, unsigned short, const char*>()}, {"OnObjectScale", Function<void, unsigned short, const char*>()},
{"OnObjectTrap", Function<void, unsigned short, const char*>()}, {"OnObjectTrap", Function<void, unsigned short, const char*>()},
{"OnActorList", Function<void, unsigned short, const char*>()}, {"OnActorList", Function<void, unsigned short, const char*>()},
{"OnActorEquipment", Function<void, unsigned short, const char*>()},
{"OnActorCellChange", Function<void, unsigned short, const char*>()}, {"OnActorCellChange", Function<void, unsigned short, const char*>()},
{"OnActorTest", Function<void, unsigned short, const char*>()}, {"OnActorTest", Function<void, unsigned short, const char*>()},
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()}, {"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},

@ -19,7 +19,11 @@ namespace mwmp
Cell *serverCell = CellController::get()->getCell(&actorList.cell); Cell *serverCell = CellController::get()->getCell(&actorList.cell);
if (serverCell != nullptr) if (serverCell != nullptr)
{
Script::Call<Script::CallbackIdentity("OnActorEquipment")>(player.getId(), actorList.cell.getDescription().c_str());
serverCell->sendToLoaded(&packet, &actorList); serverCell->sendToLoaded(&packet, &actorList);
}
} }
}; };
} }

Loading…
Cancel
Save