22#ifndef ULTIMA8_WORLD_ITEM_H
23#define ULTIMA8_WORLD_ITEM_H
25#include "ultima/ultima8/kernel/object.h"
26#include "ultima/ultima8/gfx/shape_info.h"
28#include "ultima/ultima8/usecode/intrinsics.h"
29#include "ultima/ultima8/misc/box.h"
30#include "ultima/ultima8/misc/point3.h"
31#include "ultima/ultima8/misc/direction.h"
49 ENABLE_RUNTIME_CLASSTYPE()
78 virtual void move(int32 x, int32 y, int32 z);
105 return Point3(_x, _y, _z);
150 return (_flags & flags) != 0;
158 virtual void setFlagRecursively(uint32 mask) {
174 return _extendedFlags;
179 return (_extendedFlags & flags) != 0;
184 _extendedFlags |= mask;
189 _extendedFlags &= ~mask;
302 bool canExistAt(int32 x, int32 y, int32 z,
bool needsupport =
false)
const;
325 bool canReach(
const Item *other,
int range, int32 x = 0, int32 y = 0, int32 z = 0)
const;
340 virtual int32
collideMove(int32 x, int32 y, int32 z,
bool teleport,
bool force,
341 ObjId *hititem = 0, uint8 *dirs = 0);
363 void hurl(
int xs,
int ys,
int zs,
int grav);
367 assert(_gravityPid == 0 || pid == 0);
390 void explode(
int explosion_type,
bool destroy_item,
bool cause_damage =
true);
400 virtual void receiveHit(ObjId other, Direction dir,
int damage, uint16 type);
403 uint16
fireWeapon(int32 x, int32 y, int32 z, Direction dir,
int firetype,
bool findtarget);
407 uint16
fireDistance(
const Item *other, Direction dir, int16 xoff, int16 yoff, int16 zoff)
const;
411 return _damagePoints;
416 _damagePoints = points;
439 uint32 callUsecodeEvent_look();
440 uint32 callUsecodeEvent_use();
441 uint32 callUsecodeEvent_anim();
442 uint32 callUsecodeEvent_cachein();
443 uint32 callUsecodeEvent_hit(ObjId hitted, int16 hitforce);
444 uint32 callUsecodeEvent_gotHit(ObjId hitter, int16 hitforce);
445 uint32 callUsecodeEvent_hatch();
446 uint32 callUsecodeEvent_schedule(uint32 time);
447 uint32 callUsecodeEvent_release();
448 uint32 callUsecodeEvent_equip();
449 uint32 callUsecodeEvent_equipWithParam(ObjId param);
450 uint32 callUsecodeEvent_unequip();
451 uint32 callUsecodeEvent_unequipWithParam(ObjId param);
452 uint32 callUsecodeEvent_combine();
453 uint32 callUsecodeEvent_calledFromAnim();
454 uint32 callUsecodeEvent_enterFastArea();
455 uint32 callUsecodeEvent_leaveFastArea();
456 uint32 callUsecodeEvent_cast(uint16 unk);
457 uint32 callUsecodeEvent_justMoved();
458 uint32 callUsecodeEvent_AvatarStoleSomething(uint16 unk);
459 uint32 callUsecodeEvent_guardianBark(int16 unk);
460 uint32 callUsecodeEvent_unhatch();
466 return Point3(_ix, _iy, _iz);
480 }
else if (factor == 0) {
487 _ix = ((_lPrev._x * (256 - factor) + _lNext._x * factor) >> 8);
488 _iy = ((_lPrev._y * (256 - factor) + _lNext._y * factor) >> 8);
489 _iz = ((_lPrev._z * (256 - factor) + _lNext._z * factor) >> 8);
491 _ix = _lPrev.x + (((_lNext.x - _lPrev.x) * factor) >> 8);
492 _iy = _lPrev.y + (((_lNext.y - _lPrev.y) * factor) >> 8);
493 _iz = _lPrev.z + (((_lNext.z - _lPrev.z) * factor) >> 8);
522 INTRINSIC(I_getPoint);
523 INTRINSIC(I_getShape);
524 INTRINSIC(I_setShape);
525 INTRINSIC(I_getFrame);
526 INTRINSIC(I_setFrame);
527 INTRINSIC(I_getQuality);
528 INTRINSIC(I_getUnkEggType);
529 INTRINSIC(I_setUnkEggType);
530 INTRINSIC(I_getQuantity);
531 INTRINSIC(I_getContainer);
532 INTRINSIC(I_getRootContainer);
539 INTRINSIC(I_setQuality);
540 INTRINSIC(I_setQuantity);
541 INTRINSIC(I_setQAndCombine);
542 INTRINSIC(I_getFamily);
543 INTRINSIC(I_getTypeFlag);
544 INTRINSIC(I_getStatus);
545 INTRINSIC(I_orStatus);
546 INTRINSIC(I_andStatus);
547 INTRINSIC(I_getFootpadData);
548 INTRINSIC(I_overlaps);
549 INTRINSIC(I_overlapsXY);
551 INTRINSIC(I_isCompletelyOn);
552 INTRINSIC(I_isCentreOn);
553 INTRINSIC(I_isInNpc);
555 INTRINSIC(I_getWeight);
556 INTRINSIC(I_getWeightIncludingContents);
557 INTRINSIC(I_getVolume);
559 INTRINSIC(I_getMapArray);
560 INTRINSIC(I_setMapArray);
561 INTRINSIC(I_getNpcNum);
562 INTRINSIC(I_setNpcNum);
563 INTRINSIC(I_getDirToCoords);
564 INTRINSIC(I_getDirFromCoords);
565 INTRINSIC(I_getDirToItem);
566 INTRINSIC(I_getDirFromItem);
567 INTRINSIC(I_getDirFromTo16);
568 INTRINSIC(I_getClosestDirectionInRange);
572 INTRINSIC(I_enterFastArea);
575 INTRINSIC(I_getSliderInput);
576 INTRINSIC(I_openGump);
577 INTRINSIC(I_closeGump);
579 INTRINSIC(I_legalCreateAtPoint);
580 INTRINSIC(I_legalCreateAtCoords);
581 INTRINSIC(I_legalCreateInCont);
584 INTRINSIC(I_popToCoords);
585 INTRINSIC(I_popToContainer);
586 INTRINSIC(I_popToEnd);
587 INTRINSIC(I_destroy);
589 INTRINSIC(I_legalMoveToPoint);
590 INTRINSIC(I_legalMoveToContainer);
595 INTRINSIC(I_igniteChaos);
596 INTRINSIC(I_getFamilyOfType);
597 INTRINSIC(I_getEtherealTop);
598 INTRINSIC(I_guardianBark);
599 INTRINSIC(I_getSurfaceWeight);
600 INTRINSIC(I_isExplosive);
601 INTRINSIC(I_receiveHit);
602 INTRINSIC(I_explode);
603 INTRINSIC(I_canReach);
604 INTRINSIC(I_getRange);
605 INTRINSIC(I_getRangeIfVisible);
606 INTRINSIC(I_isCrusTypeNPC);
607 INTRINSIC(I_setBroken);
608 INTRINSIC(I_inFastArea);
610 INTRINSIC(I_unequip);
611 INTRINSIC(I_avatarStoleSomething);
612 INTRINSIC(I_isPartlyOnScreen);
613 INTRINSIC(I_fireWeapon);
614 INTRINSIC(I_fireDistance);
628 uint32 _extendedFlags;
632 mutable const Shape *_cachedShape;
633 mutable const ShapeInfo *_cachedShapeInfo;
637 Lerped() : _x(0), _y(0), _z(0), _shape(0), _frame(0) {};
639 uint32 _shape, _frame;
662 uint32 callUsecodeEvent(uint32 event,
const uint8 *args = 0,
int argsize = 0);
671 void receiveHitU8(ObjId other, Direction dir,
int damage, uint16 type);
674 void receiveHitCru(ObjId other, Direction dir,
int damage, uint16 type);
709 static const int MAX_QUANTITY = 666;
713 if (!_cachedShapeInfo)
715 return _cachedShapeInfo;
Definition: container.h:35
Definition: gravity_process.h:33
Definition: item_factory.h:34
bool isCompletelyOn(const Item &item2) const
Check if this item is on completely on top of another item.
virtual uint32 getTotalWeight() const
Get the weight of this Item and its contents, if any.
Point3 getLerped() const
Get lerped location.
Definition: item.h:465
uint16 getQuality() const
Get this Item's quality (a.k.a. 'Q')
Definition: item.h:211
void movedByPlayer()
Check if moving this item is stealing; call AvatarStoleSomething if so.
uint32 getShape() const
Get this Item's shape number.
Definition: item.h:193
const ShapeInfo * getShapeInfo() const
Get the ShapeInfo object for this Item. (The pointer will be cached.)
Definition: item.h:712
Direction getDirToItemCentre(const Point3 &pt) const
Same as above, but from a fixed point.
virtual void leaveFastArea()
uint16 getMapNum() const
Definition: item.h:234
bool hasFlags(uint16 flags) const
Does this item have any of the given flags mask set.
Definition: item.h:149
bool canDrag() const
can this item be dragged?
ProcId getGravityPID() const
Get the PID of the GravityProcess for this Item (or 0)
Definition: item.h:372
virtual void destroy(bool delnow=false)
Destroy self.
const Item * getTopItem() const
bool checkLoopScript(const uint8 *script, uint32 scriptsize) const
virtual void receiveHit(ObjId other, Direction dir, int damage, uint16 type)
void explode(int explosion_type, bool destroy_item, bool cause_damage=true)
void setFrame(uint32 frame)
Set this Item's frame number.
Definition: item.h:206
void setNpcNum(uint16 npcnum)
Definition: item.h:228
bool isOn(const Item &item2) const
Check if this item is on top of another item.
void getGumpLocation(int32 &x, int32 &y) const
void setMapNum(uint16 mapnum)
Definition: item.h:240
virtual uint16 getDamageType() const
get the damage type this object does when hitting something
void returnFromEtherealVoid()
Move an item out of the Ethereal Void to where it originally was.
void setParent(ObjId p)
Set the parent container of this item.
Definition: item.h:57
bool canExistAt(int32 x, int32 y, int32 z, bool needsupport=false) const
Check if this item can exist at the given coordinates.
uint16 getFlags() const
Get all flags.
Definition: item.h:144
Container * getRootContainer() const
Get the top-most Container this Item is in, if any. (NULL if not in a Container)
void setFlag(uint32 mask)
Set the flags set in the given mask.
Definition: item.h:154
void randomGumpLocation()
void getFootpadWorld(int32 &x, int32 &y, int32 &z) const
Get the size of this item's 3D bounding box, in world coordinates.
Definition: item.h:732
void closeGump()
Close this Item's gump, if any.
void clearFlag(uint32 mask)
Clear the flags set in the given mask.
Definition: item.h:163
bool moveToContainer(Container *container, bool checkwghtvol=false)
virtual void move(int32 x, int32 y, int32 z)
uint16 fireDistance(const Item *other, Direction dir, int16 xoff, int16 yoff, int16 zoff) const
virtual int32 collideMove(int32 x, int32 y, int32 z, bool teleport, bool force, ObjId *hititem=0, uint8 *dirs=0)
virtual uint32 getWeight() const
Get the weight of this Item.
virtual uint32 getVolume() const
Get the volume this item takes up in a container.
bool hasExtFlags(uint32 flags) const
Does item have any of the given extended flags.
Definition: item.h:178
void setQuality(uint16 quality)
Set this Item's quality (a.k.a 'Q');.
Definition: item.h:216
int32 getTargetZRelativeToAttackerZ(int32 attackerz) const
bool isPartlyOnScreen() const
Check if the item is currently partly visible on screen.
void setGravityPID(ProcId pid)
Set the PID of the GravityProcess for this Item. There should be only one.
Definition: item.h:366
uint8 getDamagePoints() const
get damage points, used in Crusader for item damage.
Definition: item.h:410
int getRangeIfVisible(const Item &item2) const
get 'distance' to other item if it's visible (ie, there's nothing blocking the path)
Common::String dumpInfo() const override
dump some info about this item to a string
void getFootpadData(int32 &x, int32 &y, int32 &z) const
Definition: item.h:718
Point3 getLocationAbsolute() const
void hurl(int xs, int ys, int zs, int grav)
Hurl the item in the given direction.
void setExtFlags(uint32 f)
Set _extendedFlags.
Definition: item.h:168
int32 getZ() const
Get this Item's Z coordinate.
bool isOnScreen() const
Check if the item is currently entirely visible on screen.
bool overlaps(const Item &item2) const
Check if this item overlaps another item in 3D world-space.
void setLocation(int32 x, int32 y, int32 z)
void setZ(int32 z)
Set this Item's Z coordinate.
Definition: item.h:112
Box getWorldBox() const
Get the Box this item occupies in the world. Undef if item is contained.
Container * getParentAsContainer() const
Get the Container this Item is in, if any. (NULL if not in a Container)
void clearExtFlag(uint32 mask)
Clear the _extendedFlags set in the given mask.
Definition: item.h:188
const Shape * getShapeObject() const
Get the Shape object for this Item. (The pointer will be cached.)
ObjId getGump() const
Get the open ContainerGump for this Item, if any. (NULL if not open.)
Definition: item.h:261
void setExtFlag(uint32 mask)
Set the _extendedFlags set in the given mask.
Definition: item.h:183
int getRange(const Item &item2, bool checkz=false) const
void setDamagePoints(uint8 points)
set damage points, used in Crusader for item damage.
Definition: item.h:415
void setGumpLocation(int32 x, int32 y)
extflags
Definition: item.h:695
@ EXT_PERMANENT_NPC
Item is a permanent NPC.
Definition: item.h:703
@ EXT_CAMERA
Item is being followed by the camera.
Definition: item.h:700
@ EXT_FEMALE
Item is Crusader Female NPC (controls sfx)
Definition: item.h:705
@ EXT_TRANSPARENT
Item should be painted transparent.
Definition: item.h:702
@ EXT_FIXED
Item came from FIXED.
Definition: item.h:696
@ EXT_HIGHLIGHT
Item should be Painted highlighted.
Definition: item.h:699
@ EXT_LERP_NOPREV
Item can't be lerped this frame.
Definition: item.h:698
@ EXT_INCURMAP
Item is in a CurrentMap display list.
Definition: item.h:697
@ EXT_SPRITE
Item is a sprite.
Definition: item.h:701
@ EXT_TARGET
Item is the current reticle target in Crusader.
Definition: item.h:704
void clearBark()
Call this to notify the Item's open bark has closed.
unsigned int countNearby(uint32 shape, uint16 range) const
count nearby objects of a given shape
void moveToEtherealVoid()
Move an item to the Ethereal Void.
void move(const Point3 &pt)
Move, but with a point struct.
ObjId getParent() const
Get the Container this Item is in, if any. (0 if not in a Container)
Definition: item.h:52
void closeBark()
Close this Item's bark, if any.
uint16 getNpcNum() const
Definition: item.h:222
ObjId openGump(uint32 gumpshape)
Open a gump with the given shape for this Item.
void setupLerp(int32 gametick)
Setup the lerped info for this gametick and animate the item.
virtual GravityProcess * ensureGravityProcess()
Get the GravityProcess of this Item, creating it if necessary.
bool isRobotCru() const
True if this is a Robot shape (in a fixed list)
uint16 fireWeapon(int32 x, int32 y, int32 z, Direction dir, int firetype, bool findtarget)
fire the given weapon type in the given direction from location x, y, z.
Point3 getLocation() const
Definition: item.h:104
void doLerp(int32 factor)
Definition: item.h:472
uint32 getExtFlags() const
Get _extendedFlags.
Definition: item.h:173
virtual uint32 enterFastArea()
The item has entered the fast area.
int getThrowRange() const
bool overlapsxy(const Item &item2) const
Check if this item overlaps another item in the xy dims in 3D space.
Direction getDirToItemCentre(const Item &item2) const
int scaleReceivedDamageCru(int damage, uint16 type) const
bool canReach(const Item *other, int range, int32 x=0, int32 y=0, int32 z=0) const
void clearGump()
Call this to notify the Item's open Gump has closed.
statusflags
Definition: item.h:677
@ FLG_ETHEREAL
Item is in the ethereal list - confirmed same meaning in crusader.
Definition: item.h:688
@ FLG_INVISIBLE
Item is invisible.
Definition: item.h:681
@ FLG_BOUNCING
Item has bounced.
Definition: item.h:687
@ FLG_OWNED
Item is owned by avatar.
Definition: item.h:679
@ FLG_EQUIPPED
Item is equipped.
Definition: item.h:686
@ FLG_DISPOSABLE
Item is discarded on map change.
Definition: item.h:678
@ FLG_HANGING
Item is suspended in the air.
Definition: item.h:689
@ FLG_FAST_ONLY
Item is discarded when leaving fast area.
Definition: item.h:684
@ FLG_BROKEN
Item is broken - Crusader only - broken items are not targetable.
Definition: item.h:692
@ FLG_CONTAINED
Item is in a container.
Definition: item.h:680
@ FLG_GUMP_OPEN
Item has a gump open.
Definition: item.h:685
@ FLG_LOW_FRICTION
Item has low friction.
Definition: item.h:691
@ FLG_IN_NPC_LIST
Item is a NPC.
Definition: item.h:683
@ FLG_FASTAREA
Item is in the fast area.
Definition: item.h:690
@ FLG_FLIPPED
Item is flipped horizontally.
Definition: item.h:682
uint32 getFrame() const
Get this Item's frame number.
Definition: item.h:201
virtual const ShapeInfo * getShapeInfoFromGameInstance() const
Get the ShapeInfo object for this Item from the game instance.
bool canMergeWith(const Item *other) const
Check if we can merge with another item.
void setShape(uint32 shape)
Set this Item's shape number.
bool isCentreOn(const Item &item2) const
Check if the centre of this item is on top of another item.
Definition: shape_info.h:33