This object is in archive! 

Turrets shoot ghost targets

Mikhail Yevchenko shared this bug 3 years ago
Solved

Turrets often start shooting nonexisting targets, wasting ammo indefinitely. Or not shoot missiles, when there are missiles flying.


That's how to reproduce: https://www.youtube.com/watch?v=yabgroA_OzI&feature=youtu.be


Here's the script, that fixes the problem with shooting ghost targets:

List<TurretWatchdog> Watchdogs;
IEnumerator<TurretWatchdog> WatchdogEnumerator = null;

Program()
{
    List<IMyLargeTurretBase> Turrets = new List<IMyLargeTurretBase>();
    GridTerminalSystem.GetBlocksOfType<IMyLargeTurretBase>(Turrets);

    Watchdogs = Turrets.Select(t => new TurretWatchdog(t)).ToList();

    if (Watchdogs.Any())
        Runtime.UpdateFrequency = UpdateFrequency.Update1;
    else
        Echo("No turrets found");
}

class TurretWatchdog
{

    IMyLargeTurretBase Turret;

    MyDetectedEntityInfo PreviousEntity;

    public TurretWatchdog(IMyLargeTurretBase turret)
    {
        Turret = turret;
        PreviousEntity = turret.GetTargetedEntity();
    }

    public void Check()
    {
        var entity = Turret.GetTargetedEntity();

        if (entity.TimeStamp == PreviousEntity.TimeStamp)
            return;

        if (entity.BoundingBox == PreviousEntity.BoundingBox && entity.Velocity == PreviousEntity.Velocity && !Vector3D.IsZero(entity.Velocity))
        {
            var idleRotation = Turret.EnableIdleRotation;
            Turret.ResetTargetingToDefault();
            Turret.EnableIdleRotation = idleRotation;
        }

        PreviousEntity = entity;
    }
}

void Main()
{
    if (WatchdogEnumerator == null || !WatchdogEnumerator.MoveNext())
    {
        WatchdogEnumerator = Watchdogs.GetEnumerator();
        WatchdogEnumerator.MoveNext();
    }

    WatchdogEnumerator.Current.Check();
}

Replies (2)

photo
1

Hello, Mikhail,

thanks for reaching us with you issue. However, when I tested it, everything was working fine. Turrets are firing to the missiles fired from not-my faction rocket launcher when "Target Missiles" is turned on. They are obviously not firing to the missiles that were fired from rocket launcher that belongs to me/my faction.

Can I ask where you played it? In single player Empty world? Or some other game mode? Online/Offline?

Can I please have the BP you are using on the video to check you settings of rocker launcher and turrets and try to fiddle around with it on my own? That would be great help!

Even on the video, it seems like the turrets are firing on the rocket. But not all of them... is that what you think? If I understand it correctly, you want ALL the turrets to fire on single missile fired from the rocket launcher at the same time?

Thanks in advance for more info (if you can provide any) and providing the BP.

Kind Regards

Keen Software House: QA Department

photo
1

I don't remember exact settings I used when I made that record. But I can make one more: https://youtu.be/GgZ3DqkODiQ . World and blueprint attached.

It happens both online and offline. Very often.

I think that each turret should pick it's target rather than idling, regardless of other turreting status state. And yes, when there is only one missile fired - all turrets must shoot. Why take chances, when it's not guaranteed that singe turret is enough to stop one missile?

photo
1

By chance, I removed all videos from youtube. So I uploaded a new one here: https://drive.google.com/file/d/1SWwL_acbOwXD2-NhQpUbROCQDVla-3Cs/view?usp=sharing

photo
1

Is there any additional information you need?

photo
3

Hello, Mikhail,

no :) No more info needed. The issue is well described and reproducible as it is now.

I successfully reproduced it and put it into our internal system.

Kind Regards

Keen Software House: QA Department

photo
1

Hello, Engineer!

The fix for this is in v200

Thank you.

Kind Regards,

Keen Software House: QA Department

Replies have been locked on this page!