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

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
And this is the promised Units.bmp file for my SCW scenario revamp. It features the amazing work performed by mostly @Fairline (special thanks for these recent requests on top of all the SCW units you already prepared for my ToT v3 upgrade, @McMonkey's version and your own OG works you kindly shared with me) and @Tanelorn. It also includes some tweaks done by @Catfish, @CurtSibling and myself. Most of my own tweaks are minor enough to not to deserve my initials.

The first block of 189 slots are the in-game units. However, on top of this I decided to include extra slots (call it a "SCW mega-compilation"). And before you ask, yes, it works fine in game with such a large file :)

Second block is about alternate graphics for the existing units. If for some reason players want to replace some units, feel free to copy-paste. But please keep in mind I included in the game what I believe is most accurate in terms of camo/colouring/equipment though.

Third block is about relevant units that took part in the SCW but I didn't have room or were not in line with my vision. But they are good enough to be included in the file. Special mention deserve the multiple trucks and tractors that are featured here.

Fourth block consists of alternate poses and uniforms for units I already included in either the 1st and 2nd block. With such poses, clothes and heads, virtually any infantry unit can be represented.

Fifth block is about units that were incorrectly included in previous SCW scenarios or related compilations. These never made it historically according to my sources. Please note I was the first one to make such mistakes when I included a fighting "Condor Legion" infantry unit or a FlaK 36/37 in v1 of my scenario back in the day.

Sixth slot is post-war units I wanted to include...just for the sake of it! Most of them recently tweaked by myself.

PS: There are some units with temporary white shields which will be replaced once I get additional help.

Units.png
 

Attachments

  • Units.bmp
    4.7 MB · Views: 4

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
It's time to update you on more major game mechanics I'm currently coding with Lua, plus other relevant progress news:

1) An extra tribe (the 7th) called "AI Allies" has been introduced to the game. The role of this tribe will depend on which tribe is the Human Player using. This AI ally tribe will depict in-game units that are not under direct control of the human player, but are not enemies either. With this I open great potential for both sides: I can control with Lua desobedience of some troops by just changing their owner of specific units to this ally (temporary or permanently), political events and disputes between central government and some regionally controlled units, conflicts between several militia units, foreign-controlled units acting on their own decisions...etc, but what's most important: any foreign weapon shippings will come as AI controlled freighters for both sides, which will be directed by Lua to head to their closest major ports and if they safely make it there, Lua will handle the unloading and delivery (creatrion) of the relevant weapons/reinforcements. With this I add to the game the realistic value the cargo freighters and weapon deliveries that constantly came to spain despite of the Non-Intervention Pact. Back in v3 of the scenario I was just automatically creating these reinforcement units directly on the major ports, and the freighters were just extra shields to be disbanded. @McMonkey's modification implemented transport/air carrier capabilities to these freighters but the human player was responsible for moving them to safety to unload their cargo. Here, and thanks to this extra tribe and Lua, I realistically represent the need for the human player to protect the sea routes and escort these vessels, but never directly control them.

2) Implement morale factor for both sides. Morale will affect how units perform in combat and other several factors related to city happiness, research progress, etc. Morale will suffer when cities are lost (especially if major objectives), when capital ships are sunk, commanders killed in action, etc, and will get boosted when similar actions are inflicted to the enemy.

3) Given I am implementing historical and realistic unit ratios, I want to code an actual "Casualties Report" where by a key-pressed, a dialog will show up with actual numbers of soldiers, vehicles, airplanes and ships lost for each side. Given I want to prevent any healing/repairing in the scenario of certain units (credit goes to @Dadais for the idea), when units are only damaged by combat their lost hit points will count towards these casualty counters. I can control all of this thanks to the way @Prof. Garfield has implemented the LST combatSettings.lua mechanics (file which I already modified heavily).

