AlifePlus: Reactive Architecture on STALKER's A-Life
AlifePlus is a mod for STALKER Anomaly by Damian Sirbu, built on the 2007 X-Ray engine. I went through the source expecting the usual modding situation and found a layered reactive event pipeline w...

Source: DEV Community
AlifePlus is a mod for STALKER Anomaly by Damian Sirbu, built on the 2007 X-Ray engine. I went through the source expecting the usual modding situation and found a layered reactive event pipeline with Bresenham-derived rate limiting, which is why I'm writing this. STALKER simulates about 2000 NPCs across 30 maps. Most are "offline", meaning statistical entities on a graph. A few hundred near the player are "online" with physics, animations, combat. The engine fires Lua callbacks on events: deaths, territory transitions, item pickups. AlifePlus pattern-matches on those callbacks and dispatches reactive behaviors through a pub/sub bus. None of it is hardcoded -- the mod watches A-Life and reacts to what it sees. Pub/sub and radiant evaluation A bus called xbus sits in the middle. Causes are predicates that evaluate world state on a callback and publish a typed event or return nil. Consequences subscribe to cause types and run side effects. The two sides don't reference each other, so a n