Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental City Repair #1141 #1188

Merged
merged 10 commits into from Jan 28, 2024
Merged

Incremental City Repair #1141 #1188

merged 10 commits into from Jan 28, 2024

Conversation

kgd192
Copy link
Contributor

@kgd192 kgd192 commented Apr 20, 2023

This is the initial Entry Point for the Incremental Repair of the Cityscape as mentioned in issue #1141 going from fixing als Blocks of a Building at once per night, it will now only repair one single level per night (as per UFOPaedia) to create some sort of incremental repair effect.
Next Step will be to research the repair strategy used by the OG Game and implement it step by step plus add. further improvements as mentioned by @FilmBoy84 in #1141

@kgd192 kgd192 mentioned this pull request Apr 20, 2023
@kgd192
Copy link
Contributor Author

kgd192 commented Apr 22, 2023

Added Option to repair Buildings depending on the availability of construction Vehicles as mentioned by @FilmBoy84 in #1141. This is added as a new OpenApoc feature in the option being disabled by default.
When starting the reconstruction the organization is looking for own vehicles that are available for building repair at first. If there are none then it will look for available vehicles by other organizations as long as their relationship is friendly or allied. currently one Vehicle can repair up to 20 Tiles per Night.
Below are some screenshots which show the effect of the option in the City.

Prior to any repair
priorRepair

With Option Enabled to only repair when vehicles are available
repair_w_vehicles

With the option disabled, but still only repairing one level per night
repair_wo_vehicles

@FilmBoy84
Copy link
Collaborator

Just merged #1217 which in changing options creates a conflict with this PR
You'll probably need to rebase

@FilmBoy84 FilmBoy84 marked this pull request as ready for review November 26, 2023 12:39
@kgd192
Copy link
Contributor Author

kgd192 commented Jan 1, 2024

Rebase has been completed and Pull Request is ready to merge. I just wanted to reiterate that no research has been done yet how the OG handles Building Repairs, this is just my interpretation :D

@FilmBoy84
Copy link
Collaborator

FilmBoy84 commented Jan 1, 2024

Greatly appreciated KGD 🍻

Quickmind and I should be testing over next few days and will let you know if we find anything - if all seems okay, we'll get it merged

The last part of #1141 will need some extensive reversing of the OG to work out how building of each tile is costed and any other costs for building repair - and that will be best suited for a future PR anyway

The main thing is getting city repair working again and for that I'm extremely grateful for your work

@Quickmind01
Copy link

One thing I will say is I tested using the repair debug command, and the building I tested could not be entered with a craft after the repair occurred. Interestingly enough, when the craft started off in the destroyed tiles, it would exit once the repair occurred and couldn't go back in. So, at least in the current build, debug repair solidifies the building.

@FilmBoy84
Copy link
Collaborator

@Quickmind01 So the repair function repaired the building, but the vehicle was then blocked from entry? Interesting if that's the case - suggests that whilst the building is treated as solid, it doesn't flag the building as accessible again - did it become accessible after end of day? I wonder if it gets flagged as accessible then as it's not normal for repairs to occur in the same day something attempts to go back in

@FilmBoy84
Copy link
Collaborator

FilmBoy84 commented Jan 2, 2024

After Night 1 of repairs, the building did construct some "floating" structures
image
save_Night 1 Building Repair.zip

EDIT: And a save before Night 1 (made on a different run to the above to confirm the issue)
save_Pre Night 1 Building Repair.zip

@FilmBoy84
Copy link
Collaborator

FilmBoy84 commented Jan 2, 2024

One thing I will say is I tested using the repair debug command, and the building I tested could not be entered with a craft after the repair occurred. Interestingly enough, when the craft started off in the destroyed tiles, it would exit once the repair occurred and couldn't go back in. So, at least in the current build, debug repair solidifies the building.

I have managed to replicate this - saves attached

CoS buildng was COLLAPSED with Ctrl-Alt-Shift-R.Click
I then destroyed the hangars with Ctrl-Alt-Shift-L.Click along with a few ground tiles

