2016-01-12 03:41:44 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 24.01.16.
|
|
|
|
//
|
|
|
|
|
2016-11-17 05:18:35 +00:00
|
|
|
#ifndef SCRIPTFUNCTIONS_HPP
|
|
|
|
#define SCRIPTFUNCTIONS_HPP
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-08-30 03:17:06 +00:00
|
|
|
#include <Script/Functions/CharClass.hpp>
|
2016-08-30 04:19:49 +00:00
|
|
|
#include <Script/Functions/Translocations.hpp>
|
|
|
|
#include <Script/Functions/GUI.hpp>
|
|
|
|
#include <Script/Functions/Stats.hpp>
|
|
|
|
#include <Script/Functions/Items.hpp>
|
2016-11-21 18:37:04 +00:00
|
|
|
#include <Script/Functions/Spells.hpp>
|
2016-08-30 05:24:31 +00:00
|
|
|
#include <Script/Functions/World.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <RakNetTypes.h>
|
|
|
|
//#include <amx/amx.h>
|
|
|
|
#include <tuple>
|
|
|
|
#include <apps/openmw-mp/Player.hpp>
|
|
|
|
#include "ScriptFunction.hpp"
|
|
|
|
#include "Types.hpp"
|
|
|
|
|
|
|
|
#define GET_PLAYER(pid, pl, retvalue) \
|
2016-11-16 00:05:14 +00:00
|
|
|
pl = Players::getPlayer(pid); \
|
2016-01-12 03:41:44 +00:00
|
|
|
if (player == 0) {\
|
|
|
|
fprintf(stderr, "%s: Player with pid \'%d\' not found\n", __PRETTY_FUNCTION__, pid);\
|
2016-11-16 17:27:46 +00:00
|
|
|
/*ScriptFunctions::StopServer(1);*/ \
|
2016-01-12 03:41:44 +00:00
|
|
|
return retvalue;\
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ScriptFunctions
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static void GetArguments(std::vector<boost::any> ¶ms, va_list args, const std::string &def);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static void StopServer(int code) noexcept;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
|
|
|
|
static boost::any CallPublic(const char *name, ...) noexcept;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept;
|
|
|
|
static void CleanChat(unsigned short pid);
|
|
|
|
static void CleanChat();
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Create timer
|
|
|
|
* \param callback
|
|
|
|
* \param msec
|
|
|
|
* \return return timer id
|
|
|
|
*/
|
2016-11-16 17:27:46 +00:00
|
|
|
static int CreateTimer(ScriptFunc callback, int msec) noexcept;
|
|
|
|
static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static void StartTimer(int timerId) noexcept;
|
|
|
|
static void StopTimer(int timerId) noexcept;
|
|
|
|
static void RestartTimer(int timerId, int msec) noexcept;
|
|
|
|
static void FreeTimer(int timerId) noexcept;
|
|
|
|
static bool IsTimerElapsed(int timerId) noexcept;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static void Kick(unsigned short pid) noexcept;
|
|
|
|
static const char *GetServerVersion() noexcept;
|
|
|
|
static const char *GetProtocolVersion() noexcept;
|
|
|
|
static int GetAvgPing(unsigned short pid) noexcept;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
static constexpr ScriptFunctionData functions[]{
|
2016-11-16 17:27:46 +00:00
|
|
|
{"CreateTimer", ScriptFunctions::CreateTimer},
|
|
|
|
{"CreateTimerEx", reinterpret_cast<Function<void>>(ScriptFunctions::CreateTimerEx)},
|
|
|
|
{"MakePublic", ScriptFunctions::MakePublic},
|
|
|
|
{"CallPublic", reinterpret_cast<Function<void>>(ScriptFunctions::CallPublic)},
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
{"StartTimer", ScriptFunctions::StartTimer},
|
|
|
|
{"StopTimer", ScriptFunctions::StopTimer},
|
|
|
|
{"RestartTimer", ScriptFunctions::RestartTimer},
|
|
|
|
{"FreeTimer", ScriptFunctions::FreeTimer},
|
|
|
|
{"IsTimerElapsed", ScriptFunctions::IsTimerElapsed},
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
{"StopServer", ScriptFunctions::StopServer},
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
{"SendMessage", ScriptFunctions::SendMessage},
|
|
|
|
{"Kick", ScriptFunctions::Kick},
|
|
|
|
{"GetServerVersion", ScriptFunctions::GetServerVersion},
|
|
|
|
{"GetProtocolVersion", ScriptFunctions::GetProtocolVersion},
|
|
|
|
{"GetAvgPing", ScriptFunctions::GetAvgPing},
|
2016-08-05 06:26:32 +00:00
|
|
|
|
2016-08-30 04:19:49 +00:00
|
|
|
TRANSLOCATIONFUNCTIONS,
|
|
|
|
STATSFUNCTIONS,
|
|
|
|
ITEMAPI,
|
2016-11-21 18:37:04 +00:00
|
|
|
SPELLAPI,
|
2016-08-30 04:19:49 +00:00
|
|
|
GUIFUNCTIONS,
|
2016-08-30 03:17:06 +00:00
|
|
|
CHARCLASSFUNCTIONS,
|
2016-08-30 05:24:31 +00:00
|
|
|
WORLDFUNCTIONS,
|
2016-01-12 03:41:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr ScriptCallbackData callbacks[]{
|
2016-09-25 11:28:25 +00:00
|
|
|
{"Main", Function<int, int, int>()},
|
2016-11-16 17:27:46 +00:00
|
|
|
{"OnServerInit", Function<void>()},
|
|
|
|
{"OnServerExit", Function<void, bool>()},
|
|
|
|
{"OnPlayerConnect", Function<bool, unsigned short>()},
|
|
|
|
{"OnPlayerDisconnect", Function<void, unsigned short>()},
|
|
|
|
{"OnPlayerDeath", Function<void, unsigned short, short, unsigned short>()},
|
|
|
|
{"OnPlayerResurrect", Function<void, unsigned short>()},
|
|
|
|
{"OnPlayerChangeCell", Function<void, unsigned short>()},
|
|
|
|
{"OnPlayerChangeAttributes", Function<void, unsigned short>()},
|
|
|
|
{"OnPlayerChangeSkills", Function<void, unsigned short>()},
|
|
|
|
{"OnPlayerChangeLevel", Function<void, unsigned short>()},
|
|
|
|
{"OnPlayerChangeEquipment", Function<void, unsigned short>()},
|
|
|
|
{"OnPlayerChangeInventory", Function<void, unsigned short>()},
|
2016-11-21 04:07:29 +00:00
|
|
|
{"OnPlayerChangeSpellbook", Function<void, unsigned short>()},
|
2016-11-16 17:27:46 +00:00
|
|
|
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},
|
|
|
|
{"OnPlayerEndCharGen", Function<void, unsigned short>()},
|
|
|
|
{"OnGUIAction", Function<void, unsigned short, int, const char*>()}
|
2016-01-12 03:41:44 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-11-17 05:18:35 +00:00
|
|
|
#endif //SCRIPTFUNCTIONS_HPP
|