Unified Prereqs (Community Patch for BNW)

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,713
Location
Near Portsmouth, UK
Spawned from posts #90 to #94 and #108 in the main "Community DLL for BNW" thread

Holy Grail 3: Unified Prerequisites.

Anything in the game : buildings, units, promotions, wonders ...(what did i forget) should have prerequisites that can be selected from any or all of technology, social policy, religious belief, wonder ... (i certainly forgot something)
Why not have a policy allow you to select a specific promotion, or a crusader promotion available only if some belief is in your main religion, or special units only available after you build a national wonder ... Currently some of those are only possible with lots of hacky Lua and dummy stuff.

While I'm against dummy stuff, I'm also against adding many new columns to tables - prereqTech, prereqBelief, prereqPolicy, prereqResolution, etc - as by definition these are singular so really should be added as secondary tables - Unit_PrereqTech, Unit_PrereqBelief, Unit_PrereqPolicy, etc - and I'm against adding those as they are limited by our current knowledge of the game (what happens when a modder adds "WonderFluff" and that becomes a prereq?). Especially when a few new Lua events - PlayerCanXyz/CityCanXyz - can handle all current and future possibilities.

From your "hacky" comment, what is also obviously needed (in addition to any new events) is an improved Lua API to make writing the code, not necessarily easier, but more pleasant - pPlayer:HasTech(), pPlayer:HasPolicy(), pPlayer:HasBelief(), etc.


The following are candidates for "things" that can / could have pre-reqs
  • Beliefs
  • Buildings
  • Builds
  • GoodyHuts
  • GreatWorks
  • Improvements
  • LeagueProjects
  • Policies
  • PolicyBranchTypes
  • Processes
  • Projects
  • Relations (war/peace)
  • Religions
  • Resolutions
  • Routes
  • Specialists
  • Technologies
  • UnitPromotions
  • Units

And those "things" which are / could be used as pre-reqs
  • Beliefs
  • Buildings (type and class)
  • Civilization
  • Eras
  • Features (forest, marsh, oasis, ice, etc to include fakes - lakes, rivers, etc)
  • Improvements
  • Plot (mountails, hills, flat, ocean)
  • Policies
  • PolicyBranchTypes
  • Projects
  • Relations (war/peace)
  • Religion (founded/enhanced)
  • Resolutions
  • Resource
  • Routes
  • Specialists
  • Technologies
  • Terrains (grass, plains, desert, snow, etc)
  • Trade Routes
  • UnitPromotions
  • Units (type and class)

Please post if you think anything has been missed off either list
 
Locating all current prereqs is non-trivial, as there is no consistent naming convention. Searching all the civ5*.xml core game files for "prereq", "require" and "needed" (and adding a few others I found) results in the following lists of ways to add prereqs via the database (XML/SQL)

Items prefixed with - are columns, without are tables; items in (brackets) are not used within the core game.

Units
  • - PrereqResources
  • - PrereqTech
  • - ProjectPrereq
  • - RequiresEnhancedReligion
  • Unit_BuildingClassRequireds
  • Unit_ResourceQuantityRequirements

UnitPromotions
  • - TechPrereq
  • - PromotionPrereq
  • - PromotionPrereqOr1 (thru 9)

Technologies
  • Technology_PrereqTechs
  • (Technology_ORPrereqTechs)

Routes
  • Route_ResourceQuantityRequirements

Resolutions
  • - TechPrereqAnyMember

Projects
  • - TechPrereq
  • - AnyonePrereqProject
  • - CultureBranchesRequired
  • Project_Prereqs
  • Project_ResourceQuantityRequirements

Processes
  • - TechPrereq

PolicyBranchTypes
  • - EraPrereq

Policies
  • - TechPrereq
  • Policy_PrereqPolicies
  • (Policy_PrereqORPolicies)

Improvements
  • - SpecificCivRequired
  • - RequiresFlatlands
  • - RequiresFlatlandsOrFreshWater
  • - RequiresFeature
  • - RequiresImprovement
  • - RequiresXAdjacentLand
  • Improvement_ResourceTypes
  • (Improvement_PrereqNatureYields)
  • Improvement_ValidImprovements

