Community Patch for BNW

OK, now i do have a question and it's an important one. How do you plan to document the changes you made to the API. With the modiki still messed up and the 2kgames wiki lost in the warp, we are close to no documentation on the existing API. Adding Lua events is great but if nobody knows they are there, all your hard work will be for nothing.

Is there an easy way to get all the API events, sort them by old/new, and put them in one place for reference? I'm not the best coder and C++ always scared me when i got too close, but maybe i can at least help you with this part.
Anybody knows how DonQuiche's bot works (or even what it actually is)?
 
Is there an easy way to get all the API events, sort them by old/new, and put them in one place for reference? I'm not the best coder and C++ always scared me when i got too close, but maybe i can at least help you with this part.

Because of the way I use macros for adding events/API this is trivial

All new events defined by my code
Code:
#define GAMEEVENT_AiOverrideChooseNextTech	"AiOverrideChooseNextTech",		"ib"
#define GAMEEVENT_AreaCanHaveAnyResource	"AreaCanHaveAnyResource",		"ii"
#define GAMEEVENT_CanDoCommand				"CanDoCommand",					"iiiiiiib"
#define GAMEEVENT_CanHaveAnyUpgrade			"CanHaveAnyUpgrade",			"ii"
#define GAMEEVENT_CanHavePromotion			"CanHavePromotion",				"iii"
#define GAMEEVENT_CanHaveUpgrade			"CanHaveUpgrade",				"iiii"
#define GAMEEVENT_CanLoadAt					"CanLoadAt",					"iiii"
#define GAMEEVENT_CanMoveInto				"CanMoveInto",					"iiiibb"
#define GAMEEVENT_CannotParadropFrom		"CannotParadropFrom",			"iiii"
#define GAMEEVENT_CanParadropFrom			"CanParadropFrom",				"iiii"
#define GAMEEVENT_CanRebaseInCity			"CanRebaseInCity",				"iiii"
#define GAMEEVENT_CanRebaseTo				"CanRebaseTo",					"iiiib"
#define GAMEEVENT_CircumnavigatedGlobe		"CircumnavigatedGlobe",			"i"
#define GAMEEVENT_CityBoughtPlot			"CityBoughtPlot",				"iiiibb"
#define GAMEEVENT_CityCanAcquirePlot		"CityCanAcquirePlot",			"iiii"
#define GAMEEVENT_CityConnected				"CityConnected",				"iiiiib"
#define GAMEEVENT_CityConnections			"CityConnections",				"ib"
#define GAMEEVENT_CityConstructed			"CityConstructed",				"iiibb"
#define GAMEEVENT_CityCreated				"CityCreated",					"iiibb"
#define GAMEEVENT_CityPrepared				"CityPrepared",					"iiibb"
#define GAMEEVENT_CitySoldBuilding			"CitySoldBuilding",				"iii"
#define GAMEEVENT_CityTrained				"CityTrained",					"iiibb"
#define GAMEEVENT_CustomMissionCompleted	"CustomMissionCompleted",		"iiiiiii"
#define GAMEEVENT_CustomMissionCameraTime	"CustomMissionCameraTime",		"iiiiiii"
#define GAMEEVENT_CustomMissionDoStep		"CustomMissionDoStep",			"iiiiiii"
#define GAMEEVENT_CustomMissionPossible		"CustomMissionPossible",		"iiiiiiiiib"
#define GAMEEVENT_CustomMissionStart		"CustomMissionStart",			"iiiiiii"
#define GAMEEVENT_CustomMissionSetActivity	"CustomMissionSetActivity",		"iiiiiii"
#define GAMEEVENT_CustomMissionTargetPlot	"CustomMissionTargetPlot",		"iiiiiii"
#define GAMEEVENT_CustomMissionTimerInc		"CustomMissionTimerInc",		"iiiiiii"
#define GAMEEVENT_DeclareWar				"DeclareWar",					"ii"
#define GAMEEVENT_GetBombardRange			"GetBombardRange",				"ii"
#define GAMEEVENT_GetReligionToFound		"GetReligionToFound",			"iib"
#define GAMEEVENT_GoodyHutCanNotReceive		"GoodyHutCanNotReceive",		"iiib"
#define GAMEEVENT_GoodyHutCanResearch		"GoodyHutCanResearch",			"ii"
#define GAMEEVENT_GoodyHutTechResearched	"GoodyHutTechResearched",		"ii"
#define GAMEEVENT_GreatPersonExpended		"GreatPersonExpended",			"iiiii"
#define GAMEEVENT_IsAbleToDeclareWar		"IsAbleToDeclareWar",			"ii"
#define GAMEEVENT_IsAbleToMakePeace			"IsAbleToMakePeace",			"ii"
#define GAMEEVENT_MakePeace					"MakePeace",					"ii"
#define GAMEEVENT_MinorAlliesChanged		"MinorAlliesChanged",			"iibii"
#define GAMEEVENT_MinorFriendsChanged		"MinorFriendsChanged",			"iibii"
#define GAMEEVENT_NaturalWonderDiscovered	"NaturalWonderDiscovered",		"iiiib"
#define GAMEEVENT_NuclearDetonation			"NuclearDetonation",			"iiibb"
#define GAMEEVENT_PantheonFounded			"PantheonFounded",				"iiii"
#define GAMEEVENT_ParadropAt				"ParadropAt",					"iiiiii"
#define GAMEEVENT_PlaceResource				"PlaceResource",				"iiiii"
#define GAMEEVENT_PlayerBuilding			"PlayerBuilding",				"iiiiib"
#define GAMEEVENT_PlayerBuilt				"PlayerBuilt",					"iiiii"
#define GAMEEVENT_PlayerCanBuild			"PlayerCanBuild",				"iiiii"
#define GAMEEVENT_PlayerCanFoundPantheon	"PlayerCanFoundPantheon",		"i"
#define GAMEEVENT_PlayerCanFoundReligion	"PlayerCanFoundReligion",		"ii"
#define GAMEEVENT_PlayerCanHaveBelief		"PlayerCanHaveBelief",			"ii"
#define GAMEEVENT_PlayerCanRaze				"PlayerCanRaze",				"ii"
#define GAMEEVENT_PlayerCanRemoveHeresy		"PlayerCanRemoveHeresy",		"iiii"
#define GAMEEVENT_PlayerCanSpreadReligion	"PlayerCanSpreadReligion",		"iiii"
#define GAMEEVENT_PlotCanImprove			"PlotCanImprove",				"iii"
#define GAMEEVENT_RebaseTo					"RebaseTo",						"iiii"
#define GAMEEVENT_ReligionCanHaveBelief		"ReligionCanHaveBelief",		"iii"
#define GAMEEVENT_ReligionEnhanced			"ReligionEnhanced",				"iiii"
#define GAMEEVENT_ReligionFounded			"ReligionFounded",				"iiiiiiii"
#define GAMEEVENT_TeamSetEra				"TeamSetEra",					"iib"
#define GAMEEVENT_TerraformingMap			"TerraformingMap",				"ii"
#define GAMEEVENT_TerraformingPlot			"TerraformingPlot",				"iiiiiiii"
#define GAMEEVENT_TileFeatureChanged		"TileFeatureChanged",			"iiiii"
#define GAMEEVENT_TileImprovementChanged	"TileImprovementChanged",		"iiiiib"
#define GAMEEVENT_TileOwnershipChanged		"TileOwnershipChanged",			"iiii"
#define GAMEEVENT_TileRouteChanged			"TileRouteChanged",				"iiiiib"
#define GAMEEVENT_UiDiploEvent				"UiDiploEvent",					"iiii"
#define GAMEEVENT_UnitCaptureType			"UnitCaptureType",				"iiii"
#define GAMEEVENT_UnitCreated				"UnitCreated",					"iiiii"
#define GAMEEVENT_UnitPrekill				"UnitPrekill",					"iiiiibi"
#define GAMEEVENT_UnitPromoted				"UnitPromoted",					"iii"
#define GAMEEVENT_UnitUpgraded				"UnitUpgraded",					"iiib"

