1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 18:49:54 +00:00
openmw-tes3mp/components/openmw-mp/Base/BaseStructs.hpp
David Cernat e6c626f127 [General] Move handling of client globals to ClientScriptGlobal packet
ClientScriptGlobal is a new Worldstate packet that handles short, long and float values for global variables in clientside scripts.

Previously, short values were handled by the ScriptGlobalShort packet, while a partially implemented ScriptGlobalFloat packet also existed, but both of those packets were Object packets because they were added near the end of 2016 when only Player and Object packets existed (with the latter actually being called WorldEvent packets at the time). Both ScriptGlobalShort and ScriptGlobalFloat have now been removed.

The serverside script functions previously used to interact with ScriptGlobalShort have, however, been kept so they can be adjusted to work with local variables in clientside scripts instead in a future commit.
2020-01-04 09:56:37 +02:00

156 lines
2.8 KiB
C++

#ifndef OPENMW_BASESTRUCTS_HPP
#define OPENMW_BASESTRUCTS_HPP
#include <string>
#include <components/esm/loadcell.hpp>
#include <components/esm/statstate.hpp>
#include <RakNetTypes.h>
namespace mwmp
{
enum PACKET_ORIGIN
{
CLIENT_GAMEPLAY = 0,
CLIENT_CONSOLE = 1,
CLIENT_DIALOGUE = 2,
CLIENT_SCRIPT_LOCAL = 3,
CLIENT_SCRIPT_GLOBAL = 4,
SERVER_SCRIPT = 5
};
enum VARIABLE_TYPE
{
INTEGER,
FLOAT
};
struct ClientVariable
{
std::string id;
char variableType;
int intValue;
float floatValue;
};
struct Time
{
float hour;
int day;
int month;
int year;
int daysPassed;
float timeScale;
};
struct Item
{
std::string refId;
int count;
int charge;
float enchantmentCharge;
std::string soul;
inline bool operator==(const Item& rhs)
{
return refId == rhs.refId && count == rhs.count && charge == rhs.charge &&
enchantmentCharge == rhs.enchantmentCharge && soul == rhs.soul;
}
};
struct Target
{
bool isPlayer;
std::string refId;
unsigned int refNum;
unsigned int mpNum;
std::string name; // Remove this once the server can get names corresponding to different refIds
RakNet::RakNetGUID guid;
};
class Attack
{
public:
Target target;
enum TYPE
{
MELEE = 0,
RANGED
};
char type;
std::string attackAnimation;
std::string rangedWeaponId;
std::string rangedAmmoId;
ESM::Position hitPosition;
float damage = 0;
float attackStrength = 0;
bool isHit = false;
bool success = false;
bool block = false;
bool pressed = false;
bool instant = false;
bool knockdown = false;
bool applyWeaponEnchantment = false;
bool applyAmmoEnchantment = false;
bool shouldSend = false;
};
class Cast
{
public:
Target target;
char type; // 0 - regular magic, 1 - item magic
enum TYPE
{
REGULAR = 0,
ITEM
};
std::string spellId; // id of spell (e.g. "fireball")
std::string itemId;
ESM::Position hitPosition;
bool isHit;
bool success;
bool pressed;
bool instant;
bool shouldSend;
};
struct Animation
{
std::string groupname;
int mode;
int count;
bool persist;
};
struct SimpleCreatureStats
{
ESM::StatState<float> mDynamic[3];
bool mDead;
bool mDeathAnimationFinished;
};
}
#endif //OPENMW_BASESTRUCTS_HPP