Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for turrets #493

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Perpetuum/Zones/NpcSystem/SmartCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ public override void AcceptVisitor(IEntityVisitor visitor)
}
}

public virtual bool IsFriendly(Unit source)
{
return false;
}

protected override void OnTileChanged()
{
base.OnTileChanged();
Expand Down Expand Up @@ -417,7 +422,11 @@ protected override void OnDamageTaken(Unit source, DamageTakenEventArgs e)
}

BossInfo?.OnDamageTaken(this, player);
AddThreat(player, new Threat(ThreatType.Damage, e.TotalDamage * 0.9), true);

if (!IsFriendly(source))
{
AddThreat(player, new Threat(ThreatType.Damage, e.TotalDamage * 0.9), true);
}
}

protected override void OnUpdate(TimeSpan time)
Expand Down
2 changes: 1 addition & 1 deletion src/Perpetuum/Zones/RemoteControl/CombatDrone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal override bool IsHostile(MobileTeleport teleport)

protected override void OnUnitLockStateChanged(Lock @lock)
{
// Do nothing
// Do nothing; Combat Drones don't care about locks
}

protected override void UpdateUnitVisibility(Unit target)
Expand Down
20 changes: 7 additions & 13 deletions src/Perpetuum/Zones/RemoteControl/SentryTurret.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using Perpetuum.Players;
using Perpetuum.Services.Standing;
using Perpetuum.Units;
using Perpetuum.Zones.DamageProcessors;
using Perpetuum.Zones.Locking.Locks;
using Perpetuum.Zones.NpcSystem;
using Perpetuum.Zones.NpcSystem.ThreatManaging;
using System;

namespace Perpetuum.Zones.RemoteControl
Expand Down Expand Up @@ -73,21 +72,16 @@ protected override void OnUpdate(TimeSpan time)
base.OnUpdate(time);
}

protected override void OnDamageTaken(Unit source, DamageTakenEventArgs e)
protected override void OnUnitLockStateChanged(Lock @lock)
{
base.OnDamageTaken(source, e);
// Do nothing; Sentry Turrets don't care about locks
}

public override bool IsFriendly(Unit source)
{
Player player = Zone.ToPlayerOrGetOwnerPlayer(source);

if (player == null)
{
return;
}

if (IsHostilePlayer(player))
{
AddThreat(player, new Threat(ThreatType.Damage, e.TotalDamage * 0.9), true);
}
return player != null && IsHostilePlayer(player);
}
}
}