[BTS] M.A.D Nukes Mod

macsbug

Chieftain
Joined
Oct 31, 2005
Messages
75
[BTS] M.A.D Nukes Mod
Compatibility and SDK update by MacsBug

Kudos to TheLopez on his great mod: http://forums.civfanatics.com/showthread.php?t=168858

Download
Version: 0.06b (BETA)
Compatibility: BTS v3.02
MP Compatibility: Unknown
Download: http://forums.civfanatics.com/downloads.php?do=file&id=6792

Version: 0.07b (BETA)
Compatibility: BTS v3.13
MP Compatibility: Unknown
Download: http://forums.civfanatics.com/downloads.php?do=file&id=7483

Installation Instructions
1) Unzip MAD Nukes Mod.zip into <bts_install_folder>\Mods\

Change log:
Spoiler :
---v0.07b---
-Updated to BTS v3.13

---v0.06b---
CvPlayer.cpp
-Modified void CvPlayer::handleMADNukeExplosion(PlayerTypes ePlayer, int iRange, int iX, int iY) to fix a possible stack overflow error

CvUnitAI.cpp
-Modified CvPlayer* CvUnitAI::AI_MADGetBestPlayer() to correctly skip any players the AI may not declare war on (ex: Vassal states)
-Modified CvPlayer* CvUnitAI::AI_MADGetBestCity(CvPlayer *pCity) to correctly skip cities it may not nuke.

CvUnit.h/CvUnit.cpp
-Added the protected function bool canMADNukeAt(CvPlot* pPlot)
-Modified CvUnit::nuke to use canMADNukeAt
-Modified CvUnit::doTurn to invalidate the mad target plot appropriately
-Modified canStartMADTargetMissionAt(int iX, int iY) to appropriately return false for invalid targets

CvMADNukesManager.py
-Fixed a minor bug that occurred when attempting to display an outgoing nuke pre-targeting a non-city plot

Bug Fixes:
-Pre-targeting a nuke (both AI and Player) now requires that the player be able to declare war on the target. This, unfortunately, prevents Vassal states from pre-targeting nukes.
-iAirRange is now checked prior to pre-targeting a nuke
-Pre-targeted nukes should now never fail to launch properly when triggered by an enemy launch


---v0.05b---
-Bugfix: All variables should now be saved/loaded properly
-Bugfix: The &#8220;LAUNCH!&#8221; command should now work properly in multi-player
-Feature Addition: Runtime modification of the Enable MAD Nukes Mod flag should now work properly.
-Feature Addition: Threat counts by civilization now displayed in the NUCLEAR THREAT SUMMARY section of the INCOMING WARHEADS screen
-Feature Addition: Threat counts by civilization by city (selected cities only) now displayed in the NUCLEAR THREAT SUMMARY section of the INCOMING WARHEADS screen
-Feature Addition: Nukes should now be able to properly pre-target any plot
-Feature Addition: Nukes should now be able to properly pre-target from any plot

-Note: This version is not compatible with previous version&#8217;s saved game files

-Note: Specific list of SDK and Python changes are not be included in this change log, as the list is too extensive. Any future SDK and Python changes will note changes made from this version&#8217;s source files.


---v0.04b---
CvPlot.h/CvPlot.cpp
-Modified void CvPlot::read() to comply with variable changes (see below)
-Modified void CvPlot::write() to comply with variable changes (see below)
-Modified void CvPlot::reset() to comply with variable changes (see below)
-Added the function int CvPlot::getNumMADIncomingWarheads()
-Added the function int CvPlot::getNumMADOutgoingWarheads()
-Added the function CvUnit* CvPlot::getMADIncomingWarhead(int iIndex)
-Added the function CvUnit* CvPlot::getMADOutgoingWarhead(int iIndex)
-Added the function void CvPlot::addMADIncoming(int iUnitID, PlayerTypes ePlayer)
-Added the function void CvPlot::addMADOutgoing(int iUnitID, PlayerTypes ePlayer)
-Added the function void CvPlot::removeMADIncoming(int iUnitID, PlayerTypes ePlayer)
-Added the function void CvPlot::removeMADOutgoing(int iUnitID, PlayerTypes ePlayer)
-Added the protected variable m_aMADNukesOutgoing
-Added the protected variable m_aMADNukesIncoming
-Removed the function void CvPlot::changeMADIncoming(int iValue)
-Removed the function void CvPlot::changeMADOutgoing(int iValue)
-Removed the protected variable m_iMADIncoming
-Removed the protected variable m_iMADOutgoing

