The Hinge of Fate - Development Thread

If I switch this to less than or equal to, I get the exact opposite problem (being told I've failed even if I haven't):

local function enoughArmiesInFrance()
return minArmyInFrance <= unitsInRegion(inFrance)
end
 
Have you tried to write in console results from "function unitsInRegion(regionFn)" and "enoughArmiesInFrance()" to see what's going on ?

It seems to me you are counting AND british armies AND british fighters AND Maltese defenders AND german defenders wich are in France. Is that intended ?

Plus, for "function enoughArmiesInFrance()" to be true, with this code you need the "minArmyInFrance" variable (3?) to be equal or more than what you just counted ?
Seems strange.
 
I just noticed that inFrance takes a tile as argument, while in unitsInRegion(regionFn), you are calling regionFn(unit). Try instead to call regionFn(unit.location).

If you need more help, I'll look more closely at the function later. However, as Dadias points out, it looks like you could potentially be counting other things. You should probably re-write unitsInRegion to take two arguments, the regionFn and a unitWeightTable.
 
It seems to me you are counting AND british armies AND british fighters AND Maltese defenders AND german defenders wich are in France. Is that intended ?

OK - this seems to be exactly what the issue was - when I isolated the event, it worked fine:

local function unitsInRegion(regionFn)
local value = 0
for unit in civ.iterateUnits() do
-- if britishFighters[unit.type.id] and regionFn(unit) then
-- value = value + britishFighters[unit.type.id]
-- print("Successfully counted British fighters")
-- end
if britishArmy[unit.type.id] and regionFn(unit.location) then
value = value + britishArmy[unit.type.id]
print("Successfully counted British Army")
end

--if malteseDefenders[unit.type.id] and regionFn(unit) then
-- value = value + malteseDefenders[unit.type.id]
-- print("Successfully counted Maltese Defenders")
--end
--if germanDefenders[unit.type.id] and regionFn(unit) then
-- value = value + germanDefenders[unit.type.id]
-- print("Successfully counted German Defenders")
--end
end
return value
end

So, I suppose I can just break these into four different functions but before I do all that - is this something that "else if" instead of "if" would fix? Just curious if I'm going to spend a lot of time writing something a long way when all I need to do is tweak a word. All 4 of these things should be checked, so if I need to go ahead and write 4 of them I can, but I wanted to double check.

Thank you all very much for your help.
 
So, I suppose I can just break these into four different functions but before I do all that - is this something that "else if" instead of "if" would fix? Just curious if I'm going to spend a lot of time writing something a long way when all I need to do is tweak a word. All 4 of these things should be checked, so if I need to go ahead and write 4 of them I can, but I wanted to double check.
Like @Prof. Garfield pointed, you may just add a parameter* to your function "unitsInRegion()" to choose what you are gonna count when you call it..

*Its nature may depend on what you wanna count : Always only one item of the four present ? Or sometime also a combination of them ?
Also, if you always wanna only count one of the item, your function then could be simplified with such parameter by the way ;)
If you wanna be able to count combinations, adding a condition to your "if"s shall be required.
 
Last edited:
I'm not very confident in my ability to add the parameter so I went ahead and broke them apart with the following four:

unitsInBritainRegion(regionFn) - for the Battle of Britain
unitsInFranceRegion(regionFn) - for Dunkirk
unitsInMaltaRegion(regionFn) - for Malta

unitsInRegion(regionFn) - this is for counting German defenders in different areas. This is the only one that actually looks to multiple regions within the same function, so I hope it will work. I'm hoping that this:

Code:
local function unitsInRegion(regionFn)
    local value = 0
    for unit in civ.iterateUnits() do
        if germanDefenders[unit.type.id] and regionFn(unit.location) then
            value = value + germanDefenders[unit.type.id]
            print("Successfully counted German Defenders")
        end
    end 
    return value 
end

Will work with these without any issue. I *think* they will, because they're now doing precisely the same thing that similar code in Boudicca did, as opposed to counting different types of units for different functions, but I guess we'll find out.:

Code:
local function enoughDefendersInSicily()
    return minDefendersInSicily <= unitsInRegion(inSicily)
end

local function enoughDefendersInSardinia()
    return minDefendersInSardinia <= unitsInRegion(inSardinia)
end

local function enoughDefendersInCrete()
    return minDefendersInCrete <= unitsInRegion(inCrete)
end

local function enoughDefendersInNorway()
    return minDefendersInNorway <= unitsInRegion(inNorway)
end
 
I'm not very confident in my ability to add the parameter so I went ahead and broke them apart with the following four:

Code:
local function unitsInRegion(regionFn,unitWeightTable)
   local value = 0
    for unit in civ.iterateUnits() do
        if unitWeightTable[unit.type.id] and regionFn(unit.location) then
            value = value + unitWeightTable[unit.type.id]
            print("Counted "..unit.type.name.." with weight "..unitWeightTable[unit.type.id]..".")
        end
    end
    return value
end

Note: Once you are finished debugging, you may want to comment out the print line. Printing to the console is expensive enough that it can cause noticeable lag if you do it hundreds or thousands of times in a loop. If you're doing this onTurn or afterProduction it probably won't be noticeable anyway, but it might still clutter up the console for actual errors.
 
