Item Class Reference

#include <Item.h>

Inheritance diagram for Item:

Object Container Egg GlobEgg MonsterEgg Actor TeleportEgg MainActor List of all members.

Public Types

 FLG_DISPOSABLE = 0x0002
 FLG_OWNED = 0x0004
 FLG_CONTAINED = 0x0008
 FLG_INVISIBLE = 0x0010
 FLG_FLIPPED = 0x0020
 FLG_IN_NPC_LIST = 0x0040
 FLG_FAST_ONLY = 0x0080
 FLG_GUMP_OPEN = 0x0100
 FLG_EQUIPPED = 0x0200
 FLG_BOUNCING = 0x0400
 FLG_ETHEREAL = 0x0800
 FLG_HANGING = 0x1000
 FLG_FASTAREA = 0x2000
 FLG_LOW_FRICTION = 0x4000
 EXT_FIXED = 0x0001
 EXT_INCURMAP = 0x0002
 EXT_LERP_NOPREV = 0x0008
 EXT_HIGHLIGHT = 0x0010
 EXT_CAMERA = 0x0020
 EXT_SPRITE = 0x0040
 EXT_TRANSPARENT = 0x0080
 EXT_PERMANENT_NPC = 0x0100
enum  statusflags {
  FLG_DISPOSABLE = 0x0002, FLG_OWNED = 0x0004, FLG_CONTAINED = 0x0008, FLG_INVISIBLE = 0x0010,
  FLG_FLIPPED = 0x0020, FLG_IN_NPC_LIST = 0x0040, FLG_FAST_ONLY = 0x0080, FLG_GUMP_OPEN = 0x0100,
  FLG_EQUIPPED = 0x0200, FLG_BOUNCING = 0x0400, FLG_ETHEREAL = 0x0800, FLG_HANGING = 0x1000,
  FLG_FASTAREA = 0x2000, FLG_LOW_FRICTION = 0x4000
}
enum  extflags {
  EXT_FIXED = 0x0001, EXT_INCURMAP = 0x0002, EXT_LERP_NOPREV = 0x0008, EXT_HIGHLIGHT = 0x0010,
  EXT_CAMERA = 0x0020, EXT_SPRITE = 0x0040, EXT_TRANSPARENT = 0x0080, EXT_PERMANENT_NPC = 0x0100
}

Public Member Functions

 Item ()
virtual ~Item ()
 ENABLE_RUNTIME_CLASSTYPE ()
