Logo Platform
logo amplifiers simplified
Humankind
Universe banner wording

[Guide] Event Modding - starting guide

Reply
Copied to clipboard!
2 years ago
Dec 6, 2021, 11:48:17 AM

This a starting guide for all that want to do their own events. Some pointers before I start.

Wishlist:


  • A SimulationEvent which describes a change of diplomatic status between two empires. There is something like this for BattleStart, BattleTerminated, CityBesieged, etc. but not for that. The only one is if a surrender is signed, which does not help since it is difficult to get the winner and loser side.


 

Table of contents:

 

  1. Which elements are needed for events?
  2. Overview EventCategory
  3. Overview Event
  4. FAQ
  5. Examples and their uses

 

1) Which elements are needed for events?

 

When you create a new collection, these two are what govern the events:

Please note, the first one is optional. You can safely use those, that already in the game. I tend to do new ones. The second is the collection for each event.

Aside from that, the rest are optional like effect descriptor you want to apply but are not necessary themselves.

 

2) Overview EventCategory

Events need to be assigned to an EventCategory. All settings here govern how the assigned events function.

Global: The event will fire global once

Narrative Event Definition Distribution: Since an event needs to be assigned to an EventCategory, this defines how the events are sorted and potentially fired.

Need Manual Trigger: Events In this category need a manual trigger from another event (will be shown later).

Consume Event upon trigger: The event will only fire once if this is ticked. Please note, you can override this setting on per event basis (will be shown later)

The rest are self explanatory or have a tooltip.

 

3) Overview Event

In this definition the event itself is build. There is a lot of ground to cover.

 

Definition

Category: Choose the category which governs how event are generally triggered.

Era Definition: Is mandatory. The event will only fire in the listed eras. Has no effect on events which are triggered by another event.


Trigger

Consume Event upon Trigger: Same setting as category, just for this particular event.

Prevent Event Removal: Event can fire several times.                 

Is Narrative Consequence: This means, this event is only fire by another event.

Simulation Event (not shown if above setting is ticked): Here you can select how the event is triggered. There are many events where you can check to fire this event or not.

Prerequisites: Here you can set up WHO will get this event. Leaving this blank, will show you events from other empires too. There are many possibilities, but most you will use the Empire_Self.

 

Variables 

Here you can check and set up variable collections which can be used in the event effects further down. This is also automatically a prerequisite check for the event to fire. You setup a name and what will be collected (All, First, Last, Any). 

In the above screenshot it wants to have an empire with the Babylon legacy trait. If there is no empire with that trait in the game and the variable will be empty, the event will NOT fire.

Most useful here: MajorEmpire, Empire_xx (like Empire_Settlements).

Has Count Condition: You can tick this to setup a count check. For the variable (and the event) to be valid, there needs to be n many entries with different operators like Equal, Greater or Less Than.


You can setup an event which will fire for instance only if less than 3 empires are in the game, or more than 8, etc. Or a specific number. Of course, you can also check for other things depending on you chosen element: number of pops, Holy Sites, number of units. I think almost anything than can be quantified can be used.


Element Prerequisites: Here you can finetune what will be stored in this variable. In the screenshot above, it checks for the Babylon legacy trait. The found empire (if any) will be stored under the variable name. Please note it is also important the Collection Selector and the Sort Property name.

Empire ID: Some variables or prerequisites want you to limit it to a specific empire id. The standard is Empire (MajorEmpire) which is the one who gets this event usually (meaning the empire controller). In the variables you can also check variables. For instance you can make a variable collection of the empire of Assyria (with the trait) and then make a second variable and get all their cities (you use the the variable name as Empire ID)


UI

Setup of the used picture, title and description of the event.


GeoLocation ID 

Here you can focus the view on an element from the setup variables. Make it a single variable.


Choices

Now the choices. These are the boxes you see to make a selection. Please note, the choices are normally separate (pages) instead of under each other. You can change the view slightly to the left where you add a new element.