CyPlot.h/CyPlot.cpp
-Added the function int CyPlot::getNumMADIncomingWarheads()
-Added the function int CyPlot::getNumMADOutgoingWarheads()
-Added the function CyUnit* CyPlot::getMADIncomingWarhead(int iIndex)
-Added the function CyUnit* CyPlot::getMADOutgoingWarhead(int iIndex)

CyPlotInterface1.cpp
-Exposed the function int CyPlot::getNumMADIncomingWarheads() to Python
-Exposed the function int CyPlot::getNumMADOutgoingWarheads() to Python
-Exposed the function CyUnit* CyPlot::getMADIncomingWarhead(int iIndex) to Python
-Exposed the function CyUnit* CyPlot::getMADOutgoingWarhead(int iIndex) to Python

CvUnit.cpp
-Modified changeMADTargetPlot to comply with CvPlot changes
-Minor bug fix in CvUnit::kill that would occasionally fail to remove a MAD unit from the owner's MAD unit list.

CvPlayer.cpp
-Minor conformity change

CvMADNukesManager.py
-Modified updateMinimap to display incoming warhead locations

Game play changes:
The &#8220;OUTGOING WARHEADS&#8221; section of the &#8220;MAD WARHEAD MANAGER&#8221; will now display the locations of the warheads targeting the selected cities.
Note: This version is not compatible with previous version&#8217;s saved game files


---v0.03b---
CvMADNukesManager.py
-(BUGFIX) modified drawOutgoingWarheadsContent to use getMADUnit to retrieve its initial list of units. All pre-targeted nukes should now be properly displayed in the OUTGOING WARHEADS section.

CvPlayer.h
-Minor conformance change

CyPlayer.h/CyPlayer.cpp
-Added the function CyUnit* CyPlayer::getMADUnit(int iIndex)
-Added the function int CyPlayer::getNumMADUnits()
-Added the function int CyPlayer::getMADOutgoingAt(PlayerTypes ePlayer)

CyPlayerInterface1.cpp
-Exposed the function CyUnit* CyPlayer::getMADUnit(int iIndex) to Python
-Exposed the function int CyPlayer::getNumMADUnits() to Python
-Exposed the function int CyPlayer::getMADOutgoingAt(PlayerTypes ePlayer) to Python


---v0.02b---
CvMADNukesManager.py
-Added a &#8220;LAUNCH!&#8221; button next to the &#8220;INCOMING WARHEADS&#8221; button
-Added code to launch all selected nuclear missiles when &#8220;LAUNCH!&#8221; is selected
-Corrected a minor bug that checked for UNIT_ICBM rather than checking isMADNuke to generate a list of valid MAD nukes

CvUnit.h/CvUnit.cpp
-Added the function bool CvUnit::launchMADNuke()

CyUnit.h/CyUnit.cpp
-Added the function bool CyUnit::launchMADNuke()

CyUnitInterface1.cpp
-Exposed the function bool CyUnit::launchMADNuke() to Python

Game play changes:
Pressing &#8220;MAD NUKES MANAGER&#8221; window has an additional button, &#8220;LAUNCH!&#8221; If this window is currently displaying the OUTGOING WARHEADS window and a number of warheads are selected, pressing this button will cause all selected warheads to launch.


---v0.01b---
- First release


Known bugs:
Spoiler :
- Vassal states and other diplomatic conditions preventing war ignored for the purposes of launching a MAD nuke [FIXED - v0.06b]

- iAirRange ignored for MAD nukes except when Safe Nukes Mode is set to "1" [FIXED - v0.06b]

- Pre-targeted nukes sometimes fail to launch properly when triggered by an enemy launch [FIXED - v0.06b]

- "LAUNCH!" command not multiplayer compatable (kudos Jeckel) [FIXED - v0.05b]

- Saved games do not load properly [FIXED - v0.05b]

- Some ICBMs fail to appear on the MAD WARHEAD MANAGER after pre-targeting the unit (kudos doronron) [FIXED - v0.03b]


Planned features:
Spoiler :
- Add an espionage check prior to displaying the locations of the warheads targeting the selected cities in the INCOMING WARHEADS screen. (scraped)


Credits and Thanks:

- TheLopez for initial idea and coding for Warlords

- doronron for allowing me to bounce ideas off him and implementation suggestions
 
Note to mod makers:
All modified SDK code begins with &#8220;// < M.A.D Nukes Start >&#8221; and ends with &#8220;// < M.A.D Nukes End >&#8221;. When it was necessary to replace existing SDK code the original code was included at the end of the modified code as such:

// < M.A.D Nukes Start >
(New code here)
//(Original code here)
// < M.A.D Nukes End >

