Event System - Valheim-Modding/Wiki GitHub Wiki
RandomEventRandEventSystemZoneSystemZNetCharacter
- Gets called when an entity dies.
m_defeatSetGlobalKeywould be "defeated_boss". - This key indicates that the boss has been defeated.
- Checks if key exists in
ZoneSystem.m_globalKeys, if not add it. - Broadcasts list of keys to all connected players.
- Clears client keys & fills with new keys.
- Gets all the possible events, if none, returns.
- After getting possible events the game picks a random event/ZDO combo from the list & starts the event.
- Gets list of all
characterZDOs. - Cross references each event stored in
m_eventswithRandEventSystem.m_globalKeysbased on whether the key is "required or not." NOT required means the key MUST NOT be present inm_globalKeys. - Below are all of the event names I've pulled from the system as well as their required/notrequired keys.
| EventName | RequiredKey | NotRequiredKey |
| army_eikthyr | None | defeated_eikthyr |
| army_theelder | defeated_eikthyr | defeated_gdking |
| army_bonemass | defeated_gdking | defeated_bonemass |
| army_moder | defeated_bonemass | defeated_moder |
| army_goblin | defeated_moder | defeated_goblinking |
| wolves | None(Possibly Biome Specific) | None |
| skeletons | defeated_bonemass | defeated_dragon |
| blobs | defeated_bonemass | None |
| foresttrolls | KilledTroll, defeated_gdking | None |
| surtlings | killed_surtling, defeated_bonemass | None |
| boss_eikthyr | None | None |
| boss_bonemass | None | None |
| boss_gdking | None | None |
| boss_goblinking | None | None |
- After this check it sends each event into
GetValidEventPoints(RandomEvent ev, List<ZDO> characters). - This checks each ZDO to see if the event & ZDO match Biome, are near a base, & that the zdo is lower than 3000f in the y plane (I think dungeons are spawned in the sky, which could be the reason for this check.
- If the ZDO passes the checks, its position gets added to a list.
- After
GetValidEventPoints(), it checks that the count isn't zero, grabs a random position(ZDO) from the list and adds it along with the associatedRandomEventto the list returned fromGetPossibleRandomEvents().
- Last step. Makes sure event isn't null, isn't already running, and there isn't already a random event running.
- If all checks clear, start event &
SendEventviaZRoutedRpc.
- GlobalKeys are saved to the world. They can be grabbed as early as after
Game.Start()