Skip to content

Commit ab40f6f

Browse files
kamronbatmanclaude
andcommitted
refactor: drop Controlled || Summoned checks that guard GetMaster()
GetMaster() is already null unless the creature is controlled or summoned, so golem damage transfer, pack instinct, house access and indirect spell targeting test its result instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 3832d1a commit ab40f6f

4 files changed

Lines changed: 15 additions & 38 deletions

File tree

‎Projects/UOContent/Items/Weapons/BaseWeapon.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ public virtual int GetPackInstinctBonus(Mobile attacker, Mobile defender)
16981698
return 0;
16991699
}
17001700

1701-
if (attacker is not BaseCreature bc || bc.PackInstinct == PackInstinct.None || !bc.Controlled && !bc.Summoned)
1701+
if (attacker is not BaseCreature bc || bc.PackInstinct == PackInstinct.None)
17021702
{
17031703
return 0;
17041704
}
@@ -1713,8 +1713,7 @@ public virtual int GetPackInstinctBonus(Mobile attacker, Mobile defender)
17131713
var inPack = 1;
17141714
foreach (var m in defender.GetMobilesInRange<BaseCreature>(1))
17151715
{
1716-
if (m != attacker && (m.PackInstinct & bc.PackInstinct) != 0 && (m.Controlled || m.Summoned) &&
1717-
master == m.GetMaster() && m.Combatant == defender)
1716+
if (m != attacker && (m.PackInstinct & bc.PackInstinct) != 0 && master == m.GetMaster() && m.Combatant == defender)
17181717
{
17191718
inPack++;
17201719
}

‎Projects/UOContent/Mobiles/Monsters/Misc/Melee/Golem.cs‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,17 @@ public override void OnDeath(Container c)
142142

143143
public override void OnDamage(int amount, Mobile from, bool willKill)
144144
{
145-
if (Controlled || Summoned)
145+
if (GetMaster() is { Player: true } master && master.Map == Map && master.InRange(Location, 20))
146146
{
147-
var master = GetMaster();
148-
149-
if (master?.Player == true && master.Map == Map && master.InRange(Location, 20))
147+
if (master.Mana >= amount)
150148
{
151-
if (master.Mana >= amount)
152-
{
153-
master.Mana -= amount;
154-
}
155-
else
156-
{
157-
amount -= master.Mana;
158-
master.Mana = 0;
159-
master.Damage(amount);
160-
}
149+
master.Mana -= amount;
150+
}
151+
else
152+
{
153+
amount -= master.Mana;
154+
master.Mana = 0;
155+
master.Damage(amount);
161156
}
162157
}
163158

‎Projects/UOContent/Multis/Houses/BaseHouse.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,11 +3660,6 @@ public bool HasAccess(Mobile m)
36603660
return true;
36613661
}
36623662

3663-
if (!(bc.Controlled || bc.Summoned))
3664-
{
3665-
return false;
3666-
}
3667-
36683663
m = bc.GetMaster();
36693664

36703665
return m != null && (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access?.Contains(m) == true);

‎Projects/UOContent/Spells/Base/SpellHelper.cs‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -449,29 +449,17 @@ public static bool ValidIndirectTarget(Mobile from, Mobile to)
449449
return false;
450450
}
451451

452-
if (bcTarg != null && (bcTarg.Controlled || bcTarg.Summoned))
452+
if (bcTarg?.GetMaster() is { } targMaster)
453453
{
454-
if (bcTarg.GetMaster() == from)
455-
{
456-
return false;
457-
}
458-
459-
if (p != null && p.Contains(bcTarg.GetMaster()))
454+
if (targMaster == from || p?.Contains(targMaster) == true)
460455
{
461456
return false;
462457
}
463458
}
464459

465-
if (bcFrom != null && (bcFrom.Controlled || bcFrom.Summoned))
460+
if (bcFrom?.GetMaster() is { } fromMaster)
466461
{
467-
if (bcFrom.GetMaster() == to)
468-
{
469-
return false;
470-
}
471-
472-
p = Party.Get(to);
473-
474-
if (p != null && p.Contains(bcFrom.GetMaster()))
462+
if (fromMaster == to || Party.Get(to)?.Contains(fromMaster) == true)
475463
{
476464
return false;
477465
}

0 commit comments

Comments
 (0)