MongooseSDK 3.3 Beyond the Sword 3.1.9 + Better BTS AI 0.78 (minus AIAutoPlay and ChangePlayer) This is the SDK code from my full mod (which is not publically available at the moment). I am providing it mainly for modders, though it can be used as a standalone mod if you add <iBombardLimit> values to all siege units and <iInterceptLethality> values to all air units (and turn Python errors off, heh). If you use anything from here you NEED to give me credit. ... Seriously. Don't try my patience again. Download: http://forums.civfanatics.com/downloads.php?do=file&id=5984 Old Thread: http://forums.civfanatics.com/showthread.php?t=175766 (had to start a new one as I didn't have extra top posts reserved) GENERAL FIXES FloodPlainsFix (UPDATED) (CvCity.cpp) If a city is built on a flood plain, the tile will remain a flood plain rather than becoming a desert. This removes the penalty for building on such rivers instead of near them (effectively -1 food), and preserves the tile if the city on it is ever razed and replaced with a new city nearby (which would otherwise be stuck with a desert in its working radius). This component also covers the mushroom feature in my mod, since the types have to be hardcoded unless I ever add an XML tag. CastleBypassFix (CvPlayer.cpp) Allows buildings to still be constructed after they go obsolete if they provide a defense bonus and thus still serve a purpose. This only affects Castles currently, and restores their old behavior before they got a bonus trade route that forced a tech expiration. Don't worry, they still do nothing but provide more physical defense if you build them in this manner (ie everything about them that should obsolete still does). GreatPersonFix (NEW) (CvCity.cpp, CvCity.h, CyCity.cpp, CyCity.h, CyCityInterface1.cpp, CvGameTextMgr.cpp) Applies floating point precision to great people points, preventing truncation errors (which could result in a great person taking several turns longer to finish than he should) and allowing overflow points to be calculated correctly when starting a new great person. (Note: the progress bar in the city view will display gibberish without the code in my CvMainInterface.py file which I'm not providing here, but the bar's mouseover popup will be fine since that's handled by the SDK.) Fixes a significant bug with the application of the Parthenon/Pacifist/etc effect which frequently led to incorrect results. BarbarianPassiveTechFix (NEW) (CvTeam.cpp) Fixes a minor bug where the barbs were counting themselves (and any other barbarian players for that matter) in the list of other civs for determining passive tech accumulation rate, making it slightly slower than whatever value the XML global indicates. Also adds an enforced minimum of one research per turn if any other civs have the tech, which is probably not necessary but was missing nonetheless. AITargetCityValueFix (NEW) (CvPlayerAI.cpp, CvCity.cpp, CvCity.h) Fixes the AI's calculation of the value of potential target cities: obsolete world wonders are no longer considered under any circumstances (before they were given full weight if at least one active world wonder was present, and ignored otherwise), and multi-holy-cities now count extra as appropriate (before they were valued the same as single-holy-cities). Also greatly increases the weight values for these things, which were set negligibly small. MPRandomFix (NEW) (CvGame.cpp) Currently has no effect. If I ever figure out how to restore locked random seeds to network multiplayer games, however, this will allow the New Random Seed option to function in such games. UNIT FIXES TransportUpgradeFix (CvUnit.cpp) Kicks carried units to the nearest valid tile if you upgrade a transport into something with different cargo capability (less capacity, no capacity, or carries different types of units now). CargoLoadFix (NEW) (CvUnit.cpp) Fixes an annoying but harmless vanilla bug where the Load button still appears for a unit already being carried by a transport (though hitting it does nothing). Prevents land units with the ability to enter water, generally helicopters, from automatically becoming cargo when entering a tile occupied by a friendly transport; these units must now be loaded manually (which saves a lot of annoyance, believe me). COMBAT FIXES SurfaceCombatFix (UPDATED) (CvUnit.cpp, CvUnit.h, CvUnitAI.cpp, CvGameCoreUtils.cpp, CvGameCoreUtils.h, CvGameTextMgr.cpp) Applies floating point precision to the damage calculation portion of the main combat engine (doesn't affect collateral or air strikes), and the corresponding odds generator. The difference is small and doesn't usually change fight outcomes, but for an example take a 2-vs-1 fight such as a promotionless warrior attacking a wolf: in vanilla the odds are 99.1%, and with this fix they are 98.0% (a more accurate and correct number). Makes a small code improvement to an internal odds calculator only used by AI players to determine courses of action. The fix involves an integer division not being postponed til all multiplications in the same line are done as SDK code usually does, and may or may not have a very small effect on gameplay (it's hard to test). Makes a change that could be considered a mod and not a fix, but I threw it in here anyway since it affects surface combat and is hard, imo, to object to: if two defending units have exactly the same defense strength for a fight (and either both are Great-General'd or neither are), it will now pick the lower-experience one instead of the higher-experience one to take the fight. This has two advantages: since promotions get further apart the higher you go it helps get more promotions faster; and if the defender loses the fight, the player loses a lower-experience unit which is always preferrable. Displays combat odds of 0.0% and 100.0% at their actual values rather than capping their display at 0.1% and 99.9%. I don't care if it's misleading b/c it's still technically possible to win a 0% or lose a 100%; giving the player more information is never a bad thing. CargoInterceptFix (UPDATED) (CvUnit.cpp) Formerly known as the InterceptDomainBlockingFix. I discovered that what I thought was broken -- ranged land units like SAM Batteries not being able to intercept adjacent water tiles and ranged water units like Missile Cruisers not being able to intercept adjacent land tiles -- was working fine all along (way to let me know this guys, you only had 3 years to notice lol). However there is a different bug with the exact same code, which this now fixes: units being carried as cargo could still perform intercepts if the unit transporting them was in a city or a neutral or friendly fort, and units with <bCanMoveAllTerrain> set (generally helicopters) that were being carried as cargo could still perform intercepts anywhere. PromotionRefundFix (NEW) (CvUnit.cpp) When a unit upgrades, any promotions it had (even free ones) which are invalid on the new unit type are removed and refunded, not just removed. For each promotion refunded the player may immediately choose a replacement from the new unit's valid list. This is to prevent being punished for choosing things like Woodsman, Guerilla, Hunter, etc. early on; to prevent unique units which give obsoleting free promotions from being inferior to those that give permanent ones; and to properly handle cases where upgrade lines cross type boundaries (Recon->Helicopter for example, where a large number of promotions become invalid). COMBAT-RELATED MODS FortifyOnWaterMod (CvUnit.cpp) Allows ships to fortify. Not particularly realistic but still a good gameplay improvement imo. Currently hardcoded to use 40% of the land fortify strength, so that ocean defense goes from 0% to 10% and coast defense from 10% to 20% as fortify is built up. WeakerMarchEffectMod (NEW) (CvUnit.cpp, CvUnit.h) If a unit uses its March promotion to heal, ie it has moved or taken some other action, the amount healed is cut in half. Normal (idle) heal rates are unaffected, whether March is present or not. ExperienceNeededMod (UPDATED) (CvUnit.cpp) Stops the experience gap between promotion levels from continuing to grow larger past a certain point, making further levels unreasonably and impractically expensive. That point is currently set arbitrarily, by me, to be 145 exp and beyond, where the gap reaches a fixed 25 exp. I had had it set much lower in the past but changed my mind; this way it's still useful once in a while at least, and remains a steady comfort just knowing it's there. Also no longer checks with the Python function that can override this if it exists. COMBAT-MECHANICS MODS CollateralDamageMod (CvUnit.cpp) Applies any extra collateral damage (from promotions) to the base strength ratio calculation along with the unit's normal collateral percent, instead of using it to modify the value at the end of the damage calculation where it is significantly less potent. Protection from the Drill promotions (and Morale promotion in my mod) no longer reduces the actual damage done but instead reduces the maximum damage that can be done. Strength ratio and collateral percent no longer affect this limit; you must use promotions, which provides much-needed balance to the Drill series vs the Combat series. FlankingDamageMod (NEW) (CvUnit.cpp) Extends collateral immunity to also count as flanking immunity. Protection from the Drill promotions (and Morale promotion in my mod) now reduces the maximum flanking damage that can be done as well. WithdrawalMod (UPDATED) (CvUnit.cpp, CvGameTextMgr.cpp) I didn't feel like adding another new XML tag so I added functionality to the vanilla <iWithdrawalProb> one instead. It now allows negative values, which have the effect of increasing the withdrawal chances of units that attack the unit. I currently use this with the Ironclad, which provides some survivability for people who still have wooden warships. It also makes ironclad vs ironclad battles more likely to end in withdrawal as happened historically. Allows land units currently on water tiles (generally helicopters) to have their normal withdrawal chance, rather than being unable to withdraw. AIR COMBAT MODS AirCombatMod (UPDATED) (CvUnit.cpp, CvUnitAI.cpp) My attempt to implement an air superiority mission that fakes the AI players into using it *intelligently* without requiring modding of the AI itself. There is no new mission; rather it changes the way air strike missions work. This replaces the BetterAI air combat changes. All units, both land and air, are limited to one intercept per turn. Air units without any air interception capability still try to avoid being intercepted when performing missions; they roll against the enemy's intercept chance as well as with their own stealth/evasion chance (if any). If intercepted anyway, however, some non-intercepting air units (like the WW2 Bomber) have a "Returns Fire" stat that can allow them to damage or destroy the interceptor (if it's an air unit) with relatively low odds. Air units *with* interception chances, however, seek out air combat if possible when performing any mission other than the passive city circling. If a surface unit attempts to intercept their mission they try to avoid it as above, but if it is an air unit that takes the defense then the two fighters attempt to meet for a battle. The chance of this happening is the higher of their two interception stats. If this fails then the aggressor successfully performs his mission, however if a battle occurs each fighter's odds of victory are determined by a combination of both interception stats and both evasion stats (if any). The loser will either be damaged or destroyed, which is handled below. Allows air units to intercept after moving, as with surface units. Causes the interception chances of surface units to be lower when wounded, as with air units. Causes air units that perform recon missions to be vulnerable to intercepts. Causes air units that perform air strike missions, are involved in intercepts, and survive to use up a movement point (as with all other offensive missions). Modifies how much value the AI associates with Intercept and Evasion bonuses on promotions for use with the unit and promotion stats in my mod. AirLethalityMod (UPDATED) (CvUnit.cpp, CvUnit.h, CvUnitAI.cpp, CvInfos.cpp, CvInfos.h, CyInfoInterface1.cpp, CvGameTextMgr.cpp) Separates damage, and thus lethality, from interception probability. In vanilla the damage done by an intercept is based on the interception chance (actually the square of the chance), which really sucks. Now you can specify the two independently in XML, which allows for things like WW2 fighters, battleships, and flak cannons doing a lot less damage than missile-based units while still having a relatively high intercept chance, as well as for finer tweaking of air combat stats in general. The additional stat is displayed in the unit mouseover, of course. The relevant tag is called <iInterceptionLethality>, just below <iInterceptionProbability>. Here are some example values and their effects. Values below -99 and above 100 are invalid. -99: Intercepts do a random amount of damage between 1% and 99% of the target's max health, and can be fatal if and only if the target did not start at full health. -50: Same as above, in range 1% to 50%. 0: Intercepts never do any damage, but still force incoming aircraft to turn back. 50: Intercepts have a 50% chance of being fatal outright; if this does not occur, a random amount of damage between 1% and 99% of the target's max health is dealt instead (which can still prove fatal as above). 100: Intercepts are always fatal. Also adds support for giving air units a "-50% vs Air Units" type stat, which is taken to mean the unit has a 50% to die (explode) outright when intercepted, before the interceptor's lethality is even considered. (This is used with the Airship in my mod.) SIEGE COMBAT MODS SiegeMod (UPDATED) (CvCity.cpp, CvCity.h, CvCityAI.cpp, CvPlayer.cpp, CvPlayerAI.cpp, CvUnit.cpp, CvUnitAI.cpp, CvInfos.cpp, CvInfos.h, CvGameTextMgr.cpp, CvPlot.cpp, CvSelectionGroup.cpp, CyCity.cpp, CyCity.h, CyCityInterface1.cpp) Changes bombardment to do a fixed, absolute amount of damage rather than a % of the city's max defense in damage. City healing of bombardment damage remains percent-based so that it doesn't take forever for 100-125% defense cities to heal back from zero. Just for reference, in the XML of my full mod (not provided) I have cities set to heal 10% per turn, land siege ranging from 3% (Catapult) to 8% (Mechanized Artillery) bombard strength with two levels of Accuracy promotion (2% each) available to land units only, fighters ranging from 0-4%, bombers ranging from 6-10%, and ships ranging from 2-10%. These constitute *very* heavy nerfs from vanilla stats. Manually removes the Palisade, which is a building I use from the Stone Age mod, if Walls are built in a city, as they are incompatible visually and simply obsoleting it is not sufficient. Adds support for buildings that add to a city's culture defense instead of its physical defense. Examples in my mod include the Palisade (since it must be a precursor to Walls, and thus weaker, but any physical defense I could give it that is noticably lower than that of Walls would be largely useless when cities get these amounts from early culture level expansions anyway), and the NextWar Energy Shield from the end of the tech tree (where adding to physical defense would be pointless). Removes various restrictions which caused the AI to consider 3/4 or 5/6 bombardment sufficient before proceeding to either attack, blockade, or move on. The AI will now fully bombard its targets. Fixes some broken logic in BombardTarget() in CvUnit.cpp that will never normally run; it involves picking a bombard target if more than one exists within one tile of the bombarding unit, but since bombard targets pretty much have to be cities I'm not sure why this function even exists given the minimum tile distance required between cities that makes this scenario impossible. I guess they were just being thorough. BombardLimitMod (UPDATED) (CvInfos.cpp, CvInfos.h, CvGameTextMgr.cpp, CvUnit.cpp) Installs limitations on how far certain units can bombard defenses, which show up on unit mouseovers. Also adds separate tracking of physical and cultural defense damage and displays both, which fixes some problems and allows the bombard limits to work correctly in all cases. Uses the <iBombardLimit> tag just below <iBombardRate>. GENERAL MODS UpgradeCostTraitMod (CvInfos.cpp, CvInfos.h, CvGameTextMgr.cpp, CvUnit.cpp) Allows putting a unit upgrade cost modifier in traits like you already can with civics. (I currently use this with Financial.) CivicUpkeepMod (NEW) (CvPlayer.cpp) Removes 3 corrupting factors (involving the number of civic categories and which one you're in) from the calculation of civic upkeep costs. Costs are now uniform across the board; Medium Upkeep means Medium Upkeep, damnit. (Okay so maybe it's less cool this way, and less realistic, but it makes balancing the effects of the various civics a lot easier/better, and if you add new civic categories you can put them on the right end for visual separation without being stuck with bad prices now.) LakeSizeMod (CvArea.cpp) Makes the definition of a lake scale with map size. With an XML Globals value of 4 which is what I use, lakes will become inland seas when greater than 4 tiles in size on Duel, up through greater than 16 tiles in size on Huge. GoodyHutMod (NEW) (CvPlayer.cpp) Removes the "not before Turn 10" restriction on getting Experience Huts. Removes the "never with no cities, and not within 7 tiles with one city" restriction on getting Barbarian Huts. Removes the "not before Turn 20, and never in multiplayer" restriction on getting Offensive Unit Huts. Makes Tech Huts unable to provide techs which the player has already done any research in. (This last one is exploitable as it currently stands, I know, but for my purposes is well worth it.) Allows player, though not barbarian, research to begin immediately on Turn 0 without having to found a city first. (This change has no significant effect but I like it anyway.) UNIT MODS AnimalMod (UPDATED) (CvGame.cpp, CvUnit.cpp, CvUnitAI.cpp) Makes animals unlikely to leave their TerrainNative and/or FeatureNative tiles, unless attacking something. (Before these XML tags just specified where the animals would spawn and didn't attempt to restrict their movement.) Prevents animals from instantly de-spawning everywhere when barbarians start. There will still be no new animals spawning after this point. Allows animals to enter player borders, and tiles with resources or improvements when not attacking. They will still move entirely randomly unless locked on to a target, but if they happen to wander into an undefended city it will be captured or destroyed. BarbarianMod (UPDATED) (CvGame.cpp, CvUnit.cpp, CvPlayer.cpp) If starting a game in an era later than the first, the reduction in time before barbarian cities start appearing is changed from a "1 + Number of Eras Skipped" division to a 10%-per-Era subtraction. (If nothing is changing the total number of eras, a Future start would normally cause them to start at 14% of the base delay, versus 40% now.) Removes the requirement of 1.5 cities per living player on average (unless One City Challenge) for barbarians to start. Fixes a bug causing barbarians to start one turn later than they should. (If they were set to start on Turn 90, for example -- after Turns 0-89 ie 90 turns of peace -- they would not actually appear until Turn 91.) Fixes a bug introduced with the AnimalMod, where the number of barbarians spawned each turn was unintentionally being reduced by the number of animals still alive. Continues the grand tradition of barbarian naval assaults throughout an entire game, rather than letting them stop once players fully control all major coastlines. Barbs are restricted to spawning ships on coastlines as before until the barbarian player acquires Astronomy, at which point they attempt to spawn half of their ships in coastline and half in ocean (although if no valid coastline locations are available those will then become ocean spawns as well). Once the barbarian player acquires Assembly Line they spawn all of their ships in ocean. Ocean spawns are also modified to only allow ocean-capable ship types. (This won't work very well in mods that significantly change the tech tree, or at all in mods that use a completely different tech tree, of course, but it was a quick and effective solution for vanilla-esque setups. Note: I did not include the BetterAI reduction in barb ship spawn rate that scales with player navy sizes, as I believe the game is better without it.) Adds support for the XML Production Cost value of -2, which specifies a unit the barbarian player can train, but no one else can. Also prevents the BarbarianCombatModifier and AIBarbarianCombatModifier XML effects (from the difficulty settings) from applying to such units, so that they cannot be killed more easily than intended. Designed for use with the Kraken in my mod. PirateMod (NEW) (CvGame.cpp, CvPlayer.cpp) Moved from Python to SDK for speed: Every barbarian ship that spawns, and has a cargo capacity, will have its mission changed to ASSAULT_SEA and will spawn a full load of carried land units (using the same rules as normal land barbs). Moved from Python to SDK for speed: Checks all barb ship transports at the end of each turn and changes their mission back from ASSAULT to ATTACK if they're not carrying anything anymore. Prevents huge numbers of empty Galleys, Kogges, Galleons and Transports from piling up in barb cities and slowing the game down, as well as providing more (relatively weak) barb ships that attack players. CITY MODS CityTileCommerceMod (CvPlot.cpp) Makes city tile commerce additive rather than an enforced minimum. This is mainly so that players will not be penalized for building cities on rivers, but also lessens the hit for building on resources that give commerce naturally (without their improvement). Food and hammers are still treated as enforced minimums. FeatureGrowthMod (NEW) (CvPlot.cpp) Allows features to grow into tiles that already have improvements built, if they're allowed there. (I use this with Camps that can exist in forests in my mod, for example.) Also allows features with an improvement present to still generate spreads; before if you built a Forest Preserve in a forest, for example, that forest would no longer be able to cause new forests to grow in adjacent tiles. EventTileDowngradeMod (NEW) (CvPlot.cpp, CvPlayer.cpp, CvCity.cpp) Tile improvements that are hit by destruction events (like a Tornado) now behave as if they were pillaged instead; most are still destroyed, but Towns downgrade to Villages instead of being wiped out entirely, for example. RailroadMod (NEW) (CvPlot.cpp, CvPlayerAI.cpp, CvGameTextMgr.cpp) Supports upgrading the speed of railroads with techs. (This is used with Maglev in my mod.) Also modifies the AI to value all route-enhancing effects on techs equally, so that something like Maglev is given the same priority as Construction with its road speed increase even though the actual values are very different. PillageOwnRoadsMod (CvUnit.cpp) Allows you to pillage roads and railroads in your own territory. Serves no real purpose most of the time, but useful for those of us who like to have roads only inside city working radii from a vanity standpoint. DemolishOwnCitiesMod (NEW) (CvUnit.cpp) Allows you to blow up your own cities. *Solves the age-old desync problem in multiplayer!* Okay maybe not such a breakthrough nowadays, but I haven't seen anyone else do it yet. Basically it activates the Pillage command for your military units in your own cities, which is then used to trigger the demolition. Also saves the presence of National Wonders, Great Wonders, and Holy Cities, if any -- basically all the unreplaceable stuff -- in a temporary memory buffer; the next human player to place a new city will have these items instantly restored there. It is definitely abusable at the moment (in several ways heh), Corporation HQ's need to be added to the list of things saved, and if the power goes out or you have to reload a save or whatever the items will be lost, but for now it serves its purpose nicely, allowing you to move a city if scouting or vision of a new resource type change your mind about where to put it, or if you find a wonder in an enemy city that is in a terrible location for your empire. CultureDecayMod (NEW) (CvGame.cpp) Based on the old Python versions by other people, but moved into the SDK for significantly more speed (since this is a full sweep of all the map tiles and it occurs on every turnover). ReligionMod (NEW) (CvPlayer.cpp, CvPlayer.h, CvPlayerAI.cpp, CvGame.cpp, CvTeam.cpp, CvUnit.cpp, CvUnitAI.cpp) Adds the following restrictions: a player cannot found more than two religions, and a city cannot have more than four religions in it. If a player is the first to a third religion-founding tech, he will simply leave the religion for someone else to found and proceed as normal. A missionary cannot spread a religion to a full foreign city (ie no foreign inquisitions). If a missionary attempts to spread a 5th religion to one of his own cities, and doesn't randomly fail as he normally can, his religion will override/replace one of the existing ones at random (with all related buildings being immediately torn down), subject to one condition: if the player also owns the holy city for a religion that is present (or the target city itself is a holy city), that religion is immune to removal and one of the others will be chosen instead. If all 4 religions in the target city are protected, spreading in that city is not possible. (Having 4 protected religions is possible by conquering other players' holy cities; there is no cap on acquiring them this way.) No longer checks with the Python function that can override spread validities if it exists. This mod replaces my previous one reducing gold income from shrines (by up to 50% based on world size), which were overpowered when a single player could get 4 to 7 of them just by having a high-tech-rate early game. It removes the mess of spreading that many religions to all of your cities to get all the shrine money, and reins in the runaway extra happiness (up to +14) from having lots of temples and being on Free Religion, which was very difficult to deal with from a balance standpoint. Also fixes a bug where barbarian players could found religions. This was extremely unlikely in vanilla (though not technically impossible if the barbs had a lot of cities), but under my system if one or more players who had already founded their two religions early then also got the founding techs for later religions before someone else did, the barbs would start to research these techs passively at the normal rate and potentially get them fast enough. Further, blocks the AI from performing domestic inquisitions (spreading a 5th religion to a full city) if they neither have the holy city for the new religion nor are using it as a state religion. I'm not actually sure if they would or not, but this guarantees they will not do anything stupid if they have the ability to make missionaries for 5 or more religions but only control 3 or fewer holy cities (as it would then be possible to swap out replaceable religions with other replaceable religions endlessly, wasting production time both on missionaries and on rebuilding purged religious buildings). This restriction does not apply to human players. Changes the odds of success for a missionary spreading a religion to 100% for own/teammate cities and 80% for other cities, minus 10% per existing religion there. Under the above system the lowest domestic spread chance is thus 60% and the lowest foreign spread chance is 50%. (This is much simpler, and better, than before imo, where the odds would range from 100% to 40% domestic and 50% to 20% foreign depending on the number of existing religions there; constant missionary failure is annoying and unnecessary.) GreatPersonMod (NEW) (CvPlayer.cpp, CvGameTextMgr.cpp) A city's great person mouseover (and the Great Person Bar in my mod) now display the *final* odds breakdown of person types assuming things continue as they are currently, rather than the odds breakdown if the person were generated immediately (which is irrelevant). You can see what effect changing a specialist, for example, will have on the final person chances while there is still time for such decisions to matter. Removes the doubling of threshold increases after every 10 great people (and every 10 great generals, separately).