Events on Tech Discovery or Resource Aquisition

Elucidus

King
Joined
Mar 3, 2002
Messages
983
Location
USA
Is there a way to have an event trigger for everyone when they discover a specific technology or when they gain access to a specific resource?

Or maybe a better way to apply a specific promotion when a tech is discovered or a resource is available. I tried to do this a few months ago but was not successful at all. Any help would be appreciated.
 
You should be able to do both of those.

In CIV4EventTriggerInfos.xml the event trigger can have a prereq tech specified, via
the OrPreReqs and/or the AndPreReqs tags, perhaps something like this:
Code:
			<OrPreReqs>
				<PrereqTech>TECH_INDUSTRY_13</PrereqTech>
			</OrPreReqs>
If you also set iWeight to -1 it will automatically trigger when the prereq is met.

If iPercentGamesActive is 100 it will happen in every game (if it is less, then in some games it will happen and in some it won't - unless you have this set to 0, in which case it will never happen.)

There is also a BonusesRequired tag which may allow the same sort of thing for that, except it is aparently only be used when picking a specific plot - this might not matter since you can probably still do anything you want with the event, it shouldn't have to actually apply something to the plot picked. You probably need to set bOwnPlot to 1 (so that is for bonuses on plots that you actually own) and sey iPlotType to -1 so that it doesnt matter what the type is. With iNumPlotsRequired set to 1 you'd only need 1 such plot. To trigger when the resource is actually acquired, you'd probably also need to specify the ImprovementsRequired to be the improvement type that gives the bonus. Then you hit the problem of "is the plot connected via a route?" If it is not on a river, you can tell by using the RoutesRequired and specifying both road and railroad. If it is on a river it doesnt' need the route and you've got a problem... Or you could skip all that because, all in all, this case is easier to do via a PythonCanDo function (pretty much just check the player's hasBonus function for the bonus type you are interested in).

You should probably have bRecurring set to 0 so it only happens once - it will be once per player if bGlobal is 0 or once per game if bGlobal is 1 (good for a "first player to get X gets some sort of benefit" type thing).

The trigger then lists an event (or more than one to choose from) which can apply a free promotion. There are multiple ways to apply it, including UnitCombatPromotions (apply to all units with one of a list of unitcombat types) or UnitClassPromotions (allows you to be much more selective in your units).

I have done this to apply a free promotion when getting a tech and it does work.
 
Top Bottom