AirCombatLimit - idea for MOD

cf_nz

Prince
Joined
Mar 17, 2006
Messages
414
Location
New Zealand
This has been mentioned a number of times with regards people wanting to allow air units to destroy sea units and even some land units.

It's something I've always wanted to improve. Unfortunately my modding ability is limited to XML modification.

Changing to value of iAirCombatLimit to 100 too allow unit destruction is too powerful a change. So as a kind of compromise I've got an idea for a compromise.

Is it possible though?

The idea is to remove the current fixed iAirCombatLimit value and replace it with a value representative of the tile defense, in practice iAirCombatLimit becomes something like 100 - tile defense.

So a ship on an ocean square and a land unit on open ground can be completely destroyed by air strikes; a unit in a fort on a hill will get 50% damage; units in a modern city may not take any damage until the city defenses are reduced.

So once again is it possible? What level of modding will be required, python and/or SDK?

As I said this is not something I have the programming ability to do so I would appreciate any input.

Thanks.
 
cf_nz, I have already done this in my Air Forces Mod... you should test it out to see if it answers your needs.
 
TheLopez,

I think that what you've done is not really what he's asking for. What you did was:

Code:
iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), 100));//airCombatLimit()));

But I think that what he wants is something like:

Code:
iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), airCombatLimit() - pPlot->defenseModifier(pDefender->getTeam(),false)));
 
PeteT,

Can you translate those lines a little for me please. My knowledge of C++ is very limited.

iUnitDamage = ? calculation of max damage done to unit
pDefender = defenders ? strength
iDamage = ??

TheLopez has removed AirCombatLimit from the equation but how does the 100 come into things now?
 
The line comes from the method 'void CvUnit::airStrike(CvPlot* pPlot)' which makes an air unit launch an air attack on the CvPlot* pPlot.

pDefender = the best defender against an air strike on pPlot.

iDamage = how much new damage could this attacking air unit inflict on pDefender.

iUnitDamage = the unit's actual damage level after the attack (so if its >100, he gets killed).

TheLopez has removed AirCombatLimit from the equation but how does the 100 come into things now?

airCombatLimit() returns the unit's iAirCombatLimit from CvUnitInfos.xml, so as I read it, what Thelopez did is equivalent to replacing the '50's in the vanilla game xml with '100's.

By the way, I tried this out and, although it sort of works, there's a problem with unrealistic collateral damage. I'll have another look at it tomorrow.
 
airCombatLimit() returns the unit's iAirCombatLimit from CvUnitInfos.xml, so as I read it, what Thelopez did is equivalent to replacing the '50's in the vanilla game xml with '100's.
Of course, now that you explain it it's just a straight replacement. This is one of the first things I did, changed the XML 50's to 100's. I thought it was over powered.

By the way, I tried this out and, although it sort of works, there's a problem with unrealistic collateral damage.
Great, I'll have look and see what I can achieve through trial and error.
 
The problem is that if it isn't removed then air domain units cannot destroy land domain units. That's why I commented it out.
 
TheLopez said:
The problem is that if it isn't removed then air domain units cannot destroy land domain units. That's why I commented it out.

Sorry, I'm learning so I question everything ;).
 
The idea is to remove the current fixed iAirCombatLimit value and replace it with a value representative of the tile defense...

units in a modern city may not take any damage until the city defenses are reduced.

As usual, one thing leads to another. ;)

I think we need to make the same kind of change with respect to collateral damage. For example, you have a Bomber attacking a unit in a city. The unit being attacked suffers no damage because he gets a tile defense bonus. But other units in the city may suffer significant collateral damage because - as the game currently works - they don't get a tile defense bonus. What do you think?
 
I think we need to make the same kind of change with respect to collateral damage.
Agreed.

Can the tile defense modifier be added to the calculation for collateral damage, or is it more complicated than that?

Can you also document (in this thread) any code changes you make, as a reference, thanks.
 
Can the tile defense modifier be added to the calculation for collateral damage, or is it more complicated than that?

Actually, it will be more complicated as we only want to change collateral damage done by air units, not by all units.
 
That's not really a problem. I just added these lines into 'void CvUnit::collateralCombat':


Code:
if(getDomainType() == DOMAIN_AIR)
			{
				iCollateralDamage -= (iCollateralDamage * pBestUnit - > plot() - > defenseModifier(pBestUnit- > getTeam(),false)) / 100;//pft add terrain defense
}