upload_2021-12-19_21-7-1.png


This is satisfying :D
 
It is a pitty that TOTPP still has no working solution for the defense animation (=attack animation) in the combat of animated Civ 2 TOT sprites.

HoodRun.gif


HoodAttack.gif


Hoodsink.gif


BismarckRun.gif


BismarckAttack.gif


Bismarcksink.gif


The blue colour in the funnels of the Hood and the turrets of the Bismarck marks the place for civspecific colours in these Civ 3 units (same effect as it can be done with masks in Civ 2 ToT).
 
Last edited:
Bismarck was chased down and sunk for the outrage in case anyone is wondering... Currently prepping for Barbarossa while trying to deal with the Southern issue and scrambling a bit to see if I can actually address it before I launch my main offensive.

What I can say about this scenario is you will definitely be stretched thin. My *hope* is that this is a scenario that is "fun to lose" so people will keep on playing and take advantage of the events I'm creating that try to beat you down. I'm not sure how many people are willing to do that - I think there's a tendency to give up early and restart, which would be a shame for this scenario, IMO. Half the fun (I hope, but we'll see) will be trying to stave off complete defeat and at least squeak out a stalemate or even marginal defeat.
 
The Afrika Korps races to confront the British and restore the situation in Cyrenaica.


upload_2021-12-20_6-33-49.png


Note: Once you are finished debugging, you may want to comment out the print line. Printing to the console is expensive enough that it can cause noticeable lag if you do it hundreds or thousands of times in a loop. If you're doing this onTurn or afterProduction it probably won't be noticeable anyway, but it might still clutter up the console for actual errors.

So I think earlier there was an issue that caused a ton of printing and you had advised that if I commented out one line somewhere it would remove most of this stuff. I can't remember if it was this or not. I'm hoping that I don't have too much lag in this scenario as it goes on and there are more units given how much I use with onActivate. There doesn't seem to be any real lag for the human player but Britain's turn takes a little while. It's not as bad as the AI turns in Red Front (yet) so I can live with it for now, but I'm keeping an eye on it and might need a second set of eyes before release just to see if I'm doing things in a stupid way that is causing way more trouble for the player than it should.
 
What I can say about this scenario is you will definitely be stretched thin. My *hope* is that this is a scenario that is "fun to lose" so people will keep on playing and take advantage of the events I'm creating that try to beat you down. I'm not sure how many people are willing to do that - I think there's a tendency to give up early and restart, which would be a shame for this scenario, IMO. Half the fun (I hope, but we'll see) will be trying to stave off complete defeat and at least squeak out a stalemate or even marginal defeat.

In the next version of the WW2 scenario SOE (Storm over Europe) I try to implant a GröFaZ-victory based on the space race victory in C3C. You can win by becoming the Greatest Field Commander of all Time (Größter Feldherr aller Zeiten) by conquering 5 main objectives on the map (in SOE for Germany Moscow, Stalingrad, London, Paris and the Suez canal). May be this can become an interesting idea for your scenario, too.

In your screenshot about the Cyrenaica the Marble Arch could be a neat additional detail in your scenario, especially for triggering some events (the graphics for the cities in that Civ3 scenario are Civ 2 graphics).

Marble Arch.jpg
 
Last edited:
If I ever find the time I really need to get into Civ3. I remember talking about it with Harlan all excited - he had a WW2 scenario already plotted out, but then we kind of took a look at it and were completely lost from a modding standpoint. Perhaps now it wouldn't be so difficult. Does it run well enough on Windows 10? I think I still have the CD.
 
I am still torn back and forth between Civ 2 ToT (especially with TOTPP) and C3C. Civ 3 is missing events (to substitute this, for the SOE scenario I had to sacrifice the techtree to become a calendar and now the triggering of the major events in that C3C scenario is possible, too. Fall Gelb, Unternehmen Barbarossa, Operation Torch, D-Day and many other events, even the correct commissioning of battleships with their correct names during WW2 can happen just in time with that calendar setting). For my much liked Civ 2 TOT space scenario, Civ 3 has nothing to form a perfect jedi knight as it is possible with the Civ 2 spies and to do those random "galactic terrain effects" as it can be done with Civ 2 ToT(PP), especially invasions from another galaxy or galactic quadrant (from a different map).

On the other side it is the number of high class animated units, that brought me many years ago to focus on Civ 3. The next version of my mod CCM will hold over 4,000 animated unit types and until now I have seen no limit how many of these units can be added to a mod or scenario. 31 civs, borders and culture are not bad, too - but I would be happy if some of the highlights of Civ 2, Civ 2 ToT and TOTPP could be added to C3C, too - or reverse, if the animated unit sprites that could be done with many Civ 3 units, could be properly transferred to Civ 2 ToT. Many years ago I showed, that this could be possible, but there was never found any solution for giving the defending unit sprites a proper use of an animation. :sad:

