The maps in our most beloved game are quite detailed. Modders put in quite an effort to make the place feel realistic. Houses have all kinds of furniture, with bathrooms and kitchens, there are bookshelves, computers and so on. Sadly, we can't really do anything with the stuff. All we can do is sometimes open structures to get hidden items, and open doors. That is okay, but... well... not that much.
This feature attempts to change that. The idea is simple: You rightclick with your mouse. As usual, your cursor will transform to 'force' an action. If you then hover over structures, they show you whether a special action is possible. Click on the structure, and the merc will do whatever is possible here.
The special trick is that which actions are possible where, and what they do, can be fully defined in xml and lua. I basically provide a base structure for this - what can happen where with what is up to the modders.
So far, the following actions exist:
Hacking - hack a computer
Read file - read the contents of bookshelves and file cabinets
Drink from a water tap - drinking from a water tap or sink restores breath and stills your thirst
I will go into more detail on these actions in the following posts.
The actions themselves are defined in the new xml TableData\Map\InteractiveActions.xml. You can find more details on what tags exist and how they work in there.
If you want something specific to happen on an interaction with a specific structure (for example, hacking a specific computer should give you a specific text), you can set a LUA Id. A lua script - HandleInteractiveActionResult() in Overhead.lua - will be called. You can then set whatever you want to happen in there as a result of the interaction. The stock script also contains quite a few detailed examples, so look for inspiration there.
The interesting thing is that you can define actions both very broadly and very precise. So you can set all structures of a tileset to yield result A, but not in sector X, where the result should be B. Apart from that one specific one, which should give you C. And so on and so on. I've recently added a way for modders to store their own data. This is extremely useful for this feature - you can 'remember' what actions were already taken, and alter your results accordingly. For example, hacking a computer might yield you a few dollars - but of course only the first time. The stock script also uses this extensively, so look there for inspiration.
Keep in mind that the code only provides a base structure. What you do in LUA is up to you. If you want to be able to hack a tree to spawn tanks that recite Macbeth, you are free to do so.
This feature is fully savegame compatible.
This feature has been added to the trunk in r8278 & GameDir r2333. Using the new exe without the new GameDir will cause you to forever live in the twilight. You will walk the earth, neither dead or alive. Sorrow shall be your nourishment, regret being your only companion.
[Updated on: Sun, 11 December 2016 14:31]
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.