ULTIMA8: More Crusader usecode for items

This commit is contained in:
Matthew Duggan committed 2020-06-17 18:02:41 +09:00
1 parent d5bd2826f6
commit 3e680ea65d
4 files changed
+73 -10

No files matched your search

@@ -160,7 +160,7 @@ const char* const ConvertUsecodeCrusader::_intrinsics[] = {
"void I_NPCSetActivityProbably_055(Actor *, int)", // part of same coff set 055, 07D, 0CD, 0DB, 0F2, 131
"void Intrinsic056(2 bytes)",
"int16 Item::I_getSOMETHING_57(Item *)",
"byte Item::I_doSOMETHING_58(Item *, uint16 unk)",
"byte Item::Item::I_isCentreOn(Item *, uint16 other)",
"void Item::I_setFrame(Item *, frame)", // based on same coff as 002
"int16 Actor::I_getLastAnimSet(4 bytes)", // part of same coff set 01D, 05A, 0B9, 0D7, 0E4, 124
"byte Item::I_legalCreateAtPoint(Item *, int16 shape, int16 frame, Point *)", // see PEPSIEW::use
@@ -388,7 +388,7 @@ const char* const ConvertUsecodeCrusader::_intrinsics[] = {
"byte Item::I_isOn(Item *, itemno)", // part of same coff set 044, 046, 048, 04A, 04C, 04E, 0A5, 0BC, 0C5, 0DC, 0F1, 0FA, 12C
"void Item::I_getFootpadData(Item *, uint *, uint *, uint *)", // same coff as 064
"byte Actor::I_isDead(Item *)", // same coff as 122, 039
"int16 Intrinsic12F(Item *, uint16 other_itemno)",
"int16 MonsterEgg::I_monsterEggHatch(Item *, uint16 other_itemno)",
// 0130
"void Actor::I_clrImmortal(Actor *)", // same coff as 07B
"void I_NPCSetActivityProbably_131(Actor *, int)", // part of same coff set 055, 07D, 0CD, 0DB, 0F2, 131
@@ -128,7 +128,7 @@ Intrinsic RemorseIntrinsics[] = {
0, // void Intrinsic055(6 bytes)
0, // void Intrinsic056(2 bytes)
0, // void Intrinsic057(4 bytes)
0, // int Intrinsic058(6 bytes)
Item::I_isCentreOn, // int Intrinsic058(6 bytes)
Item::I_setFrame, // based on same coff as 002
Actor::I_getLastAnimSet, // void Intrinsic05A(4 bytes)
Item::I_legalCreateAtPoint, // probably. see PEPSIEW::use
+58 -3
View File
@@ -462,7 +462,7 @@ void Item::setShape(uint32 shape_) {
_cachedShape = nullptr;
}
bool Item::overlaps(Item &item2) const {
bool Item::overlaps(const Item &item2) const {
int32 x1a, y1a, z1a, x1b, y1b, z1b;
int32 x2a, y2a, z2a, x2b, y2b, z2b;
getLocation(x1b, y1b, z1a);
@@ -485,7 +485,7 @@ bool Item::overlaps(Item &item2) const {
return true;
}
bool Item::overlapsxy(Item &item2) const {
bool Item::overlapsxy(const Item &item2) const {
int32 x1a, y1a, z1a, x1b, y1b;
int32 x2a, y2a, z2a, x2b, y2b;
getLocation(x1b, y1b, z1a);
@@ -505,7 +505,7 @@ bool Item::overlapsxy(Item &item2) const {
return true;
}
bool Item::isOn(Item &item2) const {
bool Item::isOn(const Item &item2) const {
int32 x1a, y1a, z1a, x1b, y1b;
int32 x2a, y2a, z2a, x2b, y2b, z2b;
getLocation(x1b, y1b, z1a);
@@ -527,6 +527,49 @@ bool Item::isOn(Item &item2) const {
return false;
}
bool Item::isCompletelyOn(const Item &item2) const {
// FIXME: this is just a copy of isOn at the moment
int32 x1a, y1a, z1a, x1b, y1b;
int32 x2a, y2a, z2a, x2b, y2b, z2b;
getLocation(x1b, y1b, z1a);
item2.getLocation(x2b, y2b, z2a);
int32 xd, yd, zd;
getFootpadWorld(xd, yd, zd);
x1a = x1b - xd;
y1a = y1b - yd;
item2.getFootpadWorld(xd, yd, zd);
x2a = x2b - xd;
y2a = y2b - yd;
z2b = z2a + zd;
if (x1b <= x2a || x2b <= x1a) return false;
if (y1b <= y2a || y2b <= y1a) return false;
if (z2b == z1a) return true;
return false;
}
bool Item::isCentreOn(const Item &item2) const {
int32 x1c, y1c, z1c;
int32 x2a, y2a, z2a, x2b, y2b, z2b;
item2.getLocation(x2b, y2b, z2a);
getCentre(x1c, y1c, z1c);
int32 xd, yd, zd;
item2.getFootpadWorld(xd, yd, zd);
x2a = x2b - xd;
y2a = y2b - yd;
z2b = z2a + zd;
if (x1c <= x2a || x2b <= x1c) return false;
if (y1c <= y2a || y2b <= y1c) return false;
if (z2b == z1c) return true;
return false;
}
bool Item::canExistAt(int32 x_, int32 y_, int32 z_, bool needsupport) const {
CurrentMap *cm = World::get_instance()->getCurrentMap();
const Item *support;
@@ -2492,6 +2535,18 @@ uint32 Item::I_isOn(const uint8 *args, unsigned int /*argsize*/) {
return 0;
}
uint32 Item::I_isCentreOn(const uint8 *args, unsigned int /*argsize*/) {
ARG_ITEM_FROM_PTR(item);
ARG_ITEM_FROM_ID(item2);
if (!item) return 0;
if (!item2) return 0;
if (item->isCentreOn(*item2))
return 1;
else
return 0;
}
uint32 Item::I_getFamilyOfType(const uint8 *args, unsigned int /*argsize*/) {
ARG_UINT16(shape);
+12 -4
View File
@@ -263,13 +263,19 @@ public:
virtual void destroy(bool delnow = false);
//! Check if this item overlaps another item in 3D world-space
bool overlaps(Item &item2) const;
bool overlaps(const Item &item2) const;
//! Check if this item overlaps another item in the xy dims in 3D space
bool overlapsxy(Item &item2) const;
bool overlapsxy(const Item &item2) const;
//! Check if this item is on top another item
bool isOn(Item &item2) const;
//! Check if this item is on top of another item
bool isOn(const Item &item2) const;
//! Check if this item is on completely on top of another item
bool isCompletelyOn(const Item &item2) const;
//! Check if the centre of this item is on top of another item
bool isCentreOn(const Item &item2) const;
//! Check if this item can exist at the given coordinates
bool canExistAt(int32 x_, int32 y_, int32 z_, bool needsupport = false) const;
@@ -487,6 +493,8 @@ public:
INTRINSIC(I_overlaps);
INTRINSIC(I_overlapsXY);
INTRINSIC(I_isOn);
INTRINSIC(I_isCompletelyOn);
INTRINSIC(I_isCentreOn);
INTRINSIC(I_ascend);
INTRINSIC(I_getWeight);
INTRINSIC(I_getWeightIncludingContents);