There is another problem with orientation. The Hacker Outpost will appear at random locations off the corridor, but I want it to face the planet. So I use the spawnShip-method and created 4 shipdata-entries of hacker-outpost1..4. They have got the following spawn-entries (copying only the relevant part of the code):
Code: Select all
<key>hacker-outpost1</key>
<dict>
<key>spawn</key>
<dict>
<key>position</key>
<string>wpm 0 0 -150000</string>
<key>facing_position</key>
<string>pwm 0 0 0</string>
</dict>
</dict>
<key>hacker-outpost2</key>
<dict>
<key>like_ship</key>
<string>hacker-outpost1</string>
<key>spawn</key>
<dict>
<key>position</key>
<string>pwm 0 0 -300000</string>
<key>facing_position</key>
<string>pwm 0 0 0</string>
</dict>
</dict>
<key>hacker-outpost3</key>
<dict>
<key>like_ship</key>
<string>hacker-outpost1</string>
<key>spawn</key>
<dict>
<key>position</key>
<string>pwm 0 250000 250000</string>
<key>facing_position</key>
<string>pwm 0 0 0</string>
</dict>
</dict>
<key>hacker-outpost4</key>
<key>spawn</key>
<dict>
<key>position</key>
<string>psm 400000 400000 400000</string>
<key>facing_position</key>
<string>psm 0 0 0</string>
</dict>
</dict>
That should spawn the outpost at one of the four given positions, but always facing the planet. But it doesn't! Also it isn't facing in random directions, but always in the same one: along the wpm z-axis. So hacker-outpost1
is facing the planet. And the facing of all the other variants is parallel to that one. If you launch from any of them with the coordinates displayed you see always the same: the last value in the pwm-system decreases, the others are stable. I have no idea what's wrong.
First I thought, perhaps the facing_position is too close for the engine to compute it usefully. So I put it backward, e.g. for hacker-outpost4 I changed it to <string>psm -1000000 -1000000 -1000000</string>, which is exactly the same direction, but. No difference.
The strange thing is: in Equilibrium.oxp I am spawning a station with the following position and facing:
Code: Select all
<key>spawn</key>
<dict>
<key>position</key>
<string>psm 0 0 1000530</string>
<key>facing_position</key>
<string>psm 0 0 0</string>
</dict>
And this one works. I can't figure out the difference between the two of them!
Anyway, after A_H posted here about setting the destination to planet and performFaceDestination, I thought that might be a way to force my hacker outpost to face the planet. So I inserted the following methods into the GLOBAL_part of its AI:
Code: Select all
GLOBAL = {ENTER = (findNearestPlanet, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Didn't work. Now the outpost faced in random directions. Perhaps the planet has to be made the current destination first:
Code: Select all
GLOBAL = {ENTER = (findNearestPlanet, setDestinationToTarget, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Again random directions, perhaps with a preference to face
away from the planet. Ah, maybe it doesn't work all in the ENTER-part. So insert a TARGET_FOUND:
Code: Select all
GLOBAL = {ENTER = (findNearestPlanet); TARGET_FOUND = (setDestinationToTarget, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Still nothing. A quick insert of a commsMessage reveals that the AI-message TARGET_FOUND is never received! Why that? Hm, there is no range defined yet. Okay, give the hacker outpost a biiig scanner_range in shipdata. Still nothing.
Perhaps findNearestPlanet doesn't return TARGET_FOUND, but PLANET_FOUND. So changed that:
Code: Select all
GLOBAL = {ENTER = (findNearestPlanet); PLANET_FOUND = (setDestinationToTarget, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Nope. No result. I am running out of ideas. Ah, there is another useful AI-method, called setCoordinates:(NSString *)system_x_y_z, which is supposed to set the
destination coords, exactly what I need. So everything taken back, instead it is:
Code: Select all
GLOBAL = {ENTER = ("setCoordinates: pwm 0 0 0", performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
And ... again a certain randomization of the facing directions, but all of them more or less
away from the planet.
Now I'm really stuck. Why the heck is this bl***y hacker outpost so persistantly refusing to face into the one direction I want it to??? What am I doing wrong here? I can't see it.
Help!