2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2012-01-02 17:58:37 +01:00
|
|
|
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
2011-08-28 15:17:58 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
#ifndef ITEM_H
|
|
|
|
#define ITEM_H
|
|
|
|
|
|
|
|
#include <framework/global.h>
|
|
|
|
#include "thing.h"
|
2012-07-29 14:04:47 +02:00
|
|
|
#include "effect.h"
|
2012-07-19 23:22:52 +02:00
|
|
|
#include "itemtype.h"
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-07-20 07:45:11 +02:00
|
|
|
enum ItemAttr : uint8
|
2012-07-15 01:20:38 +02:00
|
|
|
{
|
2012-06-21 05:05:44 +02:00
|
|
|
ATTR_END = 0,
|
2012-07-18 10:34:17 +02:00
|
|
|
//ATTR_DESCRIPTION = 1,
|
|
|
|
//ATTR_EXT_FILE = 2,
|
2012-06-21 05:05:44 +02:00
|
|
|
ATTR_TILE_FLAGS = 3,
|
|
|
|
ATTR_ACTION_ID = 4,
|
|
|
|
ATTR_UNIQUE_ID = 5,
|
|
|
|
ATTR_TEXT = 6,
|
|
|
|
ATTR_DESC = 7,
|
|
|
|
ATTR_TELE_DEST = 8,
|
|
|
|
ATTR_ITEM = 9,
|
|
|
|
ATTR_DEPOT_ID = 10,
|
2012-07-18 10:34:17 +02:00
|
|
|
//ATTR_EXT_SPAWN_FILE = 11,
|
2012-06-21 05:05:44 +02:00
|
|
|
ATTR_RUNE_CHARGES = 12,
|
2012-07-18 10:34:17 +02:00
|
|
|
//ATTR_EXT_HOUSE_FILE = 13,
|
2012-07-09 08:59:16 +02:00
|
|
|
ATTR_HOUSEDOORID = 14,
|
2012-06-21 05:05:44 +02:00
|
|
|
ATTR_COUNT = 15,
|
|
|
|
ATTR_DURATION = 16,
|
|
|
|
ATTR_DECAYING_STATE = 17,
|
|
|
|
ATTR_WRITTENDATE = 18,
|
|
|
|
ATTR_WRITTENBY = 19,
|
|
|
|
ATTR_SLEEPERGUID = 20,
|
|
|
|
ATTR_SLEEPSTART = 21,
|
|
|
|
ATTR_CHARGES = 22,
|
|
|
|
ATTR_CONTAINER_ITEMS = 23,
|
|
|
|
ATTR_NAME = 30,
|
|
|
|
ATTR_PLURALNAME = 31,
|
|
|
|
ATTR_ATTACK = 33,
|
|
|
|
ATTR_EXTRAATTACK = 34,
|
|
|
|
ATTR_DEFENSE = 35,
|
|
|
|
ATTR_EXTRADEFENSE = 36,
|
|
|
|
ATTR_ARMOR = 37,
|
|
|
|
ATTR_ATTACKSPEED = 38,
|
2012-07-09 08:59:16 +02:00
|
|
|
ATTR_HITCHANCE = 39,
|
2012-06-21 05:05:44 +02:00
|
|
|
ATTR_SHOOTRANGE = 40,
|
|
|
|
ATTR_ARTICLE = 41,
|
|
|
|
ATTR_SCRIPTPROTECTED = 42,
|
|
|
|
ATTR_DUALWIELD = 43,
|
|
|
|
ATTR_ATTRIBUTE_MAP = 128
|
2012-06-21 04:31:29 +02:00
|
|
|
};
|
|
|
|
|
2012-06-22 05:14:13 +02:00
|
|
|
// @bindclass
|
2012-07-15 15:23:13 +02:00
|
|
|
#pragma pack(push,1) // disable memory alignment
|
2011-08-15 16:11:24 +02:00
|
|
|
class Item : public Thing
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Item();
|
2012-07-15 15:23:13 +02:00
|
|
|
virtual ~Item() { }
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-01-12 20:20:18 +01:00
|
|
|
static ItemPtr create(int id);
|
2012-06-22 01:58:18 +02:00
|
|
|
static ItemPtr createFromOtb(int id);
|
2012-01-09 06:23:39 +01:00
|
|
|
|
2012-11-29 02:47:26 +01:00
|
|
|
void draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView = nullptr);
|
2011-11-03 01:55:50 +01:00
|
|
|
|
2012-02-02 17:37:52 +01:00
|
|
|
void setId(uint32 id);
|
2012-06-22 01:58:18 +02:00
|
|
|
void setOtbId(uint16 id);
|
2012-04-28 02:44:55 +02:00
|
|
|
void setCountOrSubType(int value) { m_countOrSubType = value; }
|
|
|
|
void setCount(int count) { m_countOrSubType = count; }
|
|
|
|
void setSubType(int subType) { m_countOrSubType = subType; }
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-04-28 02:44:55 +02:00
|
|
|
int getCountOrSubType() { return m_countOrSubType; }
|
2012-07-30 10:51:03 +02:00
|
|
|
int getSubType();
|
|
|
|
int getCount();
|
2012-08-19 23:49:24 +02:00
|
|
|
uint32 getId() { return m_clientId; }
|
|
|
|
uint16 getClientId() { return m_clientId; }
|
|
|
|
uint16 getServerId() { return m_serverId; }
|
2012-06-23 16:26:18 +02:00
|
|
|
bool isValid();
|
2011-08-15 23:02:52 +02:00
|
|
|
|
2012-07-15 07:46:56 +02:00
|
|
|
ItemPtr clone();
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-07-20 20:56:08 +02:00
|
|
|
void unserializeItem(const BinaryTreePtr& in);
|
2012-08-20 00:30:49 +02:00
|
|
|
void serializeItem(const OutputBinaryTreePtr& out);
|
2012-07-15 15:23:13 +02:00
|
|
|
|
|
|
|
void setDepotId(uint16 depotId) { m_attribs.set(ATTR_DEPOT_ID, depotId); }
|
|
|
|
uint16 getDepotId() { return m_attribs.get<uint16>(ATTR_DEPOT_ID); }
|
|
|
|
|
|
|
|
void setDoorId(uint8 doorId) { m_attribs.set(ATTR_HOUSEDOORID, doorId); }
|
|
|
|
uint8 getDoorId() { return m_attribs.get<uint8>(ATTR_HOUSEDOORID); }
|
|
|
|
|
|
|
|
void setActionId(uint16 actionId) { m_attribs.set(ATTR_ACTION_ID, actionId); }
|
|
|
|
void setUniqueId(uint16 uniqueId) { m_attribs.set(ATTR_UNIQUE_ID, uniqueId); }
|
|
|
|
|
|
|
|
bool isDepot() { return m_attribs.has(ATTR_DEPOT_ID); }
|
|
|
|
bool isContainer() { return m_attribs.has(ATTR_CONTAINER_ITEMS); }
|
|
|
|
bool isDoor() { return m_attribs.has(ATTR_HOUSEDOORID); }
|
|
|
|
bool isTeleport() { return m_attribs.has(ATTR_TELE_DEST); }
|
2012-07-20 20:56:08 +02:00
|
|
|
bool isMoveable();
|
2012-08-08 15:59:38 +02:00
|
|
|
bool isGround();
|
2012-07-15 15:23:13 +02:00
|
|
|
|
2012-08-01 09:49:09 +02:00
|
|
|
ItemPtr asItem() { return static_self_cast<Item>(); }
|
2012-07-15 15:23:13 +02:00
|
|
|
bool isItem() { return true; }
|
|
|
|
|
2012-08-19 17:41:03 +02:00
|
|
|
void addContainerItem(const ItemPtr& i) { m_containerItems.push_back(i); }
|
2012-08-19 19:20:20 +02:00
|
|
|
void clearContainerItems() { m_containerItems.clear(); }
|
2012-08-19 17:41:03 +02:00
|
|
|
|
2012-09-01 01:33:51 +02:00
|
|
|
void calculatePatterns(int& xPattern, int& yPattern, int& zPattern);
|
|
|
|
int calculateAnimationPhase(bool animate);
|
|
|
|
int getExactSize(int layer = 0, int xPattern = 0, int yPattern = 0, int zPattern = 0, int animationPhase = 0);
|
|
|
|
|
2012-07-19 23:22:52 +02:00
|
|
|
const ThingTypePtr& getThingType();
|
|
|
|
ThingType *rawGetThingType();
|
2012-06-21 04:31:29 +02:00
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
private:
|
2012-08-19 23:49:24 +02:00
|
|
|
uint16 m_clientId;
|
|
|
|
uint16 m_serverId;
|
2012-02-02 17:37:52 +01:00
|
|
|
uint8 m_countOrSubType;
|
2012-08-01 09:49:09 +02:00
|
|
|
stdext::packed_storage<uint8> m_attribs;
|
2012-08-19 17:41:03 +02:00
|
|
|
std::vector<ItemPtr> m_containerItems;
|
2011-08-15 16:11:24 +02:00
|
|
|
};
|
2012-07-15 15:23:13 +02:00
|
|
|
|
2012-08-02 02:08:12 +02:00
|
|
|
#pragma pack(pop)
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#endif
|