Builds
  • - PrereqTech

Buildings
  • - NearbyMountainRequired
  • - NearbyTerrainRequired
  • - (CitiesPrereq)
  • - (LevelPrereq)
  • - PrereqTech
  • Building_PrereqBuildingClasses
  • (Building_TechAndPrereqs)
  • Building_ClassesNeededInCity
  • Building_ResourceQuantityRequirements

Beliefs
  • - RequiresPeace

Due to the problems of locating prereqs, these lists are certainly not complete, but they do amply illustrate the scale of the task if an attempt was made to enable prereqs to be added via the database (there is a good reason why Firaxis only implement the parts/features they actually need!) Please don't bother posting updates for these lists, they aren't required.
 
GameEvents coverage - the left hand column should be the same as the "candidates list" (the top list) in post #1 (let me know if any got/get left off)

Player City Unit Plot Beliefs PlayerCanHaveBelief , ReligionCanHaveBelief Buildings PlayerCanConstruct CityCanConstruct Builds PlayerCanBuild GoodyHuts GoodyHutCanNotReceive , GoodyHutCanResearch GreatWorks UnitCanHaveGreatWork Improvements PlotCanImprove LeagueProjects PlayerCanPropose , PlayerCanMaintain CityCanMaintain Policies PlayerCanAdoptPolicy , PlayerCanAdoptTenet PolicyBranchTypes PlayerCanAdoptPolicyBranch , PlayerCanAdoptIdeology Processes PlayerCanMaintain CityCanMaintain Projects PlayerCanCreate CityCanCreate Relations PlayerCanDeclareWar , PlayerCanMakePeace Religions PlayerCanFoundPantheon , PlayerCanFoundReligion , GetReligionToFound Resolutions PlayerCanPropose Routes PlayerCanBuild Specialists PlayerCanPrepare CityCanPrepare Technologies PlayerCanEverResearch , PlayerCanResearch UnitPromotions UnitCanHavePromotion Units PlayerCanTrain CityCanTrain UnitCanHaveAnyUpgrade , UnitCanHaveUpgrade

Game Core
DLL - Various Mod Components (v51)
Proposed


GameEvents and parameters
Code:
GameEvents.[COLOR="Purple"]PlayerCanAdoptIdeology[/COLOR].Add(function(iPlayer, iIdeologyType) return true end)
GameEvents.[COLOR="Green"]PlayerCanAdoptPolicy[/COLOR].Add(function(iPlayer, iPolicyType) return true end)
GameEvents.[COLOR="green"]PlayerCanAdoptPolicyBranch[/COLOR].Add(function(iPlayer, iPolicyBranchType) return true end)
GameEvents.[COLOR="Purple"]PlayerCanAdoptTenet[/COLOR].Add(function(iPlayer, iTenetType) return true end)
GameEvents.[COLOR="purple"]PlayerCanBuild[/COLOR].Add(function(iPlayer, iUnit, iX, iY, iBuild) return true end)
GameEvents.[COLOR="Green"]PlayerCanConstruct[/COLOR].Add(function(iPlayer, iBuildingType) return true end)
GameEvents.[COLOR="green"]PlayerCanCreate[/COLOR].Add(function(iPlayer, iProjectType) return true end)
GameEvents.[COLOR="Purple"]PlayerCanDeclareWar[/COLOR].Add(function(iPlayer, iAgainstTeam) return true end)
GameEvents.[COLOR="green"]PlayerCanEverResearch[/COLOR].Add(function(iPlayer, iTechType) return true end)
GameEvents.[COLOR="purple"]PlayerCanFoundPantheon[/COLOR].Add(function(iPlayer) return true end)
GameEvents.[COLOR="Purple"]PlayerCanFoundReligion[/COLOR].Add(function(iPlayer, iCity) return true end)
GameEvents.[COLOR="purple"]PlayerCanHaveBelief[/COLOR].Add(function(iPlayer, iBelief) return true end)
GameEvents.[COLOR="green"]PlayerCanMaintain[/COLOR].Add(function(iPlayer, iProcessType) return true end)
GameEvents.[COLOR="Purple"]PlayerCanMakePeace[/COLOR].Add(function(iPlayer, iAgainstTeam) return true end)
GameEvents.[COLOR="green"]PlayerCanPrepare[/COLOR].Add(function(iPlayer, iSpecialistType) return true end)
GameEvents.[COLOR="Purple"]PlayerCanPropose[/COLOR].Add(function(iPlayer, iResolutionType, iChoice, bEnact) return true end)
GameEvents.[COLOR="green"]PlayerCanResearch[/COLOR].Add(function(iPlayer, iTechType) return true end)
GameEvents.[COLOR="green"]PlayerCanTrain[/COLOR].Add(function(iPlayer, iUnitType) return true end)

