- planets now rotate around their poles, even script added ones
- changing orientation by JS script now correctly changes the rotation axis - relocated the "stationLaunchedShip" handler - escorts looking for a new master won't find masters that are busy targeting the escort. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2923 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
6bfe4ef87e
commit
f502f30e66
@ -11,8 +11,14 @@
|
||||
"INCOMING_MISSILE" = (fightOrFleeMissile, "setStateTo: FLEE");
|
||||
"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: COLLECT_STUFF");
|
||||
"NOTHING_FOUND" = ("setStateTo: DOCK_WITH_STATION");
|
||||
"LAUNCHED OKAY" = ("setStateTo: CLEAR_STATION");
|
||||
UPDATE = (scanForRandomLoot, "pauseAI: 8.0");
|
||||
};
|
||||
"CLEAR_STATION" = {
|
||||
ENTER = (getWitchspaceEntryCoordinates, setDestinationFromCoordinates, "setDesiredRangeTo: 100.0",
|
||||
"setSpeedFactorTo: 0.75", performFlyToRangeFromDestination, "pauseAI: 10");
|
||||
UPDATE = ("setStateTo: LOOK_FOR_STUFF");
|
||||
};
|
||||
"DOCK_WITH_STATION" =
|
||||
{
|
||||
ENTER = (setTargetToNearestStation, "setDesiredRangeTo: 5000.0", performIntercept);
|
||||
|
@ -38,6 +38,7 @@
|
||||
"ROLL_1" = ("setStateTo: ATTACK_SHIP");
|
||||
"ROLL_2" = ("setDesiredRangeTo: 25600", performFlee);
|
||||
"ROLL_3" = ("setDesiredRangeTo: 25600", performFlee);
|
||||
"ESCORT_ATTACKED" = (setTargetToPrimaryAggressor, groupAttackTarget); // only player attacks escorts
|
||||
"TARGET_LOST" = (performIdle, exitAI);
|
||||
"TARGET_DESTROYED" = (performIdle, exitAI);
|
||||
"ENERGY_LOW" = (setTargetToPrimaryAggressor, deployEscorts);
|
||||
|
@ -141,10 +141,12 @@ MA 02110-1301, USA.
|
||||
|
||||
collision_radius = radius_km * 10.0; // Scale down by a factor of 100
|
||||
_rotationAxis = kBasisYVector;
|
||||
#if 0
|
||||
#if 1
|
||||
orientation = (Quaternion){ M_SQRT1_2, M_SQRT1_2, 0, 0 }; // FIXME: do we want to do something more interesting here?
|
||||
// EW: NO, setting orientation should be handled by the code that adds the planet, not by planetEntity itself.
|
||||
// just start with a default value.
|
||||
#else
|
||||
[self setOrientation:kIdentityQuaternion];
|
||||
[self setOrientation:kIdentityQuaternion]; // No need to do this, all planet adding code will override this this a new orientiation
|
||||
#endif
|
||||
[_planetDrawable setRadius:collision_radius];
|
||||
|
||||
@ -334,6 +336,13 @@ static OOColor *ColorWithHSBColor(Vector c)
|
||||
}
|
||||
|
||||
|
||||
- (void) setOrientation:(Quaternion) quat
|
||||
{
|
||||
[super setOrientation: quat];
|
||||
_rotationAxis = vector_up_from_quaternion(quat);
|
||||
}
|
||||
|
||||
|
||||
- (double) radius
|
||||
{
|
||||
return collision_radius;
|
||||
@ -367,7 +376,7 @@ static OOColor *ColorWithHSBColor(Vector c)
|
||||
// FIXME: update atmosphere
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
quaternion_rotate_about_axis(&orientation, _rotationAxis, _rotationalVelocity * delta_t);
|
||||
#else
|
||||
quaternion_rotate_about_y(&orientation, _rotationalVelocity * delta_t);
|
||||
|
@ -1905,7 +1905,7 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
#endif
|
||||
StationEntity *stationLaunchedFrom = [UNIVERSE nearestEntityMatchingPredicate:IsStationPredicate parameter:NULL relativeToEntity:self];
|
||||
[self doScriptEvent:@"shipLaunchedFromStation" withArgument:stationLaunchedFrom];
|
||||
if (stationLaunchedFrom) [stationLaunchedFrom doScriptEvent:@"stationLaunchedShip" withArgument:self]; // script might have removed it.
|
||||
//if (stationLaunchedFrom) [stationLaunchedFrom doScriptEvent:@"stationLaunchedShip" withArgument:self]; // script might have removed it.
|
||||
}
|
||||
}
|
||||
|
||||
@ -3776,6 +3776,8 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
hyperspeed_engaged = NO;
|
||||
hyperspeed_locked = NO;
|
||||
[self safeAllMissiles];
|
||||
primaryTarget = NO_TARGET; // must happen before showing break_pattern to supress active reticule.
|
||||
[self clearTargetMemory];
|
||||
|
||||
[hud setScannerZoom:1.0];
|
||||
scanner_zoom_rate = 0.0f;
|
||||
@ -3819,10 +3821,10 @@ static PlayerEntity *sSharedPlayer = nil;
|
||||
|
||||
hyperspeed_engaged = NO;
|
||||
hyperspeed_locked = NO;
|
||||
[self safeAllMissiles];
|
||||
// [self safeAllMissiles];
|
||||
|
||||
primaryTarget = NO_TARGET;
|
||||
[self clearTargetMemory];
|
||||
// primaryTarget = NO_TARGET;
|
||||
// [self clearTargetMemory];
|
||||
|
||||
forward_shield = [self maxForwardShieldLevel];
|
||||
aft_shield = [self maxAftShieldLevel];
|
||||
|
@ -1490,7 +1490,7 @@ static WormholeEntity *whole = nil;
|
||||
for (i = 0; i < n_scanned_ships; i++)
|
||||
{
|
||||
ShipEntity *ship = scanned_ships[i];
|
||||
if ((ship != self) && (!ship->isPlayer) && (ship->scanClass == scanClass)) // look for alike
|
||||
if ((ship != self) && (!ship->isPlayer) && (ship->scanClass == scanClass) && [ship primaryTarget] != self) // look for alike
|
||||
{
|
||||
GLfloat d2 = distance2_scanned_ships[i];
|
||||
if ((d2 < found_d2) && [ship canAcceptEscort:self])
|
||||
|
@ -1127,19 +1127,8 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
|
||||
{
|
||||
ShipEntity *se=(ShipEntity *)[launchQueue objectAtIndex:0];
|
||||
[self launchShip:se];
|
||||
#if 0
|
||||
// This code is most likely causing many ships to leave the station with the wrong AI
|
||||
// (route1PatrolAi.plist). Disabling it for now - Nikos
|
||||
if([se groupID] == universalID) //defender - might have lost its state machine while queueing...
|
||||
{
|
||||
if ([se hasPrimaryRole:@"pirate"])
|
||||
[se setAITo:@"pirateAI.plist"];
|
||||
else
|
||||
[se setAITo:@"route1PatrolAI.plist"];
|
||||
}
|
||||
#endif
|
||||
[launchQueue removeObjectAtIndex:0];
|
||||
[self doScriptEvent:@"stationLaunchedShip" withArgument:se];
|
||||
// [self doScriptEvent:@"stationLaunchedShip" withArgument:se];
|
||||
}
|
||||
if (([launchQueue count] == 0)&&(no_docking_while_launching))
|
||||
no_docking_while_launching = NO; // launching complete
|
||||
@ -1260,6 +1249,8 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
|
||||
[[ship getAI] setNextThinkTime:last_launch_time + 2]; // pause while launching
|
||||
|
||||
[ship resetExhaustPlumes]; // resets stuff for tracking/exhausts
|
||||
|
||||
[self doScriptEvent:@"stationLaunchedShip" withArgument:ship];
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@ MA 02110-1301, USA.
|
||||
#import "OOJSPlanet.h"
|
||||
#import "OOJSEntity.h"
|
||||
#import "OOJavaScriptEngine.h"
|
||||
#import "OOJSQuaternion.h"
|
||||
|
||||
#import "OOPlanetEntity.h"
|
||||
|
||||
@ -72,6 +73,7 @@ enum
|
||||
kPlanet_hasAtmosphere,
|
||||
kPlanet_radius, // Radius of planet in metres, read-only
|
||||
kPlanet_texture, // Planet texture read / write
|
||||
kPlanet_orientation, // orientation, quaternion, read/write
|
||||
};
|
||||
|
||||
|
||||
@ -82,6 +84,7 @@ static JSPropertySpec sPlanetProperties[] =
|
||||
{ "hasAtmosphere", kPlanet_hasAtmosphere, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||
{ "radius", kPlanet_radius, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||
{ "texture", kPlanet_texture, JSPROP_PERMANENT | JSPROP_ENUMERATE },
|
||||
{ "orientation", kPlanet_orientation, JSPROP_PERMANENT | JSPROP_ENUMERATE },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -161,6 +164,10 @@ static JSBool PlanetGetProperty(JSContext *context, JSObject *this, jsval name,
|
||||
OK = YES;
|
||||
break;
|
||||
|
||||
case kPlanet_orientation:
|
||||
OK = QuaternionToJSValue(context, [planet normalOrientation], outValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
OOReportJSBadPropertySelector(context, @"Planet", JSVAL_TO_INT(name));
|
||||
}
|
||||
@ -174,6 +181,7 @@ static JSBool PlanetSetProperty(JSContext *context, JSObject *this, jsval name,
|
||||
OOPlanetEntity *planet = nil;
|
||||
NSString *sValue = nil;
|
||||
BOOL procGen = NO;
|
||||
Quaternion qValue;
|
||||
|
||||
NSString *pre = @"";
|
||||
OOEntityStatus playerStatus;
|
||||
@ -215,6 +223,15 @@ static JSBool PlanetSetProperty(JSContext *context, JSObject *this, jsval name,
|
||||
}
|
||||
break;
|
||||
|
||||
case kPlanet_orientation:
|
||||
if (JSValueToQuaternion(context, *value, &qValue))
|
||||
{
|
||||
quaternion_normalize(&qValue);
|
||||
[planet setOrientation:qValue];
|
||||
OK = YES;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
OOReportJSBadPropertySelector(context, @"Planet", JSVAL_TO_INT(name));
|
||||
OK = NO;
|
||||
|
Loading…
x
Reference in New Issue
Block a user