Route air bombing

NotSoGood

Emperor
Joined
Jan 25, 2009
Messages
1,077
Location
Finland
This is a little modcomp that allows you to air bomb routes. It uses the original improvement and city defence bombing button. I have tested it, and it works. I have redone the AI code, but I'm sure the AI won't use it like humans would.
download

GREDITS
Huge thanks to xienwolf and EmperorFool for teching and explaining me how to do things with SDK.
 

Attachments

  • Civ4ScreenShot0004.JPG
    Civ4ScreenShot0004.JPG
    180.7 KB · Views: 385
  • Civ4ScreenShot0005.JPG
    Civ4ScreenShot0005.JPG
    181.7 KB · Views: 329
Nice. I don't know how many times I've ALMOST done this mod for Merged Mod, but simply not found the time for it. My guess is that the AI will use it randomly from time to time, but it probably won't do it smartly (unless you've taught it when and, more importantly, what to target). :goodjob:
 
Nice. I don't know how many times I've ALMOST done this mod for Merged Mod, but simply not found the time for it. My guess is that the AI will use it randomly from time to time, but it probably won't do it smartly (unless you've taught it when and, more importantly, what to target). :goodjob:

I have added few lines to AI. The all I want to know is how to improve the logic AI uses. That's why I need someone else's oppinion too.
 
I wish I could help you do it. But my skills are not that great when it comes to actually programming the AI. Which is another reason why I have been reluctant to introduce this concept. I suspected it would become another war tool for the human, but a concept which could detract from the AI's use of airpower. Given the amount of roads that exist in this game, you're basically giving the AI a target for every plot you've built roads on. It's not smart enough to select the important targets. In my humble opinion, if we could just make the AI bomb the improvements on strategic, non-obsolete bonus resources better than it does now, that would be a great improvement (and I say this without empirical evidence that it actually sucks at this) :D
 
This is actually the first AI code I have ever made. And actually the first code that added myself. (I'm not saying that I made this all by myself, most of the work was done by xienwolf and EmperorFool) I think also that the way I have done it now, isn't the best way to do it.
Perhaps I should ask jdog5000 about this...
 
One of the toughest parts of conquest is that the enemy can use its roads within its territory. That means that an offensive stack is always reacting to the enemy forces that are quicker because they can use (rail)roads.

If the main game had the option of air bombing of roads, then I would use it on the roads around my main stack which was advancing through enemy territory in order to remove the advantage of faster movement from the AI. I could stop counterattacks against my stack. It should be possible for the AI to recognise its main offensive stacks and the roads around it and do the same.

However, it might also be more interesting to use the bombers to actually bomb enemy units that can reach its own units. Maybe the AI should prefer to do that as I don't see it using the air bombing of roads as tactically sound as a human could.

Another interesting option is to bomb resource improvements plus the roads connecting them. That way, it will take the opponent longer to reconnect them. I still think that the AI should prefer to bomb actual units that could harm its units though.

Oh, nice work by the way. It's one of those elements that should have been part of the game from the start (vanilla civ4).
 
I have tested it few times in different situations. I think the AI code doesn't even have to be anything big. I think the code I have now is good enought until I or someone else come with better idea how to do it. The only thing I'm going to change now, is the AI values I gave to plots. I have to reduce them a bit. The AI concentrates too much to improvements. It should bomb something else too(units, cities, etc.).

EDIT: I have uploaded the modcomp with the changes I have made. I didn't change anything big, just cleaned the code little and lowered the value of routes and improvements. I'm going to test play the mod I'm making where I have merged this modcomp. Mayby I'll have a great idea how to improve it when testing the mod.
 
Ok, now when I have my DLL running smoothly again, I can start improving this modcomp. I have also found a bug that existed in the original BTS, but I don't know "how" to fix it. The problem is that CvUnit::canAirBombAt checks only if the plot has owner who you are at war with. And CvUnit::airBomb what uses that CvUnit::canAirBombAt check, checks if the plot owner is your enemy.
Now this leads to it when you try to bomb unowned plots the canAirBombAt lets you pass but the airBomb function returns false. So you can see the "plot picker" is green meaning you can bomb it, but nothing actually happens.

Now how do you want me to fix it. You can't air bomb unowned tiles AND see the grey "plot picker", or that you can air bomb unowned tiles?
 
I would prefer a situation where you can airbomb unowned tiles but the AIvalue for it is lowered so that the AI doesn't use it frequently. The AI isn't smart enough to know when it would be useful anyway and it usually won't be a great move. An unowned tile doesn't even have to be close to your enemy.
 
Hmm, since no one else said anything about air bombing unowned tiles, I guess you all agree with RJ. :D It's all up to you if you WANT to air bomb unowned tiles. And about the AI, I noticed it had this check in CvUnitAI::AI_airBombPlots()
Code:
				if (!pLoopPlot->isCity() && [B]pLoopPlot->isOwned()[/B] && pLoopPlot != plot())
So AI wont even consider bombing unowned plots. I don't think I'll change that. It would give some work with AI. :sad:

I thought about the fix, I might add a check in CvUnit::airBomb() something like this
Code:
	[COLOR="Red"]if (pPlot->isOwned())
	{[/COLOR]
		if (!isEnemy(pPlot->getTeam()))
		{
			getGroup()->groupDeclareWar(pPlot, true);
		}

		if (!isEnemy(pPlot->getTeam()))
		{
			return false;
		}
	[COLOR="red"]}[/COLOR]
Not sure yet if that'll work. I have also redone my previous route bombing AI. It's suprisingly hard to create a new AI that checks can you gain something from bombing routes. That's why the AI most likely won't bomb plain routes if it has something else to do. It still does need lots of testing. And if someone merges this in his/her mod (what i would like to hear :D), but someday wants to remove it, I have added a possibility to turn it off in the GlobaDefinesAlt. Then it should be like in the normal game.
 
I have uploaded a new version of this mod comp. The link is in the first post. I have redone the AI code, but it's still aweful. I have read these posts here and think that AI might not need to use this at all. The AI has better to do than air bomb stupid routes. BUT, I didn't ignore them completely. The AI might bomb them sometimes if there isn't much to do. Also other added thing are:
  • ability to turn the mod comp off (made for other modders that might include this in their mod)
  • a fix to air bombing unowned tiles (allowing you to air bomb plots that isn't someone's)
 
Possibly for the Unofficial Patch, definitely for my own mod, I'm requesting: Allow Air Bombardment of Enemy Forts (without the route bombing)
Both human and AI can only bombard an improvement on an unowned tile if it gives defense bonus or acts like a city AND at least one unit of an enemy team (isAtWar()) is present on that tile.
The AI should give the mission the same value as if the tile was actually owned by the enemy.


edit: nevermind
 
Top Bottom