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

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 ?
-code issue there : that's maybe a lot of calculs to do each time a unit is activated in compare with the feature provided ?
Exactly, I'm not convinced of using "land transporters" because of the points you outlined.

Nevermind I fixed it :)

I really thought that giving a "gotoTile" order to a unit that has not spent its movement points would automatically make it move, but no, I had to activate it beforehand. So just invoking "unit:activate()" before setting the goto order did the trick:

SQL:
for unit in tile.units do
    unit:activate()
    gen.setToGoingTo(unit,destination)
end

Now it's doing exactly what I wanted it to do so I'll amend the "instructions" pop up :)
 
In OTR we used a "formation" feature where you could move multiple units as one, and could grab them from the same tile, or many tiles (I think we had 4x4 or 5x5 as the max). This significantly helped housekeeping when moving mass air formations in that scenario, but it wasn't automatic as the player would still need to input the movement keys, one at a time.

This might be an easier solution for you than trying to get the go to command to work over time and it would save a lot of work for the player (you could move a stack of 20 units as one, for 1/20th of the time).

I may, however, be misinterpreting what you are trying to achieve.
 
I may, however, be misinterpreting what you are trying to achieve.
I only wanted to be able to move multiple ones at once (bulk movement), instead of having to do it one by one as in traditional MGE/ToT scenarios. In my old MGE I got fed up of moving every turn multiple units spawning in the same locations via events, so I wanted to address that with Lua.

I have done some amendments as moving all units at one will never work correctly when units of different domains are in the same city. However I run into an issue I need to troubleshoot: If my units when moving "wake up" another waiting/sleeping unit when passing nearby, then the "loop" breaks as these become now active. All the remaining units which were supposed to be activated and set goto are just waiting with the "goto" order but not moving...

I believe gen.selectNextActiveUnit and gen.activate(unit) would help me so will dig into their functionality...
 
I've only skimmed the posts from today, but if you haven't noticed, you can hold down CTRL in order to move all the units on a square (I think excluding fortified units). That's not necessarily a reason not to build/rebuild something else, but it is available.
 
I've only skimmed the posts from today, but if you haven't noticed, you can hold down CTRL in order to move all the units on a square (I think excluding fortified units). That's not necessarily a reason not to build/rebuild something else, but it is available.
Wait ... what ?!? :D
 
That was interesting! I need to check that CTRL key when I get back home and see if that meets my requirements
Woaaa with ToTpp it woooorks ! Much thanks @Prof. Garfield . Tens of years playing civ2 unaware of that ! :D
Fortified unit are indeed left on tile. So are sleeping ones it seems
-To take care of, "Fortified" ordered and "sleeping" ordered units are left on tile, but "fortify" ordered units aren't and go with the stack.

AAAARGH ! Tested the Ctrl trick to go through a transporter. Ctrl + n is "End Player Turn" :lmao:
 
Last edited:
Woaaa with ToTpp it woooorks ! Much thanks @Prof. Garfield . Tens of years playing civ2 unaware of that ! :D
Fortified unit are indeed left on tile. So are sleeping ones it seems

AAAARGH ! Tested the Ctrl trick to go through an transporter. Ctrl + n is "End Player Turn" :lmao:
I'll test it tomorrow as I'm still out, but yes, just like you, many years playing Civ and had no idea I could do that, is it a ToTPP feature or vanilla ToT?
 
I have done some amendments as moving all units at one will never work correctly when units of different domains are in the same city. However I run into an issue I need to troubleshoot: If my units when moving "wake up" another waiting/sleeping unit when passing nearby, then the "loop" breaks as these become now active. All the remaining units which were supposed to be activated and set goto are just waiting with the "goto" order but not moving...

I believe gen.selectNextActiveUnit and gen.activate(unit) would help me so will dig into their functionality...
gen.activate runs unit:activate(), and then also the onActivateUnit event. In earlier versions of TOTPP, unit:activate() didn't run the unit activation code (I think that's resolved now, but I'm not 100% sure), so I wrote gen.activate.

gen.selectNextActiveUnit is a function that runs behind the scenes, in events.lua. simpleSettings.lua has a line to activate its effects:
Code:
-- uses events to select the next unit to activate
-- see gen.selectNextActiveUnit 
simpleSettings.enableCustomUnitSelection = false

What it does is select the next unit that 'should' be activated, and gives all other units the 'wait' command (unless they have some other order). Units that you've given the wait order to will be stored in a table. Units with goto orders have priority over other units, so if you assign goto orders to units, they'll move next, or at least after the next 'selected' unit has moved. I suppose it might make sense to add a function to get the 'next' unit, so that it can be given the wait order if goto orders have been given.

You can provide a 'weight' function to help select the next unit to be activated. The unit with the smallest weight is chosen.
Code:
-- provide an alternate weight function for selecting the next
-- active unit
-- see gen.selectNextActiveUnit
simpleSettings.customWeightFunction = nil
By default, the weight is +1 if the units are of different types, +10,000 if the units are on different maps, and +distance between the unit that was just activated, and the unit being given a weight.
 
I've only skimmed the posts from today, but if you haven't noticed, you can hold down CTRL in order to move all the units on a square (I think excluding fortified units). That's not necessarily a reason not to build/rebuild something else, but it is available.
So I did some tests with the CTRL key and I saw I need to use the keyboard arrows instead of the mouse and move through tiles one by one. Not sure if this is how other players usually move their units, but I always played Civ2 by selecting a unit and with the mouse selecting where I wanted the unit to go, being that a city or a tile, when the mouse cursor changes to "GO":

