Good luck with that. I've been trying to 3 years.
Heh, do you know if it's possible to create new "callbacks", or are we stuck with the ones that exist already? That's what I should probably try next... Steal an existing callback and use that instead.
Right now I tried interjecting this code into things, once a defender and attacker has been decided upon (and they're pointed at each other and all, it happens right before CvMissionDefinition kMission

. Unfortunately it crashes, and I'm rather stumped as to why. If my declaration or passing of arguments was the case, I'd tinker with that. If the callback isn't defined elsewhere in the code (or is embedded into the EXE), then I'd work around that. But for now, I don't know what the case is.
Anyway, here's what I have so far:
Code:
if (1)
{
CyUnit* pyAttacker = new CyUnit(this);
CyUnit* pyDefender = new CyUnit(pDefender);
CyArgsList argsList2; // XXX
argsList2.add(pyAttacker);
argsList2.add(pyDefender);
long lResult=0;
gDLL->getPythonIFace()->callFunction(PYGameModule, "customCombat", argsList2.makeFunctionArgs(), &lResult);
delete pyAttacker;
delete pyDefender;
if (lResult == 1)
{
return;
}
}
The python code should be irrelevant, as it doesn't produce an exception, but the function called basically assembles a list of all of the attackers and all of the defenders and randomly picks a defender to die. Sure, a little unbalanced for the attacking side, but it's just a placeholder.
Where I more skilled with c++, this wouldn't be all that difficult, but I'm just dead set on using python because the only dynamic memory structuring available in c++ (as in, storing an arbitrary number of ships) is a bit beyond my comprehension and requires like 100 lines of code just to manipulate. Python it's just.. "untlist.append(unit)". And then you go... unitlist[SorenRand(len(unitlist))].kill and boom, a random unit is killed.