New XML Tags:
Spoiler :
CIV4UnitInfos.xml:
bMADNuke

CIV4BuildingInfos.xml:
bEnablesMADStrategicCommand


Python Commands:
Spoiler :
--- CyPlot---
int getMADIncoming()
int CyPlot::getMADOutgoing()
int CyPlot::getNumMADIncomingWarheads()
int CyPlot::getNumMADOutgoingWarheads()
CyUnit* CyPlot::getMADIncomingWarhead(int iIndex)
CyUnit* CyPlot::getMADOutgoingWarhead(int iIndex)

--- CyUnit---
bool isMADNuke()
bool isMADTargetSet()
CyPlot* getMADTargetPlot()
int getMADTargetPlotX()
int getMADTargetPlotY()
PlayerTypes getMADTargetPlotOwner()

---CyPlayer---
int getMADOutgoingAt(PlayerTypes ePlayer)
int getNumMADUnits()
CyUnit* getMADUnit(int iIndex)
int getMADIncoming()
int getMADOutgoing()
bool isMADStrategicCommandEnabled()
void setMADStrategicCommandEnabled()
bool toggleMADStrategicCommandEnabled()

---CyGame---
bool isMADEnabled()
void setMADEnabled()
bool toggleMADEnabled()
int isMADSafeNukesEnabled()
void setMADSafeNukesEnabled()


MAD Nukes Mod Config.ini Changes
Spoiler :
Removed Enable Nuclear Warhead Pretargetting
Added Enable MAD Nukes Mod
Added Safe Nukes Mode



Significant gameplay changes from TheLopez&#8217;s M.A.D Nukes Mod:
Nuclear explosions:
Spoiler :
TheLopez&#8217;s M.A.D Nukes Mod:
ICBM&#8217;s detonate instantly after selecting &#8220;Nuke&#8221; (no change from Vanilla)

Currently:
When &#8220;Nuke&#8221; is selected the ICBM is first launched and then detonated. The &#8220;launch&#8221; portion occours instantly and the ICBM is destroyed. The &#8220;detonation&#8221; portion, however, occurs at the end of the target player&#8217;s turn.


Triggering M.A.D:
Spoiler :
TheLopez&#8217;s M.A.D Nukes Mod:
When an ICBM is launched the target player&#8217;s &#8220;trigger&#8221; flag is set. At the beginning of the target player&#8217;s turn all ICBMs targeting the aggressor&#8217;s cities are launched.

Currently:
When an ICBM is launched the all of the target player&#8217;s ICBM&#8217;s currently targeting the aggressor&#8217;s cities are immediately launched.


ICBM AI:
Spoiler :
TheLopez&#8217;s M.A.D Nukes Mod:
The target city is selected randomly from all valid cities.

Currently:
The target player is selected first based on who has the most nukes targeting the AI relative to how many nukes the AI has targeting them, then by who the AI has the worst attitude towards. The target city is then selected from the target player&#8217;s cities in the order the AI would nuke cities under Vanilla. One nuke is set to target every one of the target player&#8217;s cities before targeting a second nuke at any city and so on.


Other:
Spoiler :
A toggle has been added to enable/disable the mod and a toggle has been added to modify how the mod functions when launching an ICBM would draw additional players into a war. More documentation to follow.
 
Very, very cool, man. Given the differences in the original code and the BtS c++ files, seeing this released so quickly is amazing.
 
Updated to version 0.02b (minor bug-fix and "LAUNCH!" command, see change log).
 
Updated to v0.03b (python bug-fix and minor SDK update).

EDIT: v0.03 was released with the Debug DLL. Fixed and uploaded a new file under the same version name.
 
Updated to version 0.04b (minor bug fix and feature implementation, see change log).

Please note: v0.04b is not compatible with the saved-game files of previous versions.
 
Nice job macsbug, this was a good component and is nice to have in BtS. :cool:

And I see in the OP that you have MP compatability listed as Unknown. To let you know, the mod was MP compatable in TheLopez's Warlords version and SDK changes wouldn't break that, but the launch button you added in the MAD manager screen will cause OOS errors.

For screens to do things other then display data and still work in MP you have to add a custom event handler. For examples of this take a look at the Great Statesman mod by TheLopez or the Final Frontier mod that shipped with BtS, they both use custom event handlers to keep screen actions MP compatable. :)
 
Nice job macsbug, this was a good component and is nice to have in BtS. :cool:

And I see in the OP that you have MP compatability listed as Unknown. To let you know, the mod was MP compatable in TheLopez's Warlords version and SDK changes wouldn't break that, but the launch button you added in the MAD manager screen will cause OOS errors.

