The Cold War 1947 - 1991

I'd also like to ask some opinions on the replay factor.

Right now, the current rebellions/revolts are coded in with various triggers:

-Vietnam tends to want to be Pro-Eastern and is initiated by a random event;
-Vietnam tends to want to be Pro-Eastern and is initiated by a random event;
-Algeria tends to want to be Non-Aligned and is initiated by the Non-Aligned researching a tech to spark their war of indendence
-Indonesia is a mess - the Non-Aligned can grab some of it via events, but other civs capturing one city in there triggers a broader civil war
-Ghana and Egypt both go Non-Aligned via tech
-Cuba will go Pro-East via tech
-Israel will go Pro-West via event early in the game
-Turkey starts neutral but can be aligned by USSR, USA or Europe

I definitely want to add Angola and Greece to the above. Perhaps Congo too.

I question if I should add others. Note, these are just event-driven rebellions. The "spawn Rebels" module (when built) will also allow players to start rebellions most places on the globe (defined by regions).

I'm inclined to add Angola, Congo, and Greece and leave the rest of the map up for grabs and dependent on player action, but wanted to know what everyone thinks about that. I'm concerned that if I add every last thing that ever happened, there isn't going to be as much story telling or replay value to the experience.

Thoughts?
 
A question I have for our coders is: is there any way that I can have the AI randomly select option 1 or 2 if this was used in a SP game? I would love to put these kind of events in the SP game, but the big hurdle is I'm not sure how to trigger the AI to choose one of the dialogue boxes. I'd like a 75% chance of the historic response unfolding. In SP, I would add an event to change the diplomacy state to war between the USA and USSR if the 25% ahistoric nuclear holocaust path is chosen.

Do something like
Code:
local choice = nil
if choosingTribe.isHuman then
    -- create menu
    choice = text.menu(--[[arguments]])
else
    local probabilityRoll = math.random()
    if probabilityRoll < 0.25 then
        choice = 1
    elseIf probabilityRoll < 0.6 then
        choice = 2
    else
        choice = 3
    end
end
This example would make the AI choose option 1 with 25% probability, 2 with 30% probability, 3 with 40% probability.
 
You could use a threshold table to specify the different choices and their probabilities, rather than explicitly listing them in an elseif chain.
 
So I "thought" I was doing a good job at creating a RebelSpawn function that is called onKeyPress but the problem has become that if I drill down all the way to spawning rebels in Mexico, and then go to spawn them in Honduras, they will spawn in Mexico a second time before also spawning in Honduras.

Is there a way I can end the "drill down" each time a unit is actually spawned and then "reset" the function so it starts fresh each time?

On the plus side, everything besides this is working just dandy...

Edit - attaching events in case that's easier... It all starts on 1330.

Edit 2 - just to explain myself a bit clearer:

When you press backspace a dialogue comes up asking what general region you want to spawn rebels in.
You select one of the regions, which brings up a second dialogue box asking which country you want to spawn rebels in.
You select one of the countries, which brings up a third dialogue box asking how much effort ($$$) you want to put into this.
On that third dialogue box, depending on your choice, rebels will spawn in the country you selected.

Unfortunately if you repeat this process twice with the code I've provided, you get the first decision twice as well as the second decision once (in my testing, 2x Mexico and 1x Honduras). I just want each decision to happen once. Is there a way to clear a state once it has just happened?


Spoiler :

Code:
--My attempt at a rebel spawn
function rebelSpawn()
local activeTribe = civ.getCurrentTribe()
    if activeTribe == object.tUSSR then
    --Tier I asks which continent to spawn the rebels
    dialog = civ.ui.createDialog()
        dialog.title = "Cold War Concepts: Rebel Spawn"
        dialog.width = 300
        dialog:addText("We can attempt to influence world events, expand the reach of Communism, and extend our hegemony by backing rebels in distant lands.  The more we invest, the stronger our rebel allies will become.")
        dialog:addOption("Fund Communist Revolutionaries in Central America", 1)
        dialog:addOption("Fund Communist Revolutionaries in the Caribbean", 2)
        dialog:addOption("Fund Communist Revolutionaries in South America", 3)
        dialog:addOption("Fund Communist Revolutionaries in Southeast Asia", 4)
        dialog:addOption("Fund Communist Revolutionaries in North Africa", 5)
        dialog:addOption("Fund Communist Revolutionaries in Central Africa", 6)
        dialog:addOption("Fund Communist Revolutionaries in Southern Africa", 7)
        dialog:addOption("Fund Communist Revolutionaries in the Middle East", 8)
        dialog:addOption("Never mind.  We have pressing domestic affairs to contend with.", 9)
        state.ussrFundsRebelsTierI = dialog:show()
 
        --These decide the Specific Country
 
        if state.ussrFundsRebelsTierI==1 then
            dialog = civ.ui.createDialog()
            dialog.title = "Central American Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Mexico", 1)
            dialog:addOption("Honduras", 2)
            dialog:addOption("Nicaragua", 3)
            dialog:addOption("Panama", 4)
            dialog:addOption("Never mind.", 5)
            state.ussrFundsRebelsCentralAmerica = dialog:show()
        end
 
        if state.ussrFundsRebelsTierI==2 then
            dialog = civ.ui.createDialog()
            dialog.title = "Caribbean Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Cuba", 1)
            dialog:addOption("Haiti", 2)
            dialog:addOption("Jamaica", 3)
            dialog:addOption("Never mind.", 4)
            state.ussrFundsRebelsCaribbean = dialog:show()
        end
 
        if state.ussrFundsRebelsTierI==3 then
            dialog = civ.ui.createDialog()
            dialog.title = "South American Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Columbia", 1)
            dialog:addOption("Venezuela", 2)
            dialog:addOption("Ecuador", 3)
            dialog:addOption("Peru", 4)
            dialog:addOption("Chile", 5)
            dialog:addOption("Argentina", 6)
            dialog:addOption("Paraguay", 7)
            dialog:addOption("Uruguay", 8)
            dialog:addOption("Brazil", 9)
            dialog:addOption("Bolivia", 10)
            dialog:addOption("Guyana", 11)
            dialog:addOption("Never mind.", 12)
            state.ussrFundsRebelsSouthAmerica = dialog:show()
        end
 
        if state.ussrFundsRebelsTierI==4 then
            dialog = civ.ui.createDialog()
            dialog.title = "Southeast Asian Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Vietnam", 1)
            dialog:addOption("Cambodia", 2)
            dialog:addOption("Thailand", 3)
            dialog:addOption("Malaysia", 4)
            dialog:addOption("Indonesia", 5)
            dialog:addOption("Burma", 6)
            dialog:addOption("Philippines", 7)
            dialog:addOption("New Guinea", 8)
            dialog:addOption("Sri Lanka", 9)
            dialog:addOption("Never mind.", 10)
            state.ussrFundsRebelsSoutheastAsia = dialog:show()
        end
 
        if state.ussrFundsRebelsTierI==5 then
            dialog = civ.ui.createDialog()
            dialog.title = "North African Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Morocco", 1)
            dialog:addOption("Algeria", 2)
            dialog:addOption("Tunisia", 3)
            dialog:addOption("Libya", 4)
            dialog:addOption("Egypt", 5)
            dialog:addOption("Sudan", 6)
            dialog:addOption("Never mind.", 7)
            state.ussrFundsRebelsNorthAfrica = dialog:show()
        end
 
        if state.ussrFundsRebelsTierI==6 then
            dialog = civ.ui.createDialog()
            dialog.title = "Central African Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Ethiopia", 1)
            dialog:addOption("Somalia", 2)
            dialog:addOption("Congo", 3)
            dialog:addOption("Nigeria", 4)
            dialog:addOption("Chad", 5)
            dialog:addOption("Mali", 6)
            dialog:addOption("Liberia", 7)
            dialog:addOption("Senegal", 8)
            dialog:addOption("Kenya", 9)
            dialog:addOption("Never mind.", 10)
            state.ussrFundsRebelsCentralAfrica = dialog:show()
        end
 
        if state.ussrFundsRebelsTierI==7 then
            dialog = civ.ui.createDialog()
            dialog.title = "South African Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Angola", 1)
            dialog:addOption("Mozambique", 2)
            dialog:addOption("Zimbabwe", 3)
            dialog:addOption("Botswana", 4)
            dialog:addOption("Namibia", 5)
            dialog:addOption("Malawi", 6)
            dialog:addOption("Rawanda", 7)
            dialog:addOption("Never mind.", 8)
            state.ussrFundsRebelsSouthAfrica = dialog:show()
        end
 
        if state.ussrFundsRebelsTierI==8 then
            dialog = civ.ui.createDialog()
            dialog.title = "Middle Eastern Communist Rebels"
            dialog.width = 300
            dialog:addText("In which country should we fund Communist revolutionaries?")
            dialog:addOption("Pakistan", 1)
            dialog:addOption("Afghanistan", 2)
            dialog:addOption("Iran", 3)
            dialog:addOption("Iraq", 4)
            dialog:addOption("Syria", 5)
            dialog:addOption("Saudi Arabia", 6)
            dialog:addOption("Yemen", 7)
            dialog:addOption("Oman", 8)
            dialog:addOption("U.A.E.", 9)
            dialog:addOption("Never mind.", 10)
            state.ussrFundsRebelsMidEast = dialog:show()
        end
 
    --End of Specific Country
    --Start of Payment/Forces provided
 
            if state.ussrFundsRebelsCentralAmerica==1 then
            --Tier III asks how much to support
                dialog = civ.ui.createDialog()
                dialog.title = "The Mexican Communist Party"
                dialog.width = 300
                dialog:addText("How much support should we provide the Mexican Communist Party?")
                dialog:addOption("Minor support at cost of $" ..tostring(specialNumbers.ussrMinorRebelFund).."", 1)
                dialog:addOption("Moderate support at cost of $" ..tostring(specialNumbers.ussrModerateRebelFund).."", 2)
                dialog:addOption("Massive support at cost of $" ..tostring(specialNumbers.ussrLargeRebelFund).."", 3)
                dialog:addOption("Never mind.", 4)
                state.ussrFundsRebelsInMexico = dialog:show()
 
            end
     
            if state.ussrFundsRebelsCentralAmerica==2 then
            --Tier III asks how much to support
                dialog = civ.ui.createDialog()
                dialog.title = "Support Communists in Honduras"
                dialog.width = 300
                dialog:addText("How much support should we provide Communist Rebels in Honduras?")
                dialog:addOption("Minor support at cost of $" ..tostring(specialNumbers.ussrMinorRebelFund).."", 1)
                dialog:addOption("Moderate support at cost of $" ..tostring(specialNumbers.ussrModerateRebelFund).."", 2)
                dialog:addOption("Massive support at cost of $" ..tostring(specialNumbers.ussrLargeRebelFund).."", 3)
                dialog:addOption("Never mind.", 4)
                state.ussrFundsRebelsInHonduras = dialog:show()
 
            end
     
            if state.ussrFundsRebelsCentralAmerica==3 then
            --Tier III asks how much to support
                dialog = civ.ui.createDialog()
                dialog.title = "Support Communists in Nicaragua"
                dialog.width = 300
                dialog:addText("How much support should we provide Communist Rebels in Nicaragua?")
                dialog:addOption("Minor support at cost of $" ..tostring(specialNumbers.ussrMinorRebelFund).."", 1)
                dialog:addOption("Moderate support at cost of $" ..tostring(specialNumbers.ussrModerateRebelFund).."", 2)
                dialog:addOption("Massive support at cost of $" ..tostring(specialNumbers.ussrLargeRebelFund).."", 3)
                dialog:addOption("Never mind.", 4)
                state.ussrFundsRebelsInNicaragua = dialog:show()
 
            end
     
            if state.ussrFundsRebelsCentralAmerica==4 then
            --Tier III asks how much to support
                dialog = civ.ui.createDialog()
                dialog.title = "Support Communists in Panama"
                dialog.width = 300
                dialog:addText("How much support should we provide Communist Rebels in Panama?")
                dialog:addOption("Minor support at cost of $" ..tostring(specialNumbers.ussrMinorRebelFund).."", 1)
                dialog:addOption("Moderate support at cost of $" ..tostring(specialNumbers.ussrModerateRebelFund).."", 2)
                dialog:addOption("Massive support at cost of $" ..tostring(specialNumbers.ussrLargeRebelFund).."", 3)
                dialog:addOption("Never mind.", 4)
                state.ussrFundsRebelsInPanama = dialog:show()
 
            end
     
            if state.ussrFundsRebelsCentralAmerica==5 then
            return
 
            end
     
            if state.ussrFundsRebelsCaribbean==1 then
            --Tier III asks how much to support
                dialog = civ.ui.createDialog()
                dialog.title = "Support Communists in Cuba"
                dialog.width = 300
                dialog:addText("How much support should we provide the Cuban Revolutionaries?")
                dialog:addOption("Minor support at cost of $" ..tostring(specialNumbers.ussrMinorRebelFund).."", 1)
                dialog:addOption("Moderate support at cost of $" ..tostring(specialNumbers.ussrModerateRebelFund).."", 2)
                dialog:addOption("Massive support at cost of $" ..tostring(specialNumbers.ussrLargeRebelFund).."", 3)
                dialog:addOption("Never mind.", 4)
                state.ussrFundsRebelsInCuba = dialog:show()
 
            end
     
            if state.ussrFundsRebelsCaribbean==2 then
            --Tier III asks how much to support
                dialog = civ.ui.createDialog()
                dialog.title = "Support Communists in Haiti"
                dialog.width = 300
                dialog:addText("How much support should we provide the Haitian Revolutionaries?")
                dialog:addOption("Minor support at cost of $" ..tostring(specialNumbers.ussrMinorRebelFund).."", 1)
                dialog:addOption("Moderate support at cost of $" ..tostring(specialNumbers.ussrModerateRebelFund).."", 2)
                dialog:addOption("Massive support at cost of $" ..tostring(specialNumbers.ussrLargeRebelFund).."", 3)
                dialog:addOption("Never mind.", 4)
                state.ussrFundsRebelsInHaiti = dialog:show()
 
            end
     
            if state.ussrFundsRebelsCaribbean==3 then
            --Tier III asks how much to support
                dialog = civ.ui.createDialog()
                dialog.title = "Support Communists in Jamaica"
                dialog.width = 300
                dialog:addText("How much support should we provide the Jamaican Revolutionaries?")
                dialog:addOption("Minor support at cost of $" ..tostring(specialNumbers.ussrMinorRebelFund).."", 1)
                dialog:addOption("Moderate support at cost of $" ..tostring(specialNumbers.ussrModerateRebelFund).."", 2)
                dialog:addOption("Massive support at cost of $" ..tostring(specialNumbers.ussrLargeRebelFund).."", 3)
                dialog:addOption("Never mind.", 4)
                state.ussrFundsRebelsInJamaica = dialog:show()
 
            end
     
            if state.ussrFundsRebelsCaribbean==5 then
            return
 
            end
     
            --{{},{},{},{},{},{},{},{},{},{},},
                --Mexico
                if state.ussrFundsRebelsInMexico==1 and object.tUSSR.money >= specialNumbers.ussrMinorRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{204,84,0},{205,85,0},{206,86,0},{206,92,0},{210,94,0},{205,97,0},{209,99,0},{210,98,0},{211,103,0},{197,85,0},}, {count=3, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrMinorRebelFund
                civ.ui.text(func.splitlines("A small band of Communist Revolutionaries rises up in Mexico!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInMexico==1 and object.tUSSR.money <= specialNumbers.ussrMinorRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInMexico==2 and object.tUSSR.money >= specialNumbers.ussrModerateRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{204,84,0},{205,85,0},{206,86,0},{206,92,0},{210,94,0},{205,97,0},{209,99,0},{210,98,0},{211,103,0},{197,85,0},}, {count=5, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{204,84,0},{205,85,0},{206,86,0},{206,92,0},{210,94,0},{205,97,0},{209,99,0},{210,98,0},{211,103,0},{197,85,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrModerateRebelFund
                civ.ui.text(func.splitlines("A large group of Communist Revolutionaries rises up in Mexico!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInMexico==2 and object.tUSSR.money <= specialNumbers.ussrModerateRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
                         
                if state.ussrFundsRebelsInMexico==3 and object.tUSSR.money >= specialNumbers.ussrLargeRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{204,84,0},{205,85,0},{206,86,0},{206,92,0},{210,94,0},{205,97,0},{209,99,0},{210,98,0},{211,103,0},{197,85,0},}, {count=50, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{204,84,0},{205,85,0},{206,86,0},{206,92,0},{210,94,0},{205,97,0},{209,99,0},{210,98,0},{211,103,0},{197,85,0},}, {count=2, randomize=true, veteran=false})
                civlua.createUnit(object.uRPG, object.tProEast, {{204,84,0},{205,85,0},{206,86,0},{206,92,0},{210,94,0},{205,97,0},{209,99,0},{210,98,0},{211,103,0},{197,85,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrLargeRebelFund
                civ.ui.text(func.splitlines("We have sparked a massive Communist revolution in Mexico!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInMexico==3 and object.tUSSR.money <= specialNumbers.ussrLargeRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInMexico==4 then
                return
                end
         
                --Honduras
                if state.ussrFundsRebelsInHonduras==1 and object.tUSSR.money >= specialNumbers.ussrMinorRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{216,102,0},{217,103,0},{218,104,0},{218,102,0},{219,103,0},{217,107,0},{213,103,0},{215,101,0},{216,100,0},{217,101,0},}, {count=3, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrMinorRebelFund
                civ.ui.text(func.splitlines("A small band of Communist Revolutionaries rises up in Honduras!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInHonduras==1 and object.tUSSR.money <= specialNumbers.ussrMinorRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInHonduras==2 and object.tUSSR.money >= specialNumbers.ussrModerateRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{216,102,0},{217,103,0},{218,104,0},{218,102,0},{219,103,0},{217,107,0},{213,103,0},{215,101,0},{216,100,0},{217,101,0},}, {count=5, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{216,102,0},{217,103,0},{218,104,0},{218,102,0},{219,103,0},{217,107,0},{213,103,0},{215,101,0},{216,100,0},{217,101,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrModerateRebelFund
                civ.ui.text(func.splitlines("A large group of Communist Revolutionaries rises up in Honduras!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInHonduras==2 and object.tUSSR.money <= specialNumbers.ussrModerateRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
                         
                if state.ussrFundsRebelsInHonduras==3 and object.tUSSR.money >= specialNumbers.ussrLargeRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{216,102,0},{217,103,0},{218,104,0},{218,102,0},{219,103,0},{217,107,0},{213,103,0},{215,101,0},{216,100,0},{217,101,0},}, {count=50, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{216,102,0},{217,103,0},{218,104,0},{218,102,0},{219,103,0},{217,107,0},{213,103,0},{215,101,0},{216,100,0},{217,101,0},}, {count=2, randomize=true, veteran=false})
                civlua.createUnit(object.uRPG, object.tProEast, {{216,102,0},{217,103,0},{218,104,0},{218,102,0},{219,103,0},{217,107,0},{213,103,0},{215,101,0},{216,100,0},{217,101,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrLargeRebelFund
                civ.ui.text(func.splitlines("We have sparked a massive Communist revolution in Honduras!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInHonduras==3 and object.tUSSR.money <= specialNumbers.ussrLargeRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInHonduras==4 then
                return
                end
         
                --Nicaragua
                if state.ussrFundsRebelsInNicaragua==1 and object.tUSSR.money >= specialNumbers.ussrMinorRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{221,111,0},{222,112,0},{221,109,0},{220,108,0},{219,109,0},{219,111,0},{222,106,0},{220,106,0},{220,110,0},{218,108,0},}, {count=3, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrMinorRebelFund
                civ.ui.text(func.splitlines("A small band of Communist Revolutionaries rises up in Nicaragua!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInNicaragua==1 and object.tUSSR.money <= specialNumbers.ussrMinorRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInNicaragua==2 and object.tUSSR.money >= specialNumbers.ussrModerateRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{221,111,0},{222,112,0},{221,109,0},{220,108,0},{219,109,0},{219,111,0},{222,106,0},{220,106,0},{220,110,0},{218,108,0},}, {count=5, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{221,111,0},{222,112,0},{221,109,0},{220,108,0},{219,109,0},{219,111,0},{222,106,0},{220,106,0},{220,110,0},{218,108,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrModerateRebelFund
                civ.ui.text(func.splitlines("A large group of Communist Revolutionaries rises up in Nicaragua!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInNicaragua==2 and object.tUSSR.money <= specialNumbers.ussrModerateRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
                         
                if state.ussrFundsRebelsInNicaragua==3 and object.tUSSR.money >= specialNumbers.ussrLargeRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{221,111,0},{222,112,0},{221,109,0},{220,108,0},{219,109,0},{219,111,0},{222,106,0},{220,106,0},{220,110,0},{218,108,0},}, {count=50, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{221,111,0},{222,112,0},{221,109,0},{220,108,0},{219,109,0},{219,111,0},{222,106,0},{220,106,0},{220,110,0},{218,108,0},}, {count=2, randomize=true, veteran=false})
                civlua.createUnit(object.uRPG, object.tProEast, {{221,111,0},{222,112,0},{221,109,0},{220,108,0},{219,109,0},{219,111,0},{222,106,0},{220,106,0},{220,110,0},{218,108,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrLargeRebelFund
                civ.ui.text(func.splitlines("We have sparked a massive Communist revolution in Nicaragua!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInNicaragua==3 and object.tUSSR.money <= specialNumbers.ussrLargeRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInNicaragua==4 then
                return
                end
                --Panama
                if state.ussrFundsRebelsInPanama==1 and object.tUSSR.money >= specialNumbers.ussrMinorRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{222,112,0},{221,113,0},{222,114,0},{223,115,0},{226,114,0},{227,113,0},{227,115,0},}, {count=3, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrMinorRebelFund
                civ.ui.text(func.splitlines("A small band of Communist Revolutionaries rises up in Panama!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInPanama==1 and object.tUSSR.money <= specialNumbers.ussrMinorRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInPanama==2 and object.tUSSR.money >= specialNumbers.ussrModerateRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{222,112,0},{221,113,0},{222,114,0},{223,115,0},{226,114,0},{227,113,0},{227,115,0},}, {count=5, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{222,112,0},{221,113,0},{222,114,0},{223,115,0},{226,114,0},{227,113,0},{227,115,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrModerateRebelFund
                civ.ui.text(func.splitlines("A large group of Communist Revolutionaries rises up in Panama!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInPanama==2 and object.tUSSR.money <= specialNumbers.ussrModerateRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
                         
                if state.ussrFundsRebelsInPanama==3 and object.tUSSR.money >= specialNumbers.ussrLargeRebelFund then
                civlua.createUnit(object.uLatinRev, object.tProEast, {{222,112,0},{221,113,0},{222,114,0},{223,115,0},{226,114,0},{227,113,0},{227,115,0},}, {count=50, randomize=true, veteran=false})
                civlua.createUnit(object.uGunTruck, object.tProEast, {{222,112,0},{221,113,0},{222,114,0},{223,115,0},{226,114,0},{227,113,0},{227,115,0},}, {count=2, randomize=true, veteran=false})
                civlua.createUnit(object.uRPG, object.tProEast, {{222,112,0},{221,113,0},{222,114,0},{223,115,0},{226,114,0},{227,113,0},{227,115,0},}, {count=1, randomize=true, veteran=false})
                object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrLargeRebelFund
                civ.ui.text(func.splitlines("We have sparked a massive Communist revolution in Panama!"))
                civ.playSound("infantry.wav")
                end
                if state.ussrFundsRebelsInPanama==3 and object.tUSSR.money <= specialNumbers.ussrLargeRebelFund then
                civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
                end
         
                if state.ussrFundsRebelsInPanama==4 then
                return
                end
elseif activeTribe == object.tUSA then
dialog = civ.ui.createDialog()
        dialog.title = "Cold War Concepts: Rebel Spawn"
        dialog.width = 300
        dialog:addText("We can attempt to influence world events, make the world safe for Democracy, and extend our hegemony by backing nationalist causes in distant lands.  The more we invest, the stronger our nationalist allies will become.")
        dialog:addOption("Fund Communist Revolutionaries in Latin America", 1)
        dialog:addOption("Fund Communist Revolutionaries in Asia", 2)
        dialog:addOption("Fund Communist Revolutionaries in Africa", 3)
        dialog:addOption("Fund Communist Revolutionaries in the Middle East", 4)
        dialog:addOption("Never mind.  We have pressing domestic affairs to contend with.", 5) 
        state.DiegoGarciaLease = dialog:show()
end
end
 

Attachments

  • Events.zip
    39.1 KB · Views: 87
Last edited:
I was able to get it to work by adding state.ussrFundsRebelsInMexico=nil

to this

--Mexico
if state.ussrFundsRebelsInMexico==1 and object.tUSSR.money >= specialNumbers.ussrMinorRebelFund then
civlua.createUnit(object.uLatinRev, object.tProEast, {{204,84,0},{205,85,0},{206,86,0},{206,92,0},{210,94,0},{205,97,0},{209,99,0},{210,98,0},{211,103,0},{197,85,0},}, {count=3, randomize=true, veteran=false})
object.tUSSR.money = object.tUSSR.money - specialNumbers.ussrMinorRebelFund
civ.ui.text(func.splitlines("A small band of Communist Revolutionaries rises up in Mexico!"))
civ.playSound("infantry.wav")
state.ussrFundsRebelsInMexico=nil
end
if state.ussrFundsRebelsInMexico==1 and object.tUSSR.money <= specialNumbers.ussrMinorRebelFund then
civ.ui.text(func.splitlines("We can't afford to fund these rebels!"))
end
 
Just a status update for all...

-Made it so the USSR, USA, and Non-Aligned can all fund Rebels. USSR pays the least for this function, USA the most, Non-Aligned in the middle. You can spawn small, medium, or large rebellion (low = 3 infantry, high = 5 infantry, 1 gun truck, 1 RPG).
-Made it so the USSR can capture and hold 3 cities without penalty, after that they lose $1,000 per turn. This cost doubles every 3 cities until they're losing $8,000 per turn. Thus, USSR can make some moves in Europe and capture 6 or so cities for cost of $2,000 / turn. May increase or decrease this amount.
-Made it so the USA can't capture any cities for free - first one costs 500/turn and this triples for every one after that to max cost of $13,500/turn. US is going to need to rely on military bases but may find they have a need in cramped quarters (think Vietnam) to hold a city and pay the fee to maintain a strong presence.
-Added SP Rebel movement where something like 60 different countries can spawn rebels. Currently have it at 1% chance per turn for each, but with so many, still pretty high occurrence... May change to .5% - will test.
-Added "devastation" terrain - Europe, much of Asia covered with it. Worthless. Needs to be transformed up to "developing" (factory route) or "plains-->grassland" (agricultural route).
-Considering random event where terrain under attacker will change to this when battle occurs.

This is coming together...
 
Sorry, I'm not up to speed. Will there be chemical weapons? Their use or the use of nukes would justify creating a devastated tile.

I dont have chemical weapons in the game right now, but the devastated tiles that start off in game got that way from B17s and B29s, so I'm sure if things came to blows, B52s would have a similar effect!
 
Playtests have revealed that the most compelling thing for the US and USSR to do is to immediately invade Mexico and Turkey, respectively. I've instituted an event where their attacking any units controlled by the neutrals (barbarians) that is NOT a pirate ship or terrorist will result in the neutral unit being restored as a veteran in the place of its defeat. I've put a similar hold on Europe, but not China or the Non-Aligned.

Thus, if America wants a friendly Mexico, they'll need to fund a proxy war to get it. On the other hand, if the Soviets fund Communist insurgents, American airstrikes can intervene to defend their neighbor.

Lua = Cool.
 
Some rather disjointed thoughts on China:

I've made quite a few changes to China and the Non-Aligned that I think you'll enjoy. Many took your advice.

So, as the scenario starts both of these civs start with a "developing" government (monarchy). The Non-Aligned have an option to research Communism, Republic, or Democracy and choose their own adventure (I may just give them Statue of Liberty - does anyone know if you can still change governments at will with it if government switching is turned off?). The Chinese get the Communism government as a reward for winning the Civil War (official Soviet recognition).

The Chinese and Soviets start the game allied to prevent the American or European players from dogpiling on the Chinese player. As long as this alliance is in place, the Chinese will receive a stipend of 200 gold each turn (ostensibly from the Soviets). However, as you suggested, if China wants to reach its full potential and build its unique buildings and units, it needs to research "international power" which drives an event called the "Sino-Soviet Split" that removes the alliance and stipend but of course allows access to these other techs/units.

While the Chinese have an opportunity to capture Nationalist forces, I've shut this down after 22 cities have been captured by China as the civil war winds down. As China starts with only 4 cities, they'll have this advantage for awhile.

In other news, I was a bit concerned about how money will play out in this scenario given the lack of freighters each civ has. Wanting this to be plausible SP as well as MP, I've decided to count the # of cities each civ (or, in the case of the USA and USSR, their proxy) has and then provide a cash bonus. Europe is the only civ that doesn't get this, as they are cash starved. The USA, USSR and Non-Aligned get the bonus for every city, but the Non-Aligned's bonus is less as it can build freight and the US/USSR cannot. China gets the bonus, but only for Asian cities. The USA and USSR actually get a double bonus as both they and their proxy receive one, reflecting their position as superpowers.

This should help fuel further proxy wars throughout the scenario and provide yet another reason to want to chip down the larger powers.

As it stands, I'm "mostly" done with the scenario. @Prof. Garfield has generously agreed to help me with the unit purchase event, and I still want to modify some of my "choice" events so that the AI will also use them. Finally, I do want to implement some events where Europe is rebuilt and strengthened via their unique tech path (consider this the Marshall Plan etc.) but this won't take too long.

Once that's done (and after I play a game myself) I intend to split the events into MP and SP versions, write a short playtester readme, and get this one out to all of you to check out...
 
(I may just give them Statue of Liberty - does anyone know if you can still change governments at will with it if government switching is turned off?)

I don't think so, but you could just do a key press event, or, perhaps, only offer the choice after production at certain intervals, perhaps on the turns that Indian leaders change.
 
Question for you folks - this pops up, but only if I try to reload events (such as after discovering and correcting an error). It does not pop up at the game start:

Code:
error loading module 'civlua' from file 'D:\Test of Time\Scenario\The Cold War 1947\Events.lua':
    D:\Test of Time\Scenario\The Cold War 1947\Events.lua:14507: too many C levels (limit is 200) in function at line 14506 near 'conqueror'

What are C levels? If this isn't showing up on load and only when I try to load the events from the console, am I OK, or do I need to worry about something not working?
 
I couldn't find anything helpful with a web search, and when I tried (only once) to load events from the console for the most recent version you sent me, I didn't get any errors. I would ignore it for now, if it only appears when you use the console's load script button.
 
I don't think so, but you could just do a key press event, or, perhaps, only offer the choice after production at certain intervals, perhaps on the turns that Indian leaders change.

Since "India" is now really the non-aligned, it might be fun to swap out the civ's ruler name depending on what way you go... I'd probably use an isHuman trigger for this and forgo it entirely in the SP game (where monarchy would be just fine for the Non-Aligned, frankly).

Edit - I've been using your trick for changing leader names from your lessons. Now that I've gone through the trouble of adding in the option choices for human players, can I effectively ensure that your function won't fire with an "and not" here? Probably a stupid question but I know you've cautioned me about the "not" before.

Code:
if indiaRulers[civ.getTurn()] and not object.tIndia.isHuman then
    -- if there is no entry for this index, it returns nil, which the if statement counts as false.
    object.tIndia.leader.name = indiaRulers[civ.getTurn()].name
    object.tIndia.leader.female = indiaRulers[civ.getTurn()].female
end
 
Last edited:
Yes, that should work.

"not" is a very useful operator, but you have to be careful that you are "notting" the correct thing. You may need parentheses where you wouldn't for "or" or "and". I had a situation where I used

Code:
not a == b
and I had to write it as
Code:
not (a == b)
since without the parentheses, it evaluated as
Code:
(not a) == b
and I spent a decent amount of time checking other stuff for the bug. It is just something you need to be aware of so that you don't make fruitless (but sometimes difficult) efforts trying to figure out why a and b aren't what you expect them to be in that instance of the function being called.

I suppose in this particular case, the 'usual' thing to do would be
Code:
a ~= b
,
but the issue could still arise.
 
I've been quite busy. Prof. Garfield built a brilliant arms deal mechanism that I think everyone is going to enjoy. Now I'm spending my time ensuring that events will work in SP as well as MP versions. I've also tweaked the alignment mechanism. Now instead of having multiple techs to research that correspond with one country or another, one will simply research one technology "Align Neutrals." Doing so brings up a box that features the neutrals who can be aligned. Selecting one accomplishes the alignment and removes the tech that was researched, allowing it to be researched a second time. One will need to wait a tech cycle to research it again, but that should be fine.

In this way, the neutral lands of Europe such as Spain, Turkey, Austria, etc. can be brought to one of the three main camps. A similar mechanism is in play for the Non-Aligned movement to bring Indonesia, Egypt, and Ghana into the group.

I'm quite pleased with these dialogue boxes. They work well and are easy enough to configure for SP and MP use in one event.
 
Question for everyone/anyone:

I know that by doing this I'm saying that between turns 28 and 52 there is a 1/10 chance that there will be a strike/protest in the US. However, as currently written, ALL of these improvements will be removed in ALL U.S. cities.

Code:
if turn >= 28 and turn <= 52 and tribe == object.tUSA and math.random(1, 10) == 10 then
civ.ui.text(func.splitlines("Massive strikes and protests erupt across the United States as part of the Civil Rights Movement!" ))
for city in civ.iterateCities()do
        if civ.hasImprovement(city,object.iEqualProtections) then
            if city.owner == object.tUSA then
            civ.removeImprovement(city, object.iEqualProtections)
            end   
        end
        if civ.hasImprovement(city,object.iGovernmentOffices) then
            if city.owner == object.tUSA then
            civ.removeImprovement(city,object.iGovernmentOffices)
            end   
        end
        if civ.hasImprovement(city,object.iPoliceStation) then
            if city.owner == object.tUSA then
            civ.removeImprovement(city,object.iPoliceStation)
            end   
        end
    end
end

How do I make it so there is just a random chance that a city will have this issue? Would inserting the math.random check into one of the secondary tiers accomplish this, or will it not work as I think it will? Example:

Code:
  if civ.hasImprovement(city,object.iPoliceStation) then
            if city.owner == object.tUSA and math.random(1,10)==10 then
            civ.removeImprovement(city,object.iPoliceStation)
            end

Would this first look at all cities in the world with police stations
Then look at those cities that are US
Then choose from the US cities with police stations and only remove them from them?

I think this code below would make for a very turbulent time in the U.S. and could well be used for later Soviet economic difficulties, but only if I can make it so that not "every" city in the entire country loses certain improvements.

Code:
if turn >= 28 and turn <= 52 and tribe == object.tUSA and math.random(1, 10) == 10 then 
for city in civ.iterateCities()do
        if civ.hasImprovement(city,object.iEqualProtections) then
            if city.owner == object.tUSA and math.random(1, 10) == 10 then
            civ.ui.text(func.splitlines("Massive strikes and protests erupt across the United States as citizens protest the lack of equal protections for all!" ))
            civ.removeImprovement(city, object.iEqualProtections)
            end    
        end
        if civ.hasImprovement(city,object.iGovernmentOffices) then
            if city.owner == object.tUSA and math.random(1, 10) == 10 then
            civ.ui.text(func.splitlines("Government offices shutter as massive protests grip the United States!" ))
            civ.removeImprovement(city,object.iGovernmentOffices)
            end    
        end
        if civ.hasImprovement(city,object.iPoliceStation) then
            if city.owner == object.tUSA and math.random(1, 10) == 10 then
            civ.ui.text(func.splitlines("Massive protests grip the United States! Several police departments are forced to close!" ))
            civ.removeImprovement(city,object.iPoliceStation)
            end    
        end
    end
end
 
I know that by doing this I'm saying that between turns 28 and 52 there is a 1/10 chance that there will be a strike/protest in the US. However, as currently written, ALL of these improvements will be removed in ALL U.S. cities.
Correct.

How do I make it so there is just a random chance that a city will have this issue? Would inserting the math.random check into one of the secondary tiers accomplish this, or will it not work as I think it will?
Did you mean to leave in the math.random(1, 10) on the first line, as well as introduce it for each improvement?

Here's what the last block of code will do:

On turns 28 through 52, there is a 10% chance that we will check cities on that turn. This is a period of 25 turns, so on average, we will check cities 2.5 times (i.e. 2 or 3 times) during those turns.

If we check cities, then for every city in the U.S.:
- if the city has object.iEqualProtections, there is a 10% chance that improvement will be removed
- if the city has object.iGovernmentOffices, there is a 10% chance that improvement will be removed
- if the city has object.iPoliceStation, there is a 10% chance that improvement will be removed

So it's possible that a city with all 3 improvements would lose 0, 1, 2, or 3 of them. With a 90% chance that each improvement is safe, there is actually a 72.9% chance that all 3 improvements would be safe (0.9^3).

Overall I think this will do what you want, you just might need to adjust the percentages to meet your definition of "a very turbulent time".
 
Thanks @Knighttime - I'll have to play around with the figures but at least it means it more or less will do what I was going for. I appreciate it!
 
Ever played a MP game where you agreed with another player to limit nuclear weapons, but weren't quite sure if they were playing by the rules, or playing you? Well, lua allows some ways around that for your next MP adventure... Introducing the Strategic Arms Limitation Treaty, or SALT.

When any civ researches "Detente" all nuclear-armed civs will receive this pop up asking if they'd like to become a signatory to SALT, and explaining the conditions:

upload_2020-8-28_15-28-56.png


Should a tribe violate the conditions, they will receive this pop up box alerting them of how much they're in violation, and what their penalty was.

upload_2020-8-28_15-29-6.png


For gameplay, and to make sure people stick to it, there's no way out or in after you've made your decision. Are you going to agree to limit your nuclear arsenal, or are you going to let your opponents get the cash bonus and spend it on who knows what?

With the completion of this, all events necessary for playtesting are complete. I've been bug testing as I go but of course more are possible. Anyway, I will be giving this a go myself shortly and will then open a thread for all of you to play. I hope a few of you will take a spin in a SP match!
 
Top Bottom