4) I plan to let the Human Player to be able to give "bulk orders" to units of a certain type (offensive, defensive) on a certain tile or city by a multiple choice menu on key-press. One of the main cons of all previous versions of my scenario (since v1) was the time consuming and boring mechanics to have to move loads of units every turn appearing in the port cities to the actual frontlines. This is something most large-scale scenarios such as Red Front have suffered: players had to spend more time moving units around than actually planning offensives and fighting, which is the fun part. With what I have in mind it all should be more easy thanks to Lua.

So as you can see, I'm still focused on implementing basic game mechanics. I will not start coding actual historical events until I'm done with all these mechanics, and I still have loads to implement!!...challenging reactive AI one of the most difficult items in my "to do list".

EDIT: Updated the progress report as of today:

Comments/suggestions are always welcome!

Have a great day
 
Last edited:

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
Some actual in-game examples:

The maximun number of T-26B tanks to be received in the game will be limited to 47 (281)
The maximum number of CR.32 planes to be received will be limited to 63 (376)
The initial numbers of Legion units on scenario start will be 18 civ2 units (2 legions, of 3 "banderas" each, each "bandera" with 3 infantry companies + 1 MG company). During the war each bandera received a 4th company, which will translate into 6 additional civ2 units created by events.
So as I said previously, I'm limiting the amount of foreign weapons/reinforcements to actual historical numbers. One of the flaws of all previous versions of my scenario was that once the relevant tech was researched, every turn a unit of a particular type would respawn automatically with no limits, leading to unrealistic situations where a particular plane received in limited numbers, would had completely unrealistic figures in game.

Thanks to Lua, I can limit this to actual historical numbers (though unfortunately not all the historical sources throw the same figures), based on the unit ratio conversion I defined for the scenario.

This is controlled by the parameters.lua file. If reinforcements need to be created (the relevant tech is researched and an AI allied freighter arrived to a port city), Lua code will ensure a random number of units, but never more than the historical actual number, are created by events. See example of how I am limiting the numbers for some Republican planes:

1665764550161.png
 

Prof. Garfield

Deity
Supporter
Joined
Mar 6, 2004
Messages
3,975
Location
Ontario
3) Given I am implementing historical and realistic unit ratios, I want to code an actual "Casualties Report" where by a key-pressed, a dialog will show up with actual numbers of soldiers, vehicles, airplanes and ships lost for each side. Given I want to prevent any healing/repairing in the scenario of certain units (credit goes to @Dadais for the idea), when units are only damaged by combat their lost hit points will count towards these casualty counters. I can control all of this thanks to the way @Prof. Garfield has implemented the LST combatSettings.lua mechanics (file which I already modified heavily).
Damage to Civ II units doesn't necessarily represent casualties. It just represents diminished combat effectiveness. For example, a unit might fight, defeat an enemy, take relatively light casualties, but use up so much of their ammo and supplies that they'll be very vulnerable to counter attack for a while.
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
Damage to Civ II units doesn't necessarily represent casualties. It just represents diminished combat effectiveness. For example, a unit might fight, defeat an enemy, take relatively light casualties, but use up so much of their ammo and supplies that they'll be very vulnerable to counter attack for a while.
In my opinion it really depends on the unit type and also what a Civ2 unit represents in real world terms.

A naval unit (ratio 1:1 in my scenario, where it actually represents an actual ship) when suffering Civ2 damage, and therefore having less hit points and having the "health bar" not filled to 100%, I agree it would represent damage. The ship is still afloat, it still can fight, but because of that damage its movement points get reduced. I totally agree with you. I will allow ships to slowly be repaired if they make it back to a port city, but not if just put to "sleep" in the middle of the ocean, which is what we all do in Civ2 games.

Another example of 1:1 units would be commanders, where a Civ2 unit represents an actual person. Unless hit points reduce to zero and the unit is killed, reduced hit points represent injuries. Agree with you it's not casualties, but injuries.

But in my view, when a civ2 unit actually represents many actual units, we are not talking about just damage. In this scenario, a Civ2 infantry unit actually represents an infantry company. That means around 150 soldiers. If after combat, an infantry Civ2 unit gets its hit points reduced to 50% of its original strength, then yes we're talking about casualties. Of course there will be wounded soldiers that eventually will heal and maybe sent back to the front lines, but there will also be many KIA. Therefore I want to translate these hit points in casualties. Maybe not 100% of the hit point loss will be actual casualties, so I might introduce a correction factor to represents injuries.

