The Mine Warfare Mod

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
Mine Warfare 2.0

Download: http://forums.civfanatics.com/downloads.php?do=file&id=14620

Version History:

2.0 Released on 24 Dec 2011

1. Converted 6 units down to just 2. Mine fields and nuclear mines are now special promotions.

2. For your convenience, the zip file includes BUG4, Better BTS AI and Mine Warfare version 2.

3. Huge Python changes to improve performance and conditions. However...

4. Testing of this stand alone mod has proven my theory to be true. Although Mine Warfare ver 2 is a much improved version over version 1, the game performance becomes really slow in the late game. This is due to checking the movement of every unit to see if there is a mine on the plot. The more units you have, the slower the game becomes. It is really slow on a huge map. Therefore, after careful consideration, I have come to the conclusion that Mine Warfare must migrate to SDK. I will require help to make this happen, as I have limited SDK skills. Still, I will release the mod for others to consider.

1.0 Released on 7 April 2010

1.1 Forcasted Release Date 1 Oct 2010

Ideas being looked at for inclusion:

Spoiler :

1. Interim fix file (Already available). What it does: Added line of code to insure a mine is armed before it is allowed to blow up.

2. Add the Mine Hunter unit for both land and sea.

3. Make Mine Hunter available with the Mine Warfare Tech

4. Mine Hunters can remove individual mines only (not Mine Fields or Nuclear Mines)

5. Mine Hunters will upgrade to Mine Sweepers, which can take out any mine type.

6. Make Mine Sweepers available with Industrialism

7. Fix the hover message for land mines

8. Need code change to focus on a mine explosion, when a mine detonates.



-----------------------------------------------------------------------------------

Mod Summary:

This mod introduces Mine Warfare to Civ4. Remember how much fun mines were in Civ3. Well, this mod is better. 6 different mines and 2 mine Sweepers make their debut in the Mine Warfare mod. Here are the attributes:

New Tech: Mine Warfare: Allows the construction of mines. Mine Warfare is a link from Gunpowder.

New Wonder: The Advanced Mine Technology Center: This new National Wonder becomes available with the discovery of Physics and the advance technology, learned in this facility, is now an additional prerequisite for constructing the most powerful mine in the game: The Nuclear Mine. It also enhances production by lowering the cost of both Mines and Mine Fields by 50%. The wonder also increases the effective power of Mines and Mine Fields against armored units to allow the Anti-Tank capability. The Wonder has a movie file that demonstrates the awesome destructive power of a mine with the sinking of a ship.

Sea Units:

1. Naval Mines: All Naval Mines are invisible to all units and have a hidden nationality. Naval mines are produced in coastal cities and will remain harmless until they are armed. Once they are armed, they no longer can move and the can be lethal. All Naval mines can be removed by a Naval Mine Sweeper. There will be 3 types of naval mines:

a. Naval Mine: Available with Mine Warfare tech and can be built in any coastal city that has a harbor. This mine has 5 movement points and is harmless until armed. Once armed it becomes immobile. After the Naval Mine is armed, it will attack and totally destroy or damage only one ship on a plot. The Naval Mine is used up, when it explodes. The color is black.

b. Naval Mine Field: This Mine is available with the tech Industrialism and requires a harbor and a factory to produce. This mine has 5 movement points and is harmless until armed. Once armed it becomes immobile. After the Naval Mine Field is armed, it will attack all ships on a plot. It has a high percentage randum chance of destroying any and perhaps all ships that move into it's plot and will remain persistant, requiring a Mine Sweeper to remove it. Any wooden ship that hits this mine has a 100% chance of getting sunk. Because of the destructive capability of this mine, the cost is twice that of a Battleship. The color is red.

c. Nuclear Naval Mine: This Mine is available with the tech Fussion and requires a harbor, a factory and the Advanced Mine Technology Center National Wonder to produce. This mine has 5 movement points and is harmless until armed. Once armed it becomes immobile. After the Nuclear Naval Mine is armed, it will remain dormant until a nuclear explosion is triggered manually by the owner of the mine. This makes the nuclear mine unique from the other two mines, which automatically explode. The nuclear detonation will destroy every ship on the plot. The Nuclear Naval Mine is used up, when it is detonated. The color is green.

2. Naval Mine Sweeper: This ship is available with the Mine Warfare tech. It is the only unit that can detect and remove enemy naval mines. Detection of a mine will sound off the alert. This activates the mine removal button. Removing a mine uses up one movement point for the ship.


Land Units:

1. Land Mines: All Land Mines are invisible to all units and have a hidden nationality. Land mines can be produced in any city and will remain harmless until they are armed. Once they are armed, they no longer can move and they can be lethal. All land mines can be removed by a Land Mine Sweeper. Want to stop enemy spies? Land Mines placed at the border will destroy these menacing infultraitors. There will be 3 types of land mines:

