View Issue Details

IDProjectCategoryLast Update
0023118AI War 2[All Projects] SuggestionMay 20, 2020 1:11 pm
ReporterStarKeepAssigned To 
Severityminor 
Status closedResolutionfixed 
Product Version2.021 Hotfix 
Fixed in Version2.045 Scientific Emergence 
Summary0023118: Melee Logic Tweak
DescriptionMelee still have a problem in regards to failing to hit moving targets. Here is a potential suggestion to alleviate that.

Old -
bool setMoveToEnemy = true;

int kiteDistance = -1;
for ( int i = 0; i < entity.Systems.Count; i++ )
{
    EntitySystem system = entity.Systems[i];
    if ( system.DataForMark.CalculateActualRange( system.ParentEntity ) >= 124000 ) //Range of Artillery Golem
    {
        setMoveToEnemy = false;
        kiteDistance = system.GetKitingDistance( targetEnemyEntity );
        break;
    }
    if ( !system.GetCanHitAssumingItIsEnemy( targetEnemyEntity, true ) )
        continue;
    if ( kiteDistance < 0 )
    {
        kiteDistance = system.GetKitingDistance( targetEnemyEntity );
    }
    else
        kiteDistance = Math.Min( kiteDistance, system.GetKitingDistance( targetEnemyEntity ) );
}
Regular Chasing & Kiting Logic...

New -
bool setMoveToEnemy = true;
bool isMelee = false;
int kiteDistance = -1;
for ( int i = 0; i < entity.Systems.Count; i++ )
{
    EntitySystem system = entity.Systems[i];
    int range = system.DataForMark.CalculateActualRange( system.ParentEntity );
    if ( system.TypeData.IsMelee ) //Melee
    {
        isMelee = true;
        break;
    }
    else if ( range >= 124000 ) //Range of Artillery Golem
    {
        setMoveToEnemy = false;
        kiteDistance = system.GetKitingDistance( targetEnemyEntity );
        break;
    }
    if ( !system.GetCanHitAssumingItIsEnemy( targetEnemyEntity, true ) )
        continue;
    if ( kiteDistance < 0 )
    {
        kiteDistance = system.GetKitingDistance( targetEnemyEntity );
    }
    else
        kiteDistance = Math.Min( kiteDistance, system.GetKitingDistance( targetEnemyEntity ) );
}

// If melee, always try to move into melee range.
if ( isMelee )
{
    if ( targetEnemyEntity.FramePlan_Move_NextMovePoint != ArcenPoint.ZeroZeroPoint )
        targetDest = targetEnemyEntity.FramePlan_Move_NextMovePoint;
    else
        targetDest = targetEnemyEntity.WorldLocation;
} else {
    Regular Chasing/Kiting Logic...
}
TagsNo tags attached.

Activities

BadgerBadger

Apr 8, 2020 2:44 pm

manager   ~0056754

So this
     if ( targetEnemyEntity.FramePlan_Move_NextMovePoint != ArcenPoint.ZeroZeroPoint )
        targetDest = targetEnemyEntity.FramePlan_Move_NextMovePoint;

is a potential source of races, but it's not clear that it will cause problems.

You have source access though. Have you tested this?

StarKeep

Apr 8, 2020 3:08 pm

reporter   ~0056757

Yes sir; it has caused melee to correctly hit targets moving away from themselves, and has not caused any hanging or performance degradation as far as I can tell.

Didn't want to push it to source without prior approval considering its a sim change. Any minor errors there could cause a cascading effect.

StarKeep

Apr 8, 2020 3:23 pm

reporter   ~0056759

Update - Swapped the range check for an isMelee check due to things like cloaking triggering it with their range of 0.

Old-
if ( range <= 300 ) //Melee
New-
if ( system.TypeData.IsMelee ) //Melee

BadgerBadger

Apr 8, 2020 4:18 pm

manager   ~0056761

I doubt chris is going to push to steam, so I'd say go ahead and check it in and we'll see.

If you want to be paranoid, gate the logic behind a Setting

StarKeep

Apr 8, 2020 5:00 pm

reporter   ~0056763

Pushed in behind a setting; thanks for the suggestion Badger.

Scout1Treia

Apr 10, 2020 11:15 pm

reporter   ~0056784

First of all - great stuff. This new logic seems to be working flawlessly.

That said, I'm not sure you've committed it correctly. I see that steamdb reports depot changes, wiki says this was introduced in 2.023 and the ingame behavior has certainly changed (much to the better!)... but the settings toggle option is missing. I would assume that the merged logic is now on by default instead of being available as an option.

Just in case: Main menu reports 2.024, checked *all* settings menus both in and out of proper gameplay, and checked galaxy settings in a newly generated game in case it only showed up there. It's MIA on all of them. No settings toggle.

StarKeep

Apr 10, 2020 11:44 pm

reporter   ~0056785

So it turns out that I forgot a field that allows the setting to show mid-save. It will correctly show in the lobby; but no longer appear after the game has started. Whoops. Will nudge that in for the next update.

BadgerBadger

May 20, 2020 1:11 pm

manager   ~0057065

This seems to be fixed now, by starkelp

Issue History

Date Modified Username Field Change
Apr 8, 2020 2:18 pm StarKeep New Issue
Apr 8, 2020 2:44 pm BadgerBadger Note Added: 0056754
Apr 8, 2020 3:08 pm StarKeep Note Added: 0056757
Apr 8, 2020 3:23 pm StarKeep Description Updated View Revisions
Apr 8, 2020 3:23 pm StarKeep Note Added: 0056759
Apr 8, 2020 4:18 pm BadgerBadger Note Added: 0056761
Apr 8, 2020 5:00 pm StarKeep Note Added: 0056763
Apr 10, 2020 11:15 pm Scout1Treia Note Added: 0056784
Apr 10, 2020 11:44 pm StarKeep Note Added: 0056785
May 20, 2020 1:11 pm BadgerBadger Status new => closed
May 20, 2020 1:11 pm BadgerBadger Resolution open => fixed
May 20, 2020 1:11 pm BadgerBadger Fixed in Version => 2.045 Scientific Emergence
May 20, 2020 1:11 pm BadgerBadger Note Added: 0057065