Nuclear war in the Age of Lua

Coming back to this... board games like "NATO: The Cold War Goes Hot" and "World War 3 1976-1984" have an "Armageddon" die roll that becomes increasingly hard to pass the more nukes are used. Can something like that be implemented with Lua? Does it even need Lua?
 
Coming back to this... board games like "NATO: The Cold War Goes Hot" and "World War 3 1976-1984" have an "Armageddon" die roll that becomes increasingly hard to pass the more nukes are used. Can something like that be implemented with Lua? Does it even need Lua?

Counting things in Lua is easy, as is making an event that has a chance of happening. Combining them is no more difficult. I believe these are fairly difficult to do in the Macro system. There was a civil war scenario that strung together 5 events with flags in order to count to 5 confederate infantry killed, and I think that you would have to combine a random turn trigger with another trigger to get a random chance, but I'm not totally sure about that.

The difficult part of all this is actually figuring out when a nuke has been launched so you can count it. A quick test tells me that onChooseDefender will be triggered by a nuclear attack if there is a unit defender, but onInitiateCombat and onUnitKilled will not be triggered. Also, onChooseDefender will not be triggered if an undefended city is nuked. So, you can easily count nukes used against defended cities and units in the field, but you will have to infer if a nuke is used against an undefended city. onChooseDefender will also happen even if SDI defense blocks the nuke, but that is an easy thing to check, since SDI always works. Perhaps @TheNamelessOne will consider adding a 'nuke used' event in a future TOTPP release.

You would also have to program an event to stop the AI using nukes to account for the Armageddon event, since the AI won't know to stop.
 
Aren't you able to count the pollution tiles on a map? I think they still show up with a nuclear attack even if there is "no pollution" in the scenario, right? Perhaps that could be a way to infer an attack against defenseless cities.
 
Counting things in Lua is easy, as is making an event that has a chance of happening. Combining them is no more difficult. I believe these are fairly difficult to do in the Macro system. There was a civil war scenario that strung together 5 events with flags in order to count to 5 confederate infantry killed, and I think that you would have to combine a random turn trigger with another trigger to get a random chance, but I'm not totally sure about that.

The difficult part of all this is actually figuring out when a nuke has been launched so you can count it. A quick test tells me that onChooseDefender will be triggered by a nuclear attack if there is a unit defender, but onInitiateCombat and onUnitKilled will not be triggered. Also, onChooseDefender will not be triggered if an undefended city is nuked. So, you can easily count nukes used against defended cities and units in the field, but you will have to infer if a nuke is used against an undefended city. onChooseDefender will also happen even if SDI defense blocks the nuke, but that is an easy thing to check, since SDI always works. Perhaps @TheNamelessOne will consider adding a 'nuke used' event in a future TOTPP release.

You would also have to program an event to stop the AI using nukes to account for the Armageddon event, since the AI won't know to stop.

Macro can count event triggers, but only if they occur in different turns. It can't count things that happen in the same turn. You're referring to the events in Tootall's "A House Divided", which requires the Union player to kill 5 Confederate infantry units within a set time, each in a different turn.
 
Aren't you able to count the pollution tiles on a map? I think they still show up with a nuclear attack even if there is "no pollution" in the scenario, right? Perhaps that could be a way to infer an attack against defenseless cities.

I was about to write how checking every square on the map for pollution every time a unit moves might be slow (checking every square on the map and doing something to many of them would be slow, but I'm not sure about just checking info), but I checked the function reference, and it turns out that @Knighttime found civ.game.pollution, which gives us the information we need. It doesn't count pollution added by Lua, but that doesn't matter for this purpose.

In any case, having to infer when a nuke has been used, at least sometimes, makes the whole endeavour more difficult than placing these lines in the appropriate places:
Code:
counter.define("nukeDetonations",0)
Code:
if attacker.type.attack == 99 then
    counter.add("nukeDetonations",1)
end

Also, if there are important triggers for units killed by the nuke, those have to be done manually. This isn't a big deal if we know the nuke will go off before it does, since we can kill the units before the nuke deletes them. However, if we're inferring that a nuke happened, then we need to figure out what units were killed after the fact, and work out if any other event code must be run. This doesn't seem insurmountable, but it isn't easy either.
 
Would a "Theatre Europe"-esque nuclear options set be possible? I mean, I expect a new AI would have to be written for it...
 
Would a "Theatre Europe"-esque nuclear options set be possible? I mean, I expect a new AI would have to be written for it...

I don't know anything about that game other than what I read in the Wiki article about it. However, I see no reason why something like that couldn't be created. It would probably make most sense in that context to have the nukes handled by events, rather than supply them as standard units.
 
Top Bottom