(1ST DRAFT) Mod-modder's guide to MNAI

Tholal

Emperor
Joined
May 19, 2009
Messages
1,676
This thread is for information, questions and discussions about modding More Naval AI. This thread will include info about any new or changed info and tags for this mod.

For base info about modding Civ4, you should visit the Civ4 Modding, Tutorials and Reference forum. For modding Fall from Heaven II, you should read Kael's Modders Guide to FfH2.

This mod also includes several sub-mods. You should visit their respective threads/forums for full info, though I will try to include modding information here as well since there are some things that are different for MNAI

New XML Tags in More Naval AI

Civ4BuildingInfos.xml
  • iRevIdxLocal
  • iRevIdxNational
  • iRevIdxDistanceModifier
  • bVictoryBuilding - used to identify buildings that lead to a Victory to help the AI

Civ4CivilizationInfos.xml
  • TerrainType
  • TerrainYields
  • TerrainRiverYields
  • TerrainYieldChange
  • TerrainYieldChanges - note: this and the previous 4 tags are for defining Civilization-specific yield changes for terrain (this was in the TerrainSchema but has been moved here to improve the code)
  • iCultureVictoryWeight
  • iSpaceVictoryWeight
  • iConquestVictoryWeight
  • iDominationVictoryWeight
  • iDiplomacyVictoryWeight - note: this and the previous 4 tags are from BBAI and are intended to weight certain civs towards certain victory conditions. Currently unused in MNAI and likely to be removed entirely
  • MilitaryUnitRefuseAttitudeThreshold -
  • EmbassyRefuseAttitudeThreshold
  • Trait effects for Revolutions - unused at the moment and will likely be purged/removed in the near future
    Spoiler :
    <!-- Phungus Rev Trait Effects -->
    <element type="iRevIdxLocal" minOccurs="0"/>
    <element type="iRevIdxNational" minOccurs="0"/>
    <element type="iRevIdxDistanceModifier" minOccurs="0"/>
    <element type="iRevIdxHolyCityGood" minOccurs="0"/>
    <element type="iRevIdxHolyCityBad" minOccurs="0"/>
    <element type="fRevIdxNationalityMod" minOccurs="0"/>
    <element type="fRevIdxBadReligionMod" minOccurs="0"/>
    <element type="fRevIdxGoodReligionMod" minOccurs="0"/>
    <element type="bNonStateReligionCommerce" minOccurs="0"/>
    <element type="bUpgradeAnywhere" minOccurs="0"/>
    <!-- End Phungus Traits -->

    [*]The following tags are deprecated and have been removed from this file
    • bAltarVictory
    • bArcaneTowerVictory
    • bCultureVictory
    • bReligionVictory
    • bReligionOpportunist
    • iAIPatrolGroupMage
    • iAIPatrolGroupSize
    • iAIValueDefense
    • iAIValueMage
    • iEconomyTechValue
    • iFavoriteEarlyMilTech
    • iFavoriteEarlyReligion
    • iFavoriteEarlyTech1
    • iFavoriteEarlyTech2
    • iFavoriteEarlyTech3
    • iFavoriteEarlyWonder
    • iFavoriteLateWonder

Civ4CivicInfos.xml
  • bDisallowInquisitions - Civics with this tag set to 1 block use of the Inquisition ability
  • iRevIdxLocal
  • iRevIdxNational
  • iRevIdxDistanceModifier
  • iRevIdxHolyCityGood
  • iRevIdxHolyCityBad
  • iRevIdxSwitchTo
  • fRevIdxNationalityMod
  • fRevIdxBadReligionMod
  • fRevIdxGoodReligionMod
  • fRevViolentMod
  • iRevReligiousFreedom
  • iRevLaborFreedom
  • iRevEnvironmentalProtection
  • iRevDemocracyLevel
  • bCommunism
  • bFreeSpeech
  • bCanDoElection

Civ4BonusInfos.xml
  • bMana - used to identify bonuses that provide mana or that are Raw mana

CivImprovementInfos.xml
  • bExploreTarget - tag for Improvements that can be explored
  • FreeSpawnPromotion - defines a promotion that will be given to any units spawned from this Improvement
  • iCulture - Super Forts
  • iCultureRange
  • bSuperFort
  • bBombardable - Improvement can be bombarded
  • bUpgradeRequiresFortify

CivTerrainInfos.xml

  • [*]The following tags are deprecated and have been removed from this file
    • CivilizationYieldType
    • CivilizationYieldChange

