The Spanish Civil War v4 for ToT + ToTPP + Lua - Development Thread [ON HOLD]

The only issue is that the only way I know of for the player to tell the difference is with some sort of text box, which could get annoying really fast.

I suppose the text box could be brought on by a keypress though, which wouldn't be too annoying (if it showed up on activate, it would drive folks nuts).
 
I suppose the text box could be brought on by a keypress though, which wouldn't be too annoying (if it showed up on activate, it would drive folks nuts).

That's a great idea, given this only affects the human player (knowing which unit in particular they are using), keypress would do the trick. Thanks @JPetroski! this has inspired me on planning the following: pressing 'w' key (who am I?) would display a nicely formatted textbox outlining a small unit report...what unit in particular is that (if it's identifiable by its ID), unit type, current location, closest friendly city, attacks left in turn, movement points left in turn, current damage report, etc (possibilities are endless again!), playing with properties of the unit and unittype object. Given I want to mix strategic with tactical aspects in my scenario, I already planned a series of (optional) battle reports in my scenario (users will be able to switch them on/off by pressing a key), so this unit report feature will add just nicely to the whole thing.

The possibilities of reusing unit slots and having separate events for specific unit IDs can expand outside naval units (single unit slot for each ship class) but also for commander/general units, where I can assign IDs to identify specific leaders in game, and personalize actions/events/texts for them. In my original MGE scenario commanders were only a strong defensive unit and when you killed one, you got one for free, but in the ToT revamp I want them to have an enhanced role...I've seen very interesting uses of leaders in other current TOTPP/Lua scenarios so I think it's an area with lots of potential that I want to explore.

I'm sitting an exam on April the 28th, then my plan once/if I pass it is to finish placing the scenario historical starting units as soon as I can so I can start playing around with Lua on all the multiple ideas I have in mind. In order to not to reinvent the wheel I'll implement @Prof. Garfield 's template and use whatever modules I'm interested in, then work on top of that.
 
Last edited:
would display a nicely formatted textbox outlining a small unit report...what unit in particular is that (if it's identifiable by its ID), unit type, current location, closest friendly city, attacks left in turn, movement points left in turn, current damage report, etc (possibilities are endless again!), playing with properties of the unit and unittype object.

I just checked the files in the Napoleon scenario designed by @tootall_2012 and @Knighttime (I downloaded it when I came back to CFC along other modern TOTPP scenarios for reference but never had the chance to play it) and found out a similar report is already implemented in the helpkey.lua module :) Again, me trying to re-invent the wheel :)
 
I just checked the files in the Napoleon scenario designed by @tootall_2012 and @Knighttime (I downloaded it when I came back to CFC along other modern TOTPP scenarios for reference but never had the chance to play it) and found out a similar report is already implemented in the helpkey.lua module :) Again, me trying to re-invent the wheel :)

I don't think we can take credit for this feature as I believe we borrrowed the code from John and Prof. Garfield's Over the Reich scenario. You will find an even more polished version in John's Hinge of Fate.
 
Last edited:
I don't believe we can take credit for this feature as I believe we borrrowed the code from John and Prof. Garfield's Over the Reich scenario. I believe you will find an even more polished version in John's Hinge of Fate.

You're right! I just checked and it's there :) all of the mentioned scenarios are in my Civ2 directory but again haven't time to play them...thanks for pointing me out to whom I need to give credit to once I implement the feature!
 
If you're having fun you're having fun (and you might invent a better mousetrap) but you may well find that much of the stuff you are thinking about doing has been implemented in Prof. Garfield's lua template. It may provide a good starting point or at least a reference for some other stuff you'd like to try, or it might simply work currently. Not sure if you've seen it or not but I more or less deserve zero credit in regards to lua with the possible exception of being one of the knuckleheads crazy enough to be an early adopter.
 
Helpkey.lua is part of the template, and the helpKeySettings.lua file already has a function to display arbitrary text based on the unit (currently its HP, and distance to the nearest city). You could modify it to check the unit ID and determine if the unit is special in some way.