GameEvents.[COLOR="green"]CityCanConstruct[/COLOR].Add(function(iPlayer, iCity, iBuildingType) return true end)
GameEvents.[COLOR="green"]CityCanCreate[/COLOR].Add(function(iPlayer, iCity, iProjectType) return true end)
GameEvents.[COLOR="green"]CityCanMaintain[/COLOR].Add(function(iPlayer, iCity, iProcessType) return true end)
GameEvents.[COLOR="green"]CityCanPrepare[/COLOR].Add(function(iPlayer, iCity, iSpecialistType) return true end)
GameEvents.[COLOR="green"]CityCanTrain[/COLOR].Add(function(iPlayer, iCity, iUnitType) return true end)

GameEvents.[COLOR="Purple"]UnitCanHaveAnyUpgrade[/COLOR].Add(function(iPlayer, iUnit) return true end)
GameEvents.[COLOR="Purple"]UnitCanHaveGreatWork[/COLOR].Add(function(iPlayer, iUnit, iGreatWorkType) return true end)
GameEvents.[COLOR="Purple"]UnitCanHavePromotion[/COLOR].Add(function(iPlayer, iUnit, iPromotionType) return true end)
GameEvents.[COLOR="Purple"]UnitCanHaveUpgrade[/COLOR].Add(function(iPlayer, iUnit, iUnitClassType, iUnitType) return true end)

GameEvents.[COLOR="purple"]PlotCanImprove[/COLOR].Add(function(iX, iY, iImprovement) return true end)

GameEvents.[COLOR="purple"]ReligionCanHaveBelief[/COLOR].Add(function(iPlayer, iReligion, iBelief) return true end)
GameEvents.[COLOR="purple"]GetReligionToFound[/COLOR].Add(function(iPlayer, iPreferredReligion, bIsAlreadyFounded) return iPreferredReligion end)

GameEvents.[COLOR="Purple"]GoodyHutCanNotReceive[/COLOR].Add(function(iPlayer, iUnit, eGoody, bPick) return false end)
GameEvents.[COLOR="purple"]GoodyHutCanResearch[/COLOR].Add(function(iPlayer, eTech) return true end)

Current coverage is good, some new events will be needed - comments appreciated
 
Lua API methods - the left hand column should be the same as the "pre-reqs list" (the bottom list) in post #1 (let me know if any got/get left off)


The current Lua API is not user-friendly for writing prereq conditions - how many intermediate modders know that techs are common to the team and therefore not on the Player object, nor the Team object, but the TeamTech object - I still forget this!

Rather than analyse the current Lua API against a desired, consistent set of methods, I'm just going to come up with that set and then implement it - if there are "near duplicates" (eg pPlot:IsMountain() vs pPlot:IsMountains()) then so be it (at least the API is practically free - just consuming a few extra bytes on the hard disk / in memory)