Civ4UnitInfos.xml
  • bObject - this marks whether or not a unit is an object (this was added in addition to the bEquipment tag to handle 'units' such as Treasure Chests)
  • bCanMoveLimitedBorders - allows units to pass through lands of other Civs with the Rights of Passage agreement (part of Advanced Diplomacy)

    [*]The following tags are deprecated and have been removed from this file
    • bAIblockPermDefense
    • bAIblockPatrol
    • bAIblockExplore

Civ4PromotionInfos.xml
  • UnitReligionPrereq - unit must have the designated religion in order to take this promotion
  • bAllowsMoveImpassable - units with this promotion can move through impassable terrain
  • bAllowsMoveLimitedBorders - units with this promotion can move through Limited Borders
  • bCastingBlocked - prevents units with this promotion from casting spells
  • bUpgradeOutsideBorders - units with this promotion can upgrade outside of their own borders

Civ4SpellInfos.xml
  • PyHelp
    Spoiler :

    A quick explanation for everyone interested in using this:
    The new tag works much like the other Spell tags regarding python: it must get a python expression, instead of a function. I'll give an example:

    CvSpellInterface.py in the component:
    Code:

    def canCast(argsList):
    pCaster, eSpell = argsList
    spell = gc.getSpellInfo(eSpell)
    return eval(spell.getPyRequirement())

    ...

    def getSpellHelp( argsList ) :
    eSpell, ePlayer, leUnits = argsList
    pSpell = gc.getSpellInfo( eSpell )
    pPlayer = gc.getPlayer( ePlayer )
    lpUnits = []
    for eUnit in leUnits :
    lpUnits.append( pPlayer.getUnit( eUnit ) )
    return eval( pSpell.getPyHelp() )

    CIV4SpellInfos.xml
    Code:

    <SpellInfo>
    <Type>SPELL_EXPLORE_LAIR_AIFON_ISLE</Type>
    ...
    <PyRequirement>reqExploreLair(pCaster)</PyRequirement>
    <PyHelp>helpExploreLair(lpUnits, True)</PyHelp>
    ...
    </SpellInfo>
    <SpellInfo>
    <Type>SPELL_EXPLORE_LAIR_BARROW</Type>
    ...
    <PyRequirement>reqExploreLair(pCaster)</PyRequirement>
    <PyHelp>helpExploreLair(lpUnits, False)</PyHelp>
    ...
    </SpellInfo>

    canCast() evaluates the expression given in the PyRequirement tag. That expression can use all variables defined in canCast before eval(), namely pCaster, eSpell and spell (although AFAIK only pCaster is used and intended to be used).

    PyHelp works the same way, but is has different variables. lpUnits holds all selected units that can cast the spell. The reason why I chose to consider a list of units rather than just one (the first selected), is that when you click on a spell button while having more than one unit selected, all valid units will cast that spell. So getting only information about one could be misleading.

    Also note the call of helpExploreLair in <PyHelp>, with the second argument being True or False. It determines whether the lair is epic or not. This way you can use the same function for epic and non-epic lairs instead of having two separate functions.

    [*]The following tags are deprecated and have been removed from this file
    • iAIWeightCity
    • iAIWeightWar

Civ4TechInfos.xml
  • bLimitedBordersTrading - this tech allows the player to trade Rights of Passage agreements
  • bEmbassyTrading - this tech allows the player to trade Embassies
  • bPuppetTrading - this tech allows the player to create Puppet States

Civ4UnitAIInfos.xml
  • UNITAI_INQUISITOR
  • UNITAI_LAIRGUARDIAN
    [*]The following tags are deprecated and have been removed from this file
    • UNITAI_BARBSMASHER

New functions exposed to python
The following functions are now exposed to python for modder's use.
  • CyUnit::isPermanentSummon()
  • CyUnit::setPermanentSummon(bool bNewValue)
  • CyGame::setHandicapType(int /*HandicapTypes*/ eHandicap)
  • CvBuildingInfo::isRequiresCaster()
 

New DLL Functions



CvPlayer::countNumOwnedTerrainTypes(TerrainTypes eTerrain) const;
CvPlayer::getHighestUnitTier(bool bIncludeHeroes = false, bool bIncludeLimitedUnits = false) const;
CvPlayer::canInquisition();
CvPlayer::setCanInquitision(bool bNewValue);


Note: Tags highlighted in green are exposed to python.
 
Hi,

Does MNAI allow for modular python?
 
Back
Top Bottom