|
|
|
//
|
|
|
|
// Created by koncord on 07.01.16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OPENMW_BASEPLAYER_HPP
|
|
|
|
#define OPENMW_BASEPLAYER_HPP
|
|
|
|
|
|
|
|
#include <components/esm/npcstats.hpp>
|
|
|
|
#include <components/esm/loadcell.hpp>
|
|
|
|
#include <components/esm/loadnpc.hpp>
|
|
|
|
#include <components/esm/creaturestats.hpp>
|
|
|
|
#include <components/esm/loadclas.hpp>
|
|
|
|
#include <components/esm/loadspel.hpp>
|
|
|
|
#include <RakNetTypes.h>
|
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
|
|
|
class Attack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RakNet::RakNetGUID target;
|
|
|
|
RakNet::RakNetGUID attacker;
|
|
|
|
char type; // 0 - melee, 1 - magic, 2 - throwable
|
|
|
|
enum TYPE
|
|
|
|
{
|
|
|
|
MELEE = 0,
|
|
|
|
MAGIC,
|
|
|
|
THROWABLE
|
|
|
|
};
|
|
|
|
std::string refid; // id of spell (e.g. "fireball")
|
|
|
|
char success;
|
|
|
|
char block;
|
|
|
|
float damage;
|
|
|
|
char pressed;
|
|
|
|
char knockdown;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Item
|
|
|
|
{
|
|
|
|
std::string refid;
|
|
|
|
int count;
|
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
```
8 years ago
|
|
|
int health;
|
|
|
|
inline bool operator==(const Item& rhs)
|
|
|
|
{
|
|
|
|
return refid == rhs.refid && count == rhs.count && health == rhs.health;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Inventory
|
|
|
|
{
|
|
|
|
std::vector<Item> items;
|
|
|
|
unsigned int count;
|
|
|
|
enum ACTION_TYPE
|
|
|
|
{
|
|
|
|
UPDATE = 0,
|
|
|
|
ADDITEM,
|
|
|
|
REMOVEITEM
|
|
|
|
};
|
|
|
|
int action; //0 - FullUpdate, 1 - AddItem, 2 - RemoveItem
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Spellbook
|
|
|
|
{
|
|
|
|
std::vector<ESM::Spell> spells;
|
|
|
|
unsigned int count;
|
|
|
|
enum ACTION_TYPE
|
|
|
|
{
|
|
|
|
UPDATE = 0,
|
|
|
|
ADD,
|
|
|
|
REMOVE
|
|
|
|
};
|
|
|
|
int action; //0 - Update, 1 - Add, 2 - Remove
|
|
|
|
};
|
|
|
|
|
|
|
|
class BasePlayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
struct CGStage
|
|
|
|
{
|
|
|
|
int current, end;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GUIMessageBox
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
int type;
|
|
|
|
enum GUI_TYPE
|
|
|
|
{
|
|
|
|
MessageBox = 0,
|
|
|
|
CustomMessageBox,
|
|
|
|
InputDialog,
|
|
|
|
PasswordDialog,
|
|
|
|
ListBox
|
|
|
|
};
|
|
|
|
std::string label;
|
|
|
|
std::string buttons;
|
|
|
|
|
|
|
|
std::string data;
|
|
|
|
};
|
|
|
|
|
|
|
|
BasePlayer(RakNet::RakNetGUID guid) : guid(guid)
|
|
|
|
{
|
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
```
8 years ago
|
|
|
inventory.action = 0;
|
|
|
|
inventory.count = 0;
|
|
|
|
spellbook.action = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BasePlayer()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ESM::Position *Position()
|
|
|
|
{
|
|
|
|
return &pos;
|
|
|
|
}
|
|
|
|
virtual ESM::NPC *Npc()
|
|
|
|
{
|
|
|
|
return &npc;
|
|
|
|
}
|
|
|
|
virtual ESM::NpcStats *NpcStats()
|
|
|
|
{
|
|
|
|
return &npcStats;
|
|
|
|
}
|
|
|
|
virtual ESM::CreatureStats *CreatureStats()
|
|
|
|
{
|
|
|
|
return &creatureStats;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual unsigned int *MovementFlags()
|
|
|
|
{
|
|
|
|
return &movementFlags;
|
|
|
|
}
|
|
|
|
virtual ESM::Cell *getCell()
|
|
|
|
{
|
|
|
|
return &cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Item *EquipedItem(int id)
|
|
|
|
{
|
|
|
|
if (id >= 18) return &equipedItems[18];
|
|
|
|
return &equipedItems[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual char *MovementAnim()
|
|
|
|
{
|
|
|
|
return &movementAnim;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual char *DrawState()
|
|
|
|
{
|
|
|
|
return &drawState;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ESM::Position *Dir()
|
|
|
|
{
|
|
|
|
return &dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Attack *getAttack()
|
|
|
|
{
|
|
|
|
return &attack;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string *BirthSign()
|
|
|
|
{
|
|
|
|
return &birthSign;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string *ChatMessage()
|
|
|
|
{
|
|
|
|
return &chatMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual CGStage *CharGenStage()
|
|
|
|
{
|
|
|
|
return &stage;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string *getPassw()
|
|
|
|
{
|
|
|
|
return &passw;
|
|
|
|
}
|
|
|
|
RakNet::RakNetGUID guid;
|
|
|
|
GUIMessageBox guiMessageBox;
|
|
|
|
ESM::Class charClass;
|
|
|
|
int month;
|
|
|
|
int day;
|
|
|
|
double hour;
|
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
```
8 years ago
|
|
|
Inventory inventory;
|
|
|
|
Spellbook spellbook;
|
|
|
|
bool consoleAllowed;
|
|
|
|
bool ignorePosPacket;
|
|
|
|
ESM::ActiveSpells activeSpells;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ESM::Position pos;
|
|
|
|
ESM::Position dir;
|
|
|
|
ESM::Cell cell;
|
|
|
|
ESM::NPC npc;
|
|
|
|
ESM::NpcStats npcStats;
|
|
|
|
ESM::CreatureStats creatureStats;
|
|
|
|
Item equipedItems[19];
|
|
|
|
unsigned int movementFlags;
|
|
|
|
char movementAnim;
|
|
|
|
char drawState;
|
|
|
|
Attack attack;
|
|
|
|
std::string birthSign;
|
|
|
|
std::string chatMessage;
|
|
|
|
CGStage stage;
|
|
|
|
std::string passw;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //OPENMW_BASEPLAYER_HPP
|