just finished up the mega patch for AI crew damage control. Wow, that was a lot of code. More than I thought it would take
There are some memory variables that can be adjusted (and will need to be tweaked through more testing) in order for this to be working 100% correct. The end user will be able to adjust these memory variables (have to add this functionality to generic patcher yet).
Here's how it's working:
Zone (Box) damage:
every frame update a function is called to check/update zone(box) damage:
- check to see if allowed to repair damage on this zone (box)
- if not allowed then return
- if allowed:
- if zone (box) damage is 0 then it returns
- if zone (box) has damage then:
- get current damage %
- compare current damage % to memory variable (max % damage crew allowed to repair damage - currently set to 0.7)
- if current damage greater then return
- if current damage not greater then:
- get a random number (0-1.0)
- compare random number to memory variable (% chance crew repairs some damage - currently 0.6)
- if random number is greater then return
- if random number less:
- get flooding level %
- compare flooding level % to memory variable (max % flood level in order to make repairs - currently 0.65)
- if flooding level % greater then return
- if flooding level % not greater then:
- get a random number (0-1.0)
- multiply random number by memory variable (max % damage repaired per hour - 10% currently)
- multiply result by conversion factor ( 1/ 3600 ) to get % damage repair / second
- multiply result by frame render time
- save new damage value to memory
Zone (Box) flooding:
if zone (box) has a floatability value then every frame update call a function to check/update flooding amount to add to zone (box):
- check to see if allowed to remove flood water from this zone (box)
- if not allowed then return
- if allowed:
- get a random number (0-1.0)
- compare random number to memory variable (% chance crew removes some flood water - currently 0.7)
- if random number greater then return
- if random number not greater then:
- get a random number (0-1.0)
- multiply random number by memory variable (max % decrease in flood water / hour - currently 0.1)
- multiply result by memory variable (conversion factor - 1 / 3600 - converts to max % decrease in flood water per second)
- multiply result by memory variable (second conversion factor - 250 - used to tweak the flood water removal)
- multiply result by frame render time
- save result to memory
All these memory variables are defined in the patch file and can be adjusted by user.
We will need to tweak these values. Lots of testing needs to be done with this

The end result is amazing though...watching a listing ship correct it's list due to removing flood water.
There are certain zones that are allowed to repair/remove flood water. These zones are defined in the patch file also. We can add/remove from the list as needed.
The following zone numbers are defined:
5-7
9-11
38-40
45-48
69-71
83-88
105-112
114-115
136
148
150
154-160
162-168
170-171
174-177
181
183-191
You can find these numbers in \data\Zones.cfg
By defining these zones it prevents items from being repaired that shouldn't be repaired (i.e. keel, airplane zones, etc.)
I should have this available tomorrow
There is one thing I haven't been able to do yet: remove the effects from a zone when it's damage is less than the effects setpoint. I just haven't been able to find how these effects are generated yet.