Hi Manuel,
Great to see more interest in Lua events in these forums!
Everything you've listed here does seem possible with Lua, including your #6, #7, and #8. Unfortunately that doesn't mean these events would be simple or easy to write. There's quite a bit of complexity here, and it would take plenty of time and many lines of code to accomplish everything you have in mind. So it's a little more difficult for me to assess the degree to which you might consider it feasible or practical.
All Lua interaction with the game is based around a fixed set of what I call "triggers" -- situations or actions that take place within the game that cause it to interact with the events.lua file, and provide you with an opportunity to inject Lua code which will run at precisely that point in time. Two key ones for your needs are probably going to be
civ.scen.onResolveCombat() and
civ.scen.onUnitKilled(). The first of these runs once for every "round" of a battle, but unfortunately doesn't give you the ability to stop a battle partway through (leaving both units alive) -- one unit will always be destroyed. At that point, after the battle, the second of these triggers runs. It seems to me that many of your event
actions will take place during the second trigger, after the battle is over, but may require
information that needs to be gathered prior that point, either during the first of those triggers or else (perhaps) at the beginning of that turn.
For example, within
onUnitKilled(), if the attacking unit was defeated, it doesn't seem to be possible to determine what tile it was on when it launched the attack. So I think you'd need to determine this and store it in memory while the battle is active, during
onResolveCombat(). Similarly, since for some of your events you need to know how many hit points the losing unit had at the start of a battle, you'd have to document this in memory ahead of time, in order to be able to reference it after the battle ends.
For some of your events involving encirclement or proximity, you might benefit from using the Supply Lines module that I wrote and released
here. I'm a little unsure whether that's going to be the best solution, though, without more information such as whether or not you expect enemy units to exert a zone of control, what you envision for encirclement "distance" (how tight a blockading circle needs to be), and how these affect the ability to evade or dodge.
You may have done the following things already, but to anyone who's interested in learning how to write Lua events for Civ 2 and has limited programming experience, my recommendation would be:
1) Start with
@Prof. Garfield 's tutorial,
Get Started With Lua Events. This is a very helpful guide to learning how to program in Lua that uses examples directly from Civ 2 (unlike other Lua guides you may find on the web). It's not complete yet -- there are more lessons still to be written -- but even what's there now represents a great foundation. I'd encourage you to make it interactive by actually typing out and running all of the code examples, rather than just reading the guide.
2) Download all of the recent scenarios that use Lua:
Caesar's Gallic Wars,
Napoléon I, and
Over the Reich. The Lua files in those scenarios are very large, but see if you can start picking apart what each section does, and how it works. Having lots of examples of working code to review can be a big help in putting together your own events.
3) Start small and simple with an events.lua file for your own scenario. Some of your proposed events could require a hundred lines of code or more, but it's unrealistic to think that
anyone would be able to write that top-to-bottom in one shot. Instead, focus on smaller building blocks that might form the foundation of several events. For example, write an event that runs when a battle begins and simply prints some data to the Lua console, such as the tile coordinates of the attacker and defender and how many hit points each one has. Then build on this by storing that data in memory and only displaying it later, after the battle completes and one unit has been destroyed. You get the idea. In general, always use the Lua console to print a lot of status messages and display the values of variables, as you're working on new events, so you can see what's working and what's providing unexpected results.
4) Feel free to post questions or sections of code to this forum if something just isn't coming together for you, or you're not sure how to break a big problem into more manageable pieces. The more you can narrow a question down to a specific issue, the easier it will be for someone to give you practical ideas that might work for you.
Good luck and have fun!