ObjId getParent () const
void setParent (ObjId p)
ContainergetParentAsContainer () const
ItemgetTopItem ()
void setLocation (sint32 x, sint32 y, sint32 z)
void move (sint32 x, sint32 y, sint32 z)
bool moveToContainer (Container *container, bool checkwghtvol=false)
void moveToEtherealVoid ()
void returnFromEtherealVoid ()
void movedByPlayer ()
void getLocationAbsolute (sint32 &x, sint32 &y, sint32 &z) const
void getLocation (sint32 &x, sint32 &y, sint32 &z) const
sint32 getZ () const
void setZ (sint32 z_)
void getGumpLocation (sint32 &x, sint32 &y) const
void setGumpLocation (sint32 x, sint32 y)
void randomGumpLocation ()
void getCentre (sint32 &x, sint32 &y, sint32 &z) const
void getFootpadWorld (sint32 &x, sint32 &y, sint32 &z) const
void getFootpadData (sint32 &x, sint32 &y, sint32 &z) const
Pentagram::Box getWorldBox () const
uint16 getFlags () const
void setFlag (uint32 mask)
virtual void setFlagRecursively (uint32 mask)
void clearFlag (uint32 mask)
void setExtFlags (uint32 f)
uint32 getExtFlags () const
void setExtFlag (uint32 mask)
void clearExtFlag (uint32 mask)
uint32 getShape () const
void setShape (uint32 shape_)
uint32 getFrame () const
void setFrame (uint32 frame_)
uint16 getQuality () const
void setQuality (uint16 quality_)
uint16 getNpcNum () const
void setNpcNum (uint16 npcnum_)
uint16 getMapNum () const
void setMapNum (uint16 mapnum_)
ShapeInfogetShapeInfo () const
ShapeInfogetShapeInfoFromGameInstance () const
ShapegetShapeObject () const
uint16 getFamily ()
bool canMergeWith (Item *other)
ObjId getGump ()
void clearGump ()
ObjId openGump (uint32 gumpshape)
void closeGump ()
virtual void destroy (bool delnow=false)
bool overlaps (Item &item2) const
bool overlapsxy (Item &item2) const
bool isOn (Item &item2) const
bool canExistAt (sint32 x, sint32 y, sint32 z, bool needsupport=false) const
int getDirToItemCentre (Item &item2) const
int getRange (Item &item2, bool checkz=false) const
bool canReach (Item *other, int range, sint32 x=0, sint32 y=0, sint32 z=0)
sint32 collideMove (sint32 x, sint32 y, sint32 z, bool teleport, bool force, ObjId *hititem=0)
sint32 ascend (int delta)
void fall ()
void grab ()
void hurl (int xs, int ys, int zs, int grav)
void setGravityPID (ProcId pid)
ProcId getGravityPID () const
virtual GravityProcessensureGravityProcess ()
virtual uint32 getWeight ()
virtual uint32 getTotalWeight ()
virtual uint32 getVolume ()
void explode ()
virtual uint16 getDamageType ()
virtual void receiveHit (ObjId other, int dir, int damage, uint16 type)
unsigned int countNearby (uint32 shape, uint16 range)
bool canDrag ()
int getThrowRange ()
bool checkLoopScript (const uint8 *script, uint32 scriptsize)
uint32 callUsecodeEvent_look ()
uint32 callUsecodeEvent_use ()
uint32 callUsecodeEvent_anim ()
uint32 callUsecodeEvent_cachein ()
uint32 callUsecodeEvent_hit (ObjId hitted, sint16 hitforce)
uint32 callUsecodeEvent_gotHit (ObjId hitter, sint16 hitforce)
uint32 callUsecodeEvent_hatch ()
uint32 callUsecodeEvent_schedule (uint32 time)
uint32 callUsecodeEvent_release ()
uint32 callUsecodeEvent_combine ()
uint32 callUsecodeEvent_enterFastArea ()
uint32 callUsecodeEvent_leaveFastArea ()
uint32 callUsecodeEvent_cast (uint16 unk)
uint32 callUsecodeEvent_justMoved ()
uint32 callUsecodeEvent_AvatarStoleSomething (uint16 unk)
uint32 callUsecodeEvent_guardianBark (sint16 unk)
uint32 use ()
void getLerped (sint32 &x, sint32 &y, sint32 &z) const
void doLerp (sint32 factor)
void setupLerp (sint32 gametick)
virtual void enterFastArea ()
virtual void leaveFastArea ()
virtual void dumpInfo ()
bool loadData (IDataSource *ids, uint32 version)
 INTRINSIC (I_touch)
 INTRINSIC (I_getX)
 INTRINSIC (I_getY)
 INTRINSIC (I_getZ)
 INTRINSIC (I_getCX)
 INTRINSIC (I_getCY)
 INTRINSIC (I_getCZ)
 INTRINSIC (I_getPoint)
 INTRINSIC (I_getShape)
 INTRINSIC (I_setShape)
 INTRINSIC (I_getFrame)
 INTRINSIC (I_setFrame)
 INTRINSIC (I_getQuality)
 INTRINSIC (I_getUnkEggType)
 INTRINSIC (I_getQuantity)
 INTRINSIC (I_getContainer)
 INTRINSIC (I_getRootContainer)
 INTRINSIC (I_getQ)
 INTRINSIC (I_getQHi)
 INTRINSIC (I_getQLo)
 INTRINSIC (I_setQ)
 INTRINSIC (I_setQHi)
 INTRINSIC (I_setQLo)
 INTRINSIC (I_setQuality)
 INTRINSIC (I_setQuantity)
 INTRINSIC (I_getFamily)
 INTRINSIC (I_getTypeFlag)
 INTRINSIC (I_getStatus)
 INTRINSIC (I_orStatus)
 INTRINSIC (I_andStatus)
 INTRINSIC (I_getFootpadData)
 INTRINSIC (I_overlaps)
 INTRINSIC (I_overlapsXY)
 INTRINSIC (I_isOn)
 INTRINSIC (I_ascend)
 INTRINSIC (I_getWeight)
 INTRINSIC (I_getWeightIncludingContents)
 INTRINSIC (I_getVolume)
 INTRINSIC (I_bark)
 INTRINSIC (I_getMapArray)
 INTRINSIC (I_setMapArray)
 INTRINSIC (I_getNpcNum)
 INTRINSIC (I_getDirToCoords)
 INTRINSIC (I_getDirFromCoords)
 INTRINSIC (I_getDirToItem)
 INTRINSIC (I_getDirFromItem)
 INTRINSIC (I_look)
 INTRINSIC (I_use)
 INTRINSIC (I_gotHit)
 INTRINSIC (I_enterFastArea)
 INTRINSIC (I_ask)
 INTRINSIC (I_getSliderInput)
 INTRINSIC (I_openGump)
 INTRINSIC (I_closeGump)
 INTRINSIC (I_create)
 INTRINSIC (I_legalCreateAtPoint)
 INTRINSIC (I_legalCreateAtCoords)
 INTRINSIC (I_legalCreateInCont)
 INTRINSIC (I_push)
 INTRINSIC (I_pop)
 INTRINSIC (I_popToCoords)
 INTRINSIC (I_popToContainer)
 INTRINSIC (I_popToEnd)
 INTRINSIC (I_destroy)
 INTRINSIC (I_move)
 INTRINSIC (I_legalMoveToPoint)
 INTRINSIC (I_legalMoveToContainer)
 INTRINSIC (I_hurl)
 INTRINSIC (I_shoot)
 INTRINSIC (I_fall)
 INTRINSIC (I_grab)
 INTRINSIC (I_igniteChaos)
 INTRINSIC (I_getFamilyOfType)
 INTRINSIC (I_getEtherealTop)
 INTRINSIC (I_guardianBark)
 INTRINSIC (I_getSurfaceWeight)
 INTRINSIC (I_isExplosive)
 INTRINSIC (I_receiveHit)
 INTRINSIC (I_explode)
 INTRINSIC (I_canReach)
 INTRINSIC (I_getRange)
 INTRINSIC (I_isCrusTypeNPC)

