Page 1 of 1

xml for self.XMLScript

Posted: Sun Oct 19, 2008 7:21 pm
by dagg
hello.
I've seen in the file ai_qct_waitjump.py that there is a call for self.XMLScript on a script.
form what I understand, this file can guide the ship, right? if yes what is the syntax of the file?

Re: xml for self.XMLScript

Posted: Mon Oct 20, 2008 10:07 pm
by dagg
another question, can I insert a xml string instead of the path?

Re: xml for self.XMLScript

Posted: Mon Oct 20, 2008 11:19 pm
by ace123
I don't know much about AI scripts, but I suspect not.
Also, a lot of the AI is coded in C++.

There are python AI scripts, but I don't think they are used ever but rarely because it may be too slow for each ship to run it many times a second (think a hundred ships like exist in a normal VS system). It looks like the last time the AI script you referenced was modified was in 2003, so there's a chance it won't work entirely correctly.

But there are AI functions you should be able to call unit.LoadAIScript("somefile.py") if you want a python AI script.

if you describe in more detail what you are trying, you may get more forum responses.

Re: xml for self.XMLScript

Posted: Tue Oct 21, 2008 7:54 am
by dagg
I want to cause the ship to circle a planet.

OT, can you answer my previous post at http://vegastrike.sourceforge.net/forum ... 38&t=13193 ?

Re: xml for self.XMLScript

Posted: Fri Oct 24, 2008 10:07 am
by ace123
There are a lot of hardcoded scripts you can choose from (the list is in src/cmd/ai/script.cpp). Also, the ai/script directory has a lot of XML ai scripts.
maybe you want "loop around" or have a XML file call "face perpendicular" and also have a speed.

Alternatively, it should be possible to use a PlanetaryOrbit which you can do by placing the unit in orbit in the system file. However planetaryOrbit actually sets the position to the correct place in the orbit so for non-massive units this may not be the best thing.

I believe python has a LoadAIScript (or an EnqueueAIScript) whcih takes a script name as an argument. This script name can either be something in ai/script or one of the hardcoded scripts.

Re: xml for self.XMLScript

Posted: Fri Oct 24, 2008 5:02 pm
by dagg
ok, I've looked into the file you've mentioned, there are usable scripts, the questions are,
1) can I set the object that the script will cause the ship to circle around?
2) how can I call this scripts? can they be linked to a specific key stroke? how?

Re: xml for self.XMLScript

Posted: Thu Oct 30, 2008 8:54 pm
by dagg
sorry for bumping this topic up but I could really appriciate an answer on this issue

thanks

Re: xml for self.XMLScript

Posted: Fri Oct 31, 2008 12:41 am
by ace123
Not sure if it's possible to call the scripts directly with a keystroke (though you can send them certain commands like formation or attack my target, so it might be possible to override one of them to be "circle around my target".

It is possible to bind keys to commands that you can type while in flight, if that is good enough, like:
'[' (brings up prompt), "/mycommand", enter

These commands are defined in "custom.py" so you can try and copy one of those examples and make it just do something simple like:
VS.getPlayer().GetTarget().ExecuteAIScript("something");
which will execute something on the player's target. Or you can search for a specific unit.

To set the object that a ship circles around you set its target (I think that's the only thing it will look at but I'm not entirely sure. Kind of unintuitive and ships can only have one target. If you want AI scripts to do special things you may have to write them in Python by extending the PythonAI class, and then you should be able to do anything you want.