Title and Description is what is shown on a button.


Instant: can be ticked to make the effects instant. Please note, you can give for example an empire 500 fame and apply a descriptor to something. The 500 fame will be given once. The descriptor stays until the end.

Duration: Only available if the Instant box is not ticked. Number in turns. Please note, it does take game speed into account and will multiply your number.

Prerequisites: not sure if and how they work in this place… so can’t say much about them

Narrative Event Effects

Here you add the different event effect this choice does.

Reversible: If this is ticked and you have a duration for the choice the effect will last until the duration is over and is then removed. This applies to EVERYTHING (from example above: each turn +500 fame and the descriptor effects apply and both get removed when its over). 

Simulation Event Effects: Most are self explanatory. You have stuff like AddFame, AddMoney, AddGrowth, Unlock stuff, trigger another event, apply status or descriptors, end the game etc.

Hidden: The actual effects are hidden in the choice box. Only title and description is shown, but effects are still applied as normal. (The omnipotent choice of the persona mod is like this)

AI Gain Values: Here you can setup values for the ai for some properties like food, military, etc. It is tied to the AI Archtype at the end. If no archtype is chosen, the values here are useless.

Target ID: The target where the effect is applied to, can also feature variable names. Please note that for status and descriptors, the target and the starting point of descriptors must be the same. If the target id is a MajorEmpire, so does the descriptor need to start from as MajorEmpire (watch the parenthesis).

Here you can select archtypes of personas and give them a weight. Or different weights for different personalities. How the weight is multiplied with the AI Gain values, I do not know.

Please note: If the archtype of the persona is NOT covered at all. That empire will ALWAYS choose the very first option of an event. So make the first one your fallback choice.


4) FAQ

Q: So can I make culture exclusive event chains?

A: Yes you can, use the descriptor validation and set it to the legacy trait. This can be even more elaborate with validating two specific empires and then make event chains around both of them and their interaction.


Q: Can I add events specific to transcendence empires?

A: Yes you can. You can even limit this to specific cultures. I made one which only fires if you take Babylon in era 1 and then transcend them. Gives you two choices. (Not publicly available) 

Please note, the legacy trait for era 2 is the legacytrait_era1_upgrade.


Q: Can I unlock new constructables (districts, units, infrastructures)?

A: Yes you can. But you need to add those to an invisible tech. Otherwise they will become available as soon as the building prerequisites are met. 


Q: I made an event which applies a descriptor to settlement stuff. It now shows "Unknown" as source.

A: Apply the descriptor with a status instead (use ApplyStatus in the event). This will show the used status category as source for this descriptor. You need to add the StatusCategory to the UI Mapper for your own text.


I will add more questions and answer from users when they come up.


5) Examples

Animal Kill Event: Discord link

An event which gives a one time bonus (40 food to the army and 150 incluence) after winning against an animal once per animal type. Shared on discord and made by me. This a unity database, which you can import into your own project: 


Player Persona Handicap: Player Persona Handicap Bonus mod for Humankind - mod.io

Event chain on mod.io (also from me). You get some permanent bonuses in different categories.



Trigger another event:

I will use my persona handicap mod for this. The following screenshot show the very first window where you make the choice which categories you want to choose from.

I added the Event Effect "TriggerNarrativeEvent". For each additional window I added a new TriggerNarrativeEvent effect. Only the first one is not collapsed in the screenshot, but the setting is the same. Each possible consequence needs a weight. YOu can have several consequences in one event. I split it here so each window gets fired.

The stack should be which variables are ported to the triggered event.


Apply a descriptor to a territory after a district has been built (this allows infrastructure to have per territory effect if a specific district is build in that territory)

I saw that someone on discord asked for this, if this was possible. And yes it seems to be.

Goal: Make the City Watch only apply their Stability once per Territory IF in that territory is a garrison. You can built the garrison any number of times in that territory, but any beyond the first does not grant any benefit from the infrstructure.


Mandatory: Have a descriptor you want to apply. Do not forget the validationmapper and effectmapper for that. 