Running the game forward from the Night 1 save the building repairs - including the hangars/landing pads
(Note i have added the warning about destroyed landing pads to #666 when loading this save)

But i am unable to get the Hawk to enter the building in the second save

Additionally, many vehicles will attempt to enter the building as the day goes on and fail - causing MASSIVE slow down in ultra speed

It does appear there is an issue with both landing pads AND garages not being flagged as accessible when repaired

saves.zip

EDIT: I have tested on a new game, this time with construction vehicle lead repair, and even when i destroy pads/hangars/garages i can use them again from the next day. This issue therefore may only affect "level based repair" or it may be map specific - further testing needed

@Quickmind01
Copy link

Quickmind01 commented Jan 2, 2024

I believe I may have been unclear in what I tested. Here are two screenshots of what I meant.
image
image

I didn't try to get parked in the building. I was referring to the building itself being solid with the repair debug.

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 2, 2024

@Quickmind01 @FilmBoy84 Thanks for all the input so far, just keep them coming especially with the save files attached and I will have a look at the issues over the weekend 👌

@Quickmind01
Copy link

I played OG for a bit and took down some Osirion buildings and also put the Government in debt. Here is a picture of one day where I leveled Osiron and the next. Very little was rebuilt.
OG Repair Between Days

During my test, Osirion seemed to be able to build more when the Government had money, but the Government didn't lose money, either. It also cost Osirion $30K a day to do their repairs. Now, when I leveled a Government building so that they had to do repairs as well, Osirion's costs went down. So, it appears there is a maximum amount of reconstruction that can be done per day, and the costs are proportionate to that. The Government seemed to spend a ridiculous amount more to repair which didn't make sense. Gov. seemed to spend ~$160K a day to repair, and it didn't seem to speed things up, so I'm not sure why there was a cost difference.

I also did some raiding of Osirion. Being in debt did not appear to affect their numbers nor their equipment. They continued to have numerous agents with disruptor and devastator tech, shields, cloaks, and missile launchers (MARSEC heavy). I'm thinking money and accounts in OG have little to do with the game outside of the Government being able to fund X-COM.

@FilmBoy84
Copy link
Collaborator

Thanks for checking @Quickmind01 costs will have to most likely be a separate PR

As to why government pays more - they cover all the "infrastructure" costs like roads into buildings, people tubes between them and other terrain types damaged during the building's destruction, whereas only the tiles related to the building and it's immediate grounds are paid for by the organisations.

Thus, when a building is damaged and needs repairing both government AND the parent organisation end up paying toward it

As said in my list of things to check on discord - we need some extensive reversing of the OG before costs can be worked out

Otherwise, apart from the issues above, this PR seems really stable - im happy to merge pending those fixes unless anything else crops up - just having some mechanism to repair at present is very welcome

@Quickmind01
Copy link

I forgot to mention that OA appears to have buildings repair random chunks/levels. I did a real brief test prior to my OG testing, and the building wasn't rebuilding from the ground up. There was a level nearly missing completely between one level below and one above. I think I recall someone mentioning this was a known issue, but I wanted to confirm that it still exists.

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 5, 2024

After Night 1 of repairs, the building did construct some "floating" structures image

Currently trying to figure out why the floating structures are happening, no luck so far, will keep you posted over the weekend 👌

@FilmBoy84
Copy link
Collaborator

Much appreciated KGD - never any pressure from us, we're just grateful for the work

I note that it is most prominent on buildings that have "rubble" or other tiles most commonly associated with the ground as part of the structure - for example, slums do this

So maybe therein lies a clue?

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 5, 2024

I note that it is most prominent on buildings that have "rubble" or other tiles most commonly associated with the ground as part of the structure - for example, slums do this

So maybe therein lies a clue?

Great, I will definitely go down that road then, and also having a closer look into the tiles supporting other tiles relationships since that is a major part of how to sort in which order to repair them

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 7, 2024

Reworked the Repair Code, it will now only allow Scenery to be repaired which has a valid support below it or does not need any support at all. This also leads now to correctly only reconstructing one level per night.

@FilmBoy84 @Quickmind01 Please go ahead and try your best 😉

@FilmBoy84
Copy link
Collaborator

Many thanks for the update.

I have had a play and for single level per night repair it appears really solid!

image

It does appear however that construction vehicle lead repair has been broken - regardless of construction vehicles, each building still repairs one level per night rather than the RNG up to 20 tiles per vehicle per night

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 10, 2024

It does appear however that construction vehicle lead repair has been broken - regardless of construction vehicles, each building still repairs one level per night rather than the RNG up to 20 tiles per vehicle per night

Copy, I will have a look at that 👍

@FilmBoy84
Copy link
Collaborator

FilmBoy84 commented Jan 12, 2024

It does appear however that construction vehicle lead repair has been broken - regardless of construction vehicles, each building still repairs one level per night rather than the RNG up to 20 tiles per vehicle per night

Copy, I will have a look at that 👍

Many thanks

Here's a video of me messing around with the build, mods and Debug today :)
https://youtu.be/pFeQ21mgns4

It's REALLY stable, even handled me putting a vehicle inside a tile that got repaired well

Just the Construction Vehicle thing that seems to be outstanding - I do wonder if we should have a user set min/max RNG value for the amount per vehicle per night though - 20 seemed too high on the previous build before it broke and if there's a lot of vehicles whole buildings were restored quickly - so being able to set the min/max per vehicle would be useful

I propose a default of 1-5 tiles per night, per vehicle, extendable up to the 1-99 range by user preference....

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 12, 2024

Perfect I will watch the Video tonight and then get to fixing the Construction Vehicles.

Great Idea to have lower that value und make it adjustable. @FilmBoy84 Where do you reccon this option schould be locacted, should it remain in the more options menu?

@FilmBoy84
Copy link
Collaborator

I'd say it definitely needs to stay in the more options menu under the cityscape list

Though I can see issues with the form and entry of min/max values - so maybe they'd be better just being held in OpenApoc_settings.conf (which can also be added to the launcher in the future)

It's a difficult one, if you can find a way to put under the more options list - do that as then end users can alter things in one place

But equally, with forms being problematic, don't stress too much if you have to move to placing the values in the config and referencing under a tab in the Launcher

As to the video, it's mainly just me rambling ha ha ha, nothing other than a record of how i was testing this build

Had a weird error relating to crashing UFOs and a self-inflicted slowing of the game with too many battlescape explosions but they are unrelated to this - most useful thing is probably the log on the left :)

