CurtSibling
ENEMY ACE™
Amazing, sir - Thanks - Your help is invaluable.
@IF
CityTaken
city=AnyCity
attacker=Soviet Union
defender=German Reich
@THEN
JUSTONCE
TEXT
^
^^ Stalin has daringly unleashed a concerted strike upon German
^^ positions. He hopes to dislocate any action from the fascists.
^^ An inspired move, or potential disaster? Time will tell...
^
ENDTEXT
PlayWaveFile
RUS.wav
@ENDIF
function triggerEvents.onCityTaken(city,defender)
context[getContext()]["onCityTaken"](city,defender)
universal["onCityTaken"](city,defender)
legacy.doCityTakenEvents(city,defender)
if city == object.cParis and city.owner == object.tGermany then
civ.ui.text("^^ Stalin has daringly unleashed a concerted strike upon German positions. He hopes to dislocate any future aggression from the fascists. An inspired move, or potential disaster? Time will tell...")
civ.playSound("RUS.wav")
end
end
The code I have so far is Below...What I want to change is instead of Paris, I would like that any city can be taken, and it will trigger the message...
if defender == object.tGermany then
The defender line is perfect, but is there a way to make this event only fire once when the Russsians take a city?
gen.justOnce("UniqueJustOnceString", function ()
-- put your code here
end) -- the end here is for the function we defined inside of gen.justOnce, the ) is to close gen.justOnce
1. Acquire the location of this unit (it's the only one out there so this should be possible)
local bismark = nil -- This is deliberately outside the function
local function getBismark()
if bismark and bismark.type == object.uBismark then
return bismark
end
if bismark == false then
return nil -- return nil if no Bismark unit found
end
for unit in civ.iterateUnits() do
if unit.type == object.uBismark then
bismark = unit
return unit
end
end
bismark = false -- set to false, so we don't always look for a nonexistent Bismark
return nil -- return nil if no Bismark unit found
end
2. Then redirect certain units in an area to that location (for example, maybe British ships out of Scapa Flow try to intercept it).
local function chaseBismark(hunterUnit)
local bismarkUnit = getBismark()
if bismarkUnit and bismarkUnit.location then
hunterUnit.gotoTile = bismark.location
end
end
-On the AI turn, when a carrier activates, it "senses" if there are human naval units within a range of the carrier.
-If so, AI air units are created on the carrier's tile, their value/unique id is captured, and given a goto command to the human naval units' tile
-Then, at the start of the human player's turn, the air units with that value/unique id are deleted (so the human has to go kill the carrier to get the air attacks to stop).
I've never tried using this trigger before, but you made me curious so I had to try it out. I agree that this doesn't seem to fire for me either, at least in an Original game (where arrival on Alpha Centauri automatically ends the game). Did you try testing this in an Extended Original, SciFi, or Fantasy game? I wonder if that would make a difference.
There isn't a separate value for Extended Original? Is that just coded as Original and then detected by the presence of more than 1 map?
For that matter, how did you add a second map to an Original game? By editing Rules.txt in the folder where the saved game was stored, to add a @SECONDARY_MAPS section, and then reloading? I never realized you could change the number of maps once a game was underway.
local railBuilders = {}
railBuilders[object.uGuderian.id] = true
railBuilders[object.uModel.id] = true
railBuilders[object.uRommel.id] = true
railBuildres[object.uManstein.id] = true
local railUpgradeMoneyCost = 1000
local railUpgradeMoveCost = 3
local activeUnit = civ.getActiveUnit()
if activeUnit and railBuilder[activeUnit.type.id] and gen.hasRoad(activeUnit.location) and
not gen.hasRailroad(activeUnit.location) and activeUnit.owner.money >= railUpgradeMoneyCost then
local menuOptions = {[1]="No, do not place railroad.", [2]="Yes, spend "..text.money(railUpgradeMoneyCost).." to upgrade this road to a railroad."}
local menuText = text.substitute("Our %STRING1 unit can place a railroad at the cost of %STRING2 and %STRING3 movement points. Shall we proceed?",
{activeUnit.type.name, text.money(railUpgradeMoneyCost),railUpgradeMoveCost})
local menuTitle = "Place Railroad"
local choice = text.menu(menuOptions,menuText,menuTitle)
if choice == 2 then
activeUnit.moveSpent = activeUnit.moveSpent + totpp.movementMultipliers.aggregate*railUpgradeMoveCost
activeUnit.owner.money = activeUnit.owner.money - railUpgradeMoneyCost
gen.placeRailroad(activeUnit.location)
end
end
While I could probably handle a portion of this event myself, trying to figure out if there is a road on a tile is a bit beyond my grasp. Many thanks to anyone who is willing to help.