Game. pPlayer: pCity: pUnit: pPlot: Beliefs AnyoneHasBelief() HasBelief() HasBelief()
Buildings (type and class) - including Wonders AnyoneHasBuilding(), AnyoneHasBuildingClass(), AnyoneHasAnyWonder(), AnyoneHasWonder() HasBuilding(), HasBuildingClass(), HasAnyWonder(), HasWonder() HasBuilding(), HasBuildingClass(), HasAnyWonder(), HasWonder()
Civilization GetCivilizationPlayer() IsCivilization() IsCivilization() IsCivilization() IsCivilization()
Eras AnyoneIsInEra(), AnyoneHasReachedEra() IsInEra(), HasReachedEra()
Features (forest, marsh, oasis, ice, etc to include fakes - lakes, rivers, etc) - including Natural Wonders AnyoneHasAnyNaturalWonder(), AnyoneHasNaturalWonder() HasAnyNaturalWonder(), HasNaturalWonder() HasFeature(), HasWorkedFeature(), HasAnyNaturalWonder(), HasNaturalWonder() IsOnFeature(), IsAdjacentToFeature(), IsWithinDistanceOfFeature() HasFeature(), IsNaturalWonder(), HasAnyNaturalWonder(), HasNaturalWonder(), IsXyz()
Improvements HasImprovement(), HasWorkedImprovement() IsOnImprovement(), IsAdjacentToImprovement(), IsWithinDistanceOfImprovement() HasImprovement()
Plot (mountains, hills, flat, ocean) HasPlotType(), HasWorkedPlotType() IsOnPlotType(), IsAdjacentToPlotType(), IsWithinDistanceOfPlotType() HasPlotType(), IsXyz()
Policies AnyoneHasPolicy(), AnyoneHasTenet() HasPolicy(), HasTenet()
PolicyBranchTypes AnyoneHasPolicyBranch(), AnyoneHasIdeology() HasPolicyBranch(), HasIdeology()
Projects AnyoneHasProject() HasProject()
Relations IsAtPeace(), IsAtPeaceWith(), IsAtWar(), IsAtWarWith()
Religion AnyoneHasPantheon(), AnyoneHasAnyReligion(), AnyoneHasReligion() HasPantheon(), HasAnyReligion(), HasReligion(), HasEnhancedReligion() HasAnyReligion(), HasReligion()
Resolutions IsResolutionPassed()
Resource HasResource(), HasWorkedResource() IsOnResource(), IsAdjacentToResource(), IsWithinDistanceOfResource() HasResource()
Routes IsConnectedTo() IsConnectedToCapital(), IsConnectedTo() HasRoute(), IsXyz()
Specialists HasSpecialistSlot(), HasSpecialist() HasSpecialistSlot(), HasSpecialist()
Technologies AnyoneHasTech() HasTech()
Terrains (grass, plains, desert, snow, etc) HasTerrain(), HasWorkedTerrain() IsOnTerrain(), IsAdjacentToTerrain(), IsWithinDistanceOfTerrain() HasTerrain(), IsXyz()
Trade Routes HasAnyDomesticTradeRoute(), HasAnyInternationalTradeRoute(), HasAnyTradeRoute(), HasAnyTradeRouteWith() HasAnyDomesticTradeRoute(), HasAnyInternationalTradeRoute(), HasTradeRouteToAnyCity(), HasTradeRouteTo(), HasTradeRouteFromAnyCity(), HasTradeRouteFrom()
UnitPromotions HasPromotion()
Units (type and class) AnyoneHasUnit(), AnyoneHasUnitClass() HasUnit(), HasUnitClass() IsUnit(), IsUnitClass()


