diff --git a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp index 7406eaaf..f06bce51 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp @@ -879,8 +879,8 @@ namespace fastFuncts } return; } - un->general->movepoints1 = movepoints; - un->general->movepoints2 = movepoints; + un->general->movePointsCharacter = movepoints; + un->general->movePointsArmy = movepoints; general* gen = un->general; @@ -926,7 +926,7 @@ namespace fastFuncts - int diff = count - un->number; + int diff = count - un->SoldierCountStrat; if (diff == 0) { return; @@ -947,7 +947,7 @@ namespace fastFuncts } else { - un->number = count; + un->SoldierCountStrat = count; } diff --git a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp index d4b74a2d..e0be83eb 100644 --- a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp +++ b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp @@ -370,7 +370,7 @@ namespace battleCreator unit* un = army->units[k]; tempS = "unit "; tempS.append(un->eduEntry->Type); - tempS.append(" soldiers ").append(to_string(un->number)); + tempS.append(" soldiers ").append(to_string(un->SoldierCountStrat)); tempS.append(" exp ").append(to_string(un->expScreen)); tempS.append(" armour ").append(to_string(un->stats >> 0xd & 0x1f)); tempS.append(" weapon_lvl ").append(to_string(un->stats >> 0x8 & 0x1f)); diff --git a/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp index b2ce6a85..ac68d3fe 100644 --- a/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp +++ b/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp @@ -26,7 +26,7 @@ namespace battleCreator { numberInArmy = pnumberInArmy; type = un->eduEntry->Type; - soldiersNumber = un->number; + soldiersNumber = un->SoldierCountStrat; exp = un->expScreen; @@ -232,7 +232,7 @@ namespace battleCreator { unitJson["general"] = 0; } - unitJson["soldiers"] = unit->number; + unitJson["soldiers"] = unit->SoldierCountStrat; unitJson["exp"] = unit->expScreen; j.push_back(unitJson); diff --git a/M2TWEOP Code/M2TWEOP library/realGameTypes.h b/M2TWEOP Code/M2TWEOP library/realGameTypes.h index 5b67ffd2..774c3dd6 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -16,12 +16,115 @@ typedef unsigned short ushort; #pragma pack(push,1) typedef struct stackStruct stackStruct, * PstackStruct; typedef struct settlementStruct settlementStruct, * PsettlementStruct; + + struct UNICODE_STRING { USHORT something;//idk USHORT Length;//idk USHORT something2;//idk PWSTR Buffer;//y }; + +struct rcString +{ +public: + char pad_0000[12]; //0x0000 + wchar_t* string; //0x000C + char pad_0010[104]; //0x0010 +}; //Size: 0x0078 + +struct generalStats +{ +public: + struct soldierInBattle* generalBgSoldier; //0x0000 + struct soldierInBattle* generalBgMount; //0x0004 +}; //Size: 0x0008 + +struct coordPair +{ +public: + int32_t xCoord; //0x0000 + int32_t yCoord; //0x0004 +}; //Size: 0x0008 + +struct movePath +{ +public: + struct coordPair* tileCoords; //0x0000 + int32_t tileCoordsSize; //0x0004 + int32_t tileCoordsCount; //0x0008 +}; //Size: 0x000C + + +class religionDatabase +{ +public: + void* religionDatabase_vtbl;//0x0000 + struct rcString** religionNames; //0x0004 + int32_t religionNamesSize; //0x0008 + int32_t religionCount; //0x000C + struct rcString** religionPips; //0x0010 + int32_t religionPipsSize; //0x0014 + int32_t religionPipsCount; //0x0018 + void* hashedStringTable; //0x001C + +}; //Size: 0x0020 + +struct capturedCharacter +{ + struct namedCharacter* namedChar; + int32_t capturedValue; +}; + +struct capturedUnit +{ + struct unit* unit; + int32_t capturedSoldiers; + int32_t capturedValue; +}; + +struct capturedFactionInfo +{ + int32_t targetFactionID; + int32_t factionID; + struct namedCharacter* character; + struct namedCharacter* targetCharacter; + int32_t bitMap; + struct capturedCharacter* capturedCharacters; + uint32_t capturedCharactersEnd; + uint32_t capturedCharactersEnd2; + char* logString; + struct capturedUnit* capturedUnits; + uint32_t capturedUnitsEnd; + int32_t capturedUnitsEnd2; + int32_t ransomValue; +}; + +struct floatsSeaConnect +{ +public: + uint32_t tileId; //0x0000 + float someFloat; //0x0004 +}; //Size: 0x0008 + +struct seaConnectedRegion +{ +public: + int32_t regionID; //0x0000 + char pad_0004[4]; //0x0004 + float angle; //0x0008 + float distance; //0x000C + int32_t seaExportValue; //0x0010 + int32_t seaImportValue; //0x0014 + struct floatsSeaConnect* tilesReachable; //0x0018 + int32_t tilesReachableSize; //0x001C + int32_t tilesReachableCount; //0x0020 + struct coordPair* seaTradeLanePath; //0x0024 + int32_t seaTradeLanePathSize; //0x0028 + int32_t seaTradeLanePathCount; //0x002C + char pad_0030[4]; //0x0030 +}; //Size: 0x0034 + struct regionStruct { char* regionName;//0x0000 int regionNameHash;//0x0004 @@ -31,7 +134,9 @@ struct regionStruct { int legioNameHash;//0x0014 undefined field4_0x10[4];//0x0018 int regionID;//0x001C - char pad_0020[12]; //0x0020 + int32_t N00008C49; //0x0020 + int32_t N00008C4A; //0x0024 + int32_t overOneAllowsFamine; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -43,23 +148,46 @@ struct regionStruct { int32_t watchtowersNum; //0x004C int8_t isSea; //0x0050 int8_t hasLake; //0x0051 - char pad_0052[58]; //0x0052 + char pad_0052[2]; //0x0052 + struct landMass* landMass; //0x0054 + struct roadStruct* roadToPort; //0x0054 + struct seaConnectedRegion* seaConnectedRegions; //0x005C + int32_t seaConnectedRegionsCountArraySize; //0x0060 + int32_t seaConnectedRegionsCount; //0x0064 + int32_t loyaltyFactionID; //0x0068 + struct seaConnectedRegion* seaExportRegion; //0x006C + char pad_0070[12]; //0x0070 + struct seaConnectedRegion** seaImportRegions; //0x007C + int32_t seaImportRegionsSize; //0x0080 + int32_t seaImportRegionsCount; //0x0084 + int32_t canSeaTrade; //0x0088 struct mercPool* mercPool;//0x008C - undefined field6_0x90[36];//0x0090 + int32_t* regionSeaEdges; //0x0090 + int32_t regionSeaEdgesSize; //0x0094 + int32_t regionSeaEdgesCount; //0x0098 + char pad_009C[24]; //0x009C float* religionsARR;//0x00B4 - int* religionsEnd; //0x00B8 - undefined field8_0xbc[212];//0x00BC + float* religionHistory[20]; + uint32_t* tilesBorderingEdgeOfMap; //0x0108 + int32_t tilesBorderingEdgeOfMapSize; //0x010C + int32_t tilesBorderingEdgeOfMapCount; //0x0110 + char pad_0114[124]; //0x0114 struct settlementStruct* settlement;//0x0190 - char pad_0194[8]; //0x0194 + int* tiles; //0x0194 + int32_t tilesSize; //0x0198 int32_t tileCount; //0x019C - char pad_0177[12]; //0x0194 + int* fertileTiles; //0x01A0 + int32_t fertileTilesSize; //0x01A4 + int32_t fertileTilesCount; //0x01A8 struct neighbourRegion* neighbourRegions;//0x01AC int32_t neighbourRegionsCountArraySize; //0x01B0 int32_t neighbourRegionsNum; //0x01B4 struct resStrat** resources;//0x01B8 - int32_t resourceCountArrayZie; //0x01BC + int32_t resourcesSize; //0x01BC int32_t resourcesNum; //0x01C0 - char pad_01C4[12]; //0x01C4 + int32_t N00008CB2; //0x01C4 + uint32_t resourceTypesBitMap; //0x01C8 + int32_t N00008CB4; //0x01CC uint32_t hiddenResources1; //0x01D0 uint32_t hiddenResources2; //0x01D4 char pad_01D8[4]; //0x01D8 @@ -87,20 +215,45 @@ struct neighbourRegion int32_t regionID; //0x0004 float distance; //0x0008 char pad_000C[4]; //0x000C - void* tileStuff; //0x0010 - char pad_0014[68]; //0x0014 + struct roadStruct* connectingRoad; //0x0010 + int32_t tradeValue; //0x0014 + int32_t* bordertiles; //0x0018 + int32_t borderTilessize; //0x001C + int32_t borderTilesCount; //0x0020 + char pad_0024[52]; //0x0024 }; //Size: 0x0058 +struct landMass +{ +public: + int32_t index; //0x0000 + int32_t* regions; //0x0004 + int32_t regionsSize; //0x0008 + int32_t regionsNum; //0x000C +}; //Size: 0x0010 + struct stratMap { - undefined field_0x0[44]; + undefined field_0x0[4]; + struct UNICODE_STRING** campaignName; //0x0004 + struct UNICODE_STRING*** campaignPath; //0x0008 + char pad_000C[28]; //0x000C + void* climates; //0x0028 int mapWidth; int mapHeight; undefined field_0x34[20]; struct oneTile* tilesArr; - undefined field_0x4c[4]; - undefined field_0x50[44]; + DWORD TileListEnd; //0x004C + undefined field_0x50[20]; + struct coordPair* volcanoes; //0x0064 + int32_t volcanoesSize; //0x0068 + int32_t volcanoesNum; //0x006C + struct coordPair* landMassConnections; //0x0070 + int32_t landMassConnectionsSize; //0x0074 + int32_t landMassConnectionsNum; //0x0078 struct regionStruct regions[200]; int regionsNum; + struct landMass landMass[20]; //0x1A660 + int32_t landMassNum; //0x1A7A0 }; struct mercPoolUnit { @@ -170,9 +323,24 @@ struct uiElement { undefined field_0x58[112]; }; +struct roadStruct +{ +public: + struct coordPair* coords; //0x0000 + int32_t coordsSize; //0x0004 + int32_t coordsNum; //0x0008 + void* someOtherArray; //0x000C + int32_t someOtherArraySize; //0x0010 + int32_t someOtherArrayCount; //0x0014 + int32_t regionIdStart; //0x0018 + int32_t regionIdEnd; //0x001C + char pad_0020[24]; //0x0020 +}; //Size: 0x0038 + struct oneTile { void* object; - undefined field_0x4[6]; + struct roadStruct* road; //0x0004 + undefined field_0x8[2]; int8_t isLand; undefined field_0xB[1]; int8_t terrainModel; @@ -188,9 +356,13 @@ struct oneTile { int8_t hasRoad; int8_t border; undefined field_0x22[2]; - int8_t objectTypes; + int8_t objectTypes; //bit87_character6_ship5_watchtower4_port3_bit32_fort1_settlement0 int8_t passable; - undefined field_0x26[14]; + int8_t N0002227F; //0x0026 + int8_t N00022271; //0x0027 + uint32_t armiesNearTile; //0x0028 + uint32_t charactersOnTile; //0x002C + float mpModifier; //0x0030 }; struct siegeS { @@ -199,20 +371,77 @@ struct siegeS { struct stackStruct* army; }; -//diplomacy data of faction to another faction -struct factionDiplomacy { - undefined field_0x0[16]; - int state; /* diplomatic state(war, alliance, peace)(600/0/200) */ - int trade; /* trade rights(0 or 1) */ - int protectorate; /* protectorate or not(15 or 6) */ - undefined field_0x1c[108]; -}; +struct stringWithHash +{ +public: + char* name; //0x0000 + int32_t hash; //0x0004 +}; //Size: 0x0008 + +struct holdRegionsWinCondition +{ +public: + char pad_0000[4]; //0x0000 + int32_t intSomethingTurns; //0x0004 + struct stringWithHash* regionsToHold; //0x0008 + int32_t regionsToHoldSize; //0x000C + int32_t regionsToHoldCount; //0x0010 + char pad_0014[4]; //0x0014 + int32_t numberOfRegions; //0x0018 + char pad_001C[4]; //0x001C + int32_t* holdRegionLengths; //0x0020 + int32_t holdRegionLengthsSize; //0x0024 + int32_t holdRegionLengthsCount; //0x0028 + char pad_002C[12]; //0x002C +}; //Size: 0x0080 + +struct battleSettlement +{ +public: + char pad_0000[4]; //0x0000 + struct settlementStruct* settlement; //0x0004 + char pad_0008[4]; //0x0008 + struct battleResidence* battleResidence; //0x000C + char pad_0010[304]; //0x0010 +}; //Size: 0x0140 + +struct battleResidence +{ +public: + char pad_0000[28]; //0x0000 + struct settlementStruct* settlement; //0x001C + char pad_0020[16]; //0x0020 + int32_t isFortBattle; //0x0030 + char pad_0034[8]; //0x0034 + float N000203C6; //0x003C + float N000203C7; //0x0040 + char pad_0044[40]; //0x0044 + int8_t settlementWallsBreached; //0x006C + int8_t settlementGateDestroyed; //0x006D + char pad_006E[2]; //0x006E + int8_t N0003A33C; //0x0070 + char pad_0071[7]; //0x0071 + float N0003A33E; //0x0078 + char pad_007C[200]; //0x007C +}; //Size: 0x0144 + +struct factionRanking +{ +public: + float totalRanking; //0x0000 + float militaryRanking; //0x0004 + float productionRanking; //0x0008 + float territoryRanking; //0x000C + float FinancialRanking; //0x0010 + float populationRanking; //0x0014 +}; //Size: 0x0018 struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int id; char* facName; DWORD facNameHash; - undefined field_0xc[60]; + undefined field_0xc[56]; + int religionID; struct model_Rigid* symbol; char* symbolPath; DWORD symbolPathHash; @@ -233,7 +462,26 @@ struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int standard_index; int logo_index; int small_logo_index; - undefined field_0x88[88]; + undefined field_0x88[20]; + int32_t hordeMaxUnits; //0x009C + char pad_00A0[28]; //0x00A0 + uint8_t customBattleAvailability; //0x00BC + char pad_00BD[3]; //0x00BD + uint32_t periodsUnavailableInCustomBattle; //0x00C0 + uint8_t N00008DC2; //0x00C4 + uint8_t canSap; //0x00C5 + char pad_00C6[2]; //0x00C6 + int32_t prefersNavalInvasions; //0x00C8 + uint8_t canHavePrincess; //0x00CC + char pad_00CD[3]; //0x00CD + char* specialfactionType; //0x00D0 + char pad_00D4[4]; //0x00D4 + uint8_t hasFamilyTree; //0x00D8 + uint8_t teutonic; //0x00D9 + uint8_t disbandToPools; //0x00DA + uint8_t canBuildSiegeTowers; //0x00DB + uint8_t canTransmitPlague; //0x00DC + char pad_00DD[3]; //0x00DD }; struct watchTowerModel { @@ -262,6 +510,91 @@ struct worldRecord { undefined field_0x38[40]; }; +struct crusade +{ +public: + char pad_0000[20]; //0x0000 + void* N0000121D; //0x0014 + char pad_0018[28]; //0x0018 + int32_t startTurn; //0x0034 + int32_t endTurn; //0x0038 + struct settlementStruct* targetSettlement; //0x003C + int32_t length; //0x0040 + int32_t outcome; //0x0044 + char pad_0048[252]; //0x0048 + void* N00001269; //0x0144 + char pad_0148[44]; //0x0148 +}; //Size: 0x0174 + + + +struct jihad +{ +public: + char pad_0000[52]; //0x0000 + int32_t startTurn; //0x0034 + int32_t endTurn; //0x0038 + struct settlementStruct* targetSettlement; //0x003C + int32_t length; //0x0040 + int32_t outcome; //0x0044 + char pad_0048[292]; //0x0048 +}; //Size: 0x016C + +struct settlementList +{ + struct settlementStruct** settlements; //0x0000 + struct settlementList* nextSettlements; //0x0004 + struct settlementList* previousSettlements; //0x0008 + int32_t settlementsSize; //0x000C + int32_t settlementsNum; //0x0010 +}; + + +struct factionDiplomacy +{ +public: + char pad_0000[4]; //0x0000 + int state; /* diplomatic state(war, alliance, peace)(600/0/200) */ + int trade; /* trade rights(0 or 1) */ + int protectorate; /* protectorate or not(15 or 6) */ + float factionStanding; //0x0010 + char pad_0014[116]; //0x0014 +}; //Size: 0x0088 + +struct trackedCharacter +{ +public: + struct N0001F08D* N0001F061; //0x0000 + struct general* character; //0x0004 +}; //Size: 0x0008 + +struct cardinal +{ +public: + struct trackedCharacter* trackedCharacter; //0x0000 + struct N0001F079* cardinalInfo; //0x0004 +}; //Size: 0x0008 + +struct collegeOfCardinals +{ +public: + char pad_0000[4]; //0x0000 + struct namedCharacter* pope; //0x0004 + char pad_0008[4]; //0x0008 + struct cardinal* cardinalsArray; //0x000C + int32_t cardinalsArraySize; //0x0010 + int32_t cardinalNum; //0x0014 + int8_t N0001D9D6; //0x0018 + int8_t getsUsedForCountVotes; //0x0019 + int8_t N0001F1B6; //0x001A + int8_t N0001F1B4; //0x001B + struct N0001F0B9* someOtherArray; //0x001C + int32_t someOtherArraySize; //0x0020 + int32_t someOtherArrayCount; //0x0024 + struct UNICODE_STRING** localizedCardinalNames; //0x0028 + char pad_002C[32]; //0x002C +}; //Size: 0x004C + struct campaign { undefined field0_0x0[4]; undefined field1_0x4[52]; @@ -271,22 +604,22 @@ struct campaign { undefined field5_0x44[232]; int humanPlayers; /* number of player-controlled factions */ int factionIdPow; /* pow(2,factionId) */ - int campaignDifficultyFaction[8]; - undefined field9_0x154[120]; - int battleDifficulty07; - undefined field11_0x1d0[88]; - int battleDifficulty30; + int32_t campaignDifficultyFaction[31]; + int32_t battleDifficultyFaction[31]; struct factionStruct* factionsSortedByDescrStrat[31]; struct factionStruct* factionsSortedByID[31]; int numberOfFactionsWithSlave; - undefined field16_0x328[28]; + char pad_0328[20]; //0x0328 + struct collegeOfCardinals* collegeOfCardinals; //0x033C + struct factionStruct* papalFaction; //0x0340 struct factionStruct* currentFactionTurn; - int field18_0x348; /* FactionTurn? */ + int factionTurnID; /* FactionTurn? */ UNICODE_STRING** currentDescrFile; /* path to descr_battle.txt or to descr_strat.txt */ - undefined field20_0x350[28]; - int field21_0x36c; /* TickCount? */ - int MillisecondCount; - float SecondCount; + int32_t fogOfWar; //0x0350 + undefined field20_0x354[24]; + int tickCount; /* TickCount? */ + int millisecondCount; + float secondCount; int TurnNumber; int field25_0x37c; /* PauseForBattleDialog? */ float TimeScale; @@ -300,17 +633,22 @@ struct campaign { undefined field34_0x3d2[26]; float BrigandSpawnValue; float PirateSpawnValue; - undefined field37_0x3f4[4]; + int8_t N00001211; //0x03F4 + int8_t smthingDateTurnDisplay; //0x03F5 + int8_t restrictAutoResolve; //0x03F6 + char pad_03F7[1]; //0x03F7 int FreeUpkeepForts; int ActiveFactions; /* number factions minus slave */ undefined field40_0x400[12]; int lastrandomseed; - undefined field42_0x410[744]; - int8_t isAdminPasswordExist; - int8_t isHotseatLogon; - undefined field45_0x6fa[2]; + struct crusade crusade; //0x0410 + struct jihad jihad; //0x0584 + struct UNICODE_STRING** someUniStringMaybePassword; //0x06F0 + int8_t isAdminPasswordExist; //0x06F4 + int8_t saveEnabled; //0x06F5 + undefined field45_0x6f6[6]; int8_t hotseatConsole; - int8_t hotseatConsole2; + int8_t hotseatConsoleEnabledWithLogon; undefined field48_0x6fe[14]; float currentDate; int season; /* season(0-summer,1-winter) */ @@ -322,18 +660,49 @@ struct campaign { float timeAtStartBattle; int daysInBattle; float currentTimeInBattle; /* 24 max, so calc as daysInBattle*24+currentTimeInBattle */ - undefined field59_0x734[4124]; - struct factionDiplomacy dipArray[31][31]; - undefined field61_0x215d8[48]; + char pad_0734[28]; //0x0734 + float clockTime; //0x0750 + char pad_0754[260]; //0x0754 + int32_t interFactionMarriage[31][31]; //0x0858 + struct factionDiplomacy diplomaticStandings[31][31]; //0x175C + struct settlementList settlementList; //0x215E4 + char* introVid; //0x215F8 + char pad_215FC[16]; //0x215FC struct fortStruct** fortsArray; - undefined field63_0x2160c; - int fortsNum; + int32_t fortsSize; //0x21610 + int32_t fortsNum; //0x21614 struct portBuildingStruct** portsBuildings; - undefined field66_0x21615; - int portsBuildingsNum; + int32_t portsBuildingsSize; //0x2161C + int32_t portsBuildingsNum; //0x21620 struct watchTowerStruct** watchtowers; - undefined field69_0x2161e; - int watchtowersNum; + int32_t watchtowersSize; //0x21628 + int32_t watchtowersNum; //0x2162C +}; + +struct uiUnitCard +{ +public: + char pad_0000[380]; //0x0000 + unit* unit; //0x0384 +}; + +struct uiCardManager +{ +public: + char pad_0000[16]; //0x0000 + struct uiUnitCard** selectedUnitCards; //0x0010 + int32_t selectedUnitCardsSize; //0x0014 + int32_t selectedUnitCardsCount; //0x0018 + char pad_001C[24]; //0x001C + struct uiUnitCard** unitCards; //0x0034 + int32_t unitCardsSize; //0x0038 + int32_t unitCardsCount; //0x003C + char pad_0060[328]; //0x0060 + struct settlementStruct* selectedSettlement; //0x0188 + char pad_018C[12]; //0x018C + struct general* selectedCharacter; //0x0198 + char pad_019C[12]; //0x019C + struct fortStruct* selectedFort; //0x01A8 }; struct gameDataAllStruct { @@ -344,7 +713,11 @@ struct gameDataAllStruct { struct campaign* field_0x38; undefined field_0x3c[28]; struct battleDataS* battleHandler; - undefined field_0x5c[8]; + undefined field_0x5c[36]; + struct battleSettlement* battleSettlement; + char pad[112]; + struct uiCardManager* uiCardManager; + char pad2[84]; }; struct battleUnit @@ -360,13 +733,242 @@ struct battleUnit int32_t soldiersStart; //0x001C uint32_t unitsRouted; //0x0020 int32_t soldiersHealed; //0x0024 - char pad_0028[4]; //0x0028 + int32_t unitsRoutedEnd; //0x0028 int32_t soldiersEnd; //0x002C - char pad_0030[8]; //0x0030 - int8_t hasRouted; //0x0038 - char pad_0039[15]; //0x0039 + int32_t friendlyFireCasualties; //0x0030 + int32_t expStart; //0x0034 + int32_t expGained; //0x0038 + int8_t isGeneral; //0x003C + char pad_003D[11]; //0x003D }; //Size: 0x0048 +struct options1 +{ + void* cursor; //0x0000 + int8_t N0003DD45; //0x0004 + int8_t widescreen; //0x0005 + char pad_0006[2]; //0x0006 + int64_t antiAliasMode; //0x0008 + int16_t subtitles; //0x0010 + int8_t english; //0x0012 + int8_t noBattleTimeLimit; //0x0013 + char pad_0014[4]; //0x0014 + int32_t useNewCursorActions; //0x0018 + int32_t campaignNumTimesPlay; //0x001C + int8_t uiWinConditions; //0x0020 + int8_t isScenario; //0x0021 + char pad_0022[2]; //0x0022 + int32_t isHotseatEnabled; //0x0024 + int8_t hotseatAutosave; //0x0028 + int8_t email; //0x0029 + int8_t saveConfig; //0x002A + int8_t closeAfterSave; //0x002B + int8_t validateData; //0x002C + int8_t campaignMapSpeedUp; //0x002D + char pad_002E[2]; //0x002E + int32_t skipAiFactions; //0x0030 + int8_t labelCharacters; //0x0034 + int8_t noBackGroundFmv; //0x0035 + int8_t disableArrowMarkers; //0x0036 + int8_t arcadeBattles; //0x0037 + int8_t disableEvents; //0x0038 + int8_t isPrologue; //0x0039 + int8_t updateAiCamera; //0x003A + int8_t hideCampaign; //0x003B + int32_t unlimitedMenOnBattlefield; //0x003C + char pad_0040[4]; //0x0040 + class N0003DA46* prefFactionsPlayed; //0x0044 + int32_t tgaReserveSpace; //0x0048 + int32_t keysetUsed; //0x004C + class N0003DD67* descrShortcuts; //0x0050 + int8_t muteAdvisor; //0x0054 + int8_t advancedStatsAlways; //0x0055 + int8_t microManageAllSettlements; //0x0056 + int8_t blindAdvisor; //0x0057 + int32_t terrainQuality; //0x0058 + int32_t vegetationQuality; //0x005C + int8_t useQuickChat; //0x0060 + int8_t someBoolNetworkManager; //0x0061 + char pad_0062[1]; //0x0062 + int8_t someBoolOnlinePlay; //0x0063 + int32_t graphicsAdaptor; //0x0064 + int8_t byte_2C6D86C; //0x0068 + int8_t showDemeanour; //0x0069 + char pad_006A[2]; //0x006A + int32_t radar; //0x006C + int32_t unitCards; //0x0070 + int32_t sa_cards; //0x0074 + int32_t buttons; //0x0078 + int8_t tutorialBattlePlayed; //0x007C + int8_t disableVnVs; //0x007D + int8_t allUsers; //0x007E + char pad_007F[29]; //0x007F + int32_t unk_2C6D8A0; //0x009C + char pad_00A0[28]; //0x00A0 + char* audioProvider; //0x00BC + char pad_00C0[20]; //0x00C0 + struct UNICODE_STRING** campaignName; //0x00D4 + char pad_00D8[4]; //0x00D8 + struct UNICODE_STRING*** N0003DA7C; //0x00DC + struct UNICODE_STRING*** maybeGameSpyUsername; //0x00E0 + struct UNICODE_STRING*** gameSpyPassword; //0x00E4 + char pad_00E8[4]; //0x00E8 + char* gameName; //0x00EC + char pad_00F0[24]; //0x00F0 + char adminPassword[28]; //0x0108 + char* tutorialPath; //0x0124 +}; //Size: 0x0128 + + +struct options2 +{ + uint16_t defaultCampaignResolutionX; //0x0000 + uint16_t defaultCampaignResolutionY; //0x0002 + uint16_t campaignResolutionX; //0x0004 + uint16_t campaignResolutionY; //0x0006 + uint16_t defaultBattleResolutionX; //0x0008 + uint16_t defaultBattleResolutionY; //0x000A + uint16_t battleResolutionX; //0x000C + uint16_t battleResolutionY; //0x000E + int8_t idk; //0x0010 + int8_t vSync; //0x0011 + char pad_0012[6]; //0x0012 + int8_t uiIconBarCheck; //0x0018 + int8_t uiRadarCheck; //0x0019 + int8_t useMorale; //0x001A + int8_t uiAmmoCheck; //0x001B + int8_t useFatigue; //0x001C + int8_t uiSupplyCheck; //0x001D + int8_t toggleFowState; //0x001E + int8_t cameraRestrict; //0x001F + int8_t eventCutscenes; //0x0020 + char pad_0021[3]; //0x0021 + int32_t defaultCameraInBattle; //0x0024 + int8_t splashes; //0x0028 + int8_t vegetationVideo; //0x0029 + int8_t byte_1639F1A; //0x002A + int8_t stencilShadows; //0x002B + int8_t byte_1639F1C; //0x002C + int8_t audioEnable; //0x002D + int8_t speechEnable; //0x002E + int8_t firstTimePlay; //0x002F + char* audioProviderName; //0x0030 + char pad_0034[1]; //0x0034 + int8_t byte_1639F25; //0x0035 + char pad_0036[1]; //0x0036 + int8_t toggleAutoSave; //0x0037 + int8_t showBanners; //0x0038 + int8_t passwords; //0x0039 + int8_t hotseatTurns; //0x003A + int8_t hotseatScroll; //0x003B + int32_t allowValidationFeatures; //0x003C + int32_t campaignSpeed; //0x0040 + int8_t labelSettlements; //0x0044 + int8_t disablePapalElections; //0x0045 + int8_t autoresolveAllBattles; //0x0046 + int8_t savePrefs; //0x0047 + int8_t disableConsole; //0x0048 + int8_t validateDiplomacy; //0x0049 + char pad_004A[2]; //0x004A + float someFloat; //0x004C + int32_t unitDetail; //0x0050 + int32_t buildingDetail; //0x0054 + int32_t maxSoldiersOnBattlefield; //0x0058 + int32_t unitSize; //0x005C + int32_t cameraRotateSpeed; //0x0060 + int32_t cameraMoveSpeed; //0x0064 + float cameraSmoothing; //0x0068 + int32_t somethingBasedOnBuildingDetail; //0x006C + int32_t masterVolume; //0x0070 + int32_t musicVolume; //0x0074 + int32_t speechVolume; //0x0078 + int32_t sfxVolume; //0x007C + int32_t subFactionAccents; //0x0080 + int32_t playerFactionId; //0x0084 + int32_t campaignDifficulty; //0x0088 + int32_t battleDifficulty; //0x008C + int32_t tgaWidth; //0x0090 + float tgaAspect; //0x0094 + int32_t tgaInputScale; //0x0098 + int32_t scrollMinZoom; //0x009C + int32_t scrollMaxZoom; //0x00A0 + int32_t advisorVerbosity; //0x00A4 + int8_t useSomethingTgaTextures; //0x00A8 + int8_t byte_1639F99; //0x00A9 + char pad_00AA[2]; //0x00AA + int32_t effectQuality; //0x00AC + int32_t EnableCameraCampaignSmoothing; //0x00B0 + int32_t chatMsgDuration; //0x00B4 + int8_t N0003DDF9; //0x00B8 + int8_t saveGameSpyPassword; //0x00B9 + int8_t addDateToLogs; //0x00BA + int8_t showToolTips; //0x00BB + int8_t isNormalHud; //0x00BC + int8_t showPackageLitter; //0x00BD + char pad_00BE[2]; //0x00BE + char* normal; //0x00C0 + char pad_00C4[8]; //0x00C4 + int32_t effectNormal; //0x00CC + char pad_00D0[8]; //0x00D0 + char* low; //0x00D8 + char pad_00DC[8]; //0x00DC + int32_t effectLow; //0x00E4 + char pad_00E8[8]; //0x00E8 + char* high; //0x00F0 + char pad_00F4[8]; //0x00F4 + int32_t effectHigh; //0x00FC + char pad_0100[8]; //0x0100 + char* lowest; //0x0108 + char pad_010C[8]; //0x010C + int32_t effectLowest; //0x0114 + char pad_0118[8]; //0x0118 + char* highest; //0x0120 + char pad_0124[8]; //0x0124 + int32_t effectHighest; //0x012C + char pad_0130[8]; //0x0130 + char* custom; //0x0138 + char pad_013C[8]; //0x013C + int32_t effectCustom; //0x0144 + char pad_0148[8]; //0x0148 + char* lower; //0x0150 + char pad_0154[8]; //0x0154 + int32_t effectLower; //0x015C + char pad_0160[8]; //0x0160 + char* higher; //0x0168 + char pad_016C[8]; //0x016C + int32_t effectHigher; //0x0174 + char pad_0178[8]; //0x0178 + char* off; //0x0180 + char pad_0184[8]; //0x0184 + int32_t effectOff; //0x018C + char pad_0190[32]; //0x0190 + int32_t maxSizeEduMaybe1; //0x01B0 + float unitMultDefault; //0x01B4 + int32_t unitMultDefaultId; //0x01B8 + int32_t maxSizeEduMaybe2; //0x01BC + float unitSizeMultiplierLow; //0x01C0 + int32_t unitMult1ID; //0x01C4 + int32_t maxSizeEduMaybe3; //0x01C8 + float unitSizeMultiplierMedium; //0x01CC + int32_t unitMult2ID; //0x01D0 + int32_t maxSizeEduMaybe4; //0x01D4 + float unitSizeMultiplierLarge; //0x01D8 + int32_t unitMult3ID; //0x01DC + char pad_01E0[12]; //0x01E0 + uint16_t word_163A0DC; //0x01EC + char pad_01EE[10]; //0x01EE + uint16_t word_163A0E8; //0x01F8 + char pad_01FA[2]; //0x01FA + uint16_t word_163A0EC; //0x01FC + char pad_01FE[54]; //0x01FE + int16_t currentHotseatPlayerOrSomething; //0x0234 + char pad_0236[2]; //0x0236 + class N0003DF44* keysetPointer; //0x0238 + char pad_023C[4]; //0x023C + int32_t keySetUsed; //0x0240 + int32_t preferencesWereLoaded; //0x0244 +}; + struct armyAndCharacter { /* in battle leader and leader army */ struct stackStruct* army;//0x0000 @@ -375,11 +977,18 @@ struct armyAndCharacter { /* in battle leader and leader army */ float generalHPRatioLost; //0x000C float someFloat; //0x0010 float battleOdds; //0x0014 - char pad_0018[20]; //0x0018 + char pad_0018[12]; //0x0018 + struct general* killedGenerals; //0x0024 + int32_t killedGeneralsSize; //0x0028 int32_t numKilledGenerals; //0x002C - char pad_0030[36]; //0x0030 - DWORD N0001FC50; //0x0054 - char pad_0058[68]; //0x0058 + char pad_0030[24]; //0x0030 + struct general* generalsDied; //0x0048 + int32_t generalsDiedSize; //0x004C + int32_t generalsDiedCount; //0x0050 + struct general* killedCaptains; //0x0054 + int32_t killedCaptainsSize; //0x0058 + int32_t killedCaptainsCount; //0x005C + char pad_005C[60]; //0x005C struct battleUnit* units; //0x009C int32_t unitArraySize; //0x00A0 int32_t unitCount; //0x00A4 @@ -538,6 +1147,13 @@ struct battleSide { char pad_1928[4]; //0x1928 }; +struct playerArmy +{ +public: + struct stackStruct* army; //0x0000 + char pad_0004[20]; //0x0004 +}; //Size: 0x0018 + struct battleDataS { undefined field_0x0[4];//0x0000 int battleState; /* 0-not in battle,5-active battle,9-results screen,etc 0x0004 */ @@ -556,11 +1172,32 @@ struct battleDataS { float speed; //0x0058 char pad_005C[8]; //0x005C float secondsPassed; //0x0064 - char pad_0068[48]; //0x0068 + int32_t secondsSinceBattleLoaded; //0x0068 + char pad_006C[16]; //0x006C + float mapWidthDoubled; //0x007C + float mapHeightDoubled; //0x0080 + char pad_0084[12]; //0x0084 + int32_t hidingEnabledSet; //0x0090 + char pad_0094[4]; //0x0094 struct UNICODE_STRING** someUniString; //0x0098 struct battleSide sides[8]; //0x009C int32_t factionSide[31]; //0xC9FC int sidesNum;//0xCA78 + char pad_CA7C[44]; //0xCA7C + struct playerArmy playerArmies[30]; //0xCAA8 + char pad_CD78[4]; //0xCD78 + int32_t playerArmyCount; //0xCD7C + char pad_CD80[84]; //0xCD80 + int32_t N0001D4DC; //0xCDD4 + int32_t N0001D4DD; //0xCDD8 + char pad_CDDC[20]; //0xCDDC + int32_t N0001D4E3; //0xCDF0 + int32_t N0001D4E4; //0xCDF4 + char pad_CDF8[4]; //0xCDF8 + int32_t N0001D4E6; //0xCDFC + int32_t N0001D4E7; //0xCE00 + char pad_CE04[44]; //0xCE04 + struct battleDataS* thisStruct; //0xCE30 };//Size: 0xCA7C struct stratPortModel { @@ -978,6 +1615,36 @@ struct RallyPointSundry { undefined field4_0x44[16]; }; +struct settlementCapability +{ +public: + int16_t value; //0x0000 + int16_t bonus; //0x0002 +}; //Size: 0x0004 + +struct recruitCapRome +{ +public: + char pad[8]; +}; //Size: 0x0008 + +struct recruitmentCapability +{ +public: + int32_t eduIndex; //0x0000 + int32_t xp; //0x0004 + float initialSize; //0x0008 + float replenishRate; //0x000C + float maxSize; //0x0010 +}; //Size: 0x0014 + +struct settlementRecruitmentPool +{ +public: + int32_t eduIndex; //0x0000 + float availablePool; //0x0004 +}; //Size: 0x0008 + //settlement struct settlementStruct { void* vTable; @@ -1022,19 +1689,51 @@ struct settlementStruct { undefined field26_0x5ac[520]; struct building* buildings[128]; int buildingsNum; /* number of the buildings in the settlement */ - undefined field29_0x9b8[1100]; - uchar isProvokedRebellion; - uchar field31_0xe05[3]; - undefined field32_0xe08[24]; - struct general* governor; - undefined field34_0xe24[32]; + undefined field29_0x9b8[1080]; + int32_t rallyPointX; //0x0DF0 + int32_t rallyPointY; //0x0DF4 + void* rallyPointPointer; //0x0DF8 + void* AIProductionController; //0x0DFC + char pad_0E00[4]; //0x0E00 + int8_t scriptRebel; //0x0E04 + uchar isProvokedRebellion;//0x0E05 + uchar field31_0xe06[34];//0x0E06 + struct general* governor;//0x0E28 + char pad_0E2C[12]; //0x0E2C + int32_t publicOrderLastTurnEnd; //0x0E38 + int32_t populationLastTurnEnd; //0x0E3C + char pad_0E40[4]; //0x0E40 struct resStrat** resources; - undefined field36_0xe48[4]; + int32_t resourceSize; //0x0E48 int resourcesNum; - undefined field38_0xe50[2164]; + int32_t settlementTaxLevel; //0x0E50 + struct settlementCapability settlementCapabilities[57]; //0x0E54 + struct settlementCapability settlementCapabilitiesAgent[6]; //0x0F38 + struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x0F50 + struct settlementCapability settlementCapabilitiesAncillary[4]; //0x0F68 (ROME - NOT IMPLEMENTED IN MED 2) + char pad_0F78[4]; //0x0F78 + struct recruitCapRome settlementCapabilitiesRecruit[64]; //0x0F7C + struct recruitmentCapability recruitmentCapabilities[64]; //0x117C + int32_t recruitPoolCapabilityCount; //0x167C + int8_t N000089C8; //0x1680 + char pad_1681[3]; //0x1681 + struct settlementStruct* thisSett; //0x1684 + struct settlementRecruitmentPool* recruitmentPools; //0x1688 + int32_t recruitmentPoolsSize; //0x168C + int32_t recruitmentPoolCount; //0x1690 + char pad_1694[12]; //0x1694 + int8_t freezeRecruitmentPool; //0x16A0 + char pad_16A1[3]; //0x16A1 + int32_t spiesInRecruitmentQueue; //0x16A4 + int32_t assassinsInRecruitmentQueue; //0x16A8 + int32_t diplomatsInRecruitmentQueue; //0x16AC + int32_t admiralsInRecruitmentQueue; //0x16B0 + int32_t merchantsInRecruitmentQueue; //0x16B4 + int32_t priestsInRecruitmentQueue; //0x16B8 + char pad_16BC[8]; //0x16BC intptr_t guildStandings; char pad_16C8[56]; //0x16C8 - int32_t Turmoil; //0x1700 + int32_t turmoil; //0x1700 char pad_1704[116]; //0x1704 int32_t populationLastTurn; //0x1778 char pad_177C[180]; //0x177C @@ -1134,24 +1833,56 @@ struct general { /* character on the stratmap, who has a unit in a stack */ struct genMod* genType; undefined field9_0x8c[24]; uchar ifMarkedToKill; - undefined field11_0xa5[19]; + undefined field11_0xa5[1]; + int8_t inEnemyZOC; //0x00A6 + char pad_00A7[17]; //0x00A7 int ambushState; undefined field13_0xbc[12]; - float movepoints1; + int8_t doNotSpendMovePoints; //0x00C5 + char pad_00C6[2]; //0x00C6 + float movePointsCharacter; undefined field15_0xcc[4]; uchar isStopCharacterNeeded; /* set to 1 if character moving now and he stops */ - undefined field17_0xd1[47]; + int32_t numTurnsIdle; //0x00D4 + int32_t regionID; //0x00D8 + float percentCharacterReligionInRegion; //0x00DC + float popConvertedThisTurn; //0x00E0 + int32_t timeInRegion; //0x00E4 + int32_t timeWithArmy; //0x00E8 + char pad_00EC[20]; //0x00EC struct stackStruct* armyLeaded; /* army of the general */ undefined field19_0x104[4]; struct unit* bodyguards; /* unit of general */ struct stackStruct* armyNotLeaded; /* army, if not leader */ undefined field22_0x110[208]; undefined field23_0x1e0[4]; - float movepointsModifier; - float movepointsMax; - float movepoints2; - undefined field27_0x1f0[64]; + float movePointsModifier; + float movePointsMax; + float movePointsArmy; + float movePointsMaxArmy; //0x01F0 + struct crusade* crusade; //0x01F4 + int32_t turnJoinedCrusade; //0x01F8 + int32_t currentTurn; //0x01FC + char pad_0200[48]; //0x0200 char* ability; /* custom ability */ + char pad_0234[4]; //0x0234 + struct general* thisCharacter; //0x0238 + char pad_023C[16]; //0x023C + struct general* thisCharacter2; //0x024C + int32_t xCoordLast; //0x0250 + int32_t yCoordLast; //0x0254 + int32_t xCoordCurrent; //0x0258 + int32_t yCoordCurrent; //0x025C + char pad_0260[332]; //0x0260 + void* someCoordStruct; //0x03AC + int32_t someCoordStructSize; //0x03B0 + int32_t someCoordStructCount; //0x03B4 + struct movePath* multiTurnMovePaths; //0x03B8 + int8_t multiTurnMovePathsSize; //0x03BC + int8_t multiTurnMovePathsCount; //0x03BD + int8_t N00032E71; //0x03BE + int8_t N00032E76; //0x03BF + char pad_03C0[8]; //0x03C0 }; //additional character data(name,label,traits, etc) @@ -1236,7 +1967,7 @@ struct namedCharacter { /* many important info about character */ int32_t battleSurgery; //0x01E0 struct traitContainer* traits; /* names at [item number] -0x4-here. Not have number, read it in while(traits != 0){this->m_memory->Read(traits + 0x08, 4).toINT32();} */ undefined field_0x1e8[4]; - struct ancData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ + struct anchData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ undefined field_0x1f0[4]; UINT32 anchNum; /* number of character ancillaries */ struct general* gen; /* on stratmap */ @@ -1319,34 +2050,411 @@ struct engineRecord { }; struct soldierInBattle { - undefined field_0x0[24]; + undefined field_0x0[8]; + int32_t unitCategory; //0x0008 + int16_t someFlags; //0x000C + int8_t N00008AC5; //0x000E + int8_t N00008AC7; //0x000F + float mass; //0x0010 + float inverseMass; //0x0014 float xCoord; float zCoord; float yCoord; - undefined field_0x24[1440]; -}; + struct soldierInBattle* self; //0x0024 + float someRadius1; //0x0028 + float someRadius2; //0x002C + float someRadius3; //0x0030 + float markerRadius; //0x0034 + float height; //0x0038 + char pad_003C[8]; //0x003C + int16_t rotation; //0x0044 + char pad_0046[2]; //0x0046 + float velocity1; + float velocity2; + float velocity3; + char pad_0054[196]; //0x0054 + struct soldierInBattle* self2; //0x0118 + char pad_011C[4]; //0x011C + float speed; //0x0120 + char pad_0124[4]; //0x0124 + float xCoord_writable; + float zCoord_writable; + float yCoord_writable; + uint16_t angle_writable; //0x0134 + int8_t N0000713A; //0x0136 + int8_t N00009525; //0x0137 + float velocityModifier; //0x0138 + int32_t currentStateGroupID; //0x013C + int32_t currentStateStateID; //0x0140 + int32_t pendingStateGroupID; //0x0144 + int32_t pendingStateStateID; //0x0148 + char pad_014C[4]; //0x014C + float xCoord_destination; + float zCoord_destination; + float yCoord_destination; + int16_t destinationAngle; //0x015C + int16_t thisIsAngleCauseTwoByteMaybe; //0x015E + float destinationRadius; //0x0160 + char pad_0164[16]; //0x0164 + int16_t N00001DC6; //0x0174 + char pad_0176[2]; //0x0176 + int32_t targetStateGroupID; //0x0178 + int32_t targetStateStateID; //0x017C (One = Standing, 2 = Walking, 3 = running) + int32_t moveStateGroupID; //0x0180 + int32_t moveStateStateID; //0x0184 (2 = walking, 3 = running) + int32_t finishStateGroupID; //0x0188 + int32_t finishStateStateID; //0x018C + int32_t options; //0x0190 + int32_t pendingAction; //0x0194 + float stoppingModifier; //0x0198 + float slideRotation; //0x019C + int32_t numTicks; //0x01A0 + char pad_01A4[20]; //0x01A4 + int32_t surfaceID; //0x01B8 + int16_t pathHistoryAndObstacleDirection; //0x01BC + int16_t unk; //0x01BE + char pad_01C0[16]; //0x01C0 + int16_t waypoint; //0x01D0 + char pad_01D2[18]; //0x01D2 + int16_t cone; //0x01E4 + int16_t directionOffset; //0x01E6 + int16_t blockedCounter; //0x01E8 + int16_t N0000954E; //0x01EA + float radiusModifier; //0x01EC + float speedModifier; //0x01F0 + int32_t deflectionCounter; //0x01F4 + float stoppingDistance; //0x01F8 + float externalModifier; //0x01FC + uint32_t locomotionFlags; //0x0200 + char pad[960]; //0x01D2 + +}; + +struct generalInfo +{ +public: + char** generalModelName; //0x0000 + struct unit* unit; //0x0004 + struct namedCharacter* namedChar; //0x0008 + char pad_000C[48]; //0x000C + int8_t N00010FEA; //0x003C + char pad_003D[43]; //0x003D + struct soldierInBattle* soldier; //0x0068 + int8_t isCharacter; //0x006C + int8_t alive; //0x006D + char pad_006E[2]; //0x006E + struct heroAbility* ability; //0x0070 + char pad_0074[144]; //0x0074 +}; //Size: 0x0104 + +struct floatPosData +{ +public: + float rotStart; //0x0000 + float coord2_1; //0x0004 + float coord2_2; //0x0008 + float coord3_2; //0x000C + float coord3_1; //0x0010 + float coord0_2; //0x0014 + float coord0_1; //0x0018 + float unk1; //0x001C + float unk2; //0x0020 + float unk; //0x0024 + float rotation1; //0x0028 + float rotation2; //0x002C + float coord1_1; //0x0030 + float coord1_2; //0x0034 + float val15; //0x0038 + float rotValue1; //0x003C + float rotValue2; //0x0040 +}; //Size: 0x0044 + +struct targetUnitStruct +{ +public: + char pad_0000[4]; //0x0000 + struct unit* target; //0x0004 + char pad_0008[4]; //0x0008 + int32_t targetUnitIndex; //0x000C + char pad_0010[4]; //0x0010 +}; //Size: 0x0014 + +struct targetPos +{ +public: + int32_t typeOrSomething; //0x0000 + int32_t N0001B8DA; //0x0004 + void* unitVerificationTable; //0x0008 + struct targetUnitStruct* targetUnit; //0x000C + char pad_0010[4]; //0x0010 + float targetPosXStart; //0x0014 + float targetPosYStart; //0x0018 + char pad_001C[16]; //0x001C + int32_t noDraggedFormation; //0x002C + float N0001B8E5; //0x0030 + float N0001B8E6; //0x0034 + char pad_0038[4]; //0x0038 + float somethingDistanceRelated; //0x003C + int32_t ranks; //0x0040 + float N0001B8EA; //0x0044 + char pad_0048[4]; //0x0048 + float N0001B8EC; //0x004C + char pad_0050[4]; //0x0050 + int8_t N0001B8EE; //0x0054 + int8_t draggedFormation1; //0x0055 + int8_t N0003D819; //0x0056 + int8_t draggedFormation2; //0x0057 + int8_t N0001B8EF; //0x0058 + int8_t N0003D80B; //0x0059 + int8_t N0003D80E; //0x005A + int8_t N0003D80C; //0x005B + float targetPosXEnd; //0x005C + float targetPosYEnd; //0x0060 + int8_t N0001B8F4; //0x0064 + int8_t N0003D7F4; //0x0065 + int8_t N0003D7F7; //0x0066 + int8_t N0003D7F5; //0x0067 + void* N0001B8F5; //0x0068 + int8_t N0001B8F6; //0x006C + int8_t N0003D7EA; //0x006D + int8_t N0003D7ED; //0x006E + int8_t N0003D7EB; //0x006F + float targetCoordXEngine; //0x0070 + float targetCoordZEngine; //0x0074 + float targetCoordYEngine; //0x0078 + struct siegeEngine* siegeEngine; //0x007C + int32_t N0001B8FB; //0x0080 + int32_t N0001B8FC; //0x0084 + char pad_0088[8]; //0x0088 + float N0001B8FF; //0x0090 + char pad_0094[16]; //0x0094 + float N0003A5AB; //0x00A4 +}; //Size: 0x00A8 + +struct battleMapPosition +{ +public: + int32_t positionIDMaybe; //0x0000 + int32_t numSoldiers; //0x0004 +}; //Size: 0x0008 + +struct engagedUnit +{ +public: + struct unit* unit; //0x0000 + int32_t intValue; //0x0004 + int32_t intValue2; //0x0008 + int32_t intValue3; //0x000C + int32_t intValue4; //0x0010 + int32_t intValue5; //0x0014 + float floatValue; //0x0018 +}; //Size: 0x001C + + +struct unitPositionData +{ +public: + struct engagedUnit* engagedUnits; //0x0000 + int32_t engagedUnitsSize; //0x0004 + int32_t engagedUnitsNum; //0x0008 + struct engagedUnit* engagedUnits2; //0x000C + int32_t engagedUnits2Size; //0x0010 + int32_t engagedUnits2Num; //0x0014 + char pad_0018[16]; //0x0018 + struct unit* unit; //0x0028 + char pad_002C[4]; //0x002C + void* N00002C71; //0x0030 + char pad_0034[4]; //0x0034 + struct unit* N00002C73; //0x0038 + float coord0; //0x003C + float coord1; //0x0040 + float coord2; //0x0044 + float coord3; //0x0048 + float rotation; //0x004C + struct battleMapPosition* isOnWalls; //0x0050 + int32_t isOnWallsSize; //0x0054 + int32_t isOnWallsCount; //0x0058 + struct battleMapPosition* isInTower; //0x005C + int32_t isInTowerSize; //0x0060 + int32_t isInTowerCount; //0x0064 + struct battleMapPosition* isInGateHouse; //0x0068 + int32_t isInGateHouseSize; //0x006C + int32_t isInGateHouseCount; //0x0070 + struct battleMapPosition* positions1; //0x0074 + int32_t positions1Size; //0x0078 + int32_t positions1Count; //0x007C + struct battleMapPosition* positions2; //0x0080 + int32_t positions2Size; //0x0084 + int32_t positions2Count; //0x0088 + struct battleMapPosition* positions3; //0x008C + int32_t positions3Size; //0x0090 + int32_t positions3Count; //0x0094 + struct battleMapPosition* positions4; //0x0098 + int32_t positions4Size; //0x009C + int32_t positions4Count; //0x00A0 + char pad_00A4[12]; //0x00A4 + struct floatPosData floatPosData; //0x00B0 + char pad_00F4[4]; //0x00F4 + struct targetPos targetArray[16]; //0x00F8 + int32_t targetsDone; //0x0B78 + int32_t additionalTargetsOverOne; //0x0B7C + int32_t targetsToGo; //0x0B80 + int8_t hasTargets; //0x0B84 + int8_t isHalted; //0x0B85 + char pad_0B86[6]; //0x0B86 + float lastTargetCoord1; //0x0B8C + float lastTargetCoord2; //0x0B90 + char pad_0B94[20]; //0x0B94 + float N00002F68; //0x0BA8 + float N00002F69; //0x0BAC + float N00002F6A; //0x0BB0 + float N00002F6B; //0x0BB4 + float N00002F6C; //0x0BB8 + float N00002F6D; //0x0BBC + float N00002F6E; //0x0BC0 + float N00002F6F; //0x0BC4 + float N00002F70; //0x0BC8 + float N00002F71; //0x0BCC + float N00002F72; //0x0BD0 + float N00002F73; //0x0BD4 + float N00002F74; //0x0BD8 + float N00002F75; //0x0BDC + float N00002F76; //0x0BE0 + float N00002F77; //0x0BE4 + float N00002F78; //0x0BE8 + char pad_0BEC[20]; //0x0BEC + void** towersUnderFireFrom; //0x0C00 + int32_t towersUnderFireFromSize; //0x0C04 + int32_t towersUnderFireFromCount; //0x0C08 + struct unit** unitsUnderFireFrom; //0x0C0C + int32_t unitsUnderFireFromSize; //0x0C10 + int32_t unitsUnderFireFromCount; //0x0C14 + void** underFireSomething2; //0x0C18 + int32_t underFireSomething2Size; //0x0C1C + int32_t underFireSomething2Count; //0x0C20 + void** underFireSomething3; //0x0C24 + int32_t underFireSomething3Size; //0x0C28 + int32_t underFireSomething3Count; //0x0C2C + char pad_0C30[8]; //0x0C30 + int32_t combatStatus; //0x0C38 +}; //Size: 0x0C3C //unit data struct unit { undefined field0_0x0[4]; struct trackedPointerUnit** trackedUnitPointerP; - undefined field2_0x8[636]; - struct stackStruct* army; + undefined field2_0x8[52]; + int32_t aiActiveSet; //0x003C + undefined field_0040[24]; + struct modelEntry* bmdbEntry; //0x0058 + undefined field3_0x5C[548];//0x005C + struct unitPositionData* unitPositionData; //0x0280 + struct stackStruct* army;//0x0284 undefined field4_0x288[12]; struct eduEntry* eduEntry; - int ID; - undefined field7_0x29c[612]; + int ID; //0x0298 + int battlemapTeam; //0x029C + int actionStatus; //0x02A0 + char pad_02A4[24]; //0x02A4 + void* ThirtyTwoByteObject; //0x02BC + char pad_02C0[8]; //0x02C0 + void* hundredSixtyByteObject; //0x02C8 + char pad_02CC[8]; //0x02CC + int fatigue; //0x02D4 + float killChanceModifier; //0x02D8 + struct Unit* this2; //0x02DC + int moraleLevel; //0x02E0 + int moraleStatusSum; //0x02E4 + char pad_02E8[24]; //0x02E8 + int moraleValue1; //0x0300 + int moraleValue2; //0x0304 + int moraleValue3; //0x0308 + int moraleValue4; //0x030C + int moraleValue5; //0x0310 + int moraleValue6; //0x0314 + int moraleValue7; //0x0318 + int moraleValue8; //0x031C + int moraleValue9; //0x0320 + char pad_0324[372]; //0x0324 + struct unitMorale* moralePartOfUnitLookAbove; //0x0498 + char pad_049C[4]; //0x049C + int someMoraleValue; //0x04A0 + char pad_04A4[4]; //0x04A4 + int16_t N0000271D; //0x04A8 + int8_t N00009770; //0x04AA + int8_t skipsMoraleCalcIFNotZero; //0x04AB + int8_t lockedMorale; //0x04AC + char pad_04AD[11]; //0x04AD + int moraleAreaEffectEnd; //0x04B8 + char pad_04BC[60]; //0x04BC + int hasActiveEffects; //0x04F8 + int activeEffectsOnThisUnit; //0x04FC int expScreen; /* screen experience */ struct general* general; float movePoints; - int number; /* number of soldiers */ - int numberTact; /* number of soldiers on tactical map */ - int numberMax; /* max number of soldiers */ - undefined field14_0x518[216]; + int SoldierCountStrat; /* number of soldiers */ + int SoldierCountMaxStrat; /* number of soldiers on tactical map */ + int SoldierCountBattlemap; /* max number of soldiers */ + int soldierCountMaxBattlemap; /* max number of soldiers */ + char pad_051C[64]; //0x051C + struct generalInfo* officer1; //0x055C + struct generalInfo* officer2; //0x0560 + struct generalInfo* officer3; //0x0560 + struct generalInfo* generalInfo; //0x0568 + struct soldierInBattle* generalSoldier; //0x056C + struct soldierInBattle* officer1Soldier; //0x0570 + struct soldierInBattle* officer2Soldier; //0x0574 + struct soldierInBattle* officer3Soldier; //0x0578 + int32_t numOfficer; //0x057C + int32_t numOfficerInBattle; //0x0580 + int32_t N00002755; //0x0584 + int32_t N00002756; //0x0588 + int32_t N00002757; //0x058C + int32_t N00002758; //0x0590 + int32_t statPri; //0x0594 + char pad_0598[20]; //0x0598 + int32_t weaponType; //0x05AC + int32_t weaponTecType; //0x05B0 + char pad_05B4[8]; //0x05B4 + int32_t minAttackDelayPri; //0x05BC + char pad_05C0[28]; //0x05C0 + int32_t statPriArmour; //0x05DC + int32_t valueAfterInEdu; //0x05E0 + int8_t attackInBattle; //0x05E4 + int16_t armourInBattle; //0x05E5 + char pad_05E7[1]; //0x05E7 + int8_t N0000276E; //0x05E8 + int8_t N00010E95; //0x05E9 + char pad_05EA[6]; //0x05EA UINT32 stats; /* def/atk/etc */ struct soldierInBattle** soldiersBattleArr; /* array of soldiers battle data */ struct soldierData* soldiersArr; /* array of soldiers data */ - undefined field18_0x5fc[6780]; + void* soldierIndices; //0x05FC + void* generalOrMount; //0x0600 + int32_t attachmentCount; //0x0604 + char pad_0608[6172]; //0x0608 + void* UNIT_TASK_INTERFACE; //0x1E24 + char pad_1E28[28]; //0x1E28 + int32_t unitBattleProperties; //0x1E44 + char pad_1E48[4]; //0x1E48 + void* formationsArray; //0x1E4C + char pad_1E50[28]; //0x1E28 + int16_t ranks; //0x1E76 + char pad_1E78[14]; //0x1E78 + int8_t isCloseFormation; //0x1E84 + char pad_1E85[59]; //0x1E85 + float positionX; //0x1EC0 + float N00002FB7; //0x1EC4 + float positionY; //0x1EC8 + char pad_1ECC[400]; //0x1ECC + int32_t maxAmmo; //0x205C + int32_t currentAmmo; //0x2060 + uint8_t statusField1; //0x2064 + uint8_t statusField2; //0x2065 + uint8_t statusField3; //0x2066 + char pad_2067[1]; //0x2067 + int8_t rallyHornCountdown; //0x2068 + char pad_2069[15];; //0x2069 UNICODE_STRING** alias; /* Legio string etc */ undefined field20_0x207c[44]; struct siegeEngine** siegeEngine; @@ -1363,27 +2471,50 @@ struct stackStruct { /* structure of stack */ struct factionStruct* faction; int regionID; struct unit** units; - undefined field_0x58[4]; + int32_t unitsSize; //0x0058 int numOfUnits; - undefined field_0x60[56]; + undefined field_0x60[48]; + int8_t isBoarded; //0x0090 + char pad_0091[7]; //0x0091 struct stackStruct* boardedArmy; /* if fleet, here army */ undefined field_0x9c[4]; struct stackStruct* shipArmy; /* here fleet what contain our army */ undefined field_0xa4[8]; struct siegeS* siege; struct portBuildingStruct* blockedPort; /* if port blocked by this army when it here */ - undefined field_0xb4[32]; + undefined field_0xb4[3]; + int8_t ladders; //0x00B7 + int8_t rams; //0x00B8 + int8_t towers; //0x00B9 + char pad_00BA[10]; //0x00BA + int32_t tilesMovedThisTurnDoesntStatAtZero; //0x00C4 + char pad_00C8[4]; //0x00C8 + uint32_t upkeepModifier; //0x00CC + char pad_00D0[4]; //0x00D0 struct general* gen; /* 0 if in settlement/fort */ - undefined field_0xd8[24]; - struct general** characters; - undefined field_0xf4[4]; - int charactersNum; - undefined field_0xfc[4]; - struct settlementStruct* settlement; - undefined field_0x104[32]; + struct unit* generalsUnit; //0x00D8 + struct generalInfo* generalInfo; //0x00DC + float armyStrengthForAutoResolveMaybe; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct general** characters; //0x00F0 + undefined field_0xf4[4]; //0x00F4 + int charactersNum; //0x00F8 + undefined field_0xfc[4]; //0x00FC + struct settlementStruct* settlement; //0x0100 + undefined field_0x104[16]; + struct stackStruct* enemyArmy; + int32_t inBattle; //0x0118 + int8_t N00001BCA; //0x011C + int8_t N0003D211; //0x011D + uint16_t N0003D214; //0x011E + char pad_0120[4]; //0x0120 int totalStrength; float reform_point_x; float reform_point_y; + int32_t battleSide; //0x0130 + char pad_0134[16]; //0x0134 + int32_t battleAllianceOrSomething; //0x0144 + int32_t battleDifficulty; //0x0148 }; struct coords { @@ -1401,56 +2532,129 @@ struct factionTileStruct { int revealedTilesNumber; undefined field7_0x34[24]; }; + +struct factionEconomy +{ +public: + int32_t farmingIncome; //0x0000 + int32_t taxesIncome; //0x0004 + int32_t miningIncome; //0x0008 + int32_t tradeIncome; //0x000C + int32_t merchantIncome; //0x0010 + int32_t constructionIncome; //0x0014 + int32_t otherIncome1; //0x0018 + int32_t otherIncome2; //0x001C + int32_t diplomacyIncome; //0x0020 + int32_t tributesIncome; //0x0024 + int32_t adminIncome; //0x0028 + int32_t kingsPurseIncome; //0x002C + int32_t wagesExpense; //0x0030 + int32_t upkeepExpense; //0x0034 + int32_t constructionExpenseBuildings; //0x0038 + int32_t constructionExpenseField; //0x003C + int32_t recruitmentExpenseBuildings; //0x0040 + int32_t recruitmentExpenseMercs; //0x0044 + int32_t corruptionExpense; //0x0048 + int32_t diplomacyExpense; //0x004C + int32_t tributesExpense; //0x0050 + int32_t otherExpense1; //0x0054 + int32_t otherExpense2; //0x0058 + int32_t devastationExpense; //0x005C +}; //Size: 0x0060 + +struct battleFactionCounter +{ +public: + int32_t battlesWon; //0x0000 + int32_t battlesLost; //0x0004 + int32_t wonLostRatio; //0x0008 +}; //Size: 0x000C + //faction struct factionStruct { undefined field_0x0[180]; int dipNum; /* number of faction in diplomatic array */ int cultureID; char* ai_label; /* ai_label of faction */ - undefined field_0xc0[4]; + int32_t AILabelHash; //0x00C0 struct settlementStruct* capital; /* capital of the faction */ struct namedCharacter* leader; /* faction leader */ struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ - UINT32* ai_assistant; - undefined field_0xdc[20]; - UINT32 holdRegions; - undefined field_0xf4[4]; + struct aiFaction* AIFaction; //0x00D8 + int32_t AIPersonalityType; //0x00DC + int32_t AIPersonalityName; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct holdRegionsWinCondition* WinConditions; //0x00F0 + int32_t someInteger; //0x00F4 struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ - undefined field_0xfc[4]; + int32_t namedCharactersSize; //0x00FC int numOfCharactersAll; /* all characters, died, alive, etc */ struct general** characters; /* characters on stratmap */ - undefined field_0x108[4]; + int32_t charactersSize; //0x0108 int numOfCharacters; /* characters on stratmap */ struct stackStruct** stacks; - undefined field_0x114[4]; + int32_t armiesSize; //0x0114 int stackNum; int* regionsID; - undefined field_0x120[4]; + int32_t regionsSize; //0x0120 int regionsNum; struct settlementStruct** settlements; - undefined field_0x12c[4]; + int32_t settlementsSize; //0x012C int settlementsNum; struct fortStruct** forts; - undefined field_0x138[4]; + int32_t fortsSize; //0x0138 int fortsNum; struct watchTowerStruct** watchTowers; /* watchtowers */ - undefined field_0x144[4]; + int32_t watchtowersSize; //0x0144 int wathtowersNum; struct portBuildingStruct** portBuildings; /* port buildings */ - undefined field_0x150[4]; + int32_t portBuildingsSize; //0x0150 int portBuildingsNum; - undefined field_0x158[68]; + uint32_t neighBourFactionsBitmap; //0x0158 + int* neighBourRegions; //0x015C + int32_t neighBourRegionsSize; //0x0160 + int32_t neighBourRegionsNum; //0x0164 + char pad_0168[49]; //0x0168 + int8_t isUndiscovered; //0x0199 + char pad_019A[2]; //0x019A factionTileStruct* tilesFac; - undefined field_0x1a0[2208]; + struct mission** missions; //0x01A0 + int32_t missionsSize; //0x01A4 + int32_t missionCount; //0x01A8 + char pad_01AC[48]; //0x01AC + struct factionRanking* factionRankings; //0x01DC + int32_t factionRankingsSize; //0x01E0 + int32_t factionRankingsCount; //0x01E4 + char pad_01E8[24]; //0x01E8 + int32_t freezeFactionAI; //0x0200 + char pad_0204[2096]; //0x0204 + int32_t treasuryTurnStart; //0x0A34 + char pad_0A38[8]; //0x0A38 UINT32 religion; /* number of religion */ - undefined field_0xa44[84]; + undefined field_0xa44[16]; + int8_t isFactionExcommunicated; //0x0A54 + char pad_0A55[67]; //0x0A55 UNICODE_STRING** someString; UNICODE_STRING** localizedName; undefined field_0xaa0[76]; int money; /* money of the faction */ int KingsPurse; /* money of the faction */ + int32_t incomeDoubled; //0x0AF4 + struct factionEconomy factionEconomy[10]; //0x0AF8 + int32_t nextCounterEconomy; //0x0EB8 + int32_t counterEconomy; //0x0EBC + int32_t maxTurnsTillReset; //0x0EC0 + char pad_0EC4[16]; //0x0EC4 + struct battleFactionCounter(*battlesWonVsFaction)[31]; //0x0ED4 + int32_t factionCountStart; //0x0ED8 + int32_t otherFactionCount; //0x0EDC + int32_t battlesWon; //0x0EE0 + int32_t battlesLost; //0x0EE4 + int32_t settlementsCaptured; //0x0EE8 + int32_t settlementsLost; //0x0EEC + char pad_0EF0[24]; //0x0EF0 }; struct ModelDbEntry @@ -1678,8 +2882,8 @@ struct eduEntry { void* N00000152; void* N00000153; char pad_0394[12]; - void* Attributes; - void* EndOfAttributes; + DWORD* Attributes; + DWORD* EndOfAttributes; void* BytesBeforeNextAttributes; int8_t Attributes2; int8_t Attributes3; @@ -1710,7 +2914,7 @@ struct someFactNameStruct { }; //pointer to ancillary -struct ancData { /* data of the ancillary */ +struct anchData { /* data of the ancillary */ struct anchillary* dataAnch; }; @@ -1779,21 +2983,20 @@ struct consoleCommands { int size; }; +struct battleCameraStruct +{ +public: + float xCoord; //0x0000 + char pad_0004[4]; //0x0004 + float yCoord; //0x0008 + char pad_000C[20]; //0x000C + float zCoord; //0x0020 +}; //Size: 0x0024 + struct descr_sm_factions_list { struct factionStratMapDescrS* facDescrs; int capacity; int size; }; -struct battleCameraStruct -{ - public: - float xCoord; //0x0000 - char pad_0004[4]; //0x0004 - float yCoord; //0x0008 - char pad_000C[20]; //0x000C - float zCoord; //0x0020 -}; //Size: 0x0024 - - #pragma pack(pop) \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp index 60508b8a..3738261f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp @@ -1,4 +1,6 @@ #include "battleHandlerHelpers.h" + +#include "gameDataAllHelper.h" #include "plugData.h" namespace battleHandlerHelpers { @@ -28,4 +30,25 @@ namespace battleHandlerHelpers { return &battleArmy->units[index]; } + + stackStruct* getPlayerArmy(const battleDataS* battleData) + { + return battleData->playerArmies[0].army; + } + + factionStruct* getFaction(const battleSide* side, int index) + { + return side->factions[index]; + } + + battleResidence* getBattleResidence() + { + const auto gameData = gameDataAllHelper::get(); + const auto battleSettlement = gameData->battleSettlement; + if (battleSettlement) + { + return battleSettlement->battleResidence; + } + return nullptr; + } }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h index 12de1186..6faac421 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h @@ -6,5 +6,8 @@ namespace battleHandlerHelpers std::string getWinConditionS(DWORD condition); armyAndCharacter* getBattleArmy(const battleSide* side, int index); battleUnit* getBattleUnit(const armyAndCharacter* battleArmy, int index); + stackStruct* getPlayerArmy(const battleDataS* battleData); + factionStruct* getFaction(const battleSide* side, int index); + battleResidence* getBattleResidence(); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp index 7cc3f190..f1f05738 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp @@ -39,6 +39,11 @@ portBuildingStruct* factionHelpers::getPort(const factionStruct* fac, int index) return fac->portBuildings[index]; } +int factionHelpers::getNeighbourRegionID(const factionStruct* fac, int index) +{ + return fac->neighBourRegions[index]; +} + watchTowerStruct* factionHelpers::getWatchtower(const factionStruct* fac, int index) { return fac->watchTowers[index]; @@ -49,6 +54,11 @@ void factionHelpers::deleteFort(const factionStruct* fac, fortStruct* fort) (*(*plugData::data.funcs.deleteFort))(fac, fort); } +battleFactionCounter* factionHelpers::getBattleVsFactionStats(factionStruct* fac, int targetFactionID) +{ + return fac->battlesWonVsFaction[targetFactionID]; +} + bool factionHelpers::hasMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2) { const auto gameData = gameDataAllHelper::get(); @@ -79,6 +89,11 @@ float factionHelpers::getFactionStanding(const factionStruct* fac1, const factio return campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].factionStanding; } +bool factionHelpers::isNeighbourFaction(const factionStruct* fac1, const factionStruct* fac2) +{ + return fac1->neighBourFactionsBitmap & (1 << fac2->dipNum); +} + void factionHelpers::setFactionStanding(const factionStruct* fac1, const factionStruct* fac2, float standing) { const auto gameData = gameDataAllHelper::get(); @@ -101,6 +116,35 @@ void factionHelpers::changeFactionName(factionStruct* fac, const char* newName) (*(*plugData::data.funcs.changeFactionName))(fac, newName); } +factionRanking* factionHelpers::getFactionRanking(const factionStruct* fac, int turnNum) +{ + return &fac->factionRankings[turnNum]; +} + +factionEconomy* factionHelpers::getFactionEconomy(factionStruct* fac, int turnsAgo) +{ + int turnIndex = fac->counterEconomy - turnsAgo; + if (turnIndex < 0) + { + turnIndex += fac->maxTurnsTillReset; + } + return &fac->factionEconomy[turnIndex]; +} + +const char* factionHelpers::getRegionToHoldName(const holdRegionsWinCondition* condition, int index) +{ + return condition->regionsToHold[index].name; +} + +int factionHelpers::getRegionToHoldLength(const holdRegionsWinCondition* condition, int index) +{ + if (index < condition->holdRegionLengthsCount) + { + return condition->holdRegionLengths[index]; + } + return 0; +} + std::string factionHelpers::getLocalizedFactionName(factionStruct* fac) { UNICODE_STRING** localizedname = fac->localizedName; diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h index 461ffc17..66c4b194 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h @@ -24,7 +24,13 @@ namespace factionHelpers void setFactionStanding(const factionStruct* fac1, const factionStruct* fac2, float standing); void setMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2, bool set); std::string getLocalizedFactionName(factionStruct* fac); - + const char* getRegionToHoldName(const holdRegionsWinCondition* condition, int index); + int getRegionToHoldLength(const holdRegionsWinCondition* condition, int index); + factionRanking* getFactionRanking(const factionStruct* fac, int turnNum); + factionEconomy* getFactionEconomy(factionStruct* fac, int turnsAgo); + bool isNeighbourFaction(const factionStruct* fac1, const factionStruct* fac2); + int getNeighbourRegionID(const factionStruct* fac, int index); + battleFactionCounter* getBattleVsFactionStats(factionStruct* fac, int targetFactionID); //faction template std::string getStringProperty(const factionStruct* fac) diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp index 03c45e38..45c2dfaf 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp @@ -118,10 +118,9 @@ namespace gameHelpers return region->resources[index]; } - regionStruct* gameHelpers::getNeighbour(regionStruct* region, const int index) + neighbourRegion* gameHelpers::getNeighbour(regionStruct* region, const int index) { - neighbourRegion* nregion = ®ion->neighbourRegions[index]; - return nregion->region; + return ®ion->neighbourRegions[index]; } bool gameHelpers::getHiddenResource(regionStruct* region, int index) @@ -356,6 +355,130 @@ namespace gameHelpers return campaign->watchtowers[index]; } + unit* gameHelpers::getSelectedUnitCard(const uiCardManager* cardManager, const int index) + { + return cardManager->selectedUnitCards[index]->unit; + } + + unit* gameHelpers::getUnitCard(const uiCardManager* cardManager, const int index) + { + return cardManager->unitCards[index]->unit; + } + + coordPair* getVolcanoCoords(const stratMap* map, const int index) + { + return &map->volcanoes[index]; + } + + coordPair* getLandConnection(const stratMap* map, const int index) + { + return &map->landMassConnections[index]; + } + + landMass* getLandMass(stratMap* map, const int index) + { + return &map->landMass[index]; + } + + int getRegionID(const landMass* landMass, const int index) + { + return landMass->regions[index]; + } + + coordPair* getRoadCoord(const roadStruct* road, const int index) + { + return &road->coords[index]; + } + + int getTileFactionID(const oneTile* tile) + { + return tile->factionId & 0b00111111; + } + + bool tileHasRiver(const oneTile* tile) + { + return tile->factionId & 0b01000000; + } + + bool tileHasCrossing(const oneTile* tile) + { + return tile->factionId & 0b10000000; + } + + int tileBorderType(const oneTile* tile) + { + return tile->border / 4; + } + + bool tileHasCharacter(const oneTile* tile) + { + return tile->objectTypes & (1 << 6); + } + + bool tileHasShip(const oneTile* tile) + { + return tile->objectTypes & (1 << 5); + } + + bool tileHasWatchtower(const oneTile* tile) + { + return tile->objectTypes & (1 << 4); + } + + bool tileHasPort(const oneTile* tile) + { + return tile->objectTypes & (1 << 3); + } + + bool tileHasFort(const oneTile* tile) + { + return tile->objectTypes & (1 << 1); + } + + bool tileHasSettlement(const oneTile* tile) + { + return tile->objectTypes & (1 << 0); + } + + bool factionHasArmyNearTile(const oneTile* tile, int factionID) + { + return tile->armiesNearTile & (1 << factionID); + } + + bool factionHasCharacterOnTile(const oneTile* tile, int factionID) + { + return tile->charactersOnTile & (1 << factionID); + } + + coordPair* convertTileCoords(DWORD arrayIndex) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + bool found = false; + int x = 0; + int y = 0; + int index = arrayIndex; + for (y = 0;y < map->mapHeight;y++) + { + x = index - y * map->mapWidth; + if (x >= 0 && x < map->mapWidth) + { + auto coords = new coordPair; + coords->xCoord = x; + coords->yCoord = y; + return coords; + } + } + return nullptr; + } + + coordPair* getTileCoords(const oneTile* tile) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + return convertTileCoords(tile - map->tilesArr); + } + settlementStruct* getSettlementByName(campaign* campaign, const char* name) { settlementList* settlementList = &campaign->settlementList; @@ -400,4 +523,92 @@ namespace gameHelpers // Return the converted string return buffer; } + + seaConnectedRegion* getSeaConnectedRegion(const regionStruct* region, const int index) + { + return ®ion->seaConnectedRegions[index]; + } + + seaConnectedRegion* getSeaImportRegion(const regionStruct* region, const int index) + { + return region->seaImportRegions[index]; + } + + oneTile* getRegionSeaEdge(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->regionSeaEdges[index]]; + } + + float getReligionHistory(const regionStruct* region, const int religionID, int turnsAgo) + { + if (turnsAgo > 19) + { + return 0.0f; + } + if (turnsAgo == 0) + { + return region->religionsARR[religionID]; + } + return region->religionHistory[turnsAgo][religionID]; + } + + oneTile* getTileBorderingEdgeOfMap(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->tilesBorderingEdgeOfMap[index]]; + } + + oneTile* getTileRegion(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->tiles[index]]; + } + + oneTile* getFertileTile(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->fertileTiles[index]]; + } + + oneTile* getBorderTile(const neighbourRegion* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->bordertiles[index]]; + } + + oneTile* getReachableTile(const seaConnectedRegion* region, int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + if (!®ion->tilesReachable[index]) + { + return nullptr; + } + auto tile = region->tilesReachable[index].tileId; + return &map->tilesArr[tile]; + } + + coordPair* getTradeLaneCoord(const seaConnectedRegion* region, int index) + { + return ®ion->seaTradeLanePath[index]; + } + + bool hasResourceType(const regionStruct* region, const int resourceType) + { + return region->resourceTypesBitMap & (1 << resourceType); + } + + + } diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h index df3af8fe..0e719ec2 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h @@ -25,7 +25,8 @@ namespace gameHelpers fortStruct* getFort(const regionStruct* region, int index); watchTowerStruct* getWatchtower(const regionStruct* region, int index); resStrat* getResource(const regionStruct* region, int index); - regionStruct* getNeighbour(regionStruct* region, int index); + neighbourRegion* getNeighbour(regionStruct* region, const int index); + oneTile* getBorderTile(const neighbourRegion* region, const int index); bool getHiddenResource(regionStruct* region, int index); void setHiddenResource(regionStruct* region, int index, bool enable); void changeRegionName(regionStruct* region, const char* newName); @@ -37,6 +38,35 @@ namespace gameHelpers watchTowerStruct* getWatchTowerAll(const campaign* campaign, const int index); settlementStruct* getSettlementByName(campaign* campaign, const char* name); std::string getRebelsName(regionStruct* region); + coordPair* getVolcanoCoords(const stratMap* map, const int index); + coordPair* getLandConnection(const stratMap* map, const int index); + landMass* getLandMass(stratMap* map, const int index); + int getRegionID(const landMass* landMass, const int index); + coordPair* getRoadCoord(const roadStruct* road, const int index); + int getTileFactionID(const oneTile* tile); + bool tileHasRiver(const oneTile* tile); + bool tileHasCrossing(const oneTile* tile); + int tileBorderType(const oneTile* tile); + bool tileHasCharacter(const oneTile* tile); + bool tileHasShip(const oneTile* tile); + bool tileHasWatchtower(const oneTile* tile); + bool tileHasPort(const oneTile* tile); + bool tileHasFort(const oneTile* tile); + bool tileHasSettlement(const oneTile* tile); + bool factionHasArmyNearTile(const oneTile* tile, int factionID); + bool factionHasCharacterOnTile(const oneTile* tile, int factionID); + coordPair* convertTileCoords(DWORD arrayIndex); + coordPair* getTileCoords(const oneTile* tile); + seaConnectedRegion* getSeaConnectedRegion(const regionStruct* region, const int index); + seaConnectedRegion* getSeaImportRegion(const regionStruct* region, const int index); + oneTile* getRegionSeaEdge(const regionStruct* region, const int index); + float getReligionHistory(const regionStruct* region, const int religionID, int turnsAgo); + oneTile* getTileBorderingEdgeOfMap(const regionStruct* region, const int index); + oneTile* getTileRegion(const regionStruct* region, const int index); + oneTile* getFertileTile(const regionStruct* region, const int index); + bool hasResourceType(const regionStruct* region, const int resourceType); + oneTile* getReachableTile(const seaConnectedRegion* region, int index); + coordPair* getTradeLaneCoord(const seaConnectedRegion* region, int index); int getMercUnitNum(mercPool* mercPool); mercPoolUnit* getMercUnit(mercPool* pool, int index); @@ -46,5 +76,7 @@ namespace gameHelpers void historicEvent(const char* name, const char* title, const char* description); void scriptCommand(const char* command, const char* args); const char* getReligionName(const int index); + unit* getSelectedUnitCard(const uiCardManager* cardManager, const int index); + unit* getUnitCard(const uiCardManager* cardManager, const int index); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp index acdb5e7d..82ae36e3 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp @@ -3,7 +3,21 @@ namespace generalHelpers { - + std::unordered_map characterTypes = { + {0,"spy"}, + {1,"assassin"}, + {2,"diplomat"}, + {3,"admiral"}, + {4,"merchant"}, + {5,"priest"}, + {6,"general"}, + {7,"named_character"}, + {8,"princess"}, + {9,"heretic"}, + {10,"witch"}, + {11,"inquisitor"}, + {13,"pope"} + }; void moveToTile(general* gen, int x, int y) { (*(*plugData::data.funcs.moveNormal))(gen, x, y); @@ -40,8 +54,8 @@ namespace generalHelpers void setMovepoints(general* gen, float movepoints) { - gen->movepoints1 = movepoints; - gen->movepoints2 = movepoints; + gen->movePointsCharacter = movepoints; + gen->movePointsArmy = movepoints; if (gen->bodyguards == nullptr)return; @@ -50,7 +64,17 @@ namespace generalHelpers float getMovepoints(const general* gen) { - return gen->movepoints2; + return gen->movePointsArmy; + } + + const char* getTypeName(const general* gen) + { + const auto charType = characterTypes.find(gen->genType->type); + if (charType != characterTypes.end()) + { + return charType->second; + } + return "unknown"; } int getTypeID(const general* gen) diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h index 016778b9..02c25426 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h @@ -7,7 +7,7 @@ namespace generalHelpers void moveToTile(general* gen, int x, int y); void reposition(general* gen, int x, int y); - + const char* getTypeName(const general* gen); void killGeneral(general* gen); void setBodyguard(general* gen, unit* un); void setMovepoints(general* gen, float movepoints); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index 743c566e..d7057823 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -122,6 +122,13 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) sol::usertypebuildingLevel; sol::usertypebattleCameraStruct; sol::usertypeunitPositionData; + sol::usertypefactionEconomy; + sol::usertypefactionRanking; + sol::usertypeholdRegionsWinCondition; + sol::usertypesettlementCapability; + sol::usertyperecruitmentCapability; + sol::usertypesettlementRecruitmentPool; + sol::usertypebattleFactionCounter; }types; luaState = {}; luaPath = modPath + "\\youneuoy_Data\\plugins\\lua"; @@ -502,7 +509,22 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) local religionName =M2TWEOP.getReligionName(1); */ tables.M2TWEOPTable.set_function("getReligionName", &gameHelpers::getReligionName); - + /*** + Get some game options. + @function M2TWEOP.getOptions1 + @treturn options1 options + @usage + local options =M2TWEOP.getOptions1(); + */ + tables.M2TWEOPTable.set_function("getOptions1", &m2tweopHelpers::getOptions1); + /*** + Get some game options. + @function M2TWEOP.getOptions2 + @treturn options1 options + @usage + local options =M2TWEOP.getOptions2(); + */ + tables.M2TWEOPTable.set_function("getOptions2", &m2tweopHelpers::getOptions2); /// BattleCamera @@ -927,6 +949,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield float battlePosX 2d position on battlemap useful for getting distance etc (battle) @tfield float battlePosY 2d position on battlemap useful for getting distance etc (battle) @tfield character character + @tfield unitPositionData unitPositionData @tfield stackStruct army @tfield siegeEngineNum siegeEngineNum @tfield kill kill @@ -955,6 +978,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.unit.set("weaponLVL", sol::property(&unitHelpers::getweaponLVL, &unitHelpers::setweaponLVL)); types.unit.set("soldierCountStratMapMax", sol::property(&unitHelpers::getMaxSoldiersCount)); types.unit.set("soldierCountBattleMap", &unit::SoldierCountBattlemap); + types.unit.set("unitPositionData", &unit::unitPositionData); types.unit.set("character", &unit::general); types.unit.set("isCloseFormation", &unit::isCloseFormation); types.unit.set("moraleLevel", &unit::moraleLevel); @@ -1233,11 +1257,23 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield unit bodyguards @tfield stackStruct armyLeaded @tfield stackStruct armyNotLeaded in the stack but not leading it - @tfield float movePointsMax + @tfield int inEnemyZOC + @tfield int ambushState + @tfield int doNotSpendMovePoints + @tfield float movePointsCharacter @tfield float movePointsModifier - @tfield float movePoints + @tfield float movePointsMaxCharacter + @tfield float movePointsMaxArmy + @tfield float movePointsArmy + @tfield int turnJoinedCrusade + @tfield int numTurnsIdle + @tfield float percentCharacterReligionInRegion 0 to 1 + @tfield float popConvertedThisTurn + @tfield int timeInRegion + @tfield int timeWithArmy for auxiliary generals, not leading general @tfield string ability see descr\_hero\_abilities.xml @tfield getTypeID getTypeID + @tfield getTypeName getTypeName @tfield setTypeID setTypeID @tfield moveToTile moveToTile @tfield reposition reposition @@ -1255,9 +1291,20 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.character.set("bodyguards", &general::bodyguards); types.character.set("armyLeaded", &general::armyLeaded); types.character.set("armyNotLeaded", &general::armyNotLeaded); - types.character.set("movePointsMax", &general::movepointsMax); - types.character.set("movePointsModifier", &general::movepointsModifier); - types.character.set("movePoints", sol::property(&generalHelpers::getMovepoints, &generalHelpers::setMovepoints)); + types.character.set("inEnemyZOC", &general::inEnemyZOC); + types.character.set("ambushState", &general::ambushState); + types.character.set("doNotSpendMovePoints", &general::doNotSpendMovePoints); + types.character.set("turnJoinedCrusade", &general::turnJoinedCrusade); + types.character.set("numTurnsIdle", &general::numTurnsIdle); + types.character.set("percentCharacterReligionInRegion", &general::percentCharacterReligionInRegion); + types.character.set("popConvertedThisTurn", &general::popConvertedThisTurn); + types.character.set("timeInRegion", &general::timeInRegion); + types.character.set("timeWithArmy", &general::timeWithArmy); + types.character.set("movePointsCharacter", &general::movePointsCharacter); + types.character.set("movePointsModifier", &general::movePointsModifier); + types.character.set("movePointsMaxArmy", &general::movePointsMaxArmy); + types.character.set("movePointsMaxCharacter", &general::movePointsMax); + types.character.set("movePointsArmy", sol::property(&generalHelpers::getMovepoints, &generalHelpers::setMovepoints)); types.character.set("ability", sol::property(&luaGetSetFuncs::getStringPropertyGen, &luaGetSetFuncs::setStringPropertyGen)); /*** Get the character type. See hint below for the types. @@ -1281,6 +1328,27 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) */ types.character.set_function("getTypeID", &generalHelpers::getTypeID); /*** + Get the character type. See hint below for the types. + 0-spy + 1-assassin + 2-diplomat + 3-admiral + 4-merchant + 5-priest + 6-general + 7-named character + 8-princess + 9-heretic + 10-witch + 11-inquisitor + 13-pope + @function character:getTypeName + @treturn string type + @usage + local ourType=ourCharacter:getTypeName(); + */ + types.character.set_function("getTypeName", &generalHelpers::getTypeName); + /*** Set the character type. See hint below for the types. 0-spy 1-assassin @@ -1738,6 +1806,8 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int dipNum @tfield getFactionName getFactionName @tfield int cultureID + @tfield int AIPersonalityType + @tfield int AIPersonalityName @tfield string ai_label @tfield string name @tfield string localizedName @@ -1745,7 +1815,18 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield namedCharacter leader @tfield namedCharacter heir @tfield int isPlayerControlled 0=AI, 1=player + @tfield int neighBourFactionsBitmap @tfield int religion + @tfield int isUndiscovered + @tfield int missionCount + @tfield int freezeFactionAI + @tfield int treasuryTurnStart + @tfield int incomeDoubled + @tfield int battlesWon + @tfield int battlesLost + @tfield int settlementsCaptured + @tfield int settlementsLost + @tfield int otherFactionCount @tfield int money @tfield int kingsPurse @tfield factionStratMapStruct facStrat @@ -1763,17 +1844,24 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getPort getPort @tfield int watchtowersNum @tfield getWatchtower getWatchtower + @tfield int neighBourRegionsNum @tfield deleteFort deleteFort @tfield createFortXY createFortXY @tfield hasMilitaryAccess hasMilitaryAccess @tfield setMilitaryAccess setMilitaryAccess @tfield getFactionStanding getFactionStanding @tfield setFactionStanding setFactionStanding + @tfield getFactionRanking getFactionRanking + @tfield getFactionEconomy getFactionEconomy + @tfield getNeighbourRegionID getNeighbourRegionID + @tfield getBattleVsFactionStats getBattleVsFactionStats @table factionStruct */ types.factionStruct = luaState.new_usertype("factionStruct"); types.factionStruct.set("dipNum", &factionStruct::dipNum); + types.factionStruct.set("AIPersonalityType", &factionStruct::AIPersonalityType); + types.factionStruct.set("AIPersonalityName", &factionStruct::AIPersonalityName); /*** Get the faction's internal name @function factionStruct:getFactionName @@ -1801,9 +1889,21 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.factionStruct.set("heir", &factionStruct::heir); types.factionStruct.set("isPlayerControlled", &factionStruct::isPlayerControlled); types.factionStruct.set("religion", &factionStruct::religion); + types.factionStruct.set("missionCount", &factionStruct::missionCount); + types.factionStruct.set("isUndiscovered", &factionStruct::isUndiscovered); + types.factionStruct.set("neighBourRegionsNum", &factionStruct::neighBourRegionsNum); + types.factionStruct.set("factionRankings", &factionStruct::factionRankings); types.factionStruct.set("money", &factionStruct::money); types.factionStruct.set("kingsPurse", &factionStruct::KingsPurse); types.factionStruct.set("facStrat", &factionStruct::factSmDescr); + types.factionStruct.set("freezeFactionAI", &factionStruct::freezeFactionAI); + types.factionStruct.set("treasuryTurnStart", &factionStruct::treasuryTurnStart); + types.factionStruct.set("incomeDoubled", &factionStruct::incomeDoubled); + types.factionStruct.set("battlesWon", &factionStruct::battlesWon); + types.factionStruct.set("battlesLost", &factionStruct::battlesLost); + types.factionStruct.set("settlementsCaptured", &factionStruct::settlementsCaptured); + types.factionStruct.set("settlementsLost", &factionStruct::settlementsLost); + types.factionStruct.set("otherFactionCount", &factionStruct::otherFactionCount); types.factionStruct.set("numOfNamedCharacters", &factionStruct::numOfCharactersAll); /*** Get named character using it's index. @@ -1975,8 +2075,191 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) fac:setFactionStanding(targetFac, 0.5) */ types.factionStruct.set_function("setFactionStanding", &factionHelpers::setFactionStanding); + + /*** + Get the faction ranking scores. + @function factionStruct:getFactionRanking + @tparam int turnNumber + @treturn factionRanking factionRanking + @usage + local rankings = fac:getFactionRanking(30) + */ + types.factionStruct.set_function("getFactionRanking", &factionHelpers::getFactionRanking); + + /*** + Get the faction ecomomy table, specified number of turns ago (max 10). + @function factionStruct:getFactionEconomy + @tparam int turnsAgo + @treturn factionEconomy factionEconomy + @usage + local economyTable = fac:getFactionEconomy(0) + */ + types.factionStruct.set_function("getFactionEconomy", &factionHelpers::getFactionEconomy); + + /*** + Check if 2 factions are neighbours. + @function factionStruct:isNeighbourFaction + @tparam factionStruct targetFaction + @treturn bool isNeighbour + @usage + local isNeighbour = fac:isNeighbourFaction(targetFac) + */ + types.factionStruct.set_function("isNeighbourFaction", &factionHelpers::isNeighbourFaction); + + /*** + Get a region ID of a neighbouring region by index. + @function factionStruct:getNeighbourRegionID + @tparam int index + @treturn int nRegionID + @usage + local nRegionID = fac:getNeighbourRegionID(0) + */ + types.factionStruct.set_function("getNeighbourRegionID", &factionHelpers::getNeighbourRegionID); + + /*** + Get stats versus a specific other faction. + @function factionStruct:getBattleVsFactionStats + @tparam int targetFactionID + @treturn battleFactionCounter battleStats + @usage + local battleStats = fac:getBattleVsFactionStats(2) + */ + types.factionStruct.set_function("getBattleVsFactionStats", &factionHelpers::getBattleVsFactionStats); + + ///battleFactionCounter + //@section battleFactionCounter + + /*** + Basic battleFactionCounter table + + @tfield int battlesWon + @tfield int battlesLost + + @table battleFactionCounter + */ + types.battleFactionCounter = luaState.new_usertype("battleFactionCounter"); + types.battleFactionCounter.set("battlesWon", &battleFactionCounter::battlesWon); + types.battleFactionCounter.set("battlesLost", &battleFactionCounter::battlesLost); + + ///holdRegionsWinCondition + //@section holdRegionsWinCondition + + /*** + Basic holdRegionsWinCondition table + + @tfield int regionsToHoldCount + @tfield int numberOfRegions + @tfield getRegionToHoldName getRegionToHoldName + @tfield getRegionToHoldLength getRegionToHoldLength + @table holdRegionsWinCondition + */ + types.holdRegionsWinCondition = luaState.new_usertype("holdRegionsWinCondition"); + types.holdRegionsWinCondition.set("regionsToHoldCount", &holdRegionsWinCondition::regionsToHoldCount); + types.holdRegionsWinCondition.set("numberOfRegions", &holdRegionsWinCondition::numberOfRegions); + /*** + Get the name of the region that has to be held to win the campaign. + @function holdRegionsWinCondition:getRegionToHoldName + @tparam int index + @treturn string regionName + @usage + local regionName = fac.winCondition:getRegionToHoldName(0) + */ + types.holdRegionsWinCondition.set_function("getRegionToHoldName", &factionHelpers::getRegionToHoldName); + + /*** + Get the number of turns the region has to be held to win the campaign. + @function holdRegionsWinCondition:getRegionToHoldLength + @tparam int index + @treturn int turnsToHold + @usage + local turnsToHold = fac.winCondition:getRegionToHoldLength(0) + */ + types.holdRegionsWinCondition.set_function("getRegionToHoldLength", &factionHelpers::getRegionToHoldLength); + + + ///FactionEconomy + //@section factionEconomy + + /*** + Basic factionEconomy table + + @tfield int farmingIncome + @tfield int taxesIncome + @tfield int miningIncome + @tfield int tradeIncome + @tfield int merchantIncome + @tfield int constructionIncome + @tfield int otherIncome1 + @tfield int otherIncome2 + @tfield int diplomacyIncome + @tfield int tributesIncome + @tfield int adminIncome + @tfield int kingsPurseIncome + @tfield int wagesExpense + @tfield int upkeepExpense + @tfield int constructionExpenseBuildings + @tfield int constructionExpenseField + @tfield int recruitmentExpenseBuildings + @tfield int recruitmentExpenseMercs + @tfield int corruptionExpense + @tfield int diplomacyExpense + @tfield int tributesExpense + @tfield int otherExpense1 + @tfield int otherExpense2 + @tfield int devastationExpense + + @table factionEconomy + */ + types.factionEconomy = luaState.new_usertype("factionEconomy"); + types.factionEconomy.set("farmingIncome", &factionEconomy::farmingIncome); + types.factionEconomy.set("taxesIncome", &factionEconomy::taxesIncome); + types.factionEconomy.set("miningIncome", &factionEconomy::miningIncome); + types.factionEconomy.set("tradeIncome", &factionEconomy::tradeIncome); + types.factionEconomy.set("merchantIncome", &factionEconomy::merchantIncome); + types.factionEconomy.set("constructionIncome", &factionEconomy::constructionIncome); + types.factionEconomy.set("otherIncome1", &factionEconomy::otherIncome1); + types.factionEconomy.set("otherIncome2", &factionEconomy::otherIncome2); + types.factionEconomy.set("diplomacyIncome", &factionEconomy::diplomacyIncome); + types.factionEconomy.set("tributesIncome", &factionEconomy::tributesIncome); + types.factionEconomy.set("adminIncome", &factionEconomy::adminIncome); + types.factionEconomy.set("kingsPurseIncome", &factionEconomy::kingsPurseIncome); + types.factionEconomy.set("wagesExpense", &factionEconomy::wagesExpense); + types.factionEconomy.set("upkeepExpense", &factionEconomy::upkeepExpense); + types.factionEconomy.set("constructionExpenseBuildings", &factionEconomy::constructionExpenseBuildings); + types.factionEconomy.set("constructionExpenseField", &factionEconomy::constructionExpenseField); + types.factionEconomy.set("recruitmentExpenseBuildings", &factionEconomy::recruitmentExpenseBuildings); + types.factionEconomy.set("recruitmentExpenseMercs", &factionEconomy::recruitmentExpenseMercs); + types.factionEconomy.set("corruptionExpense", &factionEconomy::corruptionExpense); + types.factionEconomy.set("diplomacyExpense", &factionEconomy::diplomacyExpense); + types.factionEconomy.set("tributesExpense", &factionEconomy::tributesExpense); + types.factionEconomy.set("otherExpense1", &factionEconomy::otherExpense1); + types.factionEconomy.set("otherExpense2", &factionEconomy::otherExpense2); + types.factionEconomy.set("devastationExpense", &factionEconomy::devastationExpense); + + ///FactionRankings + //@section factionRanking + + /*** + Basic factionRanking table + + @tfield float totalRankingScore + @tfield float militaryRankingScore + @tfield float productionRankingScore + @tfield float territoryRankingScore + @tfield float FinancialRankingScore + @tfield float populationRankingScore + + @table factionRanking + */ + types.factionRanking = luaState.new_usertype("factionRanking"); + types.factionRanking.set("totalRankingScore", &factionRanking::totalRanking); + types.factionRanking.set("militaryRankingScore", &factionRanking::militaryRanking); + types.factionRanking.set("productionRankingScore", &factionRanking::productionRanking); + types.factionRanking.set("territoryRankingScore", &factionRanking::territoryRanking); + types.factionRanking.set("FinancialRankingScore", &factionRanking::FinancialRanking); + types.factionRanking.set("populationRankingScore", &factionRanking::populationRanking); ///FactionStratMapStruct //@section factionStratMapStructTable @@ -1991,9 +2274,21 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int secondaryColorGreen Warning: resets on reload. @tfield int secondaryColorBlue Warning: resets on reload. @tfield int triumphValue Usage unknown. + @tfield int religionID. @tfield int standardIndex Warning: resets on reload. @tfield int logoIndex Warning: resets on reload. @tfield int smallLogoIndex Warning: resets on reload. + @tfield int hordeMaxUnits + @tfield int customBattleAvailability + @tfield int periodsUnavailableInCustomBattle + @tfield int canSap shouldnt do anything in med 2, but could potentially use flag to store some other info about this faction + @tfield int prefersNavalInvasions + @tfield int canHavePrincess + @tfield int hasFamilyTree + @tfield int teutonic + @tfield int disbandToPools + @tfield int canBuildSiegeTowers + @tfield int canTransmitPlague @table factionStratMapStruct */ @@ -2008,6 +2303,18 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.factionStratMapStruct.set("standardIndex", &factionStratMapDescrS::standard_index); types.factionStratMapStruct.set("logoIndex", &factionStratMapDescrS::logo_index); types.factionStratMapStruct.set("smallLogoIndex", &factionStratMapDescrS::small_logo_index); + types.factionStratMapStruct.set("religionID", &factionStratMapDescrS::religionID); + types.factionStratMapStruct.set("hordeMaxUnits", &factionStratMapDescrS::hordeMaxUnits); + types.factionStratMapStruct.set("customBattleAvailability", &factionStratMapDescrS::customBattleAvailability); + types.factionStratMapStruct.set("periodsUnavailableInCustomBattle", &factionStratMapDescrS::periodsUnavailableInCustomBattle); + types.factionStratMapStruct.set("canSap", &factionStratMapDescrS::canSap); + types.factionStratMapStruct.set("prefersNavalInvasions", &factionStratMapDescrS::prefersNavalInvasions); + types.factionStratMapStruct.set("canHavePrincess", &factionStratMapDescrS::canHavePrincess); + types.factionStratMapStruct.set("hasFamilyTree", &factionStratMapDescrS::hasFamilyTree); + types.factionStratMapStruct.set("teutonic", &factionStratMapDescrS::teutonic); + types.factionStratMapStruct.set("disbandToPools", &factionStratMapDescrS::disbandToPools); + types.factionStratMapStruct.set("canBuildSiegeTowers", &factionStratMapDescrS::canBuildSiegeTowers); + types.factionStratMapStruct.set("canTransmitPlague", &factionStratMapDescrS::canTransmitPlague); ///WatchtowerStruct @@ -2111,6 +2418,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int regionID @tfield int level @tfield int isCastle + @tfield int settlementTaxLevel @tfield int isProvokedRebellion @tfield int populationSize @tfield int PopGrowthBaseFarm - Get only @@ -2175,6 +2483,11 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getResource getResource @tfield int siegesNum @tfield getSiege getSiege + @tfield getSettlementCapability getSettlementCapability + @tfield getAgentCapability getAgentCapability + @tfield getAgentLimitCapability getAgentLimitCapability + @tfield getRecruitmentCapability getRecruitmentCapability + @tfield getSettlementRecruitmentPool getSettlementRecruitmentPool @table settlementStruct */ @@ -2205,8 +2518,19 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.settlementStruct.set("regionID", &settlementStruct::regionID); types.settlementStruct.set("level", &settlementStruct::level); types.settlementStruct.set("isCastle", &settlementStruct::isCastle); + types.settlementStruct.set("settlementTaxLevel", &settlementStruct::settlementTaxLevel); types.settlementStruct.set("isProvokedRebellion", &settlementStruct::isProvokedRebellion); types.settlementStruct.set("populationSize", &settlementStruct::populationSize); + types.settlementStruct.set("recruitPoolCapabilityCount", &settlementStruct::recruitPoolCapabilityCount); + types.settlementStruct.set("recruitmentPoolCount", &settlementStruct::recruitmentPoolCount); + types.settlementStruct.set("freezeRecruitmentPool", &settlementStruct::freezeRecruitmentPool); + types.settlementStruct.set("spiesInRecruitmentQueue", &settlementStruct::spiesInRecruitmentQueue); + types.settlementStruct.set("assassinsInRecruitmentQueue", &settlementStruct::assassinsInRecruitmentQueue); + types.settlementStruct.set("diplomatsInRecruitmentQueue", &settlementStruct::diplomatsInRecruitmentQueue); + types.settlementStruct.set("admiralsInRecruitmentQueue", &settlementStruct::admiralsInRecruitmentQueue); + types.settlementStruct.set("merchantsInRecruitmentQueue", &settlementStruct::merchantsInRecruitmentQueue); + types.settlementStruct.set("priestsInRecruitmentQueue", &settlementStruct::priestsInRecruitmentQueue); + types.settlementStruct.set("turmoil", &settlementStruct::turmoil); types.settlementStruct.set("PopGrowthBaseFarm", &settlementStruct::PopGrowthBaseFarm); types.settlementStruct.set("PopGrowthFarms", &settlementStruct::PopGrowthFarms); types.settlementStruct.set("PopGrowthHealth", &settlementStruct::PopGrowthHealth); @@ -2346,8 +2670,102 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) end */ types.settlementStruct.set_function("getSiege", &settlementHelpers::getSiege); + /*** + Get a capability by capability type. + @function settlementStruct:getSettlementCapability + @tparam int capabilityType + @treturn settlementCapability capability + @usage + local incomeBonus = settlementStruct:getSettlementCapability(55) + */ + types.settlementStruct.set_function("getSettlementCapability", &settlementHelpers::getSettlementCapability); + /*** + Get an agent capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest. + @function settlementStruct:getAgentCapability + @tparam int agentType + @treturn settlementCapability capability + @usage + local spyCap = settlementStruct:getAgentCapability(0) + */ + types.settlementStruct.set_function("getAgentCapability", &settlementHelpers::getAgentCapability); + /*** + Get an agent limit capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest. + @function settlementStruct:getAgentLimitCapability + @tparam int agentType + @treturn settlementCapability capability + @usage + local spyCapLimit = settlementStruct:getAgentLimitCapability(0) + */ + types.settlementStruct.set_function("getAgentLimitCapability", &settlementHelpers::getAgentCapability); + /*** + Get a recruitment capability by index (max 64!). + @function settlementStruct:getRecruitmentCapability + @tparam int index + @treturn recruitmentCapability capability + @usage + local capability = settlementStruct:getRecruitmentCapability(0) + */ + types.settlementStruct.set_function("getRecruitmentCapability", &settlementHelpers::getRecruitmentCapability); + /*** + Get a recruitment pool by index. + @function settlementStruct:getSettlementRecruitmentPool + @tparam int index + @treturn settlementRecruitmentPool pool + @usage + local pool = settlementStruct:getSettlementRecruitmentPool(0) + */ + types.settlementStruct.set_function("getSettlementRecruitmentPool", &settlementHelpers::getSettlementRecruitmentPool); + + ///settlementCapability + //@section settlementCapability + + /*** + Basic settlementCapability table + + @tfield int value + @tfield int bonus + @table settlementCapability + */ + types.settlementCapability = luaState.new_usertype("settlementCapability"); + types.settlementCapability.set("value", &settlementCapability::value); + types.settlementCapability.set("bonus", &settlementCapability::bonus); + + ///recruitmentCapability + //@section recruitmentCapability + + /*** + Basic recruitmentCapability table + + @tfield int eduIndex + @tfield int xp + @tfield float initialSize + @tfield float replenishRate + @tfield float maxSize + + @table recruitmentCapability + */ + types.recruitmentCapability = luaState.new_usertype("recruitmentCapability"); + types.recruitmentCapability.set("eduIndex", &recruitmentCapability::eduIndex); + types.recruitmentCapability.set("xp", &recruitmentCapability::xp); + types.recruitmentCapability.set("initialSize", &recruitmentCapability::initialSize); + types.recruitmentCapability.set("replenishRate", &recruitmentCapability::replenishRate); + types.recruitmentCapability.set("maxSize", &recruitmentCapability::maxSize); + + ///settlementRecruitmentPool + //@section settlementRecruitmentPool + + /*** + Basic settlementRecruitmentPool table + + @tfield int eduIndex + @tfield float availablePool + @table settlementRecruitmentPool + */ + types.settlementRecruitmentPool = luaState.new_usertype("settlementRecruitmentPool"); + types.settlementRecruitmentPool.set("eduIndex", &settlementRecruitmentPool::eduIndex); + types.settlementRecruitmentPool.set("availablePool", &settlementRecruitmentPool::availablePool); ///Building @@ -2618,6 +3036,10 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield factionStruct faction @tfield getUnit getUnit @tfield int numOfUnits + @tfield int isBoarded + @tfield int ladders + @tfield int rams + @tfield int towers @tfield getCharacter getCharacter @tfield int numOfCharacters Includes Auxiliary generals and agents (i.e all characters excluding the leading general) @tfield stackStruct boardedArmy army embarked on this fleet stack @@ -2642,6 +3064,10 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) */ types.stackStruct = luaState.new_usertype("stackStruct"); types.stackStruct.set("faction", &stackStruct::faction); + types.stackStruct.set("isBoarded", &stackStruct::isBoarded); + types.stackStruct.set("ladders", &stackStruct::ladders); + types.stackStruct.set("rams", &stackStruct::rams); + types.stackStruct.set("towers", &stackStruct::towers); /*** Sort units in a stack. diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp index 7d1a94de..7a4105d9 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -24,6 +24,14 @@ void luaP::initCampaign() sol::usertype collegeOfCardinals; sol::usertype crusadeStruct; sol::usertype jihadStruct; + sol::usertype options1; + sol::usertype options2; + sol::usertype uiCardManager; + sol::usertype coordPair; + sol::usertype landMass; + sol::usertype roadStruct; + sol::usertype seaConnectedRegion; + sol::usertype neighbourRegion; }typeAll; using namespace campaignEnums; @@ -56,6 +64,281 @@ void luaP::initCampaign() "trade", dipRelEnum::trade ); + ///options1 + //@section options1 + + /*** + Basic options1 table + + @tfield bool widescreen + @tfield int antiAliasMode + @tfield int subtitles + @tfield bool english + @tfield bool noBattleTimeLimit + @tfield int useNewCursorActions + @tfield int campaignNumTimesPlay + @tfield bool uiWinConditions + @tfield bool isScenario + @tfield int isHotseatEnabled + @tfield bool hotseatAutosave + @tfield bool email + @tfield bool saveConfig + @tfield bool closeAfterSave + @tfield bool validateData + @tfield bool campaignMapSpeedUp + @tfield int skipAiFactions + @tfield bool labelCharacters + @tfield bool noBackGroundFmv + @tfield bool disableArrowMarkers + @tfield bool arcadeBattles + @tfield bool disableEvents + @tfield bool isPrologue + @tfield bool updateAiCamera + @tfield bool hideCampaign + @tfield int unlimitedMenOnBattlefield + @tfield int tgaReserveSpace + @tfield int keysetUsed + @tfield bool muteAdvisor + @tfield bool advancedStatsAlways + @tfield bool microManageAllSettlements + @tfield bool blindAdvisor + @tfield int terrainQuality + @tfield int vegetationQuality + @tfield bool useQuickChat + @tfield int graphicsAdaptor + @tfield bool showDemeanour + @tfield int radar + @tfield int unitCards + @tfield int sa_cards + @tfield int buttons + @tfield bool tutorialBattlePlayed + @tfield bool disableVnVs + @tfield bool allUsers + + @table options1 + */ + typeAll.options1 = luaState.new_usertype("options1"); + typeAll.options1.set("widescreen", &options1::widescreen); + typeAll.options1.set("antiAliasMode", &options1::antiAliasMode); + typeAll.options1.set("subtitles", &options1::subtitles); + typeAll.options1.set("english", &options1::english); + typeAll.options1.set("noBattleTimeLimit", &options1::noBattleTimeLimit); + typeAll.options1.set("useNewCursorActions", &options1::useNewCursorActions); + typeAll.options1.set("campaignNumTimesPlay", &options1::campaignNumTimesPlay); + typeAll.options1.set("uiWinConditions", &options1::uiWinConditions); + typeAll.options1.set("isScenario", &options1::isScenario); + typeAll.options1.set("isHotseatEnabled", &options1::isHotseatEnabled); + typeAll.options1.set("hotseatAutosave", &options1::hotseatAutosave); + typeAll.options1.set("email", &options1::email); + typeAll.options1.set("saveConfig", &options1::saveConfig); + typeAll.options1.set("closeAfterSave", &options1::closeAfterSave); + typeAll.options1.set("validateData", &options1::validateData); + typeAll.options1.set("campaignMapSpeedUp", &options1::campaignMapSpeedUp); + typeAll.options1.set("skipAiFactions", &options1::skipAiFactions); + typeAll.options1.set("noBackGroundFmv", &options1::noBackGroundFmv); + typeAll.options1.set("disableArrowMarkers", &options1::disableArrowMarkers); + typeAll.options1.set("arcadeBattles", &options1::arcadeBattles); + typeAll.options1.set("disableEvents", &options1::disableEvents); + typeAll.options1.set("isPrologue", &options1::isPrologue); + typeAll.options1.set("updateAiCamera", &options1::updateAiCamera); + typeAll.options1.set("unlimitedMenOnBattlefield", &options1::unlimitedMenOnBattlefield); + typeAll.options1.set("tgaReserveSpace", &options1::tgaReserveSpace); + typeAll.options1.set("keysetUsed", &options1::keysetUsed); + typeAll.options1.set("muteAdvisor", &options1::muteAdvisor); + typeAll.options1.set("advancedStatsAlways", &options1::advancedStatsAlways); + typeAll.options1.set("microManageAllSettlements", &options1::microManageAllSettlements); + typeAll.options1.set("blindAdvisor", &options1::blindAdvisor); + typeAll.options1.set("terrainQuality", &options1::terrainQuality); + typeAll.options1.set("vegetationQuality", &options1::vegetationQuality); + typeAll.options1.set("useQuickChat", &options1::useQuickChat); + typeAll.options1.set("graphicsAdaptor", &options1::graphicsAdaptor); + typeAll.options1.set("showDemeanour", &options1::showDemeanour); + typeAll.options1.set("radar", &options1::radar); + typeAll.options1.set("unitCards", &options1::unitCards); + typeAll.options1.set("sa_cards", &options1::sa_cards); + typeAll.options1.set("buttons", &options1::buttons); + typeAll.options1.set("tutorialBattlePlayed", &options1::tutorialBattlePlayed); + typeAll.options1.set("disableVnVs", &options1::disableVnVs); + typeAll.options1.set("allUsers", &options1::allUsers); + + + ///options2 + //@section options2 + + /*** + Basic options2 table + + @tfield int campaignResolutionX + @tfield int campaignResolutionY + @tfield int battleResolutionX + @tfield int battleResolutionY + @tfield bool vSync + @tfield bool uiIconBarCheck + @tfield bool uiRadarCheck + @tfield bool useMorale + @tfield bool uiAmmoCheck + @tfield bool useFatigue + @tfield bool uiSupplyCheck + @tfield bool toggleFowState this does not toggle fow just remembers if it was on or off + @tfield bool cameraRestrict + @tfield bool eventCutscenes + @tfield int defaultCameraInBattle + @tfield bool splashes + @tfield bool stencilShadows + @tfield bool audioEnable + @tfield bool speechEnable + @tfield bool firstTimePlay + @tfield bool toggleAutoSave + @tfield bool showBanners + @tfield bool passwords + @tfield bool hotseatTurns + @tfield bool hotseatScroll + @tfield int allowValidationFeatures + @tfield int campaignSpeed + @tfield bool labelSettlements + @tfield bool disablePapalElections + @tfield bool autoresolveAllBattles + @tfield bool savePrefs + @tfield bool disableConsole + @tfield bool validateDiplomacy + @tfield int unitDetail + @tfield int buildingDetail + @tfield int maxSoldiersOnBattlefield if limited + @tfield int unitSize + @tfield int cameraRotateSpeed + @tfield int cameraMoveSpeed + @tfield float cameraSmoothing + @tfield int masterVolume + @tfield int musicVolume + @tfield int speechVolume + @tfield int sfxVolume + @tfield int subFactionAccents + @tfield int tgaWidth + @tfield float tgaAspect + @tfield int tgaInputScale + @tfield int scrollMinZoom + @tfield int scrollMaxZoom + @tfield int advisorVerbosity + @tfield int effectQuality + @tfield int EnableCameraCampaignSmoothing + @tfield int chatMsgDuration + @tfield bool saveGameSpyPassword + @tfield bool addDateToLogs + @tfield bool showToolTips + @tfield bool isNormalHud + @tfield bool showPackageLitter + @tfield float unitSizeMultiplierLow + @tfield float unitSizeMultiplierMedium + @tfield float unitSizeMultiplierLarge + + @table options2 + */ + typeAll.options2 = luaState.new_usertype("options2"); + typeAll.options2.set("campaignResolutionX", &options2::campaignResolutionX); + typeAll.options2.set("campaignResolutionY", &options2::campaignResolutionY); + typeAll.options2.set("battleResolutionX", &options2::battleResolutionX); + typeAll.options2.set("battleResolutionY", &options2::battleResolutionY); + typeAll.options2.set("vSync", &options2::vSync); + typeAll.options2.set("uiIconBarCheck", &options2::uiIconBarCheck); + typeAll.options2.set("uiRadarCheck", &options2::uiRadarCheck); + typeAll.options2.set("useMorale", &options2::useMorale); + typeAll.options2.set("uiAmmoCheck", &options2::uiAmmoCheck); + typeAll.options2.set("useFatigue", &options2::useFatigue); + typeAll.options2.set("uiSupplyCheck", &options2::uiSupplyCheck); + typeAll.options2.set("toggleFowState", &options2::toggleFowState); + typeAll.options2.set("cameraRestrict", &options2::cameraRestrict); + typeAll.options2.set("eventCutscenes", &options2::eventCutscenes); + typeAll.options2.set("defaultCameraInBattle", &options2::defaultCameraInBattle); + typeAll.options2.set("splashes", &options2::splashes); + typeAll.options2.set("stencilShadows", &options2::stencilShadows); + typeAll.options2.set("audioEnable", &options2::audioEnable); + typeAll.options2.set("speechEnable", &options2::speechEnable); + typeAll.options2.set("firstTimePlay", &options2::firstTimePlay); + typeAll.options2.set("toggleAutoSave", &options2::toggleAutoSave); + typeAll.options2.set("showBanners", &options2::showBanners); + typeAll.options2.set("passwords", &options2::passwords); + typeAll.options2.set("hotseatTurns", &options2::hotseatTurns); + typeAll.options2.set("hotseatScroll", &options2::hotseatScroll); + typeAll.options2.set("allowValidationFeatures", &options2::allowValidationFeatures); + typeAll.options2.set("campaignSpeed", &options2::campaignSpeed); + typeAll.options2.set("labelSettlements", &options2::labelSettlements); + typeAll.options2.set("disablePapalElections", &options2::disablePapalElections); + typeAll.options2.set("autoresolveAllBattles", &options2::autoresolveAllBattles); + typeAll.options2.set("savePrefs", &options2::savePrefs); + typeAll.options2.set("disableConsole", &options2::disableConsole); + typeAll.options2.set("validateDiplomacy", &options2::validateDiplomacy); + typeAll.options2.set("unitDetail", &options2::unitDetail); + typeAll.options2.set("buildingDetail", &options2::buildingDetail); + typeAll.options2.set("maxSoldiersOnBattlefield", &options2::maxSoldiersOnBattlefield); + typeAll.options2.set("unitSize", &options2::unitSize); + typeAll.options2.set("cameraRotateSpeed", &options2::cameraRotateSpeed); + typeAll.options2.set("cameraMoveSpeed", &options2::cameraMoveSpeed); + typeAll.options2.set("cameraSmoothing", &options2::cameraSmoothing); + typeAll.options2.set("masterVolume", &options2::masterVolume); + typeAll.options2.set("musicVolume", &options2::musicVolume); + typeAll.options2.set("speechVolume", &options2::speechVolume); + typeAll.options2.set("sfxVolume", &options2::sfxVolume); + typeAll.options2.set("subFactionAccents", &options2::subFactionAccents); + typeAll.options2.set("tgaWidth", &options2::tgaWidth); + typeAll.options2.set("tgaAspect", &options2::tgaAspect); + typeAll.options2.set("tgaInputScale", &options2::tgaInputScale); + typeAll.options2.set("scrollMinZoom", &options2::scrollMinZoom); + typeAll.options2.set("scrollMaxZoom", &options2::scrollMaxZoom); + typeAll.options2.set("advisorVerbosity", &options2::advisorVerbosity); + typeAll.options2.set("effectQuality", &options2::effectQuality); + typeAll.options2.set("EnableCameraCampaignSmoothing", &options2::EnableCameraCampaignSmoothing); + typeAll.options2.set("chatMsgDuration", &options2::chatMsgDuration); + typeAll.options2.set("saveGameSpyPassword", &options2::saveGameSpyPassword); + typeAll.options2.set("addDateToLogs", &options2::addDateToLogs); + typeAll.options2.set("isNormalHud", &options2::isNormalHud); + typeAll.options2.set("showPackageLitter", &options2::showPackageLitter); + typeAll.options2.set("unitSizeMultiplierLow", &options2::unitSizeMultiplierLow); + typeAll.options2.set("unitSizeMultiplierMedium", &options2::unitSizeMultiplierMedium); + typeAll.options2.set("unitSizeMultiplierLarge", &options2::unitSizeMultiplierLarge); + + ///uiCardManager + //@section uiCardManager + + /*** + Basic uiCardManager table + + @tfield int selectedUnitCardsCount + @tfield int unitCardsCount + @tfield settlementStruct selectedSettlement + @tfield character selectedCharacter + @tfield fortStruct selectedFort + @tfield getSelectedUnitCard getSelectedUnitCard + @tfield getUnitCard getUnitCard + + @table uiCardManager + */ + typeAll.uiCardManager = luaState.new_usertype("uiCardManager"); + typeAll.uiCardManager.set("selectedUnitCardsCount", &uiCardManager::selectedUnitCardsCount); + typeAll.uiCardManager.set("unitCardsCount", &uiCardManager::unitCardsCount); + typeAll.uiCardManager.set("selectedSettlement", &uiCardManager::selectedSettlement); + typeAll.uiCardManager.set("selectedCharacter", &uiCardManager::selectedCharacter); + typeAll.uiCardManager.set("selectedFort", &uiCardManager::selectedFort); + /*** + Get selected unit card by index. + @function uiCardManager:getSelectedUnitCard + @tparam int index + @treturn unit selectedUnit + @usage + local cardManager=gameDataAll.get().uiCardManager; + local selectedUnit=cardManager:getSelectedUnitCard(0); + */ + typeAll.uiCardManager.set_function("getSelectedUnitCard", &gameHelpers::getSelectedUnitCard); + /*** + Get unit card by index (battle or strat). + @function uiCardManager:getUnitCard + @tparam int index + @treturn unit unit + @usage + local cardManager=gameDataAll.get().uiCardManager; + local unit=cardManager:getUnitCard(0); + */ + typeAll.uiCardManager.set_function("getUnitCard", &gameHelpers::getUnitCard); + /// Campaign //@section campaignStruct @@ -72,6 +355,8 @@ void luaP::initCampaign() @tfield factionStruct currentFaction Faction whose turn it is at the moment, can be set. @tfield collegeOfCardinals collegeOfCardinals @tfield factionStruct papalFaction + @tfield int fogOfWar + @tfield int factionTurnID @tfield int tickCount @tfield int millisecondCount @tfield float secondCount @@ -118,9 +403,11 @@ void luaP::initCampaign() typeAll.campaignTable.set("numberHumanFactions", &campaign::humanPlayers); typeAll.campaignTable.set("collegeOfCardinals", &campaign::collegeOfCardinals); typeAll.campaignTable.set("currentFaction", &campaign::currentFactionTurn); + typeAll.campaignTable.set("factionTurnID", &campaign::factionTurnID); typeAll.campaignTable.set("tickCount", &campaign::tickCount); typeAll.campaignTable.set("millisecondCount", &campaign::millisecondCount); typeAll.campaignTable.set("secondCount", &campaign::secondCount); + typeAll.campaignTable.set("fogOfWar", &campaign::fogOfWar); typeAll.campaignTable.set("passedTurnsNum", &campaign::TurnNumber); typeAll.campaignTable.set("crusade", &campaign::crusade); typeAll.campaignTable.set("jihad", &campaign::jihad); @@ -226,8 +513,9 @@ void luaP::initCampaign() */ typeAll.campaignTable.set_function("getSettlementByName", &gameHelpers::getSettlementByName); - /// College of Cardinals + ///CollegeofCardinals //@section collegeOfCardinals + /*** Basic College of Cardinals table. @tfield namedCharacter pope @@ -293,6 +581,21 @@ void luaP::initCampaign() typeAll.jihadStruct.set("length", &jihad::length); typeAll.jihadStruct.set("outcome", &jihad::outcome); + /// coords + //@section coordPair + + /*** + Basic coordPair table. + + @tfield int xCoord + @tfield int yCoord + + @table coordPair + */ + typeAll.coordPair = luaState.new_usertype("coordPair"); + typeAll.coordPair.set("xCoord", &coordPair::xCoord); + typeAll.coordPair.set("yCoord", &coordPair::yCoord); + /// Strat Map //@section stratMap @@ -302,8 +605,14 @@ void luaP::initCampaign() @tfield int mapWidth @tfield int mapHeight @tfield int regionsNum + @tfield int volcanoesNum + @tfield int landConnectionsNum + @tfield int landMassNum @tfield getRegion getRegion @tfield getTile getTile + @tfield getVolcanoCoords getVolcanoCoords + @tfield getLandConnection getLandConnection + @tfield getLandMass getLandMass @table gameDataAll.stratMap */ @@ -311,6 +620,9 @@ void luaP::initCampaign() typeAll.stratMap.set("mapWidth", &stratMap::mapWidth); typeAll.stratMap.set("mapHeight", &stratMap::mapHeight); typeAll.stratMap.set("regionsNum", &stratMap::regionsNum); + typeAll.stratMap.set("volcanoesNum", &stratMap::volcanoesNum); + typeAll.stratMap.set("landConnectionsNum", &stratMap::landMassConnectionsNum); + typeAll.stratMap.set("landMassNum", &stratMap::landMassNum); /*** Get a specific region by index. @@ -334,12 +646,101 @@ void luaP::initCampaign() local tile = sMap.getTile(182, 243); */ typeAll.stratMap.set_function("getTile", &gameHelpers::getTile); + + /*** + Get a volcano's coordinates. + @function stratMap:getVolcanoCoords + @tparam int index + @treturn coordPair tile + @usage + local sMap = gameDataAll.get().stratMap; + local volcano = sMap:getVolcanoCoords(0); + */ + typeAll.stratMap.set_function("getVolcanoCoords", &gameHelpers::getVolcanoCoords); + + /*** + Get a land connection's coordinates (the green arrows on the map that allow you to cross bodies of water). + @function stratMap:getLandConnection + @tparam int index + @treturn coordPair tile + @usage + local sMap = gameDataAll.get().stratMap; + local connection = sMap:getLandConnection(0); + */ + typeAll.stratMap.set_function("getLandConnection", &gameHelpers::getLandConnection); + + /*** + Get a landmass (collection of regions reachable by land, like a continent or island). + @function stratMap:getLandMass + @tparam int index + @treturn landMass landMass + @usage + local sMap = gameDataAll.get().stratMap; + local tile = sMap:getLandMass(0); + */ + typeAll.stratMap.set_function("getLandMass", &gameHelpers::getLandMass); + + /// landMass + //@section landMass + + /*** + Basic landMass table. + + @tfield int index + @tfield int regionsNum + @tfield getRegionID getRegionID + + @table landMass + */ + typeAll.landMass = luaState.new_usertype("landMass"); + typeAll.landMass.set("index", &landMass::index); + typeAll.landMass.set("regionsNum", &landMass::regionsNum); + + /*** + Get a region ID by index. + @function landMass:getRegionID + @tparam int index + @treturn int regionID + @usage + local region = landMass:getRegionID(0); + */ + typeAll.landMass.set_function("getRegionID", &gameHelpers::getRegionID); + + /// roadStruct + //@section roadStruct + + /*** + Basic roadStruct table. + + @tfield int coordsNum + @tfield int regionIdStart + @tfield int regionIdEnd + @tfield getCoord getCoord + + @table roadStruct + */ + typeAll.roadStruct = luaState.new_usertype("roadStruct"); + typeAll.roadStruct.set("coordsNum", &roadStruct::coordsNum); + typeAll.roadStruct.set("regionIdStart", &roadStruct::regionIdStart); + typeAll.roadStruct.set("regionIdEnd", &roadStruct::regionIdEnd); + + /*** + Get a road coord by index. + @function roadStruct:getCoord + @tparam int index + @treturn coordPair coords + @usage + local coords = road:getCoord(0); + */ + typeAll.roadStruct.set_function("getCoord", &gameHelpers::getRoadCoord); + ///Tile //@section tileStruct /*** Basic tile table, not everything very known and understood yet, you can research with these fields. + @tfield roadStruct road @tfield int isLand (1 = land, 0 = sea) @tfield int groundType 0 low fertility @@ -359,21 +760,68 @@ void luaP::initCampaign() 14 impassable_land 15 impassable_sea @tfield int regionID - @tfield int factionID (Doesn't work if tile is river). - @tfield int borderingSettlement Not 0 means bordering settlement. - @tfield int hasRoad Not 0 means it has a road. - @tfield int border Not 0 means it is on border of region. - + @tfield int factionID + @tfield coordPair coords + @tfield int objectTypes bitfield, from left to right: unknown, character, ship, watchtower, port, unknown, fort, settlement. + @tfield bool hasRiver + @tfield bool hasCrossing + @tfield bool tileHasCharacter + @tfield bool tileHasShip + @tfield bool tileHasWatchtower + @tfield bool tileHasPort + @tfield bool tileHasFort + @tfield bool tileHasSettlement + @tfield int borderingSettlement 1 = bordering 2 = settlement. + @tfield int border 1 = border, 2 = seaBorder, 3 = sea edge border (point where the region border both another land region and sea). + @tfield int armiesNearTile bitfield of faction id's (counts both tile and the 8 tiles around it, if you want only on tile combine with charactersOnTile). + @tfield int charactersOnTile bitfield of faction id's + @tfield float mpModifier + @tfield factionHasArmyNearTile factionHasArmyNearTile + @tfield factionHasCharacterOnTile factionHasCharacterOnTile + @table tileStruct */ typeAll.tileStruct = luaState.new_usertype("tileStruct"); + typeAll.tileStruct.set("road", &oneTile::road); typeAll.tileStruct.set("isLand", &oneTile::isLand); typeAll.tileStruct.set("groundType", &oneTile::groundType); typeAll.tileStruct.set("regionID", &oneTile::regionId); - typeAll.tileStruct.set("factionID", &oneTile::factionId); + typeAll.tileStruct.set("objectTypes", &oneTile::objectTypes); + typeAll.tileStruct.set("coords", sol::property(gameHelpers::getTileCoords)); + typeAll.tileStruct.set("factionID", sol::property(gameHelpers::getTileFactionID)); typeAll.tileStruct.set("borderingSettlement", &oneTile::borderingSettlement); - typeAll.tileStruct.set("hasRoad", &oneTile::hasRoad); - typeAll.tileStruct.set("border", &oneTile::border); + typeAll.tileStruct.set("hasRiver", sol::property(gameHelpers::tileHasRiver)); + typeAll.tileStruct.set("hasCrossing", sol::property(gameHelpers::tileHasCrossing)); + typeAll.tileStruct.set("border", sol::property(gameHelpers::tileBorderType)); + typeAll.tileStruct.set("tileHasCharacter", sol::property(gameHelpers::tileHasCharacter)); + typeAll.tileStruct.set("tileHasShip", sol::property(gameHelpers::tileHasShip)); + typeAll.tileStruct.set("tileHasWatchtower", sol::property(gameHelpers::tileHasWatchtower)); + typeAll.tileStruct.set("tileHasPort", sol::property(gameHelpers::tileHasPort)); + typeAll.tileStruct.set("tileHasFort", sol::property(gameHelpers::tileHasFort)); + typeAll.tileStruct.set("tileHasSettlement", sol::property(gameHelpers::tileHasSettlement)); + typeAll.tileStruct.set("armiesNearTile", &oneTile::armiesNearTile); + typeAll.tileStruct.set("charactersOnTile", &oneTile::charactersOnTile); + typeAll.tileStruct.set("mpModifier", &oneTile::mpModifier); + + /*** + Check if a faction has an army near a tile. + @function tileStruct:factionHasArmyNearTile + @tparam int factionID + @treturn bool hasArmyNearTile + @usage + local hasArmyNearTile = tile:factionHasArmyNearTile(3); + */ + typeAll.roadStruct.set_function("factionHasArmyNearTile", &gameHelpers::factionHasArmyNearTile); + + /*** + Check if a faction has a character on a tile. + @function tileStruct:factionHasCharacterOnTile + @tparam int factionID + @treturn bool hasCharacterOnTile + @usage + local hasCharacterOnTile = tile:factionHasCharacterOnTile(3); + */ + typeAll.roadStruct.set_function("factionHasCharacterOnTile", &gameHelpers::factionHasCharacterOnTile); ///Region //@section Region @@ -391,11 +839,21 @@ void luaP::initCampaign() @tfield int watchtowersNum @tfield int isSea @tfield int hasLake (fully enclosed by region) - @tfield mercPool mercPool + @tfield landMass landMass + @tfield roadStruct roadToPort + @tfield int seaConnectedRegionsCount + @tfield int loyaltyFactionID + @tfield seaConnectedRegion seaExportRegion + @tfield int seaImportRegionsCount + @tfield int canSeaTrade + @tfield int regionSeaEdgesCount (point where the region border both another land region and sea). + @tfield int tilesBorderingEdgeOfMapCount @tfield settlementStruct settlement @tfield int tileCount + @tfield int fertileTilesCount @tfield int neighbourRegionsNum @tfield int resourcesNum + @tfield int resourceTypesBitMap @tfield int hiddenResources1 (bitmap with 32 first hidden resources), needs to be converted to binary and then use bitwise operators from lua. @tfield int hiddenResources2 (bitmap last 32 first hidden resources), needs to be converted to binary and then use bitwise operators from lua. @tfield int settlementXCoord @@ -413,6 +871,14 @@ void luaP::initCampaign() @tfield getNeighbour getNeighbour @tfield getHiddenResource getHiddenResource @tfield setHiddenResource setHiddenResource + @tfield getSeaConnectedRegion getSeaConnectedRegion + @tfield getSeaImportRegion getSeaImportRegion + @tfield getRegionSeaEdge getRegionSeaEdge + @tfield getReligionHistory getReligionHistory + @tfield getTileBorderingEdgeOfMap getTileBorderingEdgeOfMap + @tfield getTile getTile + @tfield getFertileTile getFertileTile + @tfield hasResourceType hasResourceType @table region */ @@ -424,6 +890,16 @@ void luaP::initCampaign() )); typeAll.region.set("legioName", ®ionStruct::legioName); typeAll.region.set("regionID", ®ionStruct::regionID); + typeAll.region.set("seaConnectedRegionsCount", ®ionStruct::seaConnectedRegionsCount); + typeAll.region.set("seaImportRegionsCount", ®ionStruct::seaImportRegionsCount); + typeAll.region.set("canSeaTrade", ®ionStruct::canSeaTrade); + typeAll.region.set("landMass", ®ionStruct::landMass); + typeAll.region.set("roadToPort", ®ionStruct::roadToPort); + typeAll.region.set("seaExportRegion", ®ionStruct::seaExportRegion); + typeAll.region.set("regionSeaEdgesCount", ®ionStruct::regionSeaEdgesCount); + typeAll.region.set("tilesBorderingEdgeOfMapCount", ®ionStruct::tilesBorderingEdgeOfMapCount); + typeAll.region.set("fertileTilesCount", ®ionStruct::fertileTilesCount); + typeAll.region.set("resourceTypesBitMap", ®ionStruct::resourceTypesBitMap); typeAll.region.set("stacksNum", ®ionStruct::stacksNum); typeAll.region.set("fortsNum", ®ionStruct::fortsNum); typeAll.region.set("watchtowersNum", ®ionStruct::watchtowersNum); @@ -499,11 +975,11 @@ void luaP::initCampaign() Get a neighbour region by it's index. @function region:getNeighbour @tparam int index - @treturn region nRegion + @treturn neighbourRegion nRegion @usage local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); - region:getNeighbour(0) + local nRegion = region:getNeighbour(0) */ typeAll.region.set_function("getNeighbour", &gameHelpers::getNeighbour); @@ -515,7 +991,7 @@ void luaP::initCampaign() @usage local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); - region:getHiddenResource(0) + localhr = region:getHiddenResource(0) */ typeAll.region.set_function("getHiddenResource", &gameHelpers::getHiddenResource); @@ -531,6 +1007,182 @@ void luaP::initCampaign() */ typeAll.region.set_function("setHiddenResource", &gameHelpers::setHiddenResource); + /*** + Get a region that is reachable from this region. + @function region:getSeaConnectedRegion + @tparam int index + @treturn seaConnectedRegion connectedRegion + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local connectedRegion = region:getSeaConnectedRegion(0) + */ + typeAll.region.set_function("getSeaConnectedRegion", &gameHelpers::getSeaConnectedRegion); + + /*** + Get a region this region is importing trade goods from. + @function region:getSeaImportRegion + @tparam int index + @treturn seaConnectedRegion seaImportRegion + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local seaImportRegion = region:getSeaImportRegion(0) + */ + typeAll.region.set_function("getSeaImportRegion", &gameHelpers::getSeaImportRegion); + + /*** + Get a region sea edge (point where it borders both sea and another land region). + @function region:getRegionSeaEdge + @tparam int index + @treturn tileStruct edge + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local edge = region:getRegionSeaEdge(0) + */ + typeAll.region.set_function("getRegionSeaEdge", &gameHelpers::getRegionSeaEdge); + + /*** + Get a tile that borders the edge of the map. + @function region:getTileBorderingEdgeOfMap + @tparam int index + @treturn tileStruct edge + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local edge = region:getTileBorderingEdgeOfMap(0) + */ + typeAll.region.set_function("getTileBorderingEdgeOfMap", &gameHelpers::getTileBorderingEdgeOfMap); + + /*** + Get a tile by index. + @function region:getTile + @tparam int index + @treturn tileStruct tile + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local tile = region:getTile(0) + */ + typeAll.region.set_function("getTile", &gameHelpers::getTileRegion); + + /*** + Get a fertile tile by index. + @function region:getFertileTile + @tparam int index + @treturn tileStruct tile + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local tile = region:getFertileTile(0) + */ + typeAll.region.set_function("getFertileTile", &gameHelpers::getFertileTile); + + /*** + Get religion amount from a set number of turns ago. + @function region:getReligionHistory + @tparam int religionID + @tparam int turnsAgo (max 19) + @treturn float religionAmount + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local catholicThreeTurnsAgo = region:getReligionHistory(0, 3) + */ + typeAll.region.set_function("getReligionHistory", &gameHelpers::getReligionHistory); + + /*** + Check if region has a resource type. + @function region:hasResourceType + @tparam int resourceID + @treturn bool hasResource + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local hasResource = region:hasResourceType(16) + */ + typeAll.region.set_function("hasResourceType", &gameHelpers::hasResourceType); + + ///neighbourRegion + //@section neighbourRegion + + /*** + Basic neighbourRegion table. + + @tfield int regionID + @tfield regionStruct region + @tfield int tradeValue + @tfield int borderTilesCount + @tfield roadStruct connectingRoad + @tfield getBorderTile getBorderTile + + + @table neighbourRegion + */ + typeAll.neighbourRegion = luaState.new_usertype("neighbourRegion"); + typeAll.neighbourRegion.set("regionID", &neighbourRegion::regionID); + typeAll.neighbourRegion.set("tradeValue", &neighbourRegion::tradeValue); + typeAll.neighbourRegion.set("region", &neighbourRegion::region); + typeAll.neighbourRegion.set("borderTilesCount", &neighbourRegion::borderTilesCount); + typeAll.neighbourRegion.set("connectingRoad", &neighbourRegion::connectingRoad); + + /*** + Get a border tile by index. + @function neighbourRegion:getBorderTile + @tparam int index + @treturn tileStruct tile + @usage + local tile = nRegion:getBorderTile(0) + */ + typeAll.neighbourRegion.set_function("getBorderTile", &gameHelpers::getBorderTile); + + + + ///seaConnectedRegion + //@section seaConnectedRegion + + /*** + Basic seaConnectedRegion table. + + @tfield int regionID + @tfield int seaExportValue + @tfield int seaImportValue + @tfield int tilesReachableCount + @tfield int seaTradeLanePathCount + @tfield getReachableTile getReachableTile + @tfield getTradeLaneCoord getTradeLaneCoord + + + @table seaConnectedRegion + */ + typeAll.seaConnectedRegion = luaState.new_usertype("seaConnectedRegion"); + typeAll.seaConnectedRegion.set("regionID", &seaConnectedRegion::regionID); + typeAll.seaConnectedRegion.set("seaExportValue", &seaConnectedRegion::seaExportValue); + typeAll.seaConnectedRegion.set("seaImportValue", &seaConnectedRegion::seaImportValue); + typeAll.seaConnectedRegion.set("tilesReachableCount", &seaConnectedRegion::tilesReachableCount); + typeAll.seaConnectedRegion.set("seaTradeLanePathCount", &seaConnectedRegion::seaTradeLanePathCount); + + /*** + Get a reachable tile by index. + @function seaConnectedRegion:getReachableTile + @tparam int index + @treturn tileStruct tile + @usage + local tile = seaRegion:getReachableTile(0) + */ + typeAll.seaConnectedRegion.set_function("getReachableTile", &gameHelpers::getReachableTile); + + /*** + Get trade lane coords by index. + @function seaConnectedRegion:getTradeLaneCoord + @tparam int index + @treturn coordPair coords + @usage + local coords = seaRegion:getTradeLaneCoord(0) + */ + typeAll.seaConnectedRegion.set_function("getTradeLaneCoord", &gameHelpers::getTradeLaneCoord); + ///MercPools //@section mercPool @@ -669,6 +1321,7 @@ void luaP::initP2() sol::usertype battleAI; sol::usertype battleArmy; sol::usertype battleUnit; + sol::usertype battleResidence; }typeAll; ///GameDataAll @@ -734,9 +1387,15 @@ void luaP::initP2() @tfield int paused @tfield float battleSpeed @tfield float secondsPassed + @tfield int secondsSinceBattleLoaded + @tfield int hidingEnabledSet + @tfield float mapWidthDoubled + @tfield float mapHeightDoubled @tfield int sidesNum Returns a battleSide[8]. Maximum: 8. @tfield battleSide[8] sides - @tfield factionSide[31] faction alliance array, -1 if not in battle + @tfield factionSide[31] faction alliance array, -1 if not in battle, start at 1 so faction dipnum + 1 + tfield getPlayerArmy getPlayerArmy + @tfield getBattleResidence getBattleResidence @table gameDataAll.battleStruct */ @@ -753,9 +1412,34 @@ void luaP::initP2() typeAll.battleTable.set("paused", &battleDataS::paused); typeAll.battleTable.set("battleSpeed", &battleDataS::speed); typeAll.battleTable.set("secondsPassed", &battleDataS::secondsPassed); + typeAll.battleTable.set("secondsSinceBattleLoaded", &battleDataS::secondsSinceBattleLoaded); + typeAll.battleTable.set("hidingEnabledSet", &battleDataS::hidingEnabledSet); + typeAll.battleTable.set("mapWidthDoubled", &battleDataS::mapWidthDoubled); + typeAll.battleTable.set("mapHeightDoubled", &battleDataS::mapHeightDoubled); typeAll.battleTable.set("sidesNum", &battleDataS::sidesNum); typeAll.battleTable.set("sides", sol::property([](battleDataS& self) { return std::ref(self.sides); })); typeAll.battleTable.set("factionSide", sol::property([](battleDataS& self) { return std::ref(self.factionSide); })); + /*** + Get the players army. + @function battleStruct:getPlayerArmy + @treturn stackStruct army + @usage + + local playerArmy = battle:getPlayerArmy() + + */ + typeAll.battleTable.set_function("getPlayerArmy", &battleHandlerHelpers::getPlayerArmy); + /*** + Get table with certain info about the battle residence. + @function battleStruct.getBattleResidence + @treturn battleResidence battleResidence + @usage + + local battleResidence = battle.getBattleResidence() + + */ + typeAll.battleTable.set_function("getBattleResidence", &battleHandlerHelpers::getBattleResidence); + ///BattleSide //@section battleSide @@ -771,10 +1455,13 @@ void luaP::initP2() @tfield int armiesNum @tfield int alliance @tfield int soldierCount + @tfield int factionCount @tfield int totalStrenght @tfield battleAI battleAIPlan @tfield getBattleArmy getBattleArmy - @tfield trackedPointerArmy[8] Returns a table of trackedPointerArmy. Maximum: 8. + @tfield trackedPointerArmy[8] armies Returns a table of trackedPointerArmy. Maximum: 8. + + @@ -788,6 +1475,7 @@ void luaP::initP2() typeAll.battleSideTable.set("alliance", &battleSide::alliance); typeAll.battleSideTable.set("soldierCount", &battleSide::soldierCount); typeAll.battleSideTable.set("totalStrenght", &battleSide::totalStrenght); + typeAll.battleSideTable.set("factionCount", &battleSide::factionCount); typeAll.battleSideTable.set("battleAIPlan", &battleSide::battleAIPlan); typeAll.battleSideTable.set("winConditions", sol::property([](battleSide& self) { return std::ref(self.winConditions); })); /*** @@ -833,16 +1521,26 @@ void luaP::initP2() typeAll.battleSideTable.set("armies", sol::property([](battleSide& self) { return std::ref(self.armies); })); /*** Get a battle army by it's index. - @function getBattleArmy - @tparam battleSideTable side + @function battleSideTable:getBattleArmy @tparam int index @treturn battleArmy army @usage - unit = side:getBattleArmy(0) + battleArmy = side:getBattleArmy(0) */ typeAll.battleSideTable.set_function("getBattleArmy", &battleHandlerHelpers::getBattleArmy); + /*** + Get a faction in this side by it's index. + @function battleSideTable:getFaction + @tparam int index + @treturn factionStruct faction + @usage + + faction = side:getFaction(0) + + */ + typeAll.battleSideTable.set_function("getFaction", &battleHandlerHelpers::getFaction); ///TrackedPointerArmy @@ -934,6 +1632,8 @@ void luaP::initP2() @tfield float generalHPRatioLost @tfield float battleOdds @tfield int numKilledGenerals + @tfield int numDiedGenerals + @tfield int numKilledCaptains @tfield int unitCount @tfield getBattleUnit getBattleUnit @@ -946,11 +1646,12 @@ void luaP::initP2() typeAll.battleArmy.set("generalHPRatioLost", &armyAndCharacter::generalHPRatioLost); typeAll.battleArmy.set("battleOdds", &armyAndCharacter::battleOdds); typeAll.battleArmy.set("numKilledGenerals", &armyAndCharacter::numKilledGenerals); + typeAll.battleArmy.set("numDiedGenerals", &armyAndCharacter::generalsDiedCount); + typeAll.battleArmy.set("numKilledCaptains", &armyAndCharacter::killedCaptainsCount); typeAll.battleArmy.set("unitCount", &armyAndCharacter::unitCount); /*** Get a battle unit by it's index. - @function getBattleUnit - @tparam battleArmy army + @function battleArmy:getBattleUnit @tparam int index @treturn battleUnit unit @usage @@ -969,7 +1670,16 @@ void luaP::initP2() @tfield int soldiersLost @tfield int soldiersStart @tfield int unitsRouted - @tfield boolean hasRouted + @tfield int soldiersKilled + @tfield int takenPrisoner + @tfield int prisonersCaught + @tfield int soldiersHealed + @tfield int unitsRoutedEnd + @tfield int soldiersEnd + @tfield int friendlyFireCasualties + @tfield int expStart + @tfield int expGained + @tfield int isGeneral @table battleUnit */ @@ -978,5 +1688,33 @@ void luaP::initP2() typeAll.battleUnit.set("soldiersLost", &battleUnit::soldiersLost); typeAll.battleUnit.set("soldiersStart", &battleUnit::soldiersStart); typeAll.battleUnit.set("unitsRouted", &battleUnit::unitsRouted); - typeAll.battleUnit.set("hasRouted", &battleUnit::hasRouted); + typeAll.battleUnit.set("soldiersKilled", &battleUnit::soldiersKilled); + typeAll.battleUnit.set("takenPrisoner", &battleUnit::takenPrisoner); + typeAll.battleUnit.set("prisonersCaught", &battleUnit::prisonersCaught); + typeAll.battleUnit.set("soldiersHealed", &battleUnit::soldiersHealed); + typeAll.battleUnit.set("unitsRoutedEnd", &battleUnit::unitsRoutedEnd); + typeAll.battleUnit.set("soldiersEnd", &battleUnit::soldiersEnd); + typeAll.battleUnit.set("friendlyFireCasualties", &battleUnit::friendlyFireCasualties); + typeAll.battleUnit.set("expStart", &battleUnit::expStart); + typeAll.battleUnit.set("expGained", &battleUnit::expGained); + typeAll.battleUnit.set("isGeneral", &battleUnit::isGeneral); + + /// battleResidence + //@section battleResidence + + /*** + Basic battleResidence table + + @tfield settlementStruct settlement + @tfield int isFortBattle + @tfield bool settlementWallsBreached + @tfield bool settlementGateDestroyed + + @table battleResidence + */ + typeAll.battleResidence = luaState.new_usertype("battleResidence"); + typeAll.battleResidence.set("settlement", &battleResidence::settlement); + typeAll.battleResidence.set("isFortBattle", &battleResidence::isFortBattle); + typeAll.battleResidence.set("settlementWallsBreached", &battleResidence::settlementWallsBreached); + typeAll.battleResidence.set("settlementGateDestroyed", &battleResidence::settlementGateDestroyed); } \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp index 4ddcae50..66f2fa42 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp @@ -215,4 +215,22 @@ namespace m2tweopHelpers return (*(*plugData::data.funcs.getGameVersion))(); } + options1* getOptions1() + { + if (getGameVersion() == 1) + { + return reinterpret_cast(0x02CB693C); + } + return reinterpret_cast(0x02C6D804); + } + + options2* getOptions2() + { + if (getGameVersion() == 1) + { + return reinterpret_cast(0x016818A0); + } + return reinterpret_cast(0x01639EF0); + } + } \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h index 8ef6eb1c..da8f0586 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h @@ -50,6 +50,8 @@ namespace m2tweopHelpers void setEDUUnitsSize(signed short min, signed short max); int getGameVersion(); + options1* getOptions1(); + options2* getOptions2(); std::tuple loadTextureToGame(const std::string& path); diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index cb7b156d..1b9e26fe 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -33,6 +33,29 @@ struct rcString char pad_0010[104]; //0x0010 }; //Size: 0x0078 +struct generalStats +{ +public: + struct soldierInBattle* generalBgSoldier; //0x0000 + struct soldierInBattle* generalBgMount; //0x0004 +}; //Size: 0x0008 + +struct coordPair +{ +public: + int32_t xCoord; //0x0000 + int32_t yCoord; //0x0004 +}; //Size: 0x0008 + +struct movePath +{ +public: + struct coordPair* tileCoords; //0x0000 + int32_t tileCoordsSize; //0x0004 + int32_t tileCoordsCount; //0x0008 +}; //Size: 0x000C + + class religionDatabase { public: @@ -77,6 +100,31 @@ struct capturedFactionInfo int32_t ransomValue; }; +struct floatsSeaConnect +{ +public: + uint32_t tileId; //0x0000 + float someFloat; //0x0004 +}; //Size: 0x0008 + +struct seaConnectedRegion +{ +public: + int32_t regionID; //0x0000 + char pad_0004[4]; //0x0004 + float angle; //0x0008 + float distance; //0x000C + int32_t seaExportValue; //0x0010 + int32_t seaImportValue; //0x0014 + struct floatsSeaConnect *tilesReachable; //0x0018 + int32_t tilesReachableSize; //0x001C + int32_t tilesReachableCount; //0x0020 + struct coordPair* seaTradeLanePath; //0x0024 + int32_t seaTradeLanePathSize; //0x0028 + int32_t seaTradeLanePathCount; //0x002C + char pad_0030[4]; //0x0030 +}; //Size: 0x0034 + struct regionStruct { char* regionName;//0x0000 int regionNameHash;//0x0004 @@ -86,7 +134,9 @@ struct regionStruct { int legioNameHash;//0x0014 undefined field4_0x10[4];//0x0018 int regionID;//0x001C - char pad_0020[12]; //0x0020 + int32_t N00008C49; //0x0020 + int32_t N00008C4A; //0x0024 + int32_t overOneAllowsFamine; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -98,23 +148,46 @@ struct regionStruct { int32_t watchtowersNum; //0x004C int8_t isSea; //0x0050 int8_t hasLake; //0x0051 - char pad_0052[58]; //0x0052 + char pad_0052[2]; //0x0052 + struct landMass* landMass; //0x0054 + struct roadStruct* roadToPort; //0x0054 + struct seaConnectedRegion* seaConnectedRegions; //0x005C + int32_t seaConnectedRegionsCountArraySize; //0x0060 + int32_t seaConnectedRegionsCount; //0x0064 + int32_t loyaltyFactionID; //0x0068 + struct seaConnectedRegion* seaExportRegion; //0x006C + char pad_0070[12]; //0x0070 + struct seaConnectedRegion** seaImportRegions; //0x007C + int32_t seaImportRegionsSize; //0x0080 + int32_t seaImportRegionsCount; //0x0084 + int32_t canSeaTrade; //0x0088 struct mercPool* mercPool;//0x008C - undefined field6_0x90[36];//0x0090 + int32_t* regionSeaEdges; //0x0090 + int32_t regionSeaEdgesSize; //0x0094 + int32_t regionSeaEdgesCount; //0x0098 + char pad_009C[24]; //0x009C float* religionsARR;//0x00B4 - int* religionsEnd; //0x00B8 - undefined field8_0xbc[212];//0x00BC + float* religionHistory[20]; + uint32_t* tilesBorderingEdgeOfMap; //0x0108 + int32_t tilesBorderingEdgeOfMapSize; //0x010C + int32_t tilesBorderingEdgeOfMapCount; //0x0110 + char pad_0114[124]; //0x0114 struct settlementStruct* settlement;//0x0190 - char pad_0194[8]; //0x0194 + int* tiles; //0x0194 + int32_t tilesSize; //0x0198 int32_t tileCount; //0x019C - char pad_0177[12]; //0x0194 + int* fertileTiles; //0x01A0 + int32_t fertileTilesSize; //0x01A4 + int32_t fertileTilesCount; //0x01A8 struct neighbourRegion* neighbourRegions;//0x01AC int32_t neighbourRegionsCountArraySize; //0x01B0 int32_t neighbourRegionsNum; //0x01B4 struct resStrat** resources;//0x01B8 - int32_t resourceCountArrayZie; //0x01BC + int32_t resourcesSize; //0x01BC int32_t resourcesNum; //0x01C0 - char pad_01C4[12]; //0x01C4 + int32_t N00008CB2; //0x01C4 + uint32_t resourceTypesBitMap; //0x01C8 + int32_t N00008CB4; //0x01CC uint32_t hiddenResources1; //0x01D0 uint32_t hiddenResources2; //0x01D4 char pad_01D8[4]; //0x01D8 @@ -142,20 +215,45 @@ struct neighbourRegion int32_t regionID; //0x0004 float distance; //0x0008 char pad_000C[4]; //0x000C - void* tileStuff; //0x0010 - char pad_0014[68]; //0x0014 + struct roadStruct* connectingRoad; //0x0010 + int32_t tradeValue; //0x0014 + int32_t* bordertiles; //0x0018 + int32_t borderTilessize; //0x001C + int32_t borderTilesCount; //0x0020 + char pad_0024[52]; //0x0024 }; //Size: 0x0058 +struct landMass +{ +public: + int32_t index; //0x0000 + int32_t* regions; //0x0004 + int32_t regionsSize; //0x0008 + int32_t regionsNum; //0x000C +}; //Size: 0x0010 + struct stratMap { - undefined field_0x0[44]; + undefined field_0x0[4]; + struct UNICODE_STRING** campaignName; //0x0004 + struct UNICODE_STRING*** campaignPath; //0x0008 + char pad_000C[28]; //0x000C + void* climates; //0x0028 int mapWidth; int mapHeight; undefined field_0x34[20]; struct oneTile* tilesArr; - undefined field_0x4c[4]; - undefined field_0x50[44]; + DWORD TileListEnd; //0x004C + undefined field_0x50[20]; + struct coordPair* volcanoes; //0x0064 + int32_t volcanoesSize; //0x0068 + int32_t volcanoesNum; //0x006C + struct coordPair* landMassConnections; //0x0070 + int32_t landMassConnectionsSize; //0x0074 + int32_t landMassConnectionsNum; //0x0078 struct regionStruct regions[200]; int regionsNum; + struct landMass landMass[20]; //0x1A660 + int32_t landMassNum; //0x1A7A0 }; struct mercPoolUnit { @@ -225,9 +323,24 @@ struct uiElement { undefined field_0x58[112]; }; +struct roadStruct +{ +public: + struct coordPair* coords; //0x0000 + int32_t coordsSize; //0x0004 + int32_t coordsNum; //0x0008 + void* someOtherArray; //0x000C + int32_t someOtherArraySize; //0x0010 + int32_t someOtherArrayCount; //0x0014 + int32_t regionIdStart; //0x0018 + int32_t regionIdEnd; //0x001C + char pad_0020[24]; //0x0020 +}; //Size: 0x0038 + struct oneTile { void* object; - undefined field_0x4[6]; + struct roadStruct* road; //0x0004 + undefined field_0x8[2]; int8_t isLand; undefined field_0xB[1]; int8_t terrainModel; @@ -243,9 +356,13 @@ struct oneTile { int8_t hasRoad; int8_t border; undefined field_0x22[2]; - int8_t objectTypes; + int8_t objectTypes; //bit87_character6_ship5_watchtower4_port3_bit32_fort1_settlement0 int8_t passable; - undefined field_0x26[14]; + int8_t N0002227F; //0x0026 + int8_t N00022271; //0x0027 + uint32_t armiesNearTile; //0x0028 + uint32_t charactersOnTile; //0x002C + float mpModifier; //0x0030 }; struct siegeS { @@ -254,11 +371,77 @@ struct siegeS { struct stackStruct* army; }; +struct stringWithHash +{ +public: + char* name; //0x0000 + int32_t hash; //0x0004 +}; //Size: 0x0008 + +struct holdRegionsWinCondition +{ +public: + char pad_0000[4]; //0x0000 + int32_t intSomethingTurns; //0x0004 + struct stringWithHash* regionsToHold; //0x0008 + int32_t regionsToHoldSize; //0x000C + int32_t regionsToHoldCount; //0x0010 + char pad_0014[4]; //0x0014 + int32_t numberOfRegions; //0x0018 + char pad_001C[4]; //0x001C + int32_t* holdRegionLengths; //0x0020 + int32_t holdRegionLengthsSize; //0x0024 + int32_t holdRegionLengthsCount; //0x0028 + char pad_002C[12]; //0x002C +}; //Size: 0x0080 + +struct battleSettlement +{ +public: + char pad_0000[4]; //0x0000 + struct settlementStruct* settlement; //0x0004 + char pad_0008[4]; //0x0008 + struct battleResidence* battleResidence; //0x000C + char pad_0010[304]; //0x0010 +}; //Size: 0x0140 + +struct battleResidence +{ +public: + char pad_0000[28]; //0x0000 + struct settlementStruct* settlement; //0x001C + char pad_0020[16]; //0x0020 + int32_t isFortBattle; //0x0030 + char pad_0034[8]; //0x0034 + float N000203C6; //0x003C + float N000203C7; //0x0040 + char pad_0044[40]; //0x0044 + int8_t settlementWallsBreached; //0x006C + int8_t settlementGateDestroyed; //0x006D + char pad_006E[2]; //0x006E + int8_t N0003A33C; //0x0070 + char pad_0071[7]; //0x0071 + float N0003A33E; //0x0078 + char pad_007C[200]; //0x007C +}; //Size: 0x0144 + +struct factionRanking +{ +public: + float totalRanking; //0x0000 + float militaryRanking; //0x0004 + float productionRanking; //0x0008 + float territoryRanking; //0x000C + float FinancialRanking; //0x0010 + float populationRanking; //0x0014 +}; //Size: 0x0018 + struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int id; char* facName; DWORD facNameHash; - undefined field_0xc[60]; + undefined field_0xc[56]; + int religionID; struct model_Rigid* symbol; char* symbolPath; DWORD symbolPathHash; @@ -279,7 +462,26 @@ struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int standard_index; int logo_index; int small_logo_index; - undefined field_0x88[88]; + undefined field_0x88[20]; + int32_t hordeMaxUnits; //0x009C + char pad_00A0[28]; //0x00A0 + uint8_t customBattleAvailability; //0x00BC + char pad_00BD[3]; //0x00BD + uint32_t periodsUnavailableInCustomBattle; //0x00C0 + uint8_t N00008DC2; //0x00C4 + uint8_t canSap; //0x00C5 + char pad_00C6[2]; //0x00C6 + int32_t prefersNavalInvasions; //0x00C8 + uint8_t canHavePrincess; //0x00CC + char pad_00CD[3]; //0x00CD + char* specialfactionType; //0x00D0 + char pad_00D4[4]; //0x00D4 + uint8_t hasFamilyTree; //0x00D8 + uint8_t teutonic; //0x00D9 + uint8_t disbandToPools; //0x00DA + uint8_t canBuildSiegeTowers; //0x00DB + uint8_t canTransmitPlague; //0x00DC + char pad_00DD[3]; //0x00DD }; struct watchTowerModel { @@ -413,7 +615,8 @@ struct campaign { struct factionStruct* currentFactionTurn; int factionTurnID; /* FactionTurn? */ UNICODE_STRING** currentDescrFile; /* path to descr_battle.txt or to descr_strat.txt */ - undefined field20_0x350[28]; + int32_t fogOfWar; //0x0350 + undefined field20_0x354[24]; int tickCount; /* TickCount? */ int millisecondCount; float secondCount; @@ -445,7 +648,7 @@ struct campaign { int8_t saveEnabled; //0x06F5 undefined field45_0x6f6[6]; int8_t hotseatConsole; - int8_t hotseatConsole2; + int8_t hotseatConsoleEnabledWithLogon; undefined field48_0x6fe[14]; float currentDate; int season; /* season(0-summer,1-winter) */ @@ -476,6 +679,32 @@ struct campaign { int32_t watchtowersNum; //0x2162C }; +struct uiUnitCard +{ +public: + char pad_0000[380]; //0x0000 + unit* unit; //0x0384 +}; + +struct uiCardManager +{ +public: + char pad_0000[16]; //0x0000 + struct uiUnitCard** selectedUnitCards; //0x0010 + int32_t selectedUnitCardsSize; //0x0014 + int32_t selectedUnitCardsCount; //0x0018 + char pad_001C[24]; //0x001C + struct uiUnitCard** unitCards; //0x0034 + int32_t unitCardsSize; //0x0038 + int32_t unitCardsCount; //0x003C + char pad_0060[328]; //0x0060 + struct settlementStruct* selectedSettlement; //0x0188 + char pad_018C[12]; //0x018C + struct general* selectedCharacter; //0x0198 + char pad_019C[12]; //0x019C + struct fortStruct* selectedFort; //0x01A8 +}; + struct gameDataAllStruct { undefined field_0x0[40]; struct campaign* campaignData; @@ -484,7 +713,11 @@ struct gameDataAllStruct { struct campaign* field_0x38; undefined field_0x3c[28]; struct battleDataS* battleHandler; - undefined field_0x5c[8]; + undefined field_0x5c[36]; + struct battleSettlement* battleSettlement; + char pad[112]; + struct uiCardManager* uiCardManager; + char pad2[84]; }; struct battleUnit @@ -494,14 +727,248 @@ struct battleUnit struct UNICODE_STRING** localizedName; //0x0004 float someFloat; //0x0008 int32_t soldiersLost; //0x000C - char pad_0010[12]; //0x0010 + int32_t soldiersKilled; //0x0010 + int32_t takenPrisoner; //0x0014 + int32_t prisonersCaught; //0x0018 int32_t soldiersStart; //0x001C uint32_t unitsRouted; //0x0020 - char pad_0024[20]; //0x0024 - int8_t hasRouted; //0x0038 - char pad_0039[15]; //0x0039 + int32_t soldiersHealed; //0x0024 + int32_t unitsRoutedEnd; //0x0028 + int32_t soldiersEnd; //0x002C + int32_t friendlyFireCasualties; //0x0030 + int32_t expStart; //0x0034 + int32_t expGained; //0x0038 + int8_t isGeneral; //0x003C + char pad_003D[11]; //0x003D }; //Size: 0x0048 +struct options1 +{ + void* cursor; //0x0000 + int8_t N0003DD45; //0x0004 + int8_t widescreen; //0x0005 + char pad_0006[2]; //0x0006 + int64_t antiAliasMode; //0x0008 + int16_t subtitles; //0x0010 + int8_t english; //0x0012 + int8_t noBattleTimeLimit; //0x0013 + char pad_0014[4]; //0x0014 + int32_t useNewCursorActions; //0x0018 + int32_t campaignNumTimesPlay; //0x001C + int8_t uiWinConditions; //0x0020 + int8_t isScenario; //0x0021 + char pad_0022[2]; //0x0022 + int32_t isHotseatEnabled; //0x0024 + int8_t hotseatAutosave; //0x0028 + int8_t email; //0x0029 + int8_t saveConfig; //0x002A + int8_t closeAfterSave; //0x002B + int8_t validateData; //0x002C + int8_t campaignMapSpeedUp; //0x002D + char pad_002E[2]; //0x002E + int32_t skipAiFactions; //0x0030 + int8_t labelCharacters; //0x0034 + int8_t noBackGroundFmv; //0x0035 + int8_t disableArrowMarkers; //0x0036 + int8_t arcadeBattles; //0x0037 + int8_t disableEvents; //0x0038 + int8_t isPrologue; //0x0039 + int8_t updateAiCamera; //0x003A + int8_t hideCampaign; //0x003B + int32_t unlimitedMenOnBattlefield; //0x003C + char pad_0040[4]; //0x0040 + class N0003DA46* prefFactionsPlayed; //0x0044 + int32_t tgaReserveSpace; //0x0048 + int32_t keysetUsed; //0x004C + class N0003DD67* descrShortcuts; //0x0050 + int8_t muteAdvisor; //0x0054 + int8_t advancedStatsAlways; //0x0055 + int8_t microManageAllSettlements; //0x0056 + int8_t blindAdvisor; //0x0057 + int32_t terrainQuality; //0x0058 + int32_t vegetationQuality; //0x005C + int8_t useQuickChat; //0x0060 + int8_t someBoolNetworkManager; //0x0061 + char pad_0062[1]; //0x0062 + int8_t someBoolOnlinePlay; //0x0063 + int32_t graphicsAdaptor; //0x0064 + int8_t byte_2C6D86C; //0x0068 + int8_t showDemeanour; //0x0069 + char pad_006A[2]; //0x006A + int32_t radar; //0x006C + int32_t unitCards; //0x0070 + int32_t sa_cards; //0x0074 + int32_t buttons; //0x0078 + int8_t tutorialBattlePlayed; //0x007C + int8_t disableVnVs; //0x007D + int8_t allUsers; //0x007E + char pad_007F[29]; //0x007F + int32_t unk_2C6D8A0; //0x009C + char pad_00A0[28]; //0x00A0 + char* audioProvider; //0x00BC + char pad_00C0[20]; //0x00C0 + struct UNICODE_STRING** campaignName; //0x00D4 + char pad_00D8[4]; //0x00D8 + struct UNICODE_STRING*** N0003DA7C; //0x00DC + struct UNICODE_STRING*** maybeGameSpyUsername; //0x00E0 + struct UNICODE_STRING*** gameSpyPassword; //0x00E4 + char pad_00E8[4]; //0x00E8 + char* gameName; //0x00EC + char pad_00F0[24]; //0x00F0 + char adminPassword[28]; //0x0108 + char* tutorialPath; //0x0124 +}; //Size: 0x0128 + + +struct options2 +{ + uint16_t defaultCampaignResolutionX; //0x0000 + uint16_t defaultCampaignResolutionY; //0x0002 + uint16_t campaignResolutionX; //0x0004 + uint16_t campaignResolutionY; //0x0006 + uint16_t defaultBattleResolutionX; //0x0008 + uint16_t defaultBattleResolutionY; //0x000A + uint16_t battleResolutionX; //0x000C + uint16_t battleResolutionY; //0x000E + int8_t idk; //0x0010 + int8_t vSync; //0x0011 + char pad_0012[6]; //0x0012 + int8_t uiIconBarCheck; //0x0018 + int8_t uiRadarCheck; //0x0019 + int8_t useMorale; //0x001A + int8_t uiAmmoCheck; //0x001B + int8_t useFatigue; //0x001C + int8_t uiSupplyCheck; //0x001D + int8_t toggleFowState; //0x001E + int8_t cameraRestrict; //0x001F + int8_t eventCutscenes; //0x0020 + char pad_0021[3]; //0x0021 + int32_t defaultCameraInBattle; //0x0024 + int8_t splashes; //0x0028 + int8_t vegetationVideo; //0x0029 + int8_t byte_1639F1A; //0x002A + int8_t stencilShadows; //0x002B + int8_t byte_1639F1C; //0x002C + int8_t audioEnable; //0x002D + int8_t speechEnable; //0x002E + int8_t firstTimePlay; //0x002F + char* audioProviderName; //0x0030 + char pad_0034[1]; //0x0034 + int8_t byte_1639F25; //0x0035 + char pad_0036[1]; //0x0036 + int8_t toggleAutoSave; //0x0037 + int8_t showBanners; //0x0038 + int8_t passwords; //0x0039 + int8_t hotseatTurns; //0x003A + int8_t hotseatScroll; //0x003B + int32_t allowValidationFeatures; //0x003C + int32_t campaignSpeed; //0x0040 + int8_t labelSettlements; //0x0044 + int8_t disablePapalElections; //0x0045 + int8_t autoresolveAllBattles; //0x0046 + int8_t savePrefs; //0x0047 + int8_t disableConsole; //0x0048 + int8_t validateDiplomacy; //0x0049 + char pad_004A[2]; //0x004A + float someFloat; //0x004C + int32_t unitDetail; //0x0050 + int32_t buildingDetail; //0x0054 + int32_t maxSoldiersOnBattlefield; //0x0058 + int32_t unitSize; //0x005C + int32_t cameraRotateSpeed; //0x0060 + int32_t cameraMoveSpeed; //0x0064 + float cameraSmoothing; //0x0068 + int32_t somethingBasedOnBuildingDetail; //0x006C + int32_t masterVolume; //0x0070 + int32_t musicVolume; //0x0074 + int32_t speechVolume; //0x0078 + int32_t sfxVolume; //0x007C + int32_t subFactionAccents; //0x0080 + int32_t playerFactionId; //0x0084 + int32_t campaignDifficulty; //0x0088 + int32_t battleDifficulty; //0x008C + int32_t tgaWidth; //0x0090 + float tgaAspect; //0x0094 + int32_t tgaInputScale; //0x0098 + int32_t scrollMinZoom; //0x009C + int32_t scrollMaxZoom; //0x00A0 + int32_t advisorVerbosity; //0x00A4 + int8_t useSomethingTgaTextures; //0x00A8 + int8_t byte_1639F99; //0x00A9 + char pad_00AA[2]; //0x00AA + int32_t effectQuality; //0x00AC + int32_t EnableCameraCampaignSmoothing; //0x00B0 + int32_t chatMsgDuration; //0x00B4 + int8_t N0003DDF9; //0x00B8 + int8_t saveGameSpyPassword; //0x00B9 + int8_t addDateToLogs; //0x00BA + int8_t showToolTips; //0x00BB + int8_t isNormalHud; //0x00BC + int8_t showPackageLitter; //0x00BD + char pad_00BE[2]; //0x00BE + char* normal; //0x00C0 + char pad_00C4[8]; //0x00C4 + int32_t effectNormal; //0x00CC + char pad_00D0[8]; //0x00D0 + char* low; //0x00D8 + char pad_00DC[8]; //0x00DC + int32_t effectLow; //0x00E4 + char pad_00E8[8]; //0x00E8 + char* high; //0x00F0 + char pad_00F4[8]; //0x00F4 + int32_t effectHigh; //0x00FC + char pad_0100[8]; //0x0100 + char* lowest; //0x0108 + char pad_010C[8]; //0x010C + int32_t effectLowest; //0x0114 + char pad_0118[8]; //0x0118 + char* highest; //0x0120 + char pad_0124[8]; //0x0124 + int32_t effectHighest; //0x012C + char pad_0130[8]; //0x0130 + char* custom; //0x0138 + char pad_013C[8]; //0x013C + int32_t effectCustom; //0x0144 + char pad_0148[8]; //0x0148 + char* lower; //0x0150 + char pad_0154[8]; //0x0154 + int32_t effectLower; //0x015C + char pad_0160[8]; //0x0160 + char* higher; //0x0168 + char pad_016C[8]; //0x016C + int32_t effectHigher; //0x0174 + char pad_0178[8]; //0x0178 + char* off; //0x0180 + char pad_0184[8]; //0x0184 + int32_t effectOff; //0x018C + char pad_0190[32]; //0x0190 + int32_t maxSizeEduMaybe1; //0x01B0 + float unitMultDefault; //0x01B4 + int32_t unitMultDefaultId; //0x01B8 + int32_t maxSizeEduMaybe2; //0x01BC + float unitSizeMultiplierLow; //0x01C0 + int32_t unitMult1ID; //0x01C4 + int32_t maxSizeEduMaybe3; //0x01C8 + float unitSizeMultiplierMedium; //0x01CC + int32_t unitMult2ID; //0x01D0 + int32_t maxSizeEduMaybe4; //0x01D4 + float unitSizeMultiplierLarge; //0x01D8 + int32_t unitMult3ID; //0x01DC + char pad_01E0[12]; //0x01E0 + uint16_t word_163A0DC; //0x01EC + char pad_01EE[10]; //0x01EE + uint16_t word_163A0E8; //0x01F8 + char pad_01FA[2]; //0x01FA + uint16_t word_163A0EC; //0x01FC + char pad_01FE[54]; //0x01FE + int16_t currentHotseatPlayerOrSomething; //0x0234 + char pad_0236[2]; //0x0236 + class N0003DF44* keysetPointer; //0x0238 + char pad_023C[4]; //0x023C + int32_t keySetUsed; //0x0240 + int32_t preferencesWereLoaded; //0x0244 +}; + struct armyAndCharacter { /* in battle leader and leader army */ struct stackStruct* army;//0x0000 @@ -510,11 +977,18 @@ struct armyAndCharacter { /* in battle leader and leader army */ float generalHPRatioLost; //0x000C float someFloat; //0x0010 float battleOdds; //0x0014 - char pad_0018[20]; //0x0018 + char pad_0018[12]; //0x0018 + struct general* killedGenerals; //0x0024 + int32_t killedGeneralsSize; //0x0028 int32_t numKilledGenerals; //0x002C - char pad_0030[36]; //0x0030 - DWORD N0001FC50; //0x0054 - char pad_0058[68]; //0x0058 + char pad_0030[24]; //0x0030 + struct general* generalsDied; //0x0048 + int32_t generalsDiedSize; //0x004C + int32_t generalsDiedCount; //0x0050 + struct general* killedCaptains; //0x0054 + int32_t killedCaptainsSize; //0x0058 + int32_t killedCaptainsCount; //0x005C + char pad_005C[60]; //0x005C struct battleUnit* units; //0x009C int32_t unitArraySize; //0x00A0 int32_t unitCount; //0x00A4 @@ -673,6 +1147,13 @@ struct battleSide { char pad_1928[4]; //0x1928 }; +struct playerArmy +{ +public: + struct stackStruct* army; //0x0000 + char pad_0004[20]; //0x0004 +}; //Size: 0x0018 + struct battleDataS { undefined field_0x0[4];//0x0000 int battleState; /* 0-not in battle,5-active battle,9-results screen,etc 0x0004 */ @@ -691,11 +1172,32 @@ struct battleDataS { float speed; //0x0058 char pad_005C[8]; //0x005C float secondsPassed; //0x0064 - char pad_0068[48]; //0x0068 + int32_t secondsSinceBattleLoaded; //0x0068 + char pad_006C[16]; //0x006C + float mapWidthDoubled; //0x007C + float mapHeightDoubled; //0x0080 + char pad_0084[12]; //0x0084 + int32_t hidingEnabledSet; //0x0090 + char pad_0094[4]; //0x0094 struct UNICODE_STRING** someUniString; //0x0098 struct battleSide sides[8]; //0x009C int32_t factionSide[31]; //0xC9FC int sidesNum;//0xCA78 + char pad_CA7C[44]; //0xCA7C + struct playerArmy playerArmies[30]; //0xCAA8 + char pad_CD78[4]; //0xCD78 + int32_t playerArmyCount; //0xCD7C + char pad_CD80[84]; //0xCD80 + int32_t N0001D4DC; //0xCDD4 + int32_t N0001D4DD; //0xCDD8 + char pad_CDDC[20]; //0xCDDC + int32_t N0001D4E3; //0xCDF0 + int32_t N0001D4E4; //0xCDF4 + char pad_CDF8[4]; //0xCDF8 + int32_t N0001D4E6; //0xCDFC + int32_t N0001D4E7; //0xCE00 + char pad_CE04[44]; //0xCE04 + struct battleDataS* thisStruct; //0xCE30 };//Size: 0xCA7C struct stratPortModel { @@ -1113,6 +1615,36 @@ struct RallyPointSundry { undefined field4_0x44[16]; }; +struct settlementCapability +{ +public: + int16_t value; //0x0000 + int16_t bonus; //0x0002 +}; //Size: 0x0004 + +struct recruitCapRome +{ +public: + char pad[8]; +}; //Size: 0x0008 + +struct recruitmentCapability +{ +public: + int32_t eduIndex; //0x0000 + int32_t xp; //0x0004 + float initialSize; //0x0008 + float replenishRate; //0x000C + float maxSize; //0x0010 +}; //Size: 0x0014 + +struct settlementRecruitmentPool +{ +public: + int32_t eduIndex; //0x0000 + float availablePool; //0x0004 +}; //Size: 0x0008 + //settlement struct settlementStruct { void* vTable; @@ -1157,19 +1689,51 @@ struct settlementStruct { undefined field26_0x5ac[520]; struct building* buildings[128]; int buildingsNum; /* number of the buildings in the settlement */ - undefined field29_0x9b8[1100]; - uchar isProvokedRebellion; - uchar field31_0xe05[3]; - undefined field32_0xe08[24]; - struct general* governor; - undefined field34_0xe24[32]; + undefined field29_0x9b8[1080]; + int32_t rallyPointX; //0x0DF0 + int32_t rallyPointY; //0x0DF4 + void* rallyPointPointer; //0x0DF8 + void* AIProductionController; //0x0DFC + char pad_0E00[4]; //0x0E00 + int8_t scriptRebel; //0x0E04 + uchar isProvokedRebellion;//0x0E05 + uchar field31_0xe06[34];//0x0E06 + struct general* governor;//0x0E28 + char pad_0E2C[12]; //0x0E2C + int32_t publicOrderLastTurnEnd; //0x0E38 + int32_t populationLastTurnEnd; //0x0E3C + char pad_0E40[4]; //0x0E40 struct resStrat** resources; - undefined field36_0xe48[4]; + int32_t resourceSize; //0x0E48 int resourcesNum; - undefined field38_0xe50[2164]; + int32_t settlementTaxLevel; //0x0E50 + struct settlementCapability settlementCapabilities[57]; //0x0E54 + struct settlementCapability settlementCapabilitiesAgent[6]; //0x0F38 + struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x0F50 + struct settlementCapability settlementCapabilitiesAncillary[4]; //0x0F68 (ROME - NOT IMPLEMENTED IN MED 2) + char pad_0F78[4]; //0x0F78 + struct recruitCapRome settlementCapabilitiesRecruit[64]; //0x0F7C + struct recruitmentCapability recruitmentCapabilities[64]; //0x117C + int32_t recruitPoolCapabilityCount; //0x167C + int8_t N000089C8; //0x1680 + char pad_1681[3]; //0x1681 + struct settlementStruct* thisSett; //0x1684 + struct settlementRecruitmentPool* recruitmentPools; //0x1688 + int32_t recruitmentPoolsSize; //0x168C + int32_t recruitmentPoolCount; //0x1690 + char pad_1694[12]; //0x1694 + int8_t freezeRecruitmentPool; //0x16A0 + char pad_16A1[3]; //0x16A1 + int32_t spiesInRecruitmentQueue; //0x16A4 + int32_t assassinsInRecruitmentQueue; //0x16A8 + int32_t diplomatsInRecruitmentQueue; //0x16AC + int32_t admiralsInRecruitmentQueue; //0x16B0 + int32_t merchantsInRecruitmentQueue; //0x16B4 + int32_t priestsInRecruitmentQueue; //0x16B8 + char pad_16BC[8]; //0x16BC intptr_t guildStandings; char pad_16C8[56]; //0x16C8 - int32_t Turmoil; //0x1700 + int32_t turmoil; //0x1700 char pad_1704[116]; //0x1704 int32_t populationLastTurn; //0x1778 char pad_177C[180]; //0x177C @@ -1269,24 +1833,56 @@ struct general { /* character on the stratmap, who has a unit in a stack */ struct genMod* genType; undefined field9_0x8c[24]; uchar ifMarkedToKill; - undefined field11_0xa5[19]; + undefined field11_0xa5[1]; + int8_t inEnemyZOC; //0x00A6 + char pad_00A7[17]; //0x00A7 int ambushState; undefined field13_0xbc[12]; - float movepoints1; + int8_t doNotSpendMovePoints; //0x00C5 + char pad_00C6[2]; //0x00C6 + float movePointsCharacter; undefined field15_0xcc[4]; uchar isStopCharacterNeeded; /* set to 1 if character moving now and he stops */ - undefined field17_0xd1[47]; + int32_t numTurnsIdle; //0x00D4 + int32_t regionID; //0x00D8 + float percentCharacterReligionInRegion; //0x00DC + float popConvertedThisTurn; //0x00E0 + int32_t timeInRegion; //0x00E4 + int32_t timeWithArmy; //0x00E8 + char pad_00EC[20]; //0x00EC struct stackStruct* armyLeaded; /* army of the general */ undefined field19_0x104[4]; struct unit* bodyguards; /* unit of general */ struct stackStruct* armyNotLeaded; /* army, if not leader */ undefined field22_0x110[208]; undefined field23_0x1e0[4]; - float movepointsModifier; - float movepointsMax; - float movepoints2; - undefined field27_0x1f0[64]; + float movePointsModifier; + float movePointsMax; + float movePointsArmy; + float movePointsMaxArmy; //0x01F0 + struct crusade* crusade; //0x01F4 + int32_t turnJoinedCrusade; //0x01F8 + int32_t currentTurn; //0x01FC + char pad_0200[48]; //0x0200 char* ability; /* custom ability */ + char pad_0234[4]; //0x0234 + struct general* thisCharacter; //0x0238 + char pad_023C[16]; //0x023C + struct general* thisCharacter2; //0x024C + int32_t xCoordLast; //0x0250 + int32_t yCoordLast; //0x0254 + int32_t xCoordCurrent; //0x0258 + int32_t yCoordCurrent; //0x025C + char pad_0260[332]; //0x0260 + void* someCoordStruct; //0x03AC + int32_t someCoordStructSize; //0x03B0 + int32_t someCoordStructCount; //0x03B4 + struct movePath *multiTurnMovePaths; //0x03B8 + int8_t multiTurnMovePathsSize; //0x03BC + int8_t multiTurnMovePathsCount; //0x03BD + int8_t N00032E71; //0x03BE + int8_t N00032E76; //0x03BF + char pad_03C0[8]; //0x03C0 }; //additional character data(name,label,traits, etc) @@ -1588,18 +2184,51 @@ struct targetPos public: int32_t typeOrSomething; //0x0000 int32_t N0001B8DA; //0x0004 - void* getsSet0IfHalted; //0x0008 + void* unitVerificationTable; //0x0008 struct targetUnitStruct* targetUnit; //0x000C char pad_0010[4]; //0x0010 - float targetPosX; //0x0014 - float targetPosY; //0x0018 - char pad_001C[24]; //0x001C + float targetPosXStart; //0x0014 + float targetPosYStart; //0x0018 + char pad_001C[16]; //0x001C + int32_t noDraggedFormation; //0x002C + float N0001B8E5; //0x0030 float N0001B8E6; //0x0034 char pad_0038[4]; //0x0038 - float N0001B8E8; //0x003C - char pad_0040[4]; //0x0040 - int32_t N0001B8EA; //0x0044 - char pad_0048[96]; //0x0048 + float somethingDistanceRelated; //0x003C + int32_t ranks; //0x0040 + float N0001B8EA; //0x0044 + char pad_0048[4]; //0x0048 + float N0001B8EC; //0x004C + char pad_0050[4]; //0x0050 + int8_t N0001B8EE; //0x0054 + int8_t draggedFormation1; //0x0055 + int8_t N0003D819; //0x0056 + int8_t draggedFormation2; //0x0057 + int8_t N0001B8EF; //0x0058 + int8_t N0003D80B; //0x0059 + int8_t N0003D80E; //0x005A + int8_t N0003D80C; //0x005B + float targetPosXEnd; //0x005C + float targetPosYEnd; //0x0060 + int8_t N0001B8F4; //0x0064 + int8_t N0003D7F4; //0x0065 + int8_t N0003D7F7; //0x0066 + int8_t N0003D7F5; //0x0067 + void* N0001B8F5; //0x0068 + int8_t N0001B8F6; //0x006C + int8_t N0003D7EA; //0x006D + int8_t N0003D7ED; //0x006E + int8_t N0003D7EB; //0x006F + float targetCoordXEngine; //0x0070 + float targetCoordZEngine; //0x0074 + float targetCoordYEngine; //0x0078 + struct siegeEngine* siegeEngine; //0x007C + int32_t N0001B8FB; //0x0080 + int32_t N0001B8FC; //0x0084 + char pad_0088[8]; //0x0088 + float N0001B8FF; //0x0090 + char pad_0094[16]; //0x0094 + float N0003A5AB; //0x00A4 }; //Size: 0x00A8 struct battleMapPosition @@ -1842,29 +2471,50 @@ struct stackStruct { /* structure of stack */ struct factionStruct* faction; int regionID; struct unit** units; - undefined field_0x58[4]; + int32_t unitsSize; //0x0058 int numOfUnits; - undefined field_0x60[56]; + undefined field_0x60[48]; + int8_t isBoarded; //0x0090 + char pad_0091[7]; //0x0091 struct stackStruct* boardedArmy; /* if fleet, here army */ undefined field_0x9c[4]; struct stackStruct* shipArmy; /* here fleet what contain our army */ undefined field_0xa4[8]; struct siegeS* siege; struct portBuildingStruct* blockedPort; /* if port blocked by this army when it here */ - undefined field_0xb4[32]; + undefined field_0xb4[3]; + int8_t ladders; //0x00B7 + int8_t rams; //0x00B8 + int8_t towers; //0x00B9 + char pad_00BA[10]; //0x00BA + int32_t tilesMovedThisTurnDoesntStatAtZero; //0x00C4 + char pad_00C8[4]; //0x00C8 + uint32_t upkeepModifier; //0x00CC + char pad_00D0[4]; //0x00D0 struct general* gen; /* 0 if in settlement/fort */ - undefined field_0xd8[24]; - struct general** characters; - undefined field_0xf4[4]; - int charactersNum; - undefined field_0xfc[4]; - struct settlementStruct* settlement; - undefined field_0x104[32]; + struct unit* generalsUnit; //0x00D8 + struct generalInfo* generalInfo; //0x00DC + float armyStrengthForAutoResolveMaybe; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct general** characters; //0x00F0 + undefined field_0xf4[4]; //0x00F4 + int charactersNum; //0x00F8 + undefined field_0xfc[4]; //0x00FC + struct settlementStruct* settlement; //0x0100 + undefined field_0x104[16]; + struct stackStruct* enemyArmy; + int32_t inBattle; //0x0118 + int8_t N00001BCA; //0x011C + int8_t N0003D211; //0x011D + uint16_t N0003D214; //0x011E + char pad_0120[4]; //0x0120 int totalStrength; float reform_point_x; float reform_point_y; - - + int32_t battleSide; //0x0130 + char pad_0134[16]; //0x0134 + int32_t battleAllianceOrSomething; //0x0144 + int32_t battleDifficulty; //0x0148 }; struct coords { @@ -1882,56 +2532,129 @@ struct factionTileStruct { int revealedTilesNumber; undefined field7_0x34[24]; }; + +struct factionEconomy +{ +public: + int32_t farmingIncome; //0x0000 + int32_t taxesIncome; //0x0004 + int32_t miningIncome; //0x0008 + int32_t tradeIncome; //0x000C + int32_t merchantIncome; //0x0010 + int32_t constructionIncome; //0x0014 + int32_t otherIncome1; //0x0018 + int32_t otherIncome2; //0x001C + int32_t diplomacyIncome; //0x0020 + int32_t tributesIncome; //0x0024 + int32_t adminIncome; //0x0028 + int32_t kingsPurseIncome; //0x002C + int32_t wagesExpense; //0x0030 + int32_t upkeepExpense; //0x0034 + int32_t constructionExpenseBuildings; //0x0038 + int32_t constructionExpenseField; //0x003C + int32_t recruitmentExpenseBuildings; //0x0040 + int32_t recruitmentExpenseMercs; //0x0044 + int32_t corruptionExpense; //0x0048 + int32_t diplomacyExpense; //0x004C + int32_t tributesExpense; //0x0050 + int32_t otherExpense1; //0x0054 + int32_t otherExpense2; //0x0058 + int32_t devastationExpense; //0x005C +}; //Size: 0x0060 + +struct battleFactionCounter +{ +public: + int32_t battlesWon; //0x0000 + int32_t battlesLost; //0x0004 + int32_t wonLostRatio; //0x0008 +}; //Size: 0x000C + //faction struct factionStruct { undefined field_0x0[180]; int dipNum; /* number of faction in diplomatic array */ int cultureID; char* ai_label; /* ai_label of faction */ - undefined field_0xc0[4]; + int32_t AILabelHash; //0x00C0 struct settlementStruct* capital; /* capital of the faction */ struct namedCharacter* leader; /* faction leader */ struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ - UINT32* ai_assistant; - undefined field_0xdc[20]; - UINT32 holdRegions; - undefined field_0xf4[4]; + struct aiFaction* AIFaction; //0x00D8 + int32_t AIPersonalityType; //0x00DC + int32_t AIPersonalityName; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct holdRegionsWinCondition* WinConditions; //0x00F0 + int32_t someInteger; //0x00F4 struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ - undefined field_0xfc[4]; + int32_t namedCharactersSize; //0x00FC int numOfCharactersAll; /* all characters, died, alive, etc */ struct general** characters; /* characters on stratmap */ - undefined field_0x108[4]; + int32_t charactersSize; //0x0108 int numOfCharacters; /* characters on stratmap */ struct stackStruct** stacks; - undefined field_0x114[4]; + int32_t armiesSize; //0x0114 int stackNum; int* regionsID; - undefined field_0x120[4]; + int32_t regionsSize; //0x0120 int regionsNum; struct settlementStruct** settlements; - undefined field_0x12c[4]; + int32_t settlementsSize; //0x012C int settlementsNum; struct fortStruct** forts; - undefined field_0x138[4]; + int32_t fortsSize; //0x0138 int fortsNum; struct watchTowerStruct** watchTowers; /* watchtowers */ - undefined field_0x144[4]; + int32_t watchtowersSize; //0x0144 int wathtowersNum; struct portBuildingStruct** portBuildings; /* port buildings */ - undefined field_0x150[4]; + int32_t portBuildingsSize; //0x0150 int portBuildingsNum; - undefined field_0x158[68]; + uint32_t neighBourFactionsBitmap; //0x0158 + int* neighBourRegions; //0x015C + int32_t neighBourRegionsSize; //0x0160 + int32_t neighBourRegionsNum; //0x0164 + char pad_0168[49]; //0x0168 + int8_t isUndiscovered; //0x0199 + char pad_019A[2]; //0x019A factionTileStruct* tilesFac; - undefined field_0x1a0[2208]; + struct mission** missions; //0x01A0 + int32_t missionsSize; //0x01A4 + int32_t missionCount; //0x01A8 + char pad_01AC[48]; //0x01AC + struct factionRanking* factionRankings; //0x01DC + int32_t factionRankingsSize; //0x01E0 + int32_t factionRankingsCount; //0x01E4 + char pad_01E8[24]; //0x01E8 + int32_t freezeFactionAI; //0x0200 + char pad_0204[2096]; //0x0204 + int32_t treasuryTurnStart; //0x0A34 + char pad_0A38[8]; //0x0A38 UINT32 religion; /* number of religion */ - undefined field_0xa44[84]; + undefined field_0xa44[16]; + int8_t isFactionExcommunicated; //0x0A54 + char pad_0A55[67]; //0x0A55 UNICODE_STRING** someString; UNICODE_STRING** localizedName; undefined field_0xaa0[76]; int money; /* money of the faction */ int KingsPurse; /* money of the faction */ + int32_t incomeDoubled; //0x0AF4 + struct factionEconomy factionEconomy[10]; //0x0AF8 + int32_t nextCounterEconomy; //0x0EB8 + int32_t counterEconomy; //0x0EBC + int32_t maxTurnsTillReset; //0x0EC0 + char pad_0EC4[16]; //0x0EC4 + struct battleFactionCounter(*battlesWonVsFaction)[31]; //0x0ED4 + int32_t factionCountStart; //0x0ED8 + int32_t otherFactionCount; //0x0EDC + int32_t battlesWon; //0x0EE0 + int32_t battlesLost; //0x0EE4 + int32_t settlementsCaptured; //0x0EE8 + int32_t settlementsLost; //0x0EEC + char pad_0EF0[24]; //0x0EF0 }; struct ModelDbEntry diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp index 91ca92ef..331b144d 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp @@ -61,3 +61,23 @@ void settlementHelpers::setGuildStanding(settlementStruct* sett, int index, int { *(int*)((sett->guildStandings) + 0x4 * index) = amount; } +settlementCapability* settlementHelpers::getSettlementCapability(settlementStruct* sett, int capabilityType) +{ + return &sett->settlementCapabilities[capabilityType]; +} +settlementCapability* settlementHelpers::getAgentCapability(settlementStruct* sett, int agentType) +{ + return &sett->settlementCapabilitiesAgent[agentType]; +} +settlementCapability* settlementHelpers::getAgentLimitCapability(settlementStruct* sett, int agentType) +{ + return &sett->settlementCapabilitiesAgentLimit[agentType]; +} +recruitmentCapability* settlementHelpers::getRecruitmentCapability(settlementStruct* sett, int index) +{ + return &sett->recruitmentCapabilities[index]; +} +settlementRecruitmentPool* settlementHelpers::getSettlementRecruitmentPool(settlementStruct* sett, int index) +{ + return &sett->recruitmentPools[index]; +} diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h index b610340a..c2861577 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h @@ -19,6 +19,11 @@ namespace settlementHelpers int getGuildStanding(settlementStruct* sett, int index); void setGuildStanding(settlementStruct* sett, int index, int amount); void changeSettlementName(settlementStruct* sett, const char* newName); + settlementCapability* getSettlementCapability(settlementStruct* sett, int capabilityType); + settlementCapability* getAgentCapability(settlementStruct* sett, int agentType); + settlementCapability* getAgentLimitCapability(settlementStruct* sett, int agentType); + recruitmentCapability* getRecruitmentCapability(settlementStruct* sett, int index); + settlementRecruitmentPool* getSettlementRecruitmentPool(settlementStruct* sett, int index); std::string getSettlementName(settlementStruct* sett); diff --git a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp index 8c524907..47bf8481 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp @@ -171,9 +171,9 @@ namespace unitHelpers { return nullptr; } - if (posData->targetArray[posData->targetsToGo].targetUnit) + if (posData->targetArray[posData->targetsDone].targetUnit) { - return posData->targetArray[posData->targetsToGo].targetUnit->target; + return posData->targetArray[posData->targetsDone].targetUnit->target; } return nullptr; }