phungus420
Deity
- Joined
- Mar 1, 2003
- Messages
- 6,296
So I could try posting this in the SDK and Python section, but I figure the only person to really know is jdog5000 anyway. So jdog, how do you reccomend going forward on having the engine figure out the best attacker in a stack?
In Piece of Mind's Advanced Combat Modcomp a recent addition to the code has been made. It might not make it into the final version of the modcomp, but I want it anyway. Here is how it works, you check out the battle odds normally, but then you can press control and the battle is reversed, showing the odds as though the defending unit were to attack you. That's pretty awesome in and of itself but, unfortunatly it shows the combat odds of the best defender in the stack attacking you. The goal is to get it to shift to the best attacker:
This is an explanation of what I've tried so far:
Any ideas on how to get this to work?
In Piece of Mind's Advanced Combat Modcomp a recent addition to the code has been made. It might not make it into the final version of the modcomp, but I want it anyway. Here is how it works, you check out the battle odds normally, but then you can press control and the battle is reversed, showing the odds as though the defending unit were to attack you. That's pretty awesome in and of itself but, unfortunatly it shows the combat odds of the best defender in the stack attacking you. The goal is to get it to shift to the best attacker:
This is an explanation of what I've tried so far:
Spoiler :
Here is where we start, this code works to show the defending unit's odds as if it were attacking:
Now I tried adding in a line
But it said getBestAttacker wasn't a member of CVPlot. So I tried to create getBestAttacker in CVPlot, but it said the group was already full (presumably by getBestDefender?), then I tried finding some relevant code in the CVUnit_AI, but couldn't find anything relevant. Finally I tried to use this code from CVSelectionGroupAI.
and said it was illegal. So I changed CVSelectionGroupAI to CVGameTextMng (the file I'm editing), and then it said AI_attackOdds wasn't a valid group for CVGameTextMng. This last snippet of code I tried twisting around every which way I could, but it always failed to compile for some reason or another.
Code:
int iEnemyOdds = GC.getDefineINT("SEE_ATTACKER_ODDS");
if (iEnemyOdds > 0)
{
bool bctrl; bctrl = gDLL->ctrlKey(); if (bctrl)
{
CvUnit* swap = pAttacker;
pAttacker = pDefender;
pDefender = swap;
}
Code:
pAttacker = pPlot->getBestAttacker(pAttacker->getOwnerINLINE(), pAttacker, false, NO_TEAM == pAttacker->getDeclareWarMove(pPlot));
Code:
int CvSelectionGroupAI::AI_attackOdds(const CvPlot* pPlot, bool bPotentialEnemy) const
{
CvUnit* pAttacker;
FAssert(getOwnerINLINE() != NO_PLAYER);
int iOdds = 0;
pAttacker = AI_getBestGroupAttacker(pPlot, bPotentialEnemy, iOdds);
}
Any ideas on how to get this to work?