First we change the infrastructure.

Next we setup the event:

The event goes as follows: when a district is built, check if its the correct district type. Then count the territories which have a garrison, but not the tag.

As for the effect itself. Apply the tag to the territories with the above limitations.


Changed city watch:


Result (City with three territories. In one are 5 garrison, in a second 1. Third has none):

Updated 2 years ago.
0Send private message
2 years ago
Dec 9, 2021, 5:12:34 PM

I added two more things to the FAQ and also an example which describes a territory based effect which relies on a specific type of district but is independent on their numbers (one is enough, but many will not add more benefit of the territory effect) since I posted this originally. Depending on *when* you visited this thread you may have missed them.

Anyway, here is a new example.


Using an event to unlock stuff with 2 tech requirements.

This is a unity package you can import into your mod project. This example will unlock a riflemen copy after researching Calendar and Domestication on the next turn.


What can you unlock by event:

In this example we use the blue highlighted one. 


Aside from the usual stuff which describes your unlocked Unit/Building/District/Tech etc. you need one thing. An event and maybe a category.

Also to make the desired unit not available asap, you need to lock it behind a technology (HiddenTech element). If you make a new technology, it has some mandatory fields, otherwise you cannot start a game (it will show you an error). But I will not go into details with that. You can still look into it in the download link for the package.


Foreword: There is some limitation to this. IF you make your new super powerful unit visible on the techscreen, it is still possible to research the tech manually. You can make the tech hidden to circumvent this (or make it super expansive to research), but you as the player may not know about this then.

You can do another event which will describe this or make this knowledgeable in another way. I do not know if it is possible to make some fake units in the tech screen just for having some info on the unit and how to unlock them since I have not really dabbled with the techscreen or making new unlockables at all. Maybe someone else can shed light on this.


Anyway, the core of this is the event:

As you can see, I added 3 requirements:

- your empire needs to trigger this event

- added two techs as prerequisite for the event to trigger (Calendar and Domestication, and you need both researched). The triggers can be something else too. Like having a specific number of resource x, or pop number >x or having at least x cities or having a specific legacy trait, etc.


Then comes the choice with the effect:


I made it instant to make the unlock stick. The other stuff is not really event related but whatever you want to unlock, so I do not cover them here.


And maybe a dev can answer two questions from me that cropped up for me:

- the SimulationEvent_TechnologyCompleted seems to do nothing (it will not trigger). Did I just use it wrong or not implemented (or obsolete?)

- the simulationEvent_NewTurnBegin does not do anything either it seems. So same as above?


Updated 2 years ago.
0Send private message
2 years ago
Jan 6, 2022, 5:46:24 PM

Something new to play with.


Loop events + cascading event choice

This is basically an event which triggers itself and whatever other events you want regularly to happen. Make sure, that the event for the loop itself is as clean as it gets with as few as pre-requirements as possible (preferably use only empire_self). 


Why use this instead of "Prevent Event Removal"? Well, for once the event call serialization between empires can get in the way if you want all empires to have it simultaneously. Also if you made some pre-reqs it is possible it won't fire and can get stuck (maybe?). They are also resistant to era change, where events which use the prevent removal option are prone to fail. As a bonus, triggered events basically ignore the era definition you set up for an event.


What you need:

1) a starting event which triggers the loop event once

2) the loop event itself

3) other events that actually do things



1) Starter Event

This is simple enough. This is a global event which just triggers the loop event. Here you can also apply other stuff to all empires if you want. For safety sake, use another event though.

It has it's own Event Category.


The settings:


The Choice:


It only has the empire_self as pre-req and triggers the loop event. You can also add other stuff here (like starting influence or fame or knowledge for testing stuff) which should be applied once to all empires. Refrain from doing some crazy stuff though. You could also add several loop event which are different somewhat or you want them to be easily separate.


2) The Loop Event