All Lua API extensions are not in one place but can easily be found by searching for LUAAPIEXTN, eg

Code:
	static int lGetNewCityName(lua_State* L);
#if defined(MOD_API_LUA_EXTENSIONS)
	LUAAPIEXTN(IsCityNameValid);
#endif

	static int lInitUnit(lua_State* L);
	static int lInitUnitWithNameOffset(lua_State* L);
	static int lDisbandUnit(lua_State* L);
	static int lAddFreeUnit(lua_State* L);

	static int lChooseTech(lua_State* L);

#if defined(MOD_API_EXTENSIONS)
	LUAAPIEXTN(GetSpecificUnitType);
	LUAAPIEXTN(GetSpecificBuildingType);
#endif
 
Anybody knows how DonQuiche's bot works (or even what it actually is)?

Yes. It's written in Visual C# and requires T4, a component of Visual C# not in the free version (so I can't get it working)
 
Are we going to start a branch off the main repo and maintain it centrally or is this a case of everyone for themselves?

I only ask after seeing this idea has been floated a couple of times before and seems to have fallen by the wayside quite quickly each time. If there is at least a place where the work can reside so anyone can pick it up if we all 'fall off the perch', so to speak.

Although it does seem to be an added burden, if someone could at least provide a measure of control of the progress, this might not stall as it has before.

