Well, i didn't really look for any way to do that, but for a way that doesn't make me change two or more files every time i make changes to some personalities.
- Code: Select all
//-- Includes another source code file at this point. This is experimental, and breaks the
//-- lint tool, so use with care.
static QScriptValue js_include(QScriptContext *context, QScriptEngine *engine)
Unfortunately, this function is nothing like #include in C or include in PHP. It can't be called in global scape, but only inside other functions, so it's not very useful to include my personality definitions that are mostly a bunch of global constants.
aubergine wrote:A lot of the code will be the same between AIs, from my understanding what will differ is:
* base build order
* research paths
* droid components
* attack targets
There's probably a few other bits that I've not thought of.
In fact, attack targets are the same. They are just things to destroy to make the enemy officially dead, in a particular order.
Anyway, here is some code, but it's pretty ugly, and it takes a lot of work to add more personalities. As you couldn't have noticed yet, every .js file is made of three parts: head that is equal for all personalities, tail that is equal for all personalities, and personality-specific code in between. In fact, i merge them with "cat" command before packing the mod. Now i can just place several personality code blocks in between and it will make the AI randomly choose one of them. But the list of all possible personalities ever existed needs to be known in advance, and it's duplicated in many places; see the beginning of the tail for all the ugliness. I'm still looking for an elegant way of getting rid of it.
Fortunately, due to #3147
, we won't have too many new personalities in the nearest future. Unfortunately, we already have too many.
- Random AI available, that picks randomly one of the personalities. Currently, it doesn't pick hover or generic personalities, cause they're too weak in normal games. It is packed into a separate mod, though it's ok to load two mods simultaneously (but you won't be able to use Semperfi AI in that case due to lack of widget space);
- No longer accidentally flashlight for tanks (usually too weak compared to TAG or plasmite, bad idea to switch)
- Delay other work when need to build anti-air defenses;