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

mduggan mgithub at guarana.org
Thu Apr 29 08:07:50 UTC 2021


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

Summary:
90ee552cc0 ULTIMA8: Correct comment
d29114b216 ULTIMA8: Fix keybinding for Crusader medikit
936120dd66 DEVTOOLS: ULTIMA8: Add more weapon data to Crusader ini files.
20cc071c0d ULTIMA8: Fix watch debug output on AnimationTracker
5480d8a531 ULTIMA8: Add more Crusader weapon data to struct
bb69710f51 ULTIMA8: Add Crusader weapon ammo usage and reload
be7ce1b6de ULTIMA8: Fix quantity when combining reagents


Commit: 90ee552cc0bc3fc43ba6afdbfdd8cac81f6634a0
    https://github.com/scummvm/scummvm/commit/90ee552cc0bc3fc43ba6afdbfdd8cac81f6634a0
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-29T17:02:56+09:00

Commit Message:
ULTIMA8: Correct comment

Changed paths:
    engines/ultima/ultima8/usecode/uc_machine.cpp


diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index 6931ce3b12..fd243b5890 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -98,7 +98,7 @@ UCMachine::UCMachine(Intrinsic *iset, unsigned int icount) {
 		_convUse = new ConvertUsecodeCrusader();
 	} else {
 		_globals = new ByteSet(0x1000);
-		// slight hack: set global 003C to start as avatar number.
+		// slight hack: set global 001E to start as avatar number.
 		_globals->setEntries(0x1E, 2, 1);
 		_convUse = new ConvertUsecodeRegret();
 	}


Commit: d29114b216043e49936d67983bee5e8ac173d82a
    https://github.com/scummvm/scummvm/commit/d29114b216043e49936d67983bee5e8ac173d82a
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-29T17:02:56+09:00

Commit Message:
ULTIMA8: Fix keybinding for Crusader medikit

Changed paths:
    engines/ultima/ultima8/meta_engine.cpp


