BNW Patch Version 1.0.3.276 New Lua Hooks

Code:
(Hook) GameEvents.TeamSetEra(teamId, eEra);

do you think this means that the civ will get all the prerequisite techs for that era?

Events are notifications that something has happened / is about to happen within the game core, not a method to change the state of the game. TeamSetEra() informs you when a team has entered a new era, it cannot be used to force the team into that era.
 
Events are notifications that something has happened / is about to happen within the game core, not a method to change the state of the game. TeamSetEra() informs you when a team has entered a new era, it cannot be used to force the team into that era.

Oh yeah you are right, it was the "set" part that misled me XD
Thank you!
 
So from what I am seeing via a re-read of the new stuff and a review of modwiki API for GameEvents there's still nothing really for a Pre-Combat hook. I know there's a Events.RunCombatSim but I was under the impression it isn't really usable.
 
So from what I am seeing via a re-read of the new stuff and a review of modwiki API for GameEvents there's still nothing really for a Pre-Combat hook.

Only a sub-set of the events from my DLL source code were added, and the RED combat events were overlooked :(
 
Maybe I missed it or maybe I'm just dummer than the average ox, but do these new events also work for G&K ? I know the improvment GameEvents.BuildFinished does not for G&K, and am wondering if the GameEvents.CityConstructed will or will not fire for G&K.

I suspect the answer is not, which will be :mad: because my most popular mod could certainly use it for G&K. GameEvents.CityConstructed certainly made everything easier on me for BNW and "trapping" the turn when a wonder was constructed.
 
BNW G&K Vanilla
BuildFinished
CanDeclareWar CanDeclareWar CanDeclareWar
CanDisplaceCivilian
CanHaveAnyUpgrade CanHaveAnyUpgrade CanHaveAnyUpgrade
CanHavePromotion CanHavePromotion CanHavePromotion
CanHaveUpgrade CanHaveUpgrade CanHaveUpgrade
CanLoadAt CanLoadAt CanLoadAt
CannotParadropFrom CannotParadropFrom CannotParadropFrom
CanParadropFrom CanParadropFrom CanParadropFrom
CanPillage
CanRaze
CanRazeOverride CanRazeOverride CanRazeOverride
CanRebaseInCity CanRebaseInCity CanRebaseInCity
CanRebaseTo CanRebaseTo CanRebaseTo
CanSaveUnit
CanStartMission
CircumnavigatedGlobe CircumnavigatedGlobe CircumnavigatedGlobe
CityBoughtPlot CityBoughtPlot CityBoughtPlot
CityBuildingsIsBuildingSellable CityBuildingsIsBuildingSellable
CityCanAcquirePlot CityCanAcquirePlot CityCanAcquirePlot
CityCanBuyAnyPlot CityCanBuyAnyPlot CityCanBuyAnyPlot
CityCanBuyPlot CityCanBuyPlot CityCanBuyPlot
CityCanConstruct CityCanConstruct CityCanConstruct
CityCanCreate CityCanCreate CityCanCreate
CityCanMaintain CityCanMaintain CityCanMaintain
CityCanPrepare CityCanPrepare CityCanPrepare
CityCanTrain CityCanTrain CityCanTrain
CityCaptureComplete CityCaptureComplete CityCaptureComplete
CityConstructed CityConstructed CityConstructed
CityConvertsReligion CityConvertsReligion N/A
CityCreated CityCreated CityCreated
CitySoldBuilding CitySoldBuilding CitySoldBuilding
CityStrategyCanActivate
CityTrained CityTrained CityTrained
DeclareWar DeclareWar DeclareWar
DoResolveVictoryVote
EconomicStrategyCanActivate
GameCoreTestVictory GameCoreTestVictory GameCoreTestVictory
GameCoreUpdateBegin GameCoreUpdateBegin GameCoreUpdateBegin
GameCoreUpdateEnd GameCoreUpdateEnd GameCoreUpdateEnd
GatherPerTurnReplayStats GatherPerTurnReplayStats GatherPerTurnReplayStats
GetFounderBenefitsReligion GetFounderBenefitsReligion N/A
GetReligionToFound GetReligionToFound N/A
GetReligionToSpread GetReligionToSpread N/A
GetScenarioDiploModifier1 GetScenarioDiploModifier1
GetScenarioDiploModifier2 GetScenarioDiploModifier2
GetScenarioDiploModifier3 GetScenarioDiploModifier3
GoodyHutCanResearch GoodyHutCanResearch GoodyHutCanResearch
GoodyHutTechResearched GoodyHutTechResearched GoodyHutTechResearched
GreatPersonExpended GreatPersonExpended GreatPersonExpended
IsAbleToMakePeace IsAbleToMakePeace IsAbleToMakePeace
MakePeace MakePeace MakePeace
MilitaryStrategyCanActivate
MinorAlliesChanged MinorAlliesChanged
MinorFriendsChanged MinorFriendsChanged MinorFriendsChanged
NaturalWonderDiscovered NaturalWonderDiscovered NaturalWonderDiscovered
NuclearDetonation NuclearDetonation NuclearDetonation
PantheonFounded PantheonFounded N/A
ParadropAt ParadropAt ParadropAt
PlayerAdoptPolicy PlayerAdoptPolicy PlayerAdoptPolicy
PlayerAdoptPolicyBranch PlayerAdoptPolicyBranch PlayerAdoptPolicyBranch
PlayerCanAdoptPolicy PlayerCanAdoptPolicy PlayerCanAdoptPolicy
PlayerCanAdoptPolicyBranch PlayerCanAdoptPolicyBranch PlayerCanAdoptPolicyBranch
PlayerCanConstruct PlayerCanConstruct PlayerCanConstruct
PlayerCanCreate PlayerCanCreate PlayerCanCreate
PlayerCanEverResearch PlayerCanEverResearch PlayerCanEverResearch
PlayerCanFoundPantheon PlayerCanFoundPantheon N/A
PlayerCanFoundReligion PlayerCanFoundReligion N/A
PlayerCanMaintain PlayerCanMaintain PlayerCanMaintain
PlayerCanPrepare PlayerCanPrepare PlayerCanPrepare
PlayerCanResearch PlayerCanResearch PlayerCanResearch
PlayerCanTrain PlayerCanTrain PlayerCanTrain
PlayerCityFounded PlayerCityFounded
PlayerDoTurn PlayerDoTurn PlayerDoTurn
PlayerPreAIUnitUpdate PlayerPreAIUnitUpdate PlayerPreAIUnitUpdate
RebaseTo RebaseTo RebaseTo
ReligionEnhanced ReligionEnhanced N/A
ReligionFounded ReligionFounded N/A
SetAlly SetAlly SetAlly
SetPopulation SetPopulation SetPopulation
TeamMeet TeamMeet TeamMeet
TeamSetEra TeamSetEra TeamSetEra
TeamSetHasTech TeamSetHasTech TeamSetHasTech
TeamTechResearched TeamTechResearched TeamTechResearched
UiDiploEvent UiDiploEvent UiDiploEvent
UnitGetSpecialExploreTarget UnitGetSpecialExploreTarget UnitGetSpecialExploreTarget
UnitKilledInCombat UnitKilledInCombat UnitKilledInCombat
UnitPrekill UnitPrekill UnitPrekill
UnitPromoted UnitPromoted UnitPromoted
UnitSetXY UnitSetXY UnitSetXY
UnitUpgraded UnitUpgraded UnitUpgraded

AgentRansack plus Notepad++ plus MS-Excel is a powerful combination!
 
Oooooo....Shiney :) !!