JPetroski, your old Civ 3 cd will not run any longer with win 7, 8 and in no case with Win 10 as the security program of that cd is no longer supported by microsoft. The Civ 3 Complete version of GOG (at present on sale for € 1,29 or an adequate amount in dollar) runs very well on my Win 10 pc and has the advantage, that the Flintlock patch (something similar to TOTPP, but not so massive and without Lua) can be used with the GOG version, too. The steam version has a problem with the labels text file.
This said, JPetroski please stay with modding Civ 2 TOT. You (and many other Civ 2 modders) are doing a phantastic work I am enjoying a lot. :hatsoff: After renovating my home, I thought to come back to the lua lessons in the cIv2 forums, so the landcarriers in my Civ 2 ToT space mod (battlestar Galactica, Cylon base stars, star destroyers and so on) can do a much better performance, but than the epidemic happened and I received emails, pms and direct posts on several forums about reworking, reloading and improving some of my C3C mods and scenarios as this helps other persons to feel better in these moments of restriction. I am sure the great scenarios you and other Civ 2 modders are creating, provide other people with much needed pleasure in these days of the
pandemic, too - even if there are no pms, emails and so on, but the most important in my eyes is to have fun with one´s own creations. :)
 
Last edited:
So I think earlier there was an issue that caused a ton of printing and you had advised that if I commented out one line somewhere it would remove most of this stuff. I can't remember if it was this or not. I'm hoping that I don't have too much lag in this scenario as it goes on and there are more units given how much I use with onActivate. There doesn't seem to be any real lag for the human player but Britain's turn takes a little while.

I suggested reassigning the print keyword to an empty function:
Code:
print = function() end
which will stop all printing. Not ideal, since there may be stuff that you don't mind printing, and can be useful. In particular, if you check for situations that indicate something went wrong, you may wish to print some information to the console before calling error.

In most recently noticed printing lag when I was testing a 1000 iteration loop for the key press event. Without the printing statement, the loop was not noticeable, but with it, the lag became apparent. If your game has thousands of units, it might end up counting hundreds of them, and printing the corresponding message. As long as the count doesn't happen all the time (i.e. not onKeyPress, onActivateUnit, onCanBuild, onCalculateCityYield), it shouldn't be an issue from a gameplay perspective. However, it will still clutter the console, so it would probably be best to comment it out once you are confident the event is working properly.
 
I've introduced a concept called "Kampfgruppe" and "Gefechtsverband."

Basically, for a large fee, a general unit can instantly bring a large number of units to their location. They can't do this in Britain, North Africa, or the United States. Because of the high cost (currently 5k, but subject to change), one can't do this that many times in the scenario. Fuel/money is important in this scenario and once your stores dip below a certain level you start having issues with units stalling out and not working as intended, annoyingly. Further, fuel is necessary to reinforce the Afrika Korps and do things like play politics in the Middle East. Finally, fuel is used every time a unit activates, so it dwindles over time. You start the scenario with very large stores (in testing, 50k but probably will bump it more to 75k or so) and you might think this allows for an awful lot of general recruitment. While true, it won't last for long and the AI gets enough units that I think folks will find themselves using this more as a fire brigade.

I do suppose the Gefechtsverband could be used to help win the Battle of Britain, but then I suppose if Germany really threw every resource they had at the battle, they might have won it in real life. Conquering Britain doesn't help your fuel situation for Russia so if you use up your funds early it may have consequences later. Thus, I think I'll leave it in and allow the player the choice of how to handle things.

Because of this, I've switched the road paving duties away from generals and towards Conscripts, which are a unit I need in the game so everyone always has something to build. The AI won't use it for this reason, of course, but now Germany has a reason to build these. Given the fuel costs of road construction I don't think this can be spammed, either, though one could certainly build infrastructure quicker with 5+ conscripts than 4 generals.

upload_2021-12-22_7-11-56.png
 
On the topic of fuel, it is also used to reinforce far off areas that you can't get units to naturally (due to limitations on transport craft without triggering Sea Lion). Generals can also choose to reinforce Norway and the Luftwaffe base for X. Fliegerkorps in Sicily. For a price, troops show up in Oslo or aircraft show up in the airbase. Again, right now, it's 5,000 per charge but we will see how it goes.


upload_2021-12-22_7-19-47.png
 
Last edited:
Can someone please take a look at this and let me know what I'm doing wrong? This looks very similar to some code in OTR so I'm scratching my head.

While I do eventually intend to add other conditions to this (a flag, specifically, as well as a restriction to Germany), what I'm trying to do here is ensure that any air unit produced will be a veteran unit. It does not appear to be working. I checked OTR and wasn't able to glean why similar things work there, but not here. Any ideas?

Thank you.

Code:
civ.scen.onCityProduction(function(city, prod)
    if civ.isUnit(prod) then
        if prod.type.domain == 1 then
        prod.veteran = true 

        end 
    end 
end)
 
Can someone please take a look at this and let me know what I'm doing wrong? This looks very similar to some code in OTR so I'm scratching my head.

The problem is that civ.scen.onCityProduction already registers a function in events.lua. That means that the function you are registering here will be overwritten with a new city production event.

You should add this code to triggerEvents.lua, under the triggerEvents.onCityProduction(city,prod) function (or, use the file in UniversalTriggerEvents).
 
Top Bottom