Skip to content

Commit

Permalink
Fixed murdering of manacled people
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhannah committed Aug 10, 2022
1 parent ff77cad commit 4a491c1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Ultima5Redux/Maps/VirtualMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,8 @@ SingleCombatMapReference getSingleCombatMapReference(SingleCombatMapReference.Br
// let's use this method to also determine if an enemy CAN attack the avatar from afar

TileReference attackToTileReference = GetTileReference(attackToPosition);
if (attackToTileReference.CombatMapIndex == SingleCombatMapReference.BritanniaCombatMaps.None) return null;

TileReference attackFromTileReference = GetTileReference(attackFromPosition);

List<MapUnit> mapUnits = TheMapUnits.GetMapUnitsByPosition(LargeMapOverUnder, attackToPosition,
Expand Down
15 changes: 8 additions & 7 deletions Ultima5Redux/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,16 @@ public void SetAggressiveGuards(bool bAggressiveGuards)
// we get the combat map reference, if any - it also tells us if there should be a ranged attack in the overworld
// instead of a combat map
singleCombatMapReference =
State.TheVirtualMap.GetCombatMapReferenceForAvatarAttacking(
avatar.MapUnitPosition.XY,
attackTargetPosition,
SingleCombatMapReference.Territory.Britannia);
State.TheVirtualMap.GetCombatMapReferenceForAvatarAttacking(avatar.MapUnitPosition.XY,
attackTargetPosition, SingleCombatMapReference.Territory.Britannia);

bool bIsMurderable = GameReferences.SpriteTileReferences.IsHeadOfBed(tileReference.Index) ||
GameReferences.SpriteTileReferences.IsStocks(tileReference.Index) ||
GameReferences.SpriteTileReferences.IsManacles(tileReference.Index);

// if there is a mapunit - BUT - no
////// NOTE - this doesn't make sense for the Avatar to attack like this
if (singleCombatMapReference == null)
if (singleCombatMapReference == null && !bIsMurderable)
{
// we were not able to attack, likely on a carpet or skiff and on the water
// but may be other edge cases
Expand Down Expand Up @@ -728,8 +730,7 @@ public void SetAggressiveGuards(bool bAggressiveGuards)
break;
case NonPlayerCharacter npc:
// if they are in bed or in the stocks then it's instadeath and you are a bad person!
if (GameReferences.SpriteTileReferences.IsHeadOfBed(tileReference.Index) ||
GameReferences.SpriteTileReferences.IsStocks(tileReference.Index))
if (bIsMurderable)
{
StreamingOutput.Instance.PushMessage(
GameReferences.DataOvlRef.StringReferences.GetString(
Expand Down
1 change: 1 addition & 0 deletions Ultima5ReduxSolution.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=moongate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Moongates/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Moonglow/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Murderable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=NBYTES/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=NOFILE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=NPCFILE/@EntryIndexedValue">True</s:Boolean>
Expand Down
21 changes: 21 additions & 0 deletions Ultima5ReduxTesting/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,27 @@ public void test_ReloadStressTest(SaveFiles saveFiles)
_ = "";
}

[Test] [TestCase(SaveFiles.b_carpet)] public void Test_AttackManacles(SaveFiles saveFiles)
{
World world = CreateWorldFromLegacy(saveFiles);

world.State.TheVirtualMap.LoadSmallMap(
GameReferences.SmallMapRef.GetSingleMapByLocation(
SmallMapReferences.SingleMapReference.Location.Palace_of_Blackthorn, 1));

Point2D avatarPosition = new Point2D(10, 1);
world.State.TheVirtualMap.MoveAvatar(avatarPosition);
//world.State.TheVirtualMap.CurrentMap.RecalculateVisibleTiles(avatarPosition);
TurnResults turnResults = new TurnResults();
List<VirtualMap.AggressiveMapUnitInfo> aggressiveMapUnitInfos =
world.TryToAttack(new Point2D(10, 10),
out MapUnit mapUnit, out SingleCombatMapReference singleCombatMapReference,
out World.TryToAttackResult tryToAttackResult, turnResults);
Assert.True(tryToAttackResult == World.TryToAttackResult.NpcMurder);
_ = "";
}


[Test] [TestCase(SaveFiles.b_carpet)] public void Test_HorizTombstoneCheck(SaveFiles saveFiles)
{
World world = CreateWorldFromLegacy(saveFiles);
Expand Down

0 comments on commit 4a491c1

Please sign in to comment.