Mostly I was looking through this. Anyone know if @Hambil is still around and available? Likewise @Pazyryk & @S3rgeus, @Gedemon, there more the merrier.

In all the different attempts, it looks like @whoward69 is the one constant.
This means either he possesses an iron-like constitution for dealing with failure or perhaps it's all a ploy to make it fail so we fall back on the DLL - Various Mod Components.:mischief:
 
Pazyryk and Gedemon are still here somewhere working on their own mods (total conversion) and building their own dll for their mods. Not sure about the others.
There sure are elements of Gedemon's dll i think could fit into the community patch mostly some configurable stacking based on unit groups and code to choose the best defender (the stacking system whoward added is based on plot/plot improvement instead). Pazyryk works on a fantasy mod.
Now, i don't know if their code is modular. The modular system used by whoward makes it easy to enable/disable features as modders see fit, and is a great base for a community patch project. Lots of small changes is the goal, while other might be working on a big "one block" change.

There is already a git-hub repo for whoward's dll source code so i guess there will be one for the community patch as soon as it does have real code (or possibly whoward's modular dll will become the base of community patch at version 50).

The real hope here is that whoward and gazebo have been working together to integrate their codes into a single dll and building some community patch even before it actually got this name, they even recovered some abandon-ware code like SmartAI mod. The community patch just looks like a normal evolution.
 
There is a reason why my DLL is at version fifty and not version five - you eat an elephant one bite at a time. Much better to work on a small bit, get it working and incorporated into a playable mod than to go for the "big bang" (which takes years, if ever to complete).

This is why I've branched off the Unified Prereqs discussion - it is self-contained and achievable in a short time frame - which will give the overall project a success and (hopefully) some traction/visibility.

V50 includes all of the CivIV Diplo Features v10.3 (Putmalk) and CSD v23 (Gazebo) code. It also includes most of Smart AI (more to come in v51) (Ninakoru), some of the events from RED (Gedemon). and the "No More Traffic Jams" code from Ea (Pazyryk). All in modular format.

I'm also a great believer in "show don't tell" - don't bother writing a style guide, just write good code yourself, and then document how to do it and what the benefits are. Doesn't always work, but works a whole lot better than "do as I say, don't do as I do"

