Author Topic: WM's quality of life fixes (Mod) (0.814 update)  (Read 6015 times)

Offline WeaponMaster

  • Newbie Mark III
  • *
  • Posts: 46
WM's quality of life fixes (Mod) (0.814 update)
« on: February 18, 2019, 05:42:37 am »
I had this posted in the steam forum for the game, but it seems like there's very little traffic on there. Might as well cross post it to the official forums

Been building up a few quality of life fixes for myself since the latest patch. They're not huge fixes in terms of how hard it was to code, but the changes have helped me enjoy the game just a little bit more. As a side effect, learning C# on the fly while making these changes makes me appreciate the amount of work put in the game so far.

Change log (crossed out entries have been implemented into the base game/obsoleted):
  • Modified the tractor code to fix a small bug with tractor ranges. For almost all ships this makes very little difference, but before this fix the black widow golem would have a tendency to tractor ships outside of the range of its own cannons.
  • Ships traveling to wormholes no longer attempt to prevent overlapping with other ships. This is really noticeable when you tell your fleet to travel to a world three warps away, without this change your ships would end up spreading out over all three worlds due to ships back tracking to avoid overlapping with others.
  • Ships now spread out and encircle the targets they are firing at to avoid clumping. This is a change that I think is necessary to survive against AI worlds that have heavy beam guardians, those would tend to kill nearly a hundred ships with every laser they fire without this, due to clumping. This is the main reason why I was inclined to release my little changes.
  • New in 1.1 - Fixed a bug with the auto kite code, your ships should now engage at a much larger range than before, because before this change your missile frigates were walking into range of raiders to fire.
  • New in 1.1 - Snipers have been excluded from the decollision code. The exceptionally large range meant that they would constantly fail to find available points to run to, and would just waste valuable CPU time.
  • New in 1.1 - A separate method of calculating decollision points was implemented for long-er ranged ships. For these ships, instead of picking a random point around the enemy and seeing if it's close to them, they pick a random point next to them and see if its close to the enemy. Method 1 is good for forcing encirclement, method 2 is good so long range ships don't waste time traveling half way across the planet.
  • New in 1.1 - Download link to the double defences version is provided, use at your own risk.
  • New in 1.2 - Fixed a bug with engineers assisting construction (e.g. turrets, shield generators, energy generators...) consuming too much metal. They were repairing the hull and shields of the thing they we're assisting when they didn't need to
  • New in 2.0 - The code has been recompiled for patch 0.813, two of the old bug fixes have been obsoleted.
  • New in 3.0 - Movement code for sniper ships fixed. Before there was a slight element of randomness to where they move to, now they always stop in place unless attacking a unit with distance based invincibility like Tesla Turrets.
  • New in 3.0 - Because the movement of sniper ships have been normalized, the decollision code can now be applied to snipers.

There is also another change that I made for myself, but it makes the game a whole lot harder so it wasn't included (unless people ask for it) - I felt like outside of Plasma Eyes, AI worlds have very little defences and just get steamrolled. I modified the reinforcement code to allow for up to double the turrets, guardians, and fleet ships to be reinforced at planets, and made it so each of them cost half as much for the AI to build them. With this change, an Mk4 world that would be 20 strength (without an Eye) is now 40-45 strength, and Mk1-2 worlds are still only around 3-6 strength.

Install instructions:
  • Download the ZIP file
  • Extract the contents into <Your Steam Path>/AI War 2/AIWar2_Data/Managed/
  • When prompted, overwrite both files

Uninstall instructions:
  • If you have any XML mods to ships and structures, back them up somewhere
  • Navigate to your steam library in the steam client
  • Right click on AI War 2, click on properties, navigate to "Local Files", and click "Verify integrity of game files"
  • After this completes, replace any XML mods that you had installed

Download link (Version 3.0)(Normal Defences)(For game version 0.814):
http://www.mediafire.com/file/iw83t59e82k8w28/WM%2527s_Tweaks_Ver_3.0_%2528Normal_Defences%2529.zip/file

Download link (Version 3.0)(Double Defences)(For game version 0.814):
http://www.mediafire.com/file/b565xck62rwf75s/WM%2527s_Tweaks_Ver_3.0_%2528Double_Defences%2529.zip/file

If anyone has any suggestions for mechanic changes put them in this thread, I make no guarantee that I have the skills or willpower to do it.

Current bugs:

Because the engineers don't repair the shields of structures not built yet, they don't have full shields when they are finished building.

Repairing shields and hull takes twice the metal that it should (this is present in 0.813 normally).
« Last Edit: February 25, 2019, 04:35:06 pm by WeaponMaster »

Offline WeaponMaster

  • Newbie Mark III
  • *
  • Posts: 46
Re: WM's quality of life fixes (Mod)
« Reply #1 on: February 18, 2019, 05:47:49 am »
I think it might also be relevant to cross post one of the posts I made because it details a few bugs in the current C# code, and how they are fixed:

Quote

There's an issue with the movement code I think:

Code: [Select]
        if ( currentDistance  <= stopDistance )
        {
            if (!entity.PlanetFaction.Faction.UnitsAutoKite)
            {
                //Not kiting; once we are in range, stay in range
                return DelReturn.Continue;
            }
            //try to stay at the highest range
            AngleDegrees currentAngle = targetDest.GetAngleToDegrees( entity.WorldLocation );
            targetDest = targetDest.GetPointAtAngleAndDistance( currentAngle, stopDistance - currentDistance );
        }
I understand that from the comment this bit of code is supposed to make your ship move away if it ends up too close. The issue is, the target destination line is a bit messed up. Assuming:

stopDistance = 8000
currentDistance = 4000

The code should tell your unit to go back to at least 8000, but because the distance passed to the function is (stopDistance - currentDistance), it actually tells the unit to move to 4000, which its already at. If you happen to be farther than 4000 away, the code actually tells your ship to move even closer, 8000 - 5000 = 3000. Since stop distance is equal to (Range * 0.9), this means that every ship is actually fighting at 0.45x max range.


Edit: A second thing that I'm less sure of is a bug: when you are outside of the range of the enemy, the movement code tells the ship to go to 0.8x range. However, once the ship is closer than 0.9x range, it tells the ship to move back to 0.9x range. I think what is intended is move the ship to 0.9x range, then move the ship back to 0.8x range if the target gets closer than 0.8x range.

Changing this around should fix the jitters the ships would get.

Edit again: A third bug appeared after swapping those around. I thought the ships would have a "do nothing" area in between 0.9x and 0.8x, but because the code uses "if (currentDistance <= 0.8x)" and "else", this means that unless the ships are exactly at 0.8x range they run back to 0.9x range.

The checks should be: "if (currentDistance <= 0.8x)" and "if (currentDistance > 0.9x)"

https://steamcommunity.com/sharedfiles/filedetails/?id=1659416597
Success, but the ships still have minor case of the jitters due to still running the decollide code while running to their decollision point. To lazy to fix at the moment though.

Offline Draco18s

  • Resident Velociraptor
  • Core Member Mark V
  • *****
  • Posts: 4,251
Re: WM's quality of life fixes (Mod)
« Reply #2 on: February 18, 2019, 10:06:39 am »
Good stuff all around. Definitely need more folks like you willing to dig into the code.

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: WM's quality of life fixes (Mod)
« Reply #3 on: February 18, 2019, 01:21:10 pm »
If you want to upload the source code too I can potentially integrate some of your bug fixes into the game. Just the modified files would be fine.

Offline WeaponMaster

  • Newbie Mark III
  • *
  • Posts: 46
Re: WM's quality of life fixes (Mod)
« Reply #4 on: February 19, 2019, 12:06:54 am »
Here's the link to the two short term planning files where I fixed the bugs: https://www.mediafire.com/file/937etoebu5de24g/AIW2_Source_Files.zip/file

The next thing I'm going to look at that I think I have the ability to fix is about one of my Mantis reports: Engineers use too much metal. A single MK1 engineer wastes 4750 metal a second assisting construction, after a few seconds that number drops to 2750 metal, but overall the observed metal assist rate is 2000 metal (by dividing metal cost by build time, subtracting self build rate). It's very weird.

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: WM's quality of life fixes (Mod)
« Reply #5 on: February 19, 2019, 09:28:55 am »
I've incorporated your fixes for the next release. Thanks!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: WM's quality of life fixes (Mod)
« Reply #6 on: February 19, 2019, 09:56:52 am »
I've incorporated your fixes for the next release. Thanks!