a. Land Mine: Available with Mine Warfare tech. This mine has 6 movement points and is harmless until armed. Once armed it becomes immobile. After the Land Mine is armed it will attack and totally destroy or damage only one unit on a plot. The Land Mine is used up, when it explodes. The color is black.

b. Land Mine Field: This Mine is available with the Industrialism tech and requires a factory to produce. This mine has 6 movement points and is harmless until armed. Once armed it becomes immobile. After the Land Mine Field is armed, it will attack all units on a plot. It has a high percentage randum chance of destroying any and perhaps all units that move into it's plot and will remain persistant, requiring a Land Mine Sweeper to remove it. Any pre gunpowder units that that hit this mine have a 100% chance of getting blown up. Because of the destructive capability of this mine, the cost is twice that of a Battleship, but not quite twice the cost of a tactical nuke. The color is red.

c. Nuclear Land Mine: This Mine is available with the tech Fussion and reqires a factory and the Advanced Mine Technology Center National Wonder to produce. This mine has 6 movement points and is harmless until armed. Once armed it becomes immobile. After the Nuclear Mine is armed, it will remain dormant until a nuclear explosion is triggered manually by the owner of the mine. This makes the Nuclear Land Mine unique from the other two mines, which automatically explode. The nuclear detonation will destroy every unit on the plot. The Nuclear Land Mine is used up, when it is detonated. The color is green.

2. Land Mine Sweeper: This unit is available with the Mine Warfare tech. It is the only unit that can detect and remove enemy land mines. Detection of a mine will sound off the alert. This activates the mine removal button. Removing a land mine uses up one movement point for the unit.


Note: The chance of being blown up by a mine field is as follows:


ANCIENT ships or units -- 100% chance

CLASSICAL ships or units -- 100% chance

MEDIEVAL ships or units -- 100% chance

RENAISSANCE Ships or units -- 75% chance

INDUSTRIAL Ships or units -- 50% chance

MODERN Ships or units -- 25% chance

FUTURE Ships or units -- 5% chance

Release date: 7 April 2010

Special Thanks to EmperorFool, God-Emporer, Afforess and The J for help resolving tough python and XML issues.

Orion Veteran :cool:
 

Attachments

  • MineWarfare.JPG
    MineWarfare.JPG
    34.9 KB · Views: 922
  • Adv Tech Center.JPG
    Adv Tech Center.JPG
    120.5 KB · Views: 833
  • Deployed Naval Mines.JPG
    Deployed Naval Mines.JPG
    76.1 KB · Views: 1,234
  • Land Mine Field.JPG
    Land Mine Field.JPG
    143.3 KB · Views: 884
  • Land Mine Sweeper.JPG
    Land Mine Sweeper.JPG
    138.5 KB · Views: 774
  • Land Mine.JPG
    Land Mine.JPG
    137.8 KB · Views: 726
  • Naval Mine Field.JPG
    Naval Mine Field.JPG
    138.8 KB · Views: 655
  • Naval Mine Sweeper.JPG
    Naval Mine Sweeper.JPG
    134.5 KB · Views: 696
  • Naval Mine.JPG
    Naval Mine.JPG
    134.9 KB · Views: 696
  • Nuclear Naval Mine.JPG
    Nuclear Naval Mine.JPG
    138.9 KB · Views: 695
can the AI handle it? is it coded in python? definitly sound interesting....

I know this will be the number one question. The answer will be revealed in testing, when the mod is complete. If not, we will teach the AI with Python, as I will do what ever it takes to make this mod work.
 
Mabye you could have anti infantry mines, and anti-tank mines (i.e. 50% vs armour):spear:

Remember mines are lethal.

Land mines do not discriminate. They will take out one unit no matter what it is.

Land Mine Fields are the same except they get a randum chance for taking out each unit on a plot. The greater the era for the unit, the less chance it will be destroyed. I posted the percentages on the 1st post.

Nuclear Land Mines take out every unit on a plot - period. It's total devastation.
 
Mabye you could have anti infantry mines, and anti-tank mines (i.e. 50% vs armour):spear:

Agree mines always being deadly could be unrealistic esp. against armoured units but if the AI will use them it will be crazy fun. Trench type warfire with the AI has always been missing in the civ series.
 
Definitely interesting. I'm suspecting I could even merge a toned-down verison of this for WoL!
 
I suspect that on the AI front the news is just about all bad.

