1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

BNW Patch Version 1.0.3.276 New Lua Hooks

Discussion in 'Civ5 - Creation & Customization' started by Pouakai, Oct 27, 2014.

  1. Pouakai

    Pouakai It belongs in a museum. Moderator

    Joined:
    Jun 16, 2010
    Messages:
    7,158
    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);
     
  2. COF

    COF Emperor

    Joined:
    Dec 30, 2013
    Messages:
    1,512
    Location:
    Bosnia and Herzegovina
    I am not really into lua, at all.
    But does this mean you can force peace treaties?
     
  3. JFD

    JFD Kathigitarkh

    Joined:
    Oct 19, 2010
    Messages:
    9,130
    Location:
    The Kingdom of New Zealand
  4. COF

    COF Emperor

    Joined:
    Dec 30, 2013
    Messages:
    1,512
    Location:
    Bosnia and Herzegovina
    Cool, I can see some interesting stuff be done with that.
     
  5. LastSword

    LastSword Prince

    Joined:
    Feb 24, 2013
    Messages:
    1,010
    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.
     
  6. bouncymischa

    bouncymischa Synthetic Genie

    Joined:
    Nov 28, 2012
    Messages:
    1,537
    Location:
    In a bottle
    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
     
  7. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    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"
     
  8. ls612

    ls612 Deity Moderator

    Joined:
    Mar 10, 2008
    Messages:
    8,073
    Location:
    America
    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.
     
  9. Pouakai

    Pouakai It belongs in a museum. Moderator

    Joined:
    Jun 16, 2010
    Messages:
    7,158
    Location:
    Aotearoa
    These are the only ones that I've noticed, but that doesn't mean there aren't potentially others
     
  10. Neirai

    Neirai the Forgiven

    Joined:
    Aug 5, 2013
    Messages:
    1,045
    Location:
    Canada
    This is incredibly great. :)

    ...Although a working combat-event would be great too.
     
  11. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    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.
     
  12. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    Yes. The events trigger when a city builds something. They are direct counterparts of the CityCanXyz events
     
  13. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    No. Just the new events (no new API methods for example)
     
  14. bouncymischa

    bouncymischa Synthetic Genie

    Joined:
    Nov 28, 2012
    Messages:
    1,537
    Location:
    In a bottle
    Well, they should certainly help in making coding easier in the future, then!
     
  15. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,132
    Location:
    Illinois, USA
    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!
     
  16. Machiavelli24

    Machiavelli24 Mod creator

    Joined:
    May 9, 2012
    Messages:
    818
    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.
     
  17. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    Yes. You'll need to be on-line to get the update. The main game and the SDK should update together.

    No, I originally wrote the religion events for G&K, and forgot to add one for Reformation when BNW came out.
     
  18. Bonci

    Bonci King

    Joined:
    Oct 22, 2005
    Messages:
    764
    Location:
    Tridentum - Italia
    Code:
    (Hook) GameEvents.TeamSetEra(teamId, eEra);
    do you think this means that the civ will get all the prerequisite techs for that era?
     
  19. Gilgamesch

    Gilgamesch Ancient Alien

    Joined:
    Dec 15, 2010
    Messages:
    2,228
    Location:
    good old germany
    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.
     
  20. bouncymischa

    bouncymischa Synthetic Genie

    Joined:
    Nov 28, 2012
    Messages:
    1,537
    Location:
    In a bottle
    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)
     

Share This Page