OK, I'm trying to implement a nuclear meltdown trigger for my modpack. I thought this would be easy, but...
Here's what I have so far (With changes so it's certain to meltdown if happiness drops below 72, for testing):
(EDIT - sorry all my indentation got killed by something when I submitted the post)
//Location used for making dead tiles and whatnot round nukes
TypeLocation NuclearMeltdownLoc;
trigger 'NuclearMeltdown' when (city.happiness < 72 && CityHasBuilding(city, "IMPROVE_NUCLEAR_PLANT"))
{ //if (Random(50)<(72-city.happiness)
if (1)
{ if (city.owner == g.player)
{ AddCenter(city.location);
}
Message(city.owner, 'NuclearMeltdownInCity');
AddEffect(city.location, "SPECEFFECT_NUCLEAR_ATTACK", "SOUND_ID_NUCLEAR_ATTACK");
AddPops(city, -(city.population/2));
i=0;
while (i<8)
{ if (GetNeighbor(city.location, i, NuclearMeltdownLoc))
{ if (Random(10)<5)
{
j=TerrainType(NuclearMeltdownLoc);
Message(city.owner, 'JunkMessage');
if (j>=0 && j<=7) //Change flat land to dead tile
{ Terraform(NuclearMeltdownLoc, 18);
}
if (j==9 || j==19 || j==21) //Change hills to dead hills
{ Terraform(NuclearMeltdownLoc, 23);
}
}
}
i=i+1;
}
}
}
Which mostly works OK, the population is halved, you get a pretty picture and a message, but the terraforming to make dead tiles is apparently doing nothing at all. The junk message appears 3-5 times, as you would expect, but no terrain changes.
I'd also like to know how to destroy the nuclear plant improvement together with a random selection of others.
Am I going about this the right way, or is there a NukeHere() function
. You can't start creating nuclear missiles and moving them around, I'm sure that would cause far too many problems (e.g. SDI, nanite defuser, active defense).
If I can't even make this work, I'm certainly not going to try for the partisan effect...
John
Here's what I have so far (With changes so it's certain to meltdown if happiness drops below 72, for testing):
(EDIT - sorry all my indentation got killed by something when I submitted the post)
//Location used for making dead tiles and whatnot round nukes
TypeLocation NuclearMeltdownLoc;
trigger 'NuclearMeltdown' when (city.happiness < 72 && CityHasBuilding(city, "IMPROVE_NUCLEAR_PLANT"))
{ //if (Random(50)<(72-city.happiness)
if (1)
{ if (city.owner == g.player)
{ AddCenter(city.location);
}
Message(city.owner, 'NuclearMeltdownInCity');
AddEffect(city.location, "SPECEFFECT_NUCLEAR_ATTACK", "SOUND_ID_NUCLEAR_ATTACK");
AddPops(city, -(city.population/2));
i=0;
while (i<8)
{ if (GetNeighbor(city.location, i, NuclearMeltdownLoc))
{ if (Random(10)<5)
{
j=TerrainType(NuclearMeltdownLoc);
Message(city.owner, 'JunkMessage');
if (j>=0 && j<=7) //Change flat land to dead tile
{ Terraform(NuclearMeltdownLoc, 18);
}
if (j==9 || j==19 || j==21) //Change hills to dead hills
{ Terraform(NuclearMeltdownLoc, 23);
}
}
}
i=i+1;
}
}
}
Which mostly works OK, the population is halved, you get a pretty picture and a message, but the terraforming to make dead tiles is apparently doing nothing at all. The junk message appears 3-5 times, as you would expect, but no terrain changes.
I'd also like to know how to destroy the nuclear plant improvement together with a random selection of others.
Am I going about this the right way, or is there a NukeHere() function
![Smile](https://apolyton.net/core/images/smilies/smile.gif)
If I can't even make this work, I'm certainly not going to try for the partisan effect...
John
Comment