[DLL] Missing Lua methods

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,697
Location
Near Portsmouth, UK
As I come across "missing" Lua methods I'm adding them to my DLL mod (version 32/33a), feel free to post any others you may have come across and I'll try to add them

(These can be located in the code by searching CvLua*.h for "LUAAPIEXTN")

Game
  • bool IsInSomeReligion(eBelief)
  • [] GetAvailablePantheonBeliefs(ePlayer=NO_PLAYER)
  • [] GetAvailableFounderBeliefs(ePlayer=NO_PLAYER, eReligion=NO_RELIGION)
  • [] GetAvailableFollowerBeliefs(ePlayer=NO_PLAYER, eReligion=NO_RELIGION)
  • [] GetAvailableEnhancerBeliefs(ePlayer=NO_PLAYER, eReligion=NO_RELIGION)
  • [] GetAvailableBonusBeliefs(ePlayer=NO_PLAYER, eReligion=NO_RELIGION)
  • [] GetAvailableReformationBeliefs(ePlayer=NO_PLAYER, eReligion=NO_RELIGION)
  • void EnhancePantheon(ePlayer, eBelief)
  • bool IsAchievementUnlocked(iAchievement)
  • int GetSteamStat(iSteamStat)
  • int CreateGreatWork(eGreatWorkType, ePlayer, eEra, sCreator)
  • [] GetTradeRoute(iRouteIndex) [[see Player:GetTradeRoutes() for details of fields in return structure]]
  • void ReloadGameDataDefines() [[forces the cached <Defines> values to be reloaded (useful if you've changed them via DB.Query())]]
  • void ReloadCustomModOptions() [[forces the cached <CustomModOptions> to be reloaded]]

Team
  • int GetCityWorkingChange()
  • bool IsCityWorkingChange()
  • void ChangeCityWorkingChange(iChange)
  • bool HasSpyAtTeam(eTeam)

Player
  • bool IsPlotConnectedToPlot(pFromPlot, pToPlot)
  • int GetMaxStockpile()
  • void DoSwapGreatWorks(eFocusYield)
  • BeliefTypes[] GetBeliefsInPantheon()
  • int GetCityWorkingChange()
  • void ChangeCityWorkingChange(iChange)
  • void DismissNotification(iIndex, bUserInvoked)
  • int GetPolicyConversionModifier(ePolicyType)
  • void EspionageCreateSpy()
  • void EspionagePromoteSpy(iSpyIndex)
  • void EspionageSetPassive(iSpyIndex, bPassive)
  • void EspionageSetOutcome(iSpyIndex, iSpyResult, bAffectsDiplomacy)
  • [] GetEspionageSpies() [[returns additional field; Passive(bool)]]
  • [] GetPotentialInternationalTradeRouteDestinationsFrom(pUnit, pCity) [[See GetPotentialInternationalTradeRouteDestinations for return details]]
  • UnitType GetTradeUnitType() [[bug ignoring civ specific units has been fixed]]
  • [] GetTradeRoutes() [[returns additional fields; UnitID(int), IsRecalled(bool), CircuitsCompleted(int), CircuitsToComplete(int), MovingForward(bool)]]

City
  • int GetProcessProductionTurnsLeft(eProcess)
  • bool IsAddsFreshWater()
  • int GetNumBuildingClass(eBuildingClass)
  • bool IsHasBuildingClass(eBuildingClass)
  • int GetTourismRateModifier()
  • void ChangeTourismRateModifier(iChange)
  • int GetNumGreatWorks(bIgnoreYield=true)
  • void GetCityWorkingChange(iChange)
  • void ChangeCityWorkingChange(iChange)
  • int GetBaseYieldRateFromGreatWorks(eYield)
  • int iRange, bool bIndirect GetBombardRange()
  • void SetNumFreeBuilding(eBuilding)
  • bool HasDiplomat(ePlayer)
  • bool HasSpy(ePlayer)
  • bool HasCounterSpy()
  • int GetCounterSpy()
  • int GetBuildingConversionModifier(eBuilding)
  • int GetBuildingGlobalConversionModifier(eBuilding)

Unit
  • void RebaseAt(iPlotX, iPlotY)
  • bool CanPlunderTradeRoute(pPlot)
  • bool PlunderTradeRoute()
  • bool CanCreateGreatWork(pPlot)
  • bool CreateGreatWork()
  • bool CanUpgradeInTerritory(bTestVisible=false)
  • UnitCombatTypes GetUnitPromotionType()
  • int GetTradeRouteIndex()
  • bool IsRecalledTrader()
  • void RecallTrader(bImmediate)
  • bool IsHoveringUnit()
  • bool IgnoreTerrainDamage()
  • bool IgnoreFeatureDamage()
  • bool ExtraTerrainDamage()
  • bool ExtraFeatureDamage()
  • bool CanCrossMountains()
  • bool CanCrossOceans()
  • bool CanCrossIce()
  • int GetExtraReconRange()
  • bool IsTerrainHalfMove(eTerrain)
  • bool IsFeatureHalfMove(eFeature)
  • void SetReligion(eReligionType)
  • void SetConversionStrength(iStrength)
  • int GetConversionStrength(pCity=nil)
  • void SetSpreadsLeft(iSpreads)

Plot
  • int GetTurnDamage(bIgnoreTerrainDamage, bIgnoreFeatureDamage, bExtraTerrainDamage, bExtraFeatureDamage)
  • bool IsAdjacentToIce()
  • bool IsFriendlyCityOrPassableImprovement(pUnit, bCheckImprovement)
  • int GetUnitLimit()
  • int GetIndex() [[deprecated, use GetPlotIndex() instead]]
  • int ePlayer, int iCity GetOwner()
  • bool IsTerraFirma(pUnit)
  • void ChangeVisibilityCount(eTeam, iChange, eSeeInvisibleType, bInformExplorationTracking, bAlwaysSeeInvisible) [[bug with iChange has been fixed]]
 
unit:SetReligion()

There's also

pUnit:SetReligiousStrength(iReligiousStrength)
pUnit:SetSpreadsLeft(iSpreadsLeft)

in that trinity
 
I know I'm not adding anything here but I'm sure I ran across several missing Lua functions that haven't been mentioned but I can't remember what they where. Getting old sucks, I'm lucky if I remember what I had for breakfast. :lol:

I'll try to look for them...
 
GetCitiesLost() brings nothing up. Had presumed it to return a number value.

Works for me

Code:
> Players[2]:GetCitiesLost()
0
 LeaderHeadRoot: Handling LeaderMessage: 0, Greetings.
 DiscussionDialog: DiploUIStateTypes.DIPLO_UI_STATE_WAR_DECLARED_BY_HUMAN
 DiscussionDialog: DiploUIStateTypes.DIPLO_UI_STATE_WAR_DECLARED_BY_HUMAN NOT activated in DiscussionDialog
 LeaderHeadRoot: Handling LeaderMessage: 1, I will not hesitate to punish you for making such a foolish move.
 CityBannerManager: CityBanner CombatBegin
 CityBannerManager: CityBanner CombatEnd
> Players[2]:GetCitiesLost()
1
 
Works for me

Code:
> Players[2]:GetCitiesLost()
0
 LeaderHeadRoot: Handling LeaderMessage: 0, Greetings.
 DiscussionDialog: DiploUIStateTypes.DIPLO_UI_STATE_WAR_DECLARED_BY_HUMAN
 DiscussionDialog: DiploUIStateTypes.DIPLO_UI_STATE_WAR_DECLARED_BY_HUMAN NOT activated in DiscussionDialog
 LeaderHeadRoot: Handling LeaderMessage: 1, I will not hesitate to punish you for making such a foolish move.
 CityBannerManager: CityBanner CombatBegin
 CityBannerManager: CityBanner CombatEnd
> Players[2]:GetCitiesLost()
1

I'm probably not using it correctly... :mischief:
 
plot:GetMapIndex()

I was thinking more in terms of "methods that are on the C++ objects but not exposed to Lua" than writing completely new methods

Presumably index is the standard Y * mapWidth + X calculation
 
V12 of my DLL mod will include the ones in the updated OP - should be online over the weekend
 
The ReloadGameDataDefines() method looks like it will be REALLY helpful for what I want to do. However I've been away from Civ5 modding for several weeks and my aging memory is already failing me. What exactly will this affect? Anything accessed like this: GameDefines.xxx? More, less, something different?
 
The ReloadGameDataDefines() method looks like it will be REALLY helpful for what I want to do. However I've been away from Civ5 modding for several weeks and my aging memory is already failing me. What exactly will this affect? Anything accessed like this: GameDefines.xxx? More, less, something different?

It reloads everything from the <Defines> table, which is 95% of GameDefines. (3% of GameDefines comes from PostDefines and 2% from some hard coded values - like MaxMajors and MaxPlayers - that get shoved in there.)
 
Thanks for the reply whoward69. The ReloadGameDataDefines() will be a great addition. Looking forward to version 13 (I assume that's the version that will include this feature - haven't tried your dll mod yet). I know this is a little early but are you planning on update\ing your dll mod when the new expansion comes out. If I make my mod dependent on your dll - that would be important.
 
but are you planning on update\ing your dll mod when the new expansion comes out. If I make my mod dependent on your dll - that would be important.

That will very much depend on Firaxis. If they don't release the source code (anyone seen the code for patch 44 yet?) ...

I suspect there'll be a "Some Minor DLL mods for BNW" mod at some point. The way I have the code altered I can port the easy changes and leave the harder (path-finding) ones out from an initial release. Fortunately, flushing the GameDefines cache is about the easiest mod you can make for the DLL
 
That's if they bother to improve it at all. :)

More a case that if they make any chages at all to that code, merging my changes back in will be a nightmare!
 
Top Bottom