Game.
  • bool AnyoneHasBelief(iBeliefType)
  • bool AnyoneHasBuilding(iBuildingType)
  • bool AnyoneHasBuildingClass(iBuildingClassType)
  • bool AnyoneHasAnyWonder()
  • bool AnyoneHasWonder(iBuildingType)
  • int GetCivilizationPlayer(iCivilizationType)
  • bool AnyoneIsInEra(iEraType)
  • bool AnyoneHasReachedEra(iEraType)
  • bool AnyoneHasAnyNaturalWonder()
  • bool AnyoneHasNaturalWonder(iFeatureType)
  • bool AnyoneHasPolicy(iPolicyType)
  • bool AnyoneHasTenet(iPolicyType)
  • bool AnyoneHasPolicyBranch(iPolicyBranchType)
  • bool AnyoneHasIdeology(iPolicyBranchType)
  • bool AnyoneHasProject(iProjectType)
  • bool AnyoneHasPantheon()
  • bool AnyoneHasAnyReligion()
  • bool AnyoneHasReligion(iReligionType)
  • bool IsResolutionPassed(iResolutionType, iChoice)
  • bool AnyoneHasTech(iTechType)
  • bool AnyoneHasUnit(iUnitType)
  • bool AnyoneHasUnitClass(iUnitClassType)

pPlayer:
  • bool HasBelief(iBeliefType)
  • bool HasBuilding(iBuildingType)
  • bool HasBuildingClass(iBuildingClassType)
  • bool HasAnyWonder()
  • bool HasWonder(iBuildingType)
  • bool IsCivilization(iCivilizationType)
  • bool IsInEra(iEraType)
  • bool HasReachedEra(iEraType)
  • bool HasAnyNaturalWonder()
  • bool HasNaturalWonder(iFeatureType)
  • bool HasPolicy(iPolicyType)
  • bool HasTenet(iPolicyType)
  • bool HasPolicyBranch(iPolicyBranchType)
  • bool HasIdeology(iPolicyBranchType)
  • bool HasProject(iProjectType)
  • bool IsAtPeace()
  • bool IsAtPeaceWith(iPlayer)
  • bool IsAtWar()
  • bool IsAtWarWith(iPlayer)
  • bool HasPantheon()
  • bool HasAnyReligion()
  • bool HasReligion(iReligionType)
  • bool HasEnhancedReligion()
  • bool IsConnectedTo(iPlayer)
  • bool HasSpecialistSlot(iSpecialistType)
  • bool HasSpecialist(iSpecialistType)
  • bool HasTech(iTechType)
  • bool HasAnyDomesticTradeRoute()
  • bool HasAnyInternationalTradeRoute()
  • bool HasAnyTradeRoute()
  • bool HasAnyTradeRouteWith(iPlayer)
  • bool HasUnit(iUnitType)
  • bool HasUnitClass(iUnitClassType)

pCity:
  • bool HasBelief(iBeliefType)
  • bool HasBuilding(iBuildingType)
  • bool HasBuildingClass(iBuildingClassType)
  • bool HasAnyWonder()
  • bool HasWonder(iBuildingType)
  • bool IsCivilization(iCivilizationType)
  • bool HasFeature(iFeatureType)
  • bool HasWorkedFeature(iFeatureType)
  • bool HasAnyNaturalWonder()
  • bool HasNaturalWonder(iFeatureType)
  • bool HasImprovement(iImprovementType)
  • bool HasWorkedImprovement(iImprovementType)
  • bool HasPlotType(iPlotType)
  • bool HasWorkedPlotType(iPlotType)
  • bool HasAnyReligion()
  • bool HasReligion(iReligionType)
  • bool HasResource(iResourceType)
  • bool HasWorkedResource(iResourceType)
  • bool IsConnectedToCapital()
  • bool IsConnectedTo(pCity)
  • bool HasSpecialistSlot(iSpecialistType)
  • bool HasSpecialist(iSpecialistType)
  • bool HasTerrain(iTerrainType)
  • bool HasWorkedTerrain(iTerrainType)
  • bool HasAnyDomesticTradeRoute()
  • bool HasAnyInternationalTradeRoute()
  • bool HasTradeRouteToAnyCity()
  • bool HasTradeRouteTo(pCity)
  • bool HasTradeRouteFromAnyCity()
  • bool HasTradeRouteFrom(pCity)

