1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 06:23:52 +00:00

ScriptFunctions.hpp size reduction

This commit is contained in:
Koncord 2016-08-30 12:19:49 +08:00
parent 056209b26a
commit 1186d09ec0
9 changed files with 358 additions and 278 deletions

View file

@ -2,13 +2,14 @@
// Created by koncord on 23.07.16. // Created by koncord on 23.07.16.
// //
#include "GUI.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp> #include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Networking.hpp> #include <apps/openmw-mp/Networking.hpp>
#include <components/openmw-mp/NetworkMessages.hpp> #include <components/openmw-mp/NetworkMessages.hpp>
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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -44,3 +45,13 @@ void ScriptFunctions::InputDialog(unsigned short pid, int id, const char *label)
mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false); 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");
}

View file

@ -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

View file

@ -2,24 +2,26 @@
// Created by koncord on 02.03.16. // Created by koncord on 02.03.16.
// //
#include "Items.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp> #include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <components/openmw-mp/NetworkMessages.hpp> #include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Networking.hpp> #include <apps/openmw-mp/Networking.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
/*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,); 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, 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; Player *player;
GET_PLAYER(pid, 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); 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); 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; Player *player;
GET_PLAYER(pid, player, false); GET_PLAYER(pid, player, false);
@ -54,3 +59,12 @@ bool ScriptFunctions::HasItemEquipped(unsigned short pid, const char* itemName)
return true; return true;
return false; 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");
}

View file

@ -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

View file

@ -1,6 +1,7 @@
// //
// Created by koncord on 29.02.16. // Created by koncord on 29.02.16.
// //
#include "Stats.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp> #include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <components/openmw-mp/NetworkMessages.hpp> #include <components/openmw-mp/NetworkMessages.hpp>
@ -14,7 +15,7 @@
using namespace std; using namespace std;
using namespace ESM; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -25,7 +26,7 @@ void ScriptFunctions::SetName(unsigned short pid, const char *name) noexcept
player->GetCell()->mName = name; player->GetCell()->mName = name;
} }
const char *ScriptFunctions::GetName(unsigned short pid) noexcept const char *StatsFunctions::GetName(unsigned short pid) noexcept
{ {
Player *player; Player *player;
@ -34,7 +35,7 @@ const char *ScriptFunctions::GetName(unsigned short pid) noexcept
return player->Npc()->mName.c_str(); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -45,7 +46,7 @@ void ScriptFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcep
*player->BirthSign() = sign; *player->BirthSign() = sign;
} }
const char *ScriptFunctions::GetBirthsign(unsigned short pid) noexcept const char *StatsFunctions::GetBirthsign(unsigned short pid) noexcept
{ {
Player *player; Player *player;
@ -55,7 +56,7 @@ const char *ScriptFunctions::GetBirthsign(unsigned short pid) noexcept
return player->BirthSign()->c_str(); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -71,7 +72,7 @@ void ScriptFunctions::SetRace(unsigned short pid, const char *race) noexcept
player->Npc()->mRace = race; player->Npc()->mRace = race;
} }
const char *ScriptFunctions::GetRace(unsigned short pid) noexcept const char *StatsFunctions::GetRace(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -79,7 +80,7 @@ const char *ScriptFunctions::GetRace(unsigned short pid) noexcept
return player->Npc()->mRace.c_str(); 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; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
@ -95,7 +96,7 @@ void ScriptFunctions::SetClass(unsigned short pid, const char *className) noexce
player->Npc()->mClass = className; player->Npc()->mClass = className;
} }
const char *ScriptFunctions::GetClass(unsigned short pid) noexcept const char *StatsFunctions::GetClass(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -103,7 +104,7 @@ const char *ScriptFunctions::GetClass(unsigned short pid) noexcept
return player->Npc()->mClass.c_str(); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -114,7 +115,7 @@ void ScriptFunctions::SetHead(unsigned short pid, const char *race) noexcept
player->Npc()->mHead = race; player->Npc()->mHead = race;
} }
const char *ScriptFunctions::GetHead(unsigned short pid) noexcept const char *StatsFunctions::GetHead(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -123,7 +124,7 @@ const char *ScriptFunctions::GetHead(unsigned short pid) noexcept
return player->Npc()->mHead.c_str(); 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; Player *player;
GET_PLAYER(pid, 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; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -143,7 +144,7 @@ const char *ScriptFunctions::GetHairstyle(unsigned short pid) noexcept
return player->Npc()->mHair.c_str(); return player->Npc()->mHair.c_str();
} }
int ScriptFunctions::GetIsMale(unsigned short pid) noexcept int StatsFunctions::GetIsMale(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player,false); 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; Player *player;
GET_PLAYER(pid, 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; Player *player;
GET_PLAYER(pid, player,0.f); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -178,7 +179,7 @@ void ScriptFunctions::SetHealth(unsigned short pid, float value) noexcept
player->CreatureStats()->mDynamic[0].mBase = value; player->CreatureStats()->mDynamic[0].mBase = value;
} }
float ScriptFunctions::GetCurrentHealth(unsigned short pid) noexcept float StatsFunctions::GetCurrentHealth(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.f); GET_PLAYER(pid, player, 0.f);
@ -186,7 +187,7 @@ float ScriptFunctions::GetCurrentHealth(unsigned short pid) noexcept
return player->CreatureStats()->mDynamic[0].mCurrent; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -194,7 +195,7 @@ void ScriptFunctions::SetCurrentHealth(unsigned short pid, float value) noexcept
player->CreatureStats()->mDynamic[0].mCurrent = 0; player->CreatureStats()->mDynamic[0].mCurrent = 0;
} }
float ScriptFunctions::GetMagicka(unsigned short pid) noexcept float StatsFunctions::GetMagicka(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player,0.f); GET_PLAYER(pid, player,0.f);
@ -202,7 +203,7 @@ float ScriptFunctions::GetMagicka(unsigned short pid) noexcept
return player->CreatureStats()->mDynamic[1].mBase; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -210,7 +211,7 @@ void ScriptFunctions::SetMagicka(unsigned short pid, float value) noexcept
player->CreatureStats()->mDynamic[1].mBase = value; player->CreatureStats()->mDynamic[1].mBase = value;
} }
float ScriptFunctions::GetCurrentMagicka(unsigned short pid) noexcept float StatsFunctions::GetCurrentMagicka(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.f); GET_PLAYER(pid, player, 0.f);
@ -218,7 +219,7 @@ float ScriptFunctions::GetCurrentMagicka(unsigned short pid) noexcept
return player->CreatureStats()->mDynamic[1].mCurrent; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -226,7 +227,7 @@ void ScriptFunctions::SetCurrentMagicka(unsigned short pid, float value) noexcep
player->CreatureStats()->mDynamic[1].mCurrent = 0; player->CreatureStats()->mDynamic[1].mCurrent = 0;
} }
float ScriptFunctions::GetFatigue(unsigned short pid) noexcept float StatsFunctions::GetFatigue(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player,0.f); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -243,7 +244,7 @@ void ScriptFunctions::SetFatigue(unsigned short pid, float value) noexcept
player->CreatureStats()->mDynamic[2].mBase = value; player->CreatureStats()->mDynamic[2].mBase = value;
} }
float ScriptFunctions::GetCurrentFatigue(unsigned short pid) noexcept float StatsFunctions::GetCurrentFatigue(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.f); GET_PLAYER(pid, player, 0.f);
@ -251,7 +252,7 @@ float ScriptFunctions::GetCurrentFatigue(unsigned short pid) noexcept
return player->CreatureStats()->mDynamic[2].mCurrent; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -259,7 +260,7 @@ void ScriptFunctions::SetCurrentFatigue(unsigned short pid, float value) noexcep
player->CreatureStats()->mDynamic[2].mCurrent = 0; 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++) for (int x = 0; x < 8; x++)
{ {
@ -272,7 +273,7 @@ int ScriptFunctions::GetAttributeId(const char *name) noexcept
return -1; return -1;
} }
int ScriptFunctions::GetSkillId(const char *name) noexcept int StatsFunctions::GetSkillId(const char *name) noexcept
{ {
for (int x = 0; x < 27; x++) for (int x = 0; x < 27; x++)
{ {
@ -285,17 +286,17 @@ int ScriptFunctions::GetSkillId(const char *name) noexcept
return -1; return -1;
} }
const char *ScriptFunctions::GetAttributeName(unsigned short attribute) noexcept const char *StatsFunctions::GetAttributeName(unsigned short attribute) noexcept
{ {
return Attribute::sAttributeNames[attribute].c_str(); 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(); 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; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -306,7 +307,7 @@ int ScriptFunctions::GetAttribute(unsigned short pid, unsigned short attribute)
return player->CreatureStats()->mAttributes[attribute].mBase; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -317,7 +318,7 @@ void ScriptFunctions::SetAttribute(unsigned short pid, unsigned short attribute,
player->CreatureStats()->mAttributes[attribute].mBase = value; 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; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -328,7 +329,7 @@ int ScriptFunctions::GetCurrentAttribute(unsigned short pid, unsigned short attr
return player->CreatureStats()->mAttributes[attribute].mCurrent; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -339,7 +340,7 @@ void ScriptFunctions::SetCurrentAttribute(unsigned short pid, unsigned short att
player->CreatureStats()->mAttributes[attribute].mCurrent = value; 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; Player *player;
GET_PLAYER(pid, player, 0); 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; 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; Player *player;
GET_PLAYER(pid, 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; Player *player;
GET_PLAYER(pid, player, 0); 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; 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; Player *player;
GET_PLAYER(pid, 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; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -398,7 +399,7 @@ int ScriptFunctions::GetIncreaseSkill(unsigned short pid, unsigned int pos) noex
return player->NpcStats()->mSkillIncrease[pos]; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
@ -409,7 +410,7 @@ void ScriptFunctions::SetIncreaseSkill(unsigned short pid, unsigned int pos, int
player->NpcStats()->mSkillIncrease[pos] = value; 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_RESURRECT)->RequestData(player->guid); 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);

View file

@ -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

View file

@ -1,7 +1,7 @@
// //
// Created by koncord on 29.02.16. // Created by koncord on 29.02.16.
// //
#include "Translocations.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp> #include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <components/openmw-mp/NetworkMessages.hpp> #include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Player.hpp> #include <apps/openmw-mp/Player.hpp>
@ -10,7 +10,7 @@
#include <iostream> #include <iostream>
using namespace std; 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; *x = 0.00;
*y = 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]; *z = player->Position()->pos[2];
} }
double ScriptFunctions::GetPosX(unsigned short pid) noexcept double TranslocationFunctions::GetPosX(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.0f); GET_PLAYER(pid, player, 0.0f);
@ -32,7 +32,7 @@ double ScriptFunctions::GetPosX(unsigned short pid) noexcept
return player->Position()->pos[0]; return player->Position()->pos[0];
} }
double ScriptFunctions::GetPosY(unsigned short pid) noexcept double TranslocationFunctions::GetPosY(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.0f); GET_PLAYER(pid, player, 0.0f);
@ -40,7 +40,7 @@ double ScriptFunctions::GetPosY(unsigned short pid) noexcept
return player->Position()->pos[1]; return player->Position()->pos[1];
} }
double ScriptFunctions::GetPosZ(unsigned short pid) noexcept double TranslocationFunctions::GetPosZ(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.0f); GET_PLAYER(pid, player, 0.0f);
@ -48,7 +48,7 @@ double ScriptFunctions::GetPosZ(unsigned short pid) noexcept
return player->Position()->pos[2]; 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
@ -90,7 +90,7 @@ const char* ScriptFunctions::GetCell(unsigned short pid) noexcept
return player->GetCell()->mName.c_str(); 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; Player *player;
GET_PLAYER(pid, 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); 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; Player *player;
GET_PLAYER(pid, player,0); GET_PLAYER(pid, player,0);
return player->GetCell()->mCellId.mIndex.mX; return player->GetCell()->mCellId.mIndex.mX;
} }
int ScriptFunctions::GetExteriorY(unsigned short pid) noexcept int TranslocationFunctions::GetExteriorY(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player,0); GET_PLAYER(pid, player,0);
return player->GetCell()->mCellId.mIndex.mY; return player->GetCell()->mCellId.mIndex.mY;
} }
bool ScriptFunctions::IsInInterior(unsigned short pid) noexcept bool TranslocationFunctions::IsInInterior(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, false); GET_PLAYER(pid, player, false);
@ -131,7 +131,7 @@ bool ScriptFunctions::IsInInterior(unsigned short pid) noexcept
return !player->GetCell()->isExterior(); 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; *x = 0.00;
*y = 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]; *z = player->Position()->rot[2];
} }
double ScriptFunctions::GetAngleX(unsigned short pid) noexcept double TranslocationFunctions::GetAngleX(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.0f); GET_PLAYER(pid, player, 0.0f);
@ -153,7 +153,7 @@ double ScriptFunctions::GetAngleX(unsigned short pid) noexcept
return player->Position()->rot[0]; return player->Position()->rot[0];
} }
double ScriptFunctions::GetAngleY(unsigned short pid) noexcept double TranslocationFunctions::GetAngleY(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.0f); GET_PLAYER(pid, player, 0.0f);
@ -161,7 +161,7 @@ double ScriptFunctions::GetAngleY(unsigned short pid) noexcept
return player->Position()->rot[1]; return player->Position()->rot[1];
} }
double ScriptFunctions::GetAngleZ(unsigned short pid) noexcept double TranslocationFunctions::GetAngleZ(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, 0.0f); GET_PLAYER(pid, player, 0.0f);
@ -169,7 +169,7 @@ double ScriptFunctions::GetAngleZ(unsigned short pid) noexcept
return player->Position()->rot[2]; 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; Player *player;
GET_PLAYER(pid, player,); GET_PLAYER(pid, player,);

View file

@ -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

View file

@ -6,6 +6,10 @@
#define SOURCEPAWN_SCRIPTFUNCTIONS_HPP #define SOURCEPAWN_SCRIPTFUNCTIONS_HPP
#include <Script/Functions/CharClass.hpp> #include <Script/Functions/CharClass.hpp>
#include <Script/Functions/Translocations.hpp>
#include <Script/Functions/GUI.hpp>
#include <Script/Functions/Stats.hpp>
#include <Script/Functions/Items.hpp>
#include <RakNetTypes.h> #include <RakNetTypes.h>
//#include <amx/amx.h> //#include <amx/amx.h>
#include <tuple> #include <tuple>
@ -33,96 +37,9 @@ public:
static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept; static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
static boost::any CallPublic(const char *name, ...) noexcept; static boost::any CallPublic(const char *name, ...) noexcept;
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;
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 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;
static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept; static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept;
static void CleanChat(unsigned short pid); static void CleanChat(unsigned short pid);
static void CleanChat(); static void CleanChat();
static void SetCharGenStage(unsigned short pid, int start, int end) noexcept;
/** /**
* \brief Create timer * \brief Create timer
@ -133,7 +50,6 @@ public:
static int CreateTimer(ScriptFunc callback, int msec) noexcept; static int CreateTimer(ScriptFunc callback, int msec) noexcept;
static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept; static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept;
static void StartTimer(int timerId) noexcept; static void StartTimer(int timerId) noexcept;
static void StopTimer(int timerId) noexcept; static void StopTimer(int timerId) noexcept;
static void RestartTimer(int timerId, int msec) noexcept; static void RestartTimer(int timerId, int msec) noexcept;
@ -142,25 +58,6 @@ public:
static void Kick(unsigned short pid) noexcept; static void Kick(unsigned short pid) noexcept;
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;
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;
//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
{
}
static constexpr ScriptFunctionData functions[]{ static constexpr ScriptFunctionData functions[]{
{"CreateTimer", ScriptFunctions::CreateTimer}, {"CreateTimer", ScriptFunctions::CreateTimer},
{"CreateTimerEx", reinterpret_cast<Function<void>>(ScriptFunctions::CreateTimerEx)}, {"CreateTimerEx", reinterpret_cast<Function<void>>(ScriptFunctions::CreateTimerEx)},
@ -176,104 +73,14 @@ public:
{"StopServer", ScriptFunctions::StopServer}, {"StopServer", ScriptFunctions::StopServer},
{"GetPos", ScriptFunctions::GetPos},
{"GetPosX", ScriptFunctions::GetPosX},
{"GetPosY", ScriptFunctions::GetPosY},
{"GetPosZ", ScriptFunctions::GetPosZ},
{"SetPos", ScriptFunctions::SetPos},
{"GetAngle", ScriptFunctions::GetAngle},
{"GetAngleX", ScriptFunctions::GetAngleX},
{"GetAngleY", ScriptFunctions::GetAngleY},
{"GetAngleZ", ScriptFunctions::GetAngleZ},
{"SetAngle", ScriptFunctions::SetAngle},
{"GetCell", ScriptFunctions::GetCell},
{"SetCell", ScriptFunctions::SetCell},
{"SetExterior", ScriptFunctions::SetExterior},
{"GetExteriorX", ScriptFunctions::GetExteriorX},
{"GetExteriorY", ScriptFunctions::GetExteriorY},
{"IsInInterior", ScriptFunctions::IsInInterior},
{"GetName", ScriptFunctions::GetName},
{"SetName", ScriptFunctions::SetName},
{"GetRace", ScriptFunctions::GetRace},
{"SetRace", ScriptFunctions::SetRace},
{"SetClass", ScriptFunctions::SetClass},
{"GetClass", ScriptFunctions::GetClass},
{"GetHead", ScriptFunctions::GetHead},
{"SetHead", ScriptFunctions::SetHead},
{"GetHair", ScriptFunctions::GetHairstyle},
{"SetHair", ScriptFunctions::SetHairstyle},
{"GetIsMale", ScriptFunctions::GetIsMale},
{"SetIsMale", ScriptFunctions::SetIsMale},
{"GetBirthsign", ScriptFunctions::GetBirthsign},
{"SetBirthsign", ScriptFunctions::SetBirthsign},
{"GetAttributeId", ScriptFunctions::GetAttributeId},
{"GetSkillId", ScriptFunctions::GetSkillId},
{"GetAttributeName", ScriptFunctions::GetAttributeName},
{"GetSkillName", ScriptFunctions::GetSkillName},
{"GetAttribute", ScriptFunctions::GetAttribute},
{"SetAttribute", ScriptFunctions::SetAttribute},
{"GetCurrentAttribute", ScriptFunctions::GetCurrentAttribute},
{"SetCurrentAttribute", ScriptFunctions::SetCurrentAttribute},
{"GetSkill", ScriptFunctions::GetSkill},
{"SetSkill", ScriptFunctions::SetSkill},
{"GetCurrentSkill", ScriptFunctions::GetCurrentSkill},
{"SetCurrentSkill", ScriptFunctions::SetCurrentSkill},
{"GetHealth", ScriptFunctions::GetHealth},
{"SetHealth", ScriptFunctions::SetHealth},
{"GetCurrentHealth", ScriptFunctions::GetCurrentHealth},
{"SetCurrentHealth", ScriptFunctions::SetCurrentHealth},
{"GetMagicka", ScriptFunctions::GetMagicka},
{"SetMagicka", ScriptFunctions::SetMagicka},
{"GetCurrentMagicka", ScriptFunctions::GetCurrentMagicka},
{"SetCurrentMagicka", ScriptFunctions::SetCurrentMagicka},
{"SetFatigue", ScriptFunctions::SetFatigue},
{"GetFatigue", ScriptFunctions::GetFatigue},
{"SetCurrentFatigue", ScriptFunctions::SetCurrentFatigue},
{"GetCurrentFatigue", ScriptFunctions::GetCurrentFatigue},
{"GetIncreaseSkill", ScriptFunctions::GetIncreaseSkill},
{"SetIncreaseSkill", ScriptFunctions::SetIncreaseSkill},
// {"Cast", ScriptFunctions::Cast}, // {"Cast", ScriptFunctions::Cast},
// {"AddItem", ScriptFunctions::AddItem},
// {"RemoveItem", ScriptFunctions::RemoveItem},
// {"GetItemCount", ScriptFunctions::GetItemCount},
{"EquipItem", ScriptFunctions::EquipItem},
{"UnequipItem", ScriptFunctions::UnequipItem},
{"GetItemSlot", ScriptFunctions::GetItemSlot},
{"HasItemEquipped", ScriptFunctions::HasItemEquipped},
{"SendMessage", ScriptFunctions::SendMessage}, {"SendMessage", ScriptFunctions::SendMessage},
{"SetCharGenStage", ScriptFunctions::SetCharGenStage},
{"Resurrect", ScriptFunctions::Resurrect},
{"MessageBox", ScriptFunctions::MessageBox},
{"CustomMessageBox", ScriptFunctions::CustomMessageBox},
{"InputDialog", ScriptFunctions::InputDialog},
{"Kick", ScriptFunctions::Kick}, {"Kick", ScriptFunctions::Kick},
{"SendBaseInfo", ScriptFunctions::SendBaseInfo}, TRANSLOCATIONFUNCTIONS,
{"SendAttributes", ScriptFunctions::SendAttributes}, STATSFUNCTIONS,
{"SendBaseStats", ScriptFunctions::SendBaseStats}, ITEMAPI,
{"SendSkills", ScriptFunctions::SendSkills}, GUIFUNCTIONS,
{"SetMapVisibility", ScriptFunctions::SetMapVisibility},
{"SetMapVisibilityAll", ScriptFunctions::SetMapVisibilityAll},
CHARCLASSFUNCTIONS, CHARCLASSFUNCTIONS,