Protected Member Functions

virtual void saveData (ODataSource *ods)

Protected Attributes

uint32 frame
sint32 x
sint32 y
sint32 z
uint16 flags
uint16 quality
uint16 npcnum
uint16 mapnum
uint32 extendedflags
ObjId parent
ShapecachedShape
ShapeInfocachedShapeInfo
Lerped l_prev
Lerped l_next
sint32 ix
sint32 iy
sint32 iz
ObjId gump
ProcId gravitypid

Private Member Functions

uint32 callUsecodeEvent (uint32 event, const uint8 *args=0, int argsize=0)
void animateItem ()

Private Attributes

uint32 shape
sint32 last_setup

Friends

class ItemFactory

Classes

struct  Lerped

Detailed Description

Definition at line 34 of file Item.h.


Member Enumeration Documentation

enum Item::extflags

Enumerator:
EXT_FIXED  Item came from FIXED.
EXT_INCURMAP  Item is in a CurrentMap display list.
EXT_LERP_NOPREV  Item can't be lerped this frame.
EXT_HIGHLIGHT  Item should be Painted highlighted.
EXT_CAMERA  Item is being followed by the camera.
EXT_SPRITE  Item is a sprite.
EXT_TRANSPARENT  Item should be painted transparent.
EXT_PERMANENT_NPC  Item is a permanent NPC.

Definition at line 541 of file Item.h.

enum Item::statusflags

Enumerator:
FLG_DISPOSABLE  Item is discarded on map change.
FLG_OWNED  Item is owned by avatar.
FLG_CONTAINED  Item is in a container.
FLG_INVISIBLE  Item is invisible.
FLG_FLIPPED  Item is flipped horizontally.
FLG_IN_NPC_LIST  Item is a NPC.
FLG_FAST_ONLY  Item is discarded when leaving fast area.
FLG_GUMP_OPEN  Item has a gump open.
FLG_EQUIPPED  Item is equipped.
FLG_BOUNCING  Item has bounced.
FLG_ETHEREAL  Item is in the ethereal list.
FLG_HANGING  Item is suspended in the air.
FLG_FASTAREA  Item is in the fast area.
FLG_LOW_FRICTION  Item has low friction.

Definition at line 524 of file Item.h.


Constructor & Destructor Documentation

Item::Item (  ) 

Definition at line 68 of file Item.cpp.

Item::~Item (  )  [virtual]

Definition at line 79 of file Item.cpp.


Member Function Documentation

void Item::animateItem (  )  [private]

Animate the item (called by setupLerp).

Definition at line 1263 of file Item.cpp.

References ShapeInfo::animdata, ShapeInfo::animtype, callUsecodeEvent_anim(), frame, Shape::frameCount(), getShapeInfo(), getShapeObject(), last_setup, Object::objid, and pout.

Referenced by setupLerp().

sint32 Item::ascend ( int  delta  ) 

Make the item move up (delta>0) or down (delta<0), including any items on top of it

Parameters:
delta distance in Z-direction to move
Returns:
0-0x4000 representing how far it got. 0 = didn't move 0x4000 = reached destination

Definition at line 1443 of file Item.cpp.