For screens to do things other then display data and still work in MP you have to add a custom event handler. For examples of this take a look at the Great Statesman mod by TheLopez or the Final Frontier mod that shipped with BtS, they both use custom event handlers to keep screen actions MP compatable. :)

Thanks, I'll look into that :)

Are there any tutorials you could point me to, by any chance, regarding MP compatibility? I currently have absolutely no idea what will and will not cause an OOS error in multiplayer.
 
Yea, Gerikes wrote a tutorial about MP compatability and what causes OOS errors. Check threads started by him or look through some of the back pages of the tutorial section. It doesn't get into accually making mods MP compatable, but it does give alot of good data about what does and doesn't cause OOS.

Basicly it comes down to what triggers the code. If it is some built in trigger like an event in the event manager or a hook in the gameutils file then it won't cause OOS, but if its a screen that the player is clicking on to trigger the code then that is only set off on the computer that just clicked the button and won't run on the other computers unless you write it that way.

Now, in BtS, you have the new event onModNetMessage, or something like that, and using it I think you can send and catch data that will be passed to all computers, but I havn't used it myself. I think they used it in some of the BtS mods that came with the expantion.

Good luck, MP compability takes some extra work, but its worth it in the end. :)
 
Yea, Gerikes wrote a tutorial about MP compatability and what causes OOS errors. Check threads started by him or look through some of the back pages of the tutorial section. It doesn't get into accually making mods MP compatable, but it does give alot of good data about what does and doesn't cause OOS.

Found it, thank you :)

Basicly it comes down to what triggers the code. If it is some built in trigger like an event in the event manager or a hook in the gameutils file then it won't cause OOS, but if its a screen that the player is clicking on to trigger the code then that is only set off on the computer that just clicked the button and won't run on the other computers unless you write it that way.

Now, in BtS, you have the new event onModNetMessage, or something like that, and using it I think you can send and catch data that will be passed to all computers, but I havn't used it myself. I think they used it in some of the BtS mods that came with the expantion.

Good luck, MP compability takes some extra work, but its worth it in the end. :)

I noticed that while searching through the Final Frontier mod (thanks again for pointing me to that one). I stuck a quick and dirty implementation of this into the python files and it appears to properly allow the "LAUNCH!" command to be used in multiplayer (tested in a two player direct-ip game). It will be included in the next update.

On a related note: A rather nasty bug slipped into this mod as of the initial release that will prevent the game from properly loading CvPlayer's MAD unit list. Any ICBMs that existed when the game was saved will no longer show up on the OUTGOING WARHEADS screen. Re-targeting the ICBMs will not correct this problem. This bug has been fixed and will be in the next update.
 
Updated to version 0.05b (major bug fix and feature implementation, see change log).

Please note: v0.05b is not compatible with the saved-game files of previous versions.
 
As far as I can tell, aside from a few differences to help organize simultaneous launches in a turn based environment, this works pretty much like TheLopez's original component.
 
I hope you're not making this too feature intensive so it stays easy to incorporate. Right now I'm holding back on adding this to my mod 'cause it looks like it's still developing rather rapidly.

That's probably not a bad idea - I wouldn't recommend anyone add this to their mod until this is at least out of beta.

I've tried to maintain encapsulation of the mod within new functions wherever possible, so (at least for the SDK) it should be at least as easy to incorporate as TheLopez's original.
 
Wow, this looks like a bigger version of a small mod I wanted to make!

I think I'd love to run your mod... but I was also wondering. How could I mod the ICBM's so they just torch all the people and improvements where they land? As stanrdard, they destroy a few things, and will never kill units outright. I'd like to have affected units die, I'd like to have affected die. Maybe even make the fallout zones a little larger.

Can you help me do this? Thanks!
 
Wow, this looks like a bigger version of a small mod I wanted to make!

I think I'd love to run your mod... but I was also wondering. How could I mod the ICBM's so they just torch all the people and improvements where they land? As stanrdard, they destroy a few things, and will never kill units outright. I'd like to have affected units die, I'd like to have affected die. Maybe even make the fallout zones a little larger.

Can you help me do this? Thanks!

Take a look at the handleNukeDetonation and devistatePlot functions in CvMADNukesEventManager.py, those two functions are fairly well commented and should get you started. If you're trying to implement this as a separate mod then I recommend you read this post:

http://forums.civfanatics.com/showthread.php?t=237948

As for the fallout zones, the range that fallout will be scattered across is defined in the XML files. Take a look at UNIT_ICBM in CIV4UnitInfos under the tag "iNukeRange".
 
Top Bottom