openmw-tes3coop/apps/openmw-mp/Player.hpp
Koncord c27351c19e Implement inventory functions
AddItem, RemoveItem, GetItemName, GetItemCount, GetItemHealth, GetInventorySize SendInventory
Example:
```lua
tes3mp.AddItem(pid, "glass dagger", 1, 50)
tes3mp.AddItem(pid, "glass dagger", 1, -1)
tes3mp.SendInventory(pid)
tes3mp.RemoveItem(pid, "glass dagger", 1)
tes3mp.SendInventory(pid)
local invSize = tes3mp.GetInventorySize(pid) - 1
for i = 0, invSize do
    print(("%s %d %d"):format(tes3mp.GetItemName(pid, i), tes3mp.GetItemCount(pid, i), tes3mp.GetItemHealth(pid, i)))
end
```
2016-10-23 02:57:49 +08:00

73 lines
1.5 KiB
C++

//
// Created by koncord on 05.01.16.
//
#ifndef OPENMW_PLAYER_HPP
#define OPENMW_PLAYER_HPP
#include <map>
#include <string>
#include <RakNetTypes.h>
#include <components/esm/npcstats.hpp>
#include <components/esm/cellid.hpp>
#include <components/esm/loadnpc.hpp>
#include <components/esm/loadcell.hpp>
#include <components/openmw-mp/Log.hpp>
#include <components/openmw-mp/Base/BasePlayer.hpp>
struct Player;
typedef std::map<RakNet::RakNetGUID, Player*> TPlayers;
typedef std::map<unsigned short, Player*> TSlots;
class Players
{
public:
static void NewPlayer(RakNet::RakNetGUID id);
static void DeletePlayer(RakNet::RakNetGUID id);
static Player *GetPlayer(RakNet::RakNetGUID id);
static Player *GetPlayer(unsigned short id);
static TPlayers *GetPlayers();
private:
static TPlayers players;
static TSlots slots;
};
class Player : public mwmp::BasePlayer
{
unsigned short id;
public:
enum
{
NOTLOADED=0,
LOADED,
POSTLOADED
};
Player(RakNet::RakNetGUID id);
unsigned short GetID();
void SetID(unsigned short id);
bool isHandshaked();
void Handshake();
void Loaded(int state);
int LoadedState();
void setLastAttackerID(unsigned short pid);
void resetLastAttacker();
unsigned short getLastAttackerID();
virtual ~Player();
public:
mwmp::Inventory inventorySendBuffer;
private:
bool handshake;
int loaded;
unsigned short lastAttacker;
};
#endif //OPENMW_PLAYER_HPP