1667117139521.png


Given I can't give text inputs with Lua (or I haven't found a way to do it...I wish the user could enter data through a dialogue, the same as when you found a city and give it a name) I thought of using the "go to city" interface that Civ2 shows when pressing the 'g' key and that's what I showed in my screenshots. At least it was giving me a way to select a destination in a nice menu (with a scrollbar) and then with Lua code I was manipulating that selected destination to set goto orders to other units.

gen.selectNextActiveUnit is a function that runs behind the scenes, in events.lua. simpleSettings.lua has a line to activate its effects:
Code:
-- uses events to select the next unit to activate
-- see gen.selectNextActiveUnit
simpleSettings.enableCustomUnitSelection = false

What it does is select the next unit that 'should' be activated, and gives all other units the 'wait' command (unless they have some other order). Units that you've given the wait order to will be stored in a table. Units with goto orders have priority over other units, so if you assign goto orders to units, they'll move next, or at least after the next 'selected' unit has moved. I suppose it might make sense to add a function to get the 'next' unit, so that it can be given the wait order if goto orders have been given.

You can provide a 'weight' function to help select the next unit to be activated. The unit with the smallest weight is chosen.
Code:
-- provide an alternate weight function for selecting the next
-- active unit
-- see gen.selectNextActiveUnit
simpleSettings.customWeightFunction = nil
By default, the weight is +1 if the units are of different types, +10,000 if the units are on different maps, and +distance between the unit that was just activated, and the unit being given a weight.
After reading your post I decided I am not going to scrap what I've done so far as I still see usefulness in it (players can still use the CTRL key and the keyboard arrows if they want of course), so I'm going to use your gen.selectNextActiveUnit by coding a 'weight' function, I think that would make my "bulk go to" units move all first without "waking up" other units on their way. Thanks a lot @Prof. Garfield for the explanations, as usual!
 
Hi all, quick update: I continue working in game mechanics, this time implementing generic code that could be easily expanded to scenarios other than SCW.

I started working in a "effectiveAI.lua" module, which will be core to ensure the AI is challenging enough for the human player. As you know, I'm avoiding creating unrealistic AI controlled units "out of the blue" and will stick to historical numbers, so I need to ensure the AI makes good use of them.

So far I've successfully implemented a routine to ensure that all AI cities are properly defended with enough defensive units of certain types (currently I'm handling machine guns, anti-tank guns, AA guns, fighters and police garrisons) depending on the city's position in regards to its distance to the frontlines (using the political map), city size and major/minor objective flags. The closest an enemy AI city is to the human player, and the more important that city is, the stronger defenses it will have by default.

All of this is fully dynamic (nothing hardcoded) and quickly configurable. It took me a while to get it working successfully and without impacting performance, but now that the core functionality is complete I'll enhance it with extra factors to take into account. For instance, I want to prioritise the AI to defend cities that have suffered attacks in the previous turn, so the AI will be effective reacting to attacks the same way the human player would.

Once happy enough with the defensive aspect, I'll implement the offensive one, which will be quite challenging :)
 
Once happy enough with the defensive aspect, I'll implement the offensive one, which will be quite challenging :)
Forgot to say that for this I might even implement some machine learning element (decision trees, training the model, etc). Let's see how possible is that with Lua. If I see it's too overcomplicated I'll develop my own simple attack functions.
 
Hi, I haven't posted in a while. I just wanted to let you know that unfortunately I need to put the SCW scenario development on hold for a couple of months until further notice.

The reason is...I must finish a book I've been writing for the last 8 years and it's around 80% done already. A week and half ago I found out there's somebody else writing about the same topic, so must finish it ASAP to publish it before this "competitor" does. This means all my spare time will be focused on the book, and not civ2.

Thanks for all your support and talk to you soon!

Pablo
 
Hi, I haven't posted in a while. I just wanted to let you know that unfortunately I need to put the SCW scenario development on hold for a couple of months until further notice.

The reason is...I must finish a book I've been writing for the last 8 years and it's around 80% done already. A week and half ago I found out there's somebody else writing about the same topic, so must finish it ASAP to publish it before this "competitor" does. This means all my spare time will be focused on the book, and not civ2.

Thanks for all your support and talk to you soon!

Pablo

Good luck with this other project !
Guess all the civ2 community will be longing for your return !
 
Pablostuka, good luck with your book! In the meantime here the battleship España is defending your work in progress. :)

España.gif
 
Thanks @Dadais @JPetroski @Civinator for your best wishes. The book it's about automobile history, another of my passions. This is actually my second book on the topic and now I'm just under pressure to get over with it. But it's good that this happens now because at least I can focus on it and finish it, otherwise it's always sitting there and me doing multiple other things :)

@Civinator that's amazing! Is it Civ3?

BTW I'm already missing messing around with Lua, I managed to get the AI to do very interesting things and redirect their defensive units where they are more needed :)

Thanks,

Pablo
 
@Civinator that's amazing! Is it Civ3?
Yes, it is a Civ 3 unit, created by Delta_Strife. Due to its relative small size it could be easily converted to Civ 2 ToT.

Edit: This is how the España including battle animation would look in a 64x64 unit box of ToT:

Espana.png
 
Last edited:
Top Bottom