[Scummvm-git-logs] scummvm master -> df915c973cc85ce2842217838097849bb7f8daab

OMGPizzaGuy noreply at scummvm.org
Sat May 3 19:53:59 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
df915c973c ULTIMA8: Alter Guardian bark to display near screen bottom.


Commit: df915c973cc85ce2842217838097849bb7f8daab
    https://github.com/scummvm/scummvm/commit/df915c973cc85ce2842217838097849bb7f8daab
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2025-05-03T14:53:06-05:00

Commit Message:
ULTIMA8: Alter Guardian bark to display near screen bottom.
Guardian barks (speech & text) now create an ethereal actor.. Item relative gumps now force display near the bottom center of the screen for ethereal items.

Changed paths:
    engines/ultima/ultima8/gumps/bark_gump.cpp
    engines/ultima/ultima8/gumps/game_map_gump.cpp
    engines/ultima/ultima8/gumps/item_relative_gump.cpp
    engines/ultima/ultima8/world/item.cpp
    engines/ultima/ultima8/world/item.h
    engines/ultima/ultima8/world/item_factory.cpp


diff --git a/engines/ultima/ultima8/gumps/bark_gump.cpp b/engines/ultima/ultima8/gumps/bark_gump.cpp
index 33a2c1c52b6..90eba7e84bc 100644
--- a/engines/ultima/ultima8/gumps/bark_gump.cpp
+++ b/engines/ultima/ultima8/gumps/bark_gump.cpp
@@ -61,7 +61,7 @@ BarkGump::~BarkGump(void) {
 
 int BarkGump::dialogFontForActor(uint16 actor) {
 	// OK, this is a bit of a hack, but it's how it has to be
-	if (actor == kMainActorId)
+	if (actor == kMainActorId || actor == kGuardianId)
 		return 6;
 	if (actor > 256)
 		return 8;
diff --git a/engines/ultima/ultima8/gumps/game_map_gump.cpp b/engines/ultima/ultima8/gumps/game_map_gump.cpp
index 3912f4beb3a..2616aff1b94 100644
--- a/engines/ultima/ultima8/gumps/game_map_gump.cpp
+++ b/engines/ultima/ultima8/gumps/game_map_gump.cpp
@@ -228,7 +228,6 @@ uint16 GameMapGump::TraceCoordinates(int mx, int my, Point3 &coords,
 bool GameMapGump::GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy,
 									int32 lerp_factor) {
 	Item *item = getItem(itemid);
-
 	if (!item)
 		return false;
 
@@ -236,6 +235,9 @@ bool GameMapGump::GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy,
 	if (root)
 		item = root;
 
+	if (item->hasFlags(Item::FLG_ETHEREAL))
+		return false;
+
 	// Hacks be us. Force the item into the fast area
 	item->setupLerp(Kernel::get_instance()->getFrameNum());
 	item->doLerp(lerp_factor);
diff --git a/engines/ultima/ultima8/gumps/item_relative_gump.cpp b/engines/ultima/ultima8/gumps/item_relative_gump.cpp
index 8a09da5faec..5f255c17ce9 100644
--- a/engines/ultima/ultima8/gumps/item_relative_gump.cpp
+++ b/engines/ultima/ultima8/gumps/item_relative_gump.cpp
@@ -126,6 +126,7 @@ void ItemRelativeGump::GetItemLocation(int32 lerp_factor) {
 	}
 
 	int32 gx, gy;
+	bool found;
 
 	if (!gump) {
 		gump = GetRootGump()->FindGump<GameMapGump>();
@@ -135,23 +136,32 @@ void ItemRelativeGump::GetItemLocation(int32 lerp_factor) {
 			return;
 		}
 
-		gump->GetLocationOfItem(_owner, gx, gy, lerp_factor);
+		found = gump->GetLocationOfItem(_owner, gx, gy, lerp_factor);
 	} else {
 		assert(prev);
-		gump->GetLocationOfItem(prev->getObjId(), gx, gy, lerp_factor);
+		found = gump->GetLocationOfItem(prev->getObjId(), gx, gy, lerp_factor);
+	}
+
+	if (found) {
+		// Convert the GumpSpaceCoord relative to the world/item gump
+		// into screenspace coords
+		gy = gy - it->getShapeInfo()->_z * 8 - 16;
+	} else {
+		// If location not found show near bottom center
+		Rect r;
+		gump->GetDims(r);
+		gx = (r.left + r.right) / 2;
+		gy = r.bottom - 8;
 	}
 
-	// Convert the GumpSpaceCoord relative to the world/item gump
-	// into screenspace coords
-	gy = gy - it->getShapeInfo()->_z * 8 - 16;
 	gump->GumpToScreenSpace(gx, gy);
 
 	// Convert the screenspace coords into the coords of us
-	if (_parent) _parent->ScreenSpaceToGump(gx, gy);
+	if (_parent)
+		_parent->ScreenSpaceToGump(gx, gy);
 
 	// Set x and y, and center us over it
 	_ix = gx - _dims.width() / 2;
-//	_iy = gy-_dims.h-it->getShapeInfo()->z*8-16;
 	_iy = gy - _dims.height();
 
 
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index cb5e5870335..ce67f344ba1 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -28,6 +28,7 @@
 #include "ultima/ultima8/world/world.h"
 #include "ultima/ultima8/kernel/kernel.h"
 #include "ultima/ultima8/kernel/delay_process.h"
+#include "ultima/ultima8/kernel/object_manager.h"
 #include "ultima/ultima8/world/get_object.h"
 #include "ultima/ultima8/gfx/main_shape_archive.h"
 #include "ultima/ultima8/gfx/gump_shape_archive.h"
@@ -2031,12 +2032,10 @@ void Item::clearGump() {
 	_flags &= ~FLG_GUMP_OPEN;
 }
 
-ProcId Item::bark(const Std::string &msg, ObjId id) {
+ProcId Item::bark(const Std::string &msg) {
 	closeBark();
 
 	uint32 shapenum = getShape();
-	if (id == kGuardianId)
-		shapenum = kGuardianId; // Hack for guardian barks
 
 	Gump *gump = new BarkGump(getObjId(), msg, shapenum);
 	_bark = gump->getObjId();
@@ -3057,8 +3056,15 @@ uint32 Item::I_getWeightIncludingContents(const uint8 *args,
 uint32 Item::I_bark(const uint8 *args, unsigned int /*argsize*/) {
 	ARG_ITEM_FROM_PTR(item);
 	ARG_STRING(str);
-	if (id_item == kGuardianId)
-		item = getItem(kMainActorId);
+	if (!item && id_item == kGuardianId) {
+		Actor *actor = ItemFactory::createActor(kGuardianId, 0, 0, Item::FLG_ETHEREAL | Item::FLG_IN_NPC_LIST, kGuardianId, 0, Item::EXT_PERMANENT_NPC, false);
+		if (!actor) {
+			warning("Couldn't create actor");
+			return 0;
+		}
+		ObjectManager::get_instance()->assignActorObjId(actor, kGuardianId);
+		item = actor;
+	}
 
 	if (!item) {
 		// Hack! Items should always be valid?
@@ -3066,7 +3072,7 @@ uint32 Item::I_bark(const uint8 *args, unsigned int /*argsize*/) {
 		return 0;
 	}
 
-	return item->bark(str, id_item);
+	return item->bark(str);
 }
 
 uint32 Item::I_look(const uint8 *args, unsigned int /*argsize*/) {
diff --git a/engines/ultima/ultima8/world/item.h b/engines/ultima/ultima8/world/item.h
index 4cd9fae65ba..0ab8066a97c 100644
--- a/engines/ultima/ultima8/world/item.h
+++ b/engines/ultima/ultima8/world/item.h
@@ -268,7 +268,7 @@ public:
 	//! Close this Item's gump, if any
 	void closeGump();
 
-	ProcId bark(const Std::string &msg, ObjId id = 0);
+	ProcId bark(const Std::string &msg);
 	//! Call this to notify the Item's open bark has closed.
 	void clearBark(); // set bark to 0
 	//! Close this Item's bark, if any
diff --git a/engines/ultima/ultima8/world/item_factory.cpp b/engines/ultima/ultima8/world/item_factory.cpp
index 80e8d4a332d..08bc0ad208b 100644
--- a/engines/ultima/ultima8/world/item_factory.cpp
+++ b/engines/ultima/ultima8/world/item_factory.cpp
@@ -116,7 +116,7 @@ Item *ItemFactory::createItem(uint32 shape, uint32 frame, uint16 quality,
 }
 
 static Actor *getActorForNpcNum(uint32 npcnum) {
-	if (npcnum == 1)
+	if (npcnum == kMainActorId)
 		return new MainActor();
 
 	// 'normal' Actor/NPC




More information about the Scummvm-git-logs mailing list