diff --git a/engines/ultima/ultima8/meta_engine.cpp b/engines/ultima/ultima8/meta_engine.cpp
index a364bb307c..f9a5d13810 100644
--- a/engines/ultima/ultima8/meta_engine.cpp
+++ b/engines/ultima/ultima8/meta_engine.cpp
@@ -84,7 +84,7 @@ static const KeybindingRecord CRUSADER_KEYS[] = {
 	{ ACTION_NEXT_WEAPON, "NEXT_WEAPON", "Next Weapon", "MainActor::nextWeapon", nullptr, "w", nullptr, 0 },
 	{ ACTION_NEXT_INVENTORY, "NEXT_INVENTORY", "Next Inventory Item", "MainActor::nextInvItem", nullptr, "i", nullptr, 0 },
 	{ ACTION_USE_INVENTORY, "USE_INVENTORY", "Use Inventroy Item", "MainActor::useInventoryItem", nullptr, "u", nullptr, 0 },
-	{ ACTION_USE_MEDIKIT, "USE_MEDIKIT", "Use Medical Kit", "MainActor::useMedikit", nullptr, "M", nullptr, 0 },
+	{ ACTION_USE_MEDIKIT, "USE_MEDIKIT", "Use Medical Kit", "MainActor::useMedikit", nullptr, "m", nullptr, 0 },
 	{ ACTION_DETONATE_BOMB, "DETONATE_BOMB", "Detonate Bomb", "MainActor::detonateBomb", nullptr, "b", nullptr, 0 },
 	{ ACTION_SELECT_ITEMS, "SELECT_ITEM", "Select Item", "ItemSelectionProcess::startSelection", nullptr, "s", nullptr, 0 },
 	{ ACTION_USE_SELECTION, "USE_SELECTION", "Use Selection", "ItemSelectionProcess::useSelectedItem", nullptr, "RETURN", nullptr, 0 },


Commit: 936120dd665944ccc6f2f1d1a34d2849a3166a86
    https://github.com/scummvm/scummvm/commit/936120dd665944ccc6f2f1d1a34d2849a3166a86
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-29T17:02:56+09:00

Commit Message:
DEVTOOLS: ULTIMA8: Add more weapon data to Crusader ini files.

Changed paths:
    devtools/create_ultima/files/ultima8/regretweapons.ini
    devtools/create_ultima/files/ultima8/remorseweapons.ini


diff --git a/devtools/create_ultima/files/ultima8/regretweapons.ini b/devtools/create_ultima/files/ultima8/regretweapons.ini
index 334ac5a89b..8c805a756b 100644
--- a/devtools/create_ultima/files/ultima8/regretweapons.ini
+++ b/devtools/create_ultima/files/ultima8/regretweapons.ini
@@ -7,8 +7,10 @@ damage_type=0x0B
 display_shape=3
 display_frame=2
 overlay_shape=0x01A1
-overlay=4
+overlay=0
 small=1
+reload_sound=0x02B
+shot_delay=0x0C
 
 [BA-41]
 shape=0x032F
@@ -20,6 +22,11 @@ display_frame=1
 overlay_shape=0x01A1
 overlay=0
 small=1
+reload_sound=0x02B
+shot_delay=0x09
+clip_size=20
+ammo_shape=0x033D
+ammo_frame=8
 
 [PA-21]
 shape=0x0330
@@ -29,8 +36,10 @@ damage_type=0x05
 display_shape=3
 display_frame=7
 overlay_shape=0x036D
-overlay=0
+overlay=1
 small=1
+shot_delay=20
+energy=0x019
 
 [EM-4]
 shape=0x038C
@@ -40,7 +49,9 @@ damage_type=0x0F
 display_shape=3
 display_frame=3
 overlay_shape=0x036F
-overlay=0
+overlay=2
+shot_delay=20
+energy=0x087
 
 [SG-A1]
 shape=0x0332
@@ -51,6 +62,11 @@ display_shape=3
 display_frame=0
 overlay_shape=0x033B
 overlay=4
+reload_sound=0x019
+shot_delay=0x019
+clip_size=12
+ammo_shape=0x033E
+ammo_frame=10
 
 [RP-22]
 shape=0x0333
@@ -60,7 +76,12 @@ damage_type=0x01
 display_shape=3
 display_frame=6
 overlay_shape=0x036F
-overlay=0
+overlay=2
+reload_sound=0x02B
+shot_delay=10
+clip_size=0x03C
+ammo_shape=0x033F
+ammo_frame=9
 
 [RP-32]
 shape=0x0334
@@ -70,7 +91,12 @@ damage_type=0x01
 display_shape=3
 display_frame=5
 overlay_shape=0x036F
-overlay=0
+overlay=2
+reload_sound=0x02B
+shot_delay=6
+clip_size=0x03C
+ammo_shape=0x033F
+ammo_frame=9
 
 [AR-7]
 shape=0x038E
@@ -80,7 +106,12 @@ damage_type=0x0A
 display_shape=3
 display_frame=0xC
 overlay_shape=0x036E
-overlay=0
+overlay=3
+reload_sound=0x02B
+shot_delay=10
+clip_size=8
+ammo_shape=0x0340
+ammo_frame=11
 
 [GL-303]
 shape=0x0388
@@ -90,7 +121,12 @@ damage_type=0x03
 display_shape=3
 display_frame=8
 overlay_shape=0x036E
-overlay=0
+overlay=3
+reload_sound=0x02B
+shot_delay=0x03C
+clip_size=10
+ammo_shape=0x0341
+ammo_frame=12
 
 [PA-31]
 shape=0x038A
@@ -100,7 +136,9 @@ damage_type=0x05
 display_shape=3
 display_frame=9
 overlay_shape=0x036F
-overlay=0
+overlay=2
+shot_delay=12
+energy=0x023
 
 [PL-1]
 shape=0x038D
@@ -110,7 +148,9 @@ damage_type=0x06
 display_shape=3
 display_frame=0xA
 overlay_shape=0x036E
-overlay=0
+overlay=3
+shot_delay=6
+energy=0x02D
 
 [AC-88]
 shape=0x038B
@@ -120,7 +160,12 @@ damage_type=0x0D
 display_shape=3
 display_frame=4
 overlay_shape=0x036E
-overlay=0
+overlay=3
+reload_sound=0x02B
+shot_delay=10
+clip_size=12
+ammo_shape=0x033E
+ammo_frame=10
 
 [UV-9]
 shape=0x0386
@@ -130,7 +175,7 @@ damage_type=0x0E
 display_shape=3
 display_frame=0xB
 overlay_shape=0x036E
-overlay=0
+overlay=3
 
 [BK-16]
 shape=0x05F6
@@ -140,7 +185,7 @@ damage_type=0x0E
 display_shape=3
 display_frame=0xB
 overlay_shape=0x036E
-overlay=2
+overlay=3
 
 [LNR-81]
 shape=0x05F5
@@ -150,7 +195,7 @@ damage_type=0x11
 display_shape=3
 display_frame=0xB
 overlay_shape=0x036E
-overlay=0
+overlay=3
 
 [XP-5]
 shape=0x0198
@@ -160,7 +205,7 @@ display_shape=3
 display_frame=0x10h
 overlay_shape=0x033B
 # TODO: check this
-overlay=0
+overlay=4
 
 # Ammo
 [BA-41 CLIP]
@@ -289,7 +334,7 @@ display_frame=0x17
 
 # Other special case items
 [CREDITS]
-shape=0x4ED
+shape=0x112
 display_shape=3
 display_frame=0xD
 
diff --git a/devtools/create_ultima/files/ultima8/remorseweapons.ini b/devtools/create_ultima/files/ultima8/remorseweapons.ini
index d5d07174a4..bca8ff1a9b 100644
--- a/devtools/create_ultima/files/ultima8/remorseweapons.ini
+++ b/devtools/create_ultima/files/ultima8/remorseweapons.ini
@@ -9,6 +9,8 @@ display_frame=2
 overlay_shape=0x01A1
 overlay=0
 small=1
+reload_sound=0x02B
+shot_delay=0x0C
 
 [BA-41]
 shape=0x032F
@@ -20,6 +22,11 @@ display_frame=1
 overlay_shape=0x01A1
 overlay=0
 small=1
+reload_sound=0x02B
+shot_delay=0x09
+clip_size=20
+ammo_shape=0x033D
+ammo_frame=8
 
 [PA-21]
 shape=0x0330
@@ -31,6 +38,8 @@ display_frame=7
 overlay_shape=0x036D
 overlay=1
 small=1
+shot_delay=20
+energy=0x019
 
 [EM-4]
 shape=0x038C
@@ -41,6 +50,8 @@ display_shape=3
 display_frame=3
 overlay_shape=0x036F
 overlay=2
+shot_delay=20
+energy=0x087
 
 [SG-A1]
 shape=0x0332
@@ -51,6 +62,11 @@ display_shape=3
 display_frame=0
 overlay_shape=0x033B
 overlay=4
+reload_sound=0x019
+shot_delay=0x019
+clip_size=12
+ammo_shape=0x033E
+ammo_frame=10
 
 [RP-22]
 shape=0x0333
@@ -61,6 +77,11 @@ display_shape=3
 display_frame=6
 overlay_shape=0x036F
 overlay=2
+reload_sound=0x02B
+shot_delay=10
+clip_size=0x03C
+ammo_shape=0x033F
+ammo_frame=9
 
 [RP-32]
 shape=0x0334
@@ -71,6 +92,11 @@ display_shape=3
 display_frame=5
 overlay_shape=0x036F
 overlay=2
+reload_sound=0x02B
+shot_delay=6
+clip_size=0x03C
+ammo_shape=0x033F
+ammo_frame=9
 
 [AR-7]
 shape=0x038E
@@ -81,6 +107,11 @@ display_shape=3
 display_frame=0xC
 overlay_shape=0x036E
 overlay=3
+reload_sound=0x02B
+shot_delay=10
+clip_size=8
+ammo_shape=0x0340
+ammo_frame=11
 
 [GL-303]
 shape=0x0388
@@ -91,6 +122,11 @@ display_shape=3
 display_frame=8
 overlay_shape=0x036E
 overlay=3
+reload_sound=0x02B
+shot_delay=0x03C
+clip_size=10
+ammo_shape=0x0341
+ammo_frame=12
 
 [PA-31]
 shape=0x038A
@@ -101,6 +137,8 @@ display_shape=3
 display_frame=9
 overlay_shape=0x036F
 overlay=2
+shot_delay=12
+energy=0x023
 
 [PL-1]
 shape=0x038D
@@ -111,6 +149,8 @@ display_shape=3
 display_frame=0xA
 overlay_shape=0x036E
 overlay=3
+shot_delay=6
+energy=0x02D
 
 [AC-88]
 shape=0x038B
@@ -121,6 +161,11 @@ display_shape=3
 display_frame=4
 overlay_shape=0x036E
 overlay=3
+reload_sound=0x02B
+shot_delay=10
+clip_size=12
+ammo_shape=0x033E
+ammo_frame=10
 
 [UV-9]
 shape=0x0386
@@ -130,7 +175,9 @@ damage_type=0x0E
 display_shape=3
 display_frame=0xB
 overlay_shape=0x036E
-overlay=0
+overlay=3
+shot_delay=0x023
+energy=0x0D2
 
 # Ammo
 [BA-41 CLIP]


Commit: 20cc071c0d18deb102cdc3c75fa6e6e1e89f3974
    https://github.com/scummvm/scummvm/commit/20cc071c0d18deb102cdc3c75fa6e6e1e89f3974
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-29T17:02:56+09:00

Commit Message:
ULTIMA8: Fix watch debug output on AnimationTracker

Changed paths:
    engines/ultima/ultima8/world/actors/anim_action.h
    engines/ultima/ultima8/world/actors/animation_tracker.cpp


diff --git a/engines/ultima/ultima8/world/actors/anim_action.h b/engines/ultima/ultima8/world/actors/anim_action.h
index e284fa5c6c..a473e1a297 100644
--- a/engines/ultima/ultima8/world/actors/anim_action.h
+++ b/engines/ultima/ultima8/world/actors/anim_action.h
@@ -139,6 +139,10 @@ public:
 		return (_flags & mask) != 0;
 	}
 
