All functions reside in the global "EMXHookLibrary" table and must be called accordingly. (e.g. SetPlayerColorRGB(_params) -> EMXHookLibrary.SetPlayerColorRGB(_params)).
These functions influence the game logic of entities and entity types.
- Sets new goods costs for an entity type. The cost table _costs must be structured as follows:
{Good, Amount, ...}
. A maximum of 2 goods is possible. - If the entity type in the game only has one cost entry (e.g., city buildings) and two new goods are to be set, it is necessary to set the parameter _overrideSecondGoodPointer == true. For entities that already have two entries by default (e.g., decoration buildings), this is not necessary.
- Both raw materials and gold can be used as goods. However, if the second entry is meant to be a production good (e.g., Goods.G_Cheese), the Baukostensystem BCS should be used.
- Can add costs to entity types that previously had no costs in the game (e.g., village buildings). For this, a new array is created in allocated memory.
- Can also change and add costs to units, e.g., ammunition carts/thieves/wall catapults.
- Returns a table containing the original pointers so the values can be reset. Reset function:
ResetEntityTypeFullCost(_entityType, _resetPointers)
.
- Resets the values of
EMXHookLibrary.SetEntityTypeFullCost
.
SetEntityTypeUpgradeCost(_entityType, _upgradeLevel, _costs, _overrideSecondGoodPointer, _overrideUpgradeCostHandling)
- Similar to
EMXHookLibrary.SetEntityTypeFullCost
, this can change the upgrade costs of an entity type. - If the entity type in the game only has one cost entry (e.g., city buildings) and two are to be set, it is necessary to set the parameter _overrideSecondGoodPointer == true. For entities that already have two entries by default (e.g., the storehouse), this is not necessary.
- _overrideUpgradeCostHandling is required if goods other than wood, stone, or iron are used or if two goods instead of one are to be used as costs.
- Returns a table containing the original pointers so the values can be reset. Reset function:
ResetEntityTypeUpgradeCost(_entityType, _upgradeLevel, _resetPointers)
.
- Resets the values of
EMXHookLibrary.SetEntityTypeUpgradeCost
.
- Sets the maximum health points (HP) of an entity type.
- This also affects all existing entities of this type.
- Sets the settler limit for sermons per church or cathedral upgrade level.
- Default: 10, 15, 30, 60.
- _upgradeLevel starts at 0 for the first level.
- Sets the soldier limit per castle upgrade level.
- Default: 25, 43, 61, 91.
- _upgradeLevel starts at 0 for the first level.
- Sets the probability that settlers at a festival find a spouse.
- Default: 0.3.
- This allows, for example, bathhouses or resource buildings to employ spouses.
- Sets the acquiring building of a territory.
- Usually the outpost.
- Sets the blocking or build-blocking of an entity type.
- _blocking must always be a table with the values.
- For example:
EMXHookLibrary.SetEntityTypeBlocking(Entities.B_Cathedral_Big, {0, 0, 0, 0}, false) -- Removes blocking of the cathedral
. - If unclear, refer to the .xml of the entity type.
- Sets the maximum outstock of an entity type based on its upgrade level.
- Default: 3, 6, 9 or only 9.
- Works for anything with an outstock (e.g., storehouses).
- WARNING: Unlike
EMXHookLibrary.SetMaxBuildingStockSize
, this only affects newly created types.
- Sets the maximum outstock of a storehouse type.
- WARNING: Unlike
EMXHookLibrary.SetEntityTypeOutStockCapacity
, this affects individual storehouses!
- Sets the maximum outstock of an existing building.
- WARNING: Unlike
EMXHookLibrary.SetEntityTypeOutStockCapacity
, this affects individual buildings!
- Sets a new instock good for a building.
- Allocates memory and sets new instock goods for a building.
- _newGoods must be structured as follows: {Good, Good}.
- Returns a table containing the original pointers so the values can be reset.
- WARNING: The same can be achieved using the function
Logic.AddGoodToStock(ID, Good, 0, true, true, true)
, making this function (more or less) obsolete.
- Sets a new good as outstock for a building.
- If _setEntityTypeProduct ~= nil, the product of the entity type is also set; otherwise, only the outstock for a building.
- Copies a reference of a behavior from one entity type to another. All subsequently created entities will possess the behavior.
- The possible behaviors are:
"CInteractiveObjectBehavior", "CMountableBehavior", "CFarmAnimalBehavior", "CAnimalMovementBehavior", "CAmmunitionFillerBehavior". - Can be reset using
EMXHookLibrary.ResetEntityBehaviors
. - For example:
EMXHookLibrary.AddBehaviorToEntityType(Entities.B_Bakery, "CInteractiveObjectBehavior") -- Makes bakeries interactive objects
.
- Resets the behavior of an entity type. _resetPointers is a table returned by
EMXHookLibrary.AddBehaviorToEntityType
.
- Sets the workplace of a settler. This allows more than 3 settlers to be employed at a building.
- WARNING: The settler must already be assigned to a building before it can be switched!
- For more than 3 settlers,
EMXHookLibrary.SetTypeAndMaxNumberOfWorkersForBuilding
should be set accordingly beforehand.
- Sets a new maximum number and a new type of workers for a building type.
These functions affect the visual representation of entities and their models.
- Returns the current model of an entity if one has been set.
- Analogous to
Logic.SetModel
.
- Sets a minimap icon for an entity type. Icons from the icon table can be used.
- _iconIndex 0 removes the icon.
- For entities already present on the map, this function should be called in the FMA; otherwise, only newly created entities are affected.
- Allows setting various models for buildings.
- _params must be a table of models.
- _paramType must be a string specifying the type. Possible types include: "Models", "UpgradeSite", "Destroyed", "Lights".
- _model sets the current model and can also be nil.
- Before making changes, it’s best to consult the entity’s definition XML file. Both an existing entity ID and a type can be provided.
- Example:
EMXHookLibrary.SetEntityDisplayModelParameters(Entities.B_StoreHouse, "Models", {Models.Buildings_B_NPC_Cloister_ME, Models.Buildings_B_NPC_Storehouse_NE, Models.Buildings_B_NPC_Cloister_NE}, {Models.Buildings_B_NPC_Storehouse_ME}) -- Sets new models for the various upgrade levels of the storehouse.
- Similar to
EMXHookLibrary.SetEntityDisplayModelParameters
, but specifically for (production) buildings. - Possible types: "Yards", "Roofs", "RoofDestroyed", "UpgradeSite", "Floors", "Gables", "Lights", "FireCounts".
- Allows customization of various display parameters for an entity or entity type.
- Possible properties: "ShowDestroyedModelAt", "MaxDarknessFactor", "ExplodeOnDestroyedModel", "SnowFactor", "SeasonColorSet", "LODDistance", "ConstructionSite", "Decal".
- Some parameters need to be set as floats; consult the entity type’s definition XML file.
- Changes the shader of a model type. Possible shaders can be found in the "Effects" folder.
- Examples: "Object_Aligned_Additive", "ShipMovementEx", "WealthLightObject", "IceCliff", "Waterfall", "StaticBanner".
- Returns the original value for resetting purposes.
- NOTE: This may cause a slight memory leak (148 bytes) if the model was already loaded by the game.
- Modifies parameters of a model type by copying values from a reference type.
- Returns the original value for resetting purposes.
- Example:
This sets the shader effect of the first model to match the second model.
EMXHookLibrary.ModifyModelProperties(Models.Doodads_D_NA_Cliff_Set01_Deco01, Models.Doodads_D_NE_Cliff_Set03_Sheet01, 0)
- NOTE: This may cause a slight memory leak (148 bytes) if the model was already loaded by the game.
- Resets modified parameters of a model type.
- Changes the internal file path of a model.
- Example:
ChangeModelFilePath(Models.Buildings_B_Barracks, "Doodads\\D_NA_ExcavationSite_3\0\0", 29)
- If the model has not yet been loaded, it will be replaced in the ID manager by D_NA_ExcavationSite_3.
These functions affect the global game logic of the world.
- Sets new gold costs for territories.
- Index ranges from 1 (Low) to 5 (Very Expensive).
- Sets the number of settlers required before diseases can break out.
- Default: 151.
- Sets the value by which wealth goods need to be replenished in buildings.
- Default: 0.
- Sets the time it takes for carnivores to regenerate their health.
- Sets the time a knight must recover in the castle.
- Default: 60000.
- Sets the maximum tax revenue that town buildings can hold.
- Default: 100.
- Sets a new settler limit depending on the cathedral/church upgrade level.
- The index ranges from 0 to 5.
- Default: 50, 50, 100, 150, 200, 200.
- Sets the maximum number of tax collectors that can be generated.
- Default: 6.
- Sets the refund factor for demolishing a building.
- Default: 50.
- 50 equals 50%, meaning half the construction cost is refunded upon demolition.
- Sets the factor by which troops are stronger in their own territories.
- Default: 0.2.
- This is added to the total combat strength.
- Sets the amount of gold a settler donates during a sermon visit.
- Default: 5.
- Sets the damage caused by fire per second.
- Default: 5.
- Sets the maximum ammunition for ballistas (wall catapult) per type.
- Default: 10.
- Sets certain parameters for troop formations.
- The _distances parameter must be a table in the following format:
-- {_rowDistance, _colDistance, _cartRowDistance, _cartColDistance, _engineRowDistance, _engineColDistance}
- Unnecessary values can be nil.
- Changes the entity type of an upgrade category.
- For example, this allows players to construct village buildings.
- Sets the required production goods for a resource and/or their quantities (e.g., Goods.G_Carcass -> Goods.G_Sausage).
- Unnecessary parameters can be nil.
- The default ratio is 1:1 but can be adjusted (e.g., 3 wheat for 1 bread, 2 stone for 1 broom, etc.).
- Allows the use of certain parameters of a good type (e.g., RequiredResource) with goods that lack entries for these features.
- Creates a reference to another good type.
- Returns a table containing the original pointers for resetting purposes.
- Similar to
EMXHookLibrary.CopyGoodTypePointer
, but allocates new memory for an array. - _requiredResources must look like: {{_resource, _amount, _supplier}, {_resource, _amount, _supplier}, ...}.
- Example:
EMXHookLibrary.CreateGoodTypeRequiredResources(Goods.G_Soap, {{Goods.G_Wool, 3, EntityCategories.GC_Food_Supplier}, {Goods.G_Stone, 2, EntityCategories.GC_Food_Supplier}})
- Returns a table containing the original pointers for resetting purposes.
- Resets the values set by
EMXHookLibrary.CreateGoodTypeRequiredResources
andEMXHookLibrary.CopyGoodTypePointer
.
- Enables or disables Development Mode in the original game (OV) and the Steam History Edition.
- _magicWord is either 256 or 257, depending on the mode’s status.
- Only works in the Steam HE and the original game.
- For the Ubisoft HE, the S6Patcher should be used!
- Changes the terrain height at a position without immediately updating the textures below it.
- This allows for "floating" entities, but only until the next blocking update.
- Example:
EMXHookLibrary.ModifyTerrainHeightWithoutTextureUpdate(5000, 5000, 5000)
EditFestivalProperties(_festivalDuration, _promotionDuration, _promotionParticipantLimit, _festivalParticipantLimit)
- Adjusts one or more parameters of festivals (both promotion and normal festivals).
- Adjustable parameters include duration and participant limits.
- Unnecessary parameters can be nil.
These functions affect the global display of the world.
- Modifies a StringTable entry. The EntryIndex must first be retrieved, and the character limit must be respected.
- More details on usage upon request.
- Example: "Saraya" -> "Testknight":
EMXHookLibrary.EditStringTableText(2100, "Testknight")
.
- Sets the colors of a ColorSet per season.
- A table containing the original values is returned so that the ColorSet can be reset later.
- The name of the set can be found in the folder in the game directory.
- Example:
EMXHookLibrary.SetColorSetColorRGB("ME_FOW", 1, {0.32, 0.135, 0.4, 1}); -- FoW color for season spring in climate zone ME
.
- Changes a player's color.
- _rgb must be a table containing the color values (from 0 - 255).
- The alpha channel must always be 127 and the first entry in the table.
- 0 and single-digit values must be represented as two digits [e.g., 9 -> 09].
EMXHookLibrary.SetPlayerColorRGB(1, {127, 0, 0, 255, 255}) -- Yellow
EMXHookLibrary.SetPlayerColorRGB(1, {127, 253, 112, 0, 0}) -- Dark Blue
EMXHookLibrary.SetPlayerColorRGB(1, {127, 255, 255, 255}) -- White
- Changes the display duration of an EGL_Effect.
- Example:
EMXHookLibrary.SetEGLEffectDuration(EGL_Effects.FXLightning, 2)
.
- Enables or disables RTS camera rotation with CTRL + mouse wheel.
- Optionally, the speed can also be adjusted.
- Default: 2500.
- Sets the factor by which the Fog of War is applied in already revealed areas.
- Default: 0.75.
- At 0, areas remain covered unless a player's unit is present; at 1, they remain permanently revealed.