Same for vehicles and planes. Here Civ2 units represent 1 to 5 actual vehicles/planes. If after combat the hit points get reduced to 10%, health bar red, of course you can take that some vehicles would be put out of service (total loss) or some planes of the group would have got shot down. Of course there will also be damaged units which would safely make it back and eventually be repaired, but again, that wouldn't be the majority.

This is a game, I can't reproduce actual reality, so I need to adjust what I can and add some fantasy too :) Maybe other scenario designers think this total nuts and useless, nobody is going to see these casualty reports, but...I would!
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
any foreign weapon shippings will come as AI controlled freighters for both sides, which will be directed by Lua to head to their closest major ports and if they safely make it there, Lua will handle the unloading and delivery (creatrion) of the relevant weapons/reinforcements. With this I add to the game the realistic value the cargo freighters and weapon deliveries that constantly came to spain despite of the Non-Intervention Pact. Back in v3 of the scenario I was just automatically creating these reinforcement units directly on the major ports, and the freighters were just extra shields to be disbanded. @McMonkey's modification implemented transport/air carrier capabilities to these freighters but the human player was responsible for moving them to safety to unload their cargo. Here, and thanks to this extra tribe and Lua, I realistically represent the need for the human player to protect the sea routes and escort these vessels, but never directly control them.
This is my current focus. A complete foreignShipments.lua module to allow me handle one of the most important aspects of the Spanish Civil War: the continuous flow of foreign weapons despite the Non-Intervention Committee impediments.

My objective is to have a realistic and interesting system to simulate, within Civ2 terms, the importance of the naval routes in our conflict. This is why, as I said in the previous post, the freighters won't be human controlled. They will be controlled instead by a new AI tribe allied to the human player which will know where to redirect them (heading to different ports for each side issuing continuous goto orders). The human player's responsibility will be to protect the sea routes and escort the ships appropriately, and at the same time to try to capture (sink) the enemy freighters, as doing so will prevent the enemy from receiving the foreign supplies. Freighters will appear in random locations and will head to different ports, making each experience unique.

What will happen once a freighter safely arrives to a port? (entering a tile adjacent to a port city). Then a realistic combination of weapons will be created inside the city, and a comprehensive message outlining the ship details and cargo unloaded will pop up. This is all to contribute to the historical immersion, which is my main objective in version 4 of my scenario.

What will happen if the freighter is intercepted by the enemy? Then these reinforcements will never make it, but will count as "delivered" anyway.

For this I defined a comprehensive list of actual freighters, sizes, types of cargo and some extras for each tribe:

1666089484114.png


What next? In versions 1 to 3 of my scenario, reinforcements would automatically appear in the port cities as long as the human player managed to research specific technologies (e.g. having researched "acquire fighter aircraft (I)" would give the Republican player I-15s on every turn and He-51s for the Nationalist player). I did what I could within the MGE Macro language limits. Basically foreign weapons would spawn without limits regardless of the naval superiority, which was completely unrealistic.