For what its worth, helpkey.lua can be considered out of date. It was made before we had access to the terrain productivity statistics through Lua, so terrain information could be useful. Another useful feature would be to give help for AI units on a tile, which wasn't possible when I wrote helpkey.lua, since we couldn't tell what squares and units were visible to the Human player. If you're interested in updating the key press help functionality, you're welcome to do it.

@Knighttime 's Medieval Millennium has, as far as I am aware, the best help key function at the moment, but it, too, has some limitations based on what was available to Lua when it was released. E.g. it can't detect specials when giving information about tiles.
 
If you're having fun you're having fun (and you might invent a better mousetrap) but you may well find that much of the stuff you are thinking about doing has been implemented in Prof. Garfield's lua template. It may provide a good starting point or at least a reference for some other stuff you'd like to try, or it might simply work currently. Not sure if you've seen it or not but I more or less deserve zero credit in regards to lua with the possible exception of being one of the knuckleheads crazy enough to be an early adopter.

Haha true. The thing is, I came back to Civ, discovered Lua, got my mind blowed, and then by just checking the "Lua function reference" and the "lua scripting possibilities" thread I already had so many "great ideas" I was dying to implement. But yes, it's all done already thanks to @Prof. Garfield 's template! Typical, in my profession (software development) we tend to implement something, to only find out afterwards there's a library or module somewhere that already does the trick in a line of code :)

Anyway, I'll try to innovate in other aspects of the game, I want to modify substantially the way combats are performed in Civ2, as I said here."

2) A combat will not always result in either the attacker or the defender destroyed. I'm going to favour chances for the attacker to abort the attack and regroup if taking severe casualties. There will be a random factor in place that will simulate "ambushes" where the attacking unit is completely destroyed, but in general (let's say 90% of the time, I'll playtest this), the attacker will stop the attack once X hit points are taken. With this I want to avoid the usual "endless civ2 kamikaze" attacks and the "fortress in a mountain" effect, while also being able to send bombers against targets with the chance to have planes coming back to base as it would be in real life and without implementing "ammunition" techniques. Also I want to add extra random modifiers inspired by the Hearts of Iron/Darkest Hour games, like "brekthrough", "encirclements", "surprise attacks", "counterattacks", "tactical withdrawal" etc that will increase or decrease the chances of victory in combat or the amount of damage taken/inflicted.

Another of the ideas I want to implement is for air combat: Currently Civ2 allows you to base aircraft in cities, and fighters scrambling to defend them get the defending bonus. Simple as that. But in my scenario and given the scale of the map, the actual airfields/airbases are already placed outside cities, and additional airfields can (and should) be built, as happened during the war. Stationing an air unit inside a city is "weird" and unrealistic for the scale of my scenario. Captain Nemo in "Second Front" had the Air Force as a separate civ, with their own cities (airbases) separated from the "actual cities". But that doesn't work for me either as I really want to have air combat happening over cities. What I'm going to implement is the following:

1) A fighter unit stationed in a city will translate into a "fighter patrol over that city trying to intercept incoming enemy airplanes". So yes, I'll allow fighters to be "inside" cities for both human player and AI, representing air patrols. The effectiveness of the scrambling/defending fighters will depend on the distance of that city to an actual friendly airfield, with the closest distance meaning the best scramble bonus.

Also when placing fighters on cities to defend them I'll be taking into account the actual range of the planes, so if the closest friendly airfield is too far for the fighters to perform an effective air patrol, have Lua prevent "the air patrol mission", alert the player and reposition that unit back to the nearest friendly airfield. This is to prevent having fighters defending cities which are too far from their bases.

3) If a friendly bomber ends its turn inside a friendly city, have Lua automatically reposition that unit to the nearest friendly airfield. This way I avoid cities "storing" bombers.