Almost no settings aside from the prerequisite. Also make sure this starts at the same era as the event starter. It must have a different category as the first event. "Consume Event Upon Trigger" is not mandatory to be ticked, but it does no damage if it is. Do enable the "is Narrative Consequence" though.


Again we have the prerequisite empire_self

As narrative effect we add the loop event. Make sure you set the delay to at least 1 (though it seems this is not adhered to at all... the event will always trigger each turn in my tests). This example will trigger every turn. Then you can add other events where the actual stuff happens. You could also trigger several events. It depends a bit on what the event will do or the requirements are. You can also add a effect like "add fame" to check if the event triggers correctly each time. Anything that is easy to apply can be added here. Anything that is more complex should move into their own event, which is then triggered through the loop event or you can also use the starter event if those are one time events.


3) The Event... which does stuff 

Similar to the loop event. Can use the same category. The eras can be ignored. They are leftovers....

Since this event wants something to do with your settlements, I add them here as variables.

So what happens here...? The idea is, the city gets a status effect if the extra city count is at specific values. The extra city count are the number of cities which are above your city cap. It also checks if the city already has the tag from the status. If it fails (the failure flags), so fails the choice. If it fails, the next choice will be checked (there are 7 choices in this event, all similar and check the ExtraCityCount against a value) until the next in line is valid. There are 6 events which checks for a number. The 7th is an escape choice, where nothing happens but is essentially always available and will be chosen if all else fail. Since the UI for the events are hidden, this happens automatically. Remember: If you hide the event UI, the first valid choice in the event will be chosen always.


If the check goes through, it will apply the status effect to the settlement (or whatever you want).


And that's it. Here comes an extra:


So what if I want the event only to trigger every n turns instead of each turn?

Well, there are two options:

A) Make the loop event not "Instant" but set a duration. The number there is multiplied by the chosen game speed and may not feasible for every situation (This example: 8 Turns on Normal, 4 on Fast, 2 on Blitz, 12 on Slow, 16 on Endless). So take care.



B) You apply a status which has a duration. The good thing about statuses is, you can set the duration to gamespeed independent. Which gives you more options, but also more work in the events...

Add the applyStatus to the actual event from point 3) (not the LOOP event).

The Status "Status_Tag" adds a descriptor "Tag_Status_Set" to the Empirelevel. You add this descriptor as a prerequisite to the event which should only trigger every n turns (the application of the status could be done through another event or the same event. If you use another event to apply something like this, you also need to add a prereq there, otherwise the status gets refreshed each time...). 

We want this event only to trigger, if the empire does not have the Tag_Status_Set.

Please note, if you use this method and your event can have instances where every possible choice can fail or the event has a prerequisite which it fails, the status will not be applied. It is also possible, that the event may break (not sure about this one though, but at the end better safe than sorry). So you better have some "escape choice" at the end which does nothing. Maybe aside from applying the status effect for the turn delay.


If everything works as it should, your nice shiny event loop does what it should. Have Fun!


Mods which uses this:

City Walls Combat Buff mod



The Unitypackage (only includes the events and their event categories)

Loop_Event example.unitypackage

0Send private message
2 years ago
Feb 2, 2022, 12:22:41 PM

Short Update:

The game update 1.0.8.1793 changed some thing with the events. Due to this the following stuff changed:


- The "Prevent Event Removal" now works across multiple eras effortlessly and reliably. This may be used instead of the loop event now. Though I still suggest making that event as light as possible and have it trigger other events which actually filter and apply the appropriate effects.


- The "Global" tick in the EventCategory is not needed anymore (leave it empty) for triggering the event reliably for all empires at the same time. Also (and this might be a bug or unintended) the game will get stuck in a end turn bug (exception in the sandbox environment) if there are events which are global and are triggered by a simulation event (like TurnBegin or ConstructionFinished). I have not tested if this problem occurs if it is triggered by another event.

Events in general will now trigger for all empires at once if they are eligible for it which makes this option obsolete anyway.

0Send private message
?

Click here to login

Reply
Comment
0Send private message