References collideMove(), World::get_instance(), World::getCurrentMap(), getItem(), getLocation(), UCList::getSize(), UCList::getuint16(), ix, iy, iz, moveToEtherealVoid(), and CurrentMap::surfaceSearch().

uint32 Item::callUsecodeEvent ( uint32  event,
const uint8 args = 0,
int  argsize = 0 
) [private]

Call a Usecode Event. Use the separate functions instead!

Definition at line 1028 of file Item.cpp.

References Object::callUsecode(), EXT_PERMANENT_NPC, extendedflags, flags, FLG_FAST_ONLY, Usecode::get_class_event(), UCMachine::get_instance(), GameData::get_instance(), getFamily(), GameData::getMainUsecode(), Object::objid, pout, quality, ShapeInfo::SF_UNKEGG, and shape.

Referenced by callUsecodeEvent_anim(), callUsecodeEvent_AvatarStoleSomething(), callUsecodeEvent_cachein(), callUsecodeEvent_cast(), callUsecodeEvent_combine(), callUsecodeEvent_enterFastArea(), callUsecodeEvent_guardianBark(), callUsecodeEvent_hatch(), callUsecodeEvent_justMoved(), callUsecodeEvent_leaveFastArea(), callUsecodeEvent_look(), callUsecodeEvent_release(), callUsecodeEvent_schedule(), and callUsecodeEvent_use().

uint32 Item::callUsecodeEvent_anim (  ) 

Definition at line 1079 of file Item.cpp.

References callUsecodeEvent().

Referenced by animateItem().

uint32 Item::callUsecodeEvent_AvatarStoleSomething ( uint16  unk  ) 

Definition at line 1149 of file Item.cpp.

References BaseUCStack::access(), callUsecodeEvent(), and BaseUCStack::push2().

Referenced by movedByPlayer().

uint32 Item::callUsecodeEvent_cachein (  ) 

Definition at line 1084 of file Item.cpp.

References callUsecodeEvent().

Referenced by StartU8Process::run().

uint32 Item::callUsecodeEvent_cast ( uint16  unk  ) 

Definition at line 1137 of file Item.cpp.

References BaseUCStack::access(), callUsecodeEvent(), and BaseUCStack::push2().

Referenced by Actor::setInCombat().

uint32 Item::callUsecodeEvent_combine (  ) 

Definition at line 1122 of file Item.cpp.

References callUsecodeEvent().

Referenced by Actor::giveTreasure(), and SplitItemProcess::run().

uint32 Item::callUsecodeEvent_enterFastArea (  ) 

Definition at line 1127 of file Item.cpp.

References callUsecodeEvent().

Referenced by enterFastArea().

uint32 Item::callUsecodeEvent_gotHit ( ObjId  hitter,
sint16  hitforce 
)

uint32 Item::callUsecodeEvent_guardianBark ( sint16  unk  ) 

Definition at line 1156 of file Item.cpp.

References BaseUCStack::access(), callUsecodeEvent(), and BaseUCStack::push2().

uint32 Item::callUsecodeEvent_hatch (  ) 

Definition at line 1105 of file Item.cpp.

References callUsecodeEvent().

Referenced by Egg::hatch().

uint32 Item::callUsecodeEvent_hit ( ObjId  hitted,
sint16  hitforce 
)

Referenced by collideMove().

uint32 Item::callUsecodeEvent_justMoved (  ) 

Definition at line 1144 of file Item.cpp.

References callUsecodeEvent().

Referenced by move(), and moveToContainer().

uint32 Item::callUsecodeEvent_leaveFastArea (  ) 

Definition at line 1132 of file Item.cpp.

References callUsecodeEvent().

Referenced by leaveFastArea().

uint32 Item::callUsecodeEvent_look (  ) 

Definition at line 1069 of file Item.cpp.

References callUsecodeEvent().

Referenced by GameMapGump::OnMouseClick(), and ContainerGump::OnMouseClick().

uint32 Item::callUsecodeEvent_release (  ) 

Definition at line 1117 of file Item.cpp.

References callUsecodeEvent().

Referenced by collideMove(), and grab().

uint32 Item::callUsecodeEvent_schedule ( uint32  time  ) 

Definition at line 1110 of file Item.cpp.

References BaseUCStack::access(), callUsecodeEvent(), and BaseUCStack::push4().

Referenced by SchedulerProcess::run(), and Actor::schedule().

uint32 Item::callUsecodeEvent_use (  ) 

Definition at line 1074 of file Item.cpp.

References callUsecodeEvent().

Referenced by MainActor::ConCmd_useBackpack(), MainActor::ConCmd_useInventory(), MiniStatsGump::OnMouseDouble(), use(), and MainActor::useInventoryItem().

