Edit: "neutral" might also be a good faction choice, but I suppose in this specific case privateer works too... usually the player should be the only privateer unit.
Dilloh wrote:The main reason I want to do it in a different way is that I'd like the invitation to participate in a tutorial to start when the player leaves Atlantis for the first time when starting a new game (campaign). The tutorial would, of course, remain revisitable.
I am mostly learning from the different quest_* scripts in modules.
That's the main issue - fixer missions are nothing else then calling a module from a python script. You're trying to create a whole new mission type, surely based on an existing one, but still it's a whole lotta toughter then just placing modules.
VS has a lot of different ways of doing one thing. Just pick the most appropriate one for the job.
It supports campaigns, missions, independent fixers, quests, etc.
Quests are probably the best for this, as they are pretty lightweight, and saving your exact state is not a big concern.
In order for the drone to not disappear I need to keep it busy with something, like a target, or a position change.
There currently is no "greyhound bus" script, that means we cannot assign a flight plan for the drone. However, I'm not sure if the your tutorial expects the player to move far out... if not, simply rip out its engines, and let new tutorial drones spawn an the new nav points you're reaching.
First of all, look in quest_tutorial.py if you haven't already. It has a simple solution for some of this.
You can use "flightgroup directives" to give units specific orders (which is cool if you want to generate two drones and make one blow up another)
The list of is in C++ (undocumented) but I've decided to look through the code. This should probably go to the wiki sometime
H,h (help) -- leader of flightgroup requests help.
B,b (break and attack) -- default, everyone attacks like normal
A,a (attack target) -- attack their current targets
lowercase
k -- something undocumented, says something about capships
F,f (flagship?) -- Ship being escorted.
L,l -- undocumented, like F but has complicated formation rules
E,e -- half of this is copy and pasted from L but I have no idea
P,p (protect)-- I want to help out
You can also add a "." to the end to ensure that the unit will not change targets on its own.
Also, a capital letter overrides the AI script, and lower case will allow it to be changed.
Unfortunately I don't see any codes for acting like a sitting duck... You could try something like making it target itself, or making it target NULL (which you get by calling the constructor VS.Unit() ) and then using something like "A."
Or, just try doing a "B." and having it target you, and make sure it is friendly... then it might just fly near you.
I believe you can get it to fly places by having it target them and then force it to do unit.setFgDirective("B.") which I think forces it to act like normal and fly to this target.
I don't know that much about how the AI system works unfortunately.
The "quest_tutorial.py" script seems to set its velocity to A random number between -10 and 10 in all directions after setting its position to the player. That might work as well as the complicated FG directive stuff.
I'm not sure about the returns. What is the effect of return 0 (end script execution for the frame, no errors???) or return 1 (script will be killed???).
Uh well, I'm not sure as well since I'm not exactly familiar with python, just putting things together. I interpreted the lines posted as a condition checker for your savegame. You're using the drone as tutorial help, but the drone can only exist if you reached Delta and got the green gun. Since you didn't as you're starting a new game, the engine makes efforts to get the drone away. At least if we're talking about the Privateer-drone.
I'm assuming by drone he means just an instance of a dummy ship like a Talon.
Quests are run inside of "random_encounters.py"
If it returns 1 or True, it will keep going.
If it returns 0, False or None (python returns None if you don't say what to return) then the quest will stop Execute()ing and be deleted until you jump into that system again or reload.
Having to load a savegame each time I change something in the script is a bit annoying.
That's not necessary; missions set up via the launcher don't use a savegame as they
should store all relevant info... but that also includes the ship you're flying, the equipment, the universe... so it's probably less scripting stuff to create a fixer-based mission, that doesn't require alternation of savegames.
My assumption was that I would be able to include a python statement in a mission xml file and execute it directly to save time, but didn't somehow manage to do it right. Hints on that are appreciated.
The assumption is that a XML actually can import a python file; I don't know if that's possible. That'd be worth a contributor help question, or maybe you find a reference for that in the mission folder. But again, you don't have to fiddle in calls to the savegame. Alternations to it are necessary for many cases like universe or faction setups, but not in case of coming up with new python modules - which you want to have eventually.
Would be really simple to define a mission file that calls the privateer scripts.
Just go into the missions folder and copy the "explore_universe.mission", and you should be able to delete the "savegame" tag and you will always spawn at the coordinates and system file specified in the .mission file.
To run with that, you have to run the binary with "vegastrike mymission.mission"
drone says hello 'before' i launch
Just that I got you correctly - are you launching from a base, or does the game start in open space? If the latter, it's no miracle as the game spawns the drone and probably needs to load other stuff. So the drone is already generated and spitting out its message while it's not yet displaying other things. This effect will either vanish when the tutorial is embedded within a fixer, or you could place the drone to another nav point so that the player needs to approach that one first.
Unfortunately it is not easy to tell if a player is docked to any unit.
Perhaps best would be to add a wait delay of something like 10 seconds before doing anything. I believe Python does not run when a player is docked so that should give it enough time to complete docking procedures.
You can call VS.GetGameTime() to give you a number in seconds, when the quest first starts, then add 10 seconds onto that and keep checking for that to be true.
the dancing of the drone needs to be fixed
That's undiscovered land to me, but at least I can make an assumption.
Code: Select all
def setDroneNear (self,playa):
vec = playa.Position()
vec = Vector.Add (vec,(vsrandom.uniform(-1000,1000),
vsrandom.uniform(-1000,1000),
vsrandom.uniform(-1000,1000)))
self.drone.SetPosition(vec)
You seem to define the vector two times... #1 obviously tries to adapt the player's vector, while #2 gives new numbers. That probably is a paradoxon which makes the whole dancing. I'd try to delete the second vector block and see if it's still dancing. Whereas
Code: Select all
def orbitMe (self,playa):
vec = (vsrandom.uniform(-10,10),
vsrandom.uniform(-10,10),
vsrandom.uniform(-10,10))
self.drone.SetVelocity(vec)
is missing the "(vec," tag in front of "(vsrandom.uniform".
I guess you already copied it from the quest_tutorial since that looks like the same code.
Pyramid did it properly.
The "Vector.Add (vec,(vsrandom,vsrandom,vsrandom))" thing will give you a random position and add it onto the player's position ( you don't want it inside of the sun)
However, velocities are relative to (0,0,0) which is stopped. So it doesn't make sense to add a velocity to anything.
Why don't you just use self.drone.SetVelocity((0,0,0)) which will set its velocity to 0 instead of a small but random number?
Now that you've changed the faction to a friendly type, you probably could retry to change the AI as well... it currently is default, you might want to try to change it to sitting_duck as it applies for friendly behaviour.
Good idea:
Make sure there is a "sitting_duck.agg.xml" inside of the ai/events folder.
Also check for the sitting_duck.int.xml
Would probably be simpler than the SetVelocity or FG directives... though I suppose it might be harder to make it fly on its own... I guess you might be able to set a constant velocity with SetVelocity.