But now, thanks to ToT, Lua, and the enhanced tech tree introduced in the last version of TOTPP, I can define realistic combinations of prerequisite techs. I have defined a standard way which works like this for each potential unit to be received:
  • Diplomacy prerequisite: "Diplomatic" tech needed first. Players will need to first contact potential countries if they want to "purchase"/receive weapons from them. E.g. "approach the Soviet Union".
  • Technology prerequisite: Actual tech needed, in line with previous versions of the scenario. E.g. "acquire fighter aircraft (I)"
  • Unit type: The actual unit type being received.
  • unitCounter: Counter which tracks how many units of this type has the player already received. This is to implement realistic reinforcement numbers as explained in previous posts.
  • unitMax: Maximum number of units of this type to be received. This is to implement realistic reinforcement numbers as explained in previous posts.
  • Two extra fields which link to the cargo of each ship, to ensure each shipment has a realistic amount of units being delivered (we don't want a small 1000 Ton displacement ship delivering 200 airplanes!)
This is how the config table looks for receiving Russian T-26 tanks for the Republican Spanish:

SQL:
repReinforcementsTable[4] = {
    dipPrerequisite=object.aapproachtheSovietUnion,
    techPrerequisite=object.aacquiretanksI,
    unitType=object.uT26Bmod1933,
    unitCounter="cT26Bmod1933",
    unitMax=param.maxT26Bmod1933,
    unitType=reinforcementType.vehicle,
    shipSource="Russian"}

What I'm currently working on:

I'm implementing Lua functions to "fill" freighters with random combinations of possible equipment, without exceeding the capacity limits for ships, and their actual historical limits. Everything will be random, the type of units received (also depending on the tech prerequisites), the amounts of these units, the different combinations, the freighter chosen and its capacity, the location where the freighter is first created, its destination, etc. All done this way to ensure a refreshing and realistic game experience, avoiding grinding.

Many will think that it's all too much work, it's just a Civ2 scenario, but for me it's much more than this. It gives me the opportunity to mix both my profession (programmer) and one of my main passions (history, especially focused in the SCW) :)

I'll report back once everything works and I can show some PoC screenshots.

Thanks for reading,

Pablo
 

Dadais

King
Joined
Oct 20, 2010
Messages
761
Location
France
My objective is to have a realistic and interesting system to simulate, within Civ2 terms, the importance of the naval routes in our conflict. This is why, as I said in the previous post, the freighters won't be human controlled. They will be controlled instead by a new AI tribe allied to the human player which will know where to redirect them (heading to different ports for each side issuing continuous goto orders). The human player's responsibility will be to protect the sea routes and escort the ships appropriately, and at the same time to try to capture (sink) the enemy freighters, as doing so will prevent the enemy from receiving the foreign supplies. Freighters will appear in random locations and will head to different ports, making each experience unique.
Do both republicans and nationnalists have such trade route ?

I'm asking that on a multiplayer purpose.

Shouldn't there be two AI civilisations to represent then both their boats ?
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
Do both republicans and nationnalists have such trade route ?

I'm asking that on a multiplayer purpose.

Shouldn't there be two AI civilisations to represent then both their boats ?
Hi, yes they do. The new "AI allied" tribe will manage things differently depending on which tribe is the Human Player using (tribe.isHuman).

So for instance, if you choose to play as the Republicans, the "AI allied" will manage your freighters, so you don't have direct control over them. However, the Nationalist freighters will be owned by the normal AI controlled Nationalist tribe. I saw no point of having 2 AI controlled tribes to do a similar thing.

The game will be fully playable from both sides against the AI. Unfortunately I don't see a way I can implement the multiplayer (PBEM, human vs human) option which existed in versions 1-3 of the scenario. Not even sure how multiplayer works in ToT anyway :D
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
Getting closer...using multi-dimensional arrays and more complex table stuff I implemented to minimise lines of code. I'm enjoying this Lua stuff, will eventually have to add it to my LinkedIn profile :D

Can't wait to finish this module and see it in-game!

1666189372870.png
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
It works! :) For this PoC test I gave the Republican human player the required technologies (cheat mode) to be able to receive I-15s, I-16s, SB-2s and T-26s. The human player is also controlling the freighter as I haven't coded the AI part yet, but for test the functionality it's enough.

1) The freighter approaches Valencia:

1666282062402.png


2) When reaching the city's adjacent tile, this message pops up (all dynamic text, of course):

1666283032315.png

The system randomly chose to pick the "Cabo Santo Tomé", which was one of the biggest freighters, so the amount of cargo is quite substantial! Let's see what we have in the city after its arrival:

1666283251869.png


3) Tried again in another city, got a different freighter and cargo:

1666283993681.png

I got the famous Komsomol: https://www.wrecksite.eu/wreck.aspx?136337 This ship is smaller so I got few weapons in this shipment compared to the previous test:

1666284138475.png