With all of this, of course the role of airfields is enhanced, as happened historically. Players will need to defend well their airfields with air patrols and AA batteries and try not to have them captured, as the bulk of bombers will always end their turns there.

4) Seaplanes: I have seaplanes in this scenario and I want to ensure these always end their turns (after attack) in a coastal city (a city adyacent to an ocean tile). So Lua will reposition them to the nearest coastal city. Historically in the SCW we had seaplanes operating from coastal cities (usually from their fishing piers/docks) but sometimes ending their bombing missions in wide rivers or lakes, which also are implemented as "ocean tiles" in my scenario.

That's another of the ideas I want to implement with Lua... :)
 
Helpkey.lua is part of the template, and the helpKeySettings.lua file already has a function to display arbitrary text based on the unit (currently its HP, and distance to the nearest city). You could modify it to check the unit ID and determine if the unit is special in some way.

For what its worth, helpkey.lua can be considered out of date. It was made before we had access to the terrain productivity statistics through Lua, so terrain information could be useful. Another useful feature would be to give help for AI units on a tile, which wasn't possible when I wrote helpkey.lua, since we couldn't tell what squares and units were visible to the Human player. If you're interested in updating the key press help functionality, you're welcome to do it.

@Knighttime 's Medieval Millennium has, as far as I am aware, the best help key function at the moment, but it, too, has some limitations based on what was available to Lua when it was released. E.g. it can't detect specials when giving information about tiles.

I have recon airplanes as well as recon land units so yes, it's going to be interesting definitely!
 
I'm sitting an exam on April the 28th, then my plan once/if I pass it is to finish placing the scenario historical starting units as soon as I can so I can start playing around with Lua on all the multiple ideas I have in mind.

So I sit the certification exam next week (whish me luck!), but I've been continuing with the design/planning phase on my study breaks and free time and wanted to share with you my latest news:
  • AI enhancements:
Firstly, I have decided I'll use Lua for an additional feature: managing the AI-controlled tribe's moves and reactions to the human player's actions, enhancing the AI engine itself. I think it could work and would resolve what I was most unhappy with in my scenario: lack of realism in terms of amounts of units in action.

