I am working on an OXP inspired by Generation Ships (and Drew's story gave me the kick to finally start on it. The idea is older and has been roughly summarized here.
The actual OXP involves a Generation Ship spawned at a point fairly far away from the system center and heading towards the planet. So I gave it an AI that looked like this:
Code: Select all
{
GLOBAL = {ENTER = ("setStateTo: HEAD_FOR_PLANET"); EXIT = (); UPDATE = (); };
"HEAD_FOR_PLANET" = {
ENTER = (setCourseToPlanet, "setDesiredRangeTo: 25600.0", "setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
"TARGET_FOUND" = (setTargetToFoundTarget, "scriptActionOnTarget: set: mission_ghosts GENSHIP_FOUND", "pauseAI: 120.0", "setStateTo: HEAD_FOR_PLANET");
"NOTHING_FOUND" = ("pauseAI: 10.0", "setStateTo: HEAD_FOR_PLANET");
UPDATE = ("setDesiredRangeTo: 25600.0", "scanForNearestShipWithRole: player");
EXIT = ();
};
}
Then I had the idea to introduce two other planets that would help the player to find the Generation Ship in the first place (like LittleBear did to help locate the victims in Assassins). Said and done, I figured out the positions of the planets and put the Generation Ship in-between. Problem: Now the ship is heading towards one of those two new planets. A quick look in the wiki reveals:
Okay, my two new planets happen to be closer to the ship's position, so it's logical what happened.OXP howto AI wrote:setCourseToPlanet
Selects the nearest planet it can find, reaching desired range 50 km from the planet.
But there must be other ways to make the ship head for the original planet. So a change to the AI:
Code: Select all
{
GLOBAL = {ENTER = ("setStateTo: HEAD_FOR_PLANET"); EXIT = (); UPDATE = (); };
"HEAD_FOR_PLANET" = {
ENTER = ("setCoordinates: pwm 0 0 0", setDestinationFromCoordinates, "setDesiredRangeTo: 50.0", "setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
"TARGET_FOUND" = (setTargetToFoundTarget, "scriptActionOnTarget: set: mission_ghosts GENSHIP_FOUND", "pauseAI: 120.0", "setStateTo: HEAD_FOR_PLANET");
"NOTHING_FOUND" = ("pauseAI: 10.0", "setStateTo: HEAD_FOR_PLANET");
UPDATE = ("setDesiredRangeTo: 25600.0", "scanForNearestShipWithRole: player");
EXIT = ();
};
}
OK, thinks me, perhaps the coordinates are just to far away for calculating correctly? After all Selezen has used the same methods in his tgy.oxp for the patrol AI of his graveyard police, but of course in a relatively narrow area. And my Generation Ship comes into being at coordinates pwm 1864100 -4638900 -60200, that's five million meters away from the planet. So I modify the AI, setting the destination coords to one tenth of the total distance. So it's:
Code: Select all
{
GLOBAL = {ENTER = ("setStateTo: HEAD_FOR_PLANET"); EXIT = (); UPDATE = (); };
"HEAD_FOR_PLANET" = {
ENTER = ("setCoordinates: pwm 1677690 -4175010 -54180", setDestinationFromCoordinates, "setDesiredRangeTo: 50.0", "setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
"TARGET_FOUND" = (setTargetToFoundTarget, "scriptActionOnTarget: set: mission_ghosts GENSHIP_FOUND", "pauseAI: 120.0", "setStateTo: HEAD_FOR_PLANET");
"NOTHING_FOUND" = ("pauseAI: 10.0", "setStateTo: HEAD_FOR_PLANET");
UPDATE = ("setDesiredRangeTo: 25600.0", "scanForNearestShipWithRole: player");
EXIT = ();
};
}
Code: Select all
{
GLOBAL = {ENTER = ("setStateTo: START_JOURNEY"); EXIT = (); UPDATE = (); };
"CONTINUE_JOURNEY" = {
ENTER = ();
UPDATE = ("setCoordinates: pwm 1677690 -4175010 -54180", setDestinationFromCoordinates, "setDesiredRangeTo: 50.0", "setSpeedFactorTo: 1.0", performFlyToRangeFromDestination, "pauseAI: 15.0");
EXIT = ();
};
"START_JOURNEY" = {
ENTER = ("setCoordinates: pwm 1677690 -4175010 -54180", setDestinationFromCoordinates, "setDesiredRangeTo: 50.0", performFaceDestination);
"FACING_DESTINATION" = ("setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
"TARGET_FOUND" = (setTargetToFoundTarget, "scriptActionOnTarget: set: mission_ghosts GENSHIP_FOUND", "pauseAI: 10.0", "setStateTo: CONTINUE_JOURNEY");
"NOTHING_FOUND" = ("pauseAI: 15.0", "setStateTo: START_JOURNEY");
UPDATE = ("setDesiredRangeTo: 25600.0", "scanForNearestShipWithRole: player");
EXIT = ();
};
}
Then I try to have a look at which destination coordinates are actually set. Fortunately there is the key_dump_target_state. So here is all information about my Generation Ship:
Code: Select all
[dumpState]: State for <ShipEntity Generation Ship 193>:
[dumpState.entity]: Universal ID: 193
[dumpState.entity]: Scan class: CLASS_NEUTRAL
[dumpState.entity]: Status: STATUS_IN_FLIGHT
[dumpState.entity]: Position: (4.99978e+06, -441.292, 520072)
[dumpState.entity]: Orientation: (1 + 0i + 0j + 0k)
[dumpState.entity]: Distance travelled: 21103.9
[dumpState.entity]: Energy: 500000 of 500000
[dumpState.entity]: Mass: 9.4667e+11
[dumpState.entity]: Flags: isShip, hasMoved, isSunlit
[dumpState.shipEntity]: Name: Generation Ship
[dumpState.shipEntity]: Roles: ghost_from_past_1
[dumpState.shipEntity]: Subentity count: 11
[dumpState.shipEntity]: Time since shot: 100352
[dumpState.shipEntity]: Behaviour: BEHAVIOUR_FLY_TO_DESTINATION
[dumpState.shipEntity]: Destination: (4.49981e+06, -1180.1, 498050)
[dumpState.shipEntity]: Other destination: (4.49981e+06, -1180.1, 498050)
[dumpState.shipEntity]: Waypoint count: 0
[dumpState.shipEntity]: Desired speed: 60
[dumpState.shipEntity]: Fuel: 0
[dumpState.shipEntity]: Fuel accumulator: 1
[dumpState.shipEntity]: Missile count: 0
[dumpState.shipEntity.ai]: AI:
[dumpState.ai]: State machine name: ghostGenship1AI.plist
[dumpState.ai]: Current state: START_JOURNEY
[dumpState.ai]: Next think time: 370.386
[dumpState.ai]: Next think interval: 370.386
[dumpState.shipEntity]: Frustration: 0
[dumpState.shipEntity]: Success factor: 500457
[dumpState.shipEntity]: Shots fired: 0
[dumpState.shipEntity]: Hull temperature: 60
[dumpState.shipEntity]: Heat insulation: 1
[dumpState.shipEntity]: Flags: has_ecm, escortsAreSetUp, proximity_alert
Something even more interesting: I'll give it another try. This time when I arrive the ship starts turning:
Code: Select all
[dumpState]: State for <ShipEntity Generation Ship 196>:
[dumpState.entity]: Universal ID: 196
[dumpState.entity]: Scan class: CLASS_NEUTRAL
[dumpState.entity]: Status: STATUS_IN_FLIGHT
[dumpState.entity]: Position: (4.99934e+06, -2025.3, 519948)
[dumpState.entity]: Orientation: (0.690084 + 0.330817i + 0.278344j - 0.580404k)
[dumpState.entity]: Distance travelled: 21211.6
[dumpState.entity]: Energy: 500000 of 500000
[dumpState.entity]: Mass: 9.4667e+11
[dumpState.entity]: Flags: isShip, hasMoved, isSunlit
[dumpState.shipEntity]: Name: Generation Ship
[dumpState.shipEntity]: Roles: ghost_from_past_1
[dumpState.shipEntity]: Subentity count: 11
[dumpState.shipEntity]: Time since shot: 100354
[dumpState.shipEntity]: Behaviour: BEHAVIOUR_FLY_TO_DESTINATION
[dumpState.shipEntity]: Destination: (4.96949e+06, 3020.35, 544087)
[dumpState.shipEntity]: Other destination: (4.49981e+06, -1180.1, 498050)
[dumpState.shipEntity]: Waypoint count: 0
[dumpState.shipEntity]: Desired speed: 60
[dumpState.shipEntity]: Fuel: 0
[dumpState.shipEntity]: Fuel accumulator: 1
[dumpState.shipEntity]: Missile count: 0
[dumpState.shipEntity.ai]: AI:
[dumpState.ai]: State machine name: ghostGenship1AI.plist
[dumpState.ai]: Current state: CONTINUE_JOURNEY
[dumpState.ai]: Next think time: 365.46
[dumpState.ai]: Next think interval: 365.46
[dumpState.shipEntity]: Frustration: 0
[dumpState.shipEntity]: Success factor: 38718.2
[dumpState.shipEntity]: Shots fired: 0
[dumpState.shipEntity]: Hull temperature: 60
[dumpState.shipEntity]: Heat insulation: 1
[dumpState.shipEntity]: Flags: has_ecm, escortsAreSetUp, proximity_alert
Code: Select all
[dumpState]: State for <ShipEntity Generation Ship 196>:
[dumpState.entity]: Universal ID: 196
[dumpState.entity]: Scan class: CLASS_NEUTRAL
[dumpState.entity]: Status: STATUS_IN_FLIGHT
[dumpState.entity]: Position: (4.99849e+06, -1968.19, 520169)
[dumpState.entity]: Orientation: (0.441492 + 0.558536i + 0.456877j - 0.533279k)
[dumpState.entity]: Distance travelled: 22215.4
[dumpState.entity]: Energy: 500000 of 500000
[dumpState.entity]: Mass: 9.4667e+11
[dumpState.entity]: Flags: isShip, hasMoved, isSunlit
[dumpState.shipEntity]: Name: Generation Ship
[dumpState.shipEntity]: Roles: ghost_from_past_1
[dumpState.shipEntity]: Subentity count: 11
[dumpState.shipEntity]: Time since shot: 100371
[dumpState.shipEntity]: Behaviour: BEHAVIOUR_AVOID_COLLISION
[dumpState.shipEntity]: Destination: (4.99366e+06, -1917.89, 520183)
[dumpState.shipEntity]: Other destination: (4.49981e+06, -1180.1, 498050)
[dumpState.shipEntity]: Waypoint count: 0
[dumpState.shipEntity]: Desired speed: 60
[dumpState.shipEntity]: Fuel: 0
[dumpState.shipEntity]: Fuel accumulator: 1
[dumpState.shipEntity]: Missile count: 0
[dumpState.shipEntity.ai]: AI:
[dumpState.ai]: State machine name: ghostGenship1AI.plist
[dumpState.ai]: Current state: CONTINUE_JOURNEY
[dumpState.ai]: Next think time: 395.47
[dumpState.ai]: Next think interval: 395.47
[dumpState.shipEntity]: Frustration: 0
[dumpState.shipEntity]: Success factor: 499177
[dumpState.shipEntity]: Shots fired: 0
[dumpState.shipEntity]: Hull temperature: 60
[dumpState.shipEntity]: Heat insulation: 1
[dumpState.shipEntity]: Flags: has_ecm, escortsAreSetUp, proximity_alert
Code: Select all
[dumpState]: State for <ShipEntity Generation Ship 196>:
[dumpState.entity]: Universal ID: 196
[dumpState.entity]: Scan class: CLASS_NEUTRAL
[dumpState.entity]: Status: STATUS_IN_FLIGHT
[dumpState.entity]: Position: (4.98051e+06, -1841.83, 519061)
[dumpState.entity]: Orientation: (0.441492 + 0.558536i + 0.456877j - 0.533279k)
[dumpState.entity]: Distance travelled: 43635.4
[dumpState.entity]: Energy: 500000 of 500000
[dumpState.entity]: Mass: 9.4667e+11
[dumpState.entity]: Flags: isShip, hasMoved, isSunlit
[dumpState.shipEntity]: Name: Generation Ship
[dumpState.shipEntity]: Roles: ghost_from_past_1
[dumpState.shipEntity]: Subentity count: 11
[dumpState.shipEntity]: Time since shot: 100728
[dumpState.shipEntity]: Behaviour: BEHAVIOUR_FLY_TO_DESTINATION
[dumpState.shipEntity]: Destination: (4.49981e+06, -1180.1, 498050)
[dumpState.shipEntity]: Other destination: (4.49981e+06, -1180.1, 498050)
[dumpState.shipEntity]: Waypoint count: 0
[dumpState.shipEntity]: Desired speed: 60
[dumpState.shipEntity]: Fuel: 0
[dumpState.shipEntity]: Fuel accumulator: 1
[dumpState.shipEntity]: Missile count: 0
[dumpState.shipEntity.ai]: AI:
[dumpState.ai]: State machine name: ghostGenship1AI.plist
[dumpState.ai]: Current state: CONTINUE_JOURNEY
[dumpState.ai]: Next think time: 740.62
[dumpState.ai]: Next think interval: 740.62
[dumpState.shipEntity]: Frustration: 0
[dumpState.shipEntity]: Success factor: 481162
[dumpState.shipEntity]: Shots fired: 0
[dumpState.shipEntity]: Hull temperature: 60
[dumpState.shipEntity]: Heat insulation: 1
[dumpState.shipEntity]: Flags: has_ecm, escortsAreSetUp, proximity_alert
I should mention that I have a similar problem with the Hacker Outposts in Anarchies.oxp. They are spawned with spawnShip: at one of a couple of predefined pseudo-random positions in a system. I've done it that way because I want them to face the planet wherever they are. So I am using a spawn-dict in shipdata to define their facing_position as pwm 0 0 0. But they don't face the planet. Instead they are facing roughly along the witchpoint-planet-axis. Now I guess that this as well may be exactly Orientation: (1 + 0i + 0j + 0k) in absolute coordinates.
And this again indicates to me that something doesn't work properly with the set-up and especially the orientation of entities created by an OXP.
If the coders need more information, please tell me so. Ahruman already has a testcase of my new OXP with the Generation Ship, so he should be easily able to reproduce it. (Just that after sending it to you I continued fiddling with the AI, so the one in the testcase isn't the latest I posted here.)