Thunderbrd
C2C War Dog
So I'm taking a look at the code on this. A few bullet points of observations:
* I'm wrong about how it processes the damage. When buildings are added to the city that have this adjacent damage potential, they total up on an Adjacent Damage Percent variable and every round the city 'attacks' all adjacent enemy units. There's a one in four chance of striking. The damage dealt is relative to the CURRENT HP (edited) of the unit. If 50% total adjacent damage, and the unit has 60 HP left, it will deal 30 to that unit, leaving the unit with 30 remaining. This should mean that it's very uncommon for units to be completely killed outright from this effect at all. Maybe something else entirely is afoot.
* This means that when buildings process in and out, they should be removing any amounts from obsoleting or replaced buildings. I will check on this variable to ensure that but usually it's the same code line that adds the value to the city as the code line that removes it, with the difference in the cycle being whether the building is being processed in or out. It's possible it COULD not be processed out when obsoleting and that would be an explanation of the issue as some tags do this intentionally and if the processing statement on this variable is nested where those tags are being processed, that would explain the issue. I'll know here very shortly... no that shouldn't be an issue unless this is a much bigger bug that's applying to a LOT of things it shouldn't be applying to, like XP for units and all sorts of things.
* That pretty much leaves one suspicion remaining and that would be that in this era we start getting total values in cities capable of going over 100% and that particular city is doing exactly that. If this is incorrect, which I'll see soon, the digging into the code on this save is going to get a LOT more complicated!
* I have actually modded the code - first time in a while here! I added a total Adjacent Damage Percent line to the defense help hover tooltip (hover over the rook symbol in the upper right in the city to see this.) With a nanospy in a few japanese cities, I was able to see that the totals are ranging up to 80% but I'm not seeing it going above that.
Now... that's a lot, yes. But it doesn't explain how units are vanishing at all. I even stepped through the code and watched the damage being dealt and it seemed to be assigning it properly.
Can the programmers among us see anything incorrect here? Extra looping through units or?
The Japanese city your save starts off next to has an 80% total which is pretty intense. It was actually far worse than Fukushima which was nowhere near as high.
I'm thinking something else is causing the deaths here... by chance do you have the opportunity fire bug option on?
As a side note: I do think it's a bit too high. I scrolled through to try to total up sources for a while and noticed that the Fire Abatis is even still in place. Hmm... Should that perhaps be obsolete by then or no?
We might want to consider these buildings and a deeper analysis of the potential amounts they can build up to and reign them in a little. When it DOES get over 100% it's going to be problematic and this 80% was possible a bit too early for that much I think.
* I'm wrong about how it processes the damage. When buildings are added to the city that have this adjacent damage potential, they total up on an Adjacent Damage Percent variable and every round the city 'attacks' all adjacent enemy units. There's a one in four chance of striking. The damage dealt is relative to the CURRENT HP (edited) of the unit. If 50% total adjacent damage, and the unit has 60 HP left, it will deal 30 to that unit, leaving the unit with 30 remaining. This should mean that it's very uncommon for units to be completely killed outright from this effect at all. Maybe something else entirely is afoot.
* This means that when buildings process in and out, they should be removing any amounts from obsoleting or replaced buildings. I will check on this variable to ensure that but usually it's the same code line that adds the value to the city as the code line that removes it, with the difference in the cycle being whether the building is being processed in or out. It's possible it COULD not be processed out when obsoleting and that would be an explanation of the issue as some tags do this intentionally and if the processing statement on this variable is nested where those tags are being processed, that would explain the issue. I'll know here very shortly... no that shouldn't be an issue unless this is a much bigger bug that's applying to a LOT of things it shouldn't be applying to, like XP for units and all sorts of things.
* That pretty much leaves one suspicion remaining and that would be that in this era we start getting total values in cities capable of going over 100% and that particular city is doing exactly that. If this is incorrect, which I'll see soon, the digging into the code on this save is going to get a LOT more complicated!
* I have actually modded the code - first time in a while here! I added a total Adjacent Damage Percent line to the defense help hover tooltip (hover over the rook symbol in the upper right in the city to see this.) With a nanospy in a few japanese cities, I was able to see that the totals are ranging up to 80% but I'm not seeing it going above that.
Now... that's a lot, yes. But it doesn't explain how units are vanishing at all. I even stepped through the code and watched the damage being dealt and it seemed to be assigning it properly.
Code:
void CvCity::doAttack()
{
PROFILE_FUNC();
if (getAdjacentDamagePercent() > 0)
{
if (GET_TEAM(getTeam()).getAtWarCount(false) > 0)
{
bool abInformPlayer[MAX_PLAYERS];
for (int iI = 0; iI < MAX_PLAYERS; iI++)
{
abInformPlayer[iI] = false;
}
for (int iI = 0; iI < NUM_DIRECTION_TYPES; ++iI)
{
CvPlot* pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));
if (pAdjacentPlot != NULL)
{
for (CvPlot::unit_iterator unitItr = pAdjacentPlot->beginUnits(); unitItr != pAdjacentPlot->endUnits(); ++unitItr)
{
CvUnit* pLoopUnit = *unitItr;
if (pLoopUnit->getTeam() != getTeam())
{
if (GET_TEAM(getTeam()).isAtWar(pLoopUnit->getTeam()))
{
// Koshling - changed city defenses to have a 1-in-4 chance of damaging each unit each turn
if (pLoopUnit->baseCombatStr() && GC.getGame().getSorenRandNum(4, "City adjacent damage") == 0)
{
int iDamage = pLoopUnit->currHitPoints();
iDamage *= getAdjacentDamagePercent();
iDamage /= 100;
pLoopUnit->changeDamage(iDamage, getOwner());
if (!abInformPlayer[pLoopUnit->getOwner()])
{
MEMORY_TRACK_EXEMPT();
abInformPlayer[pLoopUnit->getOwner()] = true;
CvWString szBuffer = gDLL->getText("TXT_KEY_MISC_UNITS_DAMAGED", getNameKey());
AddDLLMessage(pLoopUnit->getOwner(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, NULL, MESSAGE_TYPE_INFO, pLoopUnit->getButton(), CvColorInfo::red(), pLoopUnit->getX(), pLoopUnit->getY(), true, true);
}
}
}
}
}
}
}
}
}
}
The Japanese city your save starts off next to has an 80% total which is pretty intense. It was actually far worse than Fukushima which was nowhere near as high.
I'm thinking something else is causing the deaths here... by chance do you have the opportunity fire bug option on?
As a side note: I do think it's a bit too high. I scrolled through to try to total up sources for a while and noticed that the Fire Abatis is even still in place. Hmm... Should that perhaps be obsolete by then or no?
We might want to consider these buildings and a deeper analysis of the potential amounts they can build up to and reign them in a little. When it DOES get over 100% it's going to be problematic and this 80% was possible a bit too early for that much I think.
Last edited: