[Scummvm-git-logs] scummvm master -> ac980ee10e5166545b9ab025921b5fcf3b5df71f
mduggan
mgithub at guarana.org
Tue Jun 23 07:19:30 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3420f0dec6 ULTIMA8: JANITORIAL: Correct comments slightly
ac980ee10e ULTIMA8: Add intrinsic for Crusader cameras
Commit: 3420f0dec6717e1f7c888e712f74f898a910bfde
https://github.com/scummvm/scummvm/commit/3420f0dec6717e1f7c888e712f74f898a910bfde
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-06-23T16:18:11+09:00
Commit Message:
ULTIMA8: JANITORIAL: Correct comments slightly
Changed paths:
engines/ultima/ultima8/world/current_map.cpp
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 6a992f9e7e..0e0e1a5a65 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -883,8 +883,8 @@ bool CurrentMap::scanForValidPosition(int32 x, int32 y, int32 z, const Item *ite
// Do a sweepTest of an item from start to end point.
// dims is the bounding box size.
// item is the item that we are checking to move
-// blocking_only forces us to check against blocking _items only.
-// skip will skip all _items until item num skip is reached
+// blocking_only forces us to check against blocking items only.
+// skip will skip all items until item num skip is reached
// Returns item hit or 0 if no hit.
// end is set to the colision point
bool CurrentMap::sweepTest(const int32 start[3], const int32 end[3],
@@ -961,7 +961,7 @@ bool CurrentMap::sweepTest(const int32 start[3], const int32 end[3],
// If the objects overlapped at the start, ignore collision.
// The -1 and +1 portions are to still consider collisions
- // for _items which were merely touching at the start for all
+ // for items which were merely touching at the start for all
// intents and purposes, but partially overlapped due to an
// off-by-one error (hypothetically, but they do happen so
// protect against it).
Commit: ac980ee10e5166545b9ab025921b5fcf3b5df71f
https://github.com/scummvm/scummvm/commit/ac980ee10e5166545b9ab025921b5fcf3b5df71f
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-06-23T16:18:11+09:00
Commit Message:
ULTIMA8: Add intrinsic for Crusader cameras
Changed paths:
engines/ultima/ultima8/audio/audio_process.cpp
engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
engines/ultima/ultima8/usecode/remorse_intrinsics.h
engines/ultima/ultima8/world/item.cpp
engines/ultima/ultima8/world/item.h
diff --git a/engines/ultima/ultima8/audio/audio_process.cpp b/engines/ultima/ultima8/audio/audio_process.cpp
index e7abecb78e..8e38156a9e 100644
--- a/engines/ultima/ultima8/audio/audio_process.cpp
+++ b/engines/ultima/ultima8/audio/audio_process.cpp
@@ -535,10 +535,13 @@ uint32 AudioProcess::I_playSFXCru(const uint8 *args, unsigned int argsize) {
warning("I_playSFXCru: Couldn't get item");
} else {
AudioProcess *ap = AudioProcess::get_instance();
- if (ap)
+ if (ap) {
+ // Crusader stops any existing item sounds before starting the next.
+ ap->stopSFX(item->getObjId(), -1);
ap->playSFX(sfxNum, 0x10, item->getObjId(), 0, true);
- else
+ } else {
warning("I_playSFXCru Error: No AudioProcess");
+ }
}
return 0;
}
diff --git a/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h b/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
index 8e4383235b..98eb303015 100644
--- a/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
+++ b/engines/ultima/ultima8/convert/crusader/convert_usecode_crusader.h
@@ -137,7 +137,7 @@ const char* const ConvertUsecodeCrusader::_intrinsics[] = {
// 0040
"void CameraProcess::I_moveTo(x, y, z)",
"void CameraProcess::I_setCenterOn(objid)",
- "byte Intrinsic042(Item *, otheritem)", // Something about whether item1 can see item2?
+ "byte Item::I_getRangeIfVisible(Item *, otheritem)",
"void AudioProcess::I_playSFXCru(Item *, soundno)", // TODO: Work out how this is different from Int015 - to a first approximation they are quite similar.
"byte Item::I_IsOn(Item *, uint16 itemno)", // part of same coff set 044, 046, 048, 04A, 04C, 04E, 0A5, 0BC, 0C5, 0DC, 0F1, 0FA, 12C
"int16 Item::I_getQHi(Item *)", // same as 026 based on same coff set 026, 045, 047, 049, 04B, 04D, 04F, 0AF, 0BE, 0C9, 0F0, 0F3, 0FB, 133
diff --git a/engines/ultima/ultima8/usecode/remorse_intrinsics.h b/engines/ultima/ultima8/usecode/remorse_intrinsics.h
index 9bf534c5a5..b1177233fc 100644
--- a/engines/ultima/ultima8/usecode/remorse_intrinsics.h
+++ b/engines/ultima/ultima8/usecode/remorse_intrinsics.h
@@ -105,7 +105,7 @@ Intrinsic RemorseIntrinsics[] = {
// 0x040
CameraProcess::I_moveTo, // void Intrinsic040(8 bytes)
CameraProcess::I_setCenterOn, // void Intrinsic041(2 bytes)
- 0, // int Intrinsic042(6 bytes)
+ Item::I_getRangeIfVisible, // int Intrinsic042(6 bytes)
AudioProcess::I_playSFXCru, // TODO: Work out how this is different from Int015 - to a first approximation they are quite similar.
Item::I_isOn,
Item::I_getQHi, // based on same coff set as 026
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index b46d1a14a3..0b692a59f3 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -651,6 +651,40 @@ int Item::getRange(const Item &item2, bool checkz) const {
return range;
}
+int Item::getRangeIfVisible(const Item &item2) const {
+ World *world = World::get_instance();
+ CurrentMap *map = world->getCurrentMap();
+ int32 start[3];
+ int32 end[3];
+ int32 dims[3] = {1, 1, 1};
+ Std::list<CurrentMap::SweepItem> hitItems;
+ getCentre(start[0], start[1], start[2]);
+ item2.getCentre(end[0], end[1], end[2]);
+
+ int xdiff = abs(start[0] - end[0]);
+ int ydiff = abs(start[1] - end[1]);
+ int zdiff = abs(start[2] - end[2]);
+
+ map->sweepTest(start, end, dims, getShapeInfo()->_flags, _objId, true, &hitItems);
+
+ if (hitItems.size() > 0) {
+ for (Std::list<CurrentMap::SweepItem>::const_iterator it = hitItems.begin();
+ it != hitItems.end();
+ it++) {
+ int objId = it->_item;
+ if (it->_blocking && objId != _objId && objId != item2.getObjId()) {
+ //int out[3];
+ //it->GetInterpolatedCoords(out, start, end);
+ //warning("found blocking item %d at %d %d %d.", objId, out[0], out[1], out[2]);
+ return 0;
+ }
+ }
+ }
+
+ int distance = MAX(MAX(xdiff, ydiff), zdiff);
+ return distance;
+}
+
ShapeInfo *Item::getShapeInfoFromGameInstance() const {
return GameData::get_instance()->getMainShapes()->getShapeInfo(_shape);
}
@@ -1647,14 +1681,17 @@ void Item::explode(int explosion_type, bool destroy_item) {
}
Kernel::get_instance()->addProcess(p);
- int sfx;
- if (GAME_IS_CRUSADER)
- sfx = (getRandom() % 2) ? 28 : 108;
- else
- sfx = (getRandom() % 2) ? 31 : 158;
-
AudioProcess *audioproc = AudioProcess::get_instance();
- if (audioproc) audioproc->playSFX(sfx, 0x60, 0, 0);
+ if (audioproc) {
+ int sfx;
+ if (GAME_IS_CRUSADER) {
+ sfx = (getRandom() % 2) ? 28 : 108;
+ audioproc->stopSFX(-1, _objId);
+ } else {
+ sfx = (getRandom() % 2) ? 31 : 158;
+ }
+ audioproc->playSFX(sfx, 0x60, 0, 0);
+ }
int32 xv, yv, zv;
getLocation(xv, yv, zv);
@@ -3268,6 +3305,26 @@ uint32 Item::I_getRange(const uint8 *args, unsigned int /*argsize*/) {
return item->getRange(*other);
}
+uint32 Item::I_getRangeIfVisible(const uint8 *args, unsigned int /*argsize*/) {
+ // TODO: This is not exactly the same as the implementation in Cruasder,
+ // but it should work?
+ ARG_ITEM_FROM_PTR(item);
+ ARG_ITEM_FROM_ID(other);
+
+ if (!item || !other)
+ return 0;
+
+ // Somewhat arbitrary maths in here to replicate Crusader behavior.
+ int range = item->getRangeIfVisible(*other) / 16;
+ if ((range & 0xf) != 0)
+ range++;
+
+ if (range <= 48) {
+ return range;
+ }
+ return 0;
+}
+
uint32 Item::I_isCrusTypeNPC(const uint8 *args, unsigned int /*argsize*/) {
ARG_UINT16(sh);
diff --git a/engines/ultima/ultima8/world/item.h b/engines/ultima/ultima8/world/item.h
index fc543e2912..7abeb1fde4 100644
--- a/engines/ultima/ultima8/world/item.h
+++ b/engines/ultima/ultima8/world/item.h
@@ -291,6 +291,9 @@ public:
//! between the x, y (and possibly z) coordinates of the items.
int getRange(const Item &item2, bool checkz = false) const;
+ //! get 'distance' to other item if it's visible (ie, there's nothing blocking the path)
+ int getRangeIfVisible(const Item &item2) const;
+
//! Check if this item can reach another item. (This includes LoS.)
//! \param other item to be reached
//! \param range range
@@ -552,6 +555,7 @@ public:
INTRINSIC(I_explode);
INTRINSIC(I_canReach);
INTRINSIC(I_getRange);
+ INTRINSIC(I_getRangeIfVisible);
INTRINSIC(I_isCrusTypeNPC);
INTRINSIC(I_doSomethingAndSetUnkCruFlag);
INTRINSIC(I_inFastArea);
More information about the Scummvm-git-logs
mailing list