Gedemon's GitHub was set up with the intent to be the "community" repository - which is why I branched my DLL from it (and didn't just replicate it). Code merging is taking longer and longer - Smart AI was not written with merging in mind and consequently took weeks (in fact the only reason I've gone back to it is because it has been abandoned and I now have no need to maintain compatibility with a potential version 2). CSD has gone from hours to days - mainly because it has branched away from CS into just D and is starting to conflict with the CivIV Diplo mod code.

I have no issues with my DLL being used as the base, but the one thing I'm not going to do is be the "code guardian" (partly because I hate the job, but also because I use SVN and not Git at work so have zero experience at that side of Git)
 
There is a reason why my DLL is at version fifty and not version five - you eat an elephant one bite at a time. Much better to work on a small bit, get it working and incorporated into a playable mod than to go for the "big bang" (which takes years, if ever to complete).

CSD has gone from hours to days - mainly because it has branched away from CS into just D and is starting to conflict with the CivIV Diplo mod code.

I have no issues with my DLL being used as the base, but the one thing I'm not going to do is be the "code guardian" (partly because I hate the job, but also because I use SVN and not Git at work so have zero experience at that side of Git)

Sorry about CSD, though I think it is fair to say that some of my latest changes have improved the WC AI quite a bit. I'm going to look through the CSD code to see what fits in with the Community Patch and what is genuinely CSD-specific, and change the #if defined tags as such. Also, now that everything is merged as of v23, I'm going to stop pushing out an independent dll for CSD and instead just use your combined dll with CSD. This will, ideally, make it easier for me to see where there is overlap, and possibly also make integration easier for you. I doubt there will be many more significant dll changes to CSD, as I have finished all of the checkboxes on my 'to-do' list that I made last year. Anything I do now will either be pushed directly into the Community Patch or spun-off as a new mod (I will probably spin off the advanced settlers and difficulty mods, for example, and make a 'pure' version of CSD).

I also don't want you to feel like a 'code guardian.' You do an excellent job, but it is a thankless task, and one you shouldn't be asked to do unless by your own choice.

As far as hosting the dll, the combined dll is the base of this patch. So many important tweaks and changes are already included, and it is by-far the most comprehensive DLL out there. The more quality, bug-free, and modular additions we can integrate into it, the better.

I only ask after seeing this idea has been floated a couple of times before and seems to have fallen by the wayside quite quickly each time. If there is at least a place where the work can reside so anyone can pick it up if we all 'fall off the perch', so to speak.

I know it is easy to say this now, but don't worry too much about this task not being completed. If my track record says nothing else, when I say I'm going to do a project, I don't flake out. The tasks outlined on pg. 1 of this thread (aside from the Holy Grails) are all very attainable goals. Plus, since most of the changes are 'fixes' or simply function additions, there will be much less 'balance testing' time than, say, with CSD's dll changes. I've already got working models for a few of the to-do points, I just haven't exposed them to the wild yet.

Whoward is currently working on the unified pre-req table, which is fantastic, and also assures me that he and I aren't tackling the same points on the to-do list. That said, if anyone else has a point or two they want to start working on, notify me here and I'll update the list (that way duplicate work isn't happening).

I've got a bit of company staying with me this week, so my work is going a bit slower at present, but it is moving along. I'll keep posting updates here, and, as I said, if anyone else wants to jump in and/or needs help solving a problem, post away! Glad to help. Heaven knows I need to pay the infinite help whoward has given me forward. :)

Cheers,
G

Edit: Also, I was thinking last night about a function that might be a fun addition. Would there be any interest in building a table of additional 'gifts' that could be given to players upon meeting CSs? I know whoward has a mod that does this with yields, however what if, in addition to that, we were able to take the 'Goody Hut' gifts (like advanced techs) and have CSs give those out to the first player that meets them? It makes marginally more sense to get free tech/advanced weapons/citizens etc. from CSs than from 'ruins of ancient civilizations.' Thoughts?
 
That's not a bad idea, does make more sense to get 'advanced' tech from current civilizations (though minor) than some long dead one. +1 from me.

Just to be clear, I wasn't proposing @whoward take on the role of guardian, though that would be good.:D No, I fully appreciate the thankless nature of this sort of thing. It was just a case of doing a bit of background research and going, "oh oh, we've been here before".

At the risk of becoming some sort of sycophant let me state again, I have nothing but admiration for the work you all have done, and continue to do. Bravo to all!:hatsoff:

Now, one thing I was discussing with Thalassicus before he went MIA was the settler city site selection function.
He made mention of CvCitySiteEvaluator::plotFoundValue() in CvSiteEvaluationClasses.cpp and said the multiplier on 'owned tiles' of 2/3 was changed to 1/4 in the expansions and this forces settlers to choose distant tiles, often useless 1 or 2 tile islands.

He also mentioned the AI doesn't do an adequate check for chokepoints between mountains or land bridges.

I'll quote him:
It appears the classic multiplier on owned tiles was 2/3, much more reasonable. They dropped it drastically to 1/4 in G&K. I don't know why they did this, and it explains why AI settlement patterns got so bad after that point.

I've never been able to fix this problem. I recognized it even before they released the source code, but looking at the code confirms it.

The sad thing is most of the rest of the AI settlement code is good. It's just this one critical hardcoded mistake that breaks everything.

The other mistake I see is in chokepoint detection. They didn't even try searching for chokepoints; they just add 5 to the city value for each mountain within 2 tiles. That finds clusters of mountains, not chokepoints, and they didn't even try to search for land bridges (single land tiles separating two bodies of water). This is disappointing but not surprising. Chokepoint detection has been a problem with the AI for over twenty years of Civilization games. I wonder why they never taught the AI to find chokepoints? It would only take five hours of work, at most, and if they'd done it back in the 90s then we'd have had two decades of better AIs.

It really baffles me when game companies don't spend a small amount of time on something that has such a dramatic impact on the game, like AIs finding chokepoints.

I can't see this has been changed in any of the combined DLL code, is there weight to this argument about site selection?
 
Now, one thing I was discussing with Thalassicus before he went MIA was the settler city site selection function.

I can't see this has been changed in any of the combined DLL code, is there weight to this argument about site selection?

I'm actually working on settler stuff at the moment. Trying to teach the AI to weigh the strength of neighbors before settling next to them, and to 'fill in strategic gaps' a bit more intelligently. I'll look at this issue and see what I can find.

I also spent some time this evening integrating a dynamic luxury value system based on the amount of luxuries each player in the deal has. It is much more granular.
G
 
Edit: Also, I was thinking last night about a function that might be a fun addition. Would there be any interest in building a table of additional 'gifts' that could be given to players upon meeting CSs? I know whoward has a mod that does this with yields, however what if, in addition to that, we were able to take the 'Goody Hut' gifts (like advanced techs) and have CSs give those out to the first player that meets them? It makes marginally more sense to get free tech/advanced weapons/citizens etc. from CSs than from 'ruins of ancient civilizations.' Thoughts?
If you're talking about just adding the option to do that, I'm in favor, but I would not want to play with that option on myself. Seems too easy. At least with ruins you have to walk directly to the tile.
 
Just to be clear, I wasn't proposing @whoward take on the role of guardian,

I didn't read/take it that your were. I was just drawing my own line in the sand before anyone did.
 
the multiplier on 'owned tiles' of 2/3 was changed to 1/4 in the expansions

(Not that I'm saying you are, but ...)

Please, let's not have any discussions about what one hard-coded value should be "balanced" to by re-hard-coding it.

Just push any and all of these into the database/XML - see http://forums.civfanatics.com/showthread.php?t=516108

In fact, that's probably Holy Grail 4 "remove all hard-coded values Firaxis left in" - you can find these by searching (usually) for "todo.*anton" or "todo.*xml". It's easy coding work (especially if you use the macros given in that tutorial) just incredibly tedious.
 
I was actually asking if that line of discussion was worth picking up, but, yeah I get the reminder.

May I ask, by "It's easy coding work" do you mean 'easy' for someone with a background of programming or 'easy' for anyone with a modicum of intelligence and some basic coding ability?


Edit: Pointless question, I might as well ask do you like chocolate!

Maybe that's the thing I could look into when I get back. Leave the tedious work to us grunts, while the more difficult tasks can be tackled by those more skilled.

I will look at that [DLL/C++] Replacing hard-coded constants with database values posting now.
 
All Lua API extensions are not in one place but can easily be found by searching for LUAAPIEXTN
OK, so just to be sure.
Code:
  E:\GitHub\Civ5-DLL\CvGameCoreDLL_Expansion2\Lua\CvLuaCity.h (21 hits)
	Line 118: 	LUAAPIEXTN(GetProcessProductionTurnsLeft);
	Line 169: 	LUAAPIEXTN(IsAddsFreshWater);
	Line 186: 	LUAAPIEXTN(GetNumBuildingClass);
	Line 187: 	LUAAPIEXTN(IsHasBuildingClass);
	Line 256: 	LUAAPIEXTN(GetTourismRateModifier);
	Line 257: 	LUAAPIEXTN(ChangeTourismRateModifier);
	Line 307: 	<snip>
Those are in CvLuaCity so they belong to the city object and will be called by eg :

int pCity:GetProcessProductionTurnsLeft(ProcessType)
bool pCity:IsAddsFreshWater()
int pCity:getNumBuildingClass(BuildingType)
 
May I ask, by "It's easy coding work" do you mean 'easy' for someone with a background of programming or 'easy' for anyone with a modicum of intelligence and some basic coding ability?

The latter - all the required details, including a worked example, are in that tutorial.

The hardest part will be coming up with a consistent naming convention for all the new entries in the global defines table.
 
Those are in CvLuaCity so they belong to the city object

Correct.

What we really need is some way to document any parameters to the methods in the LUAAPIEXTN macro - let me think about that.

EDIT:

Looks like I can set the macro up in such a way that the following is possible

CvLuaCity.h
Code:
LUAAPIEXTN(GetNumBuildingClass, int, iBuildingClassType);
LUAAPIEXTN(IsHasBuildingClass, bool, iBuildingClassType);
LUAAPIEXTN(GetTourismRateModifier, int);
LUAAPIEXTN(ChangeTourismRateModifier, void, iChange);

which would translate to
Code:
local iValue = pCity:GetNumBuildingClass(iBuildingClassType)

if (pCity:IsHasBuildingClass(iBuildingClassType)) then ... end

local iValue = pCity:GetTourismRateModifier()
pCity:ChangeTourismRateModifier(iChange)
 
V50 includes all of the CivIV Diplo Features v10.3 (Putmalk) and CSD v23 (Gazebo) code. It also includes most of Smart AI (more to come in v51) (Ninakoru), some of the events from RED (Gedemon). and the "No More Traffic Jams" code from Ea (Pazyryk). All in modular format.

Wait. You said your DLL compilation does NOT work with Smart AI (there are heavy AI bugs) o_o

"More of Smart AI to come in v51"??
 
Wait. You said your DLL compilation does NOT work with Smart AI (there are heavy AI bugs) o_o

"More of Smart AI to come in v51"??

A bit of semantics – it does not work with Smart AI, because it includes the bits of Smart AI that function correctly already.

The hardest part will be coming up with a consistent naming convention for all the new entries in the global defines table.

I've used 'COMMUNITY_' as the start of my database updates thus far. I can change this easily if the group desires something else.
G
 
Top Bottom