AirCombatLimit - idea for MOD

cf_nz said:
2. Remove hills from the terrain modified defense bonus, a unit on a hill is actually more exposed to aircraft.

Well, the Hills terrain is not literally just one hill on which the units are standing but rather represents an area with hilly terrain. But I see where you're coming from... the trees are a better defense modifier for this point.
 
Dom Pedro II said:
Well, the Hills terrain is not literally just one hill on which the units are standing but rather represents an area with hilly terrain. But I see where you're coming from... the trees are a better defense modifier for this point.

Do you think hilly terrain should provide some form of defensive cover against air attacks though. Convince me it's realistic and I'll change it back.
 
3. Show the 'your .... has destoyed a ....' text for air strikes.

Done this also, a simple cut and paste job.

Learnt more about sinking ships. Seems to work in practice that if the airCombatLimit from the XML file is 90 and the max set in the SDK is 100. You can damage a ship up to 90%, destroy it at 100% but not in between. So if after a few strikes it has taken 80% damage, the next strike takes it to 95% damage, no more damage can be done, ie. cannot sink it. Compared with, if a ship has 85% damage and the next strike can take it over 100% it will be sunk.
 
I was looking at this earlier today and here's what I came up with.

Maxed AirCombatLimit in the XML files to 90.

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.

Doing it like that means that every type of air unit will be able to sink ships. My inclination is to make it more variable. Something like this. You could set Stealth Bombers to 90. But then have ordinary Bombers at 80, Jet Fighters at 70 and ordinary Fighters at some lower figure. You might not want to use these numbers but you can see what I'm getting at.

Instead of using a constant '100' as a naval airCombatLimit, you make it a function of those figures from the XML. Then, for example, ordinary Bombers could be able to sink ships but only do 80% damage to exposed land units. Jet Fighters could do 90% damage to ships but only 70% to exposed land units.

Otherwise a hill with trees got no bonus, couldn't quickly figure out a way to check if pPlot is trees/jungle.

Yeah, as I recall CodeBlocks doesn't provide the kind of mouseover help that you can get with Visual Studio 2003. So, I suggest:

Code:
//added plot defenseModifier
int iAirLimit;
if (pDefender->getDomainType() == DOMAIN_SEA)
{
	iAirLimit = airCombatLimit()+20;//sea units suffer more damage
}
else
{ 
	if(pPlot->getPlotType() == PLOT_HILLS 
	&& !(pPlot->getFeatureType()== (FeatureTypes)GC.getInfoTypeForString("FEATURE_JUNGLE")) 
	&& !(pPlot->getFeatureType()== (FeatureTypes)GC.getInfoTypeForString("FEATURE_FOREST")) )
	{
		iAirLimit = airCombatLimit();//exposed units on hills get standard calculation
	}
	else//include plot defenseModifier in calculation
	{
	   iAirLimit = max(airCombatLimit() - pPlot->defenseModifier(pDefender->getTeam(),false), 0);
	}
}
iUnitDamage = max(pDefender->getDamage(), min((pDefender->getDamage() + iDamage), iAirLimit) );

//this is just for debugging:
szBuffer = gDLL->getText("iUnitDamage %d1, iAirLimit %d2", iUnitDamage, iAirLimit);
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getDefineINT("EVENT_MESSAGE_TIME"), szBuffer, "NULL", MESSAGE_TYPE_INFO, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), NULL, NULL, true, true);

//end change

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 ran into this, too, and it took awhile to figure out what was going on. There's another call to 'airCombatLimit()' in CvPlot::getBestDefender. This is where the game determines which particular defender on the plot is the one that is going to be attacked. You have, essentially, to duplicate whatever method you've used in 'CvUnit::airStrike'; so what I did was:

Code:
if (!bTestCanMove || (pLoopUnit->canMove() && !(pLoopUnit->isCargo())))
{
	//added plot defenseModifier
	int iAirLimit = 0;
	if(pAttacker != NULL)
	{
		if (pLoopUnit->getDomainType() == DOMAIN_SEA)
		{
			iAirLimit = pAttacker->airCombatLimit()+20;//sea units suffer more damage
		}
		else
		{ 
			if(getPlotType() == PLOT_HILLS 
			&& !(getFeatureType()== (FeatureTypes)GC.getInfoTypeForString("FEATURE_JUNGLE")) 
			&& !(getFeatureType()== (FeatureTypes)GC.getInfoTypeForString("FEATURE_FOREST")) )
			{
			   iAirLimit = pAttacker->airCombatLimit();//exposed units on hills get standard calculation
			}
			else//include plot defenseModifier in calculation
			{
				iAirLimit = max(pAttacker->airCombatLimit() - defenseModifier(pLoopUnit->getTeam(),false), 0);
			}
		}
	}
	if ((pAttacker == NULL) || (pAttacker->getDomainType() != DOMAIN_AIR) || (pLoopUnit->getDamage() < iAirLimit) )
	{
		if (pLoopUnit->isBetterDefenderThan(pBestUnit, pAttacker))
		{
			pBestUnit = pLoopUnit;
		}
	}
}

There's another call to 'airCombatLimit()' in CvUnitAI::AI_airStrike() that needs to be dealt with. This is where the AI decides if it wants to launch an airstrike on a unit. It looks like it might be worthwhile to add a new method to the CvUnit class. It's not necessary but it's a bit tidier.
 
Thats absolutely brilliant PeteT. Runs perfectly.

Instead of using a constant '100' as a naval airCombatLimit, you make it a function of those figures from the XML.
Yeah, thats a great idea. I'm still torn about what values to use, ultimately I'm striving for some kind of reality. So I guess all air units should be able to sink ships (with the possible exception of the fighter, depending on how you see it's role), it's just a matter of how much damage should they be able to do to land units.

Edit: In practice the lower you make the airCombatLimit vs land units the higher the relative terrain defense will become. Will need to strike a balance. Or try something like (airCombatLimit - (terrainDefense - (100 - AirCombatLimit))).

Will also need to redo collateral damage with the new plot related code.
 
I have incorperated some of these ideas in my [BTS SDK] Ultimate Ranged Combat Mod.

THe Mods allows units different attack value for Ships, Submarines and Ground units, allowing for specialised Attack units. It also incudes Seperate Lethality Values for Each attack type. So you can give torpedo bomber high Lethal value agains ships, allowing them to sink ships. All unit also have an armor value allowing your ships to be invincible from Fighter which can pennetrade their thick armor.
 
I have noted the lack of fighters attacking ships as well- but i just add this to the UnitAi for fighters/JetFghters in CivUnits.xml:
<UnitAIs>
<UnitAI>
<UnitAIType>UNITAI_ATTACK_SEA</UnitAIType>
<bUnitAI>1</bUnitAI>
</UnitAI>

This seems to tell the fighters that they Can attack ships.
Ive modded their attack to full kill, with +100% v. Battleships.

The Ai seems to catch on to this pretty quick, and ive noticed a marked increase in AI carriers once flight is discovered- usually Battleships hang around for ages.

This BtS, btw.

Regards,
HDK
 
Back
Top Bottom