So far in my previous scenario version (v3 - MGE) I was "compensating" the AI flaws by granting the AI civ extra units "out of the blue" when UNITKILLED, etc, and forcing continuous MOVETO commands in the macro events file (inspired by the classic Captain Nemo's Red Front). I did all I could back in the day to challenge the human player, but that approach was giving extra unrealistic units...this, added to the continuous and constant monthly reinforcements received once the relevant technologies were researched, resulted into the scenario having completely ridiculous amounts of planes, vehicles, etc and also a really tedious way to move units from the ports to the frontlines which was disengaging for the human player. I already planned to limit the "foreign reinforcements" received via events (on tech researched) to keep historical numbers, as per the changelog:

  1. Due to increased ToT event size and the use of variables, reinforcements will arrive on different historical locations and on a random basis instead of every single turn, making each game experience unique.
  2. The above will also allow reinforcements arriving in numbers more historically suitable as these will never exceed actual historical figures.

So as an example, given IRL between 8 and 16 (5 + 11) Henschel Hs-123 dive bombers operated in Spain (depending on sources), that's what they will get, not a unit every turn plus "extra AI compensating units" as it used to happen, having the scenario full of these :). I hated having so many units back in the day and I really want to avoid this but MGE didn't allow me to stop reinforcements with the limited events space. In v4 I want limited/historical units so players think before "wasting" them, as supplies are limited!

Of course not all units will be limited this way. Both the human player and the AI will still be allowed to build endless amounts of infantry/militia units in all the cities (simulating drafting/recruitment), and also build some other specific units in particular cities as it historically happened (buildable artillery/airplanes/vehicles in historicalyl placed factories) thanks to Lua. This feature of Lua allowing buildable units in specific cities/areas has been successfully implemented in other scenarios and this is going to be hugely used in my v4 update (on a very granular basis, some units will only be buildable in a single city!).

...but then how am I going to have a challenging AI if I'm limiting their units to historical numbers? With Lua again, by instantly moving/redeploying AI units wherever they are needed and to effectively force attacks and counterattacks with their existing units. I think with Lua I can have a dynamic reaction to the player's movements. I can also simulate historical campaigns, having the entire Condor Legion redeploying to airfields close to the battlefields and launching effective offensives all together, as historically happened when they were redeployed from Sevilla (South) to the North to support the Basque campaigns in 1937, and then the Levante (East) campaign in 1938-1939. Lua would allow me to move entire sets of units (civ.teleportUnit(unit, tile)) reacting to historical campaigns as well as in reaction to whatever achievements the human player can get. For example, ff the Nationalist human player manages to take X city, the Republican AI player will be able to relocate/redeploy units close to the frontline (in the closest cities to whatever X city was captured first) and manage a counterattack. Also with Lua I could ensure the proper defenses are set around...if tanks are seen in action in whatever front, ensure AT guns are redeployed there protecting key objectives, etc.

I can also force monthly recruitment/drafting of conscripts on relevant cities to ensure the AI tribe maintains a constant flow of manpower to replenish their unit pool, based on the city size. The bigger the city is (meaning greater population), the more infantry/militia units they will get on unit built.
  • Unit upgrade:
Secondly and lastly, another feature I want to implement with Lua is the bulk & on-demand unit upgrade feature: There will be "bulk upgrade events" on both sides, to simulate the Nationalist's April 1937 "Unification Decree" (both Carlist and Falangist militia will be integrated into regular infantry troops), as well as the Republican October 1936 "Ejército Popular" (People's Army) creation on which the different militias reorganised into a more "professional army". In different phases, the variety of militia units I have in-game will get upgraded into a regular infantry unit. These two will be triggered by researching a specific tech, so will be optional for the human player, and forced via events to the AI player.

But apart from these "bulk unit upgrades" based on historical events, I also want the human player to be able to upgrade on-demand (on-key-pressed), from regular infantry units, to motorized units, at a cost. Motorized units will have the same combat strenght as regular infantry units, but enhanced movement points and one additional attack per turn. The AI will get randomized infantry unit upgrades of this kind. For this I have two motorised infantry and motorised militia units for both sides already in-game. Also Nationalist Panzer I tanks will be able to be upgraded on-demand with the 20mm Breda Italian gun at a cost (and if the relevant technologies are researched first). The AI player will get historical upgrades of this kind. Probably I'll get even more upgrades, I'll think more about it. Again, as I always say, the possibilities of Lua seem endless to achieve a historical accurate but also challenging and fun scenario.

Will update next week after my exam...

Pablo
 
Last edited:
Hi, quick update. I passed my exam and I'm still placing the initial units on the map for scenario start. I have done some adjustments to the units file, changed some slots, got rid of some units and added new ones which are more suitable and provide more variety. This is extra unexpected work but it will be better for the scenario :)
 
And a small teaser on airlifts (screenshots from the Nationalist side - the Republican side has their own specific texts), I'm paying lots of attention to tiny details this time, playing around the game.txt file and specific unit slots...

2022-05-07 09_03_28-Civ Rules_ Airlifts.png


2022-05-07 09_02_14-Civilization II_ Test of Time.png


2022-05-07 09_05_17-Battlefield Report.png
 

Attachments

  • 2022-05-07 09_03_28-Civ Rules_ Airlifts.png
    2022-05-07 09_03_28-Civ Rules_ Airlifts.png
    218 KB · Views: 21
New update :)

My mind as a scenario designer is still in the old MGE days, but after having played recently some modern ToT (with ToTPP and Lua) scenarios I have realised about some very nice features I'm still not taking advantage of: ToT multi-maps. I have been going through some ideas (I hope innovative enough) that I want to implement here in my SCW revamp, and with Lua it will be possible:

- Main map: Current map with units, cities, etc, good old civ game, this is where all action will occur. Nothing new here.
- Political map: A quick "read-only" map showing what territory currently controls each tribe featuring plain simple colours (like any standard political maps). Helpful to see how the frontlines progress, the different regions, borders, etc. Lua will maintain each tile in this map depending on how frontlines progress in the main map (on city captured, etc).
- Weather map: I plan to have a randomly generated weather engine written in Lua for the scenario which will be based on seasons (extracted from the current turn) and geographical areas/regions as per realistic climate behaviours in Spain. Whatever current weather conditions occur on each tile and turn (and this "read-only" map will display them as in a real weather map, with symbols, etc) will affect combat happening in the main map introducing extra combat variables. From the heavy rains and muddy fields of the battle of Guadalajara (march 1937), the freezing -20°C and deep snow of the battle of Teruel in winter 1937 to the scorching over 40°C of the Ebro battle in summer 1938, the very variable climatic conditions in Spain really affected the historical events depicted in the scenario.
- Strategic map: Another "read-only" map which shows in detail important objectives, industrial and military resources, and where the combat is currently happening.

All sounds crazy, right? well, I'll try to get it implemented and working :D

However, after reading this thread I found out I can't add a new map to an existing scenario, so I can't reuse my existing .scn file and I have to start from scratch, using the Sci-fi game (as I want a total of 4 maps). This is not going to be a big problem as I already had to start from scratch before when I expanded the original map and set up tribe-specific techs and buildable units, and thanks to ProfGarfield's script I weon't lose much work, plus the main map is already perfectly shaped and ready to be exported from the .scn into a .mp file.

So yes, I'll start playing around with all this in the next days :)

Pablo
 
Last edited:
New update :)

My mind as a scenario designer is still in the old MGE days, but after having played recently some modern ToT (with ToTPP and Lua) scenarios I have realised about some very nice features I'm still not taking advantage of: ToT multi-maps. I have been going through some ideas (I hope innovative enough) that I want to implement here in my SCW revamp, and with Lua it will be possible:

- Main map: Current map with units, cities, etc, good old civ game, this is where all action will occur. Nothing new here.
- Political map: A quick "read-only" map showing what territory currently controls each tribe featuring plain simple colours (like any standard political maps). Helpful to see how the frontlines progress, the different regions, borders, etc. Lua will maintain each tile in this map depending on how frontlines progress in the main map (on city captured, etc).
- Weather map: I plan to have a randomly generated weather engine written in Lua for the scenario which will be based on seasons (extracted from the current turn) and geographical areas/regions as per realistic climate behaviours in Spain. Whatever current weather conditions occur on each tile and turn (and this "read-only" map will display them as in a real weather map, with symbols, etc) will affect combat happening in the main map introducing extra combat variables. From the heavy rains and muddy fields of the battle of Guadalajara (march 1937), the freezing -20°C and deep snow of the battle of Teruel in winter 1937 to the scorching over 40°C of the Ebro battle in summer 1938, the very variable climatic conditions in Spain really affected the historical events depicted in the scenario.
- Strategic map: Another "read-only" map which shows in detail important objectives, industrial and military resources, and where the combat is currently happening.

All sounds crazy, right? well, I'll try to get it implemented and working :D

However, after reading this thread I found out I can't add a new map to an existing scenario, so I can't reuse my existing .scn file and I have to start from scratch, using the Sci-fi game (as I want a total of 4 maps). This is not going to be a big problem as I already had to start from scratch before when I expanded the original map and set up tribe-specific techs and buildable units, and thanks to ProfGarfield's script I weon't lose much work, plus the main map is already perfectly shaped and ready to be exported from the .scn into a .mp file.

So yes, I'll start playing around with all this in the next days :)

Pablo
Do you wanna have files from my current projects using such features (EpicWwiiEuropeTotpp & EmperorIsDead) to have exemples on hand ?
 
Top Bottom