4) Another try somewhere else:

1666284681478.png

This time I got some I-15s too, which didn't come earlier. The "Cabo San Agustín" was one of the most appreciated freighters and made multiple trips to the USSR: https://blog.todoavante.es/?p=12202

I still have stuff to polish and lots of weapons to configure for both sides, but this gives you a taste of the new functionality. I tried to write the code as intuitive and self-descriptive as possible but it has some complexity:

1666285203724.png


One of the "bugs" I'm facing is when I'm creating the suppy truck (caravan) unit and setting its commodity, the id I set is being ignored and the freighter always gets created with commodity id 0, so gotta dig deeper on that.

See example:

1666285800211.png


So the commodity for my supply truck (caravan) unit is GAZ-AA spare parts, which are categorised as 11 as per below table entry:

SQL:
repExtraCargo[17]={name="GAZ-AA spare parts",weapons="Russian", commodityId=11}

The game picks it correctly (11):

1666285765367.png

The code:

SQL:
-- Set commodity for caravan unit
if unloadedUnit.type == object.uSupplytruck then
    unit.domainSpec = extraCargoTable[randomCargo].commodityId
end

But the truck is always created with commodity id 0, which is the first one in the Rules.txt file:

1666285991853.png

Code:
;
;   Trading Commodities
;
@CARAVAN
Rifle ammunition,
AT shells,
Medium artillery shells,
Heavy artillery shells,
Aviation supplies,
Airplane engines,
Aerial bombs,
Naval supplies,
Gunpowder,
Medium machine guns,
Machine gun ammunition,
Vehicle spare parts,
Rifles,
Light machine guns,
Submachine guns,
Fuel,

Any ideas @Prof. Garfield @JPetroski @Dadais ?

Thanks,

Pablo
 

Prof. Garfield

Deity
Supporter
Joined
Mar 6, 2004
Messages
3,975
Location
Ontario
The code:

SQL:
-- Set commodity for caravan unit
if unloadedUnit.type == object.uSupplytruck then
unit.domainSpec = extraCargoTable[randomCargo].commodityId
end
You are changing the domainSpec of 'unit', not 'unloadedUnit'. I've done that before...
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
You are changing the domainSpec of 'unit', not 'unloadedUnit'. I've done that before...
Arghhg! That was it :blush:. It didn't crash the interpreter as "unit" exists as a parameter passed by, it's the actual freighter.

Thank you very much!!
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
All bugs fixed :)

Some Polish FT-17 make it to Bilbao...
1666307018653.png

The 75mm shells are effectively carried by the supply truck unit :)
1666307111275.png


And two examples for the Nationalist side:

German weapons...
1666307263008.png

1666307328519.png

Now I "approach Italy"...
1666307435079.png

...and cheat-create another ship heading to Cádiz:
1666307491500.png

(Yes, the "Cabo Espartel" is a very active ship! https://www.todoavante.es/index.php?title=Cabo_Espartel)

The truck carries rifles as expected:
1666307576165.png


Third example...this time I get some Panzers!
1666307933631.png


Regards,

Pablo
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
Hi all, I completed the entire weapons shipments functionality, which is a core mechanic in my scenario. However, I'm currently optimising the code to avoid unnecessary loops and also trying to limit specific interations as in some playtests I've run into apparent "infinite loops" when I have too many AI-controlled freighters and I need to set their course heading to the relevant ports. I haven't pinpointed the issue yet but I will! :)

But I'm happy that I've achieved a way so freighters spawn in random locations across different areas in the sea, and set course to their closest port. Once they make it safely, they will unload specific weapons as you have seen in the previous screenshots.
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
All bugs resolved in this module, no mode hidden infinite loops :) The AI controlled freighters keep arriving to different ports, and will unload specific weapons only when the relevant diplomatic and technical techs have been researched:

1666793976768.png