+	uint32 getFlags() const {
+		return _flags;
+	}
+
 	const AnimFrame &getFrame(Direction dir, unsigned int frameno) const;
 
 	/**
diff --git a/engines/ultima/ultima8/world/actors/animation_tracker.cpp b/engines/ultima/ultima8/world/actors/animation_tracker.cpp
index 2e899dc78e..9286d4710d 100644
--- a/engines/ultima/ultima8/world/actors/animation_tracker.cpp
+++ b/engines/ultima/ultima8/world/actors/animation_tracker.cpp
@@ -89,10 +89,8 @@ bool AnimationTracker::init(const Actor *actor, Animation::Sequence action,
 
 #ifdef WATCHACTOR
 	if (actor && actor->getObjId() == watchactor) {
-		pout << "AnimationTracker: playing action " << actionnum << " " << _startFrame << "-" << _endFrame
-		     << " (_animAction flags: " << Std::hex << _animAction->_flags
-		     << Std::dec << ")" << Std::endl;
-
+		debug(6, "AnimationTracker: playing action %d %d-%d (animAction flags: 0x04%x)",
+			  actionnum, _startFrame, _endFrame, _animAction->getFlags());
 	}
 #endif
 


Commit: 5480d8a5310a8dad99f85fdc5cb52a05cda22aac
    https://github.com/scummvm/scummvm/commit/5480d8a5310a8dad99f85fdc5cb52a05cda22aac
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-29T17:02:56+09:00

Commit Message:
ULTIMA8: Add more Crusader weapon data to struct

Changed paths:
    engines/ultima/ultima8/graphics/type_flags.cpp
    engines/ultima/ultima8/world/item_factory.cpp
    engines/ultima/ultima8/world/weapon_info.h


diff --git a/engines/ultima/ultima8/graphics/type_flags.cpp b/engines/ultima/ultima8/graphics/type_flags.cpp
index d58a45a86e..cfdca33264 100644
--- a/engines/ultima/ultima8/graphics/type_flags.cpp
+++ b/engines/ultima/ultima8/graphics/type_flags.cpp
@@ -243,6 +243,11 @@ void TypeFlags::loadWeaponInfo() {
 		else
 			wi->_sound = 0;
 
+		if (config->get(category, section, "reload_sound", val))
+			wi->_reloadSound = static_cast<uint16>(val);
+		else
+			wi->_reloadSound = 0;
+
 		if (config->get(category, section, "display_frame", val))
 			wi->_displayGumpFrame = static_cast<uint16>(val);
 		else
@@ -258,8 +263,20 @@ void TypeFlags::loadWeaponInfo() {
 		else
 			wi->_small = 0;
 
-		// TODO: get from real data.
-		wi->_defaultAmmo = 37;
+		if (config->get(category, section, "clip_size", val))
+			wi->_clipSize = static_cast<uint16>(val);
+		else
+			wi->_clipSize = 10;
+
+		if (config->get(category, section, "energy", val))
+			wi->_energyUse = static_cast<uint16>(val);
+		else
+			wi->_energyUse = 0;
+
+		if (config->get(category, section, "shot_delay", val))
+			wi->_shotDelay = static_cast<uint16>(val);
+		else
+			wi->_shotDelay = 0;
 
 		// TODO: this should be 1, 2, or 3 depending on weapon.
 		// It's used in the AttackProcess
diff --git a/engines/ultima/ultima8/world/item_factory.cpp b/engines/ultima/ultima8/world/item_factory.cpp
index d68fa947b7..d9753b7491 100644
--- a/engines/ultima/ultima8/world/item_factory.cpp
+++ b/engines/ultima/ultima8/world/item_factory.cpp
@@ -102,8 +102,8 @@ Item *ItemFactory::createItem(uint32 shape, uint32 frame, uint16 quality,
 				item->setDamagePoints(info->_damageInfo->damagePoints());
 			}
 			if (info->_family == ShapeInfo::SF_CRUWEAPON && info->_weaponInfo &&
-				info->_weaponInfo->_defaultAmmo) {
-				item->setQuality(info->_weaponInfo->_defaultAmmo);
+				info->_weaponInfo->_clipSize) {
+				item->setQuality(info->_weaponInfo->_clipSize);
 			}
 			if (info->_family == ShapeInfo::SF_CRUAMMO ||
 					 info->_family == ShapeInfo::SF_CRUBOMB) {
diff --git a/engines/ultima/ultima8/world/weapon_info.h b/engines/ultima/ultima8/world/weapon_info.h
index 985e23ab8a..cced4fbc43 100644
--- a/engines/ultima/ultima8/world/weapon_info.h
+++ b/engines/ultima/ultima8/world/weapon_info.h
@@ -43,13 +43,16 @@ struct WeaponInfo {
 
 	// Crusader-specific fields:
 	uint16 _sound;		//!< The sound this weapon makes when fired
+	uint16 _reloadSound; //!< The sound made when reloaded
 	uint16 _ammoType;	//!< The inventory frame for the ammo used
 	uint16 _ammoShape;	//!< The shape number for the ammo used
 	uint16 _displayGumpShape; //! The gump shape to use for inventory display (3,4,5)
 	uint16 _displayGumpFrame; //!< The frame to use in the inventory gump
 	uint8 _small;	//! A flag whether or not the weapon is "small" (changes the animations used)
-	uint16 _defaultAmmo; //! Count of ammo the weapon starts with
+	uint16 _clipSize; //! Count of ammo the weapon starts with and gets from a reload
+	uint16 _energyUse; //! Energy used by each shot
 	uint8 _field8;	//! Not totally sure, used like "cycle time" in Attack Process
+	uint16 _shotDelay; //! Delay between shots
 
 	enum DmgType {
 		DMG_NORMAL = 0x0001,


Commit: bb69710f5114b8d7cf1ed54a64f510172192f438
    https://github.com/scummvm/scummvm/commit/bb69710f5114b8d7cf1ed54a64f510172192f438
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-29T17:02:56+09:00

Commit Message:
ULTIMA8: Add Crusader weapon ammo usage and reload

Changed paths:
    engines/ultima/ultima8/graphics/anim_dat.cpp
    engines/ultima/ultima8/world/actors/actor.cpp
    engines/ultima/ultima8/world/actors/animation.cpp
    engines/ultima/ultima8/world/actors/animation.h
    engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
    engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h


diff --git a/engines/ultima/ultima8/graphics/anim_dat.cpp b/engines/ultima/ultima8/graphics/anim_dat.cpp
index 3c230f00c7..9f3bf1373c 100644
--- a/engines/ultima/ultima8/graphics/anim_dat.cpp
+++ b/engines/ultima/ultima8/graphics/anim_dat.cpp
@@ -95,6 +95,8 @@ uint32 AnimDat::getActionNumberForSequence(Animation::Sequence action, const Act
 			return Animation::walkCru;
 		case Animation::retreat:
 			return (smallwpn ? Animation::retreatSmallWeapon : Animation::retreatLargeWeapon);
+		case Animation::reloadSmallWeapon:
+			return (smallwpn ? Animation::reloadSmallWeapon : Animation::reloadLargeWeapon);
 		case Animation::run:
 			return Animation::runCru;
 		case Animation::combatRunSmallWeapon:
diff --git a/engines/ultima/ultima8/world/actors/actor.cpp b/engines/ultima/ultima8/world/actors/actor.cpp
index 4a386580e3..2c2fe22682 100644
--- a/engines/ultima/ultima8/world/actors/actor.cpp
+++ b/engines/ultima/ultima8/world/actors/actor.cpp
@@ -484,7 +484,7 @@ uint16 Actor::doAnim(Animation::Sequence anim, Direction dir, unsigned int steps
 
 		if (anim == Animation::readyWeapon || anim == Animation::stopRunningAndDrawSmallWeapon ||
 				anim == Animation::combatStand || anim == Animation::attack || anim == Animation::kneel ||
-				anim == Animation::kneelAndFire)
+				anim == Animation::kneelAndFire || anim == Animation::reloadSmallWeapon)
 			setActorFlag(ACT_WEAPONREADY);
 		else
 			clearActorFlag(ACT_WEAPONREADY);
@@ -547,7 +547,7 @@ uint16 Actor::doAnim(Animation::Sequence anim, Direction dir, unsigned int steps
 		getLocation(x, y, z);
 		int32 actionno = AnimDat::getActionNumberForSequence(anim, this);
 		const AnimAction *action = GameData::get_instance()->getMainShapes()->getAnim(getShape(), actionno);
-		debug(6, "Actor::doAnim(%d, %d, %d) from (%d, %d, %d) frame repeat %d", anim, dir, steps, x, y, z, action->getFrameRepeat());
+		debug(6, "Actor::doAnim(%d, %d, %d) from (%d, %d, %d) frame repeat %d", anim, dir, steps, x, y, z, action ? action->getFrameRepeat() : -1);
 	}
 #endif
 
diff --git a/engines/ultima/ultima8/world/actors/animation.cpp b/engines/ultima/ultima8/world/actors/animation.cpp
index 9471ad8fde..77e7a8ac20 100644
--- a/engines/ultima/ultima8/world/actors/animation.cpp
+++ b/engines/ultima/ultima8/world/actors/animation.cpp
@@ -59,6 +59,7 @@ bool isCombatAnimCru(const Sequence anim) {
 	case advance:
 	case retreat:
 	case attack:
+	case reloadSmallWeapon:
 	case kick:
 	case kneel:
 	case kneelStartCru:
diff --git a/engines/ultima/ultima8/world/actors/animation.h b/engines/ultima/ultima8/world/actors/animation.h
index 741830c0c3..b36a136cd1 100644
--- a/engines/ultima/ultima8/world/actors/animation.h
+++ b/engines/ultima/ultima8/world/actors/animation.h
@@ -103,10 +103,12 @@ enum Sequence {
 	combatStandSmallWeapon = 4,
 	readySmallWeapon = 7,
 	fireSmallWeapon = 8,
+	reloadSmallWeapon = 10,
 	unreadySmallWeapon = 11,
 	readyLargeWeapon = 12,
 	fireLargeWeapon = 13,
 	reload = 14,
+	reloadLargeWeapon = 15,
 	unreadyLargeWeapon = 16,
 	fallBackwardsCru = 18,
 	fallForwardsCru = 20,
diff --git a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
index 6057a30bb5..2cdfc5cb73 100644
--- a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
@@ -28,6 +28,8 @@
 #include "ultima/ultima8/world/current_map.h"
 #include "ultima/ultima8/world/world.h"
 #include "ultima/ultima8/misc/direction_util.h"
+#include "ultima/ultima8/audio/audio_process.h"
+#include "ultima/ultima8/kernel/delay_process.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -36,7 +38,7 @@ DEFINE_RUNTIME_CLASSTYPE_CODE(CruAvatarMoverProcess)
 
 static const int REBEL_BASE_MAP = 40;
 
-CruAvatarMoverProcess::CruAvatarMoverProcess() : AvatarMoverProcess(), _avatarAngle(0) {
+CruAvatarMoverProcess::CruAvatarMoverProcess() : AvatarMoverProcess(), _avatarAngle(0), _SGA1Loaded(false) {
 }
 
 
@@ -432,21 +434,96 @@ void CruAvatarMoverProcess::step(Animation::Sequence action, Direction direction
 }
 
 void CruAvatarMoverProcess::tryAttack() {
+	// Don't do it while this process is waiting
+	if (is_suspended())
+		return;
+
 	Actor *avatar = getControlledActor();
-	if (!avatar)
+	if (!avatar || avatar->getMapNum() == REBEL_BASE_MAP || avatar->isBusy())
 		return;
 
-	if (avatar->getMapNum() == REBEL_BASE_MAP)
+	Item *wpn = getItem(avatar->getActiveWeapon());
+	if (!wpn || !wpn->getShapeInfo() || !wpn->getShapeInfo()->_weaponInfo)
 		return;
 
-	Direction dir = avatar->getDir();
 	if (!avatar->isInCombat()) {
 		avatar->setInCombat(0);
 	}
-	// Fire event happens from animation
-	Animation::Sequence fireanim = (avatar->isKneeling() ?
-									Animation::kneelAndFire : Animation::attack);
-	waitFor(avatar->doAnim(fireanim, dir));
+
+	Kernel *kernel = Kernel::get_instance();
+	AudioProcess *audio = AudioProcess::get_instance();
+	const WeaponInfo *wpninfo = wpn->getShapeInfo()->_weaponInfo;
+
+	int shotsleft;
+	if (wpninfo->_ammoShape) {
+		shotsleft = wpn->getQuality();
+	} else if (wpninfo->_energyUse) {
+		shotsleft = avatar->getMana() / wpninfo->_energyUse;
+	} else {
+		shotsleft = 1;
+	}
+
+	if (!shotsleft) {
+		Item *ammo = avatar->getFirstItemWithShape(wpninfo->_ammoShape, true);
+		if (ammo) {
+			// reload now
+			// SGA1 is special, it reloads every shot.
+			if (wpn->getShape() == 0x332)
+				_SGA1Loaded = true;
+
+			wpn->setQuality(wpninfo->_clipSize);
+			ammo->setQuality(ammo->getQuality() - 1);
+			if (ammo->getQuality() == 0)
+				ammo->destroy();
+
+			if (wpninfo->_reloadSound) {
+				audio->playSFX(0x2a, 0x80, avatar->getObjId(), 1);
+			}
+			if (avatar->getObjId() == 1 && !avatar->isKneeling()) {
+				avatar->doAnim(Animation::reloadSmallWeapon, dir_current);
+			}
+
+			int delayproc = kernel->addProcess(new DelayProcess(15));
+			this->waitFor(delayproc);
+		} else {
+			// no shots left
+			audio->playSFX(0x2a, 0x80, avatar->getObjId(), 1);
+			int delayproc = kernel->addProcess(new DelayProcess(20));
+			this->waitFor(delayproc);
+		}
+	} else {
+		// Check for SGA1 reload anim (which happens every shot)
+		if (wpn->getShape() == 0x332 && !avatar->isKneeling() && !_SGA1Loaded) {
+			if (wpninfo->_reloadSound) {
+				audio->playSFX(0x2a, 0x80, avatar->getObjId(), 1);
+			}
+			if (avatar->getObjId() == 1) {
+				avatar->doAnim(Animation::reloadSmallWeapon, dir_current);
+			}
+			_SGA1Loaded = true;
+		} else {
+			Direction dir = avatar->getDir();
+			// Fire event happens from animation
+			Animation::Sequence fireanim = (avatar->isKneeling() ?
+											Animation::kneelAndFire : Animation::attack);
+			uint16 fireanimpid = avatar->doAnim(fireanim, dir);
+			waitFor(fireanimpid);
+
+			if (wpn->getShape() == 0x332)
+				_SGA1Loaded = false;
+
+			// Use a shot up
+			if (wpninfo->_ammoShape) {
+				wpn->setQuality(shotsleft - 1);
+			} else if (wpninfo->_energyUse) {
+				avatar->setMana(avatar->getMana() - wpninfo->_energyUse);
+			}
+
+			if (wpninfo->_shotDelay) {
+				waitFor(kernel->addProcess(new DelayProcess(wpninfo->_shotDelay)));
+			}
+		}
+	}
 }
 
 void CruAvatarMoverProcess::saveData(Common::WriteStream *ws) {
diff --git a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
index 00b0b90eee..2672e2e7bb 100644
--- a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
+++ b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
@@ -62,6 +62,11 @@ private:
 	*/
 	int32 _avatarAngle;
 