Which raises the perrennial question wrt to Firaxis and expansions of why in the world they didn't make some of those (like BuildFinished) back-compatible to pre-BNW. Oh! That's right, they didn't need it before BNW.

plus whoward hadn't made it for them to , er, 'borrow'
 
plus whoward hadn't made it for them to , er, 'borrow'

Errrrmmmm ....

Code:
    <!-- Events sent by plots (v30) -->
    <!--   GameEvents.PlayerCanBuild.Add(function(iPlayer, iUnit, iX, iY, iBuild) return true end) -->
    <!--   GameEvents.PlotCanImprove.Add(function(iX, iY, iImprovement) return true end) -->
    <!--   GameEvents.PlayerBuilding.Add(function(iPlayer, iUnit, iX, iY, iBuild, bStarting) end) (v46) -->
    <!--   GameEvents.PlayerBuilt.Add(function(iPlayer, iUnit, iX, iY, iBuild) end) (v46) -->

but they already had,
Code:
GameEvents.BuildFinished.Add(function(iPlayer, iX, iY, iImprovement) end)
so didn't bother with those ;)
 
Out of curiosity, what does MilitaryStrategyCanActivate do?
 
Out of curiosity, what does MilitaryStrategyCanActivate do?

See TurnsRemaining.lua in both the "Scramble for Africa" and "Civil War" BNW scenarios
 
CityBoughtPlot doesn't return the plot co-ordinates of the tile when it is purchased with gold (returning instead the city co-ordinates) - though it does when with culture. So that's a pain - does anyone have any ideas how I might retrieve the plot X and Y when a tile is purchased with gold?
 
