View Single Post
Old 08-07-12, 12:30 PM   #741
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Like I said I have code in place that has the AI crew pumping out flood water. That code was just a theory to practice to ensure the idea/code was sound. Now being of sound nature I can add the changes necessary to make it complete.

Here's my thinking: The pumps onboard the units will be able to pump equivalent to 20-30% damage (a random function will determine the % on every frame update thus giving some randomness to the pump amount). This will allow a compartment to accumulate flood water (allbeit at a lower rate than it would without pumps) until the crew fixes the damage to the compartment. The damage to the compartment is used in the formula by the game to determine amount of flood water to add to the compartment per frame update (it's actually per flood water timer update which is set at 5 seconds by the game). If the flood water level is > 65% of the compartment the crew abandons trying to pump out the water and lets the compartment flood full (sealing it off from other compartments).

The crew will try and fix the damage to the compartment every frame update. A random function will determine whether they (crew AI) successfully decreases some damage to the compartment every frame update. If they are successfull then the max the crew can repair damage per frame is 0.003%. A random number will be generated (0-1.0 in value) and multiplied by 0.003 to get the amount of damage reduced in that frame update.

These changes will allow flood water to accumulate in the compartment if damage is > 20-30% (random number). Once the crew manages to get the damage to the compartment repaired to a level that the pumps can remove the water then the flood water level will decrease in that compartment. This all together will give a nice curve of flooding versus time (starts out high and exponentially decreases over time as crew repairs damage). Say the damage to the compartment is 55% and the game calculates that the flood water level increase in that timer update is 0.17. Since the pumps can remove 20-30% of the water I'll take 0.17 * ( 1 - 20-30% random number) to get the amount of flood water to add in that timer update. Same applies to if damage is say 12%. Since 12% is < 20-30% random number then I'll take whatever the game calculates as the flood water level increase and negate it and pass it onto the function to update compartment water level thus decreasing the water level in that compartment.

Now the game keeps track of the flood water level in the compartment at all times. Thus if the water level in the compartment gets to the water level at the hull flooding stops (as it should). This gives the crew the possibility of not exceeding the 65% damage threshold before having to quit trying to remove flood water.

If you have any ideas for this please speak up. We can make this do just about whatever we want it to do

Last edited by TheDarkWraith; 08-07-12 at 12:46 PM.
TheDarkWraith is offline   Reply With Quote