@FilmBoy84
Copy link
Collaborator

FilmBoy84 commented Jan 16, 2024

Had an excellent time testing this today as seen here:

https://youtu.be/PUdhelIbMNA

For most things, this PR appears to work perfectly - though there is an issue with Roads and how they repair - crashing vehicles as they do not appear to register as "repaired" tiles once damaged

I attach the savegames (tested under 20240104-8 with the mods included in the file for your /data/mods/ folder) and you can see what was happening when in the video

20240116_saves.zip

EDIT: Whilst i can see the reference under the ATV option in the code
The options controlling repair rate per vehicle do not appear on the screen
Will try to add it via the config file in next test
image

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 16, 2024

@FilmBoy84 Nice work, will have a look at the road/vehicle issue tomorrow. As of now the MaxTiles should be in the config file as MaxTileRepair with a default value of 5. Also had discussion w/ @Quickmind01 who also did an extensive Test Stream and his feeling is that with a Setting of 5 Repair seemed to be da tad Slow. One thing I would like to change is, that orgs will only help each other out w/ their Vehicles after all of their own tiles are repaired. Secondly the Orgs are billed the initial Cost of the Tile when Repaired, that is something which was already in the Code before my addition which I keep. I would suggest adding a Modifier for the Repair Cost in the config as well so tweaking/balancing/disableing can easily be done without needing to recompile the Code. Low Funds of the Organisations could also lead to the feeling of slow Repair @Quickmind01 had.

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 17, 2024

All of the mentioned changes in the last comment have been made.

  • Mark Road as Repaired for Pathfinding
  • Construction Vehicles will only repair allied Tiles after all of their Parent Orgs Tiles have been repaired
  • RepairCostFactor introduced in OpenApoc_settings.conf w/ a default value of 1.0f