pUnit:
  • bool IsCivilization(iCivilizationType)
  • bool IsOnFeature(iFeatureType)
  • bool IsAdjacentToFeature(iFeatureType)
  • bool IsWithinDistanceOfFeature(iFeatureType, iDistance)
  • bool IsOnImprovement(iImprovementType)
  • bool IsAdjacentToImprovement(iImprovementType)
  • bool IsWithinDistanceOfImprovement(iImprovementType, iDistance)
  • bool IsOnPlotType(iPlotType)
  • bool IsAdjacentToPlotType(iPlotType)
  • bool IsWithinDistanceOfPlotType(iPlotType, iDistance)
  • bool IsOnResource(iResourceType)
  • bool IsAdjacentToResource(iResourceType)
  • bool IsWithinDistanceOfResource(iResourceType, iDistance)
  • bool IsOnTerrain(iTerrainType)
  • bool IsAdjacentToTerrain(iTerrainType)
  • bool IsWithinDistanceOfTerrain(iTerrainType, iDistance)
  • bool HasPromotion(iPromotionType)
  • bool IsUnit(iUnitType)
  • bool IsUnitClass(iUnitClassType)

pPlot:
  • bool IsCivilization(iCivilizationType)
  • bool HasFeature(iFeatureType)
  • bool IsNaturalWonder()
  • bool HasAnyNaturalWonder()
  • bool HasNaturalWonder(iFeatureType)
  • bool IsFeatureIce()
  • bool IsFeatureJungle()
  • bool IsFeatureMarsh()
  • bool IsFeatureOasis()
  • bool IsFeatureFloodPlains()
  • bool IsFeatureForest()
  • bool IsFeatureFallout()
  • bool IsFeatureAtoll()
  • bool IsFeatureLake()
  • bool IsFeatureRiver()
  • bool HasImprovement(iImprovementType)
  • bool HasPlotType(iPlotType)
  • bool IsPlotMountain()
  • bool IsPlotMountains()
  • bool IsPlotHill()
  • bool IsPlotHills()
  • bool IsPlotLand()
  • bool IsPlotOcean()
  • bool HasResource(iResourceType)
  • bool HasRoute(iRouteType)
  • bool IsRouteRoad()
  • bool IsRouteRailroad()
  • bool HasTerrain(iTerrainType)
  • bool IsTerrainGrass()
  • bool IsTerrainPlains()
  • bool IsTerrainDesert()
  • bool IsTerrainTundra()
  • bool IsTerrainSnow()
  • bool IsTerrainCoast()
  • bool IsTerrainOcean()
  • bool IsTerrainMountain()
  • bool IsTerrainMountains()
  • bool IsTerrainHill()
  • bool IsTerrainHills()

NOTE 1: Where Firaxis are inconsistent PLOT_MOUNTAIN (singular) vs PLOT_HILLS (plural) the methods are doubled up - IsPlotMountain(), IsPlotMountains(), IsPlotHill(), IsPlotHills()

Comments appreciated
 
What is the utility of "PlayerCanPrepare" and "CityCanPrepare"?

Probably a throw back to previous versions of the game - they are sent as a city tries to train a "specialist" - I've never actually seen them fire.
 
Also, what of Ideologies, given that they are no longer tied to PlayerCanAdoptPolicyBranch (IIRC)?

Actually Ideologies ARE PolicyBranches and Tenets ARE Policies

Ideologies have a value for "PurchaseByLevel", and Tenets have a value for "Level"

But there's certainly room for confusion, so perhaps explicit events are required - PlayerCanAdoptIdeology and PlayerCanAdoptTenet
 
Yes, but are they still controllable with PlayerCanAdoptPolicyBranch and PlayerCanAdoptPolicy? I've had some trouble in the past with manipulating them.

Not checked. But I do know that the AI logic to pick an Ideology is horribly hard-coded. It's also not possible to add extra ideologies due to the hard-coding.

If it's not possible to control them via events than that needs fixing as part of the Unified Prereqs, but general discussion on adding more ideologies and/or changing how the AI chooses from them would be better under the main Community Patch for BNW thread
 