+	/**
+	 * Whether we've reloaded the SGA1 yet (it needs to happen every shot)
+	 */
+	bool _SGA1Loaded;
+
 	void handleHangingMode() override;
 	void handleCombatMode() override;
 	void handleNormalMode() override;


Commit: be7ce1b6deeef80a184f06591a7d8a9481436e25
    https://github.com/scummvm/scummvm/commit/be7ce1b6deeef80a184f06591a7d8a9481436e25
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-04-29T17:02:57+09:00

Commit Message:
ULTIMA8: Fix quantity when combining reagents

The reagent which is the target should get the updated quantity, not the one
we're about to destroy.

Changed paths:
    engines/ultima/ultima8/gumps/container_gump.cpp


diff --git a/engines/ultima/ultima8/gumps/container_gump.cpp b/engines/ultima/ultima8/gumps/container_gump.cpp
index fbf178eb83..83ac366af6 100644
--- a/engines/ultima/ultima8/gumps/container_gump.cpp
+++ b/engines/ultima/ultima8/gumps/container_gump.cpp
@@ -498,7 +498,7 @@ void ContainerGump::DropItem(Item *item, int mx, int my) {
 				// maybe this isn't needed? original doesn't do it here..
 				targetitem->callUsecodeEvent_combine();
 			} else {
-				item->setQuality(newquant);
+				targetitem->setQuality(newquant);
 				targetitem->callUsecodeEvent_combine();
 				// combined, so delete other
 				item->destroy();




More information about the Scummvm-git-logs mailing list