@FilmBoy84 only thing "missing" would be to make these two options (i.e. Cost Factor & Max Tiles per Vehicle) tweakable within the more options menu. Couldn't figure out an elegant solution so far.

@FilmBoy84
Copy link
Collaborator

Brilliant, thank's KGD - i'll aim to do another test video tomorrow

Regarding the cost structure - where is it calling the values per tile from? I can't see

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 17, 2024

@FilmBoy84

// pay
buildingOwner->balance -=
initialType->value * config().getFloat("OpenApoc.Mod.SceneryRepairCostFactor");

From where exactly the data is taken from and if it is having any effect at the Moment I would need to investigate further

@FilmBoy84
Copy link
Collaborator

FilmBoy84 commented Jan 18, 2024

Had another great test today - it's looking really good with no major issues detected

The three minor things before i can merge are as follows however (pending anything from @Quickmind01 )

  • The Debug Function to repair one level with Shift-R now repairs two levels for some reason
  • The options for MaxTileRepair and SceneryRepairCostFactor are not specified in OpenApoc_settings.conf under the [OpenApoc.Mod] header and with their default values - the user has to add them manually. The appropriate strings should be generated the first time the game makes or modifies the file. (Usually following a fresh install or having changed settings in game)
  • The SceneryRepairCostFactor at a default of 1.0 is WAAAAAY too low; i wonder if we should specify a value of 10 (still far too low but better) as the default

Otherwise, as you will see from this video - i tried to break things in a lot of ways but was pleasantly surprised by how stable this PR is - great work @kgd192 ! It's a real game-changer, especially with me being able to bankrupt Diablo with damage to the point that they can no longer repair buildings! I also love that Debug did not allow repair when this occured so it was easy to identify the financial impact was effective.

https://youtu.be/ZNgjotBETfI

Let me know if you need the saves i made :)

@kgd192
Copy link
Contributor Author

kgd192 commented Jan 18, 2024

Great I will look at those things.

  • I suspect the Debug Repair now Repairing two Levels is how the "repair own tiles before helping out" is handled, it basicaly runs through the whole Repair Loop twice.
  • I wondered about that too since I expected the game to create the lines in the config file, i have to investigate why that is not happening
  • Agree for the Cost Balancing, repairing 10 Tiles cost like 40$

Debug Repair via SHIFT+R now again correctly repairs a single Level and adjusted the default value of the cost modifier to 10.0f. Additionaly the CostModifier and Max Tile Repair will be saved to conf file after first Night
@kgd192
Copy link
Contributor Author

kgd192 commented Jan 24, 2024

@FilmBoy84 All Issues as mentioned above by you have been fixed so far. Unfortunately I couldn't find a clean way to get the two Options into the .config file, so now they will be in there after the first night or debug repair. To really fix this these values probably need to be in the More Options Menu, and I couldn't figure out how to get them in there cleanly, maybe this is something for @Kurtsley. The Workaround code have the options reliably in the config file is listed below and needs to be reworked once a UI solution for adjusting them exists.
The CostModifier has been adjusted to a default value of 10.0 by now.

// Work Around to Save Cost Modifier and max Tile Repair to .conf File w/o user Input to enable
// Manual Editing
// TODO: Remove this once These Settings are available in the more Options Menu
config().set("OpenApoc.Mod.SceneryRepairCostFactor",
config().getFloat("OpenApoc.Mod.SceneryRepairCostFactor"));
config().set("OpenApoc.Mod.MaxTileRepair", config().getInt("OpenApoc.Mod.MaxTileRepair"));

@FilmBoy84
Copy link
Collaborator

FilmBoy84 commented Jan 28, 2024

Have done a test of this today
It works brilliantly

I shall open a Issue referencing this PR for the UI issue - at present getting the repairs in game resolves a number of issues with things like crashing road vehicles and some instances of vehicles getting stuck

Thanks for your work on getting this into the game KGD192 <3

Final Testing Video
https://youtu.be/EEGr-Vfckn8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants