BNW Patch Version 1.0.3.276 New Lua Hooks

Pouakai

It belongs in a museum.
Moderator
Joined
Jun 16, 2010
Messages
7,190
Location
Aotearoa
As part of the new patch, it seems a bunch of new Lua hooks were included as an undocumented addition. These are:

(TestAll) GameEvents.CanHaveAnyUpgrade(ownerId, unitId);
(TestAll) GameEvents.CanHavePromotion(ownerId, unitId, ePromotion);
(TestAll) GameEvents.CanHaveUpgrade(ownerId, unitId, eUpgradeUnitClass, eUpgradeUnitType);
(TestAll) GameEvents.CannotParadropFrom(ownerId, unitId, targetX, targetY)
(TestAny) GameEvents.CanLoadAt(ownerId, unitId, targetX, targetY)
(TestAny) GameEvents.CanParadropFrom(ownerId, unitId, targetX, targetY)
(TestAny) GameEvents.CanRebaseInCity(ownerId, unitId, cityX, cityY);
(TestAny) GameEvents.CanRebaseTo(ownerId, unitId, toX, toY);
(Hook) GameEvents.CircumnavigatedGlobe(teamId);
(Hook) GameEvents.CityBoughtPlot(ownerId, cityId, plotX, plotY, bGold, bFaithOrCulture);
(TestAll) GameEvents.CityCanAcquirePlot(ownerId, cityId, plotX, plotY);
(Hook) GameEvents.CityConstructed(ownerId, cityId, buildingType, bGold, bFaithOrCulture);
(Hook) GameEvents.CityCreated(ownerId, cityId, projectType, bGold, bFaithOrCulture);
(Hook) GameEvents.CitySoldBuilding(playerId, cityId, eBuilding);
(Hook) GameEvents.CityTrained(ownerId, cityId, unitId, bGold, bFaithOrCulture);
(Hook) GameEvents.DeclareWar(teamId, otherTeamId);
(AccumInt) GameEvents.GetReligionToFound(ePlayer, eCivDefaultReligion, bCivDefaultReligionFounded)
(Hook) GameEvents.GreatPersonExpended(playerId, eGreatPersonType);
(TestAll) GameEvents.GoodyHutCanResearch(playerId, eTech);
(Hook) GameEvents.GoodyHutTechResearched(playerId, eTech);
(TestAll) GameEvents.IsAbleToMakePeace(playerId, toTeamId);
(Hook) GameEvents.MakePeace(teamId, otherTeamId);
(Hook) GameEvents.MinorAlliesChanged(minorplayerId, playerId, bIsAllies, iOldFriendship, iNewFriendship);
(Hook) GameEvents.MinorFriendsChanged(minorPlayerId, playerId, bIsFriends, iOldFriendship, iNewFriendship);
(Hook) GameEvents.NaturalWonderDiscovered(eTeam, eFeatureType, plotX, plotY, bFirst);
(Hook) GameEvents.NuclearDetonation(AttackerPlayerId, PlotX, PlotY, bDeclareWar, bBystander)
(Hook) GameEvents.RebaseTo(ownerId, unitId, toX, toY);
(Hook) GameEvents.ReligionEnhanced(ePlayer, eReligion, eBelief1, eBelief2);
(Hook) GameEvents.ReligionFounded(ePlayer, holyCityId, eReligion, eBelief1, eBelief2, eBelief3, eBelief4, eBelief5);
(Hook) GameEvents.ParadropAt(ownerId, unitId, fromX, fromY, toX, toY);
(Hook) GameEvents.PantheonFounded(ePlayer, capitalCityId, eReligionPantheon, eBelief)
(TestAll) GameEvents.PlayerCanFoundPantheon(ePlayer);
(TestAll) GameEvents.PlayerCanFoundReligion(playerId, cityId);
(Hook) GameEvents.TeamSetEra(teamId, eEra);
(Hook) GameEvents.UiDiploEvent(eEvent, aiPlayerId, iArg1, iArg2);
(Hook) GameEvents.UnitPrekill(unitOwnerId, unitId, unitType, unitX, unitY, bDelay, eKillingPlayer)
(Hook) GameEvents.UnitPromoted(ownerId, unitId, ePromotion);
(Hook) GameEvents.UnitUpgraded(playerId, unitId, newUnitId, bGoodyHut);
 
Actually, forcing peace was possible before. You can even lock peace/war (simulating cooldown)

There are maybe five interesting ones, but I don't see myself replacing PlayerDoTurn with CityConstructed/CitySoldBuilding. :)

I am curious if using PreKill will grant eKillingPlayer Culture/Gold (from traits/policies). This is something bugging me for a some time.
 
Wait, does this mean we actually have building/unit constructed events now? Or are CityConstructed/CityTrained something else?

I'm also curious how DeclareWar works, given that I just published a civ with a "go to war" trigger... X3
 
As part of the new patch, it seems a bunch of new Lua hooks were included as an undocumented addition. These are:

SNIP

I wrote every one of those into my DLL ... very curious

See the spoiler in post #4 here ... would of been nice to have been asked, or at least given a "heads-up"
 
Are there other undocumented changes to the DLL systems that are not minor bugfixes? I haven't gotten back to my PC yet so I haven't looked.
 
This is incredibly great. :)

...Although a working combat-event would be great too.
 
I am not really into lua, at all.
But does this mean you can force peace treaties?

No. The MakePeace/DeclareWar events fire when peace/war is declared between the two teams.

You can use the IsAbleToMakePeace event to stop the teams from making peace - useful if you want a permanent war situation, or to stop the AI members of a mixed AI/Human team from making peace.
 
Wait, does this mean we actually have building/unit constructed events now?

Yes. The events trigger when a city builds something. They are direct counterparts of the CityCanXyz events
 
Are there other undocumented changes to the DLL systems that are not minor bugfixes?

No. Just the new events (no new API methods for example)
 
Yes. The events trigger when a city builds something. They are direct counterparts of the CityCanXyz events
Yay! or : About time!

edit --> should the game be showing 1.0.3.276 when I start it up ? I'm still seeing 1.0.3.144 but that might be because I haven't given steam a chance to update to the latest ? Lately I've been running with steam in offline mode because I find the delay when starting the SDK to be incredibly annoying!
 
Wait, does this mean we actually have building/unit constructed events now?
Both of these could be achieved through some lua algorithms, but now it looks like that middleman is no longer needed.
-------
Now that we have events that can detect when a religion is enhanced (no religion reformed event?) it is possible to construct a beliefs-grant-buildings framework (similar to policies-grant-buildings). If others would find it useful I can sit down one weekend and write it out.
 
should the game be showing 1.0.3.276 when I start it up ?

Yes. You'll need to be on-line to get the update. The main game and the SDK should update together.

(no religion reformed event?)
No, I originally wrote the religion events for G&K, and forgot to add one for Reformation when BNW came out.
 
Code:
(Hook) GameEvents.TeamSetEra(teamId, eEra);

do you think this means that the civ will get all the prerequisite techs for that era?
 
Just a minor information, but since the update the logs show errors, that wasnt shown before the update (hidden) .
I guess this is a good news.
 
Both of these could be achieved through some lua algorithms, but now it looks like that middleman is no longer needed.
-------
Now that we have events that can detect when a religion is enhanced (no religion reformed event?) it is possible to construct a beliefs-grant-buildings framework (similar to policies-grant-buildings). If others would find it useful I can sit down one weekend and write it out.

Yeah, I remember you'd posted both "upon building constructed" and "upon unit trained" lua snippets, and I've tried to do similar things myself with some of my mods. But having proper events for them is going to make it a lot more convenient, particular with regards to training units. (I know before you had to use a Created promotion to avoid shenanigans with the unit created serial event...)

That sort of framework would be interesting to see! I've got to get around to revising my religious civ one of these days, so more code snippets to play with is always good. (Even as it is, I'm getting ideas for granting buildings upon a religion being founded/enhanced... a shame there's no Reformation event)
 
Top Bottom