What I'm more worried about is that the tile defense modifiers can be a bit overwhelming.

BTW, do you have a compiler so that you can build the dll?
 
What I'm more worried about is that the tile defense modifiers can be a bit overwhelming.

In terms of terrain or city defense?

BTW, do you have a compiler so that you can build the dll?

Not one that I can get to work. I've not managed to download Microsoft's Platform SDK yet, so can't use the CodeBlocks option.
 
Thanks for all your help PeteT. I have it complied and running.

The tile defense modifier for city defense is a bit strange. Say a city has +40% tile defense. 40 is actually viewed as 100% when it comes to bombardment, reducing it to +30% will show 'you have reduced the defences to 75%'. In practice there is no difference between a city with +40% and one with +80%.
 
Played around a bit more and got it working perfectly now. Maxed AirCombatLimit in the XML files to 90.

Changed the collateral damage calc to include PeteT's change.

from:

Code:
iCollateralDamage -= (iCollateralDamage * pBestUnit->getCollateralDamageProtection()) / 100;
to:

Code:
if(getDomainType() == DOMAIN_AIR)
{
    iCollateralDamage -= (iCollateralDamage * pBestUnit->plot()->defenseModifier(pBestUnit->getTeam(),false)) / 100;//pft add terrain defense
}
else
{
    iCollateralDamage -= (iCollateralDamage * pBestUnit->getCollateralDamageProtection()) / 100;
}

also combined PeteT's airCombatLimit change with the one from TheLopez's Air Force Mod to allow ships to be sunk but land unit get a max of 90% damage.

from:

Code:
iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), airCombatLimit()));
to:

Code:
if (pDefender->getDomainType() == DOMAIN_SEA)
{
    iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), 100));//airCombatLimit())); The Lopez
}
else
{
    iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), airCombatLimit() - pPlot->defenseModifier(pDefender->getTeam(),false)));//pft add terrain defense
}
Now just need to get the ship death animation to play when suck by a plane.
 
That's looking good, cf_nz.

Sorry I haven't been posting. I wrecked up my back a few days ago and it put me out of action. But it's pretty well back to normal now.

Is there anything else you'd like to do with this?
 
PeteT said:
That's looking good, cf_nz.

Thanks, you've written it though remember.

Sorry I haven't been posting. I wrecked up my back a few days ago and it put me out of action. But it's pretty well back to normal now.

No problem, it's given me a chance to learn some C++. Glad you are back to normal.

Is there anything else you'd like to do with this?

Yeah a few of things.

1. Get the death animations to work if a sea/land unit is destoyed by an air unit.

2. Remove hills from the terrain modified defense bonus, a unit on a hill is actually more exposed to aircraft. Also a city on a hill will get to great a defense bonus. Hopefully this is as simple as: if terrain == hill do standard calc else do modified calc. I've not tried this yet though. DONE

3. Show the 'your .... has destoyed a ....' text for air strikes. DONE

I kind of inadvertently managed to allow the ships to be destroyed but not land units (see last bit of code above). I say inadvertently because whilst I was trying to do this I can't get it to work as a stand alone change.

I have made numerous little changes to the unit xml, could they have an impact on this?? I'm happy with the way it is but would like to try to understand why it works.

Thanks again.
 
Been playing around a bit more, solved #2 above with regards to the hills. I took the easy but slightly crude method of:

Code:
    if (pDefender->getDomainType() == DOMAIN_SEA)
    {
        iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), 100));//airCombatLimit())); The Lopez
    }
    else
    {
        if (pPlot->isHills())
        {
            iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), airCombatLimit() - pPlot->defenseModifier(pDefender->getTeam(),false) + 25)); //PeteT
        }
        else
        {
            iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), airCombatLimit() - pPlot->defenseModifier(pDefender->getTeam(),false))); //PeteT
        }
    }
where the +25 cancels out the hill defense bonus. Otherwise a hill with trees got no bonus, couldn't quickly figure out a way to check if pPlot is trees/jungle.
 
cf_nz said:
I have made numerous little changes to the unit xml, could they have an impact on this?? I'm happy with the way it is but would like to try to understand why it works.

The answer here is yes. Increasing the airCombatLimit to 90 in the XML has an effect, even though in theory the limit for sea units is 100 anyway (changed in SDK).
 
Top Bottom