Only by caching all the tiles a city has at the start of the turn, and then working out which one got added.

If you're using my DLL I've fixed this in v67, if you're using the CPP DLL the fix is trivial

Spoiler :
Code:
	ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
	if (pkScriptSystem) 
	{
		CvLuaArgsHandle args;
		args->Push(getOwner());
		args->Push(GetID());
#if defined(MOD_BUGFIX_MINOR)
[COLOR="SeaGreen"]		args->Push(iPlotX);
		args->Push(iPlotY);[/COLOR]
#else
[COLOR="Red"]		args->Push(plot()->getX());
		args->Push(plot()->getY());[/COLOR]
#endif
		args->Push(true); // bGold
		args->Push(false); // bFaith/bCulture

		bool bResult;
		LuaSupport::CallHook(pkScriptSystem, "CityBoughtPlot", args.get(), bResult);
	}
 
Only by caching all the tiles a city has at the start of the turn, and then working out which one got added.

Yeah, I was worried as much. This is meant to be non-DLL, but I'll ask Gazebo to implement your fix regardless. Thanks for pointing it out.
 
CityBoughtPlot doesn't return the plot co-ordinates of the tile when it is purchased with gold (returning instead the city co-ordinates) - though it does when with culture. So that's a pain - does anyone have any ideas how I might retrieve the plot X and Y when a tile is purchased with gold?

Only by caching all the tiles a city has at the start of the turn, and then working out which one got added.

If you're using my DLL I've fixed this in v67, if you're using the CPP DLL the fix is trivial

Spoiler :
Code:
	ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
	if (pkScriptSystem) 
	{
		CvLuaArgsHandle args;
		args->Push(getOwner());
		args->Push(GetID());
#if defined(MOD_BUGFIX_MINOR)
[COLOR="SeaGreen"]		args->Push(iPlotX);
		args->Push(iPlotY);[/COLOR]
#else
[COLOR="Red"]		args->Push(plot()->getX());
		args->Push(plot()->getY());[/COLOR]
#endif
		args->Push(true); // bGold
		args->Push(false); // bFaith/bCulture

		bool bResult;
		LuaSupport::CallHook(pkScriptSystem, "CityBoughtPlot", args.get(), bResult);
	}

Yeah, I was worried as much. This is meant to be non-DLL, but I'll ask Gazebo to implement your fix regardless. Thanks for pointing it out.
You might ask DarkScythe if he had to do this as part of his Holo mod. I know he had a lot of code for tracking what plots belonged to who, did any change ownership, etc., but I am not sure if he has already written any lua-only code to keep track of this specific issue as part of that mod. Most of his code was written pre-latest-patch, so he might already have the lua-only code-methods worked out.
 
CityBoughtPlot doesn't return the plot co-ordinates of the tile when it is purchased with gold (returning instead the city co-ordinates) - though it does when with culture. So that's a pain - does anyone have any ideas how I might retrieve the plot X and Y when a tile is purchased with gold?

Haha, amusingly, I ran into, and asked about this same exact issue a couple months ago and was told the same thing -- it being a bug in the version of the code that Firaxis merged into the game.

You might ask DarkScythe if he had to do this as part of his Holo mod. I know he had a lot of code for tracking what plots belonged to who, did any change ownership, etc., but I am not sure if he has already written any lua-only code to keep track of this specific issue as part of that mod. Most of his code was written pre-latest-patch, so he might already have the lua-only code-methods worked out.

My method is nothing special, though.

Unfortunately, my code is not very elegant, since without the X/Y coordinates, it has to sort of brute-force it. It works for my needs, but it's sort of a roundabout method to get what JFD wants -- that being the X/Y coordinates of the plot.

However, Holo's system essentially works by hooking into Events.SerialEventCityInfoDirty and tracks 2 conditions: When the player has entered the "purchase plot" interface, and then if the player's Gold reserves have changed. This was pre-patch, and I will probably change it to use the new CityBoughtPlot event, even if it is bugged, as it allows me to avoid having to make those two checks (which in itself can be fooled.) Only thing giving me pause is that I'll still need to have that SerialEventCityInfoDirty function remain, because I need it to track when a player has re-assigned citizens, and to my knowledge, I'm not currently aware of any way to catch when that happens outside of using that event and rescanning each time to calculate bonuses.

Either way, once those conditions are triggered, I initiate a plot scan over the 36 plots around the City, and look for any plots of interest that don't already exist in a table of plot IDs that I persist via TableSaverLoader. If such a plot is found, I run whatever functions I need on that plot, and save the plot's ID into the aforementioned table.
 
Back
Top Bottom