Skip to content

Commit

Permalink
Revert "update to latest WC"
Browse files Browse the repository at this point in the history
  • Loading branch information
InvalidArgument3 authored Jul 20, 2024
1 parent f413f2c commit e7c8877
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Data/Scripts/CoreSystems/Ai/AiFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public partial class Ai
internal readonly List<SupportSys.SupportComponent> SupportComps = new List<SupportSys.SupportComponent>(32);
internal readonly List<ControlSys.ControlComponent> ControlComps = new List<ControlSys.ControlComponent>(32);
internal readonly List<WeaponComponent> PhantomComps = new List<WeaponComponent>(32);
internal readonly HashSet<Projectile> DeadProjectiles = new HashSet<Projectile>();
internal readonly List<Projectile> DeadProjectiles = new List<Projectile>();
internal readonly List<Ai> TargetAisTmp = new List<Ai>();
internal readonly List<Shields> NearByShieldsTmp = new List<Shields>();
internal readonly List<MyEntity> NearByFriendlyShields = new List<MyEntity>();
Expand Down
18 changes: 8 additions & 10 deletions Data/Scripts/CoreSystems/Projectiles/Projectile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using CoreSystems.Platform;
Expand Down Expand Up @@ -237,7 +237,7 @@ internal void Start()
{
Vector3D targetDir;
Vector3D targetPos;
if (TrajectoryEstimation(Info.AmmoDef, ref Position, out targetDir, out targetPos, false))
if (TrajectoryEstimation(Info.AmmoDef, w, ref Position, out targetDir, out targetPos))
TargetPosition = targetPos;

TargetPosition -= (Direction * variance);
Expand Down Expand Up @@ -3078,7 +3078,7 @@ internal void ForceNewTarget()
Info.Storage.PickTarget = false;
}

internal bool TrajectoryEstimation(WeaponDefinition.AmmoDef ammoDef, ref Vector3D shooterPos, out Vector3D targetDirection, out Vector3D estimatedPosition, bool isTimedSpawn)
internal bool TrajectoryEstimation(WeaponDefinition.AmmoDef ammoDef, Weapon weapon, ref Vector3D shooterPos, out Vector3D targetDirection, out Vector3D estimatedPosition)
{
var aConst = Info.AmmoDef.Const;
var eTarget = Info.Target.TargetObject as MyEntity;
Expand Down Expand Up @@ -3108,11 +3108,7 @@ internal bool TrajectoryEstimation(WeaponDefinition.AmmoDef ammoDef, ref Vector3
}

var targetVel = eTarget != null ? eTarget.GetTopMostParent().Physics.LinearVelocity : (Vector3)pTarget.Velocity;
Vector3D shooterVel = Vector3D.Zero;
if (isTimedSpawn)
shooterVel = !Info.AmmoDef.Const.FragDropVelocity ? Velocity : Vector3D.Zero;
else
shooterVel = Info.ShooterVel;
var shooterVel = !Info.AmmoDef.Const.FragDropVelocity ? Velocity : Vector3D.Zero;

var projectileMaxSpeed = ammoDef.Const.DesiredProjectileSpeed * (weapon == null ? 1 : weapon.VelocityMult);
Vector3D deltaPos = targetPos - shooterPos;
Expand Down Expand Up @@ -3147,8 +3143,9 @@ internal bool TrajectoryEstimation(WeaponDefinition.AmmoDef ammoDef, ref Vector3
if (timeToIntercept < 0)
{

if (aConst.TimedFragments && aConst.FragPointType == PointTypes.Lead)
if (aConst.FragPointType == PointTypes.Lead)
{

estimatedPosition = targetPos + timeToIntercept * (targetVel - shooterVel);
targetDirection = Vector3D.Normalize(estimatedPosition - shooterPos);
return true;
Expand All @@ -3158,6 +3155,7 @@ internal bool TrajectoryEstimation(WeaponDefinition.AmmoDef ammoDef, ref Vector3
targetDirection = Direction;
return false;
}

estimatedPosition = targetPos + timeToIntercept * (targetVel - shooterVel);
targetDirection = Vector3D.Normalize(estimatedPosition - shooterPos);
return true;
Expand Down Expand Up @@ -3591,7 +3589,7 @@ internal void SpawnShrapnel(bool timedSpawn = true) // inception begins
}

Vector3D estimatedTargetPos;
if (!TrajectoryEstimation(fragAmmoDef, ref newOrigin, out pointDir, out estimatedTargetPos, true))
if (!TrajectoryEstimation(fragAmmoDef, null, ref newOrigin, out pointDir, out estimatedTargetPos))
continue;
}

Expand Down
5 changes: 4 additions & 1 deletion Data/Scripts/CoreSystems/Projectiles/ProjectileGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ private void SpawnFragments()
if (dumbAdd || validAi)
{
targetAi.DeadProjectiles.Remove(p);
targetAi.LiveProjectile[p] = condition1 || condition2;
if (targetAi.LiveProjectile.ContainsKey(p))
targetAi.LiveProjectile[p] = condition1 || condition2;
else
targetAi.LiveProjectile.Add(p, (condition1 || condition2));
targetAi.LiveProjectileTick = Session.I.Tick;
targetAi.NewProjectileTick = Session.I.Tick;
p.Watchers.Add(targetAi);
Expand Down
6 changes: 2 additions & 4 deletions Data/Scripts/CoreSystems/Session/SessionUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ private void AiLoop()
if (!ai.ScanInProgress && Tick - ai.TargetsUpdatedTick > 100 && DbTask.IsComplete)
ai.RequestDbUpdate();

if (ai.DeadProjectiles.Count > 0)
{
foreach (var dead in ai.DeadProjectiles)
ai.LiveProjectile.Remove(dead);
if (ai.DeadProjectiles.Count > 0) {
for (int i = 0; i < ai.DeadProjectiles.Count; i++) ai.LiveProjectile.Remove(ai.DeadProjectiles[i]);
ai.DeadProjectiles.Clear();
ai.LiveProjectileTick = Tick;
}
Expand Down

0 comments on commit e7c8877

Please sign in to comment.