diff --git a/apps/openmw-mp/Script/Functions/GUI.cpp b/apps/openmw-mp/Script/Functions/GUI.cpp index 5c76b1120..1dafa9211 100644 --- a/apps/openmw-mp/Script/Functions/GUI.cpp +++ b/apps/openmw-mp/Script/Functions/GUI.cpp @@ -2,13 +2,14 @@ // Created by koncord on 23.07.16. // +#include "GUI.hpp" #include #include #include -void ScriptFunctions::MessageBox(unsigned short pid, int id, const char *label) noexcept +void GUIFunctions::MessageBox(unsigned short pid, int id, const char *label) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -20,7 +21,7 @@ void ScriptFunctions::MessageBox(unsigned short pid, int id, const char *label) mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); } -void ScriptFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept +void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -33,7 +34,7 @@ void ScriptFunctions::CustomMessageBox(unsigned short pid, int id, const char *l mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); } -void ScriptFunctions::InputDialog(unsigned short pid, int id, const char *label) noexcept +void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -43,4 +44,14 @@ void ScriptFunctions::InputDialog(unsigned short pid, int id, const char *label) player->guiMessageBox.type = Player::GUIMessageBox::InputDialog; mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); +} + +void GUIFunctions::SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept +{ + LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); +} + +void GUIFunctions::SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept +{ + LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); } \ No newline at end of file diff --git a/apps/openmw-mp/Script/Functions/GUI.hpp b/apps/openmw-mp/Script/Functions/GUI.hpp new file mode 100644 index 000000000..5eef410e8 --- /dev/null +++ b/apps/openmw-mp/Script/Functions/GUI.hpp @@ -0,0 +1,27 @@ +// +// Created by koncord on 30.08.16. +// + +#ifndef OPENMW_GUI_HPP +#define OPENMW_GUI_HPP + +#define GUIFUNCTIONS \ + {"MessageBox", GUIFunctions::MessageBox},\ + {"CustomMessageBox", GUIFunctions::CustomMessageBox},\ + {"InputDialog", GUIFunctions::InputDialog},\ + {"SetMapVisibility", GUIFunctions::SetMapVisibility},\ + {"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll}\ + +class GUIFunctions +{ +public: + static void MessageBox(unsigned short pid, int id, const char *label) noexcept; + static void CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept; + static void InputDialog(unsigned short pid, int id, const char *label) noexcept; + + //state 0 - disallow, 1 - allow + static void SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept; + static void SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept; +}; + +#endif //OPENMW_GUI_HPP diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 03230ce60..752d0b7aa 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -2,24 +2,26 @@ // Created by koncord on 02.03.16. // +#include "Items.hpp" #include #include #include #include -/*void ScriptFunctions::AddItem(unsigned short pid, const char* itemName, unsigned short count) noexcept +void ItemFunctions::AddItem(unsigned short pid, const char* itemName, unsigned short count) noexcept { - Player *player; + /*Player *player; GET_PLAYER(pid, player,); mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, false); - mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, true); -}*/ + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, true);*/ + LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); +} -void ScriptFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemName, unsigned short count) noexcept +void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemName, unsigned short count) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -31,20 +33,23 @@ void ScriptFunctions::EquipItem(unsigned short pid, unsigned short slot, const c mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_EQUIPED)->Send(player, true); } -void ScriptFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept +void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept { - ScriptFunctions::EquipItem(pid, slot, "", 0); + LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); + //ItemFunctions::EquipItem(pid, slot, "", 0); } -const char *ScriptFunctions::GetItemSlot(unsigned short pid, unsigned short slot) noexcept +const char *ItemFunctions::GetItemSlot(unsigned short pid, unsigned short slot) noexcept { - Player *player; + /*Player *player; GET_PLAYER(pid, player, 0); - return player->EquipedItem(slot)->refid.c_str(); + return player->EquipedItem(slot)->refid.c_str();*/ + LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); + return ""; } -bool ScriptFunctions::HasItemEquipped(unsigned short pid, const char* itemName) +bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemName) { Player *player; GET_PLAYER(pid, player, false); @@ -53,4 +58,13 @@ bool ScriptFunctions::HasItemEquipped(unsigned short pid, const char* itemName) if (Misc::StringUtils::ciEqual(player->EquipedItem(slot)->refid, itemName)) return true; return false; +} + +void ItemFunctions::RemoveItem(unsigned short pid, const char* itemName, unsigned short count) noexcept +{ + LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); +} +void ItemFunctions::GetItemCount(unsigned short pid, const char* itemName) noexcept +{ + LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); } \ No newline at end of file diff --git a/apps/openmw-mp/Script/Functions/Items.hpp b/apps/openmw-mp/Script/Functions/Items.hpp new file mode 100644 index 000000000..a0c0e1598 --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Items.hpp @@ -0,0 +1,29 @@ +// +// Created by koncord on 30.08.16. +// + +#ifndef OPENMW_ITEMS_HPP +#define OPENMW_ITEMS_HPP + +#define ITEMAPI \ + {"AddItem", ItemFunctions::AddItem},\ + {"RemoveItem", ItemFunctions::RemoveItem},\ + {"GetItemCount", ItemFunctions::GetItemCount},\ + {"EquipItem", ItemFunctions::EquipItem},\ + {"UnequipItem", ItemFunctions::UnequipItem},\ + {"GetItemSlot", ItemFunctions::GetItemSlot},\ + {"HasItemEquipped", ItemFunctions::HasItemEquipped}\ + +class ItemFunctions +{ +public: + static void AddItem(unsigned short pid, const char* itemName, unsigned short count) noexcept; + static void RemoveItem(unsigned short pid, const char* itemName, unsigned short count) noexcept; + static void GetItemCount(unsigned short pid, const char* itemName) noexcept; + static void EquipItem(unsigned short pid, unsigned short slot, const char* itemName, unsigned short count) noexcept; + static void UnequipItem(unsigned short pid, unsigned short slot) noexcept; + static bool HasItemEquipped(unsigned short pid, const char* itemName); + static const char *GetItemSlot(unsigned short pid, unsigned short slot) noexcept; +}; + +#endif //OPENMW_ITEMS_HPP diff --git a/apps/openmw-mp/Script/Functions/Stats.cpp b/apps/openmw-mp/Script/Functions/Stats.cpp index aff0390b5..43452f6ae 100644 --- a/apps/openmw-mp/Script/Functions/Stats.cpp +++ b/apps/openmw-mp/Script/Functions/Stats.cpp @@ -1,6 +1,7 @@ // // Created by koncord on 29.02.16. // +#include "Stats.hpp" #include #include @@ -14,7 +15,7 @@ using namespace std; using namespace ESM; -void ScriptFunctions::SetName(unsigned short pid, const char *name) noexcept +void StatsFunctions::SetName(unsigned short pid, const char *name) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -25,7 +26,7 @@ void ScriptFunctions::SetName(unsigned short pid, const char *name) noexcept player->GetCell()->mName = name; } -const char *ScriptFunctions::GetName(unsigned short pid) noexcept +const char *StatsFunctions::GetName(unsigned short pid) noexcept { Player *player; @@ -34,7 +35,7 @@ const char *ScriptFunctions::GetName(unsigned short pid) noexcept return player->Npc()->mName.c_str(); } -void ScriptFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcept +void StatsFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -45,7 +46,7 @@ void ScriptFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcep *player->BirthSign() = sign; } -const char *ScriptFunctions::GetBirthsign(unsigned short pid) noexcept +const char *StatsFunctions::GetBirthsign(unsigned short pid) noexcept { Player *player; @@ -55,7 +56,7 @@ const char *ScriptFunctions::GetBirthsign(unsigned short pid) noexcept return player->BirthSign()->c_str(); } -void ScriptFunctions::SetRace(unsigned short pid, const char *race) noexcept +void StatsFunctions::SetRace(unsigned short pid, const char *race) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -71,7 +72,7 @@ void ScriptFunctions::SetRace(unsigned short pid, const char *race) noexcept player->Npc()->mRace = race; } -const char *ScriptFunctions::GetRace(unsigned short pid) noexcept +const char *StatsFunctions::GetRace(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -79,7 +80,7 @@ const char *ScriptFunctions::GetRace(unsigned short pid) noexcept return player->Npc()->mRace.c_str(); } -void ScriptFunctions::SetClass(unsigned short pid, const char *className) noexcept +void StatsFunctions::SetClass(unsigned short pid, const char *className) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -95,7 +96,7 @@ void ScriptFunctions::SetClass(unsigned short pid, const char *className) noexce player->Npc()->mClass = className; } -const char *ScriptFunctions::GetClass(unsigned short pid) noexcept +const char *StatsFunctions::GetClass(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -103,7 +104,7 @@ const char *ScriptFunctions::GetClass(unsigned short pid) noexcept return player->Npc()->mClass.c_str(); } -void ScriptFunctions::SetHead(unsigned short pid, const char *race) noexcept +void StatsFunctions::SetHead(unsigned short pid, const char *race) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -114,7 +115,7 @@ void ScriptFunctions::SetHead(unsigned short pid, const char *race) noexcept player->Npc()->mHead = race; } -const char *ScriptFunctions::GetHead(unsigned short pid) noexcept +const char *StatsFunctions::GetHead(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -123,7 +124,7 @@ const char *ScriptFunctions::GetHead(unsigned short pid) noexcept return player->Npc()->mHead.c_str(); } -void ScriptFunctions::SetHairstyle(unsigned short pid, const char *style) noexcept +void StatsFunctions::SetHairstyle(unsigned short pid, const char *style) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -135,7 +136,7 @@ void ScriptFunctions::SetHairstyle(unsigned short pid, const char *style) noexce } -const char *ScriptFunctions::GetHairstyle(unsigned short pid) noexcept +const char *StatsFunctions::GetHairstyle(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -143,7 +144,7 @@ const char *ScriptFunctions::GetHairstyle(unsigned short pid) noexcept return player->Npc()->mHair.c_str(); } -int ScriptFunctions::GetIsMale(unsigned short pid) noexcept +int StatsFunctions::GetIsMale(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,false); @@ -152,7 +153,7 @@ int ScriptFunctions::GetIsMale(unsigned short pid) noexcept } -void ScriptFunctions::SetIsMale(unsigned short pid, int value) noexcept +void StatsFunctions::SetIsMale(unsigned short pid, int value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -161,7 +162,7 @@ void ScriptFunctions::SetIsMale(unsigned short pid, int value) noexcept } -float ScriptFunctions::GetHealth(unsigned short pid) noexcept +float StatsFunctions::GetHealth(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0.f); @@ -170,7 +171,7 @@ float ScriptFunctions::GetHealth(unsigned short pid) noexcept } -void ScriptFunctions::SetHealth(unsigned short pid, float value) noexcept +void StatsFunctions::SetHealth(unsigned short pid, float value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -178,7 +179,7 @@ void ScriptFunctions::SetHealth(unsigned short pid, float value) noexcept player->CreatureStats()->mDynamic[0].mBase = value; } -float ScriptFunctions::GetCurrentHealth(unsigned short pid) noexcept +float StatsFunctions::GetCurrentHealth(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.f); @@ -186,7 +187,7 @@ float ScriptFunctions::GetCurrentHealth(unsigned short pid) noexcept return player->CreatureStats()->mDynamic[0].mCurrent; } -void ScriptFunctions::SetCurrentHealth(unsigned short pid, float value) noexcept +void StatsFunctions::SetCurrentHealth(unsigned short pid, float value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -194,7 +195,7 @@ void ScriptFunctions::SetCurrentHealth(unsigned short pid, float value) noexcept player->CreatureStats()->mDynamic[0].mCurrent = 0; } -float ScriptFunctions::GetMagicka(unsigned short pid) noexcept +float StatsFunctions::GetMagicka(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0.f); @@ -202,7 +203,7 @@ float ScriptFunctions::GetMagicka(unsigned short pid) noexcept return player->CreatureStats()->mDynamic[1].mBase; } -void ScriptFunctions::SetMagicka(unsigned short pid, float value) noexcept +void StatsFunctions::SetMagicka(unsigned short pid, float value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -210,7 +211,7 @@ void ScriptFunctions::SetMagicka(unsigned short pid, float value) noexcept player->CreatureStats()->mDynamic[1].mBase = value; } -float ScriptFunctions::GetCurrentMagicka(unsigned short pid) noexcept +float StatsFunctions::GetCurrentMagicka(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.f); @@ -218,7 +219,7 @@ float ScriptFunctions::GetCurrentMagicka(unsigned short pid) noexcept return player->CreatureStats()->mDynamic[1].mCurrent; } -void ScriptFunctions::SetCurrentMagicka(unsigned short pid, float value) noexcept +void StatsFunctions::SetCurrentMagicka(unsigned short pid, float value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -226,7 +227,7 @@ void ScriptFunctions::SetCurrentMagicka(unsigned short pid, float value) noexcep player->CreatureStats()->mDynamic[1].mCurrent = 0; } -float ScriptFunctions::GetFatigue(unsigned short pid) noexcept +float StatsFunctions::GetFatigue(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0.f); @@ -235,7 +236,7 @@ float ScriptFunctions::GetFatigue(unsigned short pid) noexcept } -void ScriptFunctions::SetFatigue(unsigned short pid, float value) noexcept +void StatsFunctions::SetFatigue(unsigned short pid, float value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -243,7 +244,7 @@ void ScriptFunctions::SetFatigue(unsigned short pid, float value) noexcept player->CreatureStats()->mDynamic[2].mBase = value; } -float ScriptFunctions::GetCurrentFatigue(unsigned short pid) noexcept +float StatsFunctions::GetCurrentFatigue(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.f); @@ -251,7 +252,7 @@ float ScriptFunctions::GetCurrentFatigue(unsigned short pid) noexcept return player->CreatureStats()->mDynamic[2].mCurrent; } -void ScriptFunctions::SetCurrentFatigue(unsigned short pid, float value) noexcept +void StatsFunctions::SetCurrentFatigue(unsigned short pid, float value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -259,7 +260,7 @@ void ScriptFunctions::SetCurrentFatigue(unsigned short pid, float value) noexcep player->CreatureStats()->mDynamic[2].mCurrent = 0; } -int ScriptFunctions::GetAttributeId(const char *name) noexcept +int StatsFunctions::GetAttributeId(const char *name) noexcept { for (int x = 0; x < 8; x++) { @@ -272,7 +273,7 @@ int ScriptFunctions::GetAttributeId(const char *name) noexcept return -1; } -int ScriptFunctions::GetSkillId(const char *name) noexcept +int StatsFunctions::GetSkillId(const char *name) noexcept { for (int x = 0; x < 27; x++) { @@ -285,17 +286,17 @@ int ScriptFunctions::GetSkillId(const char *name) noexcept return -1; } -const char *ScriptFunctions::GetAttributeName(unsigned short attribute) noexcept +const char *StatsFunctions::GetAttributeName(unsigned short attribute) noexcept { return Attribute::sAttributeNames[attribute].c_str(); } -const char *ScriptFunctions::GetSkillName(unsigned short skill) noexcept +const char *StatsFunctions::GetSkillName(unsigned short skill) noexcept { return Skill::sSkillNames[skill].c_str(); } -int ScriptFunctions::GetAttribute(unsigned short pid, unsigned short attribute) noexcept +int StatsFunctions::GetAttribute(unsigned short pid, unsigned short attribute) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -306,7 +307,7 @@ int ScriptFunctions::GetAttribute(unsigned short pid, unsigned short attribute) return player->CreatureStats()->mAttributes[attribute].mBase; } -void ScriptFunctions::SetAttribute(unsigned short pid, unsigned short attribute, int value) noexcept +void StatsFunctions::SetAttribute(unsigned short pid, unsigned short attribute, int value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -317,7 +318,7 @@ void ScriptFunctions::SetAttribute(unsigned short pid, unsigned short attribute, player->CreatureStats()->mAttributes[attribute].mBase = value; } -int ScriptFunctions::GetCurrentAttribute(unsigned short pid, unsigned short attribute) noexcept +int StatsFunctions::GetCurrentAttribute(unsigned short pid, unsigned short attribute) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -328,7 +329,7 @@ int ScriptFunctions::GetCurrentAttribute(unsigned short pid, unsigned short attr return player->CreatureStats()->mAttributes[attribute].mCurrent; } -void ScriptFunctions::SetCurrentAttribute(unsigned short pid, unsigned short attribute, int value) noexcept +void StatsFunctions::SetCurrentAttribute(unsigned short pid, unsigned short attribute, int value) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -339,7 +340,7 @@ void ScriptFunctions::SetCurrentAttribute(unsigned short pid, unsigned short att player->CreatureStats()->mAttributes[attribute].mCurrent = value; } -int ScriptFunctions::GetSkill(unsigned short pid, unsigned short skill) noexcept +int StatsFunctions::GetSkill(unsigned short pid, unsigned short skill) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -350,7 +351,7 @@ int ScriptFunctions::GetSkill(unsigned short pid, unsigned short skill) noexcept return player->NpcStats()->mSkills[skill].mBase; } -void ScriptFunctions::SetSkill(unsigned short pid, unsigned short skill, int value) noexcept //TODO: need packet for one value +void StatsFunctions::SetSkill(unsigned short pid, unsigned short skill, int value) noexcept //TODO: need packet for one value { Player *player; GET_PLAYER(pid, player,); @@ -364,7 +365,7 @@ void ScriptFunctions::SetSkill(unsigned short pid, unsigned short skill, int val } -int ScriptFunctions::GetCurrentSkill(unsigned short pid, unsigned short skill) noexcept +int StatsFunctions::GetCurrentSkill(unsigned short pid, unsigned short skill) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -375,7 +376,7 @@ int ScriptFunctions::GetCurrentSkill(unsigned short pid, unsigned short skill) n return player->NpcStats()->mSkills[skill].mCurrent; } -void ScriptFunctions::SetCurrentSkill(unsigned short pid, unsigned short skill, int value) noexcept //TODO: need packet for one value +void StatsFunctions::SetCurrentSkill(unsigned short pid, unsigned short skill, int value) noexcept //TODO: need packet for one value { Player *player; GET_PLAYER(pid, player,); @@ -387,7 +388,7 @@ void ScriptFunctions::SetCurrentSkill(unsigned short pid, unsigned short skill, } -int ScriptFunctions::GetIncreaseSkill(unsigned short pid, unsigned int pos) noexcept +int StatsFunctions::GetIncreaseSkill(unsigned short pid, unsigned int pos) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -398,7 +399,7 @@ int ScriptFunctions::GetIncreaseSkill(unsigned short pid, unsigned int pos) noex return player->NpcStats()->mSkillIncrease[pos]; } -void ScriptFunctions::SetIncreaseSkill(unsigned short pid, unsigned int pos, int value) noexcept // TODO: need packet for transmit it +void StatsFunctions::SetIncreaseSkill(unsigned short pid, unsigned int pos, int value) noexcept // TODO: need packet for transmit it { Player *player; GET_PLAYER(pid, player,); @@ -409,7 +410,7 @@ void ScriptFunctions::SetIncreaseSkill(unsigned short pid, unsigned int pos, int player->NpcStats()->mSkillIncrease[pos] = value; } -void ScriptFunctions::SetCharGenStage(unsigned short pid, int start, int end) noexcept +void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -420,14 +421,14 @@ void ScriptFunctions::SetCharGenStage(unsigned short pid, int start, int end) no mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CHARGEN)->Send(player, false); } -void ScriptFunctions::Resurrect(unsigned short pid) +void StatsFunctions::Resurrect(unsigned short pid) { Player *player; GET_PLAYER(pid, player,); mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_RESURRECT)->RequestData(player->guid); } -void ScriptFunctions::SendBaseInfo(unsigned short pid) noexcept +void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -436,7 +437,7 @@ void ScriptFunctions::SendBaseInfo(unsigned short pid) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, true); } -void ScriptFunctions::SendAttributes(unsigned short pid) noexcept +void StatsFunctions::SendAttributes(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -445,7 +446,7 @@ void ScriptFunctions::SendAttributes(unsigned short pid) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, true); } -void ScriptFunctions::SendBaseStats(unsigned short pid) noexcept +void StatsFunctions::SendBaseStats(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -453,7 +454,7 @@ void ScriptFunctions::SendBaseStats(unsigned short pid) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_BASESTATS)->Send(player, true); } -void ScriptFunctions::SendSkills(unsigned short pid) noexcept +void StatsFunctions::SendSkills(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,); diff --git a/apps/openmw-mp/Script/Functions/Stats.hpp b/apps/openmw-mp/Script/Functions/Stats.hpp new file mode 100644 index 000000000..0e18af0ed --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Stats.hpp @@ -0,0 +1,134 @@ +// +// Created by koncord on 30.08.16. +// + +#ifndef OPENMW_STATS_HPP +#define OPENMW_STATS_HPP + +#define STATSFUNCTIONS \ + {"GetName", StatsFunctions::GetName},\ + {"SetName", StatsFunctions::SetName},\ + \ + {"GetRace", StatsFunctions::GetRace},\ + {"SetRace", StatsFunctions::SetRace},\ + \ + {"SetClass", StatsFunctions::SetClass},\ + {"GetClass", StatsFunctions::GetClass},\ + \ + {"GetHead", StatsFunctions::GetHead},\ + {"SetHead", StatsFunctions::SetHead},\ + \ + {"GetHair", StatsFunctions::GetHairstyle},\ + {"SetHair", StatsFunctions::SetHairstyle},\ + \ + {"GetIsMale", StatsFunctions::GetIsMale},\ + {"SetIsMale", StatsFunctions::SetIsMale},\ + \ + {"GetBirthsign", StatsFunctions::GetBirthsign},\ + {"SetBirthsign", StatsFunctions::SetBirthsign},\ + \ + {"GetAttributeId", StatsFunctions::GetAttributeId},\ + {"GetSkillId", StatsFunctions::GetSkillId},\ + {"GetAttributeName", StatsFunctions::GetAttributeName},\ + {"GetSkillName", StatsFunctions::GetSkillName},\ + \ + {"GetAttribute", StatsFunctions::GetAttribute},\ + {"SetAttribute", StatsFunctions::SetAttribute},\ + {"GetCurrentAttribute", StatsFunctions::GetCurrentAttribute},\ + {"SetCurrentAttribute", StatsFunctions::SetCurrentAttribute},\ + {"GetSkill", StatsFunctions::GetSkill},\ + {"SetSkill", StatsFunctions::SetSkill},\ + {"GetCurrentSkill", StatsFunctions::GetCurrentSkill},\ + {"SetCurrentSkill", StatsFunctions::SetCurrentSkill},\ + \ + {"GetHealth", StatsFunctions::GetHealth},\ + {"SetHealth", StatsFunctions::SetHealth},\ + {"GetCurrentHealth", StatsFunctions::GetCurrentHealth},\ + {"SetCurrentHealth", StatsFunctions::SetCurrentHealth},\ + \ + {"GetMagicka", StatsFunctions::GetMagicka},\ + {"SetMagicka", StatsFunctions::SetMagicka},\ + {"GetCurrentMagicka", StatsFunctions::GetCurrentMagicka},\ + {"SetCurrentMagicka", StatsFunctions::SetCurrentMagicka},\ + \ + {"SetFatigue", StatsFunctions::SetFatigue},\ + {"GetFatigue", StatsFunctions::GetFatigue},\ + {"SetCurrentFatigue", StatsFunctions::SetCurrentFatigue},\ + {"GetCurrentFatigue", StatsFunctions::GetCurrentFatigue},\ + \ + {"GetIncreaseSkill", StatsFunctions::GetIncreaseSkill},\ + {"SetIncreaseSkill", StatsFunctions::SetIncreaseSkill},\ + {"SetCharGenStage", StatsFunctions::SetCharGenStage},\ + {"Resurrect", StatsFunctions::Resurrect},\ + {"SendBaseInfo", StatsFunctions::SendBaseInfo},\ + {"SendAttributes", StatsFunctions::SendAttributes},\ + {"SendBaseStats", StatsFunctions::SendBaseStats},\ + {"SendSkills", StatsFunctions::SendSkills} + +class StatsFunctions +{ +public: + static void SetName(unsigned short pid, const char *name) noexcept; + static const char *GetName(unsigned short pid) noexcept; + + static void SetBirthsign(unsigned short pid, const char *name) noexcept; + static const char *GetBirthsign(unsigned short pid) noexcept; + + static void SetRace(unsigned short pid, const char *race) noexcept; + static const char *GetRace(unsigned short pid) noexcept; + + static void SetClass(unsigned short pid, const char *name) noexcept; + static const char *GetClass(unsigned short pid) noexcept; + + static void SetHead(unsigned short pid, const char *head) noexcept; + static const char *GetHead(unsigned short pid) noexcept; + + static void SetHairstyle(unsigned short pid, const char *style) noexcept; + static const char *GetHairstyle(unsigned short pid) noexcept; + + static void SetIsMale(unsigned short pid, int male) noexcept; + static int GetIsMale(unsigned short pid) noexcept; + + static float GetHealth(unsigned short pid) noexcept; + static void SetHealth(unsigned short pid, float health) noexcept; + static float GetCurrentHealth(unsigned short pid) noexcept; + static void SetCurrentHealth(unsigned short pid, float health) noexcept; + + static float GetMagicka(unsigned short pid) noexcept; + static void SetMagicka(unsigned short pid, float magicka) noexcept; + static float GetCurrentMagicka(unsigned short pid) noexcept; + static void SetCurrentMagicka(unsigned short pid, float magicka) noexcept; + + static float GetFatigue(unsigned short pid) noexcept; + static void SetFatigue(unsigned short pid, float fatigue) noexcept; + static float GetCurrentFatigue(unsigned short pid) noexcept; + static void SetCurrentFatigue(unsigned short pid, float fatigue) noexcept; + + static int GetAttributeId(const char *name) noexcept; + static int GetSkillId(const char *name) noexcept; + static const char *GetAttributeName(unsigned short attribute) noexcept; + static const char *GetSkillName(unsigned short skill) noexcept; + + static int GetAttribute(unsigned short pid, unsigned short attribute) noexcept; + static void SetAttribute(unsigned short pid, unsigned short attribute, int value) noexcept; + static int GetCurrentAttribute(unsigned short pid, unsigned short attribute) noexcept; + static void SetCurrentAttribute(unsigned short pid, unsigned short attribute, int value) noexcept; + + static int GetSkill(unsigned short pid, unsigned short skill) noexcept; + static void SetSkill(unsigned short pid, unsigned short skill, int value) noexcept; + static int GetCurrentSkill(unsigned short pid, unsigned short skill) noexcept; + static void SetCurrentSkill(unsigned short pid, unsigned short skill, int value) noexcept; + + static int GetIncreaseSkill(unsigned short pid, unsigned int pos) noexcept; + static void SetIncreaseSkill(unsigned short pid, unsigned int pos, int value) noexcept; + + static void Resurrect(unsigned short pid); + static void SetCharGenStage(unsigned short pid, int start, int end) noexcept; + + static void SendBaseInfo(unsigned short pid) noexcept; + static void SendAttributes(unsigned short pid) noexcept; + static void SendBaseStats(unsigned short pid) noexcept; + static void SendSkills(unsigned short pid) noexcept; +}; + +#endif //OPENMW_STATS_HPP diff --git a/apps/openmw-mp/Script/Functions/Translocations.cpp b/apps/openmw-mp/Script/Functions/Translocations.cpp index 78d5f0ea0..459a7afb7 100644 --- a/apps/openmw-mp/Script/Functions/Translocations.cpp +++ b/apps/openmw-mp/Script/Functions/Translocations.cpp @@ -1,7 +1,7 @@ // // Created by koncord on 29.02.16. // - +#include "Translocations.hpp" #include #include #include @@ -10,7 +10,7 @@ #include using namespace std; -void ScriptFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept +void TranslocationFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept { *x = 0.00; *y = 0.00; @@ -24,7 +24,7 @@ void ScriptFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) n *z = player->Position()->pos[2]; } -double ScriptFunctions::GetPosX(unsigned short pid) noexcept +double TranslocationFunctions::GetPosX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -32,7 +32,7 @@ double ScriptFunctions::GetPosX(unsigned short pid) noexcept return player->Position()->pos[0]; } -double ScriptFunctions::GetPosY(unsigned short pid) noexcept +double TranslocationFunctions::GetPosY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -40,7 +40,7 @@ double ScriptFunctions::GetPosY(unsigned short pid) noexcept return player->Position()->pos[1]; } -double ScriptFunctions::GetPosZ(unsigned short pid) noexcept +double TranslocationFunctions::GetPosZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -48,7 +48,7 @@ double ScriptFunctions::GetPosZ(unsigned short pid) noexcept return player->Position()->pos[2]; } -void ScriptFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept +void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -60,7 +60,7 @@ void ScriptFunctions::SetPos(unsigned short pid, double x, double y, double z) n mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_UPDATE_POS)->Send(player, false); } -void ScriptFunctions::SetCell(unsigned short pid, const char *name) noexcept +void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -81,7 +81,7 @@ void ScriptFunctions::SetCell(unsigned short pid, const char *name) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false); } -const char* ScriptFunctions::GetCell(unsigned short pid) noexcept +const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -90,7 +90,7 @@ const char* ScriptFunctions::GetCell(unsigned short pid) noexcept return player->GetCell()->mName.c_str(); } -void ScriptFunctions::SetExterior(unsigned short pid, int x, int y) noexcept +void TranslocationFunctions::SetExterior(unsigned short pid, int x, int y) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -109,21 +109,21 @@ void ScriptFunctions::SetExterior(unsigned short pid, int x, int y) noexcept mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false); } -int ScriptFunctions::GetExteriorX(unsigned short pid) noexcept +int TranslocationFunctions::GetExteriorX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0); return player->GetCell()->mCellId.mIndex.mX; } -int ScriptFunctions::GetExteriorY(unsigned short pid) noexcept +int TranslocationFunctions::GetExteriorY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player,0); return player->GetCell()->mCellId.mIndex.mY; } -bool ScriptFunctions::IsInInterior(unsigned short pid) noexcept +bool TranslocationFunctions::IsInInterior(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -131,7 +131,7 @@ bool ScriptFunctions::IsInInterior(unsigned short pid) noexcept return !player->GetCell()->isExterior(); } -void ScriptFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept +void TranslocationFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept { *x = 0.00; *y = 0.00; @@ -145,7 +145,7 @@ void ScriptFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) *z = player->Position()->rot[2]; } -double ScriptFunctions::GetAngleX(unsigned short pid) noexcept +double TranslocationFunctions::GetAngleX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -153,7 +153,7 @@ double ScriptFunctions::GetAngleX(unsigned short pid) noexcept return player->Position()->rot[0]; } -double ScriptFunctions::GetAngleY(unsigned short pid) noexcept +double TranslocationFunctions::GetAngleY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -161,7 +161,7 @@ double ScriptFunctions::GetAngleY(unsigned short pid) noexcept return player->Position()->rot[1]; } -double ScriptFunctions::GetAngleZ(unsigned short pid) noexcept +double TranslocationFunctions::GetAngleZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -169,7 +169,7 @@ double ScriptFunctions::GetAngleZ(unsigned short pid) noexcept return player->Position()->rot[2]; } -void ScriptFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept +void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player,); diff --git a/apps/openmw-mp/Script/Functions/Translocations.hpp b/apps/openmw-mp/Script/Functions/Translocations.hpp new file mode 100644 index 000000000..c8ec560cd --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Translocations.hpp @@ -0,0 +1,57 @@ +// +// Created by koncord on 30.08.16. +// + +#ifndef OPENMW_TRANSLOCATIONS_HPP +#define OPENMW_TRANSLOCATIONS_HPP + +#include "../Types.hpp" + +#define TRANSLOCATIONFUNCTIONS \ + {"GetPos", TranslocationFunctions::GetPos},\ + {"GetPosX", TranslocationFunctions::GetPosX},\ + {"GetPosY", TranslocationFunctions::GetPosY},\ + {"GetPosZ", TranslocationFunctions::GetPosZ},\ + {"SetPos", TranslocationFunctions::SetPos},\ +\ + {"GetAngle", TranslocationFunctions::GetAngle},\ + {"GetAngleX", TranslocationFunctions::GetAngleX},\ + {"GetAngleY", TranslocationFunctions::GetAngleY},\ + {"GetAngleZ", TranslocationFunctions::GetAngleZ},\ + {"SetAngle", TranslocationFunctions::SetAngle},\ +\ + {"GetCell", TranslocationFunctions::GetCell},\ + {"SetCell", TranslocationFunctions::SetCell},\ + {"SetExterior", TranslocationFunctions::SetExterior},\ + {"GetExteriorX", TranslocationFunctions::GetExteriorX},\ + {"GetExteriorY", TranslocationFunctions::GetExteriorY},\ + {"IsInInterior", TranslocationFunctions::IsInInterior} + + +class TranslocationFunctions +{ +public: + static void GetPos(unsigned short pid, float *x, float *y, float *z) noexcept; + static double GetPosX(unsigned short pid) noexcept; + static double GetPosY(unsigned short pid) noexcept; + static double GetPosZ(unsigned short pid) noexcept; + static void SetPos(unsigned short pid, double x, double y, double z) noexcept; + + + static void GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept; + static double GetAngleX(unsigned short pid) noexcept; + static double GetAngleY(unsigned short pid) noexcept; + static double GetAngleZ(unsigned short pid) noexcept; + static void SetAngle(unsigned short pid, double x, double y, double z) noexcept; + + static void SetCell(unsigned short pid, const char *name) noexcept; + static const char *GetCell(unsigned short pid) noexcept; + + static void SetExterior(unsigned short pid, int x, int y) noexcept; + static int GetExteriorX(unsigned short pid) noexcept; + static int GetExteriorY(unsigned short pid) noexcept; + + static bool IsInInterior(unsigned short pid) noexcept; +}; + +#endif //OPENMW_TRANSLOCATIONS_HPP diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 0be7bf9e6..d120108ab 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -6,6 +6,10 @@ #define SOURCEPAWN_SCRIPTFUNCTIONS_HPP #include