Skip to content

Commit 6a64dec

Browse files
committed
Fix mage-bolt friendly fire [GOMPS-299]
Many actions can cause the player to "look like" they're hitting another player (e.g. selecting a target and using the Attack action on them makes them play the reaction anim) but that's just amusing fluff... the problem is that mage bolt did actual damage to other players. This is fixed. Also fixed: if the target of the mage bolt had disappeared since the mage queued the attack, the attack was simply aborted because we had no target. Now, the attack is not aborted, and just turns into a normal "missed" bolt. To do this, the client sends the click-position along with all bolt attacks.
1 parent f06da28 commit 6a64dec

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

Assets/BossRoom/Scripts/Client/Game/Action/FXProjectileTargetedActionFX.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,12 @@ public override bool Start()
2828
bool wasAnticipated = Anticipated;
2929
base.Start();
3030
m_Target = GetTarget();
31-
if (HasTarget() && m_Target == null)
32-
{
33-
// target has disappeared! Abort.
34-
return false;
35-
}
3631

3732
if (Description.Projectiles.Length < 1 || Description.Projectiles[0].ProjectilePrefab == null)
3833
throw new System.Exception($"Action {Description.ActionTypeEnum} has no valid ProjectileInfo!");
3934

4035
// animate shooting the projectile
41-
if( !wasAnticipated )
36+
if (!wasAnticipated)
4237
{
4338
PlayFireAnim();
4439
}
@@ -56,7 +51,7 @@ public override bool Update()
5651
if (TimeRunning >= Description.ExecTimeSeconds && m_Projectile == null)
5752
{
5853
// figure out how long the pretend-projectile will be flying to the target
59-
Vector3 targetPos = HasTarget() ? m_Target.transform.position : m_Data.Position;
54+
Vector3 targetPos = m_Target ? m_Target.transform.position : m_Data.Position;
6055
float initialDistance = Vector3.Distance(targetPos, m_Parent.transform.position);
6156
m_ProjectileDuration = initialDistance / Description.Projectiles[0].Speed_m_s;
6257

@@ -100,14 +95,6 @@ private void PlayHitReact()
10095
}
10196
}
10297

103-
/// <summary>
104-
/// Do we even have a target? (If false, it means player clicked on nothing, and we're rendering a "missed" fake bolt.)
105-
/// </summary>
106-
private bool HasTarget()
107-
{
108-
return Data.TargetIds != null && Data.TargetIds.Length > 0;
109-
}
110-
11198
private NetworkObject GetTarget()
11299
{
113100
if (Data.TargetIds == null || Data.TargetIds.Length == 0)

Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ private void PopulateSkillRequest(Vector3 hitPoint, ActionType action, ref Actio
322322
resultData.CancelMovement = true;
323323
return;
324324
case ActionLogic.RangedFXTargeted:
325-
if (resultData.TargetIds == null) { resultData.Position = hitPoint; }
325+
resultData.Position = hitPoint;
326326
return;
327327
}
328328
}

Assets/BossRoom/Scripts/Server/Game/Action/FXProjectileTargetedAction.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@ public FXProjectileTargetedAction(ServerCharacter parent, ref ActionRequestData
2222
public override bool Start()
2323
{
2424
m_Target = GetTarget();
25-
if (m_Target == null && HasTarget())
26-
{
27-
// target has disappeared! Abort.
28-
return false;
29-
}
3025

3126
// figure out where the player wants us to aim at...
32-
Vector3 targetPos = HasTarget() ? m_Target.transform.position : m_Data.Position;
27+
Vector3 targetPos = m_Target != null ? m_Target.transform.position : m_Data.Position;
3328

3429
// then make sure we can actually see that point!
3530
if (!ActionUtils.HasLineOfSight(m_Parent.transform.position, targetPos, out Vector3 collidePos))
@@ -76,14 +71,6 @@ public override void Cancel()
7671
}
7772
}
7873

79-
/// <summary>
80-
/// Are we even supposed to have a target? (If not, we're representing a "missed" bolt that just hits nothing.)
81-
/// </summary>
82-
private bool HasTarget()
83-
{
84-
return Data.TargetIds != null && Data.TargetIds.Length > 0;
85-
}
86-
8774
/// <summary>
8875
/// Returns our intended target, or null if not found/no target.
8976
/// </summary>
@@ -97,6 +84,13 @@ private IDamageable GetTarget()
9784
NetworkObject obj;
9885
if (NetworkSpawnManager.SpawnedObjects.TryGetValue(Data.TargetIds[0], out obj) && obj != null)
9986
{
87+
// make sure this isn't a friend (or if it is, make sure this is a friendly-fire action)
88+
var serverChar = obj.GetComponent<ServerCharacter>();
89+
if (serverChar && serverChar.IsNpc == (Description.IsFriendly ^ m_Parent.IsNpc))
90+
{
91+
// not a valid target
92+
return null;
93+
}
10094
return obj.GetComponent<IDamageable>();
10195
}
10296
else

0 commit comments

Comments
 (0)