Medieval 2: Total War - Engine Overhaul Project Lua Plugin Documentation
Welcome to the EOP Lua Plugin Documentation!
Please note that many of the examples require additional checks and not all functions are fully documented. If you need additional help, we welcome you to join the Discord!
Last updated: 2024-06-09 22:27:37
Quick Links
M2TWEOP
M2TWEOP | Basic M2TWEOP table |
M2TWEOP.getModPath () | Function to return the path to the mod folder, starts from the drive not the game folder. |
M2TWEOP.toggleConsole () | Open/close the lua console. |
M2TWEOP.toggleDeveloperMode () | Toggle developer mode. |
M2TWEOP.reloadScript () | Reload the lua script (without restarting the plugin itself, onPluginLoad doesn't fire). |
M2TWEOP.restartLua () | Restart the lua plugin (onPluginLoad fires). |
M2TWEOP.saveGame (path) | Save the game. |
M2TWEOP.getGameVersion () | Function to get the game version. |
M2TWEOP.setPerfectSpy (set) | Set perfect spy. |
M2TWEOP.getLocalFactionID () | Get local faction ID. |
M2TWEOP.getPluginPath () | Function to return the path to the plugin (location of your LUA files). |
M2TWEOP.logGame (message) | Log something to the game log. |
M2TWEOP.loadGame (path) | Load a savegame. |
M2TWEOP.loadTexture (path) | Load d3d texture |
M2TWEOP.unloadTexture (id) | Unload d3d texture |
M2TWEOP.setAncillariesLimit (newLimit) | Sets the limit of ancillaries per character on the stratmap. |
M2TWEOP.unlockGameConsoleCommands () | Unlocks all console commands, also allows the use of the 'control' command to change factions in singleplayer campaigns. |
M2TWEOP.setMaxBgSize (newSize) | Sets the maximum amount of soldiers a general's bodyguard unit can replenish to. |
M2TWEOP.setEDUUnitsSize (minSize, maxSize) | Sets the new maximum soldier count. |
M2TWEOP.getSettlementInfoScroll () | Gets a struct containing color information about the settlement info scroll. |
M2TWEOP.setBuildingChainLimit (limit) | Sets the new maximum amount of building levels within a chain. |
M2TWEOP.setConversionLvlFromCastle (castleLvl, convertToLvl) | Sets which level of castle converts to which level of city. |
M2TWEOP.setConversionLvlFromCity (cityLvl, convertToLvl) | Sets which level of city converts to which level of castle. |
M2TWEOP.setGuildCooldown (turns) | Sets the minimum number of turns until the next guild offer after a rejection by the player. |
M2TWEOP.toggleUnitsBMapHighlight () | Toggle the highlighting of units on the tactical map. |
M2TWEOP.getBattleCamCoords () | Get the current x, y and z coords of the battlemap camera |
M2TWEOP.setReligionsLimit (newLimit) | Set the maximum number of religions in the mod (per descr_religions.txt). |
M2TWEOP.setEquipmentCosts (equipmentType, newCost) | Set the siege points required to make different siege equipment. |
M2TWEOP.isTileFree (X, Y) | Checks if a tile is free. |
M2TWEOP.getGameTileCoordsWithCursor () | Get the selected tile coords. |
M2TWEOP.getTileRegionID (x, y) | Get the RegionID of a tile. |
M2TWEOP.getTileVisibility (faction, xCoord, yCoord) | Get a specific tile's visibility according to faction (i.e can a faction see a tile) Note: Once the tile has been seen by a faction, it will always return true. |
M2TWEOP.getRegionOwner (regionID) | Get the owner of a region by RegionID. |
M2TWEOP.getReligionName (index) | Get religion name by index. |
M2TWEOP.getReligionCount () | Get the amount of religions. |
M2TWEOP.getCultureName (index) | Get culture name by index. |
M2TWEOP.getClimateName (index) | Get climate name by index. |
M2TWEOP.getReligion (name) | Get religion ID by name. |
M2TWEOP.getCultureID (name) | Get culture ID by name. |
M2TWEOP.getClimateID (name) | Get climate ID by name. |
M2TWEOP.getOptions1 () | Get some game options. |
M2TWEOP.getOptions2 () | Get some game options. |
M2TWEOP.getCampaignDifficulty1 () | Get the campaign difficulty modifiers. |
M2TWEOP.getCampaignDifficulty2 () | Get the campaign difficulty modifiers. |
M2TWEOP.getCampaignDb () | Get the campaign options. |
M2TWEOP.getCampaignDbExtra () | Get the campaign options. |
M2TWEOP.condition (condition, eventData) | Check game condition. |
M2TWEOP.CalculateTileMovementCost (originX, originY, targetX, targetY) | Calculate movement point cost between two adjacent tiles. |
BattleCamera
battleCameraStruct | Get information about the camera in a battle |
GameUI
gameSTDUI | Basic gameSTDUI table |
gameSTDUI.getUiElement (elementName) | Get a game UI element, element must be opened. |
UIElement
uiElementStruct | Basic uiElementStruct table |
uiElementStruct:getSubElement (index) | Get a subelement of an UI element using the index. |
uiElementStruct:execute () | execute standard game UI element, use only for buttons |
StratmapObjects
stratmap.objects | Basic stratmap.objects table |
stratmap.objects.startDrawModelAt (modelId, x, y, sizeMultiplier) | Start drawing .cas campaign strategy model with a unique ID in some coords. |
stratmap.objects.stopDrawModel (modelId) | Stop drawing .cas campaign strategy model with a unique ID. |
stratmap.objects.addModelToGame (path, modelId) | Add a new .cas campaign strategy model to the game with a unique ID. |
stratmap.objects.addCharacterCas (skeleton, caspath, shadowcaspath, typename, texturepath, scale) | Add a new .cas character strategy model to the game with a unique name. |
stratmap.objects.setModel (xCoord, yCoord, modelId, modelId2) | Set the strategy model for object at specified coordinates, works only for supported object types |
stratmap.objects.replaceTile (label, xCoord, yCoord, filename, weather, dayTime) | Replace a custom tile. |
Camera
stratmap.camera | Basic stratmap.camera table |
stratmap.camera.move (xCoord, yCoord) | Slowly move the camera to the specified tile. |
stratmap.camera.jump (xCoord, yCoord) | Quickly move the camera to the specified tile. |
stratmap.camera.zoom (distance) | Set the zoom level of the camera. |
Game
Stratmap
stratmap | Basic stratmap table |
Unit
unit | Unit table |
unit:kill () | Kill this unit |
unit:setParams (exp, armor, weapon) | Set unit basic parameters |
unit:hasAttribute () | Check if unit has edu attribute. |
unit:hasBattleProperty (property) | Check if unit has guard mode, skirmish or fire at will on. |
unit:setBattleProperty (property, value) | Set a unit battle property (guard mode, skirmish or fire at will). |
unit:getActionStatus () | Get unit action status in battle ( idling, hiding, ready, reforming, moving, withdrawing, missiles_firing, missiles_reloading, charging, fighting, pursuing, routing, fighting_backs_to_the_walls, running_amok, rallying, dead, leaving_battle, entering_battle, left_battle, go_berserk, taunting, bracing, infighting). |
unit:isMovingFastSet () | Is unit set to run? |
unit:setMovingFastSet (movingFastSet) | Toggle unit running. |
unit:isOnWalls () | Is unit on walls? |
unit:isEngaged () | Is unit engaged in melee? |
unit:isUnderFire () | Is unit under fire? |
unit:getMountClass () | Get unit mount class. |
unit:getFormation () | Get unit formation type. |
unit:moveToPosition (xCoord, yCoord, run) | Orders the unit to move to the specified position. |
unit:immediatePlace (xCoord, yCoord, angle, width) | Immediately positions the unit at the given location. |
unit:attackClosestUnit (angle, run) | Searches an arc in front of the unit, and attacks the closest enemy found. |
unit:attackUnit (targetUnit, run) | Orders the unit to attack another unit. |
unit:deployStakes () | Deploys stakes. |
unit:changeFormation (formationType) | Changes the unit's formation. |
unit:halt () | Orders the unit to stop it's orders. |
unit:moveToOrientation (xCoord, yCoord, widthInMen, angle, run) | Orders the unit to move to the specified position with a specified rotation and orientation. |
unit:moveRelative (xCoord, yCoord, run) | Orders the unit to move to the specified position. |
unit:moveToMissileRange (targetUnit, run) | Orders the attacker to move into missile range of the target. |
unit:turn (angle, isRelative) | Turn to an absolute angle or by an angle relative to it's current rotation. |
unit:taunt () | Makes the unit taunt. |
unit:useSpecialAbility () | Makes the unit perform their special ability. |
unit:getSiegeEngine (index) | Get Siege engine. |
unit:attackBuilding (building) | Order a unit with appropriate siege equipment to attack an appropriate building (including docking towers/ladders to walls). |
unit:collectEngine (engine) | Order an infantry unit to collect an engine (ram/ladder/tower). |
unit:getNearbyFriendlyUnit (index) | Get Nearby friendly unit. |
unit:getNearbyEnemyUnit (index) | Get Nearby Enemy unit. |
unit:releaseUnit () | Set ai active set to on or off depending on if the unit is player controlled. |
Unit Position Data
unitPositionData | |
unitPositionData:getUnitUnderFireFrom (index) | Get unit that is firing at this unit. |
unitPositionData:getEngagedUnit (index) | Get unit that is fighting this unit in melee. |
unitPositionData:getTargetUnit () | Get the unit this unit is currently targeting. |
Projectile
projectileStruct |
Mount
mountStruct |
EduEntry
eduEntry | Basic eduEntry table |
eduEntry:hasOwnership (factionID) | Check if a faction has ownership of this entry. |
eduEntry:setOwnerShip (factionID, setOwnership) | Set if a faction has ownership of this entry. |
eduEntry:hasAttribute (attributeName) | Check if the entry has an attribute. |
Character
character | characters as they exist on the strategy map - dead characters, wives, children, and off-map characters do not have these fields. |
character:getTypeID () | Get the character type. |
character:getTypeName () | Get the character type. |
character:setTypeID (typeId) | Set the character type. |
character:moveToTile (xCoord, yCoord) | Issue regular move command, character must have movement points. |
character:diplomacyCharacter (targetChar) | Issue diplomacy command. |
character:assassinate (targetChar) | Issue assassination command. |
character:marry (targetChar) | Issue marry command. |
character:spyCharacter (targetChar) | Issue spyCharacter command. |
character:denounce (targetChar) | Issue denounce command. |
character:bribe (targetChar) | Issue bribe command. |
character:acquire (targetChar) | Issue acquire command. |
character:sabotage (target) | Issue sabotage command. |
character:switchFaction (newFac, keepArmy, keepUnit) | Switch character faction. |
character:diplomacySettlement (targetSettlement) | Issue diplomacy command. |
character:bribeSettlement (targetSettlement) | Issue bribe command. |
character:spySettlement (targetSettlement) | Issue spy command. |
character:sabotageSettlement (targetSettlement) | Issue sabotage command. |
character:diplomacyFort (targetFort) | Issue diplomacy command. |
character:bribeFort (targetFort) | Issue bribe command. |
character:spyFort (targetFort) | Issue spy command. |
character:reposition (xCoord, yCoord) | Instantly teleport character to the coordinates, if occupied a random place in the same region is chosen. |
character:teleport (xCoord, yCoord) | Instantly teleport character to the coordinates, if occupied the closest valid place to the coordinates is chosen. |
character:kill () | Delete this character |
character:createFort () | Create a fort at the character's coordinates |
character:setBodyguardUnit (unit) | Set bodyguard. |
character:setCharacterModel (model) | Set a character's model to a new one. |
character:sendOffMap () | Send a character off map (command will not fire if the general does not have a label, as you wouldn't be able to respawn him). |
NamedCharacter
namedCharacter | Basic namedCharacter table. |
namedCharacter:setAsHeir (onlyHeir) | Sets the named character as the faction heir. |
namedCharacter:isAlive () | Checks if character is alive, read only, do not set this value. |
namedCharacter:isOffMap () | Checks if character is off map, read only, do not set this value. |
namedCharacter:isChild () | Checks if character is child, read only, do not set this value. |
namedCharacter:getTraits () | Get the pointer to the character's traits container. |
namedCharacter:addTrait (traitName, traitLevel) | Add a trait to the character. |
namedCharacter:removeTrait (traitName) | Remove a trait from the character. |
namedCharacter:getAncillary (index) | Get the pointer to the ancillary using it's index. |
namedCharacter:addAncillary (ancillaryName) | Add an ancillary to the named character using the name per export_descr_ancillaries.txt. |
namedCharacter:removeAncillary (ancillary) | Remove an ancillary from the named character using it's pointer. |
capturedFactionInfo
capturedFactionInfo | Basic capturedFactionInfo table. |
capturedFactionInfo:getCapturedUnit (index) | Get a captured unit by it's index. |
capturedFactionInfo:getCapturedCharacter (index) | Get a captured character by it's index. |
capturedUnit
capturedUnit | Basic capturedUnit table. |
settlementTextStrings
settlementTextStrings | Basic settlementTextStrings table. |
uiString
uiString | Basic uiString table. |
settlementInfoScroll
settlementInfoScroll | Basic settlementInfoScroll table. |
settlementInfoScroll:getUIStrings () | Get settlement text color info. |
capturedCharacter
capturedCharacter | Basic capturedCharacter table. |
Ancillary
ancillary | Basic ancillary table |
Trait Container
traitContainer | Basic traits table |
Trait Struct
traitStruct | Basic trait table |
Trait Entry Struct
traitEntry | Basic traitEntry table |
Trait Level Struct
traitLevel | Basic traitLevel table |
traitLevel:getTraitEffect (index) | Get trait effect. |
Trait Effect Struct
traitEffect | Basic traitEffect table |
FactionStruct
factionStruct | Basic factionStruct table |
factionStruct:getFactionName () | Outdated legacy function. |
factionStruct:getNamedCharacter (number) | Get named character using it's index. |
factionStruct:getCharacter (number) | Get a character using it's index. |
factionStruct:getStack (number) | Get an army using it's index. |
factionStruct:getSettlement (number) | Get a settlement using it's index. |
factionStruct:getFort (number) | Get a fort using it's index. |
factionStruct:getPort (number) | Get a port using it's index. |
factionStruct:getWatchtower (number) | Get a watchtower using it's index. |
factionStruct:deleteFort (fort) | Delete a specific fort. |
factionStruct:createFortXY (X, Y) | Create a fort at the specified coordinates. |
factionStruct:createWatchtower (X, Y) | Create a watchtower at the specified coordinates. |
factionStruct:hasMilitaryAccess (targetFaction) | Check if a faction has military access to another faction. |
factionStruct:setMilitaryAccess (targetFaction, hasMilitaryAccess) | Set if a faction has military access to another faction. |
factionStruct:getFactionStanding (targetFaction) | Get the faction standing between 2 factions (a faction with itself returns global standing). |
factionStruct:setFactionStanding (targetFaction, factionStanding) | Set the faction standing between 2 factions (a faction with itself sets global standing). |
factionStruct:getFactionRanking (turnNumber) | Get the faction ranking scores. |
factionStruct:getFactionEconomy (turnsAgo) | Get the faction ecomomy table, specified number of turns ago (max 10). |
factionStruct:isNeighbourFaction (targetFaction) | Check if 2 factions are neighbours. |
factionStruct:getNeighbourRegionID (index) | Get a region ID of a neighbouring region by index. |
factionStruct:getBattleVsFactionStats (targetFactionID) | Get stats versus a specific other faction. |
factionStruct:getAiFactionValues () | Get various statistics the long term goal director uses. |
factionStruct:getInterFactionLTGD (targetFaction) | Get various statistics the long term goal director uses versus a target faction. |
factionStruct:setCharacterNameFaction (characterTypeIndex, factionID) | Set the faction characters of a specific type draw their names from. |
factionStruct:splitArmy (units, targetX, targetY) | Split an army. |
aiFaction
aiFaction | Basic aiFaction table |
aiLongTermGoalDirector
aiLongTermGoalDirector | Basic aiLongTermGoalDirector table |
aiLongTermGoalDirector:getlongTermGoalValues (targetFactionID) | Get long term goal director values versus a specific other faction. |
decisionValuesLTGD
decisionValuesLTGD | Basic decisionValuesLTGD table |
aiFactionValues
aiFactionValues | Basic aiFactionValues table |
interFactionLTGD
interFactionLTGD | Basic interFactionLTGD table |
aiPersonality
aiPersonality | Basic aiPersonality table |
aiPersonality:setConstructionValue (type, value) | Set bias value of the ai personality for a capability. |
aiPersonality:setRecruitmentValue (type, value) | Set bias value of the ai personality for a recruitment class. |
aiPersonality:getConstructionValue (type) | Get bias value of the ai personality for a capability. |
aiPersonality:getRecruitmentValue (type) | Get bias value of the ai personality for a recruitment class. |
aiPersonality:getProductionController (index) | Get a production controller by index. |
aiProductionController
aiProductionController | Basic aiProductionController table |
aiProductionController:setConstructionValue (type, value) | Set bias value of the ai personality for a capability. |
aiProductionController:setRecruitmentValue (type, value) | Set bias value of the ai personality for a recruitment class. |
aiProductionController:getConstructionValue (type) | Get bias value of the ai personality for a capability. |
aiProductionController:getRecruitmentValue (type) | Get bias value of the ai personality for a recruitment class. |
battleFactionCounter
battleFactionCounter | Basic battleFactionCounter table |
holdRegionsWinCondition
holdRegionsWinCondition | Basic holdRegionsWinCondition table |
holdRegionsWinCondition:getRegionToHoldName (index) | Get the name of the region that has to be held to win the campaign. |
holdRegionsWinCondition:getRegionToHoldLength (index) | Get the number of turns the region has to be held to win the campaign. |
FactionEconomy
factionEconomy | Basic factionEconomy table |
FactionRankings
factionRanking | Basic factionRanking table |
FactionStratMapStruct
factionStratMapStruct | Basic factionStratMapStruct table |
WatchtowerStruct
watchtowerStruct | Basic watchtowerStruct table |
FortStruct
fortStruct | Basic fortStruct table |
fortStruct:getSiege (siegeIdx) | Get a specific siege by it's index |
fortStruct:changeFortOwner (newFaction, convertGarrison) | Change fort ownership. |
PortStruct
portStruct | Basic portStruct table |
DockStruct
dockStruct | Basic dockStruct table |
SettlementStruct
settlementStruct | Basic settlementStruct table |
settlementStruct:changeOwner (newOwner, convertGarrison) | Change owner faction of settlement. |
settlementStruct:getReligion (religionID) | Get the settlement's specific regligion's value |
settlementStruct:setReligion (religionID, religionValue) | Set the settlement's specific religion's value, make sure the sum of all religion values does not exceed 1.0! |
settlementStruct:getGuildStanding (guild_id) | Get a settlement's standing points with a specific guild by ID |
settlementStruct:setGuildStanding (guild_id, standing) | Set the settlement's standing points with specific guild. |
settlementStruct:getBuilding (number) | Get a specific building by it's index. |
settlementStruct:createBuilding (building_level_id) | Create a building in the settlement. |
settlementStruct:destroyBuilding (typeName, isReturnMoney) | Destroy a building of a specified type in the settlement. |
settlementStruct:getResource (number) | Get a specific resource by it's index. |
settlementStruct:getSiege (siegeIdx) | Get a specific siege by it's index |
settlementStruct:getSettlementCapability (capabilityType) | Get a capability by capability type. |
settlementStruct:getAgentCapability (agentType) | Get an agent capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest. |
settlementStruct:getAgentLimitCapability (agentType) | Get an agent limit capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest. |
settlementStruct:getRecruitmentCapability (index) | Get a recruitment capability by index (max 64!). |
settlementStruct:getSettlementRecruitmentPool (index) | Get a recruitment pool by index. |
settlementStruct:upgrade () | Upgrade a settlement to the next level. |
settlementStruct:getConstructionOptions () | Get available construction items. |
settlementStruct:getRecruitmentOptions () | Get available recruitment items. |
construction options
constructionOptions | Basic constructionOptions table |
constructionOptions:getConstructionOption (index) | Get an available construction item. |
recruitment options
recruitmentOptions | Basic recruitmentOptions table |
recruitmentOptions:getRecruitmentOption (index) | Get an available recruitment item. |
unit in queue
unitInQueue | Basic unitInQueue table |
unitInQueue:addUnitToQueue () | Add a unit to the recruitment queue. |
settlementStats
settlementStats | Basic settlementStats table |
settlementCapability
settlementCapability | Basic settlementCapability table |
recruitmentCapability
recruitmentCapability | Basic recruitmentCapability table |
settlementRecruitmentPool
settlementRecruitmentPool | Basic settlementRecruitmentPool table |
Building
building | Basic building table |
building:getType () | Get the name of the building type (the building chain in export_descr_buildings.txt). |
building:getName () | Get name of building level (as per export_descr_buildings.txt). |
BuildingsQueue
buildingsQueue | Basic buildingsQueue table |
buildingsQueue:getBuildingInQueue (position) | Get building in queue by position |
BuildingInQueue
buildingInQueue | Basic buildingInQueue table |
buildingInQueue:getQueueBuildingType () | Get name of building in queue type (chain) |
buildingInQueue:getQueueBuildingName () | Get name of building in queue level |
buildingInQueue:addBuildingToQueue () | Add a building to the construction queue. |
Guild
guild | Basic guild table |
TradeResource
tradeResource | Basic tradeResource table |
tradeResource:setStratModel (modelId) | Set the resource's strat model. |
tradeResource:getResourceID () | Get the resource's ID. |
tradeResource:getResourceValue () | Get the resource's trade value. |
tradeResource:getResourceHasMine () | Check if the resource has a mine. |
tradeResource:getResourceImage () | Get the resource's image (icon) relative path. |
StackStruct
stackStruct | Basic stackStruct table |
stackStruct:sortStack (sortMode, sortMode2, sortMode3) | Sort units in a stack. |
stackStruct:getUnit (number) | Get a unit by it's index. |
stackStruct:getCharacter (number) | Get a character (agent or non-leading named character) by it's index. |
stackStruct:findInSettlement () | Find the settlement in which the army is located. |
stackStruct:findInFort () | Find the fort in which the army is located. |
stackStruct:createEOPUnit (index, exp, armor, weapon) | Create a unit in the army by index from M2TWEOP units DB (M2TWEOPDU). |
stackStruct:createUnit (type, exp, armor, weapon) | Create a unit in the army by type from export_descr_unit.txt |
stackStruct:createUnitByIDX (index, exp, armor, weapon) | Create a unit in the army by index from export_descr_unit.txt |
stackStruct:mergeArmies (targetArmy, force) | Merge 2 armies on the strat map. |
stackStruct:siegeSettlement (settlement, isAttack) | Besiege the specified settlement, or attack it if already besieging it. |
stackStruct:siegeFort (fort, isAttack) | Besiege the specified fort, or attack it if already besieging it. |
stackStruct:blockadePort (port) | Blockade a port. |
stackStruct:attackArmy (defender) | Attack another army. |
stackStruct:getDeadUnit (index) | Get dead unit at index. |
stackStruct:getGroup (index) | Get unit group at index. |
stackStruct:defineUnitGroup (name, unit) | Define a new unit group with a label. |
stackStruct:setAiActiveSet (activeSet) | Set ai active set to a value for the whole army (0 = inacitve, 1 = active, 2 = script controlled) |
stackStruct:releaseUnits () | Set ai active set to on or off depending if army is player controlled |
stackStruct:buildWatchTower () | Build a watchtower (payment applies) |
unitGroup
unitGroup | Basic unitGroup table |
unitGroup:addUnit (unit) | Add a unit to the group (won't add if unit already in group). |
unitGroup:removeUnit (unit) | Remove a unit from a group. |
unitGroup:undefine () | Undefine a unit group. |
unitGroup:automate (automate) | Toggle group automation. |
unitGroup:automateAttack (targetUnit) | Automate group attack. |
unitGroup:automateDefense (xCoord, yCoord, radius) | Automate group defense. |
unitGroup:getUnitInFormation (index) | Get a unit in the group's formation (not given individual commands). |
unitGroup:getUnitNotInFormation (index) | Get a unit not in the group's formation (not given individual commands). |
unitGroup:place (xCoord, yCoord, angle) | Place a group at a location. |
unitGroup:changeUnitFormation (formationType) | Change the group's units formations. |
unitGroup:moveToMissileRangeOfGroup (targetGroup, run) | Move to put an enemy group inside your missile range. |
unitGroup:moveToMissileRangeOfUnit (targetUnit, run) | Move to put an enemy unit inside your missile range. |
unitGroup:attackGroup (targetGroup, run) | Attack another group. |
unitGroup:halt () | Halt the group's orders. |
unitGroup:moveFormed (xCoord, yCoord, run) | Move to the specified location in formation. |
unitGroup:moveUnformed (xCoord, yCoord, run) | Move to the specified location not in formation. |
unitGroup:moveRelativeFormed (xCoord, yCoord, run) | Move to the specified location in formation. |
unitGroup:moveRelativeUnformed (xCoord, yCoord, run) | Move to the specified location not in formation. |
unitGroup:turn (angle, isRelative) | Turn the group either relative or absolute. |
SiegeStruct
siegeStruct | Basic siegeStruct table |
EOP Events
EventsFunctionsList | Events functions list. |
onCharacterTurnStart (eventData) | Called at a character's turn start. |
onCapturedCharacterRansomed (eventData) | A captured character has been successfully ransomed back from the enemy. |
onCapturedCharacterReleased (eventData) | A captured character has been released by the enemy. |
onFatherDiesNatural (eventData) | A character father died of natural causes. |
onPreBattleWithdrawal (eventData) | When a battle is about to start but one of the armies withdraws. |
onPostBattle (eventData) | When a battle has finished. |
onHireMercenaries (eventData) | A General has hired some mercenaries. |
onGeneralCaptureResidence (eventData) | A General has captured a residence such as a fort or watchtower. |
onLeaderDestroyedFaction (eventData) | A faction has been destroyed. |
onOfferedForAdoption (eventData) | An adoption has been proposed. |
onLesserGeneralOfferedForAdoption (eventData) | A lesser general adoption has been proposed (man of the hour event). |
onOfferedForMarriage (eventData) | A marriage offer has been proposed. |
onBrotherAdopted (eventData) | A brother has been adopted. |
onBirth (eventData) | A child is born to the faction leader. |
onCharacterComesOfAge (eventData) | A character has come of age. |
onCharacterMarries (eventData) | A character has married. |
onCharacterMarriesPrincess (eventData) | A character has married a princess. |
onMarriageAlliancePossible (eventData) | A marriage alliance is possible. |
onMarriageAllianceOffered (eventData) | A marriage alliance has been offered. |
onPriestBecomesHeretic (eventData) | A priest has gone mad. |
onCharacterNearHeretic (eventData) | A character is adjacent to a heretic. |
onCharacterNearWitch (eventData) | A character is adjacent to a witch. |
onCardinalPromoted (eventData) | A character has been promoted to a cardinal. |
onCharacterBecomesAFather (eventData) | A character has become a father. |
onGeneralDevastatesTile (eventData) | A General and his army has devastated an enemy's fertile land. |
onExecutesASpyOnAMission (eventData) | A spying mission has failed and the spy is executed by the target. |
onExecutesAnAssassinOnAMission (eventData) | An assassination mission has failed and the assassin is executed by the target. |
onSufferAssassinationAttempt (eventData) | Someone has had an attempt on their life. |
onSufferAcquisitionAttempt (eventData) | Someone has had an attempt on their assets. |
onSufferMarriageAttempt (eventData) | Someone has had an attempt on their bachelorhood. |
onSufferDenouncementAttempt (eventData) | Someone has had a denouncement attempt. |
onLeaderOrderedSabotage (eventData) | A Faction leader has ordered a sabotage mission. |
onAcceptBribe (eventData) | Someone has been bribed. |
onRefuseBribe (eventData) | Someone has refused a bribe. |
onInsurrection (eventData) | Insurgence has been provoked. |
onLeaderOrderedDiplomacy (eventData) | A Faction leader has ordered a diplomacy mission. |
onNewAdmiralCreated (eventData) | A new admiral has been created for a new ship. |
onGovernorBuildingDestroyed (eventData) | A building has been destroyed. |
onGovernorThrowGames (eventData) | Games have been thrown. |
onGovernorThrowRaces (eventData) | Races have been thrown. |
onCharacterSelected (eventData) | The player has selected a character. |
onEnemyCharacterSelected (eventData) | The player has selected an enemy character. |
onMultiTurnMove (eventData) | The player has selected a position beyond the character's extents. |
onCharacterPanelOpen (eventData) | The player has opened the panel for the selected character. |
onLeaderMissionSuccess (eventData) | A mission has been completed. |
onLeaderMissionFailed (eventData) | A mission has failed. |
onGeneralJoinCrusade (eventData) | A General has been sent on Crusade/Jihad. |
onGeneralAbandonCrusade (eventData) | A General has left a Crusade/Jihad. |
onGeneralArrivesCrusadeTargetRegion (eventData) | A General has arrived in the Crusade/Jihad target region. |
onGeneralTakesCrusadeTarget (eventData) | A General has taken the Crusade/Jihad target settlement. |
onCharacterTurnEnd (eventData) | A Character has finished its turn. |
onCharacterTurnEndInSettlement (eventData) | A Character has finished its turn in a settlement. |
onBecomesFactionLeader (eventData) | The character has been made the faction leader. |
onCeasedFactionLeader (eventData) | The character is no longer faction leader. |
onBecomesFactionHeir (eventData) | The character has been made a faction heir. |
onCeasedFactionHeir (eventData) | The character is no longer faction heir. |
onCharacterDamagedByDisaster (eventData) | A character has been injured by a disaster. |
onGeneralCaptureSettlement (eventData) | A General has captured a settlement. |
onGeneralAssaultsResidence (eventData, settlement, fort) | An assault has taken place. |
onGeneralAssaultsGeneral (eventData) | An assault has taken place. |
onCharacterAttacksCrusadingGeneral (eventData) | A general on crusade/jihad has been attacked by other character (it includes crusading generals attacked in a residence or on navy and generals attacked by spotted and killed assassin). |
onGeneralPrisonersRansomedCaptor (eventData) | A General of a captor faction has made a ransom decision. |
onGeneralPrisonersRansomedCaptive (eventData) | A General of a captive faction has made a ransom decision. |
onFactionLeaderPrisonersRansomedCaptor (eventData) | A captor faction has made a ransom decision. |
onFactionLeaderPrisonersRansomedCaptive (eventData) | A captive faction has made a ransom decision. |
onSpyMission (eventData) | A spy mission has completed. |
onAssassinationMission (eventData) | An assassination mission has completed. |
onAcquisitionMission (eventData) | An acquisition mission has completed. |
onMarriageMission (eventData) | A marriage mission has completed. |
onDenouncementMission (eventData) | A denouncement mission has completed. |
onSabotageMission (eventData) | A sabotage mission has completed. |
onBriberyMission (eventData) | A bribery mission has completed. |
onDiplomacyMission (eventData) | A diplomacy mission has completed. |
onLeaderOrderedSpyingMission (eventData) | A Faction leader has ordered a spying mission. |
onLeaderOrderedAssassination (eventData) | A Faction leader has ordered an assassination mission. |
onLeaderOrderedBribery (eventData) | A Faction leader has ordered a bribery mission. |
onSettlementTurnStart (eventData) | A settlement is being processed for the start of its faction's turn. |
onUngarrisonedSettlement (eventData) | A settlement is no longer garrisoned. |
onSettlementUpgraded (eventData) | A settlement has been upgraded. |
onSettlementConverted (eventData) | A settlement has been converted. |
onSiegeEquipmentCompleted (eventData) | Siege equipment has been completed by one of the besieging armies. |
onSettlementTurnEnd (eventData) | A Settlement is being processed for the end of its faction's turn. |
onSettlementSelected (eventData) | The player has selected a settlement. |
onSettlementPanelOpen (eventData) | The player has opened the panel for the selected settlement. |
onRecruitmentPanelOpen (eventData) | The player has opened a recruitment panel. |
onConstructionPanelOpen (eventData) | The player has opened a construction panel. |
onTradePanelOpen (eventData) | The player has opened a trade panel. |
onSettlementScrollAdviceRequested (eventData) | The player has requested advice on the settlement scroll. |
onGuildUpgraded (eventData) | A guild has been created/upgraded. |
onGuildDestroyed (eventData) | A guild has been destroyed. |
onOccupySettlement (eventData) | A settlement has been captured and occupied. |
onSackSettlement (eventData) | A settlement has been captured and sacked. |
onExterminatePopulation (eventData) | A settlement has been captured and some of its population has been decimated. |
onCityRiots (eventData) | A settlement has rioted. |
onGiveSettlement (eventData) | A settlement has been given to another faction. |
onCityRebels (eventData) | A settlement has rebelled. |
onCitySacked (eventData) | A settlement has been razed. |
onGovernorCityRiots (eventData) | A settlement has rioted. |
onGovernorCityRebels (eventData) | A settlement has rebelled. |
onAbandonShowMe (eventData) | The player has abandoned a show me scipt. |
onGameReloaded (eventData) | A strat map game has been reloaded. |
onBattleWinningPlaza (eventData) | The plaza is being captured. |
onBattleStopsWinningPlaza (eventData) | The plaza capture has been stopped. |
onBattleDominatingPlaza (eventData) | The enemy will have captured the plaza in 30s. |
onBattngineUnmanned (eventData) | A siege engine is now unmanned. |
onBattlePlayerArmyHalfDestroyed (eventData) | Half of the player's army has been destroyed. |
onBattnemyArmyHalfDestroyed (eventData) | Half of the enemy's army has been destroyed. |
onBattleFinished (eventData) | The battle has finished. |
onBattleArmyHalfDestroyed (eventData) | Half of an army has been destroyed. |
onEscPressed (eventData) | The escape key has been pressed. |
onScriptedAdvice (eventData) | The player has been issued with advice by a script. |
onNavalPreBattleScrollAdviceRequested (eventData) | The player has requested advice on the naval prebattle scroll. |
onPreBattleScrollAdviceRequested (eventData) | The player has requested advice on the prebattle scroll. |
onCollegeOfCardinalsPanelOpen (eventData) | The player has opened the college of cardinals panel. |
onDiplomaticStandingPanelOpen (eventData) | The player has opened the diplomatic standing panel. |
onBattlePlayerUnderAttackIdle (eventData) | An idle unit is under missile fire. |
onBattleWinningCombat (eventData) | A team has gained the advantage in combat. |
onBattleArmyTired (eventData) | The whole army is tired. |
onBattleSpySuccess (eventData) | A spy has successfully opened the gates. |
onBattleTideofBattle (eventData) | A different team is now the strongest. |
onBattleUnitGoesBerserk (eventData) | A unit has gone berserk. |
onBattleSiegeEngineDestroyed (eventData) | A siege engine has been destroyed. |
onBattleSiegeEngineDocksWall (eventData) | A siege engine has docked with a wall. |
onBattleGatesAttackedByEngine (eventData) | An engine has started attacking a gate. |
onBattleGatesDestroyedByEngine (eventData) | An engine has destroyed a gate. |
onBattleWallsBreachedByEngine (eventData) | A siege engine has knocked down a wall. |
onBattleWallsCaptured (eventData) | A wall has been captured. |
onBattleUnitRouts (eventData) | A unit has routed. |
onUnitDisbanded (eventData) | A unit has been disbanded. |
onUnitTrained (eventData) | A unit has been trained. |
onGovernorUnitTrained (eventData) | A unit has been trained. |
onGovernorBuildingCompleted (eventData) | A building has been completed. |
onAgentCreated (eventData) | An agent has been trained. |
onGovernorAgentCreated (eventData) | An agent has been trained. |
onBuildingDestroyed (eventData) | A building has been destroyed. |
onAddedToBuildingQueue (eventData) | A building has been added to the construction queue. |
onBuildingCompleted (eventData) | A building has been completed. |
onRequestBuildingAdvice (eventData) | The player has requested building advice. |
onRequestTrainingAdvice (eventData) | The player has requested training advice. |
onAddedToTrainingQueue (eventData) | A unit has been added to the training queue. |
onBattleArmyRouted (eventData) | An army has been entirely routed. |
onBattleReinforcementsArrive (eventData) | A reinforcing army has arrived on the battlefield. |
onRequestMercenariesAdvice (eventData) | The player has requested mercenaries advice. |
onButtonPressed (eventData) | The player has clicked on a button. |
onShortcutTriggered (eventData) | The player triggered a keyboard shortcut. |
onUIElementVisible (eventData) | A special UI Element is visible. |
onScrollOpened (eventData) | The player opened a scroll. |
onScrollClosed (eventData) | The player closed a scroll. |
onScrollAdviceRequested (eventData) | The player has requested advice on a scroll. |
onAdviceSupressed (eventData) | The player has suppressed a piece of advice. |
onBattleGeneralRouted (eventData) | A general has been routed. |
onBattleGeneralKilled (eventData) | A general has been killed. |
onCrusadeCalled (eventData) | A Crusade/Jihad has been called. |
onPopeAcceptsCrusadeTarget (eventData) | The Pope has accepted the player's crusade target. |
onPopeRejectsCrusadeTarget (eventData) | The Pope has rejected the player's crusade target. |
onCrusadeEnds (eventData) | A Crusade/Jihad has ended. |
onPreFactionTurnStart (eventData) | Called before the faction's turn starts. |
onFactionTurnStart (eventData) | Called at a faction's turn start. |
onFactionNewCapital (eventData) | Called after faction changes to a new capital. |
onFactionTurnEnd (eventData) | Called at a faction's turn end. |
onVotedForPope (eventData) | A Faction has voted for the new pope. |
onFactionExcommunicated (eventData) | A Faction has been excommunicated. |
onHordeFormed (eventData) | A Faction has formed a horde. |
onCardinalRemoved (eventData) | A cardinal has been removed from the game. |
onInquisitorAppointed (eventData) | An inquisitor has been dispatched to a region. |
onAssassinCaughtAttackingPope (eventData) | An assassination mission against the pope has failed and the assassin is executed. |
onFinancesPanelOpen (eventData) | The player has opened his finances panel. |
onFactionSummaryPanelOpen (eventData) | The player has opened the faction summary panel. |
onFamilyTreePanelOpen (eventData) | The player has opened the family tree panel. |
onDiplomacyPanelOpen (eventData) | The player has opened the diplomatic standing panel. |
onPreBattlePanelOpen (eventData) | The player has attacked an army or settlement. |
onIncomingMessage (eventData) | A message has arrived for the player. |
onMessageOpen (eventData) | The player has opened a message. |
onMessageClosed (eventData) | The player has closed a message. |
onDeclineAutomatedSettlementManagement (eventData) | The player has declined automated settlement management. |
onBattleAiCommenced (eventData) | The battle AI has begun processing. |
onBattleDelayPhaseCommenced (eventData) | The delay phase has begun. |
onBattleDeploymentPhaseCommenced (eventData) | The deployment phase has begun. |
onBattleConflictPhaseCommenced (eventData) | The conflict phase has begun. |
onFactionWarDeclared (eventData) | Called after a faction declares a war. |
onFactionAllianceDeclared (eventData) | Called after a faction declares an alliance. |
onInterFactionMarriage (eventData) | A marriage has occured between two factions. |
onFactionTradeAgreementMade (eventData) | Called after a faction makes a trade agreement. |
onPopeElected (eventData) | A new pope has been elected. |
onFactionBreakAlliance (eventData) | Called after a faction breaks an alliance. |
onUpdateAttitude (eventData) | A faction to faction attitude update has occurred (once every round). |
onDemeanour (eventData) | A demeanour response has occured in diplomacy talks. |
onGiveMoney (eventData) | Called after a faction gives money to another faction. |
onBattlePlayerUnitAttacksEnemyUnit (eventData) | A player unit has attacked one of the enemies units. |
onBattleEnemyUnitAttacksPlayerUnit (eventData) | An enemy unit has attacked one of the players units. |
onBattlePlayerUnitGoesBerserk (eventData) | One of the player's units has gone berserk. |
onBattlePlayerUnitRouts (eventData) | One of the player's units has routed. |
onBattlePlayerSiegeEngineDestroyed (eventData) | A siege engine belonging to the player has been destroyed. |
onBattleGatesAttackedByPlayerEngine (eventData) | A player's engine has started attacking a gate. |
onBattleEnemyUnitGoesBerserk (eventData) | One of the enemy's units has gone berserk. |
onBattnemyUnitRouts (eventData) | One of the enemy's units has routed. |
onBattnemySiegeEngineDestroyed (eventData) | A siege engine belonging to the enemy has been destroyed. |
onBattleGatesAttackedByEnemyEngine (eventData) | An enemy's engine has started attacking a gate. |
onDisaster (eventData) | When a particular disaster has just happened. |
onEventCounter (eventData) | An event counter has changed it's value. |
onUngarrisonedFort (eventData) | The last unit has been removed from a fort, agents do not count. |
onObjSeen (eventData) | An object of the target faction has been seen by the faction. |
onTileSeen (eventData) | The tile has been seen by the faction. |
onTransgression (eventData) | A faction to faction transgression has occurred. |
onForgiveness (eventData) | A faction to faction forgiveness has occurred. |
onArmyTakesCrusadeTarget (eventData) | An army has taken a crusade or jihad target settlement. |
onUnitsDesertCrusade (eventData) | Units have deserted a crusade or jihad. |
draw (pDevice) | Called every time an image is rendered for display |
onLoadingFonts () | Called when ImGui backend reload fonts |
onNewGameStart () | Called when a new campaign is started from the menu. |
onReadGameDbsAtStart () | Called after the game loads various db`s (edu, etc) at startup. |
onGameInit () | Called after the game loads various db`s (edu, etc) at startup. |
onUnloadCampaign () | Called after the campaignStruct gets unloaded (exit to menu, load save etc). |
onAiTurn (aiFaction) | Called on ai initialized on turn start. |
onClickAtTile (x, y) | Called on clicking the stratmap. |
onCampaignMapLoaded () | Called after loading the campaign map |
onPluginLoad () | Called on plugin load (at game start). |
onCreateSaveFile () | Called on creating a new save file. |
onLoadSaveFile () | Called on loading a save file. |
onChangeTurnNum (turnNumber) | Called at the start of a new turn. |
onSelectWorldpkgdesc (selectedRecordName, selectedRecordGroup) | Called on select worldpkgdesc for battlemap. |
onfortificationlevelS (siegedSettlement) | Called on specified fortificationlevel in a siege of a settlement. |
onCalculateUnitValue (entry, value) | Called when the game calculates the value of a unit. |
onEndSiege (xCoord, yCoord) | Called on the completion of the siege (in any way, with any outcome). |
onStartSiege (xCoord, yCoord) | Called on the starting of the siege (in any way, with any outcome). |
M2TWEOPDU
M2TWEOPDU | Basic M2TWEOPDU table. |
M2TWEOPDU.addEopEduEntryFromFile (filepath, eopEnryIndex) | Create new M2TWEOPDU entry from a file describing it. |
M2TWEOPDU.addEopEduEntryFromEDUID (baseEnryIndex, eopEnryIndex) | Create new M2TWEOPDU entry. |
M2TWEOPDU.getEopEduEntryByID (eopEnryIndex) | Get eduEntry of a M2TWEOPDU entry. |
M2TWEOPDU.getEduEntry (EnryIndex) | Get eduEntry by index. |
M2TWEOPDU.getEduEntryByType (type) | Get eduEntry by edu type name. |
M2TWEOPDU.getEduIndexByType (type) | Get edu index by edu type name. |
M2TWEOPDU.getDataEopDu (eopEnryIndex) | Get data of a M2TWEOPDU entry. |
M2TWEOPDU.setEntryUnitCardTga (eopEnryIndex, newCardTga) | Set unit card for a M2TWEOPDU entry. |
M2TWEOPDU.setEntryInfoCardTga (eopEnryIndex, newInfoCardTga) | Set unit info card for M2TWEOPDU entry. |
M2TWEOPDU.setEntrySoldierModel (eopEnryIndex, newSoldierModel) | Set unit info card for a M2TWEOPDU entry. |
M2TWEOPDU.getArmourUpgradeLevelsNum (index) | Get the amount of numbers in the armourupglevels line in exportdescrunit. |
M2TWEOPDU.setArmourUpgradeLevelsNum (index, amount) | Set the amount of armourupglevels, if you increase the amount of levels the last number entry will be repeated (only for eopdu units added by file!). |
M2TWEOPDU.getArmourUpgradeLevel (index, levelidx) | Get armour upgrade level number at specified index. |
M2TWEOPDU.setArmourUpgradeLevel (index, levelidx, newlevel) | Set armour upgrade level number at specified index (only for eopdu units added by file!). |
M2TWEOPDU.getArmourUpgradeModelsNum (index) | Get the amount of models in the armourupgmodels line in exportdescrunit. |
M2TWEOPDU.setArmourUpgradeModelsNum (index, amount) | Set the amount of armourupglevels, if you increase the amount of models the last model entry will be repeated (only for eopdu units added by file!). |
M2TWEOPDU.getArmourUpgradeModel (index, levelidx) | Get armour upgrade level number at specified index. |
M2TWEOPDU.setArmourUpgradeModel (index, levelidx, modelName) | Set the unit model at specified index (only for eopdu units added by file!). |
M2TWEOPDU.setEntryAttackAttribute (index, attribute, enable, sec) | Set a primary or secondary attack attribute of an edu entry. |
M2TWEOPDU.getEntryAttackAttribute (index, attribute, sec) | Get a primary or secondary attack attribute from an edu entry. |
M2TWEOPDU.setEntryStat (index, eduStat, value, sec) | Set any of the basic unit stats of an edu entry. |
M2TWEOPDU.getEntryStat (index, eduStat, sec) | Get any of the basic unit stats of an edu entry. |
M2TWEOPDU.setEntryLocalizedName (eopEnryIndex, newLocalizedName) | Set localized name for a M2TWEOPDU entry. |
M2TWEOPDU.setEntryLocalizedDescr (eopEnryIndex, newLocalizedDescr) | Set localized description for M2TWEOPDU entry. |
M2TWEOPDU.setEntryLocalizedShortDescr (eopEnryIndex, newLocalizedShortDescr) | Set localized short description for M2TWEOPDU entry. |
EdbEntry
edbEntry | Basic edbEntry table. |
Capability
capability | Basic capability table. |
RecruitPool
recruitpool | Basic recruitpool table. |
EDB
Game Options
options1 | Basic options1 table |
options2 | Basic options2 table |
Campaign Difficulty Modifiers
campaignDifficulty1 | Basic campaignDifficulty1 table. |
campaignDifficulty2 | Basic campaignDifficulty2 table. |
eventTrigger
eventTrigger | This is data that comes with game events. |
mapImage
mapImageStruct | |
mapImageStruct.makeMapImage () | Create a new image you want to determine region colors. |
mapImageStruct:clearMapImage () | Reset image state. |
mapImageStruct:loadMapTexture (path) | Create a new map texture. |
mapImageStruct:fillRegionColor (id, r, g, b, a) | Fill a region with a color. |
mapImageStruct:addRegionColor (id, r, g, b, a) | Add a color to already filled region. |
mapImageStruct:fillTileColor (x, y, r, g, b, a) | Fill a tile with a color. |
mapImageStruct:addTileColor (x, y, r, g, b, a) | Add a color to an already set tile. |
unitInfoScroll
unitInfoScroll | Basic unitInfoScroll table |
buildingInfoScroll | Basic buildingInfoScroll table |
uiCardManager
uiCardManager | Basic uiCardManager table |
uiCardManager:getSelectedUnitCard (index) | Get selected unit card by index. |
uiCardManager:getUnitCard (index) | Get unit card by index (battle or strat). |
uiCardManager:getBuildingInfoScroll () | Get building info scroll. |
uiCardManager:getUnitInfoScroll () | Get unit info scroll. |
selectionInfo
selectionInfo | Basic selectionInfo table |
Campaign
campaignStruct | Basic campaign table. |
campaignStruct:checkDipStance (checkType, fac1, fac2) | Check if a diplomatic relation between two factions. |
campaignStruct:setDipStance (relType, fac1, fac2) | Set a diplomatic relation between two factions. |
campaignStruct:GetUnitSize () | Get size of unit(i.e. |
campaignStruct:getFort (index) | Get fort by index. |
campaignStruct:getPort (index) | Get port by index. |
campaignStruct:getWatchTower (index) | Get watchtower by index. |
campaignStruct:getSettlementByName (name) | Get settlement by internal name. |
campaignStruct:getFaction (name) | Get a faction by it's internal name. |
campaignStruct:getCampaignPath () | Get path to the current descr_strat file used. |
campaignStruct:getMercPool (name) | Get a mercenary pool by name. |
campaignStruct:getRoad (index) | Get a road by index. |
CollegeofCardinals
collegeOfCardinals | Basic College of Cardinals table. |
collegeOfCardinals:getCardinal (index) | Get a specific cardinal by index. |
Crusade
crusadeStruct | Basic crusade table. |
Jihad
jihadStruct | Basic jihad table. |
coords
coordPair | Basic coordPair table. |
Strat Map
stratMap | Basic strat map table. |
stratMap.getRegion (index) | Get a specific region by index. |
stratMap.getTile (x, y) | Get a specific tile by it's coordinates. |
stratMap:getVolcanoCoords (index) | Get a volcano's coordinates. |
stratMap:getLandConnection (index) | Get a land connection's coordinates (the green arrows on the map that allow you to cross bodies of water). |
stratMap:getLandMass (index) | Get a landmass (collection of regions reachable by land, like a continent or island). |
stratMap:getSettlement (name) | Get a settlement by its internal name. |
stratMap:getRegionByName (name) | Get a region by its internal name. |
landMass
landMass | Basic landMass table. |
landMass:getRegionID (index) | Get a region ID by index. |
roadStruct
roadStruct | Basic roadStruct table. |
roadStruct:getCoord (index) | Get a road coord by index. |
Tile
tileStruct | Basic tile table. |
tileStruct:factionHasArmyNearTile (factionID) | Check if a faction has an army near a tile. |
tileStruct:factionHasCharacterOnTile (factionID) | Check if a faction has a character on a tile. |
tileStruct:getTileCharacterCount () | Get amount of characters on a tile. |
tileStruct:getTileCharacterAtIndex (index) | Get a character on a tile. |
RegionStruct
regionStruct | Basic regionStruct table. |
regionStruct:getStack (index) | Get an army by it's index. |
regionStruct:getFort (index) | Get a fort by it's index. |
regionStruct:getWatchtower (index) | Get a watchtower by it's index. |
regionStruct:getResource (index) | Get a resource by it's index. |
regionStruct:getNeighbour (index) | Get a neighbour region by it's index. |
regionStruct:getHiddenResource (index) | Check if a region has a hidden resource. |
regionStruct:setHiddenResource (index, enable) | Set a region's hidden resource (reset on game restart). |
regionStruct:getSeaConnectedRegion (index) | Get a region that is reachable from this region. |
regionStruct:getSeaImportRegion (index) | Get a region this region is importing trade goods from. |
regionStruct:getRegionSeaEdge (index) | Get a region sea edge (point where it borders both sea and another land region). |
regionStruct:getDevastatedTile (index) | Get a devastated tile. |
regionStruct:getTileBorderingEdgeOfMap (index) | Get a tile that borders the edge of the map. |
regionStruct:getTile (index) | Get a tile by index. |
regionStruct:getFertileTile (index) | Get a fertile tile by index. |
regionStruct:getReligionHistory (religionID, turnsAgo) | Get religion amount from a set number of turns ago. |
regionStruct:hasResourceType (resourceID) | Check if region has a resource type. |
regionStruct:getHostileArmiesStrength (factionID) | Get the strength total of all armies in this region that are hostile to a specific faction. |
neighbourRegion
neighbourRegion | Basic neighbourRegion table. |
neighbourRegion:getBorderTile (index) | Get a border tile by index. |
seaConnectedRegion
seaConnectedRegion | Basic seaConnectedRegion table. |
seaConnectedRegion:getReachableTile (index) | Get a reachable tile by index. |
seaConnectedRegion:getTradeLaneCoord (index) | Get trade lane coords by index. |
MercPools
mercPool | Basic mercenary pool table. |
mercPool:getMercUnitNum () | Get amount of mercenary units a region has. |
mercPool:addMercUnit (idx, exp, cost, repmin, repmax, maxunits, startpool, startyear, endyear, crusading) | Add a new mercenary unit to a pool. |
mercPool:getMercUnit (idx) | Get a mercenary unit from a pool by index. |
MercenaryUnits
mercPoolUnit | Basic mercenary unit table. |
mercPoolUnit:setMercReligion (religion, set) | Set or remove a religion requirement for a mercenary unit. |
GameDataAll
gameDataAll | Basic gameDataAll table |
gameDataAll.get () | Call at the start of the script, this is a static object and the pointer to it doesn't change. |
BattleStruct
battleStruct | basic battleStruct table |
battleStruct:getPlayerArmy (index) | Get a players army. |
battleStruct.getBattleResidence () | Get table with certain info about the battle residence. |
battleStruct.getUnitByLabel (label) | Get a unit by it's label. |
battleStruct.getGroupByLabel (label) | Get a group by it's label. |
battleStruct.getBattleMapHeight (xCoord, yCoord) | Get battlemap height at position. |
battleStruct.getBattlefieldEngines () | Get battlefield engines. |
battleStruct.getBattleTile (xCoord, yCoord) | Get battlefield tile. |
battleStruct.getZoneID (xCoord, yCoord) | Get zone ID. |
battleStruct.getPosPerimeter (xCoord, yCoord) | Get position perimeter. |
battleStruct.isZoneValid (zoneID) | Is zone valid. |
BattleSide
battleSide | Basic battleSide table |
battleSide.getWinConditionString (condition) | Get win condition string, for example: destroy_or_rout_enemy |
battleSide:getBattleArmy (index) | Get a battle army by it's index. |
battleSide:getFaction (index) | Get a faction in this side by it's index. |
battleSide:getReinforcementArmy (index) | Get a reinforcement army in this side by it's index. |
battleSideArmy
battleSideArmy | Basic battleSideArmy table |
battlePos
battlePos | Basic battlePos table |
DeploymentAreaS
deploymentAreaS | Basic DeploymentAreaS table |
deploymentAreaS:getCoordPair (index) | Get pair of coords with index. |
BattleAI
battleAI | Basic Battle AI table |
battleAI:getObjective (index) | Get a battle objective by it's index. |
BattleObjective
battleObjective | Basic battleObjective table |
battleObjective:getUnit (index) | Get a unit by it's index. |
battleObjective:getType () | Get the type of objective. |
BattleArmy
battleArmy | Basic battleArmy table |
battleArmy:getBattleUnit (index) | Get a battle unit by it's index. |
BattleUnit
battleUnit | Basic battleUnit table |
battleResidence
battleResidence | Basic battleResidence table |
battleResidence.getBattleStreets () | Get battle streets. |
plazaData
plazaData | Basic plazaData table |
battleBuildingStats
battleBuildingStats | Basic battleBuildingStats table |
battleBuildingStats:getTowerStats (index) | Get tower stats by index. |
towerStats
towerStats | Basic towerStats table |
fireRate | Basic fireRate table |
terrainLine
terrainLine | Basic terrainLine table |
terrainFeatureHill
terrainFeatureHill | Basic terrainFeatureHill table |
terrainHills
terrainHills | Basic terrainHills table |
terrainHills:getHill (index) | Get a hill by index. |
terrainLines
terrainLines | Basic terrainLines table |
terrainLines:getTerrainLine (index) | Get a terrain line segment by index. |
terrainFeatures
terrainFeatures | Basic terrainFeatures table |
roadNode
roadNode | Basic roadNode table |
battleStreets
battleStreets | Basic battleStreets table |
battleStreets:getStreetNode (index) | Get a street point. |
buildingBattle
buildingBattle | Basic buildingBattle table |
Siege Engine
siegeEngineStruct | Basic siegeEngineStruct table |
siegeEngineStruct:getType () | Get the type of the engine (use the enum). |
Battle Tile
battleTile | Basic battleTile table |
Battlefield Engines
battlefieldEngines | Basic battlefieldEngines table |
battlefieldEngines:getEngine (index) | Get an engine from the battlefield. |
battleBuildings
battleBuildings | Basic battleBuildings table |
battleBuildings:getBuilding (index) | Get a battle building by it's index. |
battleBuildings:getPerimeter (index) | Get a perimeter by it's index. |
perimeterBuildings
perimeterBuildings | Basic perimeterBuildings table |
perimeterBuildings:getBuilding (index) | Get a battle building in a perimiter by it's index. |
fortBattleInfo
fortBattleInfo | Basic fortBattleInfo table |
EOP Enums
dipRelType | Enum with a list of types of diplomatic relations. |
unitBattleProperties | Enum with a list of types of unit battle properties. |
buildingCapability | Enum with a list of types of building capabilities. |
characterType | Enum with a list of character types. |
sortType | Enum with a list of army sort types. |
aiPlan | Enum with a list of GTA AI plans. |
aiObjective | Enum with a list of GTA AI objectives. |
resourceType | Enum with a list of resources. |
moraleStatus | Enum of unit morale status. |
unitDiscipline | Enum of unit discipline. |
unitTraining | Enum of unit training. |
combatStatus | Enum of unit combat status. |
battleSuccess | Enum of battle success types. |
mountClass | Enum of unit mount class. |
battleType | Enum of battle types. |
battleState | Enum of battle states. |
unitClass | Enum of unit classes |
unitCategory | Enum of unit categories |
unitCategoryClass | Enum of unit categories and class combo |
managePolicy | Enum of automated settlement policy types |
formationType | Enum of formation types |
battleBuildingType | Enum of battle building types |
physicalGroundType | Enum of battle ground types |
engineType | Enum of engine types |
Campaign DB
campaignDbRecruitment | Basic campaignDb Recruitment table |
campaignDbReligion | Basic campaignDb Religion table |
campaignDbBribery | Basic campaignDb Bribery table |
campaignDbFamilyTree | Basic campaignDb Family Tree table |
campaignDbDiplomacy | Basic campaignDb Diplomacy table |
campaignDbDisplay | Basic campaignDb Display table |
campaignDbRansom | Basic campaignDb Ransom table |
campaignDbAutoresolve | Basic campaignDb Autoresolve table |
campaignDbSettlement | Basic campaignDb Settlement table |
campaignDbRevolt | Basic campaignDb Revolt table |
campaignDbHorde | Basic campaignDb Horde table |
campaignDbMerchants | Basic campaignDb Merchants table |
campaignDbAgents | Basic campaignDb Agents table |
campaignDbCrusades | Basic campaignDb Crusades table |
campaignDbAi | Basic campaignDb Ai table |
campaignDbMisc | Basic campaignDb Misc table |
campaignDb | Basic campaignDb table |
campaignDbExtra | Basic campaignDb Extra table (these options are just in another place in memory) |
M2TWEOPFBX
M2TWEOP3dObjects
M2TWEOP3dObjects | Basic M2TWEOP3dObjects table. |
M2TWEOP3dObjects.MakeTextFont (fontName, weight, isItalic) | Create new 3d text font. |
M2TWEOP3dObjects.DeleteTextFont (fondID) | Delete 3d text font. |
M2TWEOP3dObjects.Make3dText (fondID, text) | Create line of 3d text. |
3dText
Eop3dText | 3d text object. |
Eop3dText:Scale (sizeMultiplier) | Scale 3d text. |
Eop3dText:ChangeColor (a, r, g, b) | Set 3d text color. |
Eop3dText:SetCoords (x, y, z) | Set 3d text coords. |
Eop3dText:StartDrawing () | Start draw text. |
Eop3dText:StopDrawing () | Stop draw text. |
Eop3dText:DrawOnce () | Draw text once(at one frame only). |
Eop3dText:Delete () | Delete text. |
M2TWEOPSounds
M2TWEOPSounds | Basic M2TWEOPSounds table. |
M2TWEOPSounds.createEOPSound (soundPath) | Create (and load) a new sound. |
M2TWEOPSounds.deleteEOPSound (soundID) | Delete a sound |
M2TWEOPSounds.playEOPSound (soundID) | Play a sound. |
M2TWEOPSounds.setEOPSoundOffset (soundID, millisecondsOffset) | Set a sound's playing offset. |
M2TWEOPSounds.getEOPSoundOffset (soundID) | Get a sound's playing offset. |
M2TWEOPSounds.pauseEOPSound (soundID) | Pause a sound that is playing. |
M2TWEOPSounds.stopEOPSound (soundID) | Stop a sound that is playing. |
M2TWEOP
- M2TWEOP
-
Basic M2TWEOP table
Fields:
- getModPath getModPath
- toggleConsole toggleConsole
- reloadScript reloadScript
- restartLua restartLua
- toggleDeveloperMode toggleDeveloperMode
- saveGame saveGame
- getGameVersion getGameVersion
- setPerfectSpy setPerfectSpy
- getLocalFactionID getLocalFactionID
- getPluginPath getPluginPath
- loadTexture loadTexture
- unloadTexture unloadTexture
- setAncillariesLimit setAncillariesLimit
- unlockGameConsoleCommands unlockGameConsoleCommands
- setMaxBgSize setMaxBgSize
- toggleUnitsBMapHighlight toggleUnitsBMapHighlight
- getBattleCamCoords getBattleCamCoords
- setReligionsLimit setReligionsLimit
- setEquipmentCosts setEquipmentCosts
- isTileFree isTileFree
- getGameTileCoordsWithCursor getGameTileCoordsWithCursor
- getTileRegionID getTileRegionID
- getTileVisibility getTileVisibility
- setGuildCooldown setGuildCooldown
- getRegionOwner getRegionOwner
- setEDUUnitsSize setEDUUnitsSize
- setBuildingChainLimit setBuildingChainLimit
- getReligionName getReligionName
- getReligionCount getReligionCount
- getCultureName getCultureName
- getClimateName getClimateName
- getSettlementInfoScroll getSettlementInfoScroll
- getReligion getReligion
- getClimateID getClimateID
- getCultureID getCultureID
- condition condition
- getOptions1 getOptions1
- getOptions2 getOptions2
- CalculateTileMovementCost CalculateTileMovementCost
- getCampaignDifficulty1 getCampaignDifficulty1
- getCampaignDifficulty2 getCampaignDifficulty2
- setConversionLvlFromCastle setConversionLvlFromCastle
- setConversionLvlFromCity setConversionLvlFromCity
- loadGame loadGame
- logGame logGame
- getCampaignDb getCampaignDb
- getCampaignDbExtra getCampaignDbExtra
- M2TWEOP.getModPath ()
-
Function to return the path to the mod folder, starts from the drive not the game folder.
Returns:
-
string
mod path
Usage:
mPath=M2TWEOP.getModPath(); print(mPath);
- M2TWEOP.toggleConsole ()
-
Open/close the lua console.
Usage:
M2TWEOP.toggleConsole();
- M2TWEOP.toggleDeveloperMode ()
-
Toggle developer mode.
Usage:
M2TWEOP.toggleDeveloperMode();
- M2TWEOP.reloadScript ()
-
Reload the lua script (without restarting the plugin itself, onPluginLoad doesn't fire).
Usage:
M2TWEOP.reloadScript();
- M2TWEOP.restartLua ()
-
Restart the lua plugin (onPluginLoad fires).
Usage:
M2TWEOP.restartLua();
- M2TWEOP.saveGame (path)
-
Save the game.
Parameters:
- path string (start from mods)
Usage:
M2TWEOP.saveGame("mods/bare_geomod/saves/newsave.sav");
- M2TWEOP.getGameVersion ()
-
Function to get the game version.
Returns:
-
int
gamever (1 = disk 2 = steam)
Usage:
M2TWEOP.getGameVersion();
- M2TWEOP.setPerfectSpy (set)
-
Set perfect spy.
Parameters:
- set bool
Usage:
M2TWEOP.setPerfectSpy(true);
- M2TWEOP.getLocalFactionID ()
-
Get local faction ID.
Returns:
-
int
localFaction
Usage:
local localFaction = M2TWEOP.getLocalFactionID();
- M2TWEOP.getPluginPath ()
-
Function to return the path to the plugin (location of your LUA files).
Returns:
-
string
plugin path
Usage:
plPath=M2TWEOP.getPluginPath(); print(plPath);
- M2TWEOP.logGame (message)
-
Log something to the game log.
Parameters:
- message string
Usage:
M2TWEOP.logGame("log message");
- M2TWEOP.loadGame (path)
-
Load a savegame.
Parameters:
- path string starting from mods
Usage:
M2TWEOP.loadGame("mods/bare_geomod/saves/test.sav");
- M2TWEOP.loadTexture (path)
-
Load d3d texture
Parameters:
- path string full path to texture
Returns:
- int x size of the image
- int y size of the image
- int id of the image
Usage:
-- This function supports the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga. -- Recommended to use .dds for best performance -- Note: Doing image scaling and format conversion at load time can be slow. Store images in the format and resolution they will be used. -- More info: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxcreatetexturefromfileex local testImage = { x = 0, y = 0, img = nil}; testImage.x, testImage.y, testImage.img=M2TWEOP.loadTexture(M2TWEOP.getModPath().."/youneuoy_textures/test.dds");
- M2TWEOP.unloadTexture (id)
-
Unload d3d texture
Parameters:
- id int of the image
Usage:
local testImage = { x = 0, y = 0, img = nil}; testImage.x, testImage.y, testImage.img=M2TWEOP.loadTexture(M2TWEOP.getModPath().."/youneuoy_textures/test.dds"); M2TWEOP.unloadTexture(testImage.img);
- M2TWEOP.setAncillariesLimit (newLimit)
-
Sets the limit of ancillaries per character on the stratmap.
Parameters:
- newLimit int default: 8, maximum: 127
Usage:
M2TWEOP.setAncillariesLimit(15);
- M2TWEOP.unlockGameConsoleCommands ()
-
Unlocks all console commands, also allows the use of the 'control' command to change factions in singleplayer campaigns.
Usage:
M2TWEOP.unlockGameConsoleCommands();
- M2TWEOP.setMaxBgSize (newSize)
-
Sets the maximum amount of soldiers a general's bodyguard unit can replenish to. The value is multiplied by the unit size modifiers (e.g Huge = 2.5 multiplier)
Parameters:
- newSize int
Usage:
M2TWEOP.setMaxBgSize(100) -- On huge unit size, 100*2.5 = 250 max bodyguard size M2TWEOP.setMaxBgSize(150) -- On huge unit size, 150*2.5 = 300 max bodyguard size M2TWEOP.setMaxBgSize(50) -- On huge unit size, 50*2.5 = 125 max bodyguard size
- M2TWEOP.setEDUUnitsSize (minSize, maxSize)
-
Sets the new maximum soldier count.
Parameters:
- minSize int maximum: 300
- maxSize int maximum: 300
Usage:
M2TWEOP.setEDUUnitsSize(1,300);
- M2TWEOP.getSettlementInfoScroll ()
-
Gets a struct containing color information about the settlement info scroll.
Returns:
-
settlementInfoScroll
infoScroll
Usage:
// Make the words "Income" on the Settlement Info scroll red settlementInfoScroll = M2TWEOP.getSettlementInfoScroll(); settlementInfoScroll:getUIStrings.incomeString.red = 255 settlementInfoScroll:getUIStrings.incomeString.green = 0 settlementInfoScroll:getUIStrings.incomeString.blue = 0
- M2TWEOP.setBuildingChainLimit (limit)
-
Sets the new maximum amount of building levels within a chain.
Parameters:
- limit int default: 9, maximum: 57
Usage:
M2TWEOP.setBuildingChainLimit(12);
- M2TWEOP.setConversionLvlFromCastle (castleLvl, convertToLvl)
-
Sets which level of castle converts to which level of city.
Parameters:
- castleLvl int 0-5
- convertToLvl int 0-6, 6 means conversion from that level is disabled
Usage:
M2TWEOP.setConversionLvlFromCastle(3,3)
- M2TWEOP.setConversionLvlFromCity (cityLvl, convertToLvl)
-
Sets which level of city converts to which level of castle.
Parameters:
- cityLvl int 0-5
- convertToLvl int 0-6, 6 means conversion from that level is disabled
Usage:
M2TWEOP.setConversionLvlFromCity(3,3)
- M2TWEOP.setGuildCooldown (turns)
-
Sets the minimum number of turns until the next guild offer after a rejection by the player.
Parameters:
- turns int default: 10
Usage:
M2TWEOP.setGuildCooldown(5)
- M2TWEOP.toggleUnitsBMapHighlight ()
-
Toggle the highlighting of units on the tactical map.
Usage:
M2TWEOP.toggleUnitsBMapHighlight();
- M2TWEOP.getBattleCamCoords ()
-
Get the current x, y and z coords of the battlemap camera
Returns:
-
battleCameraStruct
Camera struct
Usage:
local cameraCoords = M2TWEOP.getBattleCamCoords(); -- Zoom out the camera beyond it's normal range cameraCoords.zCoord = 500;
- M2TWEOP.setReligionsLimit (newLimit)
-
Set the maximum number of religions in the mod (per descr_religions.txt). Do not use religions > 10 in CombatVsReligion attributes!
Parameters:
- newLimit int maximum: 127
Usage:
M2TWEOP.setReligionsLimit(25);
- M2TWEOP.setEquipmentCosts (equipmentType, newCost)
-
Set the siege points required to make different siege equipment.
Parameters:
- equipmentType int 0 = ram, 1 = ladder, 2 = siege tower
- newCost int
Usage:
M2TWEOP.setEquipmentCosts(0, 25);
- M2TWEOP.isTileFree (X, Y)
-
Checks if a tile is free.
Parameters:
- X int coordinate of the tile.
- Y int coordinate of the tile.
Returns:
-
boolean isFree
Usage:
M2TWEOP.isTileFree(55,25);
- M2TWEOP.getGameTileCoordsWithCursor ()
-
Get the selected tile coords.
Returns:
- int x
- int y
Usage:
local x,y=M2TWEOP.getGameTileCoordsWithCursor();
- M2TWEOP.getTileRegionID (x, y)
-
Get the RegionID of a tile.
Parameters:
- x int
- y int
Returns:
-
int
regionID
Usage:
local regionID=M2TWEOP.getTileRegionID(55,25);
- M2TWEOP.getTileVisibility (faction, xCoord, yCoord)
-
Get a specific tile's visibility according to faction (i.e can a faction see a tile) Note: Once the tile has been seen by a faction, it will always return true. e.g If you have spotted a settlement but it is now outside of the fog of war, it will still be classed as visible.
Parameters:
- faction factionStruct Faction to check
- xCoord int x coord of the tile
- yCoord int y coord of the tile
Returns:
-
bool
isVisible true = visible, false = not visible
Usage:
local faction = CAMPAIGN:getFaction("england") local isVisible = M2TWEOP.getTileVisibility(faction, xCoord, yCoord) if isVisible == true then print("Tile is visible to faction "..faction.name) else print("Tile is not visible to faction "..faction.name) end
- M2TWEOP.getRegionOwner (regionID)
-
Get the owner of a region by RegionID.
Parameters:
- regionID int
Returns:
-
factionStruct
owner
Usage:
local regionID = M2TWEOP.getTileRegionID(55,25); local ownerFac = M2TWEOP.getRegionOwner(regionID);
- M2TWEOP.getReligionName (index)
-
Get religion name by index.
Parameters:
- index int
Returns:
-
string
name
Usage:
local religionName = M2TWEOP.getReligionName(1);
- M2TWEOP.getReligionCount ()
-
Get the amount of religions.
Returns:
-
int
religionCount
Usage:
local religionCount = M2TWEOP.getReligionCount();
- M2TWEOP.getCultureName (index)
-
Get culture name by index.
Parameters:
- index int
Returns:
-
string
name
Usage:
local name = M2TWEOP.getCultureName(1);
- M2TWEOP.getClimateName (index)
-
Get climate name by index.
Parameters:
- index int
Returns:
-
string
name
Usage:
local name = M2TWEOP.getClimateName(1);
- M2TWEOP.getReligion (name)
-
Get religion ID by name.
Parameters:
- name string
Returns:
-
int
index
Usage:
local religion = M2TWEOP.getReligion("catholic");
- M2TWEOP.getCultureID (name)
-
Get culture ID by name.
Parameters:
- name string
Returns:
-
int
index
Usage:
local cultureID = M2TWEOP.getCultureID("southern_european");
- M2TWEOP.getClimateID (name)
-
Get climate ID by name.
Parameters:
- name string
Returns:
-
int
index
Usage:
local climateID = M2TWEOP.getClimateID("sandy_desert");
- M2TWEOP.getOptions1 ()
-
Get some game options.
Returns:
-
options1
options
Usage:
local options = M2TWEOP.getOptions1();
- M2TWEOP.getOptions2 ()
-
Get some game options.
Returns:
-
options2
options
Usage:
local options = M2TWEOP.getOptions2();
- M2TWEOP.getCampaignDifficulty1 ()
-
Get the campaign difficulty modifiers.
Returns:
-
campaignDifficulty1
options
Usage:
local modifiers = M2TWEOP.getCampaignDifficulty1();
- M2TWEOP.getCampaignDifficulty2 ()
-
Get the campaign difficulty modifiers.
Returns:
-
campaignDifficulty2
options
Usage:
local modifiers = M2TWEOP.getCampaignDifficulty2();
- M2TWEOP.getCampaignDb ()
-
Get the campaign options.
Returns:
-
campaignDb
options
Usage:
local options = M2TWEOP.getCampaignDb();
- M2TWEOP.getCampaignDbExtra ()
-
Get the campaign options.
Returns:
-
campaignDbExtra
options
Usage:
local options = M2TWEOP.getCampaignDbExtra();
- M2TWEOP.condition (condition, eventData)
-
Check game condition.
Parameters:
- condition string
- eventData eventTrigger or nil
Returns:
-
bool
isTrue
Usage:
if M2TWEOP.condition("InEnemyLands", eventData) then --do stuff end
- M2TWEOP.CalculateTileMovementCost (originX, originY, targetX, targetY)
-
Calculate movement point cost between two adjacent tiles.
Parameters:
- originX int
- originY int
- targetX int only adjacent tiles! Does not calculate paths just the cost of moving from one tile to another.
- targetY int only adjacent tiles! Does not calculate paths just the cost of moving from one tile to another.
Returns:
-
float
moveCost
Usage:
local moveCost = M2TWEOP.CalculateTileMovementCost(153, 245, 154, 245);
BattleCamera
- battleCameraStruct
-
Get information about the camera in a battle
Fields:
- xCoord float
- yCoord float
- zCoord float
GameUI
- gameSTDUI
-
Basic gameSTDUI table
Fields:
- getUiElement getUiElement
- gameSTDUI.getUiElement (elementName)
-
Get a game UI element, element must be opened.
Parameters:
- elementName string
Returns:
-
uiElementStruct
element
Usage:
function analyzeScroll(scrollName) local scroll, uiList = gameSTDUI.getUiElement(scrollName), "UI elements of scroll: "..scrollName if scroll ~= nil then for i = 0, scroll.subElementsNum - 1, 1 do uiList = uiList.."\n\t"..i.." "..scroll:getSubElement(i).elementName end print(uiList) end end
UIElement
- uiElementStruct
-
Basic uiElementStruct table
Fields:
- elementName string
- xSize int
- ySize int
- xPos int
- yPos int
- subElementsNum int
- getSubElement getSubElement
- execute execute
- uiElementStruct:getSubElement (index)
-
Get a subelement of an UI element using the index.
Parameters:
- index int Starts from 0.
Returns:
-
uiElementStruct
subelement
Usage:
local financeScroll = gameSTDUI.getUiElement("finance_scroll"); local subElement1 = financeScroll:getSubElement(5);
- uiElementStruct:execute ()
-
execute standard game UI element, use only for buttons
Usage:
local financeScroll = gameSTDUI.getUiElement("finance_scroll"); --at index 5 we have faction_listviews_button local subElement1 = financeScroll:getSubElement(5); subElement1:execute();
StratmapObjects
- stratmap.objects
-
Basic stratmap.objects table
Fields:
- addModelToGame addModelToGame
- addCharacterCas addCharacterCas
- setModel setModel
- replaceTile replaceTile
- startDrawModelAt startDrawModelAt
- stopDrawModel stopDrawModel
- stratmap.objects.startDrawModelAt (modelId, x, y, sizeMultiplier)
-
Start drawing .cas campaign strategy model with a unique ID in some coords. Can be used at any time.
Parameters:
- modelId int Unique ID
- x int
- y int
- sizeMultiplier int 1 is value with what it draw as same size as game objects
Usage:
stratmap.objects.addModelToGame("data/models_strat/residences/invisible.CAS", 1); stratmap.objects.startDrawModelAt(1, 50, 150, 2.25);
- stratmap.objects.stopDrawModel (modelId)
-
Stop drawing .cas campaign strategy model with a unique ID. Can be used at any time.
Parameters:
- modelId int Unique ID
Usage:
stratmap.objects.addModelToGame("data/models_strat/residences/invisible.CAS", 1); stratmap.objects.startDrawModelAt(1, 50, 150, 2.25); stratmap.objects.stopDrawModel(1);
- stratmap.objects.addModelToGame (path, modelId)
-
Add a new .cas campaign strategy model to the game with a unique ID. This should be called during onPluginLoad()
Parameters:
- path string Relative path from the modfolder (starting with "data/").
- modelId int Unique ID to use the model later.
Usage:
stratmap.objects.addModelToGame("data/models_strat/residences/invisible.CAS",1);
- stratmap.objects.addCharacterCas (skeleton, caspath, shadowcaspath, typename, texturepath, scale)
-
Add a new .cas character strategy model to the game with a unique name. Only add it after loading to campaign map!
Parameters:
- skeleton string name of skeleton used.
- caspath string Relative path from the mods folder (starting with "mods/").
- shadowcaspath string Relative path from the mods folder (starting with "mods/").
- typename string Name of the new model used to assign.
- texturepath string Relative path from the mods folder (starting with "mods/").
- scale float
Usage:
stratmap.objects.addCharacterCas( "strat_named_with_army", "mods/Bare_Geomod/data/models_strat/islamic_general2.cas", "mods/Bare_Geomod/data/models_strat/shadow_sword2.cas", "islamic_general2", "mods/Bare_Geomod/data/models_strat/textures/islamic_general_turks.tga", 0.7 );
- stratmap.objects.setModel (xCoord, yCoord, modelId, modelId2)
-
Set the strategy model for object at specified coordinates, works only for supported object types
Parameters:
- xCoord int
- yCoord int
- modelId int used for: watchtower, resource, settlement, fort, port
- modelId2 int used for: fort wall (use fort coords), dock (use port coords)
Usage:
stratmap.objects.addModelToGame("data/models_strat/residences/invisible.CAS",1); stratmap.objects.setModel(288,257,1,1);
- stratmap.objects.replaceTile (label, xCoord, yCoord, filename, weather, dayTime)
-
Replace a custom tile. Change the custom battlefield on the specified coordinates.
Parameters:
- label string Identifier.
- xCoord int X coordinate of tile.
- yCoord int Y coordinate of tile.
- filename string Just the name, not full path (.wfc)
- weather string Weather on the battle map.
- dayTime string Time of day.
Usage:
stratmap.objects.replaceTile("Helms-Deep_Province",167,158,"hornburg_amb.wfc","clear","midday");
Camera
- stratmap.camera
-
Basic stratmap.camera table
Fields:
- stratmap.camera.move (xCoord, yCoord)
-
Slowly move the camera to the specified tile.
Parameters:
- xCoord int
- yCoord int
Usage:
stratmap.camera.move(1,2);
- stratmap.camera.jump (xCoord, yCoord)
-
Quickly move the camera to the specified tile.
Parameters:
- xCoord int
- yCoord int
Usage:
stratmap.camera.jump(1,2);
- stratmap.camera.zoom (distance)
-
Set the zoom level of the camera.
Parameters:
- distance float
Usage:
stratmap.camera.zoom(0.12);
Game
- stratmap.game
-
Basic stratmap.game table
Fields:
- getFactionsCount getFactionsCount
- getFaction getFaction
- createCharacterByString createCharacterByString
- createArmy createArmy
- spawnArmy spawnArmy
- createArmyInSettlement createArmyInSettlement
- getScriptCounter getScriptCounter
- setScriptCounter setScriptCounter
- historicEvent historicEvent
- scriptCommand scriptCommand
- callConsole callConsole
- getGuild getGuild
- stratmap.game.callConsole (command, args)
-
Execute a Medieval II console command.
Parameters:
Returns:
-
string
error Note: string can be empty but not nil
Usage:
-- Creating units, adding money function onCharacterSelected(eventData) local selectedChar = eventData.character local err = stratmap.game.callConsole("add_money", "2321") local err2 = stratmap.game.callConsole("create_unit", "testcharacter 'Cool Unit' 4 1 1 1") print(err) print(err2) end
- stratmap.game.getFactionsCount ()
-
Get the amount of factions. Just returns campaignStruct.numberOfFactions field.
Returns:
-
int
facNumber Amount of factions
Usage:
local facNum=stratmap.game.getFactionsCount();
- stratmap.game.getFaction (Index)
-
Get a faction by the turn order. Same thing as doing campaignStruct.factionsSortedByDescrStrat[index + 1].
Parameters:
- Index int of the faction.
Returns:
-
factionStruct
faction
Usage:
faction=stratmap.game.getFaction(2);
- stratmap.game.getGuild (index)
-
Get a guild by the index.
Parameters:
- index int
Returns:
-
guild
guild
Usage:
ourGuild=stratmap.game.getGuild(1);
- stratmap.game.createCharacterByString (type, Faction, age, name, name2, subFaction, portrait_custom, xCoord, yCoord)
-
Create a new character at the specified coordinates. If you are not spawning an agent it is preferred to use spawnArmy instead.
Parameters:
- type string Character type, for example "named character".
- Faction factionStruct the new character belongs to.
- age int The character's age
- name string The short name of the character.
- name2 string The full name of the character.
- subFaction int Set to 31 to disable.
- portrait_custom string cannot be nil Name of the folder inside 'data/ui/custom_portraits folder. Can not be nil!
- xCoord int X coordinate of the new character
- yCoord int Y coordinate of the new character
Returns:
-
character
newCharacter Returns a character class, not a named character class!
Usage:
newCharacter=stratmap.game.createCharacterByString("named character",CAMPAIGN:getFaction("england"),18,"Name1","Name2",31,"custom_portrait_name",character.character.xCoord+5,character.character.yCoord);
- stratmap.game.spawnArmy (Faction, name, name2, type, label, portrait, x, y, age, family, subFaction, unitIndex, exp, wpn, armour)
-
Create a new army at the specified coordinates. Works similarly to the script command spawn_army. You can respawn off-map characters using it. You can not re-use labels!
Parameters:
- Faction factionStruct the new character belongs to.
- name string The short name of the character. Use random_name to pick a random name.
- name2 string The full name of the character.
- type int characterType.named_character or characterType.general or characterType.admiral.
- label string label of the character, has to be unique!. Can be nil.
- portrait string Name of the folder inside 'data/ui/custom_portraits folder.
- x int X coordinate of the new character
- y int Y coordinate of the new character
- age int The character's age
- family bool should character be auto adopted?
- subFaction int Set to 31 to disable.
- unitIndex int Index of the unit in the unit list. Can be EOP or normal.
- exp int
- wpn int
- armour int
Returns:
-
stackStruct
newArmy
Usage:
local army = stratmap.game.spawnArmy( CAMPAIGN:getFaction("england"), "Rufus", "", characterType.named_character, "rufus_1", "", 106, 149, 18, false, 31, M2TWEOPDU.getEduIndexByType("Peasants"), 3, 0, 0 )
- stratmap.game.createArmy (ourGeneral)
-
Legacy code to spawn an army for a created character. Use spawnArmy instead!
Parameters:
- ourGeneral character Character class, not named character class!
Returns:
-
stackStruct
army
Usage:
army=stratmap.game.createArmy(gen);
- stratmap.game.createArmyInSettlement (settlement)
-
Create an army in a settlement (don't need a character). Used to add units to an empty settlement.
Parameters:
- settlement settlementStruct
Returns:
-
stackStruct
army
Usage:
army=stratmap.game.createArmyInSettlement(STRAT_MAP:getSettlement("London"));
- stratmap.game.getScriptCounter (counterName)
-
Get a script counter value, works for counters and for event_counters
Parameters:
- counterName string The name of the counter
Returns:
- bool isExist Returns true if the counter exists i.e it has been used at least once in any way in the campaign_script
- int counterValue Returns the value of the counter
Usage:
isExist, counterValue = stratmap.game.getScriptCounter("SomeCounter")
- stratmap.game.setScriptCounter (counterName, value)
-
Set an event_counter value, does not work for counters, only event_counters.
Parameters:
- counterName string
- value int
Usage:
stratmap.game.setScriptCounter("SomeCounter", 25)
- stratmap.game.historicEvent (eventName, title, body)
-
Fire a game event message. Picture needs to be provided in the ui folders as default.
Parameters:
Usage:
stratmap.game.historicEvent("my_event", "my title", "my description")
- stratmap.game.scriptCommand (command, args)
-
Fire any script command available from the game. It is always just 2 parameters in the function, the command name and all the arguments as 1 string in the second parameter.
Do not use inc_counter, set_counter, declare_counter! they crash!
Parameters:
Usage:
stratmap.game.scriptCommand("give_everything_to_faction", "france england false") stratmap.game.scriptCommand("send_character_off_map", "Rufus") -- Multiline commands and using variables in command strings local facName="hre" stratmap.game.scriptCommand("set_faction_banner", string.format([[ faction england banner %s end_set_faction_banner]], facName))
Stratmap
- stratmap
-
Basic stratmap table
Fields:
- objects stratmap.objects
- camera stratmap.camera
- game stratmap.game
Unit
- unit
-
Unit table
Fields:
- eduEntry eduEntry
- movePoints float
- aiActiveSet int 0 means inactive, 1 means active, 2 means labelled unit (for Battle)
- soldierCountStratMap int soldiers count. You can change it on stratmap and soldiers updated. Use setParams if you need change several parameters at once.
- exp int soldiers expierence. You can change it on stratmap and soldiers updated. Use setParams if you need change several parameters at once.
- armourLVL int soldiers armour. You can change it on stratmap and soldiers updated. Use setParams if you need change several parameters at once.
- weaponLVL int soldiers weapon. You can change it on stratmap and soldiers updated. Use setParams if you need change several parameters at once.
- soldierCountStratMapMax int Read only
- soldierCountBattleMap int Read only
- moraleLevel int use moraleStatus enum
- isCloseFormation int
- ID int
- nearbyFriendlyUnitsNum int
- nearbyEnemyUnitsNum int
- missileRange int
- missile projectileStruct
- weaponType int
- techType int
- armourInBattle int
- attackInBattle int
- retrainingSettlement settlementStruct
- unitGroup unitGroup
- fatigue int (battle)
- angle float (battle)
- maxAmmo int (battle)
- currentAmmo int (battle)
- battlePosZ float (battle)
- battlePosX float (battle)
- battlePosY float (battle)
- character character
- unitPositionData unitPositionData
- army stackStruct
- siegeEngineNum int (only infantry and artillery units!)
- kill kill
- setParams setParams change soldierCountStratMap, exp, armourLVL, weaponLVL at one time.
- hasAttribute hasAttribute Check if unit has edu attribute.
- alias string
- hasBattleProperty hasBattleProperty
- setBattleProperty setBattleProperty
- getActionStatus getActionStatus
- isMovingFastSet isMovingFastSet
- setMovingFastSet setMovingFastSet
- isOnWalls isOnWalls
- supplies int
- isEngaged isEngaged
- isUnderFire isUnderFire
- getMountClass getMountClass
- moveToPosition moveToPosition
- immediatePlace immediatePlace
- getFormation getFormation
- attackClosestUnit attackClosestUnit
- attackUnit attackUnit
- deployStakes deployStakes
- changeFormation changeFormation
- halt halt
- moveToOrientation moveToOrientation
- moveRelative moveRelative
- moveToMissileRange moveToMissileRange
- turn turn
- taunt taunt
- useSpecialAbility useSpecialAbility
- getSiegeEngine getSiegeEngine
- attackBuilding attackBuilding
- collectEngine collectEngine
- getNearbyFriendlyUnit getNearbyFriendlyUnit
- getNearbyEnemyUnit getNearbyEnemyUnit
- releaseUnit releaseUnit
- unit:kill ()
-
Kill this unit
Usage:
unit:kill();
- unit:setParams (exp, armor, weapon)
-
Set unit basic parameters
Parameters:
- exp int Experience. Maximum: 9
- armor int Armour level.
- weapon int Weapon Upgrade. Maximum: 1
Usage:
unit:setParams(0,0,0);
- unit:hasAttribute ()
-
Check if unit has edu attribute.
Usage:
local hasAttr = unit:hasAttribute("sea_faring");
- unit:hasBattleProperty (property)
-
Check if unit has guard mode, skirmish or fire at will on.
Parameters:
- property int use enum: unitBattleProperties.guardMode, unitBattleProperties.skirmish, unitBattleProperties.fireAtWill
Returns:
-
bool
hasProperty
Usage:
local hasProp = unit:hasBattleProperty(unitBattleProperties.guardMode);
- unit:setBattleProperty (property, value)
-
Set a unit battle property (guard mode, skirmish or fire at will).
Parameters:
- property int use enum: unitBattleProperties.guardMode, unitBattleProperties.skirmish, unitBattleProperties.fireAtWill
- value bool
Usage:
unit:setBattleProperty(unitBattleProperties.skirmish, true);
- unit:getActionStatus ()
-
Get unit action status in battle ( idling, hiding, ready, reforming, moving, withdrawing, missiles_firing, missiles_reloading, charging, fighting, pursuing, routing, fighting_backs_to_the_walls, running_amok, rallying, dead, leaving_battle, entering_battle, left_battle, go_berserk, taunting, bracing, infighting).
Returns:
-
string
actionStatus
Usage:
local status = unit:getActionStatus();
- unit:isMovingFastSet ()
-
Is unit set to run?
Returns:
-
bool
movingFastSet
Usage:
local isRunning = unit:isMovingFastSet();
- unit:setMovingFastSet (movingFastSet)
-
Toggle unit running.
Parameters:
- movingFastSet bool
Usage:
unit:setMovingFastSet(true);
- unit:isOnWalls ()
-
Is unit on walls?
Returns:
-
bool
isOnWalls
Usage:
local isOnWalls = unit:isOnWalls();
- unit:isEngaged ()
-
Is unit engaged in melee?
Returns:
-
bool
isEngaged
Usage:
local isEngaged = unit:isEngaged();
- unit:isUnderFire ()
-
Is unit under fire?
Returns:
-
bool
isUnderFire
Usage:
local isUnderFire = unit:isUnderFire();
- unit:getMountClass ()
-
Get unit mount class.
Returns:
-
int
mountClass
Usage:
local mountClass = unit:getMountClass();
- unit:getFormation ()
-
Get unit formation type.
Returns:
-
int
formationType
Usage:
local formationType = unit:getFormation();
- unit:moveToPosition (xCoord, yCoord, run)
-
Orders the unit to move to the specified position.
Parameters:
- xCoord float
- yCoord float
- run bool
Usage:
unit:moveToPosition(150, -300, true);
- unit:immediatePlace (xCoord, yCoord, angle, width)
-
Immediately positions the unit at the given location.
Parameters:
- xCoord float
- yCoord float
- angle int
- width int
Usage:
unit:immediatePlace(150, -300, 60, 0);
- unit:attackClosestUnit (angle, run)
-
Searches an arc in front of the unit, and attacks the closest enemy found.
Parameters:
- angle int
- run bool
Usage:
unit:attackClosestUnit(0, true);
- unit:attackUnit (targetUnit, run)
-
Orders the unit to attack another unit.
Parameters:
- targetUnit unit
- run bool
Usage:
unit:attackUnit(target, true);
- unit:deployStakes ()
-
Deploys stakes.
Usage:
unit:deployStakes();
- unit:changeFormation (formationType)
-
Changes the unit's formation.
Parameters:
- formationType int use formationType enum
Usage:
unit:changeFormation();
- unit:halt ()
-
Orders the unit to stop it's orders.
Usage:
unit:halt();
- unit:moveToOrientation (xCoord, yCoord, widthInMen, angle, run)
-
Orders the unit to move to the specified position with a specified rotation and orientation.
Parameters:
- xCoord float
- yCoord float
- widthInMen int
- angle int
- run bool
Usage:
unit:moveToOrientation(150, 105, 100, 60, true);
- unit:moveRelative (xCoord, yCoord, run)
-
Orders the unit to move to the specified position.
Parameters:
- xCoord float
- yCoord float
- run bool
Usage:
unit:moveRelative(150, 105, true);
- unit:moveToMissileRange (targetUnit, run)
-
Orders the attacker to move into missile range of the target.
Parameters:
- targetUnit unit
- run bool
Usage:
unit:moveToMissileRange(targetUnit, true);
- unit:turn (angle, isRelative)
-
Turn to an absolute angle or by an angle relative to it's current rotation.
Parameters:
- angle int
- isRelative bool
Usage:
unit:turn(90, true);
- unit:taunt ()
-
Makes the unit taunt.
Usage:
unit:taunt();
- unit:useSpecialAbility ()
-
Makes the unit perform their special ability.
Usage:
unit:useSpecialAbility();
- unit:getSiegeEngine (index)
-
Get Siege engine.
Parameters:
- index int
Returns:
-
siegeEngineStruct
engine
Usage:
local engine = unit:getSiegeEngine(0);
- unit:attackBuilding (building)
-
Order a unit with appropriate siege equipment to attack an appropriate building (including docking towers/ladders to walls).
Parameters:
- building buildingBattle
Usage:
unit:attackBuilding(building);
- unit:collectEngine (engine)
-
Order an infantry unit to collect an engine (ram/ladder/tower).
Parameters:
- engine siegeEngineStruct
Usage:
unit:collectEngine(engine);
- unit:getNearbyFriendlyUnit (index)
-
Get Nearby friendly unit.
Parameters:
- index int
Returns:
-
unit
nearUnit
Usage:
local nearUnit = unit:getNearbyFriendlyUnit(0);
- unit:getNearbyEnemyUnit (index)
-
Get Nearby Enemy unit.
Parameters:
- index int
Returns:
-
unit
nearUnit
Usage:
local nearUnit = unit:getNearbyEnemyUnit(0);
- unit:releaseUnit ()
-
Set ai active set to on or off depending on if the unit is player controlled.
Usage:
unit:releaseUnit();
Unit Position Data
- unitPositionData
-
Fields:
- engagedUnitsNum int
- unit unit
- isOnWallsCount int (amount of walls
- isInTowerCount int (amount of towers)
- isInGateHouseCount int (amount of gatehouses)
- targetsDone int dont set
- additionalTargetsOverOne int dont set
- targetsToGo int dont set
- hasTargets int dont set
- isHalted int
- combatStatus int use enum: combatStatus
- lastTargetCoord1 float dont set
- lastTargetCoord2 float dont set
- towersUnderFireFromCount int
- unitsUnderFireFromCount int
- getUnitUnderFireFrom getUnitUnderFireFrom
- getEngagedUnit getEngagedUnit
- getTargetUnit getTargetUnit
- unitPositionData:getUnitUnderFireFrom (index)
-
Get unit that is firing at this unit.
Parameters:
- index int
Returns:
-
unit
unit
Usage:
local enemyUnit = unit.unitPositionData:getUnitUnderFireFrom(0);
- unitPositionData:getEngagedUnit (index)
-
Get unit that is fighting this unit in melee.
Parameters:
- index int
Returns:
-
unit
unit
Usage:
local enemyUnit = unit.unitPositionData:getEngagedUnit(0);
- unitPositionData:getTargetUnit ()
-
Get the unit this unit is currently targeting.
Returns:
-
unit
unit
Usage:
local enemyUnit = unit.unitPositionData:getTargetUnit();
Projectile
- projectileStruct
-
Fields:
- name string
- accuracy float
- accuracyVsBuildings float
- accuracyVsTowers float
- damage int
- damageToTroops int
- isBodyPiercing int
- fiery int
- affectedByRain int
Mount
- mountStruct
-
Fields:
- name string
- mountClass int
- radius float
- mass float
- elephantDeadRadius float
- elephantTuskRadius float
EduEntry
- eduEntry
-
Basic eduEntry table
Fields:
- eduType
string
- Get only
- soldier
string
- Get only
- unitCardTga
string
- Get only
- infoCardTga
string
- Get only
- localizedName string
- localizedDescription string
- localizedDescriptionShort string
- index
int
- Get only
- unitCreatedCounter
int
- Get only
- category
int
- Get only
- class
int
- Get only
- categoryClassCombo
int
- Get only
- recruitPriorityOffset int times 4
- crusadingUpkeepModifier int
- aiUnitValuePerSoldier number
- aiUnitValue number
- soldierCount int
- mass float
- width float
- height float
- haveAttributeLegio bool
- moveSpeedMod float
- unitSpacingFrontToBackClose float
- unitSpacingSideToSideClose float
- unitSpacingFrontToBackLoose float
- unitSpacingSideToSideLoose float
- statHealth int
- statHealthAnimal int
- statHeat int
- statScrub int
- statSand int
- statForest int
- statSnow int
- recruitTime int
- recruitCost int
- upkeepCost int
- weaponCost int
- armourCost int
- customBattleCost int
- customBattleIncrease int
- customBattleLimit int
- training int
- discipline int
- canPhalanx int
- morale int
- moraleLocked int
- statFood1 int
- statFood2 int
- ammunition int
- range int
- projectile projectileStruct
- weaponType int
- techType int
- damageType int
- soundType int
- attackMinDelay int
- secAmmunition int
- secRange int
- secProjectile projectileStruct
- secWeaponType int
- secTechType int
- secDamageType int
- secSoundType int
- secAttackMinDelay int
- engineAmmunition int
- engineRange int
- engineProjectile projectileStruct
- engineWeaponType int
- engineTechType int
- engineDamageType int
- engineSoundType int
- engineAttackMinDelay int
- armourMaterial int
- mount mountStruct
- primaryAnim string
- secondaryAnim string
- hasOwnership hasOwnership
- hasAttribute hasAttribute
- setOwnerShip setOwnerShip
- eduType
string
- eduEntry:hasOwnership (factionID)
-
Check if a faction has ownership of this entry.
Parameters:
- factionID int
Returns:
-
bool
hasOwnership
Usage:
local hasOwnership = unit.eduEntry:hasOwnership(2);
- eduEntry:setOwnerShip (factionID, setOwnership)
-
Set if a faction has ownership of this entry.
Parameters:
- factionID int
- setOwnership bool
Usage:
unit.eduEntry:setOwnerShip(2, true);
- eduEntry:hasAttribute (attributeName)
-
Check if the entry has an attribute.
Parameters:
- attributeName string
Returns:
-
bool
hasAttribute
Usage:
local hasAttribute = entry:hasAttribute("sea_faring");
Character
- character
-
characters as they exist on the strategy map - dead characters, wives, children, and off-map characters do not have these fields.
Fields:
- xCoord int
- yCoord int
- namedCharacter namedCharacter
- bodyguards unit
- armyLeaded stackStruct
- armyNotLeaded stackStruct in the stack but not leading it
- inEnemyZOC int
- ambushState int
- regionID int
- isMarkedToKill int can check if the character died before the game updates he is dead like post battle event
- doNotSpendMovePoints int
- movePointsCharacter float
- movePointsModifier float
- movePointsMaxCharacter float
- movePointsMaxArmy float
- movePointsArmy float
- movePoints float sets both army and character move points.
- turnJoinedCrusade int
- numTurnsIdle int
- percentCharacterReligionInRegion float 0 to 1
- popConvertedThisTurn float
- timeInRegion int
- timeWithArmy int for auxiliary generals, not leading general
- crusade crusadeStruct
- currentTurn int
- distanceToCrusadeTarget float
- disbandProgress int
- isCrusadeDisbandActive int
- besiegingSettlement settlementStruct
- besiegingCharacter character
- ability string see descr_hero_abilities.xml
- getTypeID getTypeID
- getTypeName getTypeName
- setTypeID setTypeID
- moveToTile moveToTile
- reposition reposition
- teleport teleport
- diplomacyCharacter diplomacyCharacter
- diplomacySettlement diplomacySettlement
- kill kill
- createFort createFort
- assassinate assassinate
- marry marry
- spyCharacter spyCharacter
- denounce denounce
- bribe bribe
- acquire acquire
- setBodyguardUnit setBodyguardUnit
- setCharacterModel setCharacterModel
- switchFaction switchFaction
- sendOffMap sendOffMap
- sabotage sabotage
- diplomacyFort diplomacyFort
- bribeFort bribeFort
- spyFort spyFort
- bribeSettlement bribeSettlement
- spySettlement spySettlement
- sabotageSettlement sabotageSettlement
- character:getTypeID ()
-
Get the character type. Use characterType enum.
Returns:
-
int
typeId
Usage:
local ourType=ourCharacter:getTypeID();
- character:getTypeName ()
-
Get the character type. Use characterType enum.
Returns:
-
string
type
Usage:
local ourType=ourCharacter:getTypeName();
- character:setTypeID (typeId)
-
Set the character type. Use characterType enum.
Parameters:
- typeId int
Usage:
ourCharacter:setTypeID(2);
- character:moveToTile (xCoord, yCoord)
-
Issue regular move command, character must have movement points.
Parameters:
- xCoord int
- yCoord int
Usage:
ourCharacter:moveToTile(11,25);
- character:diplomacyCharacter (targetChar)
-
Issue diplomacy command.
Parameters:
- targetChar character
Usage:
ourCharacter:diplomacyCharacter(targetChar);
- character:assassinate (targetChar)
-
Issue assassination command.
Parameters:
- targetChar character
Usage:
ourCharacter:assassinate(targetChar);
- character:marry (targetChar)
-
Issue marry command.
Parameters:
- targetChar character
Usage:
ourCharacter:marry(targetChar);
- character:spyCharacter (targetChar)
-
Issue spyCharacter command.
Parameters:
- targetChar character
Usage:
ourCharacter:spyCharacter(targetChar);
- character:denounce (targetChar)
-
Issue denounce command.
Parameters:
- targetChar character
Usage:
ourCharacter:denounce(targetChar);
- character:bribe (targetChar)
-
Issue bribe command.
Parameters:
- targetChar character
Usage:
ourCharacter:bribe(targetChar);
- character:acquire (targetChar)
-
Issue acquire command.
Parameters:
- targetChar character
Usage:
ourCharacter:acquire(targetChar);
- character:sabotage (target)
-
Issue sabotage command.
Parameters:
- target building
Usage:
ourCharacter:sabotage(targetBuilding);
- character:switchFaction (newFac, keepArmy, keepUnit)
-
Switch character faction.
Parameters:
- newFac factionStruct
- keepArmy bool
- keepUnit bool
Usage:
ourCharacter:switchFaction(otherFac, true, true);
- character:diplomacySettlement (targetSettlement)
-
Issue diplomacy command.
Parameters:
- targetSettlement settlementStruct
Usage:
ourCharacter:diplomacySettlement(targetSettlement);
- character:bribeSettlement (targetSettlement)
-
Issue bribe command.
Parameters:
- targetSettlement settlementStruct
Usage:
ourCharacter:bribeSettlement(targetSettlement);
- character:spySettlement (targetSettlement)
-
Issue spy command.
Parameters:
- targetSettlement settlementStruct
Usage:
ourCharacter:spySettlement(targetSettlement);
- character:sabotageSettlement (targetSettlement)
-
Issue sabotage command.
Parameters:
- targetSettlement settlementStruct
Usage:
ourCharacter:sabotageSettlement(targetSettlement);
- character:diplomacyFort (targetFort)
-
Issue diplomacy command.
Parameters:
- targetFort fortStruct
Usage:
ourCharacter:diplomacyFort(targetFort);
- character:bribeFort (targetFort)
-
Issue bribe command.
Parameters:
- targetFort fortStruct
Usage:
ourCharacter:bribeFort(targetFort);
- character:spyFort (targetFort)
-
Issue spy command.
Parameters:
- targetFort fortStruct
Usage:
ourCharacter:spyFort(targetFort);
- character:reposition (xCoord, yCoord)
-
Instantly teleport character to the coordinates, if occupied a random place in the same region is chosen.
Parameters:
- xCoord int
- yCoord int
Usage:
ourCharacter:reposition(11,25);
- character:teleport (xCoord, yCoord)
-
Instantly teleport character to the coordinates, if occupied the closest valid place to the coordinates is chosen.
Parameters:
- xCoord int
- yCoord int
Returns:
-
bool
hasTeleported
Usage:
local success = ourCharacter:teleport(11,25);
- character:kill ()
-
Delete this character
Usage:
ourCharacter:kill();
- character:createFort ()
-
Create a fort at the character's coordinates
Usage:
ourCharacter:createFort();
- character:setBodyguardUnit (unit)
-
Set bodyguard. Do this only for characters without it, such as immediately after creating a character.
Parameters:
- unit unit
Usage:
ourCharacter:setBodyguardUnit(unit);
- character:setCharacterModel (model)
-
Set a character's model to a new one.
Parameters:
- model string
Usage:
ourCharacter:setCharacterModel("saruman");
- character:sendOffMap ()
-
Send a character off map (command will not fire if the general does not have a label, as you wouldn't be able to respawn him). It automatically acounts for the bug relating to sending characters off map that are leading a 1 unit army, by adding and killing a unit.
Usage:
ourCharacter:sendOffMap();
NamedCharacter
- namedCharacter
-
Basic namedCharacter table. All named characters have these fields including dead characters, wives, children, and off-map characters.
Fields:
- index int
- character character
- shortName string Internal name.
- fullName string Internal name including surname.
- localizedDisplayName string Display name, resets upon reloading a save.
- label string
- portrait string Wives (who have never been princesses) and children do not have anything for this field. Path to 'young' portrait used starting from 'mods' folder. Resets upon reloading a save.
- portrait2 string Wives (who have never been princesses) and children do not have anything for this field. Path to 'old' portrait used starting from 'mods' folder. Resets upon reloading a save.
- portrait_custom string Wives (who have never been princesses) and children do not have anything for this field. Folder name in ui/custom_portraits folder.
- modelName string Battle model (needs battle_models.modeldb entry).
- status int 5-leader,2 - heir, 0 - ordinary character, read only, do not set value
- setAsHeir setAsHeir
- isAlive isAlive
- isFamily bool
- isMale bool
- isOffMap isOffMap
- isChild isChild
- age int
- yearOfBirth float For example with 4 turns per year, the yearOfBirth could be 1840.25
- seasonOfBirth int
- yearOfMaturity float
- seasonOfMaturity int
- numberOfChildren int
- faction factionStruct
- subFaction int
- parent namedCharacter
- spouse namedCharacter
- childs namedCharacter[4] Maximum 4.
- getTraits getTraits
- addTrait addTrait
- removeTrait removeTrait
- ancNum int
- getAncillary getAncillary
- addAncillary addAncillary
- removeAncillary removeAncillary
- level int
- authority int
- command int
- chivalryAndDread int positive = Chivalry, negative = Dread
- loyalty int
- piety int
- ambush int
- artilleryCommand int
- assassination int
- attack int
- battleSurgery int
- bodyguardSize int
- bodyguardValour int
- boldness int
- bribeResistance int
- bribery int
- cavalryCommand int
- charm int
- construction int
- defence int
- disposition int
- electability int
- eligibility int
- farming int
- fertility int
- finance int
- footInTheDoor int
- generosity int
- gunpowerCommand int
- health int
- heresyImmunity int
- hitpoints int
- infantryCommand int
- influence int
- law int
- lineOfSight int
- localPopularity int
- looting int
- magic int
- management int
- mining int
- movementPointsBonus int
- navalCommand int
- nightBattle int
- personalSecurity int
- publicSecurity int
- purity int
- sabotage int
- siegeAttack int
- siegeDefense int
- siegeEngineering int
- squalor int
- subterfuge int
- taxCollection int
- trading int
- trainingAgents int
- trainingAnimalUnits int
- trainingUnits int
- troopMorale int
- unorthodoxy int
- unrest int
- violence int
- portraitIndex int
- combatVsReligion int[10] Maximum 10. EVEN IF YOU SET RELIGION LIMIT.
- combatVsFaction int[31] Maximum 31.
- namedCharacter:setAsHeir (onlyHeir)
-
Sets the named character as the faction heir.
Parameters:
- onlyHeir bool True = this character will be the only heir, false = add another heir (faction can appear to have multiple heirs but only one will become leader).
Usage:
ourcharacter:setAsHeir(true)
- namedCharacter:isAlive ()
-
Checks if character is alive, read only, do not set this value.
Returns:
-
bool
liveStatus true = alive, false = dead
Usage:
if ourcharacter:isAlive() == true then ourcharacter.character:kill() end
- namedCharacter:isOffMap ()
-
Checks if character is off map, read only, do not set this value.
Returns:
-
bool
offMap
Usage:
if ourcharacter:isOffMap() == true then --do something end
- namedCharacter:isChild ()
-
Checks if character is child, read only, do not set this value.
Returns:
-
bool
isChild
Usage:
if ourcharacter:isChild() == true then --do something end
- namedCharacter:getTraits ()
-
Get the pointer to the character's traits container.
Returns:
-
traitContainer
The character's traits.
Usage:
local thisTrait, traitsList, index = selectedChar:getTraits(), selectedChar.fullName.." traits:", 0 while thisTrait ~= nil do traitsList, thisTrait, index = traitsList.."\n\tTrait "..index.." - Name: "..thisTrait.name.." - Level: "..thisTrait.level, thisTrait.nextTrait, index + 1 end print(traitsList)
- namedCharacter:addTrait (traitName, traitLevel)
-
Add a trait to the character.
Parameters:
- traitName string Trait's internal name per export_descr_character_traits.txt
- traitLevel int Trait's level.
Usage:
ourNamedCharacter:addTrait("GoodCommander", 2)
- namedCharacter:removeTrait (traitName)
-
Remove a trait from the character.
Parameters:
- traitName string Trait's internal name per export_descr_character_traits.txt
Usage:
ourNamedCharacter:removeTrait("GoodCommander");
- namedCharacter:getAncillary (index)
-
Get the pointer to the ancillary using it's index. You can iterate over a character's ancillaries for example by going from index 0 to ancNum - 1.
Parameters:
- index int
Returns:
-
ancillary
ancillary
Usage:
ancillary = ourNamedCharacter:getAncillary(2)
- namedCharacter:addAncillary (ancillaryName)
-
Add an ancillary to the named character using the name per export_descr_ancillaries.txt.
Parameters:
- ancillaryName string
Usage:
ourNamedCharacter:addAncillary("VeryVeryGoodMan");
- namedCharacter:removeAncillary (ancillary)
-
Remove an ancillary from the named character using it's pointer. Use getAncillary function to get the specific ancillary.
Parameters:
- ancillary ancillary
Usage:
ourAnc=ourNamedCharacter:getAncillary(2); ourNamedCharacter:removeAncillary(ourAnc);
capturedFactionInfo
- capturedFactionInfo
-
Basic capturedFactionInfo table.
Fields:
- targetFactionID int
- factionID int
- namedChar namedCharacter
- targetCharacter namedCharacter
- getCapturedCharacter getCapturedCharacter
- capturedCharactersNum int
- getCapturedUnit getCapturedUnit
- capturedUnitsNum int
- ransomValue int
- capturedFactionInfo:getCapturedUnit (index)
-
Get a captured unit by it's index.
Parameters:
- index int
Returns:
-
capturedUnit
capUnit
Usage:
capUnit = capInfo:getCapturedUnit(0);
- capturedFactionInfo:getCapturedCharacter (index)
-
Get a captured character by it's index.
Parameters:
- index int
Returns:
-
capturedCharacter
capChar
Usage:
capUnit = capInfo:getCapturedCharacter(0);
capturedUnit
- capturedUnit
-
Basic capturedUnit table.
Fields:
- unit unit
- capturedSoldiers int
- capturedValue int
settlementTextStrings
uiString
- uiString
-
Basic uiString table.
Fields:
- thickness int (0-255)
- blue int (0-255)
- green int (0-255)
- red int (0-255)
settlementInfoScroll
- settlementInfoScroll
-
Basic settlementInfoScroll table.
Fields:
- settlement settlementStruct
- getUIStrings getUIStrings
- settlementInfoScroll:getUIStrings ()
-
Get settlement text color info.
Returns:
-
settlementTextStrings
getUIStrings
Usage:
function onScrollOpened(eventData) local settlementInfoScroll = M2TWEOP.getSettlementInfoScroll(); if settlementInfoScroll then settlementInfoScroll:getUIStrings().incomeString.red = 0 settlementInfoScroll:getUIStrings().incomeString.green = 0 settlementInfoScroll:getUIStrings().incomeString.blue = 0 settlementInfoScroll:getUIStrings().incomeString.thickness = 0 settlementInfoScroll:getUIStrings().incomeValue.red = 0 settlementInfoScroll:getUIStrings().incomeValue.green = 0 settlementInfoScroll:getUIStrings().incomeValue.blue = 0 end end
capturedCharacter
- capturedCharacter
-
Basic capturedCharacter table.
Fields:
- namedChar namedCharacter
- capturedValue int
Ancillary
Trait Container
- traitContainer
-
Basic traits table
Fields:
- level int
- name string
- nextTrait traitContainer
- prevTrait traitContainer
- traitInfo traitStruct
Trait Struct
- traitStruct
-
Basic trait table
Fields:
- traitEntry traitEntry
- levelEntry traitLevel
- traitPoints int
Trait Entry Struct
- traitEntry
-
Basic traitEntry table
Fields:
- index int
- name string
- levels traitLevel[10] Maximum: 10
- levelCount int
- antiTraits traitEntry[20] Maximum: 20
- antiTraitCount int
- noGoingBackLevel int
- hidden int
Trait Level Struct
- traitLevel
-
Basic traitLevel table
Fields:
- level int
- threshold int
- effectsCount int
- getTraitEffect getTraitEffect
- traitLevel:getTraitEffect (index)
-
Get trait effect.
Parameters:
- index int
Returns:
-
traitEffect
effect
Usage:
local effect = level:getTraitEffect(0);
Trait Effect Struct
FactionStruct
- factionStruct
-
Basic factionStruct table
Fields:
- factionID int
- getFactionName getFactionName
- cultureID int
- aiPersonalityType int
- aiPersonalityName int
- aiFaction aiFaction
- ai_label string
- name string
- localizedName string
- capital settlementStruct
- leader namedCharacter
- heir namedCharacter
- isPlayerControlled int 0=AI, 1=player
- neighBourFactionsBitmap int
- religion int
- isUndiscovered int
- missionCount int
- freezeFactionAI int
- treasuryTurnStart int
- incomeDoubled int
- battlesWon int
- battlesLost int
- settlementsCaptured int
- settlementsLost int
- otherFactionCount int
- money int
- kingsPurse int
- regionsOwnedStart int
- facStrat factionStratMapStruct
- numOfNamedCharacters int includes literally all characters without distinction (so also wives, children, dead and those sent off map)
- getNamedCharacter getNamedCharacter
- numOfCharacters int includes all the characters present on the strat map
- getCharacter getCharacter
- stacksNum int
- getStack getStack
- settlementsNum int
- getSettlement getSettlement
- fortsNum int
- getFort getFort
- portsNum int
- getPort getPort
- watchtowersNum int
- getWatchtower getWatchtower
- neighBourRegionsNum int
- deleteFort deleteFort
- createFortXY createFortXY
- createWatchtower createWatchtower
- hasMilitaryAccess hasMilitaryAccess
- setMilitaryAccess setMilitaryAccess
- getFactionStanding getFactionStanding
- setFactionStanding setFactionStanding
- getFactionRanking getFactionRanking
- getFactionEconomy getFactionEconomy
- getNeighbourRegionID getNeighbourRegionID
- getBattleVsFactionStats getBattleVsFactionStats
- setCharacterNameFaction setCharacterNameFaction
- isNeighbourFaction isNeighbourFaction
- getAiFactionValues getAiFactionValues
- getInterFactionLTGD getInterFactionLTGD
- splitArmy splitArmy
- factionStruct:getFactionName ()
-
Outdated legacy function. Use faction.name instead.
Returns:
-
string
facName
Usage:
- factionStruct:getNamedCharacter (number)
-
Get named character using it's index.
Parameters:
- number int
Returns:
-
namedCharacter
retNamedCharacter
Usage:
ourNamedCharacter = stratmap.game.getFaction(0):getNamedCharacter(0) if ourNamedCharacter.command > 5 then ourFac.money = ourFac.money - (ourNamedCharacter.command * 10) end
- factionStruct:getCharacter (number)
-
Get a character using it's index.
Parameters:
- number int
Returns:
-
character
retCharacter
Usage:
ourCharacter = stratmap.game.getFaction(0):getCharacter(0) if ourCharacter.xCoord > 150 and ourCharacter.movePoints < 10 then ourCharacter:kill() end
- factionStruct:getStack (number)
-
Get an army using it's index.
Parameters:
- number int
Returns:
-
stackStruct
army
Usage:
function FindArmy(x,y) CAMPAIGN = gameDataAll.get().campaignStruct for i = 1, #CAMPAIGN.numberOfFactions do local faction = CAMPAIGN.factionsSortedByDescrStrat[i] if not faction then return nil end local armiesNum = faction.stacksNum for j = 0, armiesNum - 1 do local army = faction:getStack(j) local x2, y2 = 0, 0 if (army.leader) then x2 = army.leader.xCoord y2 = army.leader.yCoord elseif army:findInSettlement() then x2 = army:findInSettlement().xCoord y2 = army:findInSettlement().yCoord elseif army:findInFort() then x2 = army:findInFort().xCoord y2 = army:findInFort().yCoord elseif army.shipArmy and army.shipArmy.leader then x2 = army.shipArmy.leader.xCoord y2 = army.shipArmy.leader.yCoord else return nil end if (x2 == x and y2 == y) then return army end end end return nil end
- factionStruct:getSettlement (number)
-
Get a settlement using it's index.
Parameters:
- number int
Returns:
-
settlementStruct
settlement
Usage:
ourSett = CAMPAIGN:getFaction("byzantium"):getSettlement(0) if ourSett.isProvokedRebellion ~= 0 then ourFac.money = ourFac.money - (ourSett.level*5000) end
- factionStruct:getFort (number)
-
Get a fort using it's index.
Parameters:
- number int
Returns:
-
fortStruct
fort
Usage:
ourFort = CAMPAIGN:getFaction("byzantium"):getFort(0) if ourFort then print(ourFort.xCoord..", "..ourFort.yCoord) end
- factionStruct:getPort (number)
-
Get a port using it's index.
Parameters:
- number int
Returns:
-
portStruct
port
Usage:
local thisFac, portList = gameDataAll.get().campaignStruct.currentFaction, "Ports:" for i = 0, thisFac.portsNum - 1, 1 do local thisPort = thisFac:getPort(i) local thisDock = thisPort.dock portList = portList.."\n\t"..i.." "..thisPort.settlement.name.." ("..thisPort.xCoord..", "..thisPort.yCoord..") " if thisDock then portList = portList.."\n\t\tDock: ("..thisDock.xCoord..", "..thisDock.yCoord..")" end end print(portList)
- factionStruct:getWatchtower (number)
-
Get a watchtower using it's index.
Parameters:
- number int
Returns:
-
watchtowerStruct
watchtower
Usage:
local thisFac, watchtowerList = gameDataAll.get().campaignStruct.currentFaction, "Watchtowers:" for i = 0, thisFac.watchtowersNum - 1, 1 do local thisTower = thisFac:getWatchtower(i) watchtowerList = watchtowerList.."\n\t"..i.." ("..thisTower.xCoord..", "..thisTower.yCoord..") " end print(watchtowerList)
- factionStruct:deleteFort (fort)
-
Delete a specific fort.
Parameters:
- fort fortStruct
Usage:
fac:deleteFort(someFort)
- factionStruct:createFortXY (X, Y)
-
Create a fort at the specified coordinates.
Parameters:
- X int
- Y int
Usage:
fac:createFortXY(193, 283)
- factionStruct:createWatchtower (X, Y)
-
Create a watchtower at the specified coordinates.
Parameters:
- X int
- Y int
Returns:
-
watchtowerStruct
watchTower
Usage:
fac:createWatchtower(193, 283)
- factionStruct:hasMilitaryAccess (targetFaction)
-
Check if a faction has military access to another faction.
Parameters:
- targetFaction factionStruct
Returns:
-
bool
hasMilitaryAccess
Usage:
local hasAccess = fac:hasMilitaryAccess(targetFac)
- factionStruct:setMilitaryAccess (targetFaction, hasMilitaryAccess)
-
Set if a faction has military access to another faction.
Parameters:
- targetFaction factionStruct
- hasMilitaryAccess bool
Usage:
fac:setMilitaryAccess(targetFac, true)
- factionStruct:getFactionStanding (targetFaction)
-
Get the faction standing between 2 factions (a faction with itself returns global standing).
Parameters:
- targetFaction factionStruct
Returns:
-
float
factionStanding
Usage:
local standing = fac:getFactionStanding(targetFac)
- factionStruct:setFactionStanding (targetFaction, factionStanding)
-
Set the faction standing between 2 factions (a faction with itself sets global standing).
Parameters:
- targetFaction factionStruct
- factionStanding float
Usage:
fac:setFactionStanding(targetFac, 0.5)
- factionStruct:getFactionRanking (turnNumber)
-
Get the faction ranking scores.
Parameters:
- turnNumber int
Returns:
-
factionRanking
factionRanking
Usage:
local rankings = fac:getFactionRanking(30)
- factionStruct:getFactionEconomy (turnsAgo)
-
Get the faction ecomomy table, specified number of turns ago (max 10).
Parameters:
- turnsAgo int
Returns:
-
factionEconomy
factionEconomy
Usage:
local economyTable = fac:getFactionEconomy(0)
- factionStruct:isNeighbourFaction (targetFaction)
-
Check if 2 factions are neighbours.
Parameters:
- targetFaction factionStruct
Returns:
-
bool
isNeighbour
Usage:
local isNeighbour = fac:isNeighbourFaction(targetFac)
- factionStruct:getNeighbourRegionID (index)
-
Get a region ID of a neighbouring region by index.
Parameters:
- index int
Returns:
-
int
nRegionID
Usage:
local nRegionID = fac:getNeighbourRegionID(0)
- factionStruct:getBattleVsFactionStats (targetFactionID)
-
Get stats versus a specific other faction.
Parameters:
- targetFactionID int
Returns:
-
battleFactionCounter
battleStats
Usage:
local battleStats = fac:getBattleVsFactionStats(2)
- factionStruct:getAiFactionValues ()
-
Get various statistics the long term goal director uses.
Returns:
-
aiFactionValues
aiFactionValues
Usage:
local aiFacValues = fac:getAiFactionValues()
- factionStruct:getInterFactionLTGD (targetFaction)
-
Get various statistics the long term goal director uses versus a target faction.
Parameters:
- targetFaction factionStruct
Returns:
-
interFactionLTGD
interFactionLTGD
Usage:
local iLTGD = fac:getInterFactionLTGD(targetFac)
- factionStruct:setCharacterNameFaction (characterTypeIndex, factionID)
-
Set the faction characters of a specific type draw their names from.
Parameters:
- characterTypeIndex int
- factionID int
Usage:
fac:setCharacterNameFaction(characterType.spy, 2)
- factionStruct:splitArmy (units, targetX, targetY)
-
Split an army.
Parameters:
- units table
- targetX int
- targetY int
Usage:
local units = {} for i = 0, myStack.unitsNum / 2 - 1 do table.insert(units, myStack:getUnit(i)) end fac:splitArmy(units, 154, 84)
aiFaction
- aiFaction
-
Basic aiFaction table
Fields:
- faction factionStruct
- factionID int
- LTGD aiLongTermGoalDirector
- aiPersonality aiPersonality
aiLongTermGoalDirector
- aiLongTermGoalDirector
-
Basic aiLongTermGoalDirector table
Fields:
- faction factionStruct
- aiFaction aiFaction
- trustedAllyEnemiesBitfield int
- freeStrengthEnemy int
- freeStrengthEnemyBalance int
- consideringNavalInvasion int
- navalTargetRegionID int
- navalTargetRegionPriority int
- getlongTermGoalValues getlongTermGoalValues
- aiLongTermGoalDirector:getlongTermGoalValues (targetFactionID)
-
Get long term goal director values versus a specific other faction.
Parameters:
- targetFactionID int
Returns:
-
decisionValuesLTGD
longTermGoalValues
Usage:
local longTermGoalValues = LTGD:getlongTermGoalValues(2)
decisionValuesLTGD
- decisionValuesLTGD
-
Basic decisionValuesLTGD table
Fields:
- defendType int
- defendPriority int
- invasionType int
- invadePriority int
- atWar int
- wantPeace int
- wantAlly int
- forceInvade int
- wantBeProtect int
- wantOfferProtect int
- allianceAgainst int
- ptsDesire int
- ptsAlliance int
- pointsInvasion int
- pointsDefense int
- canForceInvade int
aiFactionValues
- aiFactionValues
-
Basic aiFactionValues table
Fields:
- totalPopulation int
- tileCount int
- averagePopulation int
- productionValue int
- nonAlliedBorderLength int
- enemyBorderLength int
- fleetCount int
- navalPowerPerFleet int
- navalStrength int
- armyCount int
- strengthPerArmy int
- totalStrength int
- freeStrength int
- neighbourEnemyNum int
- enemyStrength int
- protectorateOf int
interFactionLTGD
- interFactionLTGD
-
Basic interFactionLTGD table
Fields:
- borderTiles int
- frontLineBalance int
- hasAllianceAgainst int
- isStrongestNeighbour int
- isWeakestNeighbour int
aiPersonality
- aiPersonality
-
Basic aiPersonality table
Fields:
- aiFaction aiFaction
- aiProductionControllersNum int
- aiPersonalityType int
- aiPersonalityName int
- spyBias int
- assassinBias int
- diplomatBias int
- admiralBias int
- priestBias int
- merchantBias int
- balancedPolicyNum int
- financialPolicyNum int
- militaryPolicyNum int
- growthPolicyNum int
- culturalPolicyNum int
- setConstructionValue setConstructionValue
- setRecruitmentValue setRecruitmentValue
- getConstructionValue getConstructionValue
- getRecruitmentValue getRecruitmentValue
- getProductionController getProductionController
- aiPersonality:setConstructionValue (type, value)
-
Set bias value of the ai personality for a capability.
Parameters:
- type int use building capabilities enum
- value int
Usage:
aiPersonality:setConstructionValue(buildingCapability.law_bonus, 100)
- aiPersonality:setRecruitmentValue (type, value)
-
Set bias value of the ai personality for a recruitment class.
Parameters:
- type int use unitCategoryClass enum
- value int
Usage:
aiPersonality:setRecruitmentValue(unitCategoryClass.heavyCavalry, 100)
- aiPersonality:getConstructionValue (type)
-
Get bias value of the ai personality for a capability.
Parameters:
- type int use building capabilities enum
Returns:
-
int
value
Usage:
local value = aiPersonality:getConstructionValue(buildingCapability.law_bonus)
- aiPersonality:getRecruitmentValue (type)
-
Get bias value of the ai personality for a recruitment class.
Parameters:
- type int use unitCategoryClass enum
Returns:
-
int
value
Usage:
local value = aiPersonality:getRecruitmentValue(unitCategoryClass.heavyCavalry)
- aiPersonality:getProductionController (index)
-
Get a production controller by index.
Parameters:
- index int
Returns:
-
aiProductionController
controller
Usage:
local prodController = aiPersonality:getProductionController(0)
aiProductionController
- aiProductionController
-
Basic aiProductionController table
Fields:
- aiFaction aiFaction
- regionID int
- settlement settlementStruct
- autoManagePolicy int
- isAutoManaged int
- isAutoManagedRecruitment int
- isAutoManagedConstruction int
- spyBias int
- assassinBias int
- diplomatBias int
- admiralBias int
- priestBias int
- merchantBias int
- setConstructionValue setConstructionValue
- setRecruitmentValue setRecruitmentValue
- getConstructionValue getConstructionValue
- getRecruitmentValue getRecruitmentValue
- aiProductionController:setConstructionValue (type, value)
-
Set bias value of the ai personality for a capability.
Parameters:
- type int use building capabilities enum
- value int
Usage:
aiProductionController:setConstructionValue(buildingCapability.law_bonus, 100)
- aiProductionController:setRecruitmentValue (type, value)
-
Set bias value of the ai personality for a recruitment class.
Parameters:
- type int use unitCategoryClass enum
- value int
Usage:
aiProductionController:setRecruitmentValue(unitCategoryClass.heavyCavalry, 100)
- aiProductionController:getConstructionValue (type)
-
Get bias value of the ai personality for a capability.
Parameters:
- type int use building capabilities enum
Returns:
-
int
value
Usage:
local value = aiProductionController:setConstructionValue(buildingCapability.law_bonus)
- aiProductionController:getRecruitmentValue (type)
-
Get bias value of the ai personality for a recruitment class.
Parameters:
- type int use unitCategoryClass enum
Returns:
-
int
value
Usage:
local value = aiProductionController:setRecruitmentValue(unitCategoryClass.heavyCavalry)
battleFactionCounter
holdRegionsWinCondition
- holdRegionsWinCondition
-
Basic holdRegionsWinCondition table
Fields:
- regionsToHoldCount int
- numberOfRegions int
- getRegionToHoldName getRegionToHoldName
- getRegionToHoldLength getRegionToHoldLength
- holdRegionsWinCondition:getRegionToHoldName (index)
-
Get the name of the region that has to be held to win the campaign.
Parameters:
- index int
Returns:
-
string
regionName
Usage:
local regionName = fac.winCondition:getRegionToHoldName(0)
- holdRegionsWinCondition:getRegionToHoldLength (index)
-
Get the number of turns the region has to be held to win the campaign.
Parameters:
- index int
Returns:
-
int
turnsToHold
Usage:
local turnsToHold = fac.winCondition:getRegionToHoldLength(0)
FactionEconomy
- factionEconomy
-
Basic factionEconomy table
Fields:
- farmingIncome int
- taxesIncome int
- miningIncome int
- tradeIncome int
- merchantIncome int
- constructionIncome int
- otherIncome1 int
- otherIncome2 int
- diplomacyIncome int
- tributesIncome int
- adminIncome int
- kingsPurseIncome int
- wagesExpense int
- upkeepExpense int
- constructionExpenseBuildings int
- constructionExpenseField int
- recruitmentExpenseBuildings int
- recruitmentExpenseMercs int
- corruptionExpense int
- diplomacyExpense int
- tributesExpense int
- otherExpense1 int
- otherExpense2 int
- devastationExpense int
FactionRankings
- factionRanking
-
Basic factionRanking table
Fields:
- totalRankingScore float
- militaryRankingScore float
- productionRankingScore float
- territoryRankingScore float
- financialRankingScore float
- populationRankingScore float
FactionStratMapStruct
- factionStratMapStruct
-
Basic factionStratMapStruct table
Fields:
- primaryColorRed int Warning: resets on reload.
- primaryColorGreen int Warning: resets on reload.
- primaryColorBlue int Warning: resets on reload.
- secondaryColorRed int Warning: resets on reload.
- secondaryColorGreen int Warning: resets on reload.
- secondaryColorBlue int Warning: resets on reload.
- triumphValue int Usage unknown.
- religionID int
- standardIndex int Warning: resets on reload.
- logoIndex int Warning: resets on reload.
- smallLogoIndex int Warning: resets on reload.
- customBattleAvailability int
- periodsUnavailableInCustomBattle int
- canSap int shouldnt do anything in med 2, but could potentially use flag to store some other info about this faction
- prefersNavalInvasions int
- canHavePrincess int
- hasFamilyTree int
- teutonic int
- disbandToPools int
- canBuildSiegeTowers int
- canTransmitPlague int
- shadowedByID int
- shadowingID int
- spawnsOnRevoltID int
- roman int
- barbarian int
- eastern int
- slave int
- hordeMinUnits int
- hordeMaxUnits int
- reductionPerHorde int
- hordeUnitPerSettlementPop int
- hordeMinNamedCharacters int
- hordeMaxPercentArmyStack int
WatchtowerStruct
- watchtowerStruct
-
Basic watchtowerStruct table
Fields:
- xCoord int
- yCoord int
- factionID int
- regionID int
- faction factionStruct
- settlement settlementStruct
- blockingArmy stackStruct
FortStruct
- fortStruct
-
Basic fortStruct table
Fields:
- xCoord int
- yCoord int
- governor character
- army stackStruct
- ownerFaction factionStruct
- siegeNum int
- siegeHoldoutTurns int
- turnsSieged int
- plagued int
- subFactionID int
- factionID int
- regionID int
- cultureID int
- gatesAreOpened int
- fortFortificationLevel int
- getSiege getSiege
- changeFortOwner changeFortOwner
- fortStruct:getSiege (siegeIdx)
-
Get a specific siege by it's index
Parameters:
- siegeIdx int
Returns:
-
siegeStruct
siege
Usage:
for i = 0, currSet.siegesNum-1 do local siege=currFort:getSiege(i); --etc end
- fortStruct:changeFortOwner (newFaction, convertGarrison)
-
Change fort ownership.
Parameters:
- newFaction factionStruct
- convertGarrison bool
Usage:
myFort:changeFortOwner(otherFac, true)
PortStruct
- portStruct
-
Basic portStruct table
Fields:
- xCoord int land tile, Note: setting this only moves port's strat model.
- yCoord int land tile, Note: setting this only moves port's strat model.
- ownerFaction factionStruct Note: port's ownership changes to blockading faction (army on port)
- settlement settlementStruct
- regionID int
- cultureID int
- numTurnsBlocked int
- blockadingArmy stackStruct Enemy army blockading the port, by standing on it's tile, check for nil.
- dock dockStruct water tile, only upgraded ports have this, check for nil.
DockStruct
- dockStruct
-
Basic dockStruct table
Fields:
- xCoord int water tile, Note: setting only moves dock strat model
- yCoord int water tile, Note: setting only moves dock strat model
- regionID int
- ownerFaction factionStruct Note: port's ownership changes to blockading faction (army on port)
- settlement settlementStruct
- cultureID int
- numTurnsBlocked int
- port portStruct
- dockedArmy stackStruct
SettlementStruct
- settlementStruct
-
Basic settlementStruct table
Fields:
- xCoord int
- yCoord int
- governor character
- army stackStruct
- name string internal name of settlement
- localizedName string
- ownerFaction factionStruct
- changeOwner changeOwner
- creatorFactionID int
- regionID int
- level int
- isCastle int
- siegeHoldoutTurns int
- turnsSieged int
- subFactionID int
- yearFounded int
- isCapital int
- harvestSuccess int
- baseFertility int
- rebelFactionChance int
- plagued int
- plagueDeaths int
- turnsOwned int start at 10 for settlements owned at game start without specification in descr_strat
- populationSiegeStart int
- settlementTaxLevel int
- recruitmentPoolCount int
- recruitmentCapabilityNum int
- freezeRecruitmentPool int
- spiesInRecruitmentQueue int
- assassinsInRecruitmentQueue int
- diplomatsInRecruitmentQueue int
- admiralsInRecruitmentQueue int
- merchantsInRecruitmentQueue int
- priestsInRecruitmentQueue int
- aiProductionController aiProductionController
- turmoil int
- gatesAreOpened int
- isProvokedRebellion int
- populationSize int
- getReligion getReligion
- setReligion setReligion
- getGuildStanding getGuildStanding
- setGuildStanding setGuildStanding
- buildingsNum int
- getBuilding getBuilding
- createBuilding createBuilding
- destroyBuilding destroyBuilding
- buildingsQueue buildingsQueue
- resourcesNum int
- settlementStats settlementStats
- settlementStatsLastTurn settlementStats
- getResource getResource
- siegesNum int
- getSiege getSiege
- getSettlementCapability getSettlementCapability
- getAgentCapability getAgentCapability
- getAgentLimitCapability getAgentLimitCapability
- getRecruitmentCapability getRecruitmentCapability
- getSettlementRecruitmentPool getSettlementRecruitmentPool
- upgrade upgrade
- getConstructionOptions getConstructionOptions
- getRecruitmentOptions getRecruitmentOptions
- settlementStruct:changeOwner (newOwner, convertGarrison)
-
Change owner faction of settlement. All agents, armies etc. leave the settlement.
Parameters:
- newOwner factionStruct Faction to change ownership to.
- convertGarrison bool
Usage:
local campaign=gameDataAll.get().campaignStruct; local fac1=campaign.factionsSortedByDescrStrat[1]; currSet:changeOwner(fac1); end
- settlementStruct:getReligion (religionID)
-
Get the settlement's specific regligion's value
Parameters:
- religionID int In order of descr_religions.txt, starting from 0
Returns:
-
float
religionValue from 0 to 1
Usage:
local firstRelVal = settlementStruct:getReligion(0) --get float of religion with ID 0
- settlementStruct:setReligion (religionID, religionValue)
-
Set the settlement's specific religion's value, make sure the sum of all religion values does not exceed 1.0!
Parameters:
- religionID int in order of descr_religions.txt, starting from 0
- religionValue float from 0 to 1
Usage:
settlementStruct:setReligion(0, 0.5) --set religion with ID 0 as 50%
- settlementStruct:getGuildStanding (guild_id)
-
Get a settlement's standing points with a specific guild by ID
Parameters:
- guild_id int
Usage:
ourGuildStanding = settlementStruct:getGuildStanding(0)
- settlementStruct:setGuildStanding (guild_id, standing)
-
Set the settlement's standing points with specific guild.
Parameters:
- guild_id int
- standing int
Usage:
settlementStruct:setGuildStanding(0, 300)
- settlementStruct:getBuilding (number)
-
Get a specific building by it's index.
Parameters:
- number int
Returns:
-
building
build
Usage:
ourBuilding=settlementStruct:getBuilding(0); if(ourBuilding.level>1) then print("test"); end
- settlementStruct:createBuilding (building_level_id)
-
Create a building in the settlement.
Parameters:
- building_level_id string
Usage:
settlementStruct:createBuilding("some_build1");
- settlementStruct:destroyBuilding (typeName, isReturnMoney)
-
Destroy a building of a specified type in the settlement.
Parameters:
- typeName string Type of building.
- isReturnMoney bool Should money be returned to the faction like with a manual desctruction.
Usage:
settlementStruct:destroyBuilding("some_buildType",false);
- settlementStruct:getResource (number)
-
Get a specific resource by it's index.
Parameters:
- number int
Returns:
-
tradeResource
resource
Usage:
ourResource = settlementStruct:getResource(0)
- settlementStruct:getSiege (siegeIdx)
-
Get a specific siege by it's index
Parameters:
- siegeIdx int
Returns:
-
siegeStruct
siege
Usage:
for i = 0, currSet.siegesNum-1 do local siege=currSet:getSiege(i); --etc end
- settlementStruct:getSettlementCapability (capabilityType)
-
Get a capability by capability type.
Parameters:
- capabilityType int
Returns:
-
settlementCapability
capability
Usage:
local incomeBonus = settlementStruct:getSettlementCapability(55)
- settlementStruct:getAgentCapability (agentType)
-
Get an agent capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest.
Parameters:
- agentType int
Returns:
-
settlementCapability
capability
Usage:
local spyCap = settlementStruct:getAgentCapability(0)
- settlementStruct:getAgentLimitCapability (agentType)
-
Get an agent limit capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest.
Parameters:
- agentType int
Returns:
-
settlementCapability
capability
Usage:
local spyCapLimit = settlementStruct:getAgentLimitCapability(0)
- settlementStruct:getRecruitmentCapability (index)
-
Get a recruitment capability by index (max 64!).
Parameters:
- index int
Returns:
-
recruitmentCapability
capability
Usage:
local capability = settlementStruct:getRecruitmentCapability(0)
- settlementStruct:getSettlementRecruitmentPool (index)
-
Get a recruitment pool by index.
Parameters:
- index int
Returns:
Usage:
local pool = settlementStruct:getSettlementRecruitmentPool(0)
- settlementStruct:upgrade ()
-
Upgrade a settlement to the next level.
Usage:
settlement:upgrade()
- settlementStruct:getConstructionOptions ()
-
Get available construction items.
Returns:
-
constructionOptions
options
Usage:
local items = settlement:getConstructionOptions()
- settlementStruct:getRecruitmentOptions ()
-
Get available recruitment items.
Returns:
-
recruitmentOptions
options
Usage:
local items = settlement:getRecruitmentOptions()
construction options
- constructionOptions
-
Basic constructionOptions table
Fields:
- buildingNum int
- totalCost int
- totalTime int
- getConstructionOption getConstructionOption
- constructionOptions:getConstructionOption (index)
-
Get an available construction item.
Parameters:
- index int
Returns:
-
buildingInQueue
building
Usage:
local building = constructionOptions:getConstructionOption(0)
recruitment options
- recruitmentOptions
-
Basic recruitmentOptions table
Fields:
- unitNum int
- totalCost int
- totalTime int
- getRecruitmentOption getRecruitmentOption
- recruitmentOptions:getRecruitmentOption (index)
-
Get an available recruitment item.
Parameters:
- index int
Returns:
-
unitInQueue
item
Usage:
local item = recruitmentOptions:getRecruitmentOption(0)
unit in queue
- unitInQueue
-
Basic unitInQueue table
Fields:
- recruitType int 0 = normal, 1 = ship, 2 = agent, 3 = retraining 4 = retraining ship
- experience int
- armourUpg int
- weaponUpg int
- eduEntry eduEntry
- agentType int
- soldierCount int
- cost int
- recruitTime int
- turnsTrained int
- settlement settlementStruct
- turnNumber int
- isMercenary int
- addUnitToQueue addUnitToQueue
- unitInQueue:addUnitToQueue ()
-
Add a unit to the recruitment queue.
Returns:
-
bool
success
Usage:
unitOption:addUnitToQueue()
settlementStats
- settlementStats
-
Basic settlementStats table
Fields:
- PopGrowthBaseFarm
int
- Get only
- population int
- PopGrowthFarms
int
- Get only
- PopGrowthHealth
int
- Get only
- PopGrowthBuildings
int
- Get only
- PopGrowthTaxBonus
int
- Get only
- PopGrowthEntertainment
int
- Get only
- PopGrowthTrade
int
- Get only
- PopGrowthGovernorInfluence
int
- Get only
- PopGrowthSqualor
int
- Get only
- PopGrowthPlague
int
- Get only
- PopGrowthTaxPenalty
int
- Get only
- PublicOrderGarrison
int
- Get only
- PublicOrderLaw
int
- Get only
- PublicOrderBuildingsEntertainment
int
- Get only
- PublicOrderGovernorInfluence
int
- Get only
- PublicOrderTaxBonus
int
- Get only
- PublicOrderTriumph
int
- Get only
- PublicOrderPopulationBoom
int
- Get only
- PublicOrderEntertainment
int
- Get only
- PublicOrderHealth
int
- Get only
- PublicOrderGarrisonTwo
int
- Get only
- PublicOrderFear
int
- Get only
- PublicOrderGlory
int
- Get only
- PublicOrderSqualor
int
- Get only
- PublicOrderDistanceToCapital
int
- Get only
- PublicOrderNoGovernance
int
- Get only
- PublicOrderTaxPenalty
int
- Get only
- PublicOrderUnrest
int
- Get only
- PublicOrderBesieged
int
- Get only
- PublicOrderBlockaded
int
- Get only
- PublicOrderCulturalUnrest
int
- Get only
- PublicOrderExcommunication
int
- Get only
- PublicOrder
int
- Get only
- FarmsIncome
int
- Get only
- TaxesIncome
int
- Get only
- MiningIncome
int
- Get only
- TradeIncome
int
- Get only
- DiplomaticIncome
int
- Get only
- DemolitionIncome
int
- Get only
- LootingIncome
int
- Get only
- BuildingsIncome
int
- Get only
- AdminIncome
int
- Get only
- ConstructionExpense
int
- Get only
- RecruitmentExpense
int
- Get only
- DiplomaticExpense
int
- Get only
- CorruptionExpense
int
- Get only
- EntertainmentExpense
int
- Get only
- DevastationExpense
int
- Get only
- TotalIncomeWithoutAdmin
int
- Get only
- majorityReligionID int
- PopGrowthBaseFarm
int
settlementCapability
recruitmentCapability
- recruitmentCapability
-
Basic recruitmentCapability table
Fields:
- eduIndex int
- xp int
- initialSize float
- replenishRate float
- maxSize float
settlementRecruitmentPool
- settlementRecruitmentPool
-
Basic settlementRecruitmentPool table
Fields:
- eduIndex int
- availablePool float
Building
- building
-
Basic building table
Fields:
- level int
- hp int
- factionID int
- settlement settlementStruct
- edbEntry edbEntry
- getType getType
- getName getName
- building:getType ()
-
Get the name of the building type (the building chain in export_descr_buildings.txt).
Returns:
-
string
buildingType (building chain name)
Usage:
if building:getType() == "core_building" then --do stuff end
- building:getName ()
-
Get name of building level (as per export_descr_buildings.txt).
Returns:
-
string
buildingName
Usage:
if building:getName() == "large_stone_wall" then --do stuff end
BuildingsQueue
- buildingsQueue
-
Basic buildingsQueue table
Fields:
- currentlyBuilding int position in queue of building currently under construction, usually 1
- numBuildingsInQueue int maximum is 6
- getBuildingInQueue getBuildingInQueue by position in queue (1-6)
- buildingsQueue:getBuildingInQueue (position)
-
Get building in queue by position
Parameters:
- position int
Returns:
-
buildingInQueue
buildingInQueue
Usage:
if ourQueue.numBuildingsInQueue > 0 then local result = "ourQueue:\n\t" for i = 1, ourQueue.numBuildingsInQueue, 1 do local ourQueueBuld = ourQueue:getBuildingInQueue(i) result = result..i.." "..ourQueueBuld:getQueueBuildingName().."\n\t" end print(result) end
BuildingInQueue
- buildingInQueue
-
Basic buildingInQueue table
Fields:
- building building Is nil if building doesn't exist yet.
- settlement settlementStruct
- currentLevel int
- edbEntry edbEntry
- constructionType int 0 = upgrade, 1 = normal, 4 = convert settlement
- previousLevel int
- buildCost int
- buildTurnsPassed int
- buildTurnsRemaining int
- percentBuilt int
- getQueueBuildingType getQueueBuildingType
- getQueueBuildingName getQueueBuildingName
- addBuildingToQueue addBuildingToQueue
- buildingInQueue:getQueueBuildingType ()
-
Get name of building in queue type (chain)
Returns:
-
string
buildingType (building chain name)
Usage:
if ourQueueBld:getQueueBuildingType() = "core_building" then --do stuff end
- buildingInQueue:getQueueBuildingName ()
-
Get name of building in queue level
Returns:
-
string
buildingName
Usage:
if ourQueueBld:getQueueBuildingName() = "wooden_pallisade" then --do stuff end
- buildingInQueue:addBuildingToQueue ()
-
Add a building to the construction queue.
Returns:
-
bool
success
Usage:
build:addBuildingToQueue()
Guild
- guild
-
Basic guild table
Fields:
- name string
- id int
- level1 int
- level2 int
- level3 int
TradeResource
- tradeResource
-
Basic tradeResource table
Fields:
- xCoord int
- yCoord int
- regionID int
- resourceID int
- settlement settlementStruct
- setStratModel setStratModel
- getResourceID getResourceID
- getResourceValue getResourceValue
- getResourceHasMine getResourceHasMine
- getResourceImage getResourceImage
- tradeResource:setStratModel (modelId)
-
Set the resource's strat model.
Parameters:
- modelId int Added with stratmap.objects.addModelToGame
Usage:
tradeResource:setStratModel(5);
- tradeResource:getResourceID ()
-
Get the resource's ID.
Returns:
-
int
ID
Usage:
-- if tradeResource:getResourceID() == resourceType.wool then --wool --do stuff end
- tradeResource:getResourceValue ()
-
Get the resource's trade value.
Returns:
-
int
value
Usage:
if tradeResource:getResourceValue() == 5 then --do stuff end
- tradeResource:getResourceHasMine ()
-
Check if the resource has a mine.
Returns:
-
int
hasMine 0=no mine, 1=mine
Usage:
if tradeResource:getResourceHasMine() == 1 then --do stuff end
- tradeResource:getResourceImage ()
-
Get the resource's image (icon) relative path.
Returns:
-
string
imagePath
Usage:
function onSettlementSelected(eventData) local selectedSett = eventData.settlement local resList = "" for i = 0, selectedSett.resourcesNum - 1, 1 do local thisRes = selectedSett:getResource(i) resList = resList.."Resource ID: "..thisRes:getResourceID().."\n\t("..thisRes.xCoord..", "..thisRes.yCoord..")\n\tTrade Value: "..thisRes:getResourceValue().."\n\thasMine: "..thisRes:getResourceHasMine().."\n\timage: "..thisRes:getResourceImage().."\n\n" end print(selectedSett.name.." resource list\n\n"..resList) end
StackStruct
- stackStruct
-
Basic stackStruct table
Fields:
- faction factionStruct
- getUnit getUnit
- numOfUnits int
- deadUnitsNum int
- isAdmiral int
- ladders int
- rams int
- towers int
- getCharacter getCharacter
- numOfCharacters int Includes Auxiliary generals and agents (i.e all characters excluding the leading general)
- boardedArmy stackStruct army embarked on this fleet stack
- shipArmy stackStruct fleet that this army stack is embarked on
- blockedPort dockStruct
- leader character Returns nil if stack is inside residence (fleet, settlement, fort).
- findInSettlement findInSettlement
- findInFort findInFort
- totalStrength int
- subFactionID int
- regionID int
- totalStrengthStart int
- alliance int
- isHalfDestroyed int
- generalBattleCommand int
- generalCommandRadius number
- commandingArmy stackStruct if not leading army but reinforcement
- commandingArmyThatGivesCommands stackStruct reinforcement and listening to player commands
- inBattle int
- maxGroups int
- reform_point_x float X coordinate to which the retreating units will go.
- reform_point_y float Y coordinate to which the retreating units will go.
- createEOPUnit createEOPUnit
- createUnit createUnit
- sortStack sortStack
- mergeArmies mergeArmies
- createUnitByIDX createUnitByIDX
- siegeSettlement siegeSettlement
- siegeFort siegeFort
- blockadePort blockadePort
- attackArmy attackArmy
- getGroup getGroup
- siege siegeStruct Current siege.
- defineUnitGroup defineUnitGroup
- getDeadUnit getDeadUnit
- setAiActiveSet setAiActiveSet
- releaseUnits releaseUnits
- buildWatchTower buildWatchTower
- stackStruct:sortStack (sortMode, sortMode2, sortMode3)
-
Sort units in a stack. Use the sortType enum to specify the sorting mode.
Parameters:
- sortMode int
- sortMode2 int
- sortMode3 int
Usage:
function onFactionTurnStart(eventData) local faction = eventData.faction -- If it's not the players turn, don't sort if faction.isPlayerControlled == 0 then return end; function onFactionTurnStart(eventData) CAMPAIGN = gameDataAll.get().campaignStruct local faction = eventData.faction -- If it's not the players turn, don't sort if faction.isPlayerControlled == 0 then return end; -- Sort all the stacks on the map right before the turn starts local factionsNum = CAMPAIGN.numberOfFactions; for i = 1, #factionsNum do local fac = CAMPAIGN.factionsSortedByDescrStrat[i]; for j = 0, fac.stacksNum - 1 do local stack = fac:getStack(j); if stack then -- Sort the stack by category + class, then by soldier count, then by experience stack:sortStack(sortType.categoryClass, sortType.soldierCount, sortType.experience) end end end end
- stackStruct:getUnit (number)
-
Get a unit by it's index.
Parameters:
- number int
Returns:
-
unit
retUnit
Usage:
ourUnit=stackStruct:getUnit(0); ourUnit:kill();
- stackStruct:getCharacter (number)
-
Get a character (agent or non-leading named character) by it's index.
Parameters:
- number int
Returns:
-
character
retCharacter
Usage:
ourChar=stackStruct:getCharacter(0); ourChar:kill();
- stackStruct:findInSettlement ()
-
Find the settlement in which the army is located. Returns nil if the army is not in a settlement.
Returns nil if the army is not in the settlement.
Returns:
-
settlementStruct
settlement
Usage:
ourSett=stackStruct:findInSettlement(); if(ourSett~=nil) then --something end
- stackStruct:findInFort ()
-
Find the fort in which the army is located. Returns nil if the army is not in a fort.
Returns nil if the army is not in the fort.
Returns:
-
fortStruct
fort
Usage:
ourFort=stackStruct:findInFort(); if(ourFort~=nil) then --something end
- stackStruct:createEOPUnit (index, exp, armor, weapon)
-
Create a unit in the army by index from M2TWEOP units DB (M2TWEOPDU).
Parameters:
- index int
- exp int
- armor int
- weapon int
Returns:
-
unit
newUnit
Usage:
local newUnit=stackStruct:createEOPUnit(1000,1,1,1);
- stackStruct:createUnit (type, exp, armor, weapon)
-
Create a unit in the army by type from export_descr_unit.txt
Parameters:
- type string
- exp int Experience. Maximum: 9.
- armor int Armour level.
- weapon int Weapon upgrade. Maximum: 1.
Returns:
-
unit
newUnit
Usage:
local newUnit=stackStruct:createUnit("Axemen of Lossarnach",1,1,1);
- stackStruct:createUnitByIDX (index, exp, armor, weapon)
-
Create a unit in the army by index from export_descr_unit.txt
Parameters:
- index int Index (order in export_descr_unit.txt)
- exp int Experience. Maximum: 9.
- armor int Armour level.
- weapon int Weapon upgrade. Maximum: 1.
Returns:
-
unit
newUnit
Usage:
local newUnit=stackStruct:createUnitByIDX(255,1,1,1);
- stackStruct:mergeArmies (targetArmy, force)
-
Merge 2 armies on the strat map. Does nothing if the total size of the new army exceeds 20 units.
Parameters:
- targetArmy stackStruct
- force bool optional
Usage:
army:mergeArmies(anotherArmy);
- stackStruct:siegeSettlement (settlement, isAttack)
-
Besiege the specified settlement, or attack it if already besieging it. Requires movement points.
Parameters:
- settlement settlementStruct
- isAttack bool if this is false it makes the army maintain a siege
Usage:
stackStruct:siegeSettlement(settlement);
- stackStruct:siegeFort (fort, isAttack)
-
Besiege the specified fort, or attack it if already besieging it. Requires movement points.
Parameters:
- fort fortStruct
- isAttack bool if this is false it makes the army maintain a siege
Usage:
stackStruct:siegeFort(fort);
- stackStruct:blockadePort (port)
-
Blockade a port.
Parameters:
- port portStruct
Returns:
-
bool
success
Usage:
local success = stackStruct:blockadePort(port);
- stackStruct:attackArmy (defender)
-
Attack another army. Requires movement points.
Parameters:
- defender stackStruct
Returns:
-
int
Success Failed = 0.
Usage:
sucess=stackStruct:attackArmy(defenderArmy); if(sucess~=0) then --something end
- stackStruct:getDeadUnit (index)
-
Get dead unit at index.
Parameters:
- index int
Returns:
-
unit
deadUnit
Usage:
local unit =stackStruct:getDeadUnit(0);
- stackStruct:getGroup (index)
-
Get unit group at index.
Parameters:
- index int
Returns:
-
unitGroup
group
Usage:
local group =stackStruct:getGroup(0);
- stackStruct:defineUnitGroup (name, unit)
-
Define a new unit group with a label.
Parameters:
Returns:
-
unitGroup
group
Usage:
local group =stackStruct:defineUnitGroup("group1", unit);
- stackStruct:setAiActiveSet (activeSet)
-
Set ai active set to a value for the whole army (0 = inacitve, 1 = active, 2 = script controlled)
Parameters:
- activeSet int
Usage:
stackStruct:setAiActiveSet(1);
- stackStruct:releaseUnits ()
-
Set ai active set to on or off depending if army is player controlled
Usage:
stackStruct:releaseUnits();
- stackStruct:buildWatchTower ()
-
Build a watchtower (payment applies)
Usage:
stackStruct:buildWatchTower();
unitGroup
- unitGroup
-
Basic unitGroup table
Fields:
- unitsInFormationNum int
- unitsNotInFormationNum int
- unitNumTotal int
- xCoord float
- yCoord float
- angle int
- automationType int 1 = defend, 2 = attack
- defendXCoord float if automated defend (1)
- defendYCoord float if automated defend (1)
- defendRadius float if automated defend (1)
- targetUnit unit if automated attack (2)
- newAutomationType int 1 = defend, 2 = attack (setting this passes info from new fields to active fields)
- newDefendXCoord float if automated defend (1)
- newDefendYCoord float if automated defend (1)
- newDefendRadius float if automated defend (1)
- newTargetUnit unit if automated attack (2)
- getUnitInFormation getUnitInFormation
- getUnitNotInFormation getUnitNotInFormation
- addUnit addUnit
- removeUnit removeUnit
- undefine undefine
- automate automate
- automateAttack automateAttack
- automateDefense automateDefense
- changeUnitFormation changeUnitFormation
- moveToMissileRangeOfGroup moveToMissileRangeOfGroup
- moveToMissileRangeOfUnit moveToMissileRangeOfUnit
- attackGroup attackGroup
- halt halt
- place place
- moveFormed moveFormed
- moveUnformed moveUnformed
- moveRelativeFormed moveRelativeFormed
- moveRelativeUnformed moveRelativeUnformed
- turn turn
- unitGroup:addUnit (unit)
-
Add a unit to the group (won't add if unit already in group).
Parameters:
- unit unit
Usage:
unitGroup:addUnit(unit);
- unitGroup:removeUnit (unit)
-
Remove a unit from a group.
Parameters:
- unit unit
Usage:
unitGroup:removeUnit(unit);
- unitGroup:undefine ()
-
Undefine a unit group.
Usage:
unitGroup:undefine();
- unitGroup:automate (automate)
-
Toggle group automation.
Parameters:
- automate bool
Usage:
unitGroup:automate(true);
- unitGroup:automateAttack (targetUnit)
-
Automate group attack.
Parameters:
- targetUnit unit
Usage:
unitGroup:automateAttack(targetUnit);
- unitGroup:automateDefense (xCoord, yCoord, radius)
-
Automate group defense.
Parameters:
- xCoord float
- yCoord float
- radius float
Usage:
unitGroup:automateDefense(180, 283, 50);
- unitGroup:getUnitInFormation (index)
-
Get a unit in the group's formation (not given individual commands). Once you give a unit a command once it seems they will always be in the other array.
Parameters:
- index int
Returns:
-
unit
unit
Usage:
local un = unitGroup:getUnitInFormation(0);
- unitGroup:getUnitNotInFormation (index)
-
Get a unit not in the group's formation (not given individual commands). Once you give a unit a command once it seems they will always be in the other array.
Parameters:
- index int
Returns:
-
unit
unit
Usage:
local un = unitGroup:getUnitNotInFormation(0);
- unitGroup:place (xCoord, yCoord, angle)
-
Place a group at a location.
Parameters:
- xCoord float
- yCoord float
- angle float
Usage:
unitGroup:place(150, 127, 0);
- unitGroup:changeUnitFormation (formationType)
-
Change the group's units formations.
Parameters:
- formationType int use enum
Usage:
unitGroup:changeUnitFormation(formationType.phalanx);
- unitGroup:moveToMissileRangeOfGroup (targetGroup, run)
-
Move to put an enemy group inside your missile range.
Parameters:
- targetGroup unitGroup
- run bool
Usage:
unitGroup:moveToMissileRangeOfGroup(otherGroup, true);
- unitGroup:moveToMissileRangeOfUnit (targetUnit, run)
-
Move to put an enemy unit inside your missile range.
Parameters:
- targetUnit unit
- run bool
Usage:
unitGroup:moveToMissileRangeOfUnit(targetUnit, true);
- unitGroup:attackGroup (targetGroup, run)
-
Attack another group.
Parameters:
- targetGroup unitGroup
- run bool
Usage:
unitGroup:attackGroup(targetGroup, true);
- unitGroup:halt ()
-
Halt the group's orders.
Usage:
unitGroup:halt();
- unitGroup:moveFormed (xCoord, yCoord, run)
-
Move to the specified location in formation.
Parameters:
- xCoord float
- yCoord float
- run bool
Usage:
unitGroup:moveFormed(182, 333, true);
- unitGroup:moveUnformed (xCoord, yCoord, run)
-
Move to the specified location not in formation.
Parameters:
- xCoord float
- yCoord float
- run bool
Usage:
unitGroup:moveUnformed(182, 333, true);
- unitGroup:moveRelativeFormed (xCoord, yCoord, run)
-
Move to the specified location in formation.
Parameters:
- xCoord float
- yCoord float
- run bool
Usage:
unitGroup:moveRelativeFormed(182, 333, true);
- unitGroup:moveRelativeUnformed (xCoord, yCoord, run)
-
Move to the specified location not in formation.
Parameters:
- xCoord float
- yCoord float
- run bool
Usage:
unitGroup:moveRelativeUnformed(182, 333, true);
- unitGroup:turn (angle, isRelative)
-
Turn the group either relative or absolute.
Parameters:
- angle int
- isRelative bool
Usage:
unitGroup:turn(90, true);
SiegeStruct
- siegeStruct
-
Basic siegeStruct table
Fields:
- besieger stackStruct
- besiegedSettlement settlementStruct
- besiegedFort fortStruct
- siegeTurns integer
- soldierCount integer
EOP Events
- EventsFunctionsList
-
Events functions list.
Just list, use it without EventsFunctionsList.!!!
Fields:
- onCharacterTurnStart onCharacterTurnStart
- onCapturedCharacterRansomed onCapturedCharacterRansomed
- onCapturedCharacterReleased onCapturedCharacterReleased
- onFatherDiesNatural onFatherDiesNatural
- onPreBattleWithdrawal onPreBattleWithdrawal
- onPostBattle onPostBattle
- onHireMercenaries onHireMercenaries
- onGeneralCaptureResidence onGeneralCaptureResidence
- onLeaderDestroyedFaction onLeaderDestroyedFaction
- onOfferedForAdoption onOfferedForAdoption
- onLesserGeneralOfferedForAdoption onLesserGeneralOfferedForAdoption
- onOfferedForMarriage onOfferedForMarriage
- onBrotherAdopted onBrotherAdopted
- onBirth onBirth
- onCharacterComesOfAge onCharacterComesOfAge
- onCharacterMarries onCharacterMarries
- onCharacterMarriesPrincess onCharacterMarriesPrincess
- onMarriageAlliancePossible onMarriageAlliancePossible
- onMarriageAllianceOffered onMarriageAllianceOffered
- onPriestBecomesHeretic onPriestBecomesHeretic
- onCharacterNearHeretic onCharacterNearHeretic
- onCharacterNearWitch onCharacterNearWitch
- onCardinalPromoted onCardinalPromoted
- onCharacterBecomesAFather onCharacterBecomesAFather
- onGeneralDevastatesTile onGeneralDevastatesTile
- onExecutesASpyOnAMission onExecutesASpyOnAMission
- onExecutesAnAssassinOnAMission onExecutesAnAssassinOnAMission
- onSufferAssassinationAttempt onSufferAssassinationAttempt
- onSufferAcquisitionAttempt onSufferAcquisitionAttempt
- onSufferMarriageAttempt onSufferMarriageAttempt
- onSufferDenouncementAttempt onSufferDenouncementAttempt
- onLeaderOrderedSabotage onLeaderOrderedSabotage
- onAcceptBribe onAcceptBribe
- onRefuseBribe onRefuseBribe
- onInsurrection onInsurrection
- onLeaderOrderedDiplomacy onLeaderOrderedDiplomacy
- onNewAdmiralCreated onNewAdmiralCreated
- onGovernorBuildingDestroyed onGovernorBuildingDestroyed
- onGovernorThrowGames onGovernorThrowGames
- onGovernorThrowRaces onGovernorThrowRaces
- onCharacterSelected onCharacterSelected
- onEnemyCharacterSelected onEnemyCharacterSelected
- onMultiTurnMove onMultiTurnMove
- onCharacterPanelOpen onCharacterPanelOpen
- onLeaderMissionSuccess onLeaderMissionSuccess
- onLeaderMissionFailed onLeaderMissionFailed
- onGeneralJoinCrusade onGeneralJoinCrusade
- onGeneralAbandonCrusade onGeneralAbandonCrusade
- onGeneralArrivesCrusadeTargetRegion onGeneralArrivesCrusadeTargetRegion
- onGeneralTakesCrusadeTarget onGeneralTakesCrusadeTarget
- onCharacterTurnEnd onCharacterTurnEnd
- onCharacterTurnEndInSettlement onCharacterTurnEndInSettlement
- onBecomesFactionLeader onBecomesFactionLeader
- onCeasedFactionLeader onCeasedFactionLeader
- onBecomesFactionHeir onBecomesFactionHeir
- onCeasedFactionHeir onCeasedFactionHeir
- onCharacterDamagedByDisaster onCharacterDamagedByDisaster
- onGeneralCaptureSettlement onGeneralCaptureSettlement
- onGeneralAssaultsResidence onGeneralAssaultsResidence
- onGeneralAssaultsGeneral onGeneralAssaultsGeneral
- onCharacterAttacksCrusadingGeneral onCharacterAttacksCrusadingGeneral
- onGeneralPrisonersRansomedCaptor onGeneralPrisonersRansomedCaptor
- onGeneralPrisonersRansomedCaptive onGeneralPrisonersRansomedCaptive
- onFactionLeaderPrisonersRansomedCaptor onFactionLeaderPrisonersRansomedCaptor
- onFactionLeaderPrisonersRansomedCaptive onFactionLeaderPrisonersRansomedCaptive
- onSpyMission onSpyMission
- onAssassinationMission onAssassinationMission
- onAcquisitionMission onAcquisitionMission
- onMarriageMission onMarriageMission
- onDenouncementMission onDenouncementMission
- onSabotageMission onSabotageMission
- onBriberyMission onBriberyMission
- onDiplomacyMission onDiplomacyMission
- onLeaderOrderedSpyingMission onLeaderOrderedSpyingMission
- onLeaderOrderedAssassination onLeaderOrderedAssassination
- onLeaderOrderedBribery onLeaderOrderedBribery
- onSettlementTurnStart onSettlementTurnStart
- onUngarrisonedSettlement onUngarrisonedSettlement
- onSettlementUpgraded onSettlementUpgraded
- onSettlementConverted onSettlementConverted
- onSiegeEquipmentCompleted onSiegeEquipmentCompleted
- onSettlementTurnEnd onSettlementTurnEnd
- onSettlementSelected onSettlementSelected
- onSettlementPanelOpen onSettlementPanelOpen
- onRecruitmentPanelOpen onRecruitmentPanelOpen
- onConstructionPanelOpen onConstructionPanelOpen
- onTradePanelOpen onTradePanelOpen
- onSettlementScrollAdviceRequested onSettlementScrollAdviceRequested
- onGuildUpgraded onGuildUpgraded
- onGuildDestroyed onGuildDestroyed
- onOccupySettlement onOccupySettlement
- onSackSettlement onSackSettlement
- onExterminatePopulation onExterminatePopulation
- onCityRiots onCityRiots
- onGiveSettlement onGiveSettlement
- onCityRebels onCityRebels
- onCitySacked onCitySacked
- onGovernorCityRiots onGovernorCityRiots
- onGovernorCityRebels onGovernorCityRebels
- onAbandonShowMe onAbandonShowMe
- onGameReloaded onGameReloaded
- onBattleWinningPlaza onBattleWinningPlaza
- onBattleStopsWinningPlaza onBattleStopsWinningPlaza
- onBattleDominatingPlaza onBattleDominatingPlaza
- onBattngineUnmanned onBattngineUnmanned
- onBattlePlayerArmyHalfDestroyed onBattlePlayerArmyHalfDestroyed
- onBattnemyArmyHalfDestroyed onBattnemyArmyHalfDestroyed
- onBattleFinished onBattleFinished
- onBattleArmyHalfDestroyed onBattleArmyHalfDestroyed
- onEscPressed onEscPressed
- onScriptedAdvice onScriptedAdvice
- onNavalPreBattleScrollAdviceRequested onNavalPreBattleScrollAdviceRequested
- onPreBattleScrollAdviceRequested onPreBattleScrollAdviceRequested
- onCollegeOfCardinalsPanelOpen onCollegeOfCardinalsPanelOpen
- onDiplomaticStandingPanelOpen onDiplomaticStandingPanelOpen
- onBattlePlayerUnderAttackIdle onBattlePlayerUnderAttackIdle
- onBattleWinningCombat onBattleWinningCombat
- onBattleArmyTired onBattleArmyTired
- onBattleSpySuccess onBattleSpySuccess
- onBattleTideofBattle onBattleTideofBattle
- onBattleUnitGoesBerserk onBattleUnitGoesBerserk
- onBattleSiegeEngineDestroyed onBattleSiegeEngineDestroyed
- onBattleSiegeEngineDocksWall onBattleSiegeEngineDocksWall
- onBattleGatesAttackedByEngine onBattleGatesAttackedByEngine
- onBattleGatesDestroyedByEngine onBattleGatesDestroyedByEngine
- onBattleWallsBreachedByEngine onBattleWallsBreachedByEngine
- onBattleWallsCaptured onBattleWallsCaptured
- onBattleUnitRouts onBattleUnitRouts
- onUnitDisbanded onUnitDisbanded
- onUnitTrained onUnitTrained
- onGovernorUnitTrained onGovernorUnitTrained
- onGovernorBuildingCompleted onGovernorBuildingCompleted
- onAgentCreated onAgentCreated
- onGovernorAgentCreated onGovernorAgentCreated
- onBuildingDestroyed onBuildingDestroyed
- onAddedToBuildingQueue onAddedToBuildingQueue
- onBuildingCompleted onBuildingCompleted
- onRequestBuildingAdvice onRequestBuildingAdvice
- onRequestTrainingAdvice onRequestTrainingAdvice
- onAddedToTrainingQueue onAddedToTrainingQueue
- onBattleArmyRouted onBattleArmyRouted
- onBattleReinforcementsArrive onBattleReinforcementsArrive
- onRequestMercenariesAdvice onRequestMercenariesAdvice
- onButtonPressed onButtonPressed
- onShortcutTriggered onShortcutTriggered
- onUIElementVisible onUIElementVisible
- onScrollOpened onScrollOpened
- onScrollClosed onScrollClosed
- onScrollAdviceRequested onScrollAdviceRequested
- onAdviceSupressed onAdviceSupressed
- onBattleGeneralRouted onBattleGeneralRouted
- onBattleGeneralKilled onBattleGeneralKilled
- onCrusadeCalled onCrusadeCalled
- onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget
- onPopeRejectsCrusadeTarget onPopeRejectsCrusadeTarget
- onCrusadeEnds onCrusadeEnds
- onPreFactionTurnStart onPreFactionTurnStart
- onFactionTurnStart onFactionTurnStart
- onFactionNewCapital onFactionNewCapital
- onFactionTurnEnd onFactionTurnEnd
- onVotedForPope onVotedForPope
- onFactionExcommunicated onFactionExcommunicated
- onHordeFormed onHordeFormed
- onCardinalRemoved onCardinalRemoved
- onInquisitorAppointed onInquisitorAppointed
- onAssassinCaughtAttackingPope onAssassinCaughtAttackingPope
- onFinancesPanelOpen onFinancesPanelOpen
- onFactionSummaryPanelOpen onFactionSummaryPanelOpen
- onFamilyTreePanelOpen onFamilyTreePanelOpen
- onDiplomacyPanelOpen onDiplomacyPanelOpen
- onPreBattlePanelOpen onPreBattlePanelOpen
- onIncomingMessage onIncomingMessage
- onMessageOpen onMessageOpen
- onMessageClosed onMessageClosed
- onDeclineAutomatedSettlementManagement onDeclineAutomatedSettlementManagement
- onBattleAiCommenced onBattleAiCommenced
- onBattleDelayPhaseCommenced onBattleDelayPhaseCommenced
- onBattleDeploymentPhaseCommenced onBattleDeploymentPhaseCommenced
- onBattleConflictPhaseCommenced onBattleConflictPhaseCommenced
- onFactionWarDeclared onFactionWarDeclared
- onFactionAllianceDeclared onFactionAllianceDeclared
- onInterFactionMarriage onInterFactionMarriage
- onFactionTradeAgreementMade onFactionTradeAgreementMade
- onPopeElected onPopeElected
- onFactionBreakAlliance onFactionBreakAlliance
- onUpdateAttitude onUpdateAttitude
- onDemeanour onDemeanour
- onGiveMoney onGiveMoney
- onBattlePlayerUnitAttacksEnemyUnit onBattlePlayerUnitAttacksEnemyUnit
- onBattleEnemyUnitAttacksPlayerUnit onBattleEnemyUnitAttacksPlayerUnit
- onBattlePlayerUnitGoesBerserk onBattlePlayerUnitGoesBerserk
- onBattlePlayerUnitRouts onBattlePlayerUnitRouts
- onBattlePlayerSiegeEngineDestroyed onBattlePlayerSiegeEngineDestroyed
- onBattleGatesAttackedByPlayerEngine onBattleGatesAttackedByPlayerEngine
- onBattleEnemyUnitGoesBerserk onBattleEnemyUnitGoesBerserk
- onBattnemyUnitRouts onBattnemyUnitRouts
- onBattnemySiegeEngineDestroyed onBattnemySiegeEngineDestroyed
- onBattleGatesAttackedByEnemyEngine onBattleGatesAttackedByEnemyEngine
- onDisaster onDisaster
- onEventCounter onEventCounter
- onUngarrisonedFort onUngarrisonedFort
- onObjSeen onObjSeen
- onTileSeen onTileSeen
- onTransgression onTransgression
- onForgiveness onForgiveness
- onArmyTakesCrusadeTarget onArmyTakesCrusadeTarget
- onUnitsDesertCrusade onUnitsDesertCrusade
- draw draw
- onLoadingFonts onLoadingFonts
- onNewGameStart onNewGameStart
- onReadGameDbsAtStart onReadGameDbsAtStart
- onGameInit onGameInit
- onUnloadCampaign onUnloadCampaign
- onAiTurn onAiTurn
- onClickAtTile onClickAtTile
- onCampaignMapLoaded onCampaignMapLoaded
- onCreateSaveFile onCreateSaveFile
- onLoadSaveFile onLoadSaveFile
- onChangeTurnNum onChangeTurnNum
- onSelectWorldpkgdesc onSelectWorldpkgdesc
- onfortificationlevelS onfortificationlevelS
- onCalculateUnitValue onCalculateUnitValue
- onEndSiege onEndSiege
- onStartSiege onStartSiege
- onPluginLoad onPluginLoad
- onCharacterTurnStart (eventData)
-
Called at a character's turn start.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterTurnStart(eventData) --something here end
- onCapturedCharacterRansomed (eventData)
-
A captured character has been successfully ransomed back from the enemy.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCapturedCharacterRansomed(eventData) --something here end
- onCapturedCharacterReleased (eventData)
-
A captured character has been released by the enemy.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCapturedCharacterReleased(eventData) --something here end
- onFatherDiesNatural (eventData)
-
A character father died of natural causes.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onFatherDiesNatural(eventData) --something here end
- onPreBattleWithdrawal (eventData)
-
When a battle is about to start but one of the armies withdraws.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onPreBattleWithdrawal(eventData) --something here end
- onPostBattle (eventData)
-
When a battle has finished.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onPostBattle(eventData) --something here end
- onHireMercenaries (eventData)
-
A General has hired some mercenaries.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onHireMercenaries(eventData) --something here end
- onGeneralCaptureResidence (eventData)
-
A General has captured a residence such as a fort or watchtower.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGeneralCaptureResidence(eventData) --something end
- onLeaderDestroyedFaction (eventData)
-
A faction has been destroyed.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onLeaderDestroyedFaction(eventData) --something end
- onOfferedForAdoption (eventData)
-
An adoption has been proposed.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onOfferedForAdoption(eventData) --something end
- onLesserGeneralOfferedForAdoption (eventData)
-
A lesser general adoption has been proposed (man of the hour event).
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onLesserGeneralOfferedForAdoption(eventData) --something end
- onOfferedForMarriage (eventData)
-
A marriage offer has been proposed.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onOfferedForMarriage(eventData) --something end
- onBrotherAdopted (eventData)
-
A brother has been adopted.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onBrotherAdopted(eventData) --something end
- onBirth (eventData)
-
A child is born to the faction leader.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onBirth(eventData) --something end
- onCharacterComesOfAge (eventData)
-
A character has come of age.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterComesOfAge(eventData) --something end
- onCharacterMarries (eventData)
-
A character has married.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterMarries(eventData) --something end
- onCharacterMarriesPrincess (eventData)
-
A character has married a princess.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterMarriesPrincess(eventData) --something end
- onMarriageAlliancePossible (eventData)
-
A marriage alliance is possible.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onMarriageAlliancePossible(eventData) --something end
- onMarriageAllianceOffered (eventData)
-
A marriage alliance has been offered.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onMarriageAllianceOffered(eventData) --something end
- onPriestBecomesHeretic (eventData)
-
A priest has gone mad.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onPriestBecomesHeretic(eventData) --something end
- onCharacterNearHeretic (eventData)
-
A character is adjacent to a heretic.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterNearHeretic(eventData) --something end
- onCharacterNearWitch (eventData)
-
A character is adjacent to a witch.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterNearWitch(eventData) --something end
- onCardinalPromoted (eventData)
-
A character has been promoted to a cardinal.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCardinalPromoted(eventData) --something end
- onCharacterBecomesAFather (eventData)
-
A character has become a father.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterBecomesAFather(eventData) --something end
- onGeneralDevastatesTile (eventData)
-
A General and his army has devastated an enemy's fertile land.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGeneralDevastatesTile(eventData) --something end
- onExecutesASpyOnAMission (eventData)
-
A spying mission has failed and the spy is executed by the target.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onExecutesASpyOnAMission(eventData) --something end
- onExecutesAnAssassinOnAMission (eventData)
-
An assassination mission has failed and the assassin is executed by the target.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onExecutesAnAssassinOnAMission(eventData) --something end
- onSufferAssassinationAttempt (eventData)
-
Someone has had an attempt on their life.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onSufferAssassinationAttempt(eventData) --something end
- onSufferAcquisitionAttempt (eventData)
-
Someone has had an attempt on their assets.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onSufferAcquisitionAttempt(eventData) --something end
- onSufferMarriageAttempt (eventData)
-
Someone has had an attempt on their bachelorhood.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onSufferMarriageAttempt(eventData) --something end
- onSufferDenouncementAttempt (eventData)
-
Someone has had a denouncement attempt.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onSufferDenouncementAttempt(eventData) --something end
- onLeaderOrderedSabotage (eventData)
-
A Faction leader has ordered a sabotage mission.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onLeaderOrderedSabotage(eventData) --something end
- onAcceptBribe (eventData)
-
Someone has been bribed.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onAcceptBribe(eventData) --something end
- onRefuseBribe (eventData)
-
Someone has refused a bribe.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onRefuseBribe(eventData) --something end
- onInsurrection (eventData)
-
Insurgence has been provoked.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onInsurrection(eventData) --something end
- onLeaderOrderedDiplomacy (eventData)
-
A Faction leader has ordered a diplomacy mission.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onLeaderOrderedDiplomacy(eventData) --something end
- onNewAdmiralCreated (eventData)
-
A new admiral has been created for a new ship.
Exports: stratCharacter, character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onNewAdmiralCreated(eventData) --something end
- onGovernorBuildingDestroyed (eventData)
-
A building has been destroyed.
Exports: character, faction, regionID, characterType, religion, settlement
Parameters:
- eventData eventTrigger
Usage:
function onGovernorBuildingDestroyed(eventData) --something end
- onGovernorThrowGames (eventData)
-
Games have been thrown.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGovernorThrowGames(eventData) --something end
- onGovernorThrowRaces (eventData)
-
Races have been thrown.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGovernorThrowRaces(eventData) --something end
- onCharacterSelected (eventData)
-
The player has selected a character.
Exports: character, targetSettlement, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterSelected(eventData) --something end
- onEnemyCharacterSelected (eventData)
-
The player has selected an enemy character.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onEnemyCharacterSelected(eventData) --something end
- onMultiTurnMove (eventData)
-
The player has selected a position beyond the character's extents.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onMultiTurnMove(eventData) --something end
- onCharacterPanelOpen (eventData)
-
The player has opened the panel for the selected character.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterPanelOpen(eventData) --something end
- onLeaderMissionSuccess (eventData)
-
A mission has been completed.
Exports: character, faction, regionID, characterType, missionDetails, religion
Parameters:
- eventData eventTrigger
Usage:
function onLeaderMissionSuccess(eventData) --something end
- onLeaderMissionFailed (eventData)
-
A mission has failed.
Exports: character, faction, regionID, characterType, missionDetails, religion
Parameters:
- eventData eventTrigger
Usage:
function onLeaderMissionFailed(eventData) --something end
- onGeneralJoinCrusade (eventData)
-
A General has been sent on Crusade/Jihad.
Exports: character, targetSettlement, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onGeneralJoinCrusade(eventData) --something end
- onGeneralAbandonCrusade (eventData)
-
A General has left a Crusade/Jihad.
Exports: character, targetSettlement, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onGeneralAbandonCrusade(eventData) --something end
- onGeneralArrivesCrusadeTargetRegion (eventData)
-
A General has arrived in the Crusade/Jihad target region.
Exports: character, targetSettlement, faction, targetFaction, army, regionID, targetRegionID, characterType, religion, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onGeneralArrivesCrusadeTargetRegion(eventData) --something end
- onGeneralTakesCrusadeTarget (eventData)
-
A General has taken the Crusade/Jihad target settlement.
Exports: character, targetSettlement, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onGeneralTakesCrusadeTarget(eventData) --something end
- onCharacterTurnEnd (eventData)
-
A Character has finished its turn.
Exports: character, settlement, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterTurnEnd(eventData) --something end
- onCharacterTurnEndInSettlement (eventData)
-
A Character has finished its turn in a settlement.
Exports: character, settlement, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterTurnEndInSettlement(eventData) --something end
- onBecomesFactionLeader (eventData)
-
The character has been made the faction leader.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onBecomesFactionLeader(eventData) print("Function: onBecomesFactionLeader()\n\tLeader: ".. eventData.character.fullName) end
- onCeasedFactionLeader (eventData)
-
The character is no longer faction leader.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCeasedFactionLeader(eventData) --something end
- onBecomesFactionHeir (eventData)
-
The character has been made a faction heir.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onBecomesFactionHeir(eventData) print("Function: onBecomesFactionHeir()\n\tHeir: ".. eventData.character.fullName) end
- onCeasedFactionHeir (eventData)
-
The character is no longer faction heir.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onCeasedFactionHeir(eventData) print("Function: onCeasedFactionHeir()\n\tHeir: ".. eventData.character.fullName) end
- onCharacterDamagedByDisaster (eventData)
-
A character has been injured by a disaster.
Exports: character, faction, regionID, disasterType, characterType, religion disasterTypes: earthquake, flood, horde, storm, volcano, dustbowl, locusts, famine, plague, riot, fire
Parameters:
- eventData eventTrigger
Usage:
function onCharacterDamagedByDisaster(eventData) --something end
- onGeneralCaptureSettlement (eventData)
-
A General has captured a settlement.
Exports: character, settlement, targetSettlement, faction, targetFaction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGeneralCaptureSettlement(eventData) --something end
- onGeneralAssaultsResidence (eventData, settlement, fort)
-
An assault has taken place. NOTE: settlement and fort are not in eventData! They are separate arguments!.
Exports: character, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion
Parameters:
- eventData eventTrigger
- settlement settlementStruct or nil
- fort fortStruct or nil
Usage:
function onGeneralAssaultsResidence(eventData, settlement, fort) --something end
- onGeneralAssaultsGeneral (eventData)
-
An assault has taken place.
Exports: character, targetCharacter, faction, targetFaction, regionID, characterType, targetCharacterType, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onGeneralAssaultsGeneral(eventData) --something end
- onCharacterAttacksCrusadingGeneral (eventData)
-
A general on crusade/jihad has been attacked by other character (it includes crusading generals attacked in a residence or on navy and generals attacked by spotted and killed assassin).
Exports: character, targetCharacter, faction, targetFaction, regionID, characterType, targetCharacterType, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onCharacterAttacksCrusadingGeneral(eventData) --something end
- onGeneralPrisonersRansomedCaptor (eventData)
-
A General of a captor faction has made a ransom decision.
Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType ransomType: ransom, execute, release, cannot_pay_ransom
Parameters:
- eventData eventTrigger
Usage:
function onGeneralPrisonersRansomedCaptor(eventData) --something end
- onGeneralPrisonersRansomedCaptive (eventData)
-
A General of a captive faction has made a ransom decision.
Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType
Parameters:
- eventData eventTrigger
Usage:
function onGeneralPrisonersRansomedCaptive(eventData) --something end
- onFactionLeaderPrisonersRansomedCaptor (eventData)
-
A captor faction has made a ransom decision.
Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType
Parameters:
- eventData eventTrigger
Usage:
function onFactionLeaderPrisonersRansomedCaptor(eventData) --something end
- onFactionLeaderPrisonersRansomedCaptive (eventData)
-
A captive faction has made a ransom decision.
Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType
Parameters:
- eventData eventTrigger
Usage:
function onFactionLeaderPrisonersRansomedCaptive(eventData) --something end
- onSpyMission (eventData)
-
A spy mission has completed. May also export fort or settlement if target was a garrison residence.
Exports: character, settlement, fort, faction, targetFaction, regionID, characterType, missionSuccessLevel, missionProbability, religion, targetReligion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onSpyMission(eventData) --something end
- onAssassinationMission (eventData)
-
An assassination mission has completed.
Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onAssassinationMission(eventData) --something end
- onAcquisitionMission (eventData)
-
An acquisition mission has completed.
Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onAcquisitionMission(eventData) --something end
- onMarriageMission (eventData)
-
A marriage mission has completed.
Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onMarriageMission(eventData) --something end
- onDenouncementMission (eventData)
-
A denouncement mission has completed.
Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onDenouncementMission(eventData) --something end
- onSabotageMission (eventData)
-
A sabotage mission has completed.
Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onSabotageMission(eventData) --something end
- onBriberyMission (eventData)
-
A bribery mission has completed.
Exports: character, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onBriberyMission(eventData) --something end
- onDiplomacyMission (eventData)
-
A diplomacy mission has completed.
Exports: character, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onDiplomacyMission(eventData) --something end
- onLeaderOrderedSpyingMission (eventData)
-
A Faction leader has ordered a spying mission.
Exports: character, settlement, fort, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onLeaderOrderedSpyingMission(eventData) --something end
- onLeaderOrderedAssassination (eventData)
-
A Faction leader has ordered an assassination mission.
Exports: character, targetCharacter, faction, regionID, characterType, missionSuccessLevel, religion missionSuccessLevel: not_successful, slightly_successful, partly_successful, highly_successful
Parameters:
- eventData eventTrigger
Usage:
function onLeaderOrderedAssassination(eventData) --something end
- onLeaderOrderedBribery (eventData)
-
A Faction leader has ordered a bribery mission.
Exports: character, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onLeaderOrderedBribery(eventData) --something end
- onSettlementTurnStart (eventData)
-
A settlement is being processed for the start of its faction's turn.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onSettlementTurnStart(eventData) --something end
- onUngarrisonedSettlement (eventData)
-
A settlement is no longer garrisoned.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onUngarrisonedSettlement(eventData) --something end
- onSettlementUpgraded (eventData)
-
A settlement has been upgraded.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onSettlementUpgraded(eventData) --something end
- onSettlementConverted (eventData)
-
A settlement has been converted.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onSettlementConverted(eventData) --something end
- onSiegeEquipmentCompleted (eventData)
-
Siege equipment has been completed by one of the besieging armies.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onSiegeEquipmentCompleted(eventData) --something end
- onSettlementTurnEnd (eventData)
-
A Settlement is being processed for the end of its faction's turn.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onSettlementTurnEnd(eventData) --something end
- onSettlementSelected (eventData)
-
The player has selected a settlement.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onSettlementSelected(eventData) --something end
- onSettlementPanelOpen (eventData)
-
The player has opened the panel for the selected settlement.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onSettlementPanelOpen(eventData) --something end
- onRecruitmentPanelOpen (eventData)
-
The player has opened a recruitment panel.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onRecruitmentPanelOpen(eventData) --something end
- onConstructionPanelOpen (eventData)
-
The player has opened a construction panel.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onConstructionPanelOpen(eventData) --something end
- onTradePanelOpen (eventData)
-
The player has opened a trade panel.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onTradePanelOpen(eventData) --something end
- onSettlementScrollAdviceRequested (eventData)
-
The player has requested advice on the settlement scroll.
Exports: settlement, faction, regionID, resourceDescription, religion
Parameters:
- eventData eventTrigger
Usage:
function onSettlementScrollAdviceRequested(eventData) --something end
- onGuildUpgraded (eventData)
-
A guild has been created/upgraded.
Exports: settlement, faction, regionID, resourceDescription, guild, religion
Parameters:
- eventData eventTrigger
Usage:
function onGuildUpgraded(eventData) --something end
- onGuildDestroyed (eventData)
-
A guild has been destroyed.
Exports: settlement, faction, regionID, guild, religion
Parameters:
- eventData eventTrigger
Usage:
function onGuildDestroyed(eventData) --something end
- onOccupySettlement (eventData)
-
A settlement has been captured and occupied.
Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onOccupySettlement(eventData) --something end
- onSackSettlement (eventData)
-
A settlement has been captured and sacked.
Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onSackSettlement(eventData) --something end
- onExterminatePopulation (eventData)
-
A settlement has been captured and some of its population has been decimated.
Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onExterminatePopulation(eventData) --something end
- onCityRiots (eventData)
-
A settlement has rioted.
Exports: settlement, faction, targetFaction, regionID, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onCityRiots(eventData) --something end
- onGiveSettlement (eventData)
-
A settlement has been given to another faction.
Exports: settlement, faction, targetFaction, regionID, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onGiveSettlement(eventData) --something end
- onCityRebels (eventData)
-
A settlement has rebelled.
Exports: settlement, faction, targetFaction, regionID, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onCityRebels(eventData) --something end
- onCitySacked (eventData)
-
A settlement has been razed.
Exports: settlement, faction, targetFaction, regionID, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onCitySacked(eventData) --something end
- onGovernorCityRiots (eventData)
-
A settlement has rioted.
Exports: character, settlement, faction, targetFaction, regionID, characterType, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onGovernorCityRiots(eventData) --something end
- onGovernorCityRebels (eventData)
-
A settlement has rebelled.
Exports: character, settlement, faction, targetFaction, regionID, characterType, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onGovernorCityRebels(eventData) --something end
- onAbandonShowMe (eventData)
-
The player has abandoned a show me scipt.
Parameters:
- eventData eventTrigger
Usage:
function onAbandonShowMe(eventData) --something here end
- onGameReloaded (eventData)
-
A strat map game has been reloaded.
Parameters:
- eventData eventTrigger
Usage:
function onGameReloaded(eventData) --something here end
- onBattleWinningPlaza (eventData)
-
The plaza is being captured.
Parameters:
- eventData eventTrigger
Usage:
function onBattleWinningPlaza(eventData) --something here end
- onBattleStopsWinningPlaza (eventData)
-
The plaza capture has been stopped.
Parameters:
- eventData eventTrigger
Usage:
function onBattleStopsWinningPlaza(eventData) --something here end
- onBattleDominatingPlaza (eventData)
-
The enemy will have captured the plaza in 30s.
Parameters:
- eventData eventTrigger
Usage:
function onBattleDominatingPlaza(eventData) --something here end
- onBattngineUnmanned (eventData)
-
A siege engine is now unmanned.
Parameters:
- eventData eventTrigger
Usage:
function onBattngineUnmanned(eventData) --something here end
- onBattlePlayerArmyHalfDestroyed (eventData)
-
Half of the player's army has been destroyed.
Parameters:
- eventData eventTrigger
Usage:
function onBattlePlayerArmyHalfDestroyed(eventData) --something here end
- onBattnemyArmyHalfDestroyed (eventData)
-
Half of the enemy's army has been destroyed.
Parameters:
- eventData eventTrigger
Usage:
function onBattnemyArmyHalfDestroyed(eventData) --something here end
- onBattleFinished (eventData)
-
The battle has finished.
Parameters:
- eventData eventTrigger
Usage:
function onBattleFinished(eventData) --something here end
- onBattleArmyHalfDestroyed (eventData)
-
Half of an army has been destroyed.
Parameters:
- eventData eventTrigger
Usage:
function onBattleArmyHalfDestroyed(eventData) --something here end
- onEscPressed (eventData)
-
The escape key has been pressed. This trigger will only fire if the command StealEscKey has been used.
Parameters:
- eventData eventTrigger
Usage:
function onEscPressed(eventData) --something here end
- onScriptedAdvice (eventData)
-
The player has been issued with advice by a script.
Parameters:
- eventData eventTrigger
Usage:
function onScriptedAdvice(eventData) --something here end
- onNavalPreBattleScrollAdviceRequested (eventData)
-
The player has requested advice on the naval prebattle scroll.
Parameters:
- eventData eventTrigger
Usage:
function onNavalPreBattleScrollAdviceRequested(eventData) --something here end
- onPreBattleScrollAdviceRequested (eventData)
-
The player has requested advice on the prebattle scroll.
Parameters:
- eventData eventTrigger
Usage:
function onPreBattleScrollAdviceRequested(eventData) --something here end
- onCollegeOfCardinalsPanelOpen (eventData)
-
The player has opened the college of cardinals panel.
Parameters:
- eventData eventTrigger
Usage:
function onCollegeOfCardinalsPanelOpen(eventData) --something here end
- onDiplomaticStandingPanelOpen (eventData)
-
The player has opened the diplomatic standing panel.
Parameters:
- eventData eventTrigger
Usage:
function onDiplomaticStandingPanelOpen(eventData) --something here end
- onBattlePlayerUnderAttackIdle (eventData)
-
An idle unit is under missile fire.
Parameters:
- eventData eventTrigger
Usage:
function onBattlePlayerUnderAttackIdle(eventData) --something here end
- onBattleWinningCombat (eventData)
-
A team has gained the advantage in combat.
Parameters:
- eventData eventTrigger
Usage:
function onBattleWinningCombat(eventData) --something here end
- onBattleArmyTired (eventData)
-
The whole army is tired.
Parameters:
- eventData eventTrigger
Usage:
function onBattleArmyTired(eventData) --something here end
- onBattleSpySuccess (eventData)
-
A spy has successfully opened the gates.
Parameters:
- eventData eventTrigger
Usage:
function onBattleSpySuccess(eventData) --something here end
- onBattleTideofBattle (eventData)
-
A different team is now the strongest.
Parameters:
- eventData eventTrigger
Usage:
function onBattleTideofBattle(eventData) --something here end
- onBattleUnitGoesBerserk (eventData)
-
A unit has gone berserk.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleUnitGoesBerserk(eventData) --something here end
- onBattleSiegeEngineDestroyed (eventData)
-
A siege engine has been destroyed.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleSiegeEngineDestroyed(eventData) --something here end
- onBattleSiegeEngineDocksWall (eventData)
-
A siege engine has docked with a wall.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleSiegeEngineDocksWall(eventData) --something here end
- onBattleGatesAttackedByEngine (eventData)
-
An engine has started attacking a gate.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleGatesAttackedByEngine(eventData) --something here end
- onBattleGatesDestroyedByEngine (eventData)
-
An engine has destroyed a gate.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleGatesDestroyedByEngine(eventData) --something here end
- onBattleWallsBreachedByEngine (eventData)
-
A siege engine has knocked down a wall.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleWallsBreachedByEngine(eventData) --something here end
- onBattleWallsCaptured (eventData)
-
A wall has been captured.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleWallsCaptured(eventData) --something here end
- onBattleUnitRouts (eventData)
-
A unit has routed.
Exports: unit
Parameters:
- eventData eventTrigger
Usage:
function onBattleUnitRouts(eventData) --something here end
- onUnitDisbanded (eventData)
-
A unit has been disbanded.
Exports: faction, playerUnit, eduEntry, religion
Parameters:
- eventData eventTrigger
Usage:
function onUnitDisbanded(eventData) --something here end
- onUnitTrained (eventData)
-
A unit has been trained.
Exports: settlement, faction, playerUnit, eduEntry, religion
Parameters:
- eventData eventTrigger
Usage:
function onUnitTrained(eventData) --something here end
- onGovernorUnitTrained (eventData)
-
A unit has been trained.
Exports: character, settlement, faction, regionID, playerUnit, eduEntry, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGovernorUnitTrained(eventData) --something here end
- onGovernorBuildingCompleted (eventData)
-
A building has been completed.
Exports: character, settlement, faction, regionID, priorBuild, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGovernorBuildingCompleted(eventData) --something here end
- onAgentCreated (eventData)
-
An agent has been trained.
Exports: character, settlement, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onAgentCreated(eventData) --something here end
- onGovernorAgentCreated (eventData)
-
An agent has been trained.
Exports: character, settlement, faction, regionID, characterType, religion
Parameters:
- eventData eventTrigger
Usage:
function onGovernorAgentCreated(eventData) --something here end
- onBuildingDestroyed (eventData)
-
A building has been destroyed.
Exports: settlement, faction, regionID, resourceDescription, religion
Parameters:
- eventData eventTrigger
Usage:
function onBuildingDestroyed(eventData) --something here end
- onAddedToBuildingQueue (eventData)
-
A building has been added to the construction queue.
Exports: settlement, faction, regionID, resourceDescription, religion
Parameters:
- eventData eventTrigger
Usage:
function onAddedToBuildingQueue(eventData) --something here end
- onBuildingCompleted (eventData)
-
A building has been completed.
Exports: settlement, faction, priorBuild, religion
Parameters:
- eventData eventTrigger
Usage:
function onBuildingCompleted(eventData) --something here end
- onRequestBuildingAdvice (eventData)
-
The player has requested building advice.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onRequestBuildingAdvice(eventData) --something here end
- onRequestTrainingAdvice (eventData)
-
The player has requested training advice.
Exports: settlement, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onRequestTrainingAdvice(eventData) --something here end
- onAddedToTrainingQueue (eventData)
-
A unit has been added to the training queue.
Exports: settlement, faction, regionID, resourceDescription, religion
Parameters:
- eventData eventTrigger
Usage:
function onAddedToTrainingQueue(eventData) --something here end
- onBattleArmyRouted (eventData)
-
An army has been entirely routed.
Exports: army
Parameters:
- eventData eventTrigger
Usage:
function onBattleArmyRouted(eventData) --something here end
- onBattleReinforcementsArrive (eventData)
-
A reinforcing army has arrived on the battlefield.
Exports: army
Parameters:
- eventData eventTrigger
Usage:
function onBattleReinforcementsArrive(eventData) --something here end
- onRequestMercenariesAdvice (eventData)
-
The player has requested mercenaries advice.
Exports: army
Parameters:
- eventData eventTrigger
Usage:
function onRequestMercenariesAdvice(eventData) --something here end
- onButtonPressed (eventData)
-
The player has clicked on a button.
Exports: resourceDescription
Parameters:
- eventData eventTrigger
Usage:
function onButtonPressed(eventData) --something here end
- onShortcutTriggered (eventData)
-
The player triggered a keyboard shortcut.
Exports: resourceDescription
Parameters:
- eventData eventTrigger
Usage:
function onShortcutTriggered(eventData) --something here end
- onUIElementVisible (eventData)
-
A special UI Element is visible.
Exports: resourceDescription
Parameters:
- eventData eventTrigger
Usage:
function onUIElementVisible(eventData) --something here end
- onScrollOpened (eventData)
-
The player opened a scroll.
Exports: resourceDescription
Parameters:
- eventData string
Usage:
function onScrollOpened(eventData) --something here end
- onScrollClosed (eventData)
-
The player closed a scroll.
Exports: resourceDescription
Parameters:
- eventData eventTrigger
Usage:
function onScrollClosed(eventData) --something here end
- onScrollAdviceRequested (eventData)
-
The player has requested advice on a scroll.
Exports: resourceDescription
Parameters:
- eventData eventTrigger
Usage:
function onScrollAdviceRequested(eventData) --something here end
- onAdviceSupressed (eventData)
-
The player has suppressed a piece of advice.
Exports: resourceDescription
Parameters:
- eventData eventTrigger
Usage:
function onAdviceSupressed(eventData) --something here end
- onBattleGeneralRouted (eventData)
-
A general has been routed.
Exports: stratCharacter, character
Parameters:
- eventData eventTrigger
Usage:
function onBattleGeneralRouted(eventData) --something here end
- onBattleGeneralKilled (eventData)
-
A general has been killed.
Exports: stratCharacter
Parameters:
- eventData eventTrigger
Usage:
function onBattleGeneralKilled(eventData) --something here end
- onCrusadeCalled (eventData)
-
A Crusade/Jihad has been called.
Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onCrusadeCalled(eventData) --something here end
- onPopeAcceptsCrusadeTarget (eventData)
-
The Pope has accepted the player's crusade target.
Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onPopeAcceptsCrusadeTarget(eventData) --something here end
- onPopeRejectsCrusadeTarget (eventData)
-
The Pope has rejected the player's crusade target.
Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onPopeRejectsCrusadeTarget(eventData) --something here end
- onCrusadeEnds (eventData)
-
A Crusade/Jihad has ended.
Exports: targetSettlement, targetRegionID, crusade
Parameters:
- eventData eventTrigger
Usage:
function onCrusadeEnds(eventData) --something here end
- onPreFactionTurnStart (eventData)
-
Called before the faction's turn starts.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onPreFactionTurnStart(eventData) --something here end
- onFactionTurnStart (eventData)
-
Called at a faction's turn start.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onFactionTurnStart(eventData) --something here end
- onFactionNewCapital (eventData)
-
Called after faction changes to a new capital.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onFactionNewCapital(eventData) newCapital=fac.capital(); end
- onFactionTurnEnd (eventData)
-
Called at a faction's turn end.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onFactionTurnEnd(eventData) --something here end
- onVotedForPope (eventData)
-
A Faction has voted for the new pope.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onVotedForPope(eventData) --something here end
- onFactionExcommunicated (eventData)
-
A Faction has been excommunicated.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onFactionExcommunicated(eventData) --something here end
- onHordeFormed (eventData)
-
A Faction has formed a horde.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onHordeFormed(eventData) --something here end
- onCardinalRemoved (eventData)
-
A cardinal has been removed from the game.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onCardinalRemoved(eventData) --something here end
- onInquisitorAppointed (eventData)
-
An inquisitor has been dispatched to a region.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onInquisitorAppointed(eventData) --something here end
- onAssassinCaughtAttackingPope (eventData)
-
An assassination mission against the pope has failed and the assassin is executed.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onAssassinCaughtAttackingPope(eventData) --something here end
- onFinancesPanelOpen (eventData)
-
The player has opened his finances panel.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onFinancesPanelOpen(eventData) --something here end
- onFactionSummaryPanelOpen (eventData)
-
The player has opened the faction summary panel.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onFactionSummaryPanelOpen(eventData) --something here end
- onFamilyTreePanelOpen (eventData)
-
The player has opened the family tree panel.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onFamilyTreePanelOpen(eventData) --something here end
- onDiplomacyPanelOpen (eventData)
-
The player has opened the diplomatic standing panel.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onDiplomacyPanelOpen(eventData) --something here end
- onPreBattlePanelOpen (eventData)
-
The player has attacked an army or settlement. The decision panel is now open.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onPreBattlePanelOpen(eventData) --something here end
- onIncomingMessage (eventData)
-
A message has arrived for the player.
Exports: faction, eventID, religion
Parameters:
- eventData eventTrigger
Usage:
function onIncomingMessage(eventData) --something here end
- onMessageOpen (eventData)
-
The player has opened a message.
Exports: faction, eventID, religion
Parameters:
- eventData eventTrigger
Usage:
function onMessageOpen(eventData) --something here end
- onMessageClosed (eventData)
-
The player has closed a message.
Exports: eventID
Parameters:
- eventData eventTrigger
Usage:
function onMessageClosed(eventData) --something here end
- onDeclineAutomatedSettlementManagement (eventData)
-
The player has declined automated settlement management.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onDeclineAutomatedSettlementManagement(eventData) --something here end
- onBattleAiCommenced (eventData)
-
The battle AI has begun processing.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onBattleAiCommenced(eventData) --something here end
- onBattleDelayPhaseCommenced (eventData)
-
The delay phase has begun.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onBattleDelayPhaseCommenced(eventData) --something here end
- onBattleDeploymentPhaseCommenced (eventData)
-
The deployment phase has begun.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onBattleDeploymentPhaseCommenced(eventData) --something here end
- onBattleConflictPhaseCommenced (eventData)
-
The conflict phase has begun.
Exports: faction, religion
Parameters:
- eventData eventTrigger
Usage:
function onBattleConflictPhaseCommenced(eventData) --something here end
- onFactionWarDeclared (eventData)
-
Called after a faction declares a war.
Exports: faction, targetFaction, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onFactionWarDeclared(eventData) --something end
- onFactionAllianceDeclared (eventData)
-
Called after a faction declares an alliance.
Exports: faction, targetFaction, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onFactionAllianceDeclared(eventData) --something end
- onInterFactionMarriage (eventData)
-
A marriage has occured between two factions. gets fired for both factions involved.
Exports: faction, targetFaction, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onInterFactionMarriage(eventData) --something end
- onFactionTradeAgreementMade (eventData)
-
Called after a faction makes a trade agreement.
Exports: faction, targetFaction, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onFactionTradeAgreementMade(eventData) --something end
- onPopeElected (eventData)
-
A new pope has been elected.
Exports: faction, targetFaction, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onPopeElected(eventData) --something end
- onFactionBreakAlliance (eventData)
-
Called after a faction breaks an alliance.
Exports: faction, targetFaction, religion, targetReligion
Parameters:
- eventData eventTrigger
Usage:
function onFactionBreakAlliance(eventData) --something end
- onUpdateAttitude (eventData)
-
A faction to faction attitude update has occurred (once every round).
Exports: faction, targetFaction, religion
Parameters:
- eventData eventTrigger
Usage:
function onUpdateAttitude(eventData) --something end
- onDemeanour (eventData)
-
A demeanour response has occured in diplomacy talks.
Exports: faction, targetFaction, religion, targetReligion, amount
Parameters:
- eventData eventTrigger
Usage:
function onDemeanour(eventData) --something end
- onGiveMoney (eventData)
-
Called after a faction gives money to another faction.
Exports: faction, targetFaction, religion, targetReligion, amount
Parameters:
- eventData eventTrigger
Usage:
function onGiveMoney(eventData) --something end
- onBattlePlayerUnitAttacksEnemyUnit (eventData)
-
A player unit has attacked one of the enemies units.
Exports: attackingUnit, defendingUnit, playerUnit, enemyUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattlePlayerUnitAttacksEnemyUnit(eventData) --something here end
- onBattleEnemyUnitAttacksPlayerUnit (eventData)
-
An enemy unit has attacked one of the players units.
Exports: attackingUnit, defendingUnit, playerUnit, enemyUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattleEnemyUnitAttacksPlayerUnit(eventData) --something here end
- onBattlePlayerUnitGoesBerserk (eventData)
-
One of the player's units has gone berserk.
Exports: playerUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattlePlayerUnitGoesBerserk(eventData) --something here end
- onBattlePlayerUnitRouts (eventData)
-
One of the player's units has routed.
Exports: playerUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattlePlayerUnitRouts(eventData) --something here end
- onBattlePlayerSiegeEngineDestroyed (eventData)
-
A siege engine belonging to the player has been destroyed.
Exports: playerUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattlePlayerSiegeEngineDestroyed(eventData) --something here end
- onBattleGatesAttackedByPlayerEngine (eventData)
-
A player's engine has started attacking a gate.
Exports: playerUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattleGatesAttackedByPlayerEngine(eventData) --something here end
- onBattleEnemyUnitGoesBerserk (eventData)
-
One of the enemy's units has gone berserk.
Exports: enemyUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattleEnemyUnitGoesBerserk(eventData) --something here end
- onBattnemyUnitRouts (eventData)
-
One of the enemy's units has routed.
Exports: enemyUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattnemyUnitRouts(eventData) --something here end
- onBattnemySiegeEngineDestroyed (eventData)
-
A siege engine belonging to the enemy has been destroyed.
Exports: enemyUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattnemySiegeEngineDestroyed(eventData) --something here end
- onBattleGatesAttackedByEnemyEngine (eventData)
-
An enemy's engine has started attacking a gate.
Exports: enemyUnit
Parameters:
- eventData eventTrigger
Usage:
function onBattleGatesAttackedByEnemyEngine(eventData) --something here end
- onDisaster (eventData)
-
When a particular disaster has just happened.
Exports: resourceDescription
Parameters:
- eventData eventTrigger
Usage:
function onDisaster(eventData) if eventData.resourceDescription == "earthquake" then --something here end end
- onEventCounter (eventData)
-
An event counter has changed it's value.
Exports: eventCounter
Parameters:
- eventData eventTrigger
Usage:
function onEventCounter(eventData) if eventData.eventCounter == "my_event_counter" then --something here end end
- onUngarrisonedFort (eventData)
-
The last unit has been removed from a fort, agents do not count.
Exports: fort, faction, regionID, religion
Parameters:
- eventData eventTrigger
Usage:
function onUngarrisonedFort(eventData) --something here end
- onObjSeen (eventData)
-
An object of the target faction has been seen by the faction.
Exports: faction, targetFaction, regionID, coords, religion
Parameters:
- eventData eventTrigger
Usage:
function onObjSeen(eventData) --something here end
- onTileSeen (eventData)
-
The tile has been seen by the faction.
Exports: faction, regionID, coords, religion
Parameters:
- eventData eventTrigger
Usage:
function onTileSeen(eventData) --something here end
- onTransgression (eventData)
-
A faction to faction transgression has occurred.
Exports: faction, targetFaction, resourceDescription, religion, targetReligion transgressions: TC_THREATEN_WAR, TC_DECLARED_WAR, TC_MINOR_ASSASSINATION_ATTEMPT, TC_BROKE_TREATY_TERMS, TC_BROKE_ALLIANCE, TC_INVASION
Parameters:
- eventData eventTrigger
Usage:
function onTransgression(eventData) --something here end
- onForgiveness (eventData)
-
A faction to faction forgiveness has occurred.
Exports: faction, targetFaction, resourceDescription, religion forgiveness: FC_MILITARY_ASSISTANCE, FC_OBVIOUS_BRIBE
Parameters:
- eventData eventTrigger
Usage:
function onForgiveness(eventData) --something here end
- onArmyTakesCrusadeTarget (eventData)
-
An army has taken a crusade or jihad target settlement.
Exports: targetSettlement, faction, targetFaction, army, regionID, targetRegionID, coords, religion, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onArmyTakesCrusadeTarget(eventData) --something here end
- onUnitsDesertCrusade (eventData)
-
Units have deserted a crusade or jihad.
Exports: targetSettlement, faction, targetFaction, targetRegionID, religion, targetReligion, crusade
Parameters:
- eventData eventTrigger
Usage:
function onUnitsDesertCrusade(eventData) --something here end
- draw (pDevice)
-
Called every time an image is rendered for display
Parameters:
- pDevice LPDIRECT3DDEVICE9
Usage:
function draw(device) ImGui.Begin("test"); ImGui.Text("Some test text") ImGui.End(); end
- onLoadingFonts ()
-
Called when ImGui backend reload fonts
Usage:
function onLoadingFonts() --something here end
- onNewGameStart ()
-
Called when a new campaign is started from the menu.
Usage:
function onNewGameStart() --something here end
- onReadGameDbsAtStart ()
-
Called after the game loads various db`s (edu, etc) at startup.
Usage:
function onReadGameDbsAtStart() --something here end
- onGameInit ()
-
Called after the game loads various db`s (edu, etc) at startup.
Usage:
function onGameInit() --something here end
- onUnloadCampaign ()
-
Called after the campaignStruct gets unloaded (exit to menu, load save etc).
Usage:
function onUnloadCampaign() --something here end
- onAiTurn (aiFaction)
-
Called on ai initialized on turn start.
Parameters:
- aiFaction aiFaction
Usage:
function onAiTurn(aiFaction) --something here end
- onClickAtTile (x, y)
-
Called on clicking the stratmap.
Parameters:
- x int
- y int
Usage:
clickAtMap={["isClicked"]=false,["xTile"]=0,["yTile"]=0} function draw(device) if(clickAtMap.isClicked==true) then print(tostring(ImGui.IsMouseDown(ImGuiMouseButton.ImGuiMouseButton_Right)).."\n"); print(tostring(ImGui.IsMouseDown(ImGuiMouseButton.ImGuiMouseButton_Left)).."\n"); print(tostring(clickAtMap.xTile).." "..tostring(clickAtMap.yTile)); clickAtMap.isClicked=false; end end function onClickAtTile(x,y) clickAtMap.isClicked=true; clickAtMap.xTile=x; clickAtMap.yTile=y; end
- onCampaignMapLoaded ()
-
Called after loading the campaign map
Usage:
function onCampaignMapLoaded() --something here end
- onPluginLoad ()
-
Called on plugin load (at game start).
Usage:
--An example of using this event to perform actions at the beginning of a campaign once: isCampaignLoadedFirstTime=false; function onNewGameStart() isCampaignLoadedFirstTime=true; end function onCampaignMapLoaded() if(isCampaignLoadedFirstTime==false) then do return end end --here we do our stuff, what works only one time for each campaign isCampaignLoadedFirstTime=false; end
- onCreateSaveFile ()
-
Called on creating a new save file.
Usage:
function onCreateSaveFile() local savefiles, currentPath = {}, M2TWEOP.getPluginPath() savefiles[1] = currentPath.."\\testSaveFile1.ourSave" savefiles[2] = currentPath.."\\testSaveFile2.ourSave" file1 = io.open(savefiles[1], "w"); file1:write("This is save file 1!!!"); file1:close() file2 = io.open(savefiles[2], "w"); file2:write("This is save file 2!!!"); file2:close() return savefiles end
- onLoadSaveFile ()
-
Called on loading a save file.
Usage:
function onLoadSaveFile(paths) lastSaveFiles={}; for key, value in pairs(paths) do print(key, " -- ", value); lastSaveFiles[key]={}; lastSaveFiles[key][1]=value; lastSaveFiles[key][2]=readFile(value); end end --read file and return it`s content local function readFile(path) local file = io.open(path, "r") ; if (not file) then return nil end local content = file:read "*a"; file:close(); return content; end
- onChangeTurnNum (turnNumber)
-
Called at the start of a new turn.
Parameters:
- turnNumber int
Usage:
function onChangeTurnNum(turnNum) --something here end
- onSelectWorldpkgdesc (selectedRecordName, selectedRecordGroup)
-
Called on select worldpkgdesc for battlemap. See https://wiki.twcenter.net/index.php?title=.worldpkgdesc-M2TW. M2TWEOP will ignore the return value if its group does not match the required group!
Parameters:
Returns:
-
string
newSelectedRecordName
Usage:
function onSelectWorldpkgdesc(selectedRecord,selectedRecordGroup) --something here return selectedRecord; end
- onfortificationlevelS (siegedSettlement)
-
Called on specified fortificationlevel in a siege of a settlement.
Parameters:
- siegedSettlement settlementStruct
Returns:
- int overridedFortificationlevel
- bool isCastle override settlement type (siege equipment is slightly different between cities and castles of the same level)
Usage:
function onfortificationlevelS(settlement) if settlement.xCoord == 10 and settlement.yCoord == 25 then return 3, false --override settlement under siege at these coordinates to level 3 city end return nil --else, do not override end
- onCalculateUnitValue (entry, value)
-
Called when the game calculates the value of a unit. For example, in battle, when it says 'Victory seems certain' when units are engaging each other it uses this, it uses this to decide which units to recruit, to evaluate army strength for attack decisions, for auto resolve balance and results, it is just the value that decides how strong it thinks a unit is. The long term goal director also uses this for the values you have in campaignaidb like military balance and free strength balance.
Parameters:
- entry eduEntry
- value float
Returns:
-
float
newValue
Usage:
function onCalculateUnitValue(entry, value) if entry.eduType = "my_unit" then return value * 2 end return value end
- onEndSiege (xCoord, yCoord)
-
Called on the completion of the siege (in any way, with any outcome).
Parameters:
- xCoord int x coordinate of siege(settlement or fort)
- yCoord int y coordinate of siege(settlement or fort)
Usage:
function onEndSiege(x,y) --something here end
- onStartSiege (xCoord, yCoord)
-
Called on the starting of the siege (in any way, with any outcome).
Parameters:
- xCoord int x coordinate of siege(settlement or fort)
- yCoord int y coordinate of siege(settlement or fort)
Usage:
function onStartSiege(x,y) --something here end
M2TWEOPDU
- M2TWEOPDU
-
Basic M2TWEOPDU table. Contains descriptions of M2TWEOP unit types.
Fields:
- addEopEduEntryFromFile addEopEduEntryFromFile
- addEopEduEntryFromEDUID addEopEduEntryFromEDUID
- getEopEduEntryByID getEopEduEntryByID Needed for change many parameters of entry.
- getDataEopDu getDataEopDu
- getEduEntry getEduEntry
- getEduEntryByType getEduEntryByType
- getEduIndexByType getEduIndexByType
- setEntryUnitCardTga setEntryUnitCardTga (only for eopdu units added by file!)
- setEntryInfoCardTga setEntryInfoCardTga (only for eopdu units added by file!)
- setEntrySoldierModel setEntrySoldierModel
- getArmourUpgradeLevelsNum getArmourUpgradeLevelsNum
- setArmourUpgradeLevelsNum setArmourUpgradeLevelsNum (only for eopdu units added by file!)
- getArmourUpgradeLevel getArmourUpgradeLevel
- setArmourUpgradeLevel setArmourUpgradeLevel (only for eopdu units added by file!)
- getArmourUpgradeModelsNum getArmourUpgradeModelsNum
- setArmourUpgradeModelsNum setArmourUpgradeModelsNum (only for eopdu units added by file!)
- getArmourUpgradeModel getArmourUpgradeModel
- setArmourUpgradeModel setArmourUpgradeModel (only for eopdu units added by file!)
- setEntryAttackAttribute setEntryAttackAttribute
- getEntryAttackAttribute getEntryAttackAttribute
- setEntryStat setEntryStat
- getEntryStat getEntryStat
- setEntryLocalizedName setEntryLocalizedName
- setEntryLocalizedDescr setEntryLocalizedDescr
- setEntryLocalizedShortDescr setEntryLocalizedShortDescr
- M2TWEOPDU.addEopEduEntryFromFile (filepath, eopEnryIndex)
-
Create new M2TWEOPDU entry from a file describing it.
Parameters:
- filepath string path to file with unit type description(like in export_descr_unit.txt, but only with one record and without comments)
- eopEnryIndex int Entry index, which will be assigned to a new record in DU (recommend starting from 1000, so that there is no confusion with records from EDU).
Returns:
-
eduEntry
retEntry Usually you shouldn't use this value.
Usage:
M2TWEOPDU.addEopEduEntryFromFile(M2TWEOP.getModPath().."/eopData/unitTypes/myTestType.txt",1000);
- M2TWEOPDU.addEopEduEntryFromEDUID (baseEnryIndex, eopEnryIndex)
-
Create new M2TWEOPDU entry.
Parameters:
- baseEnryIndex int Entry index number, which will be taken as the base for this DU record.
- eopEnryIndex int Entry index, which will be assigned to a new record in DU (recommend starting from 1000, so that there is no confusion with records from EDU).
Returns:
-
eduEntry
retEntry Usually you shouldn't use this value.
Usage:
M2TWEOPDU.addEopEduEntryFromEDUID(1,1000);
- M2TWEOPDU.getEopEduEntryByID (eopEnryIndex)
-
Get eduEntry of a M2TWEOPDU entry. Needed to change many parameters of the entry.
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
Returns:
-
eduEntry
retEntry
Usage:
local eduEntryOfEOPDU=M2TWEOPDU.getEopEduEntryByID(1000); eduEntryOfEOPDU.SoldierCount=20; eduEntryOfEOPDU.Width=1.5;
- M2TWEOPDU.getEduEntry (EnryIndex)
-
Get eduEntry by index. Needed to change many parameters of the entry.
Parameters:
- EnryIndex int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
Returns:
-
eduEntry
retEntry
Usage:
local eduEntry=M2TWEOPDU.getEduEntry(5); eduEntry.SoldierCount=20; eduEntry.Width=1.5;
- M2TWEOPDU.getEduEntryByType (type)
-
Get eduEntry by edu type name. Needed to change many parameters of the entry.
Parameters:
- type string Unit type as in exportdescrunit.
Returns:
-
eduEntry
retEntry
Usage:
local eduEntry=M2TWEOPDU.getEduEntryByType("Peasants"); eduEntry.SoldierCount=20; eduEntry.Width=1.5;
- M2TWEOPDU.getEduIndexByType (type)
-
Get edu index by edu type name. Needed to use many edu functions.
Parameters:
- type string Unit type as in exportdescrunit.
Returns:
-
int
eduindex
Usage:
local eduindex=M2TWEOPDU.getEduIndexByType("Peasants"); M2TWEOPDU.setEntryStat(eduindex, eduStat.armour, 5, 1);
- M2TWEOPDU.getDataEopDu (eopEnryIndex)
-
Get data of a M2TWEOPDU entry. You usually won't need this.
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
Returns:
-
int
retEntry Usually you shouldn't use this value.
Usage:
local eopEntry=M2TWEOPDU.getDataEopDu(1000);
- M2TWEOPDU.setEntryUnitCardTga (eopEnryIndex, newCardTga)
-
Set unit card for a M2TWEOPDU entry. Requirements for the location and parameters of the image are unchanged in relation to the game (only for eopdu units added by file!).
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
- newCardTga string
Usage:
M2TWEOPDU.setEntryUnitCardTga(1000,"#akavir_swordsmen.tga");
- M2TWEOPDU.setEntryInfoCardTga (eopEnryIndex, newInfoCardTga)
-
Set unit info card for M2TWEOPDU entry. Requirements for the location and parameters of the image are unchanged in relation to the game (only for eopdu units added by file!).
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
- newInfoCardTga string
Usage:
M2TWEOPDU.setEntryInfoCardTga(1000,"akavir_swordsmen_info.tga");
- M2TWEOPDU.setEntrySoldierModel (eopEnryIndex, newSoldierModel)
-
Set unit info card for a M2TWEOPDU entry. Requirements for the location and parameters of the image are unchanged in relation to the game.
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
- newSoldierModel string
Usage:
M2TWEOPDU.setEntrySoldierModel(1000,"Sword_and_Buckler_Men");
- M2TWEOPDU.getArmourUpgradeLevelsNum (index)
-
Get the amount of numbers in the armourupglevels line in exportdescrunit.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
Returns:
-
int
ArmourUpgradeLevelsNum
Usage:
M2TWEOPDU.getArmourUpgradeLevelsNum(1000);
- M2TWEOPDU.setArmourUpgradeLevelsNum (index, amount)
-
Set the amount of armourupglevels, if you increase the amount of levels the last number entry will be repeated (only for eopdu units added by file!).
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- amount int
Usage:
M2TWEOPDU.setArmourUpgradeLevelsNum(1000, 3);
- M2TWEOPDU.getArmourUpgradeLevel (index, levelidx)
-
Get armour upgrade level number at specified index.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- levelidx int
Returns:
-
int
level
Usage:
M2TWEOPDU.getArmourUpgradeLevel(1000, 0);
- M2TWEOPDU.setArmourUpgradeLevel (index, levelidx, newlevel)
-
Set armour upgrade level number at specified index (only for eopdu units added by file!).
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- levelidx int
- newlevel int
Usage:
M2TWEOPDU.setArmourUpgradeLevel(1000, 1, 4);
- M2TWEOPDU.getArmourUpgradeModelsNum (index)
-
Get the amount of models in the armourupgmodels line in exportdescrunit.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
Returns:
-
int
ArmourUpgradeLevelsNum
Usage:
M2TWEOPDU.getArmourUpgradeModelsNum(1000);
- M2TWEOPDU.setArmourUpgradeModelsNum (index, amount)
-
Set the amount of armourupglevels, if you increase the amount of models the last model entry will be repeated (only for eopdu units added by file!).
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- amount int Maximum: 4
Usage:
M2TWEOPDU.setArmourUpgradeModelsNum(1000, 3);
- M2TWEOPDU.getArmourUpgradeModel (index, levelidx)
-
Get armour upgrade level number at specified index.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- levelidx int
Returns:
-
string
modelName
Usage:
M2TWEOPDU.getArmourUpgradeModel(1000, 0);
- M2TWEOPDU.setArmourUpgradeModel (index, levelidx, modelName)
-
Set the unit model at specified index (only for eopdu units added by file!).
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- levelidx int
- modelName string
Usage:
M2TWEOPDU.setArmourUpgradeModel(1000, 1, 4);
- M2TWEOPDU.setEntryAttackAttribute (index, attribute, enable, sec)
-
Set a primary or secondary attack attribute of an edu entry.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- attribute int Use the attackAttr enum: attackAttr.spear, attackAttr.light_spear, attackAttr.prec, attackAttr.ap, attackAttr.bp, attackAttr.area, attackAttr.fire, attackAttr.launching, attackAttr.thrown, attackAttr.short_pike, attackAttr.long_pike, attackAttr.spear_bonus_12, attackAttr.spear_bonus_10, attackAttr.spear_bonus_8, attackAttr.spear_bonus_6, attackAttr.spear_bonus_4.
- enable boolean
- sec int 1 = primary, 2 = secondary.
Usage:
M2TWEOPDU.setEntryAttackAttribute(1000, attackAttr.ap, true, 1);
- M2TWEOPDU.getEntryAttackAttribute (index, attribute, sec)
-
Get a primary or secondary attack attribute from an edu entry.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- attribute int Use the attackAttr enum: attackAttr.spear, attackAttr.light_spear, attackAttr.prec, attackAttr.ap, attackAttr.bp, attackAttr.area, attackAttr.fire, attackAttr.launching, attackAttr.thrown, attackAttr.short_pike, attackAttr.long_pike, attackAttr.spear_bonus_12, attackAttr.spear_bonus_10, attackAttr.spear_bonus_8, attackAttr.spear_bonus_6, attackAttr.spear_bonus_4.
- sec int 1 = primary, 2 = secondary.
Returns:
-
boolean
hasAttackAttribute
Usage:
M2TWEOPDU.getEntryAttackAttribute(1000, attackAttr.ap, 1);
- M2TWEOPDU.setEntryStat (index, eduStat, value, sec)
-
Set any of the basic unit stats of an edu entry.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- eduStat int Use the eduStat enum: eduStat.armour, eduStat.defense, eduStat.shield, eduStat.attack, eduStat.charge.
- value int
- sec int 1 = primary, 2 = secondary.
Usage:
M2TWEOPDU.setEntryStat(1000, attackAttr.attack, 1);
- M2TWEOPDU.getEntryStat (index, eduStat, sec)
-
Get any of the basic unit stats of an edu entry.
Parameters:
- index int Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry).
- eduStat int Use the eduStat enum: eduStat.armour, eduStat.defense, eduStat.shield, eduStat.attack, eduStat.charge.
- sec int 1 = primary, 2 = secondary.
Returns:
-
int
unitStat
Usage:
M2TWEOPDU.getEntryStat(1000, attackAttr.attack, 1);
- M2TWEOPDU.setEntryLocalizedName (eopEnryIndex, newLocalizedName)
-
Set localized name for a M2TWEOPDU entry. This does not require any entries in the text folder.
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
- newLocalizedName string
Usage:
M2TWEOPDU.setEntryLocalizedName(1000,"Test unit");
- M2TWEOPDU.setEntryLocalizedDescr (eopEnryIndex, newLocalizedDescr)
-
Set localized description for M2TWEOPDU entry. This does not require any entries in the text folder.
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
- newLocalizedDescr string
Usage:
M2TWEOPDU.setEntryLocalizedDescr(1000,"This is test unit description\n123321\nCreated with m2tweop");
- M2TWEOPDU.setEntryLocalizedShortDescr (eopEnryIndex, newLocalizedShortDescr)
-
Set localized short description for M2TWEOPDU entry. This does not require any entries in the text folder.
Parameters:
- eopEnryIndex int Entry index in M2TWEOPDU.
- newLocalizedShortDescr string
Usage:
M2TWEOPDU.setEntryLocalizedShortDescr(1000,"This is test unit short description\n123321\nCreated with m2tweop");
EdbEntry
- edbEntry
-
Basic edbEntry table.
Fields:
- buildingID int
- classification int
- isCoreBuilding int
- isPort int
- isCoreBuilding2 int
- hasReligion int
- religionID int
- isHinterland int
- isFarm int
- buildingLevelCount int
Capability
- capability
-
Basic capability table.
Fields:
- capabilityType int
- capabilityLvl int
- bonus int
- capabilityID int
RecruitPool
- recruitpool
-
Basic recruitpool table.
Fields:
- capabilityType int
- capabilityLvlorExp int Difference is for agents
- unitID int
- initialSize float
- gainPerTurn float
- maxSize float
EDB
- EDB
-
Basic EDB table.
Fields:
- addEopBuildEntry addEopBuildEntry
- getEopBuildEntry getEopBuildEntry
- setBuildingPic setBuildingPic
- setBuildingPicConstructed setBuildingPicConstructed
- setBuildingPicConstruction setBuildingPicConstruction
- setBuildingLocalizedName setBuildingLocalizedName
- setBuildingLocalizedDescr setBuildingLocalizedDescr
- setBuildingLocalizedDescrShort setBuildingLocalizedDescrShort
- addBuildingCapability addBuildingCapability
- removeBuildingCapability removeBuildingCapability
- getBuildingCapability getBuildingCapability
- getBuildingCapabilityNum getBuildingCapabilityNum
- addBuildingPool addBuildingPool
- removeBuildingPool removeBuildingPool
- getBuildingPool getBuildingPool
- getBuildingPoolNum getBuildingPoolNum
- getBuildingByName getBuildingByName
- EDB.addEopBuildEntry (edbEntry, newIndex)
-
Create new EOP Building entry
Parameters:
- edbEntry edbEntry Old entry.
- newIndex int New index of new entry. Use index > 127!
Returns:
-
edbEntry
eopentry.
Usage:
-- Basic Example oldBuilding = EDB.getBuildingByName("market") newBuilding = EDB.addEopBuildEntry(oldBuilding,150); -- Full example local oldBuilding = EDB.getBuildingByName("market"); local eopBuilding = EDB.addEopBuildEntry(oldBuilding, 150); -- Set pictures, names and descriptions by culture and faction for c = 0, 6 do --every culture EDB.setBuildingPic(eopBuilding, 'some path to pic', 0, c) EDB.setBuildingPicConstructed(eopBuilding,'some path to pic', 0, c) end for f = 0, 30 do --every faction EDB.setBuildingLocalizedName(eopBuilding, 'some name', 0, f) EDB.setBuildingLocalizedDescr(eopBuilding, 'some description', 0, f) end -- Add in an income bonus of 500 EDB.addBuildingCapability(eopBuilding, 0, buildingCapability.income_bonus, 500, true) -- Add a recruit pool EDB.addBuildingPool(eopBuilding, 0, M2TWEOPDU.getEduIndexByType("Peasants"), 1, 0.1, 2, 0, ""); -- Create a dummy building and get it sett:createBuilding("market");; --just assuming you have got a sett with some loop or function -- Set the existing building in the settlement to be the EOP building we just created local dummyBuilding = sett:getBuilding(5) dummyBuilding.edbEntry = eopBuilding
- EDB.getEopBuildEntry (index)
-
Get EOP Building entry. Returns vanilla build entry if you use a vanilla building index (< 128).
Parameters:
- index int Index of eop entry.
Returns:
-
edbEntry
eopentry.
Usage:
building = EDB.getEopBuildEntry(150);
- EDB.setBuildingPic (edbEntry, newPic, level, culture)
-
Set picture of building.
Parameters:
- edbEntry edbEntry Entry to set.
- newPic string Path to new pic.
- level int Building level to set pic for.
- culture int ID of the culture to set the pic for.
Usage:
building = EDB.getBuildingByName("market") EDB.setBuildingPic(building, modPath .. mp_path_mods .. "data/ui/northern_european/buildings/#northern_european_vintner.tga", 0, 4);
- EDB.setBuildingPicConstructed (edbEntry, newPic, level, culture)
-
Set constructed picture of building.
Parameters:
- edbEntry edbEntry Entry to set.
- newPic string Path to new pic.
- level int Building level to set pic for.
- culture int ID of the culture to set the pic for.
Usage:
building = EDB.getBuildingByName("market") EDB.setBuildingPicConstructed(building, modPath .. mp_path_mods .. "data/ui/northern_european/buildings/#northern_european_vintner.tga", 0, 4);
- EDB.setBuildingPicConstruction (edbEntry, newPic, level, culture)
-
Set construction picture of building.
Parameters:
- edbEntry edbEntry Entry to set.
- newPic string Path to new pic.
- level int Building level to set pic for.
- culture int ID of the culture to set the pic for.
Usage:
building = EDB.getBuildingByName("market") EDB.setBuildingPicConstruction(building, modPath .. mp_path_mods .. "data/ui/northern_european/buildings/#northern_european_vintner.tga", 0, 4);
- EDB.setBuildingLocalizedName (edbEntry, newName, level, facnum)
-
Set name of a building.
Parameters:
- edbEntry edbEntry Entry to set.
- newName string New name.
- level int Building level.
- facnum int Faction ID of the faction to set it for (dipNum).
Usage:
building = EDB.getBuildingByName("market") EDB.setBuildingLocalizedName(building, modPath .. mp_path_mods .. "data/ui/northern_european/buildings/#northern_european_vintner.tga", 0, 4);
- EDB.setBuildingLocalizedDescr (edbEntry, newName, level, facnum)
-
Set description of a building.
Parameters:
- edbEntry edbEntry Entry to set.
- newName string New description.
- level int Building level.
- facnum int Faction ID of the faction to set it for (dipNum).
Usage:
building = EDB.getBuildingByName("market") EDB.setBuildingLocalizedDescr(building, modPath .. mp_path_mods .. "data/ui/northern_european/buildings/#northern_european_vintner.tga", 0, 4);
- EDB.setBuildingLocalizedDescrShort (edbEntry, newName, level, facnum)
-
Set short description of a building.
Parameters:
- edbEntry edbEntry Entry to set.
- newName string New short description.
- level int Building level.
- facnum int Faction ID of the faction to set it for (dipNum).
Usage:
building = EDB.getBuildingByName("market") EDB.setBuildingLocalizedDescrShort(building, modPath .. mp_path_mods .. "data/ui/northern_european/buildings/#northern_european_vintner.tga", 0, 4);
- EDB.addBuildingCapability (edbEntry, level, capability, value, bonus)
-
Add a capability to a building.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
- capability int ID of capability to set. Use buildingCapability enum.
- value int Value to set.
- bonus bool Is it bonus or not.
Usage:
building = EDB.getBuildingByName("market") -- Add a population growth bonus to the market building EDB.addBuildingCapability(building, 0, 0, 5, true); -- Add a 500 income bonus to the market building EDB.addBuildingCapability(building, 0, buildingCapability.income_bonus, 500, true)
- EDB.removeBuildingCapability (edbEntry, level, index)
-
Remove a capability from a building.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
- index int Which capability to remove (In order of iterating).
Usage:
building = EDB.getBuildingByName("market") EDB.removeBuildingCapability(building, 0, 3);
- EDB.getBuildingCapability (edbEntry, level, index)
-
Get capability from a building at an index.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
- index int
Returns:
-
capability
capability.
Usage:
building = EDB.getBuildingByName("market") cap = EDB.getBuildingCapability(building, 0, 3);
- EDB.getBuildingCapabilityNum (edbEntry, level)
-
Get capability amount from a building.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
Returns:
-
int
capabilityNum.
Usage:
building = EDB.getBuildingByName("market") EDB.getBuildingCapabilityNum(building, 0);
- EDB.addBuildingPool (edbEntry, level, eduIndex, initialSize, gainPerTurn, maxSize, exp, condition)
-
Add a recruitment pool to a building.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
- eduIndex int edu index of unit to add.
- initialSize float Initial pool.
- gainPerTurn float Replenishment per turn.
- maxSize float Maximum size.
- exp int Initial experience.
- condition string Like in exportdescrbuildings but without "requires".
Usage:
building = EDB.getBuildingByName("market") EDB.addBuildingPool(building, 0, 55, 1, 0.1, 2, 0, "region_religion catholic 34");
- EDB.removeBuildingPool (edbEntry, level, index)
-
Remove a recruitment pool from a building.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
- index int Which pool to remove (In order of iterating).
Usage:
building = EDB.getBuildingByName("market") EDB.removeBuildingPool(building, 0, 3);
- EDB.getBuildingPool (edbEntry, level, index)
-
Get a recruitment pool from a building by index.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
- index int Which pool to get (In order of iterating).
Returns:
-
recruitpool
pool.
Usage:
building = EDB.getBuildingByName("market") EDB.getBuildingPool(building, 0, 3);
- EDB.getBuildingPoolNum (edbEntry, level)
-
Get a recruitment pool count.
Parameters:
- edbEntry edbEntry Entry to set.
- level int Building level.
Returns:
-
int
poolNum.
Usage:
building = EDB.getBuildingByName("market") EDB.getBuildingPoolNum(building, 0);
- EDB.getBuildingByName (buildingname)
-
Get a building edb entry by name.
Parameters:
- buildingname string
Returns:
-
edbEntry
entry
Usage:
building = EDB.getBuildingByName("market")
Game Options
- options1
-
Basic options1 table
Fields:
- widescreen int
- antiAliasMode int
- subtitles int
- english int
- noBattleTimeLimit int
- useNewCursorActions int
- campaignNumTimesPlay int
- uiWinConditions int
- isScenario int
- isHotseatEnabled int
- hotseatAutosave int
- email int
- saveConfig int
- closeAfterSave int
- validateData int
- campaignMapSpeedUp int
- skipAiFactions int
- labelCharacters int
- noBackGroundFmv int
- disableArrowMarkers int
- arcadeBattles int
- disableEvents int
- isPrologue int
- updateAiCamera int
- hideCampaign int
- unlimitedMenOnBattlefield int
- tgaReserveSpace int
- keysetUsed int
- muteAdvisor int
- advancedStatsAlways int
- microManageAllSettlements int
- blindAdvisor int
- terrainQuality int
- vegetationQuality int
- useQuickChat int
- graphicsAdaptor int
- showDemeanour int
- radar int
- unitCards int
- sa_cards int
- buttons int
- tutorialBattlePlayed int
- disableVnVs int
- allUsers int
- options2
-
Basic options2 table
Fields:
- campaignResolutionX int
- campaignResolutionY int
- battleResolutionX int
- battleResolutionY int
- vSync int
- uiIconBarCheck int
- uiRadarCheck int
- useMorale int
- uiAmmoCheck int
- useFatigue int
- uiSupplyCheck int
- toggleFowState int this does not toggle fow just remembers if it was on or off
- cameraRestrict int
- eventCutscenes int
- defaultCameraInBattle int
- splashes int
- stencilShadows int
- audioEnable int
- speechEnable int
- firstTimePlay int
- toggleAutoSave int
- showBanners int
- passwords int
- hotseatTurns int
- hotseatScroll int
- allowValidationFeatures int
- campaignSpeed int
- labelSettlements int
- disablePapalElections int
- autoresolveAllBattles int
- savePrefs int
- disableConsole int
- validateDiplomacy int
- unitDetail int
- buildingDetail int
- maxSoldiersOnBattlefield int if limited
- unitSize int
- cameraRotateSpeed int
- cameraMoveSpeed int
- cameraSmoothing float
- masterVolume int
- musicVolume int
- speechVolume int
- sfxVolume int
- subFactionAccents int
- tgaWidth int
- tgaAspect float
- tgaInputScale int
- scrollMinZoom int
- scrollMaxZoom int
- advisorVerbosity int
- effectQuality int
- EnableCameraCampaignSmoothing int
- chatMsgDuration int
- saveGameSpyPassword int
- addDateToLogs int
- showToolTips int
- isNormalHud int
- showPackageLitter int
- unitSizeMultiplierLow float
- unitSizeMultiplierMedium float
- unitSizeMultiplierLarge float
Campaign Difficulty Modifiers
- campaignDifficulty1
-
Basic campaignDifficulty1 table.
Fields:
- orderFromGrowth int
- considerWarWithPlayer int
- brigandChanceAi float
- brigandChancePlayer float
- forceAttackDelay int
- taxIncomeModifierPlayer float
- farmingIncomeModifierPlayer float
- incomeModifierAi float
- playerRegionValueModifier float
- campaignDifficulty2
-
Basic campaignDifficulty2 table.
Fields:
- popGrowthBonusAi int
- publicOrderBonusAi int
- experienceBonusAi int
- incomeBonusAi int
- wantsTargetPlayer int
- wantsTargetPlayerNaval int
- autoAttackPlayerIfCrusadeTarget int
eventTrigger
- eventTrigger
-
This is data that comes with game events. You need to check the event documentation to see what data is available under "Exports". The rest of the fields not stated inside "Exports" will return nil!
Fields:
- attackingUnit unit
- defendingUnit unit
- stratCharacter character
- character
namedCharacter
- Note it is namedCharacter, not character
- targetCharacter
namedCharacter
- Note it is namedCharacter, not character
- settlement settlementStruct
- targetSettlement settlementStruct
- fort fortStruct
- faction factionStruct
- targetFaction factionStruct
- army stackStruct
- regionID int
- targetRegionID int
- playerUnit unit
- enemyUnit unit
- battleBuilding buildingBattle
- priorBuild buildingInQueue
- resourceDescription string
- eduEntry eduEntry
- characterType int
- targetCharacterType int
- disasterType string
- missionSuccessLevel string
- missionProbability int
- missionDetails string
- eventID int
- guildID int
- eventCounter string
- coords coordPair
- religion int
- targetReligion int
- amount float
- crusade crusadeStruct
- captureInfo capturedFactionInfo
- ransomType string
- unit
unit
mapImage
- mapImageStruct
-
Fields:
- blurStrength float
- useBlur bool
- adaptiveBlur bool Can be slow on large or frequently updated images! needs use blur also true.
- makeMapImage makeMapImage
- clearMapImage clearMapImage
- loadMapTexture loadMapTexture
- fillRegionColor fillRegionColor
- addRegionColor addRegionColor
- fillTileColor fillTileColor
- addTileColor addTileColor
- mapImageStruct.makeMapImage ()
-
Create a new image you want to determine region colors.
Returns:
-
mapImageStruct
mapImage
Usage:
local mapImage = mapImageStruct.makeMapImage();
- mapImageStruct:clearMapImage ()
-
Reset image state.
Usage:
local mapImage = mapImageStruct.makeMapImage(); mapImage:clearMapImage();
- mapImageStruct:loadMapTexture (path)
-
Create a new map texture. Use an uncompressed(!) dds image that is some multiple of your mapregions size. The background must line up with mapregions for whatever scale you chose for it to display correctly.
Parameters:
- path string full path to texture
Returns:
- int x size of the image
- int y size of the image
- int id of the image
Usage:
local mapImage = mapImageStruct.makeMapImage(); local x, y, id = mapImage:loadMapTexture(M2TWEOP.getModPath() .. "map_regions.dds"); ImGui.Image(id, x, y);
- mapImageStruct:fillRegionColor (id, r, g, b, a)
-
Fill a region with a color.
Parameters:
- id int region ID
- r int red
- g int green
- b int blue
- a int alpha
Usage:
local mapImage = mapImageStruct.makeMapImage(); mapImage:fillRegionColor(50, 0, 255, 0, 255);
- mapImageStruct:addRegionColor (id, r, g, b, a)
-
Add a color to already filled region.
Parameters:
- id int region ID
- r int red
- g int green
- b int blue
- a int alpha
Usage:
local mapImage = mapImageStruct.makeMapImage(); mapImage:fillRegionColor(50, 0, 255, 0, 255); mapImage:addRegionColor(50, 10, -10, 10, 0);
- mapImageStruct:fillTileColor (x, y, r, g, b, a)
-
Fill a tile with a color.
Parameters:
- x int x coordinate
- y int y coordinate
- r int red
- g int green
- b int blue
- a int alpha
Returns:
-
mapImageStruct
mapImage
Usage:
local mapImage = mapImageStruct.makeMapImage(); mapImage:fillTileColor(153, 210, 0, 255, 0, 255);
- mapImageStruct:addTileColor (x, y, r, g, b, a)
-
Add a color to an already set tile.
Parameters:
- x int x coordinate
- y int y coordinate
- r int red
- g int green
- b int blue
- a int alpha
Returns:
-
mapImageStruct
mapImage
Usage:
local mapImage = mapImageStruct.makeMapImage(); mapImage:fillTileColor(153, 210, 0, 255, 0, 255); mapImage:addTileColor(153, 210, 20, -10, 20, 0);
unitInfoScroll
- unitInfoScroll
-
Basic unitInfoScroll table
Fields:
- buildingInfoScroll
-
Basic buildingInfoScroll table
Fields:
- settlement settlementStruct
- building building If the scroll is about existing building, this is set and edbEntry empty.
- edbEntry edbEntry only for non-constructed buildings.
uiCardManager
- uiCardManager
-
Basic uiCardManager table
Fields:
- selectedUnitCardsCount int
- unitCardsCount int
- selectedSettlement settlementStruct
- selectedCharacter character
- selectedFort fortStruct
- getSelectedUnitCard getSelectedUnitCard
- getUnitCard getUnitCard
- getBuildingInfoScroll getBuildingInfoScroll
- getUnitInfoScroll getUnitInfoScroll
- uiCardManager:getSelectedUnitCard (index)
-
Get selected unit card by index.
Parameters:
- index int
Returns:
-
unit
selectedUnit
Usage:
local cardManager=gameDataAll.get().uiCardManager; local selectedUnit=cardManager:getSelectedUnitCard(0);
- uiCardManager:getUnitCard (index)
-
Get unit card by index (battle or strat).
Parameters:
- index int
Returns:
-
unit
unit
Usage:
local cardManager=gameDataAll.get().uiCardManager; local unit=cardManager:getUnitCard(0);
- uiCardManager:getBuildingInfoScroll ()
-
Get building info scroll.
Returns:
-
buildingInfoScroll
scroll
Usage:
local infoScroll = cardManager:getBuildingInfoScroll();
- uiCardManager:getUnitInfoScroll ()
-
Get unit info scroll.
Returns:
-
unitInfoScroll
scroll
Usage:
local infoScroll = cardManager:getUnitInfoScroll();
selectionInfo
- selectionInfo
-
Basic selectionInfo table
Fields:
- selectedCharacter character (Get only)
- hoveredCharacter character (Get only)
- selectedEnemyCharacter character You can only select non-player characters with zoom to location button (Get only)
- selectedSettlement settlementStruct (Get only)
- hoveredSettlement settlementStruct (Get only)
- selectedEnemySettlement settlementStruct You can only select non-player settlements with zoom to location button (Get only)
- selectedFort fortStruct (Get only)
- hoveredFort fortStruct (Get only)
- selectedEnemyFort fortStruct You can only select non-player forts with zoom to location button (Get only)
Campaign
- campaignStruct
-
Basic campaign table.
Fields:
- playerFactionId int
- campaignDifficultyFaction int[31] Indexing starts at 1, so add 1 to faction ID. Maximum 31.
- battleDifficultyFaction int[31] Indexing starts at 1, so add 1 to faction ID. Maximum 31.
- factionsSortedByDescrStrat factionStruct[31] Table of factionStruct[31], indexing starts at 1. Maximum 31. Slightly misleading name, sorted by the turn order of the factions. Player controlled faction is at index 0 in single player.
- factionsSortedByID factionStruct[31] Table of factionStruct[31], indexing starts at 1, so add 1 to faction ID. Maximum 31.
- numberOfFactions int
- numberHumanFactions int Number of player-controlled factions.
- currentFaction factionStruct Faction whose turn it is at the moment, can be set.
- collegeOfCardinals collegeOfCardinals
- papalFaction factionStruct
- fogOfWar int
- factionTurnID int
- tickCount int
- millisecondCount int
- secondCount float
- turnNumber int
- timescale float Factor for number of turns per year, see descr_strat.txt
- romeSettlement settlementStruct
- constantinopleSettlement settlementStruct
- crusade crusadeStruct
- jihad jihadStruct
- BrigandSpawnValue float Lower values increase spawn rate.
- PirateSpawnValue float Lower values increase spawn rate.
- restrictAutoResolve int
- saveEnabled int
- FreeUpkeepForts int Number of units who get free upkeep in forts.
- currentDate float
- currentSeason int season (0=summer, 1=winter)
- startDate float
- startSeason int season (0=summer, 1=winter)
- endDate float
- endSeason int season (0=summer, 1=winter)
- daysInBattle int
- currentTimeInBattle float 24 max, so calculate as daysInBattle*24+currentTimeInBattle.
- fortsNum int
- portsBuildingsNum int
- watchTowerNum int
- slaveFactionID int
- roadsNum int
- nightBattlesEnabled int
- rebellingCharactersActive int
- checkDipStance checkDipStance
- setDipStance setDipStance
- GetUnitSize GetUnitSize
- getCampaignPath getCampaignPath
- getFort getFort
- getPort getPort
- getWatchTower getWatchTower
- getFaction getFaction
- getSettlementByName getSettlementByName
- getMercPool getMercPool
- getRoad getRoad
- campaignStruct:checkDipStance (checkType, fac1, fac2)
-
Check if a diplomatic relation between two factions.
Parameters:
- checkType dipRelType Example: dipRelType.war
- fac1 factionStruct A faction.
- fac2 factionStruct Another faction.
Returns:
-
bool
checkResult
Usage:
local campaign=gameDataAll.get().campaignStruct; local fac1=campaign.factionsSortedByDescrStrat[1]; local fac2=campaign.factionsSortedByDescrStrat[2]; local isInWar=campaign:checkDipStance(dipRelType.war,fac1,fac2);
- campaignStruct:setDipStance (relType, fac1, fac2)
-
Set a diplomatic relation between two factions.
Parameters:
- relType dipRelType Example: dipRelType.war
- fac1 factionStruct A faction.
- fac2 factionStruct Another faction.
Usage:
local campaign=gameDataAll.get().campaignStruct; local fac1=campaign.factionsSortedByDescrStrat[1]; local fac2=campaign.factionsSortedByDescrStrat[2]; campaign:setDipStance(dipRelType.war,fac1,fac2);
- campaignStruct:GetUnitSize ()
-
Get size of unit(i.e. small or medium, etc). Numbers from 0 to 3
Returns:
-
int
unitSize
Usage:
local campaign=gameDataAll.get().campaignStruct; local unitSize=campaign:GetUnitSize();
- campaignStruct:getFort (index)
-
Get fort by index.
Parameters:
- index int
Returns:
-
fortStruct
fort
Usage:
local campaign=gameDataAll.get().campaignStruct; local fort=campaign:getFort(0);
- campaignStruct:getPort (index)
-
Get port by index.
Parameters:
- index int
Returns:
-
portStruct
port
Usage:
local campaign=gameDataAll.get().campaignStruct; local port=campaign:getPort(0);
- campaignStruct:getWatchTower (index)
-
Get watchtower by index.
Parameters:
- index int
Returns:
-
watchtowerStruct
watchtower
Usage:
local campaign=gameDataAll.get().campaignStruct; local watchtower=campaign:getWatchTower(0);
- campaignStruct:getSettlementByName (name)
-
Get settlement by internal name.
Parameters:
- name string
Returns:
-
settlementStruct
settlement
Usage:
local campaign=gameDataAll.get().campaignStruct; local sett=campaign:getSettlementByName("London");
- campaignStruct:getFaction (name)
-
Get a faction by it's internal name.
Parameters:
- name string
Returns:
-
factionStruct
faction
Usage:
local CAMPAIGN = gameDataAll.get().campaignStruct; local fac = CAMPAIGN:getFaction("england");
- campaignStruct:getCampaignPath ()
-
Get path to the current descr_strat file used.
Returns:
-
string
path
Usage:
local campaign = gameDataAll.get().campaignStruct; local path = campaign:getCampaignPath();
- campaignStruct:getMercPool (name)
-
Get a mercenary pool by name.
Parameters:
- name string
Returns:
-
mercPool
pool
Usage:
local campaign = gameDataAll.get().campaignStruct; local pool = campaign:getMercPool("mercpool1");
- campaignStruct:getRoad (index)
-
Get a road by index.
Parameters:
- index int
Returns:
-
roadStruct
road
Usage:
local campaign = gameDataAll.get().campaignStruct; local pool = campaign:getRoad(0);
CollegeofCardinals
- collegeOfCardinals
-
Basic College of Cardinals table.
Fields:
- pope namedCharacter
- cardinalNum int
- getCardinal getCardinal
- collegeOfCardinals:getCardinal (index)
-
Get a specific cardinal by index.
Parameters:
- index int
Returns:
-
character
cardinal
Usage:
local college = campaign.collegeOfCardinals; local cardinal = college:getCardinal(2);
Crusade
- crusadeStruct
-
Basic crusade table.
Fields:
- startTurn int
- endTurn int
- targetSettlement settlementStruct
- length int
- outcome int
Jihad
- jihadStruct
-
Basic jihad table.
Fields:
- startTurn int
- endTurn int
- targetSettlement settlementStruct
- length int
- outcome int
coords
Strat Map
- stratMap
-
Basic strat map table.
Fields:
- mapWidth int
- mapHeight int
- regionsNum int
- volcanoesNum int
- landConnectionsNum int
- landMassNum int
- getRegion getRegion
- getTile getTile
- getVolcanoCoords getVolcanoCoords
- getLandConnection getLandConnection
- getLandMass getLandMass
- getSettlement getSettlement
- getRegionByName getRegionByName
- stratMap.getRegion (index)
-
Get a specific region by index.
Parameters:
- index int
Returns:
-
regionStruct
region
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2);
- stratMap.getTile (x, y)
-
Get a specific tile by it's coordinates.
Parameters:
- x int
- y int
Returns:
-
tileStruct
tile
Usage:
local sMap = gameDataAll.get().stratMap; local tile = sMap.getTile(182, 243);
- stratMap:getVolcanoCoords (index)
-
Get a volcano's coordinates.
Parameters:
- index int
Returns:
-
coordPair
tile
Usage:
local sMap = gameDataAll.get().stratMap; local volcano = sMap:getVolcanoCoords(0);
- stratMap:getLandConnection (index)
-
Get a land connection's coordinates (the green arrows on the map that allow you to cross bodies of water).
Parameters:
- index int
Returns:
-
coordPair
tile
Usage:
local sMap = gameDataAll.get().stratMap; local connection = sMap:getLandConnection(0);
- stratMap:getLandMass (index)
-
Get a landmass (collection of regions reachable by land, like a continent or island).
Parameters:
- index int
Returns:
-
landMass
landMass
Usage:
local sMap = gameDataAll.get().stratMap; local tile = sMap:getLandMass(0);
- stratMap:getSettlement (name)
-
Get a settlement by its internal name. This is the intended way to get a settlement quickly by it's name.
Parameters:
- name string
Returns:
-
settlementStruct
settlement
Usage:
local STRAT_MAP = gameDataAll.get().stratMap; local london = STRAT_MAP:getSettlement("London");
- stratMap:getRegionByName (name)
-
Get a region by its internal name.
Parameters:
- name string
Returns:
-
regionStruct
region
Usage:
local STRAT_MAP = gameDataAll.get().stratMap; local londonRegion = STRAT_MAP:getRegionByName("London_Province");
landMass
- landMass
-
Basic landMass table.
Fields:
- index int
- regionsNum int
- getRegionID getRegionID
- landMass:getRegionID (index)
-
Get a region ID by index.
Parameters:
- index int
Returns:
-
int
regionID
Usage:
local region = landMass:getRegionID(0);
roadStruct
- roadStruct
-
Basic roadStruct table.
Fields:
- coordsNum int
- regionIdStart int
- regionIdEnd int
- getCoord getCoord
- tradeValue int --only counts from 1 side (importer)
- roadStruct:getCoord (index)
-
Get a road coord by index.
Parameters:
- index int
Returns:
-
coordPair
coords
Usage:
local coords = road:getCoord(0);
Tile
- tileStruct
-
Basic tile table.
Fields:
- road roadStruct
- isLand int (1 = land, 0 = sea)
- groundType
int
0 low fertility 1 medium fertility 2 high fertility 3 wilderness 4 high moutains 5 low moutains 6 hills 7 dense forest 8 woodland 9 swamp 10 ocean 11 deep sea 12 shallow sea 13 coast (beach) 14 impassable_land 15 impassable_sea
- regionID int
- resource tradeResource or nil
- character character or nil
- settlement settlementStruct or nil
- fort fortStruct or nil
- port portStruct or nil
- watchtower watchtowerStruct or nil
- height int
- climate int
- heatValue int
- factionID int
- xCoord int
- yCoord int
- objectTypes int bitfield, from left to right: unknown, character, ship, watchtower, port, ship, fort, settlement.
- hasRiver bool
- hasRiverSource bool
- hasCrossing bool
- hasCharacter bool
- hasShip bool
- hasWatchtower bool
- hasPort bool
- hasFort bool
- hasCliff bool
- hasSettlement bool
- isDevastated bool
- isCoastalWater bool
- roadLevel int Settlement tiles return 3.
- isLandConnection bool Crossing created by green arrows.
- isSeaCrossing bool Crossing created by close proximity, not green arrows.
- border int 1 = border, 2 = seaBorder, 3 = sea edge border (point where the region border both another land region and sea).
- armiesNearTile int bitfield of faction id's (counts both tile and the 8 tiles around it, if you want only on tile combine with charactersOnTile).
- charactersOnTile int bitfield of faction id's
- mpModifier float
- factionHasArmyNearTile factionHasArmyNearTile
- factionHasCharacterOnTile factionHasCharacterOnTile
- getTileCharacterCount getTileCharacterCount
- getTileCharacterAtIndex getTileCharacterAtIndex
- hasRoad int
- borderField int
- otherField int
- choke int
- ModelIsHills int
- tileStruct:factionHasArmyNearTile (factionID)
-
Check if a faction has an army near a tile.
Parameters:
- factionID int
Returns:
-
bool
hasArmyNearTile
Usage:
local hasArmyNearTile = tile:factionHasArmyNearTile(3);
- tileStruct:factionHasCharacterOnTile (factionID)
-
Check if a faction has a character on a tile.
Parameters:
- factionID int
Returns:
-
bool
hasCharacterOnTile
Usage:
local hasCharacterOnTile = tile:factionHasCharacterOnTile(3);
- tileStruct:getTileCharacterCount ()
-
Get amount of characters on a tile.
Returns:
-
int
characterCount
Usage:
local tileCharacterCount = tile:getTileCharacterCount();
- tileStruct:getTileCharacterAtIndex (index)
-
Get a character on a tile.
Parameters:
- index int
Returns:
-
character
char
Usage:
local tileCharacterCount = tile:getTileCharacterCount(); for i=0,tileCharacterCount -1 do local character = tile:getTileCharacterAtIndex(i); end
RegionStruct
- regionStruct
-
Basic regionStruct table.
Fields:
- regionName string
- localizedName string
- settlementName string
- legioName string
- regionID int
- roadLevel int as set in descr_strat
- farmingLevel int as set in descr_strat
- famineThreat int
- harvestSuccess int
- totalSeaTradeValue int
- stacksNum int
- fortsNum int
- colorRed int
- colorGreen int
- colorBlue int
- watchtowersNum int
- isSea int
- hasLake int (fully enclosed by region)
- landMass landMass
- roadToPort roadStruct
- seaConnectedRegionsCount int
- loyaltyFactionID int
- seaExportRegion seaConnectedRegion
- seaImportRegionsCount int
- regionSeaEdgesCount int (point where the region border both another land region and sea).
- tilesBorderingEdgeOfMapCount int
- devastatedTilesCount int
- settlement settlementStruct
- tileCount int
- fertileTilesCount int
- neighbourRegionsNum int
- resourcesNum int
- resourceTypesBitMap int
- hiddenResources1 int (bitmap with 32 first hidden resources), needs to be converted to binary and then use bitwise operators from lua.
- hiddenResources2 int (bitmap last 32 first hidden resources), needs to be converted to binary and then use bitwise operators from lua.
- settlementXCoord int
- settlementYCoord int
- portEntranceXCoord int
- portEntranceYCoord int
- faction factionStruct
- mercPool mercPool
- rebelType string
- localizedRebelsName string
- triumphValue int
- getStack getStack
- getFort getFort
- getWatchtower getWatchtower
- getResource getResource
- getNeighbour getNeighbour
- getHiddenResource getHiddenResource
- setHiddenResource setHiddenResource
- getSeaConnectedRegion getSeaConnectedRegion
- getSeaImportRegion getSeaImportRegion
- getRegionSeaEdge getRegionSeaEdge
- getReligionHistory getReligionHistory
- getTileBorderingEdgeOfMap getTileBorderingEdgeOfMap
- getTile getTile
- getFertileTile getFertileTile
- getDevastatedTile getDevastatedTile
- getHostileArmiesStrength getHostileArmiesStrength
- hasResourceType hasResourceType
- regionStruct:getStack (index)
-
Get an army by it's index.
Parameters:
- index int
Returns:
-
stackStruct
army
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local army = region:getStack(0)
- regionStruct:getFort (index)
-
Get a fort by it's index.
Parameters:
- index int
Returns:
-
fortStruct
fort
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local fort = region:getFort(0)
- regionStruct:getWatchtower (index)
-
Get a watchtower by it's index.
Parameters:
- index int
Returns:
-
watchtowerStruct
watchtower
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local watch = region:getWatchtower(0)
- regionStruct:getResource (index)
-
Get a resource by it's index.
Parameters:
- index int
Returns:
-
tradeResource
resource
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local res = region:getResource(0)
- regionStruct:getNeighbour (index)
-
Get a neighbour region by it's index.
Parameters:
- index int
Returns:
-
neighbourRegion
nRegion
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local nRegion = region:getNeighbour(0)
- regionStruct:getHiddenResource (index)
-
Check if a region has a hidden resource.
Parameters:
- index int
Returns:
-
bool
hr
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); localhr = region:getHiddenResource(0)
- regionStruct:setHiddenResource (index, enable)
-
Set a region's hidden resource (reset on game restart).
Parameters:
- index int
- enable bool
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); region:setHiddenResource(0, false)
- regionStruct:getSeaConnectedRegion (index)
-
Get a region that is reachable from this region.
Parameters:
- index int
Returns:
-
seaConnectedRegion
connectedRegion
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local connectedRegion = region:getSeaConnectedRegion(0)
- regionStruct:getSeaImportRegion (index)
-
Get a region this region is importing trade goods from.
Parameters:
- index int
Returns:
-
seaConnectedRegion
seaImportRegion
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local seaImportRegion = region:getSeaImportRegion(0)
- regionStruct:getRegionSeaEdge (index)
-
Get a region sea edge (point where it borders both sea and another land region).
Parameters:
- index int
Returns:
-
tileStruct
edge
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local edge = region:getRegionSeaEdge(0)
- regionStruct:getDevastatedTile (index)
-
Get a devastated tile.
Parameters:
- index int
Returns:
-
tileStruct
tile
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local tile = region:getDevastatedTile(0)
- regionStruct:getTileBorderingEdgeOfMap (index)
-
Get a tile that borders the edge of the map.
Parameters:
- index int
Returns:
-
tileStruct
edge
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local edge = region:getTileBorderingEdgeOfMap(0)
- regionStruct:getTile (index)
-
Get a tile by index.
Parameters:
- index int
Returns:
-
tileStruct
tile
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local tile = region:getTile(0)
- regionStruct:getFertileTile (index)
-
Get a fertile tile by index.
Parameters:
- index int
Returns:
-
tileStruct
tile
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local tile = region:getFertileTile(0)
- regionStruct:getReligionHistory (religionID, turnsAgo)
-
Get religion amount from a set number of turns ago.
Parameters:
- religionID int
- turnsAgo int (max 19)
Returns:
-
float
religionAmount
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local catholicThreeTurnsAgo = region:getReligionHistory(0, 3)
- regionStruct:hasResourceType (resourceID)
-
Check if region has a resource type.
Parameters:
- resourceID int
Returns:
-
bool
hasResource
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local hasResource = region:hasResourceType(16)
- regionStruct:getHostileArmiesStrength (factionID)
-
Get the strength total of all armies in this region that are hostile to a specific faction.
Parameters:
- factionID int
Returns:
-
int
totalStrength
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local totalStrength = region:getHostileArmiesStrength(myFac.factionID)
neighbourRegion
- neighbourRegion
-
Basic neighbourRegion table.
Fields:
- regionID int
- region regionStruct
- tradeValue int
- notReachable int
- moveCost float
- borderTilesCount int
- connectingRoad roadStruct
- getBorderTile getBorderTile
- neighbourRegion:getBorderTile (index)
-
Get a border tile by index.
Parameters:
- index int
Returns:
-
tileStruct
tile
Usage:
local tile = nRegion:getBorderTile(0)
seaConnectedRegion
- seaConnectedRegion
-
Basic seaConnectedRegion table.
Fields:
- regionID int
- seaExportValue int
- seaImportValue int
- tilesReachableCount int
- seaTradeLanePathCount int
- getReachableTile getReachableTile
- getTradeLaneCoord getTradeLaneCoord
- seaConnectedRegion:getReachableTile (index)
-
Get a reachable tile by index.
Parameters:
- index int
Returns:
-
tileStruct
tile
Usage:
local tile = seaRegion:getReachableTile(0)
- seaConnectedRegion:getTradeLaneCoord (index)
-
Get trade lane coords by index.
Parameters:
- index int
Returns:
-
coordPair
coords
Usage:
local coords = seaRegion:getTradeLaneCoord(0)
MercPools
- mercPool
-
Basic mercenary pool table.
Fields:
- name string
- getMercUnitNum getMercUnitNum
- addMercUnit addMercUnit
- getMercUnit getMercUnit
- mercPool:getMercUnitNum ()
-
Get amount of mercenary units a region has.
Returns:
-
int
mercUnitNum
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local mercpool = region.mercPool; local mercNum = mercpool:getMercUnitNum();
- mercPool:addMercUnit (idx, exp, cost, repmin, repmax, maxunits, startpool, startyear, endyear, crusading)
-
Add a new mercenary unit to a pool.
Parameters:
- idx int EDU index, supports EOP units.
- exp int Starting experience.
- cost int
- repmin float Minimum replenishment rate.
- repmax float Maximum replenishment rate.
- maxunits int Maximum Pool.
- startpool float Starting pool.
- startyear int (0 to disable) Use 0 if the startyear is before the year you introduce the merc, not an earlier startyear!
- endyear int (0 to disable)
- crusading int
Returns:
-
mercPoolUnit
mercunit
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local mercpool = region.mercPool; local mercUnit = mercpool:addMercUnit(1907, 0, 570, 0.15, 0.35, 3, 3, 0, 0, 0);
- mercPool:getMercUnit (idx)
-
Get a mercenary unit from a pool by index.
Parameters:
- idx int
Returns:
-
mercPoolUnit
mercUnit
Usage:
local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); local mercpool = region.mercPool; local mercNum = mercPool:getMercUnitNum(); for i = 0, mercNum-1 do local mercUnit = mercpool:getMercUnit(i); end
MercenaryUnits
- mercPoolUnit
-
Basic mercenary unit table.
Fields:
- eduEntry eduEntry
- experience int
- cost int
- replenishMin float
- replenishMax float
- maxUnits int
- currentPool float
- startYear int
- endYear int
- crusading int
- poolIndex int
- mercPoolUnitIndex int
- mercPool mercPool
- setMercReligion setMercReligion
- mercPoolUnit:setMercReligion (religion, set)
-
Set or remove a religion requirement for a mercenary unit.
Parameters:
- religion int
- set bool True means enable this religion requirement, False means disable.
Usage:
local stratmap = gameDataAll.get().stratMap; local region = stratMap.getRegion(2); local mercpool = region.mercPool; local mercNum = mercPool:getMercUnitNum(); for i = 0, mercNum-1 do local mercUnit = mercPool:getMercUnit(i); mercUnit:setMercReligion(3, true) end
GameDataAll
- gameDataAll
-
Basic gameDataAll table
Fields:
- get get
- battleStruct battleStruct battle data
- campaignStruct campaignStruct campaign data
- uiCardManager uiCardManager ui and selected objects data
- stratMap stratMap data
- selectionInfo selectionInfo data
- gameDataAll.get ()
-
Call at the start of the script, this is a static object and the pointer to it doesn't change.
Returns:
-
gameDataAll
gameDataAll
Usage:
gameData=gameDataAll.get(); battleXCoord=gameData.battleStruct.xCoord;
BattleStruct
- battleStruct
-
basic battleStruct table
Fields:
- battleState
int
0 not in battle 1 prebattle scroll 2 delay (also for preconflict phase of successful ambushes) 3 deployment 4 5 conflict (also for pause) 6 victory scroll 7 pursuit 8 9 postbattle scroll (not for autoresolved battles)
- battleType
int
0 succesful ambush 1 failed ambush 2 normal 3 siege 4 sally besieger 5 naval 6 withdrawal?
- isNightBattle int
- xCoord int
- yCoord int
- attackerXCoord int
- attackerYCoord int
- defenderXCoord int
- defenderYCoord int
- paused int
- inBattle int
- battleSpeed float
- secondsPassed float
- secondsSinceBattleLoaded int
- hidingEnabledSet int
- fortInfo fortBattleInfo
- mapWidth float
- mapHeight float
- terrainFeatures terrainFeatures
- sidesNum int
- playerArmyNum int
- sides battleSide[8] Returns a battleSide[8]. Maximum: 8.
- factionSide int[31] faction alliance array, -1 if not in battle, start at 1 so faction ID + 1 Maximum 31.
- getPlayerArmy getPlayerArmy
- getBattleResidence getBattleResidence
- getUnitByLabel getUnitByLabel
- getGroupByLabel getGroupByLabel
- getBattleMapHeight getBattleMapHeight
- getBattlefieldEngines getBattlefieldEngines
- getBattleTile getBattleTile
- getZoneID getZoneID
- getPosPerimeter getPosPerimeter
- isZoneValid isZoneValid
- battleState
int
- battleStruct:getPlayerArmy (index)
-
Get a players army.
Parameters:
- index int
Returns:
-
stackStruct
army
Usage:
local playerArmy = battle:getPlayerArmy(0)
- battleStruct.getBattleResidence ()
-
Get table with certain info about the battle residence.
Returns:
-
battleResidence
battleResidence
Usage:
local battleResidence = battle.getBattleResidence()
- battleStruct.getUnitByLabel (label)
-
Get a unit by it's label.
Parameters:
- label string
Returns:
-
unit
foundUnit
Usage:
local unit = BATTLE.getUnitByLabel("a1u1");
- battleStruct.getGroupByLabel (label)
-
Get a group by it's label.
Parameters:
- label string
Returns:
-
unitGroup
foundGroup
Usage:
local group = BATTLE.getGroupByLabel("group1");
- battleStruct.getBattleMapHeight (xCoord, yCoord)
-
Get battlemap height at position.
Parameters:
- xCoord float
- yCoord float
Returns:
-
float
zCoord
Usage:
local unit = BATTLE.getBattleMapHeight(10,20);
- battleStruct.getBattlefieldEngines ()
-
Get battlefield engines.
Returns:
-
battlefieldEngines
engines
Usage:
local engines = BATTLE.getBattlefieldEngines();
- battleStruct.getBattleTile (xCoord, yCoord)
-
Get battlefield tile.
Parameters:
- xCoord float
- yCoord float
Returns:
-
battleTile
tile
Usage:
local tile = BATTLE.getBattleTile(103.65, 385.54);
- battleStruct.getZoneID (xCoord, yCoord)
-
Get zone ID.
Parameters:
- xCoord float
- yCoord float
Returns:
-
int
zoneID
Usage:
local id = BATTLE.getZoneID(103.65, 385.54);
- battleStruct.getPosPerimeter (xCoord, yCoord)
-
Get position perimeter.
Parameters:
- xCoord float
- yCoord float
Returns:
-
int
perimeter
Usage:
local perimeter = BATTLE.getPosPerimeter(103.65, 385.54);
- battleStruct.isZoneValid (zoneID)
-
Is zone valid.
Parameters:
- zoneID int
Returns:
-
bool
valid
Usage:
local valid = BATTLE.isZoneValid(3);
BattleSide
- battleSide
-
Basic battleSide table
Fields:
- isDefender bool
- isCanDeploy bool
- wonBattle int 0 = lose, 1 = draw, 2 = win
- battleSuccess int 0 = close, 1 = average, 2 = clear, 3 = crushing
- winConditions int[4] Returns an int index of a wincondition. Maximum 4.
- getWinConditionString getWinConditionString
- armiesNum int
- battleArmyNum int
- alliance int
- soldierCountStart int
- factionCount int
- totalStrength int
- reinforceArmyCount int
- battleOdds float
- activeArmyStrength int
- battleAIPlan battleAI
- getBattleArmy getBattleArmy
- getFaction getFaction
- getReinforcementArmy getReinforcementArmy
- armies battleSideArmy[64] Returns a table of battleSideArmy. Maximum: 64.
- battleSide.getWinConditionString (condition)
-
Get win condition string, for example: destroy_or_rout_enemy
Parameters:
- condition int
Returns:
-
string
winCondition destroy_or_rout_enemy, balance_of_strength_percent, destroy_enemy_strength_percent, capture_location, destroy_character, capture_major_settlement, capture_army_settlement, unknown_condition
Usage:
function onPostBattle(eventData) getBattleData() end function getBattleData() local thisBattle, battleList = gameData.battleStruct, "Function: getBattleData()" for i = 1, thisBattle.sidesNum, 1 do local thisSide = thisBattle.sides[i] battleList = battleList.."\n\tSide "..i.."\n\t\tisDefender: "..tostring(thisSide.isDefender).."\n\t\tisCanDeploy: "..tostring(thisSide.isCanDeploy).."\n\t\tarmiesNum: "..thisSide.armiesNum.."\n\t\twinConditions:" for j = 1, 4, 1 do local thisWinCond = thisSide.winConditions[j] if thisWinCond ~= 0 then battleList = battleList.."\n\t\t\t"..thisSide.getWinConditionString(thisWinCond) end end if thisSide.armies[1] ~= nil then local k = 1 repeat local thisArmy = thisSide.armies[k].army if thisArmy ~= nil then battleList = battleList.."\n\t\tArmy "..k.."\n\t\t\tFaction: "..thisArmy.faction.name if thisArmy.leader ~= nil then battleList = battleList.."\n\t\t\tLeader: "..thisArmy.leader.namedCharacter.fullName end end k = k + 1 until thisSide.armies[k] == nil end end print(battleList) end
- battleSide:getBattleArmy (index)
-
Get a battle army by it's index.
Parameters:
- index int
Returns:
-
battleArmy
army
Usage:
battleArmy = side:getBattleArmy(0)
- battleSide:getFaction (index)
-
Get a faction in this side by it's index.
Parameters:
- index int
Returns:
-
factionStruct
faction
Usage:
faction = side:getFaction(0)
- battleSide:getReinforcementArmy (index)
-
Get a reinforcement army in this side by it's index.
Parameters:
- index int
Returns:
-
stackStruct
army
Usage:
army = side:getReinforcementArmy(0)
battleSideArmy
- battleSideArmy
-
Basic battleSideArmy table
Fields:
- army stackStruct
- isReinforcement int
- deploymentArea deploymentAreaS
battlePos
DeploymentAreaS
- deploymentAreaS
-
Basic DeploymentAreaS table
Fields:
- coordsNum int
- getCoordPair getCoordPair
- deploymentAreaS:getCoordPair (index)
-
Get pair of coords with index.
Parameters:
- index int
Returns:
-
battlePos
position
Usage:
gameData=gameDataAll.get(); battleS=gameData.battleStruct; side1=gameData.battleStruct.sides[1]; deployArea1=side1.armies[1].deploymentArea; for i = 0, deployArea1.coordsNum-1 do xCoord,yCoord=side1.armies[1].deploymentArea:getCoordPair(i); print(xCoord,yCoord); end
BattleAI
- battleAI
-
Basic Battle AI table
Fields:
- gtaPlan
int
0 = "DO_NOTHING" 1 = "ATTACK_ALL" 2 = "DEFEND" 3 = "DEFEND_FEATURE" 4 = "HIDE" 5 = "AMBUSH" 6 = "SCOUT" 7 = "WITHDRAW" 8 = "ATTACK_SETTLEMENT" 9 = "DEFEND_SETTLEMENT" 10 = "SALLY_OUT"
- unitCount int
- enemyUnitCount int
- addedObjectivesCount int
- getObjective getObjective
- gtaPlan
int
- battleAI:getObjective (index)
-
Get a battle objective by it's index.
Parameters:
- index int
Returns:
-
battleObjective
objective
Usage:
local objective = battleAI:getObjective(0)
BattleObjective
- battleObjective
-
Basic battleObjective table
Fields:
- battleObjective:getUnit (index)
-
Get a unit by it's index.
Parameters:
- index int
Returns:
-
unit
unit
Usage:
local unit = battleObjective:getUnit(0)
- battleObjective:getType ()
-
Get the type of objective.
Returns:
-
int
objectiveType
Usage:
local objective = battleObjective:getType()
BattleArmy
- battleArmy
-
Basic battleArmy table
Fields:
- army stackStruct
- character character
- generalNumKillsBattle int
- totalValue float
- generalHPRatioLost float
- numKilledGenerals int
- unitCount int
- getBattleUnit getBattleUnit
- battleArmy:getBattleUnit (index)
-
Get a battle unit by it's index.
Parameters:
- index int
Returns:
-
battleUnit
unit
Usage:
unit = battleArmy:getBattleUnit(0)
BattleUnit
- battleUnit
-
Basic battleUnit table
Fields:
- unit unit
- valuePerSoldier float
- soldiersLost int
- soldiersStart int
- unitsRouted int
- soldiersKilled int
- takenPrisoner int
- prisonersCaught int
- soldiersHealed int
- unitsRoutedEnd int
- soldiersEnd int
- friendlyFireCasualties int
- expStart int
- expGained int
- isGeneral int
- hasWithdrawn int
battleResidence
- battleResidence
-
Basic battleResidence table
Fields:
- settlement settlementStruct
- battleBuildings battleBuildings
- faction factionStruct
- plazaData plazaData
- fortInfo fortBattleInfo
- settlementWallsBreached int
- settlementGateDestroyed int
- getBattleStreets getBattleStreets
- battleResidence.getBattleStreets ()
-
Get battle streets.
Returns:
-
battleStreets
streets
Usage:
local streets = battleResidence.getBattleStreets()
plazaData
- plazaData
-
Basic plazaData table
Fields:
- soldiersAlliance0 int
- soldiersAlliance1 int
- xCoord float
- yCoord float
- sizeX float
- sizeY float
- alliance int
- plazaMaxTime float
- plazaControlPerSecond float
- plazaControl float
battleBuildingStats
- battleBuildingStats
-
Basic battleBuildingStats table
Fields:
- name string
- flammability int
- impactDamage int
- health int (descr_walls, not currently battle)
- controlAreaRadius float
- manned int
- isSelectable int
- healthExcluded int
- getTowerStats getTowerStats
- towerStatsCount int
- battleBuildingStats:getTowerStats (index)
-
Get tower stats by index.
Parameters:
- index int
Returns:
-
towerStats
stats
Usage:
local stats = battleBuildingStats:getTowerStats(0)
towerStats
- towerStats
-
Basic towerStats table
Fields:
- range int
- projectile projectileStruct
- fireAngle float
- slotYawX float
- slotYawY float
- slotPitchX float
- slotPitchY float
- fireRates fireRate[4]
- fireRate
-
Basic fireRate table
Fields:
- normal int
- flaming int
terrainLine
- terrainLine
-
Basic terrainLine table
Fields:
- startX float
- startZ float
- startY float
- endX float
- endZ float
- endY float
- previousSegment terrainLine
- nextSegment terrainLine
terrainFeatureHill
- terrainFeatureHill
-
Basic terrainFeatureHill table
Fields:
- xCoord float
- zCoord float
- yCoord float
- radius float
- terrainLinesStart terrainLine
- area float
terrainHills
- terrainHills
-
Basic terrainHills table
Fields:
- hillsNum int
- nextHills terrainHills
- previousHills terrainHills
- getHill getHill
- terrainHills:getHill (index)
-
Get a hill by index.
Parameters:
- index int
Returns:
-
terrainFeatureHill
hill
Usage:
local hill = terrainHills:getHill(0)
terrainLines
- terrainLines
-
Basic terrainLines table
Fields:
- segmentNum int
- nextLines terrainLines
- previousLines terrainLines
- getTerrainLine getTerrainLine
- terrainLines:getTerrainLine (index)
-
Get a terrain line segment by index.
Parameters:
- index int
Returns:
-
terrainLine
line
Usage:
local lineSegment = terrainLines:getTerrainLine(0)
terrainFeatures
- terrainFeatures
-
Basic terrainFeatures table
Fields:
- lines terrainLines
- hills terrainHills
- width float
- widthHalf float
- length float
- lengthHalf float
- widthOnePercent float
- lengthOnePercent float
roadNode
battleStreets
- battleStreets
-
Basic battleStreets table
Fields:
- getStreetNode getStreetNode
- nodeNum nodeNum
- battleStreets:getStreetNode (index)
-
Get a street point.
Parameters:
- index int
Returns:
-
roadNode
node
Usage:
local node = battleStreets:getStreetNode(0)
buildingBattle
- buildingBattle
-
Basic buildingBattle table
Fields:
- type int
- endHealth int
- currentHealth int
- startHealth int
- alliance int
- factionId int
- faction factionStruct
- battleResidence battleResidence
- posX float
- posZ float
- posY float
- battleBuildingStats battleBuildingStats
- index int
Siege Engine
- siegeEngineStruct
-
Basic siegeEngineStruct table
Fields:
- xCoord float
- zCoord float
- yCoord float
- mass float
- angle int
- engineID int
- currentUnit unit
- lastUnit unit
- getType getType
- range int
- projectile projectileStruct
- siegeEngineStruct:getType ()
-
Get the type of the engine (use the enum).
Returns:
-
int
type
Usage:
local type = siegeEngineStruct:getType()
Battle Tile
Battlefield Engines
- battlefieldEngines
-
Basic battlefieldEngines table
Fields:
- engineNum int
- getEngine getEngine
- battlefieldEngines:getEngine (index)
-
Get an engine from the battlefield.
Parameters:
- index int
Returns:
-
siegeEngineStruct
engine
Usage:
local engine = battlefieldEngines:getEngine(0)
battleBuildings
- battleBuildings
-
Basic battleBuildings table
Fields:
- buildingCount int
- perimeterCount int
- getBuilding getBuilding
- getPerimeter getPerimeter
- battleBuildings:getBuilding (index)
-
Get a battle building by it's index.
Parameters:
- index int
Returns:
-
buildingBattle
building
Usage:
local building = battleBuildings:getBuilding(0)
- battleBuildings:getPerimeter (index)
-
Get a perimeter by it's index.
Parameters:
- index int
Returns:
-
perimeterBuildings
perimeter
Usage:
local perimeter = battleBuildings:getPerimeter(0)
perimeterBuildings
- perimeterBuildings
-
Basic perimeterBuildings table
Fields:
- buildingCount int
- getBuilding getBuilding
- perimeterBuildings:getBuilding (index)
-
Get a battle building in a perimiter by it's index.
Parameters:
- index int
Returns:
-
buildingBattle
building
Usage:
local building = perimeterBuildings:getBuilding(0)
fortBattleInfo
- fortBattleInfo
-
Basic fortBattleInfo table
Fields:
- fort fortStruct
- garrison stackStruct
- faction factionStruct
- ownerFactionID int
- creatorFactionID int
- fortFortificationLevel int
EOP Enums
- dipRelType
-
Enum with a list of types of diplomatic relations.
Fields:
- war int
- peace int
- alliance int
- suzerain int
- trade int (Doesn't work with trade rights agreements set at game start)
Usage:
local campaign=gameDataAll.get().campaignStruct; local fac1=campaign.factionsSortedByDescrStrat[1]; local fac2=campaign.factionsSortedByDescrStrat[2]; local isInWar=campaign:checkDipStance(dipRelType.war,fac1,fac2);
- unitBattleProperties
-
Enum with a list of types of unit battle properties.
Fields:
- guardMode int
- fireAtWill int
- skirmish int
- buildingCapability
-
Enum with a list of types of building capabilities.
Fields:
- population_growth_bonus int
- population_loyalty_bonus int
- population_health_bonus int
- trade_base_income_bonus int
- trade_level_bonus int
- trade_fleet int
- taxable_income_bonus int
- mine_resource int
- farming_level int
- road_level int
- gate_strength int
- gate_defences int
- wall_level int
- tower_level int
- armour int
- stage_games int
- stage_races int
- fire_risk int
- weapon_melee_simple int
- weapon_melee_blade int
- weapon_missile_mechanical int
- weapon_missile_gunpowder int
- weapon_artillery_mechanical int
- weapon_artillery_gunpowder int
- weapon_naval_gunpowder int
- upgrade_bodyguard int
- recruits_morale_bonus int
- recruits_exp_bonus int
- happiness_bonus int
- law_bonus int
- construction_cost_bonus_military int
- construction_cost_bonus_religious int
- construction_cost_bonus_defensive int
- construction_cost_bonus_other int
- construction_time_bonus_military int
- construction_time_bonus_religious int
- construction_time_bonus_defensive int
- construction_time_bonus_other int
- construction_cost_bonus_wooden int
- construction_cost_bonus_stone int
- construction_time_bonus_wooden int
- construction_time_bonus_stone int
- free_upkeep int
- pope_approval int
- pope_disapproval int
- religion_level int
- amplify_religion_level int
- archer_bonus int
- cavalry_bonus int
- heavy_cavalry_bonus int
- gun_bonus int
- navy_bonus int
- recruitment_cost_bonus_naval int
- retrain_cost_bonus int
- weapon_projectile int
- income_bonus int
- recruitment_slots int
- characterType
-
Enum with a list of character types.
Fields:
- spy int
- assassin int
- diplomat int
- admiral int
- merchant int
- priest int
- general int
- named_character int
- princess int
- heretic int
- witch int
- inquisitor int
- pope int
- sortType
-
Enum with a list of army sort types.
Fields:
- eduType int
- category int
- class int
- soldierCount int
- experience int
- categoryClass int
- aiUnitValue int
- aiPlan
-
Enum with a list of GTA AI plans.
Fields:
- doNothing int
- attackAll int
- defend int
- defendFeature int
- hide int
- ambush int
- scout int
- withdraw int
- attackSettlement int
- defendSettlement int
- sallyOut int
- aiObjective
-
Enum with a list of GTA AI objectives.
Fields:
- invalid int
- moveToPoint int
- attackEnemyBattleGroup int
- defendTerrainHill int
- defendTerrainForest int
- defendTerrainArea int
- defendCrossing int
- assaultCrossing int
- defendLine int
- scout int
- withdraw int
- defendSettlement int
- supportDefendSettlement int
- attackSettlement int
- skirmish int
- bombard int
- attackModel int
- sallyOut int
- ambush int
- resourceType
-
Enum with a list of resources.
Fields:
- gold int
- silver int
- fish int
- furs int
- grain int
- timber int
- iron int
- ivory int
- wine int
- slaves int
- chocolate int
- marble int
- textiles int
- dyes int
- tobacco int
- silk int
- sugar int
- sulfur int
- tin int
- spices int
- cotton int
- amber int
- coal int
- wool int
- elephants int
- camels int
- dogs int
- generic int
- moraleStatus
-
Enum of unit morale status.
Fields:
- berserk int
- impetuous int
- high int
- firm int
- shaken int
- wavering int
- routing int
- unitDiscipline
-
Enum of unit discipline.
Fields:
- berserker int
- impetuous int
- low int
- normal int
- disciplined int
- unitTraining
-
Enum of unit training.
Fields:
- untrained int
- trained int
- highly_trained int
- combatStatus
-
Enum of unit combat status.
Fields:
- notInCombat int
- victoryCertain int
- victoryAlmostCertain int
- victoryDistinct int
- balanced int
- defeatDistinct int
- defeatAlmostCertain int
- defeatCertain int
- battleSuccess
-
Enum of battle success types.
Fields:
- close int
- average int
- clear int
- crushing int
- mountClass
-
Enum of unit mount class.
Fields:
- horse int
- camel int
- elephant int
- infantry int
- battleType
-
Enum of battle types.
Fields:
- ambushSuccess int
- ambushFail int
- open int
- siege int
- sally int
- naval int
- withdrawal int
- meetEnemy int
- battleState
-
Enum of battle states.
Fields:
- notInBattle int
- preBattle int
- delay int
- deployment int
- deploymentPlayer2 int
- conflict int
- victoryScroll int
- pursuit int
- unitClass
-
Enum of unit classes
Fields:
- heavy int
- light int
- skirmish int
- spearmen int
- missile int
- unitCategory
-
Enum of unit categories
Fields:
- infantry int
- cavalry int
- siege int
- non_combatant int
- ship int
- handler int
- unitCategoryClass
-
Enum of unit categories and class combo
Fields:
- nonCombatant int
- lightInfantry int
- heavyInfantry int
- spearmenInfantry int
- missileInfantry int
- lightCavalry int
- heavyCavalry int
- missileCavalry int
- siegeWeapon int
- animalHandler int
- battleShip int
- managePolicy
-
Enum of automated settlement policy types
Fields:
- balanced int
- financial int
- military int
- growth int
- cultural int
- noPolicy int
- formationType
-
Enum of formation types
Fields:
- horde int
- column int
- square int
- wedge int
- squareHollow int
- phalanx int
- schiltrom int
- shieldWall int
- wall int
- movingThrough int
- battleBuildingType
-
Enum of battle building types
Fields:
- ambient int
- gate int
- tower int
- wall int
- physicalGroundType
-
Enum of battle ground types
Fields:
- grassShort int
- grassLong int
- sand int
- rock int
- forestDense int
- scrubDense int
- swamp int
- mud int
- mudRoad int
- stoneRoad int
- water int
- ice int
- snow int
- wood int
- dirt int
- unknown int
- engineType
-
Enum of engine types
Fields:
- catapult int
- trebuchet int
- ballista int
- bombard int
- grandBombard int
- hugeBombard int
- culverin int
- basilisk int
- cannon int
- mortar int
- scorpion int
- serpentine int
- rocketLauncher int
- ribault int
- monsterRibault int
- mangonel int
- tower int
- ram int
- ladder int
- holy_cart int
Campaign DB
- campaignDbRecruitment
-
Basic campaignDb Recruitment table
Fields:
- recruitmentSlots int
- retrainingSlots int
- deplenishPoolsWithCaps bool
- deplenishMultiplier float
- deplenishOffset float
- addDisbandNoCaps bool
- percentagePoolReductionLost int
- percentagePoolReductionOccupy int
- percentagePoolReductionSack int
- percentagePoolReductionExterminate int
- maxAgentsPerTurn int
- campaignDbReligion
-
Basic campaignDb Religion table
Fields:
- maxWitchesPerRegion int
- maxWitches int
- maxHereticsPerRegion int
- maxHeretics int
- maxInquisitorsPerRegion int
- maxInquisitors int
- maxHereticsConversionModifier float
- hereticConversionRateModifier float
- hereticConversionRateOffset float
- witchConversionRateOffset float
- inquisitorConversionRateModifier float
- inquisitorConversionRateOffset float
- priestConversionRateModifier float
- priestConversionRateOffset float
- witchChanceModifier float
- hereticChanceModifier float
- inquisitorChanceModifier float
- minCardinalPiety int
- convertToHereticBaseModifier float
- convertToHereticUnorthodoxModifier float
- inquisitorTurnStart int
- campaignDbBribery
-
Basic campaignDb Bribery table
Fields:
- baseCharacterChance float
- religionModifier float
- combinedAttributeModifier float
- briberAttributeDivisor float
- bribeeAttributeDivisor float
- armySizeModifier float
- baseSettlementChance float
- settlementLoyaltyModifier float
- settlementPopulationModifier float
- factionStandingDivisor float
- maxBribeChance float
- minBribeChance float
- bribeChanceModifier float
- campaignDbFamilyTree
-
Basic campaignDb Family Tree table
Fields:
- maxAge int
- maxAgeForMarriageMale int
- maxAgeForMarriageForFemale int
- maxAgeBeforeDeath int
- maxAgeOfChild int
- oldAge int
- ageOfManhood int
- daughtersAgeOfConsent int
- daughtersRetirementAge int
- ageDifferenceMin int
- ageDifferenceMax int
- parentToChildMinAgeDiff int
- minAdoptionAge int
- maxAdoptionAge int
- maxAgeForConception int
- ageOfManhoodClose int
- maxNumberOfChildren int
- campaignDbDiplomacy
-
Basic campaignDb Diplomacy table
Fields:
- maxDiplomacyItems int
- nullMissionScore int
- campaignDbDisplay
-
Basic campaignDb Display table
Fields:
- characterSelectionRadius float
- characterSelectionHeight float
- characterSelectionHeightCrouching float
- diplomacyScrollHeight float
- factionStandingMin float
- factionStandingMax float
- UseOrigRebelFactionModels bool
- hudTabTextOffset int
- useFactionCreatorSettModels bool
- standardSoldierLimit int
- standardSoldierLevelScale int
- clearBattleModelsOnNewFaction bool
- campaignDbRansom
-
Basic campaignDb Ransom table
Fields:
- captorReleaseChanceBase float
- captorReleaseChanceChivMod float
- captorRansomChanceBase float
- captorRansomChanceChivMod float
- captorRansomChanceTmMod float
- captiveRansomChanceBase float
- captiveRansomChanceChivMod float
- captiveRansomChanceTmMod float
- captiveRansomChanceMsmMod float
- campaignDbAutoresolve
-
Basic campaignDb Autoresolve table
Fields:
- minCapturePercent float
- maxCapturePercent float
- lopsidedThresh float
- lopsidedHnMod float
- separationMissileAdd int
- navalSinkModifier float
- navalSinkOffset float
- navalSinkMax float
- sallyAtDefDrawDivisor float
- useNewSettAutoResolve bool
- gateDefenceNumOilAttacks int
- gateDefenceStrengthOilBase float
- gateDefenceNumArrowAttacks int
- gateDefenceStrengthArrowBase float
- gateDefenceStrengthArrowLevelModifier float
- gateDefenceNumDefaultAttacks int
- gateDefenceStrengthDefaultBase float
- gateDefenceStrengthDefaultLevelModifier float
- settDefenceNumArrowAttacks int
- settDefenceStrengthArrowBase float
- settDefenceStrengthArrowModifier float
- settDefenceStrengthDefaultBase float
- settDefenceStrengthDefaultModifier float
- displayStrengthOil float
- displayStrengthArrow float
- displayStrengthDefault float
- campaignDbSettlement
-
Basic campaignDb Settlement table
Fields:
- sackMoneyModifier float
- exterminateMoneyModifier float
- chivSpfModifier float
- chivSofModifier float
- dreadSofModifier float
- pietyCorruptionModifier float
- pietyAdminSifModifier float
- portToPortMpMin float
- heresyUnrestNodifier float
- religionUnrestModifier float
- siegeGearRequiredForCityLevel int
- noTowersOnlyForCityLevel int
- minTurnKeepRebelGarrison int
- destroyEmptyForts bool
- canBuildForts bool
- raceGameCostsModifier float
- altRelAlliedModifier float
- altRelGovModifierBase float
- altRelGovCoefficient float
- campaignDbRevolt
-
Basic campaignDb Revolt table
Fields:
- endTurnModifier float
- excommunicatedModifier float
- newLeaderModifier float
- maxEffectiveLoyalty float
- rebelRegionModifier float
- shadowRegionModifier float
- rebelBorderModifier float
- shadowBorderModifier float
- numUnitsModifier float
- captainModifier float
- minRevoltChance float
- maxRevoltChance float
- aiRevoltModifier float
- shadowAuthorityModifier float
- shadowAuthorityModifierSett float
- campaignDbHorde
-
Basic campaignDb Horde table
Fields:
- endTargetFactionBonus int
- startTargetFactionBonus int
- farmingLevelBonus int
- sharedTargetBonus int
- disbandingHordeBonus int
- hordeStartingRegionBonus int
- hordeTargetResourceBonus int
- campaignDbMerchants
-
Basic campaignDb Merchants table
Fields:
- baseIncomeModifier float
- tradeBonusOffset float
- campaignDbAgents
-
Basic campaignDb Agents table
Fields:
- denounceInquisitorBaseChance float
- DenouncePriestBaseChance float
- denounceAttackModifier float
- denounceDefenceModifier float
- denounceChanceMax int
- assassinateBaseChance float
- assassinateAttackModifier float
- assassinateDefenceModifier float
- assassinatePublicModifier float
- assassinatePersonalModifier float
- assassinateCounterSpyModifier float
- assassinateAgentModifier float
- assassinateOwnRegionModifier float
- assassinateAssassinateAttrModifier float
- assassinateChanceMin int
- assassinateChanceMax int
- denounceHereticAttemptModifier float
- denounceCharacterAttemptModifier float
- acquisitionBaseChance float
- acquisitionLevelModifier float
- acquisitionAttackTradeRightsModifier float
- acquisitionDefenceTradeRightsModifier float
- acquisitionChanceMin int
- acquisitionChanceMax int
- inquisitorCrtHeresyDivisor float
- inquisitorCrtPfpModifier float
- inquisitorCrtPfpModifierMin float
- inquisitorCrtPfpModifierMax float
- inquisitorCrtChanceMax float
- spyBaseChance float
- spyLevelModifier float
- notSpyLevelModifier float
- spyPublicModifier float
- spyCounterSpyModifier float
- spyDistanceModifier float
- spySecretAgentTargetModifier float
- spySedentaryTurnsModifier float
- spyAllianceModifier float
- spyTargetEngagedModifier float
- spyInSettlementModifier float
- spyWatchtowerModifier float
- spyInOwnRegionModifier float
- spyChanceMin int
- spyChanceMax int
- campaignDbCrusades
-
Basic campaignDb Crusades table
Fields:
- requiredJihadPiety int
- maxDisbandProgress float
- nearTargetNoDisbandDistance float
- disbandProgressWindow int
- crusadeCalledStartTurn int
- jihadCalledStartTurn int
- movementPointsModifier float
- campaignDbAi
-
Basic campaignDb Ai table
Fields:
- priestReligionMin float
- priestReligionMax float
- priestHeresyMin float
- priestHeresyMax float
- priestReligionExport float
- priestMaxProdTurns float
- merchantMinSurvivalAcquire int
- attStrModifier float
- siegeAttStrModifier float
- crusadeAttStrModifier float
- sallyAttStrModifier float
- ambushAttStrModifier float
- strLimitWeak float
- strLimitStrong float
- campaignDbMisc
-
Basic campaignDb Misc table
Fields:
- fortDevastationDistance int
- armyDevastationDistance int
- fortDevastationModifier int
- armyDevastationModifier int
- allowEnemyForts bool
- siegeMovementPointsModifier int
- cavalryMovementPointsModifier int
- campaignDb
-
Basic campaignDb table
Fields:
- recruitment campaignDbRecruitment
- religion campaignDbReligion
- bribery campaignDbBribery
- familyTree campaignDbFamilyTree
- diplomacy campaignDbDiplomacy
- display campaignDbDisplay
- ransom campaignDbRansom
- autoResolve campaignDbAutoresolve
- settlement campaignDbSettlement
- revolt campaignDbRevolt
- horde campaignDbHorde
- merchants campaignDbMerchants
- agents campaignDbAgents
- crusades campaignDbCrusades
- ai campaignDbAi
- misc campaignDbMisc
- campaignDbExtra
-
Basic campaignDb Extra table (these options are just in another place in memory)
Fields:
- clearPoolsWithCaps bool
- addInitialWithCaps bool
- forceClampToMax bool
- witchConversionRateModifier float
- inquisitorTargetCrusades bool
- foundingConversionDefaultRate float
- ownerConversionDefaultRate float
- neighbourNormaliseWeight float
- governorConversionRateOffset float
- governorConversionRateModifier float
- spyConversionRateOffset float
- spyConversionRateModifier float
- spyConversionRateForeignModifier float
- bribeToFamilyTree bool
- enemiesRejectGifts bool
- useBalanceOwed bool
- recruitmentSortSimple bool
- keepOriginalHereticPortraits bool
- altSettOrderColors bool
- separateGamesRaces bool
- chivalryDisplayThreshold int
- captiveRansomForSlave bool
- switchableDefenceExposed bool
- gateDefenceStrengthOilLevelModifier float
- settDefenceStrengthNumDefaultAttacks int
- siegeGearRequiredForCastleLevel int
- noTowersOnlyForCastleLevel int
- fortFortificationLevel int
- alternativeReligiousUnrest bool
- revoltAdditionalArmies bool
- revoltCrusadingArmies bool
- agentsCanHide bool
- denounceChanceMin int
- inquisitorCrtChanceMin float
- inquisitorTargetLeaders bool
- inquisitorTargetHeirs bool
- spyRescaleChance bool
- allowResourceForts bool
- enableHotseatMessages bool
- enableBananaRepublicCheat bool
- enableUnitAccentOverrides bool
M2TWEOPFBX
- M2TWEOPFBX
-
Basic M2TWEOPFBX table. Contains descriptions of m2tweop fbx feathures.
Fields:
- addFbxModel addFbxModel
- deleteFbxModel deleteFbxModel
- getFbxModel getFbxModel
- addFbxObject addFbxObject
- deleteFbxObject deleteFbxObject
- getFbxObject getFbxObject
- setFbxObjectCoords setFbxObjectCoords
- getFbxObjectCoords getFbxObjectCoords
- setFbxObjectSize setFbxObjectSize
- getFbxObjectSize getFbxObjectSize
- setFbxObjectDrawState setFbxObjectDrawState
- getFbxObjectDrawState getFbxObjectDrawState
- setFbxObjectAnimState setFbxObjectAnimState
- getFbxObjectAnimState getFbxObjectAnimState
- setFbxObjectDrawType setFbxObjectDrawType
- getFbxObjectDrawType getFbxObjectDrawType
- M2TWEOPFBX.addFbxModel (modelPath, texturePath, modelID)
-
Load a new fbx model.
Parameters:
- modelPath string Path to .fbx file.
- texturePath string Path to .dds file
- modelID int ID to be used for this model.
Usage:
M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1);
- M2TWEOPFBX.deleteFbxModel (modelID)
-
Delete a fbx model.
Parameters:
- modelID int Model's ID that was specified when calling addFbxModel()
Usage:
--1 is id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); M2TWEOPFBX.deleteFbxModel(1);
- M2TWEOPFBX.getFbxModel (modelID)
-
Get an added fbx model by it's ID.
Parameters:
- modelID int Model's ID that was specified when calling addFbxModel()
Returns:
-
fbxModel
fbx model, not it`s ID!
Usage:
--1 is id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1);
- M2TWEOPFBX.addFbxObject (modelID, objectID)
-
Create new fbx object with our previously loaded model. It can be placed on map, etc.
Parameters:
- modelID int Model's ID that was specified when calling addFbxModel()
- objectID int The ID that the object should use
Returns:
-
fbxObject
The newly created FBX object (not it's ID)
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here local ourNewObject=M2TWEOPFBX.addFbxObject(1,2);
- M2TWEOPFBX.deleteFbxObject (object)
-
Delete an fbx object.
Parameters:
- object fbxObject The created FBX object (not it's ID)
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here local ourNewObject=M2TWEOPFBX.addFbxObject(1,2); M2TWEOPFBX.deleteFbxObject(ourNewObject);
- M2TWEOPFBX.getFbxObject (int)
-
Get an fbx object by it's ID.
Parameters:
- int objectID The ID of the FBX object you wish to retrieve
Returns:
-
fbxObject
The created FBX object (not it's ID)
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2);
- M2TWEOPFBX.setFbxObjectCoords (fbx, x, y, z)
-
Set an fbx object's coordinates.
Parameters:
- fbx fbxObject object
- x float coord
- y float coord
- z float coord
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1);
- M2TWEOPFBX.getFbxObjectCoords (fbx)
-
Get an fbx object's coordinates.
Parameters:
- fbx fbxObject object
Returns:
- float x coord
- float y coord
- float z coord
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject);
- M2TWEOPFBX.setFbxObjectSize (fbx, sizeModifier)
-
Set an fbx object's size modifier.
Parameters:
- fbx fbxObject object
- sizeModifier float object size modifier
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2);
- M2TWEOPFBX.getFbxObjectSize (fbx)
-
Get an fbx object's size modifier.
Parameters:
- fbx fbxObject object
Returns:
-
float
sizeModifier object size modifier
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2); local size=M2TWEOPFBX.getFbxObjectSize(ourNewObject);
- M2TWEOPFBX.setFbxObjectDrawState (fbx, is)
-
Set an fbx object's draw state.
Parameters:
- fbx fbxObject object
- is bool draw needed
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2); local size=M2TWEOPFBX.getFbxObjectSize(ourNewObject); M2TWEOPFBX.setFbxObjectDrawState(ourNewObject,true);
- M2TWEOPFBX.getFbxObjectDrawState (fbx)
-
Get an fbx object's draw state.
Parameters:
- fbx fbxObject object
Returns:
-
bool
is draw needed
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2); local size=M2TWEOPFBX.getFbxObjectSize(ourNewObject); M2TWEOPFBX.setFbxObjectDrawState(ourNewObject,true); local isDrawed=M2TWEOPFBX.getFbxObjectDrawState(ourNewObject);
- M2TWEOPFBX.setFbxObjectAnimState (fbx, is)
-
Set an fbx object's animation state.
Parameters:
- fbx fbxObject object
- is bool animation needed
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2); local size=M2TWEOPFBX.getFbxObjectSize(ourNewObject); M2TWEOPFBX.setFbxObjectDrawState(ourNewObject,true); local isDrawed=M2TWEOPFBX.getFbxObjectDrawState(ourNewObject); M2TWEOPFBX.setFbxObjectAnimState(ourNewObject,true);
- M2TWEOPFBX.getFbxObjectAnimState (fbx)
-
Get an fbx object's animation state.
Parameters:
- fbx fbxObject object
Returns:
-
bool
is animation needed
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2); local size=M2TWEOPFBX.getFbxObjectSize(ourNewObject); M2TWEOPFBX.setFbxObjectDrawState(ourNewObject,true); local isDrawed=M2TWEOPFBX.getFbxObjectDrawState(ourNewObject); M2TWEOPFBX.setFbxObjectAnimState(ourNewObject,true); local isAnimationPlayed=M2TWEOPFBX.getFbxObjectAnimState(ourNewObject);
- M2TWEOPFBX.setFbxObjectDrawType (fbx, current)
-
Set fbx object draw type, i.e. on what part of the game it is drawn.
Can be: 1 - Strategy Map 2 - Tactical/Battle Map 0 - Both Default value - 1
Parameters:
- fbx fbxObject object
- current int draw type
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2); local size=M2TWEOPFBX.getFbxObjectSize(ourNewObject); M2TWEOPFBX.setFbxObjectDrawState(ourNewObject,true); local isDrawed=M2TWEOPFBX.getFbxObjectDrawState(ourNewObject); M2TWEOPFBX.setFbxObjectAnimState(ourNewObject,true); --get current type local whereWeDrawObject=M2TWEOPFBX.getFbxObjectDrawType(ourNewObject); --if we draw object on stratmap if (whereWeDrawObject==1) then --change drawing type to battle map M2TWEOPFBX.setFbxObjectDrawType(ourNewObject,2); end
- M2TWEOPFBX.getFbxObjectDrawType (fbx)
-
Get fbx object draw type, i.e. on what part of game it is drawn.
Can be: 1 - Strategy Map 2 - Tactical/Battle Map 0 - Both Default value - 1
Parameters:
- fbx fbxObject object
Returns:
-
int
current draw type
Usage:
--1 is model id here M2TWEOPFBX.addFbxModel(M2TWEOP.getModPath().."/eopData/testmodel.fbx",M2TWEOP.getModPath().."/eopData/testtexture.dds",1); local ourNewModel=M2TWEOPFBX.getFbxModel(1); --2 is object id here M2TWEOPFBX.addFbxObject(1,2); local ourNewObject=M2TWEOPFBX.getFbxObject(2); M2TWEOPFBX.setFbxObjectCoords(ourNewObject,1.2,123.95,1); local x,y,z=M2TWEOPFBX.getFbxObjectCoords(ourNewObject); M2TWEOPFBX.setFbxObjectSize(ourNewObject,25.2); local size=M2TWEOPFBX.getFbxObjectSize(ourNewObject); M2TWEOPFBX.setFbxObjectDrawState(ourNewObject,true); local isDrawed=M2TWEOPFBX.getFbxObjectDrawState(ourNewObject); M2TWEOPFBX.setFbxObjectAnimState(ourNewObject,true); local whereWeDrawObject=M2TWEOPFBX.getFbxObjectDrawType(ourNewObject);
M2TWEOP3dObjects
- M2TWEOP3dObjects
-
Basic M2TWEOP3dObjects table. Contains descriptions of m2tweop simple 3d objects feathures. Not call this functions onPluginLoad(graphics system not initialized here yet).
Fields:
- MakeTextFont MakeTextFont
- DeleteTextFont MakeTextFont
- Make3dText Make3dText
- M2TWEOP3dObjects.MakeTextFont (fontName, weight, isItalic)
-
Create new 3d text font. Fonts using for creating text(you not need font after it)
Parameters:
- fontName string name of font
- weight int weight of font(optional). Default - 400
- isItalic bool is font italic(optional). Default - true
Returns:
-
int
fondID ID of created font.
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman");
- M2TWEOP3dObjects.DeleteTextFont (fondID)
-
Delete 3d text font. Do it where not need anymore
Parameters:
- fondID int ID of created font.
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); M2TWEOP3dObjects.DeleteTextFont(newFont);
- M2TWEOP3dObjects.Make3dText (fondID, text)
-
Create line of 3d text.
Parameters:
- fondID int ID of created font.
- text string utf8 string with text.
Returns:
-
Eop3dText
text utf8 string with text.
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); M2TWEOP3dObjects.DeleteTextFont(newFont);
3dText
- Eop3dText
-
3d text object. Not use it onPluginLoad(graphics system not initialized here yet).
Fields:
- xSize float default value 1
- ySize float default value 0.2
- zSize
float
default value 1
- xRoll float default value 1
- yRoll float default value 90
- zRoll float default value 1
- xCoord float
- yCoord float
- zCoord float
- Scale Scale
- ChangeColor ChangeColor
- SetCoords SetCoords
- StartDrawing StartDrawing
- StopDrawing StopDrawing
- DrawOnce DrawOnce
- Delete Delete
- Eop3dText:Scale (sizeMultiplier)
-
Scale 3d text.
Parameters:
- sizeMultiplier float
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); newText:Scale(0.3);
- Eop3dText:ChangeColor (a, r, g, b)
-
Set 3d text color.
Parameters:
- a int
- r int
- g int
- b int
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); newText:ChangeColor(255,0,255,177);
- Eop3dText:SetCoords (x, y, z)
-
Set 3d text coords.
Parameters:
- x float
- y float
- z float
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); newText:SetCoords(10,20,0.2);
- Eop3dText:StartDrawing ()
-
Start draw text. Text go on display until stop function called
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); newText:SetCoords(10,20,0.2); newText:StartDrawing();
- Eop3dText:StopDrawing ()
-
Stop draw text.
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); newText:SetCoords(10,20,0.2); newText:StartDrawing(); --some time we draw newText:StopDrawing();
- Eop3dText:DrawOnce ()
-
Draw text once(at one frame only). Can be called in draw loop. Not need call stop after it.
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); newText:SetCoords(10,20,0.2); newText:DrawOnce();
- Eop3dText:Delete ()
-
Delete text. Not use after it!
Usage:
newFont = M2TWEOP3dObjects.MakeTextFont("Times New Roman"); newText = M2TWEOP3dObjects.Make3dText(newFont, "Some text"); newText:SetCoords(10,20,0.2); newText:DrawOnce(); newText:Delete();
M2TWEOPSounds
- M2TWEOPSounds
-
Basic M2TWEOPSounds table. Contains descriptions of M2TWEOP sound features.
Attention! You can use 256 sounds max. It supports the following audio formats: - WAV - OGG/Vorbis - FLAC You can play many sounds at the same time. It should be used for small sounds that can fit in memory. It's not recommended to use this for playing larger sounds like music.
Fields:
- createEOPSound createEOPSound
- deleteEOPSound deleteEOPSound
- playEOPSound playEOPSound
- setEOPSoundOffset setEOPSoundOffset
- getEOPSoundOffset getEOPSoundOffset
- pauseEOPSound pauseEOPSound
- stopEOPSound stopEOPSound
- M2TWEOPSounds.createEOPSound (soundPath)
-
Create (and load) a new sound.
Parameters:
- soundPath string Path to sound file
Returns:
-
int
soundID ID that will be used by this sound. Returns nil if the sound can't load..
Usage:
local ourNewSound=M2TWEOPSounds.createEOPSound(M2TWEOP.getModPath().."/eopData/testsound.wav");
- M2TWEOPSounds.deleteEOPSound (soundID)
-
Delete a sound
Parameters:
- soundID int ID of the sound that you want to delete.
Usage:
local ourNewSound=M2TWEOPSounds.createEOPSound(M2TWEOP.getModPath().."/eopData/testsound.wav"); M2TWEOPSounds.deleteEOPSound(ourNewSound);
- M2TWEOPSounds.playEOPSound (soundID)
-
Play a sound.
Parameters:
- soundID int ID of the sound that you want to play.
Usage:
local ourNewSound=M2TWEOPSounds.createEOPSound(M2TWEOP.getModPath().."/eopData/testsound.wav"); M2TWEOPSounds.playEOPSound(ourNewSound);
- M2TWEOPSounds.setEOPSoundOffset (soundID, millisecondsOffset)
-
Set a sound's playing offset. i.e Skip a certain number of milliseconds of the beginning of the sound.
Parameters:
- soundID int ID of the sound.
- millisecondsOffset int New playing position, from the beginning of the sound.
Usage:
local ourNewSound=M2TWEOPSounds.createEOPSound(M2TWEOP.getModPath().."/eopData/testsound.wav"); M2TWEOPSounds.setEOPSoundOffset(ourNewSound,1000); M2TWEOPSounds.playSound(ourNewSound);
- M2TWEOPSounds.getEOPSoundOffset (soundID)
-
Get a sound's playing offset.
Parameters:
- soundID int ID of the sound.
Returns:
-
int
millisecondsOffset Playing position, from the beginning of the sound.
Usage:
local ourNewSound=M2TWEOPSounds.createEOPSound(M2TWEOP.getModPath().."/eopData/testsound.wav"); M2TWEOPSounds.playSound(ourNewSound); local currentPlayPosition=M2TWEOPSounds.getEOPSoundOffset(ourNewSound);
- M2TWEOPSounds.pauseEOPSound (soundID)
-
Pause a sound that is playing.
Parameters:
- soundID int ID of the sound that you want to pause.
Usage:
local ourNewSound=M2TWEOPSounds.createEOPSound(M2TWEOP.getModPath().."/eopData/testsound.wav"); M2TWEOPSounds.playSound(ourNewSound); M2TWEOPSounds.pauseEOPSound(ourNewSound);
- M2TWEOPSounds.stopEOPSound (soundID)
-
Stop a sound that is playing.
Parameters:
- soundID int ID of the sound that you want to stop.
Usage:
local ourNewSound=M2TWEOPSounds.createEOPSound(M2TWEOP.getModPath().."/eopData/testsound.wav"); M2TWEOPSounds.playSound(ourNewSound); M2TWEOPSounds.stopEOPSound(ourNewSound);