A problem that you will run into is that there is no land unit AI that will carry another unit, so the AI won't load and deploy the land mines. (This is also a problem for land units carrying missiles or air units like fighters - the AI doesn't do it. Final Frontier and all derivative mods have this problem. The AI won't ever load missiles onto its cruisers or squadrons onto carriers or starbases since all of the terrain is actually land.) There is some slight chance that giving the land mine laying unit a sea type unit AI (like UNITAI_MISSILE_CARRIER_SEA) will work, but I expect that it would only build that unit in coastal cities if it ever builds one (I have tried this with the cruiser units in Final Frontier and it stops building them entirely since there is no water, even though the unit has the land domain and the bCanMoveAllTerrain option has been set). The land/sea roles are, for this purpose, too strictly defined.

It should be able to load the sea mines, but I don't know if it will ever drop them off anywhere. If it does, it probably won't be in very good locations (although randomly located mines could still do a lot of damage).

It is also likely that it will never sweep mines (until the AI is told to, probably in the DLL) since that is a new feature it knows nothing about. This is the standard problem with new actions: you have to make the AI use them.
 
I suspect that on the AI front the news is just about all bad.

A problem that you will run into is that there is no land unit AI that will carry another unit, so the AI won't load and deploy the land mines. (This is also a problem for land units carrying missiles or air units like fighters - the AI doesn't do it. Final Frontier and all derivative mods have this problem. The AI won't ever load missiles onto its cruisers or squadrons onto carriers or starbases since all of the terrain is actually land.) There is some slight chance that giving the land mine laying unit a sea type unit AI (like UNITAI_MISSILE_CARRIER_SEA) will work, but I expect that it would only build that unit in coastal cities if it ever builds one (I have tried this with the cruiser units in Final Frontier and it stops building them entirely since there is no water, even though the unit has the land domain and the bCanMoveAllTerrain option has been set). The land/sea roles are, for this purpose, too strictly defined.

It should be able to load the sea mines, but I don't know if it will ever drop them off anywhere. If it does, it probably won't be in very good locations (although randomly located mines could still do a lot of damage).

It is also likely that it will never sweep mines (until the AI is told to, probably in the DLL) since that is a new feature it knows nothing about. This is the standard problem with new actions: you have to make the AI use them.

Then I will do my best to write python code to make the AI deploy and use mines. I will enlist the best minds to tackle this problem, becuse this mod is worth the effort.
 
I have a possible solution. Perhaps I can eliminate mine layers altogether. I can create an inactive mine that can move, say up to 3 spaces. Then when the mine reaches it's destination, I can create an action button to activate or arm the mine and make it unmoveable. There it will remain until it detonates or is removed by a mine sweeper. This concept avoids the sticky issue of teaching the AI how to load and transport mines using mine layers. The mine will transport itself and it will not be armed to explode until after it is activated in it's permanent position. Once activated, there is no way to reverse it, short of disbanding the mine.

What do you think?
 
That sounds good OV. For the AI I would almost just make it so that after a couple turns it just automatically becomes immobile (again AI only). Maybe give it UNIT_AI EXPLORE and not enough time to get far and it'll just leave the mines all around the edges of its borders ;)
 
After thinking about it a little...

It is probably possible to do a basic mine layer AI in Python via the AI_unitUpdate callback in CvGameUtils.

Something like:
1) If the current player is not a human then check to see if we should override the regular AI.
2) Check the unit type to see if it is a mine layer.
a) If the unit is a mine layer, is it carrying a mine?
b) If empty, go to a port city saving the destination plot index somewhere - if already at that destination it should just sit there until it has a full load of mines at which time it should clear the existing destination.
c) If not empty check to see if the unit has a destination set.
d) If a destination is set and it is already there, then drop off a mine.
e) If a destination is not set then look for a "good place" (however you want to rate the plots) to put a mine and set the unit to move there, saving the destination plot index somewhere.
3) If the unit isn't a mine layer, is it a mine?
a) If it is a mine and the current location is a city then check for a mine layer that is not full on the same plot.
b) If there is a mine layer here that has room, force this mine to be loaded onto the mine layer. (This step should cause the AI to load things onto land units.)

This is pretty hand-wavy and leaves a lot out, like how to rate plots for their "good place to put a mine" factor, but the overall concept should be OK (assuming nothing else important was left out). This also does not account for escort ships for the mine layer, or the mine layer being part of a fleet - as-is it will result in them operating alone.

An example of this sort of thing can be found in Final Frontier. It does something like this for the construction ship AI for building starbases.
 
After thinking about it a little...

It is probably possible to do a basic mine layer AI in Python via the AI_unitUpdate callback in CvGameUtils.

Something like:
1) If the current player is not a human then check to see if we should override the regular AI.
2) Check the unit type to see if it is a mine layer.
a) If the unit is a mine layer, is it carrying a mine?
b) If empty, go to a port city saving the destination plot index somewhere - if already at that destination it should just sit there until it has a full load of mines at which time it should clear the existing destination.
c) If not empty check to see if the unit has a destination set.
d) If a destination is set and it is already there, then drop off a mine.
e) If a destination is not set then look for a "good place" (however you want to rate the plots) to put a mine and set the unit to move there, saving the destination plot index somewhere.
3) If the unit isn't a mine layer, is it a mine?
a) If it is a mine and the current location is a city then check for a mine layer that is not full on the same plot.
b) If there is a mine layer here that has room, force this mine to be loaded onto the mine layer. (This step should cause the AI to load things onto land units.)

