SDK - modified forts - how to recognize them as dangers?

Joined
Feb 6, 2006
Messages
796
I've modified forts so that, with the proper units inside, they can bombard enemies in close tiles.
Now, I need a way to teach the AI how to avoid them during an invasion.
I've found the method AI_getPlotDanger, and I've tried to modify it to take into account those forts. However, it doesn't seem to work; his unit fortifies just in front of a fort, and stays there to keep being bombarded.
Any idea?
Thanks!
 
Did you make it so the fort's plot is recognized as dangerous, or the plots around it? It usually helps if you post code so we can see what you've done.
 
I've created two boolean methods in the CvPlot class: isHasDangerousFort and isCloseToDangerousFort (I hope it's clear what they return! :). If you need it, I'll post these codes too.).
Then, in the CvPlayerAI.AI_getPlotDanger method, I've added this code just before the final "return":

Spoiler :
if (pPlot->isCloseToDangerousFort(getID()))
iCount+=2;​

Is it the wrong place where to put this check?
Have I to consider something else as well?
Is the value I've added (2) a too small value to have any effect?

What I want is that, if the AI recognizes a tile as dangerous, he moves his units away, instead of keeping them fortified to be bombarded.

Thanks!
 
Your logic seems correct to me, but I just don't know enough about the AI code to answer whether that is the correct approach to take or if +2 is enough of a modifier. You could try plugging in some crazy value, like +100, to see what happens.
 
Back
Top Bottom