Thanks for doing that, Badger!

And WeaponMaster, thanks for all you've been working on there, that's awesome stuff!!
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline WeaponMaster

  • Newbie Mark III
  • *
  • Posts: 46
Re: WM's quality of life fixes (Mod)
« Reply #7 on: February 19, 2019, 08:22:37 pm »
A few updates regarding looking into the engineer using too much metal:

  • The main issue was that the engineer was attempting to repair the hull (+1250) and shield (+1250) of the thing it was assisting in constructing.
  • When the engineer is assisting construction only, only the hull gets repaired to full. There's the illusion of the shield being repaired to full as the structure builds because the shield regenerates while the structure is still being built. I can't seem to fix this, its in the core code. Also a minor bug with the construction assist - if a very large amount of assist is applied to a structure that it builds in one simulation frame, there's a chance the structure is "fully constructed" but not at full health (this happens to me constantly when building hackers on a world with 20 engineers). I can't think of a fix that works on this end, how the core handles planned flows is a black box to me.
  • Most importantly: There's a bug in the code to repair hull, shields, and engines; each of these flows are consuming twice the amount of metal they should be consuming. I don't know exactly why this is happening because the flow cost is being set to maxPossibleFlow (aka +1250), but somehow the consumed flow is double that. This could be fixed just by dividing the repair cost by 2... but that's just a quick and dirty fix, doesn't solve the issue that there's a bug somewhere.
  • Claiming neutrals, building ships internally, and I assume drone construction are all unaffected by the double cost bug.

Well, for now at least I've fixed the bug with building structures, problem is right now people might get angry that their engineers "need to waste metal to repair the shields of turrets they just built". You win some, you lose some.

https://www.mediafire.com/file/runre17lyjzw8kk/MetalFlowPlanning.cs/file

Offline WeaponMaster

  • Newbie Mark III
  • *
  • Posts: 46
Re: WM's quality of life fixes (Mod) (0.813 update)
« Reply #8 on: February 20, 2019, 02:17:11 pm »
Another quick update on the engineers:

You can rule out the method EffectiveThroughput for class EntityMetalFlowEntry. I just added debugging for the output from that:

Code: [Select]
2/20/2019 2:04:37 PM Calculating metal flow for unit, Engineer, flow #SelfConstruction, with max flow rate of 49.9267578125
2/20/2019 2:04:37 PM Calculating metal flow for unit, Engineer, flow #ClaimingNeutrals, with max flow rate of 49.9267578125
2/20/2019 2:04:37 PM Calculating metal flow for unit, Engineer, flow #RepairingHullsOfFriendlies, with max flow rate of 99.853515625
2/20/2019 2:04:37 PM Calculating metal flow for unit, Engineer, flow #RepairingShieldsOfFriendlies, with max flow rate of 99.853515625
2/20/2019 2:04:37 PM Calculating metal flow for unit, Engineer, flow #RepairingEnginesOfFriendlies, with max flow rate of 99.853515625
2/20/2019 2:04:37 PM Calculating metal flow for unit, Engineer, flow #AssistConstruction, with max flow rate of 74.89013671875

My thoughts is that when you assign the flows for hull and shield in this bit of code:

Code: [Select]
plannedFlow.Recipients.Add( DelegateHelper_MetalFlowPlanning_bestTarget );
plannedFlow.RequestedFlow += repairCost;
DelegateHelper_MetalFlowPlanning_bestTarget.FramePlan_ExpectedRepairs += repairExpected;
DelegateHelper_MetalFlowPlanning_bestTarget.FramePlan_ExpectAssistanceFromThese.Add( plannedFlow );

I think that plannedFlow.RequestedFlow += repairCost and DelegateHelper_MetalFlowPlanning_bestTarget.FramePlan_ExpectAssistanceFromThese.Add( plannedFlow ) are both subtracting metal from your total, and so the cost is doubled.

Offline WeaponMaster

  • Newbie Mark III
  • *
  • Posts: 46
Re: WM's quality of life fixes (Mod) (0.813 update)
« Reply #9 on: February 21, 2019, 09:19:11 pm »
I'm going to mercy kill the double defences mod. Just had 2 games in a row with only level 7 AIs, where at 50 AIP I was somehow getting 70 strength waves. Looking at the pause menu, the budgets readout showed that the AI had spent 4.5 million points on attacking/defending.

Literally couldn't even get 1 hop outside my planet because there was a 100 strength warden fleet. No clue what happened in between 0.812 and 0.813, but it seems like there's exponential scaling now.

Offline RocketAssistedPuffin

  • Arcen Volunteer
  • Sr. Member
  • *****
  • Posts: 260
Re: WM's quality of life fixes (Mod) (0.813 update)
« Reply #10 on: February 22, 2019, 07:16:32 am »
It was the change to fixing Carriers weird display it seems. Turns out that a bunch of the AI stuff relies on that value...

I'll go and fix it...dang it.
Autistic, so apologies for any communication difficulties!

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: WM's quality of life fixes (Mod) (0.814 update)
« Reply #11 on: February 26, 2019, 12:54:21 pm »
Can you run past me again what the bug with engineers is? I am unconconvinced there's any problem with the engineers-assisting-construction code. In the XML it defines build throughput for a spacedock to be 2K and the throughput for engineers to be 750. When I'm building with 2 engineers helping my throughput is 3500, which is exactly what I would expect.

I also don't see anything wrong with the repairing of damaged units code. I have two engineers repairing a badly damaged Ark (both shield and hull damage). I see a total spending throughput of 4K, which is right. I have 1K hull + 1K shield repair on two engineers for a total of 4K. The hull and shield repair numbers are just what I would expect from the XML:
    <metal_flow purpose="RepairingHullsOfFriendlies" throughput="1000" increase_per_mark_level="500"/>^M                                                                                                                                                                                                               
    <metal_flow purpose="RepairingShieldsOfFriendlies" throughput="1000" increase_per_mark_level="500"/>^M                                                                                                                                                                                                             


Edit: Having read the comments above more clearly, I think I figured out that the problem was actually with engineers helping to build new structures; they were giving "building assist" money and "shield repair" money instead of just "Building assist" money. I have fixed this loophole. Is there anything else you know of to be broken in this area?
« Last Edit: February 26, 2019, 01:29:28 pm by BadgerBadger »

Offline WeaponMaster

  • Newbie Mark III
  • *
  • Posts: 46
Re: WM's quality of life fixes (Mod) (0.814 update)
« Reply #12 on: February 26, 2019, 02:18:39 pm »
I somehow had a critical reading error when saying that hull and shield repairs cost double of what they should, that issue doesn't actually exist it seems. (I was reading "Assist's Construction for 750", and then noticing that healing used 1500, when it says right on the tooltip that engineers heal for 1500...)

There is still an oddity when it comes to assisting the construction of ships: It seems like when a ship like a hacker finishes building, the HP gets set back to what it was on the previous (simulation?) frame. I have a recording of 20 engineers assisting the construction of a few hackers - each time the hacker finishes building, the HP drops back down to 10-30% and it needs to be repaired again. It's generally hard to notice in game, but if you are constructing a whole lot of hackers/science labs at once its possible they get built and go through a wormhole before they're completely repaired.

https://www.mediafire.com/file/mvt3564w5941uvq/AIWar2_2019-02-26_14-10-04.mp4/file

Also - constructing things doesn't heal their shield, this is a slight issue when building forcefields that makes them cost about 1.5x of normal cost because you need to repair the shield after they're built.

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: WM's quality of life fixes (Mod) (0.814 update)
« Reply #13 on: February 26, 2019, 02:37:08 pm »
Okay, I'll investigate the 20 engineers at a time can cause issues at some point later. Could you open a mantis ticket so we don't lose track of the problem?

Offline Draco18s

  • Resident Velociraptor
  • Core Member Mark V
  • *****
  • Posts: 4,251
Re: WM's quality of life fixes (Mod) (0.814 update)
« Reply #14 on: February 26, 2019, 10:59:44 pm »
Query: shields regenerate on their own (and, I assume, consume no metal to do this). Why then do they require metal to be aided?

(I think I've also seen some weirdness where engineers will assist in construction, the building's shields will rapidly fill to full, but construction won't actually be done, and the engineers will fly off and do something else)

 

SMF spam blocked by CleanTalk