Hi,
I'd like to share a WIP status of the Rails mod I'm working on. It is not a campaign or something that changes the main story, but rather something that can be used to add extra mechanics to other mods.
This mod allows you to lay down a track using objects and have any character (via an associated charScript) follow that track
without having to place any triggers! The tracks, via their itemScripts, determine their connection points automatically when the level is loaded based on two external variables: their base size and their scale (because it appears you cannot query these properties inside an itemScript, or at least I haven't found the correct arguments to ItemGetStat() yet -- just the scaled size would be enough as well; I just split them so you don't have to manually calculate the result).
The only thing you have to do to set things in motion, is tell the track on which the train is located to put the train in motion. Everything else happens via item/charScripts (the train and the tracks communicate via events), no story scripting is involved.
You can see a short demo at
http://divinity.watlock.beKnown issues:
• The turning is not very smooth. The reason is that it's done by calculating a couple of points in the turn and sequentially moving the train to those points. Ideally, a continuous RotateY() coupled to a constant "forward' movement would be used, but the game engine does not support that afaics.
• Since the train has to be a character (to be able to use CharacterMoveTo, since there is no ItemMoveTo), possibly
derived from an item, it also moves like a character. E.g. if its path is blocked, it will happily move outside the track (although that could also be an advantage in case you'd use this not for a train, but e.g. for an animal or person following a road).
• Currently, the moving itself is done via an endless loop in which CharacterMoveTo() is called (the destinations are updated in parallel by a reaction to minimise pauses between different movement steps), but the game engine doesn't like this (it kills the loop after 500 iterations)
Some todos:
1) Write an itemScript for switches/road forks
2) Add support to the train charScript to pause and continue (I originally started working on this with the idea of implementing a quest with some kind of train heist)
3) Rework the way the train moves (the endless loop mentioned above), although it's hard without introducing jarring pauses
4) Remove the requirement for all tracks to be global. In principle, only the track on which the train initially is located needs to be global (to be able to send the "start moving" event from Osiris), but right now the event to tell the tracks to connect themselves (connection event) is also sent from Osiris: in their OnInit event, the tracks calculate their end point positions, and then during the connection event they query the positions of all other tracks in order to see which ones connect at which places. I should be able to move that to a behaviour instead (since those are guaranteed to run after the OnInit events).