I'll move on to the following functionality now:
4) I plan to let the Human Player to be able to give "bulk orders" to units of a certain type (offensive, defensive) on a certain tile or city by a multiple choice menu on key-press. One of the main cons of all previous versions of my scenario (since v1) was the time consuming and boring mechanics to have to move loads of units every turn appearing in the port cities to the actual frontlines. This is something most large-scale scenarios such as Red Front have suffered: players had to spend more time moving units around than actually planning offensives and fighting, which is the fun part. With what I have in mind it all should be more easy thanks to Lua.
For this I'll design a multiple choice menu invoked "onKeyPress". This will allow me to reuse the same key for multiple options applicable to the active unit/location. My plan is to try to make the player's life as easy as possible and not have to grind too much moving units around. Will report back when I have something to show :)
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
I'll move on to the following functionality now:

For this I'll design a multiple choice menu invoked "onKeyPress". This will allow me to reuse the same key for multiple options applicable to the active unit/location. My plan is to try to make the player's life as easy as possible and not have to grind too much moving units around. Will report back when I have something to show :)
So this is a quick PoC on how the "bulk movement" of units will work. So far I have only implemented the basic "move all" mechanic, but this any further options will be easy to implement (move all offensive units, move air units only, move everything but leave a defending garrison, etc). I have done this because moving units was the most frustrating aspect of all previous versions of my scenario: having to move every turn all the units received via events on the different ports was simply exhausting and now Lua allows me to avoid all that grinding so I think it's well worth the time I'm investing in this.

1) First, we go to a tile or city with more than one unit. For instance I go to a city with 3 fortified units:

1667006019123.png


2) I select/activate one of them and press the "k" key (this key will trigger specific actions selectable via a menu). Then I select the first option in the menu:

1667006331663.png


3) I select to move all units as it's the only functionality I've implemented so far:

1667006855002.png


4) I get the instructions on how it works:

1667006425375.png


5) So I press the 'g' key as instructed, and I get the standard Civ "go to" functionality screen. Having this screen saves me much time as I don't need to code anything and I get a nice scrollbar. Then I select a city (Zaragoza) in the list and press OK:

1667006595099.png


6) Then the active unit auotmatically moves, and following the instructions I press the 'k' key again. Then if I go back to the city i was I can see the remaining units are no longer fortified and have a "go to" order set to move to the same city I selected previously:

1667006742136.png

1667006762488.png

Then I can move on with my game without having to move these units one by one. This is especially useful when a freighter carrying weapons arrives to port and you want to send these units to the frontline, or if you plan a huge offensive and have to move multiple units at once!
 

Dadais

King
Joined
Oct 20, 2010
Messages
761
Location
France
BTW: I'll research if there's a way to make the rest of the units to move automatically straight after setting the "go to" order, so there's no need to wait to the end of the turn. Maybe if I activate them they'll move...
My first idea there would be a land convoy unit, either "transporter" (I guess @Prof. Garfield and @JPetroski can tell about a land transporter module in the template) or as a temporary replacement unit ?

That said, it consumes one unit slot I'm not sure you have.
 

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
My first idea there would be a land convoy unit, either "transporter" (I guess @Prof. Garfield and @JPetroski can tell about a land transporter module in the template) or as a temporary replacement unit ?

That said, it consumes one unit slot I'm not sure you have.
I'll try a different approach and will report back :)
 

Dadais

King
Joined
Oct 20, 2010
Messages
761
Location
France
I'll try a different approach and will report back
I could also think of a convoy table of (convoyId, tribe, tileToGo, convoyMoveDone & table of units) you could check when a unit is activated :
1. Check for each convoy if its units still have the goto order (else remove the order to adapt and destroy convoy)
2. Check if one of the units in the convoy has no movepoint left then check other units in the convoy : if movepoint is left, consume it and teleport them to the unit which did move towards the common target and set true convoyMoveDone.

Give this table a maj at the beginning of the respective convoy tribes.

-gameplay issue there : what about units with same goal yet different mobility ? Add movepoint consumption to units in a convoy to lower them at the level of the convoy slowest at the beginning of turn with the maj ?
-code issue there : that's maybe a lot of calculs to do each time a unit is activated in compare with the feature provided ?
 
Last edited:
Top Bottom