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;
278 virtual void destroy(
bool delnow =
false);
302 bool canExistAt(int32 x, int32 y, int32 z,
bool needsupport =
false)
const;
314 int getRange(
const Item &item2,
bool checkz =
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;
424 unsigned int countNearby(uint32 shape, uint16 range)
const;
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;
void randomGumpLocation()
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.
ObjId openGump(uint32 gumpshape)
Open a gump with the given shape for this Item.
int getRangeIfVisible(const Item &item2) const
get 'distance' to other item if it's visible (ie, there's nothing blocking the path) ...
virtual void receiveHit(ObjId other, Direction dir, int damage, uint16 type)
bool isCompletelyOn(const Item &item2) const
Check if this item is on completely on top of another item.
Item is in a container.
Definition: item.h:680
bool canDrag() const
can this item be dragged?
bool isPartlyOnScreen() const
Check if the item is currently partly visible on screen.
void movedByPlayer()
Check if moving this item is stealing; call AvatarStoleSomething if so.
bool overlaps(const Item &item2) const
Check if this item overlaps another item in 3D world-space.
Item is being followed by the camera.
Definition: item.h:700
uint16 fireDistance(const Item *other, Direction dir, int16 xoff, int16 yoff, int16 zoff) const
void clearGump()
Call this to notify the Item's open Gump has closed.
Item is owned by avatar.
Definition: item.h:679
uint16 getQuality() const
Get this Item's quality (a.k.a. 'Q')
Definition: item.h:211
Item is a NPC.
Definition: item.h:683
Item has bounced.
Definition: item.h:687
Direction getDirToItemCentre(const Item &item2) const
Item has low friction.
Definition: item.h:691
bool isOnScreen() const
Check if the item is currently entirely visible on screen.
void setGumpLocation(int32 x, int32 y)
Item can't be lerped this frame.
Definition: item.h:698
void setShape(uint32 shape)
Set this Item's shape number.
bool moveToContainer(Container *container, bool checkwghtvol=false)
virtual uint32 getVolume() const
Get the volume this item takes up in a container.
void closeBark()
Close this Item's bark, if any.
bool hasFlags(uint16 flags) const
Does this item have any of the given flags mask set.
Definition: item.h:149
Point3 getLocation() const
Definition: item.h:104
bool hasExtFlags(uint32 flags) const
Does item have any of the given extended flags.
Definition: item.h:178
int32 getTargetZRelativeToAttackerZ(int32 attackerz) const
uint32 getExtFlags() const
Get _extendedFlags.
Definition: item.h:173
virtual void move(int32 x, int32 y, int32 z)
void setFrame(uint32 frame)
Set this Item's frame number.
Definition: item.h:206
uint16 getMapNum() const
Definition: item.h:234
virtual const ShapeInfo * getShapeInfoFromGameInstance() const
Get the ShapeInfo object for this Item from the game instance.
bool checkLoopScript(const uint8 *script, uint32 scriptsize) const
Item is a permanent NPC.
Definition: item.h:703
uint16 getFlags() const
Get all flags.
Definition: item.h:144
virtual GravityProcess * ensureGravityProcess()
Get the GravityProcess of this Item, creating it if necessary.
uint16 getNpcNum() const
Definition: item.h:222
Item is in a CurrentMap display list.
Definition: item.h:697
void setDamagePoints(uint8 points)
set damage points, used in Crusader for item damage.
Definition: item.h:415
int getThrowRange() const
bool isOn(const Item &item2) const
Check if this item is on top of another item.
Item is equipped.
Definition: item.h:686
bool canReach(const Item *other, int range, int32 x=0, int32 y=0, int32 z=0) const
unsigned int countNearby(uint32 shape, uint16 range) const
count nearby objects of a given shape
Item is in the fast area.
Definition: item.h:690
int scaleReceivedDamageCru(int damage, uint16 type) const
bool overlapsxy(const Item &item2) const
Check if this item overlaps another item in the xy dims in 3D space.
void closeGump()
Close this Item's gump, if any.
Definition: detection.h:27
void doLerp(int32 factor)
Definition: item.h:472
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
ObjId getParent() const
Get the Container this Item is in, if any. (0 if not in a Container)
Definition: item.h:52
Point3 getLocationAbsolute() const
Item should be Painted highlighted.
Definition: item.h:699
bool canMergeWith(const Item *other) const
Check if we can merge with another item.
void setGravityPID(ProcId pid)
Set the PID of the GravityProcess for this Item. There should be only one.
Definition: item.h:366
Container * getRootContainer() const
Get the top-most Container this Item is in, if any. (NULL if not in a Container)
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.
void setupLerp(int32 gametick)
Setup the lerped info for this gametick and animate the item.
Item should be painted transparent.
Definition: item.h:702
void setMapNum(uint16 mapnum)
Definition: item.h:240
Item is suspended in the air.
Definition: item.h:689
Point3 getLerped() const
Get lerped location.
Definition: item.h:465
Item is in the ethereal list - confirmed same meaning in crusader.
Definition: item.h:688
void setQuality(uint16 quality)
Set this Item's quality (a.k.a 'Q');.
Definition: item.h:216
Item is flipped horizontally.
Definition: item.h:682
void explode(int explosion_type, bool destroy_item, bool cause_damage=true)
Definition: container.h:36
extflags
Definition: item.h:695
int getRange(const Item &item2, bool checkz=false) const
void setLocation(int32 x, int32 y, int32 z)
virtual uint16 getDamageType() const
get the damage type this object does when hitting something
Item is the current reticle target in Crusader.
Definition: item.h:704
void setNpcNum(uint16 npcnum)
Definition: item.h:228
virtual uint32 getWeight() const
Get the weight of this Item.
void clearFlag(uint32 mask)
Clear the flags set in the given mask.
Definition: item.h:163
void clearBark()
Call this to notify the Item's open bark has closed.
Definition: shape_info.h:33
void getFootpadData(int32 &x, int32 &y, int32 &z) const
Definition: item.h:718
virtual void leaveFastArea()
void setExtFlag(uint32 mask)
Set the _extendedFlags set in the given mask.
Definition: item.h:183
const Shape * getShapeObject() const
Get the Shape object for this Item. (The pointer will be cached.)
Item is discarded when leaving fast area.
Definition: item.h:684
ProcId getGravityPID() const
Get the PID of the GravityProcess for this Item (or 0)
Definition: item.h:372
Definition: gravity_process.h:33
virtual uint32 enterFastArea()
The item has entered the fast area.
Item is Crusader Female NPC (controls sfx)
Definition: item.h:705
Item is discarded on map change.
Definition: item.h:678
void returnFromEtherealVoid()
Move an item out of the Ethereal Void to where it originally was.
void setFlag(uint32 mask)
Set the flags set in the given mask.
Definition: item.h:154
void setExtFlags(uint32 f)
Set _extendedFlags.
Definition: item.h:168
void clearExtFlag(uint32 mask)
Clear the _extendedFlags set in the given mask.
Definition: item.h:188
bool canExistAt(int32 x, int32 y, int32 z, bool needsupport=false) const
Check if this item can exist at the given coordinates.
const ShapeInfo * getShapeInfo() const
Get the ShapeInfo object for this Item. (The pointer will be cached.)
Definition: item.h:712
Item is broken - Crusader only - broken items are not targetable.
Definition: item.h:692
void getGumpLocation(int32 &x, int32 &y) const
uint32 getShape() const
Get this Item's shape number.
Definition: item.h:193
Item is invisible.
Definition: item.h:681
uint8 getDamagePoints() const
get damage points, used in Crusader for item damage.
Definition: item.h:410
int32 getZ() const
Get this Item's Z coordinate.
Item came from FIXED.
Definition: item.h:696
const Item * getTopItem() const
ObjId getGump() const
Get the open ContainerGump for this Item, if any. (NULL if not open.)
Definition: item.h:261
void hurl(int xs, int ys, int zs, int grav)
Hurl the item in the given direction.
Common::String dumpInfo() const override
dump some info about this item to a string
uint32 getFrame() const
Get this Item's frame number.
Definition: item.h:201
Definition: item_factory.h:32
bool isRobotCru() const
True if this is a Robot shape (in a fixed list)
Item has a gump open.
Definition: item.h:685
virtual void destroy(bool delnow=false)
Destroy self.
void moveToEtherealVoid()
Move an item to the Ethereal Void.
void setParent(ObjId p)
Set the parent container of this item.
Definition: item.h:57
statusflags
Definition: item.h:677
bool isCentreOn(const Item &item2) const
Check if the centre of this item is on top of another item.
virtual int32 collideMove(int32 x, int32 y, int32 z, bool teleport, bool force, ObjId *hititem=0, uint8 *dirs=0)
Container * getParentAsContainer() const
Get the Container this Item is in, if any. (NULL if not in a Container)
virtual uint32 getTotalWeight() const
Get the weight of this Item and its contents, if any.
Item is a sprite.
Definition: item.h:701