Code: Select all
// check planet
Vector p1 = the_planet->position;
double cr = the_planet->collision_radius;
double cr2 = cr * cr;
OOAegisStatus result = AEGIS_NONE;
p1.x -= position.x; p1.y -= position.y; p1.z -= position.z;
double d2 = p1.x*p1.x + p1.y*p1.y + p1.z*p1.z;
// check if nearing surface
BOOL wasNearPlanetSurface = isNearPlanetSurface;
isNearPlanetSurface = (d2 - cr2 < 3600000.0);
if ((!wasNearPlanetSurface)&&(isNearPlanetSurface))
[shipAI reactToMessage:@"APPROACHING_SURFACE"];
if ((wasNearPlanetSurface)&&(!isNearPlanetSurface))
[shipAI reactToMessage:@"LEAVING_SURFACE"];
d2= square(player to planet center)
c2= square(surface to planet center)
But to set an border even at 100 meter one get:
d2 - c2 = (5,000,100)^2 - (5,000,000)^2 = 1,000,010,000 That is much more than the value of Giles. He is actually setting the border at about 1 meter above the surface and that is within the collision radius of most ships.
I think a border at 500 meter above the surface is close enough and would give a value of: 5,000,250,000 (instead the current value of 3,600,000)
I encountered this bug while playing with the "fallingShuttleAI" script. It never triggered this message. But I also send in a better version of the fallingShuttleAI before 1.70 came out. I think it should be placed in 1.71. Today I uploaded "UPS-Courier.OXP 1.3.4" Within this package I also included a "bigfix OXP". Play with it and see it will be better for the shuttles.
-----
In this package I also included an improved version of the standard "escortAI". The current one has two ways by which escorts can get uncontrolled after an second attack at their mother. Both can be corrected with improved AI routines.
1) When a mothership uses the command fightOrFleeHostile it will internally use the command deployEscorts. This last one gives the target of the mother to the escorts and than uses a setAITo: intercept.plist on all escorts. When ready the escorts fall back to their escort.AI. But when the mother is attacked again by a new aggressor and is using the command fightOrFleeHostile again while the escorts are still in an interceptAI, they get an interceptAI on top of the old one. When they return from this AI they fall back in the first interceptAI with no target and will do nothing there. I think both states need a line:
"RESTARTED"=(exitAI);
This will set them back one more level.
2) Back to the hostile escorts. With such an escort near a station a second attack was programmed to happen. So it did. The attacker was killed, but I found two escorts hanging around doing nothing. They were in the "BEGIN_BUSINESS" state of the escortAI. This was caused by a second bug. For some reason escorts that were flying in a "FLYING_ESCORT" state are put in the "BEGIN_BUSINESS" after returning from a successful attack. This "BEGIN_BUSINESS" has no "UPDATE" option and so it will do nothing with escorts returning in this state. This state needs an update command and also should switch states to "FLYING_ESCORT" when it does.
----
And when someone wants to see what can be done with JS in shipscripts should spawn the ships: "ups_parcel_test1", "ups_parcel_test2", "ups_parcel_test3", "ups_parcel_test4". But don't save after this as one will set new mission variables. And don't add them twice as the reference bug in 1.70 makes that the script does not work after the second spawning.