SDK request: Missions From Python

Zebra 9

Emperor
Joined
May 17, 2006
Messages
1,554
Location
Middle of Cyberspace
I'm not much for C++ but I do know quite a bit about Python and a need to be able to add missions to units and be able to tell the AI how to use the mission.
So what I am hopeing is that some of you C++ guys could at least give me some ability. I would like it to work somthing like the CvGameUtils.py file, just a bunch of functions with names like, canDoMission, cantDoMission, and some ai functions (don't know what you call those). I will be using this in an as yet unannouced MOD I am working on (it will be amazing IMO:cool:).
 
Missions are done through C++. It's the only logical spot for it. It is technically possible through python, but I don't see why you would bother doing it that way.

I've added a number of new missions to mods, all fully AI able, and it's not really as difficult as it seems. Just need to include stuff in the right spots. ;)

Essentially, in CvUnit you just need:
- canMission: can the unit do the mission?
- canDoAtMission: only needed for targetted missions
- doMission: do the mission obviously

Then just create the call to your new mission in CvSelectionGroup::canStartMission() and CvSelectionGroup::startMission().

Disclaimer: this was all from memory, so I might be wrong on the function names. :)
 
Missions are done through C++. It's the only logical spot for it. It is technically possible through python, but I don't see why you would bother doing it that way.

I disagree. I think that adding a way to make new missions in XML and/or Python only, besides being great for the non-SDK modders, have plenty of other advantages: faster debug time, more pseudo-object-oriented methods, being able to modify how a mission works all in one spot, if the SDK changes you just need to change where the function calling python is, instead of changing all the missions over.

The problem is creating the framework (which I have been doing with Planetfall) and then putting it in a form where other people can use it (which I haven't done so well :P). For example, AI functions would be a bit strange to those who aren't sure how the SDK AI functions work.

Just looking at the Spell system in FFH and how much work it has saved.
 
Actually, python processing is slower. C++ is native, whereas python requires interpretation and on-the-fly compiling.
 
Actually, python processing is slower. C++ is native, whereas python requires interpretation and on-the-fly compiling.

Well, I think that goes without saying. However, unless you're doing massive amounts of data crunching (which, granted, is possible when you're doing AI calculations) the difference should be negligible on a modern (or even slightly pre-modern) system.

It's a trade-off, certainly, but I haven't experienced the need to start throwing stuff back into C++, even when running on a 5-year-old laptop. If python's speed was that much of a burden Firaxis wouldn't even be using it.
 
Essentially, in CvUnit you just need:
- canMission: can the unit do the mission?
- canDoAtMission: only needed for targetted missions
- doMission: do the mission obviously

Then just create the call to your new mission in CvSelectionGroup::canStartMission() and CvSelectionGroup::startMission().
I think the code might look like this.
Code:
if ([I]call Python Function With Switch statement[/I] == True)   //Handled by python
{
          return
}
[I]C++ Switch Statment Here[/I]
I think this would do it, but I'm just learning C++ and I don't have a compiler.
 
Back
Top Bottom