bool Item::canDrag (  ) 

can this item be dragged?

Definition at line 1638 of file Item.cpp.

References getShapeInfo(), ShapeInfo::is_fixed(), Actor::isDead(), and ShapeInfo::weight.

Referenced by getThrowRange(), and GameMapGump::StartDraggingItem().

bool Item::canExistAt ( sint32  x,
sint32  y,
sint32  z,
bool  needsupport = false 
) const

Check if this item can exist at the given coordinates.

Definition at line 540 of file Item.cpp.

References World::get_instance(), World::getCurrentMap(), Object::getObjId(), getShape(), and CurrentMap::isValidPosition().

Referenced by ActorAnimProcess::doSpecial(), GameMapGump::DraggingItem(), and MonsterEgg::hatch().

bool Item::canMergeWith ( Item other  ) 

Check if we can merge with another item.

Definition at line 1778 of file Item.cpp.

References GameInfo::GAME_U8, CoreApp::get_instance(), getFamily(), getFrame(), Object::getObjId(), getShape(), ShapeInfo::SF_QUANTITY, and ShapeInfo::SF_REAGENT.

Referenced by ContainerGump::DropItem().

bool Item::canReach ( Item other,
int  range,
sint32  x = 0,
sint32  y = 0,
sint32  z = 0 
)

Check if this item can reach another item. (This includes LoS.)

Parameters:
other item to be reached
range range
x x coordinate of other to use, If zero, use real coords.
y y coordinate of other to use
z z coordinate of other to use.

Definition at line 1697 of file Item.cpp.

References checkLineOfSightCollisions(), World::get_instance(), World::getCurrentMap(), getFootpadWorld(), getLocationAbsolute(), Object::getObjId(), getTopItem(), Object::objid, ShapeInfo::SI_SOLID, and CurrentMap::sweepTest().

Referenced by GameMapGump::DraggingItem(), ContainerGump::DraggingItem(), GameMapGump::DropItem(), GameMapGump::OnMouseDouble(), ContainerGump::OnMouseDouble(), GameMapGump::StartDraggingItem(), and ContainerGump::StartDraggingItem().

bool Item::checkLoopScript ( const uint8 script,
uint32  scriptsize 
)

Check this Item against the given loopscript

Parameters:
script The loopscript to run
scriptsize The size (in bytes) of the loopscript
Returns:
true if the item matches, false otherwise

check for i out of bounds

check for i out of bounds

check for i out of bounds

Definition at line 655 of file Item.cpp.

References getFamily(), getFlags(), getFrame(), getNpcNum(), getQuality(), getShape(), perr, BaseUCStack::pop2(), and BaseUCStack::push2().

Referenced by UCMachine::execProcess().

void Item::clearExtFlag ( uint32  mask  )  [inline]

Clear the extendedflags set in the given mask.

Definition at line 143 of file Item.h.

References extendedflags.

Referenced by CurrentMap::removeItemFromList(), and CameraProcess::terminate().

void Item::clearFlag ( uint32  mask  )  [inline]

Clear the flags set in the given mask.

Definition at line 131 of file Item.h.

References flags.

Referenced by GameMapGump::ConCmd_dumpMap(), Actor::setEquip(), GravityProcess::terminate(), and AnimationTracker::updateActorFlags().

void Item::clearGump (  ) 

Call this to notify the Item's open Gump has closed.

Definition at line 1437 of file Item.cpp.

References flags, FLG_GUMP_OPEN, and gump.

Referenced by PaperdollGump::Close(), ContainerGump::Close(), and closeGump().

void Item::closeGump (  ) 

Close this Item's gump, if any.

Definition at line 1423 of file Item.cpp.

References clearGump(), Gump::Close(), flags, FLG_GUMP_OPEN, GUIApp::get_instance(), GUIApp::getGump(), and gump.

Referenced by ResurrectionProcess::run(), and use().

sint32 Item::collideMove ( sint32  x,
sint32  y,
sint32  z,
bool  teleport,
bool  force,
ObjId hititem = 0 
)

Move the object to (x,y,z) colliding with objects in the way.

Parameters:
teleport move without colliding with objects between source and destination
force force the object to get to the destination without being blocked by solid objects
hititem if non-NULL, this is set to (one of) the item(s) blocking the movement, or to zero if nothing blocked it
Returns:
0-0x4000 representing how far it got. 0 = didn't move 0x4000 = reached destination
Note:
This can destroy the object

Definition at line 833 of file Item.cpp.

References callUsecodeEvent_hit(), callUsecodeEvent_release(), EXT_HIGHLIGHT, flags, Kernel::get_instance(),