This is pretty hand-wavy and leaves a lot out, like how to rate plots for their "good place to put a mine" factor, but the overall concept should be OK (assuming nothing else important was left out). This also does not account for escort ships for the mine layer, or the mine layer being part of a fleet - as-is it will result in them operating alone.

An example of this sort of thing can be found in Final Frontier. It does something like this for the construction ship AI for building starbases.

I think the key is how you might rate the plots to determine a "good place" put the mine. Can you expand on this and perhaps provide some example code?
 
Given that this would be a very special purpose AI, eliminating all the normal combat related stuff and, as presented, probably not even checking for danger from enemy units before moving (the path finding and regular movement related stuff might take this into account, I suppose), I would suggest that a basic rating system could try to have it lay mines near resources within its own cultural borders, near its cities (port cities, for sea mines), and (perhaps the hardest, and perhaps mostly relevant for land mines) along borders with other civs. There are other good places, such as bottlenecks between two land masses or passes through peaks, that are harder to locate - I'd suggest leaving them out of the first version.

The way the rating system for starbase locations in Final Frontier (findBestResourcePlot in CvAI.py) works is purely based on resources and distance from capital and a tiny bonus if the location is in an asteroid field for the defensive bonus - what location would get the starbase the most resources, and closer is better. As you might imagine this loops over every plot and then, if the plot is revealed to this player/team, loops over all plots within the range of the territory claiming effect of the starabase (a 5x5 area, also checking if they have been revealed) to see if they have a resource. If every plot is revealed then this will actually check every plot on the map 25 times. This sort of thing is expensive, in terms of time, to do in Python. It could probably be made to be more efficient at the cost of using more memory.

Sadly, any rating system is likely to need to do something similar. Loop over every plot on the map and evaluate it based on some criteria. For sea mines it might be possible to use something fairly simple if the AI is going to just use them defensively in its own territory. You may be able to speed it up by doing a single pass over the map to make some lists to be used later. For sea mines perhaps a list of all ocean plots in the AI's territory, a list of all improved ocean resources in its territory, and a list of all of its coastal cities. You could then loop over that first list and check for things that are in the other two lists and assign values. This may, or may not, speed up the rating system. The easier method would be to just keep checking the map with no such lists like FF's starbase rating system and it might be better to start with that, testing the other method later to see if it speeds things up if this is slowing the turn processing down too much.

As for the rating system itself, perhaps a good starting place for defensive sea mines would be something like: -10 if there is already a mine in the plot (or skipping the plot entirely if you can't, or don't want to, put more than 1 per plot), +10 if an improved resource is in the plot, +5 for each improved resource in an adjacent plot, +1 for each one that is 2 plots away, +5 if a port city is 1 to 3 plots away, and a random factor from 0 to 6. Or something like that - it's easy to make up stuff like this. It would require experimentation to determine if any specific rating system is doing the sort of thing you want.

The rating system depends on some factors - like if mines can destroy your own ships, or if they can be placed on top of fishing boats working a tile and if the detonation will destroy the improvement. The above "+10 if a resource is in the plot" assumes that mines don't explode for its own ships and a fishing boats improvement on the tile isn't wiped out if it explodes. If mines have any chance at detonating for its owner's ships then you'd want a negative factor in the rating for each mine already in an adjacent plot so as to leave paths for your own ships, and you probably wouldn't want to put mines immediately adjacent to your own cities or on top of resources.
 
I just finished testing the nuclear mine using the dual unit solution.

1. I moved an unarmed nuclear mine to the plot where I wanted it.
2. Then I clicked on the arm naval mine button to arm the nuclear mine (now it can no longer move). Yippee!
3. After arming the nuclear mine the detonation button appeared.
4. I detonated the nuclear mine which blewup every ship on the plot. (I used World builder to put the ships there for the test)
5. The mushroom cloud looks great.

It is hilarious! I like it! ...good explosive fun!

With the dual unit solution working, all the mine layer units will be removed from the mod.

Now all I have to do is make all the same changes for the land mines, put the mod through more testing (AI rating system, etc.) and release it.
 
I see many mushroom clouds in your future.

If you set it off in a coast tile, does it spread fallout over some of the adjacent land tiles?
 
A tip for open borders: you need to somehow make open borders exclude mines, or else you could place a nuke mine in the opponents cities and voila: you win the war.
 
Back
Top Bottom