Just to be sure, by "routes" you mean trade routes (domestic, foreign, both?) , not road improvements? Not sure how a plot can HasRoute() if it's a trade route.
This makes me think about city connections : pCity:IsConnectedToCapital() and pCity:IsRailroadConnectedToCapital() might be worthy candidates for prerequisites (not sure how much of the city connection stuff is hard coded). This includes connection with Rivers of course :)

Lua API methods - the left hand column should be the same as the "pre-reqs list" in post #1 (let me know if any got/get left off)
Don't see goody Huts in there. Not sure what API those could use but since you are asking (or maybe the "pre-reqs list" in post #1 means the second list, actually that would make more sense :hammer2:)
 
Just to be sure, by "routes" you mean trade routes

No. The XML/C++ meaning of routes, ie roads and rail (ROUTE_ROAD and ROUTE_RAILROAD)
 
Don't see goody Huts in there. Not sure what API those could use but since you are asking (or maybe the "pre-reqs list" in post #1 means the second list, actually that would make more sense :hammer2:)

Just edited post #3 (and #2) ...
same as the "pre-reqs list" (the bottom list) in post #1
 
This makes me think about city connections : pCity:IsConnectedToCapital() and pCity:IsRailroadConnectedToCapital() might be worthy candidates for prerequisites (not sure how much of the city connection stuff is hard coded). This includes connection with Rivers of course :)

There are already methods in C++ for city-to-city connections, so it would just be a matter of exposing those to Lua. The hard part is determining the type of connection - is city-harbour-harbour-rail-capital a rail connection to the capital or not? And there is already a library of Lua functions for determining arbitrary plot-to-plot connections.

(My river connection code hooks into the standard city-to-city checking code :p)
 
Post #1 and #4 updated for Trade Routes as a prereq

Post #4 updated for city-to-capital and city-to-city route connections
 
Post #1 and #3 updated for LeagueProjects - these are covered by Resolutions (PlayerCanPropose) and Processes (Player/CityCanMaintain)
 
Post #4 (Lua API methods table) updated to include IsOnXyz(), IsAdjacentToXyz() and IsWithinDistanceOfXyz() methods for Feature, PlotType, Resource and Terrain for Units - these should help modders who want to give units special abilities via temporary promotions when on or near something
 
I'm in the process of developing some C++ macros to make writing the Lua API extensions easier, currently untested

Code:
// LUA API wrappers
#define LUAAPIEXTN(method)	static int l##method(lua_State* L)
#define LUAAPIMETHOD(method) lua_pushcclosure(L, l##method, 0); lua_setfield(L, t, #method)
#define LUAAPIIMPL(object, method) int CvLua##object::l##method(lua_State* L) { return BasicLuaMethod(L, &Cv##object::##method); }
#define LUAAPIINLINE(method, hasMethod, type) inline bool ##method() const { return ##hasMethod(type); }

which would allow the following

CvPlot.h
Code:
bool HasFeature(FeatureTypes eFeature) const;
LUAAPIINLINE(IsForest, HasFeature, FEATURE_FOREST)

CvPlot.cpp
Code:
bool CvPlot::HasFeature() const
{
}

CvLuaPlot.h
Code:
LUAAPIEXTN(HasFeature);
LUAAPIEXTN(IsForest);

CvLuaPlot.cpp
Code:
void CvLuaCity::PushMethods(lua_State* L, int t)
{
  LUAAPIMETHOD(HasFeature);
  LUAAPIMETHOD(IsForest);
}

LUAAPIIMPL(Plot, HasFeature)
LUAAPIIMPL(Plot, IsForest)
 
Do you want me to add this to the list of things to fix?

If we made a list of all the badly coded areas of the DLL it would be a very long list. Anything on the list should be driven by a real need (preferably a modded actually wanting to do (interesting) stuff with the requested changes) and not just a list of "this is bad, I may want it some when, let's fix it" - I've lost count of all the things I've added to my own list to "fix" and then dropped by the wayside as I'd never actually write a mod that utilised them.
 
Top Bottom