[Scummvm-git-logs] scummvm master -> 0543594c385e2a93175439346a03e4560c1d60d6

dreammaster noreply at scummvm.org
Sat Apr 1 22:38:41 UTC 2023


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:
e35c10c4a8 NUVIE: Fix Ultima 6 NPC and object spawn probabilities
0543594c38 NUVIE: Fix Ultima 6 NPC and object spawn count


Commit: e35c10c4a89c862e5e17c1740821841cba7e122e
    https://github.com/scummvm/scummvm/commit/e35c10c4a89c862e5e17c1740821841cba7e122e
Author: PushmePullyu (127053144+PushmePullyu at users.noreply.github.com)
Date: 2023-04-01T15:38:37-07:00

Commit Message:
NUVIE: Fix Ultima 6 NPC and object spawn probabilities

- Mark spawn eggs as unstackable.
- Normalize the random number used to be in the range 1 to 100
 inclusive to match original behavior.

Stackable objects store "quality" in the high octet of uint16 "qty".
Since "qty" is used as the probability of an egg activating,
spawns would always trigger unless "quality" was 0.

Changed paths:
    engines/ultima/nuvie/core/egg_manager.cpp
    engines/ultima/nuvie/core/obj_manager.cpp


diff --git a/engines/ultima/nuvie/core/egg_manager.cpp b/engines/ultima/nuvie/core/egg_manager.cpp
index 69c4872928a..697f08f881d 100644
--- a/engines/ultima/nuvie/core/egg_manager.cpp
+++ b/engines/ultima/nuvie/core/egg_manager.cpp
@@ -141,7 +141,7 @@ void EggManager::spawn_eggs(uint16 x, uint16 y, uint8 z, bool teleport) {
 			if (((*egg)->obj->status & OBJ_STATUS_EGG_ACTIVE) == 0) {
 				(*egg)->obj->status |= OBJ_STATUS_EGG_ACTIVE;
 
-				hatch_probability = NUVIE_RAND() % 100;
+				hatch_probability = (NUVIE_RAND() % 100) + 1;
 				DEBUG(0, LEVEL_DEBUGGING, "Checking Egg (%x,%x,%x). Rand: %d Probability: %d%%", (*egg)->obj->x, (*egg)->obj->y, (*egg)->obj->z, hatch_probability, (*egg)->obj->qty);
 
 				DEBUG(1, LEVEL_DEBUGGING, " Align: %s", get_actor_alignment_str(quality % 10));
diff --git a/engines/ultima/nuvie/core/obj_manager.cpp b/engines/ultima/nuvie/core/obj_manager.cpp
index b9c94c92196..6a9fb74aaac 100644
--- a/engines/ultima/nuvie/core/obj_manager.cpp
+++ b/engines/ultima/nuvie/core/obj_manager.cpp
@@ -673,7 +673,6 @@ bool ObjManager::is_stackable(Obj *obj) {
 		case OBJ_U6_BREAD: // 0x80, // loaf of bread
 		case OBJ_U6_MEAT_PORTION: // 0x81, // portion of meat
 		case OBJ_U6_FLASK_OF_OIL: // 0x53, // flask of oil
-		case OBJ_U6_EGG: // 0x14F, // egg
 		case OBJ_U6_GOLD_NUGGET: // 0x59, // gold nugget
 		case OBJ_U6_ZU_YLEM: // 0x5B, // Zu Ylem
 		case OBJ_U6_SNAKE_VENOM: // 0x5C, // silver snake venom


Commit: 0543594c385e2a93175439346a03e4560c1d60d6
    https://github.com/scummvm/scummvm/commit/0543594c385e2a93175439346a03e4560c1d60d6
Author: PushmePullyu (127053144+PushmePullyu at users.noreply.github.com)
Date: 2023-04-01T15:38:37-07:00

Commit Message:
NUVIE: Fix Ultima 6 NPC and object spawn count

Match original behavior when randomizing the number of entities
spawned by eggs.

Changed paths:
    engines/ultima/nuvie/core/egg_manager.cpp


diff --git a/engines/ultima/nuvie/core/egg_manager.cpp b/engines/ultima/nuvie/core/egg_manager.cpp
index 697f08f881d..352c143405a 100644
--- a/engines/ultima/nuvie/core/egg_manager.cpp
+++ b/engines/ultima/nuvie/core/egg_manager.cpp
@@ -187,6 +187,8 @@ bool EggManager::spawn_egg(Obj *egg, uint8 hatch_probability) {
 
 				if (gametype == NUVIE_GAME_U6 && obj->obj_n == OBJ_U6_SILVER_SERPENT) //U6 silver serpents only hatch once per egg.
 					qty = 1;
+				else if (egg->qty != 100) // egg qty 100: do not randomize spawn count
+					qty = (NUVIE_RAND() % qty) + 1; // try to spawn 1 to qty entities
 
 				for (i = 0; i < qty; i++) {
 					if ((gametype == NUVIE_GAME_U6 && (obj->obj_n >= OBJ_U6_GIANT_RAT || obj->obj_n == OBJ_U6_CHEST))
@@ -205,16 +207,12 @@ bool EggManager::spawn_egg(Obj *egg, uint8 hatch_probability) {
 								actor_manager->toss_actor_get_location(egg->x, egg->y, egg->z, 4, 4, &actor_loc);
 						}
 						uint8 worktype = get_worktype(obj);
-						if (actor_manager->create_temp_actor(obj->obj_n, obj->status, actor_loc.x, actor_loc.y, actor_loc.z, alignment, worktype, &new_actor) && prev_actor) {
+						actor_manager->create_temp_actor(obj->obj_n, obj->status, actor_loc.x, actor_loc.y, actor_loc.z, alignment, worktype, &new_actor);
 							/*
 							// try to group actors of the same type first (FIXME: maybe this should use alignment/quality)
 							if(prev_actor->get_obj_n() != new_actor->get_obj_n() || !actor_manager->toss_actor(new_actor, 3, 2) || !actor_manager->toss_actor(new_actor, 2, 3))
 							    actor_manager->toss_actor(new_actor, 4, 4);
 							*/
-							hatch_probability = NUVIE_RAND() % 100;
-							if (hatch_probability > egg->qty)
-								break; // chance to stop spawning actors
-						}
 					} else {
 						/* spawn temp object */
 						spawned_obj = new Obj();




More information about the Scummvm-git-logs mailing list