- the player can now have misjumps when using someone else's wormhole - required some refactoring!
- when misjumping there's now a small chance of a decrease in reputation (should have kept the ship spaceworthy, etc...) - added ship.hasHyperspaceMotor as a read-only js property. - more cleanup. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3741 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
9b25043399
commit
9dedfda5b0
@ -132,6 +132,7 @@ static GLfloat sBaseMass = 0.0;
|
|||||||
- (NSArray*) contractsListForScriptingFromArray:(NSArray *) contracts_array forCargo:(BOOL)forCargo;
|
- (NSArray*) contractsListForScriptingFromArray:(NSArray *) contracts_array forCargo:(BOOL)forCargo;
|
||||||
|
|
||||||
- (void) witchStart;
|
- (void) witchStart;
|
||||||
|
- (void) witchJumpTo:(Random_Seed)sTo standard:(BOOL)standard;
|
||||||
- (void) witchEnd;
|
- (void) witchEnd;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -4654,25 +4655,10 @@ static GLfloat sBaseMass = 0.0;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//it is impossible to have a misjump here
|
// now with added misjump goodness!
|
||||||
- (void) enterWormhole:(WormholeEntity *) w_hole replacing:(BOOL)replacing
|
- (void) enterWormhole:(WormholeEntity *) w_hole
|
||||||
{
|
{
|
||||||
// don't do anything with the player's target
|
[self witchJumpTo:[w_hole destination] standard:NO];
|
||||||
system_seed = [w_hole destination];
|
|
||||||
[self setStatus:STATUS_ENTERING_WITCHSPACE];
|
|
||||||
[self doScriptEvent:@"shipWillEnterWitchspace" withArgument:@"wormhole"];
|
|
||||||
|
|
||||||
[self witchStart];
|
|
||||||
|
|
||||||
// set clock after "playerWillEnterWitchspace" and before removeAllEntitiesExceptPlayer, to allow escorts time to follow their mother.
|
|
||||||
double distance = distanceBetweenPlanetPositions(system_seed.d,system_seed.b,galaxy_coordinates.x,galaxy_coordinates.y);
|
|
||||||
ship_clock_adjust = distance * distance * 3600.0; // LY * LY hrs
|
|
||||||
|
|
||||||
[UNIVERSE removeAllEntitiesExceptPlayer:NO];
|
|
||||||
|
|
||||||
legalStatus /= 2; // 'another day, another system'
|
|
||||||
|
|
||||||
[self witchEnd];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4683,13 +4669,17 @@ static GLfloat sBaseMass = 0.0;
|
|||||||
[self setStatus:STATUS_IN_FLIGHT];
|
[self setStatus:STATUS_IN_FLIGHT];
|
||||||
return; // naughty, you cant hyperspace to your own system.
|
return; // naughty, you cant hyperspace to your own system.
|
||||||
}
|
}
|
||||||
|
[self witchJumpTo:target_system_seed standard:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) witchJumpTo:(Random_Seed)sTo standard:(BOOL)standard
|
||||||
|
{
|
||||||
|
// don't do anything with the player's target
|
||||||
[self setStatus:STATUS_ENTERING_WITCHSPACE];
|
[self setStatus:STATUS_ENTERING_WITCHSPACE];
|
||||||
[self doScriptEvent:@"shipWillEnterWitchspace" withArgument:@"standard jump"];
|
[self doScriptEvent:@"shipWillEnterWitchspace" withArgument:(standard ? @"standard jump" : @"wormhole")];
|
||||||
|
|
||||||
[self witchStart];
|
[self witchStart];
|
||||||
|
|
||||||
[UNIVERSE removeAllEntitiesExceptPlayer:NO];
|
|
||||||
|
|
||||||
// perform any check here for forced witchspace encounters
|
// perform any check here for forced witchspace encounters
|
||||||
unsigned malfunc_chance = 253;
|
unsigned malfunc_chance = 253;
|
||||||
if (ship_trade_in_factor < 80)
|
if (ship_trade_in_factor < 80)
|
||||||
@ -4699,14 +4689,16 @@ static GLfloat sBaseMass = 0.0;
|
|||||||
// 75% of the time a malfunction means a misjump
|
// 75% of the time a malfunction means a misjump
|
||||||
BOOL misjump = [self scriptedMisjump] || ((flightPitch == max_flight_pitch) || (malfunc && (randf() > 0.75)));
|
BOOL misjump = [self scriptedMisjump] || ((flightPitch == max_flight_pitch) || (malfunc && (randf() > 0.75)));
|
||||||
|
|
||||||
//wear and tear on all jumps (inc misjumps and failures)
|
//wear and tear on all jumps (inc misjumps, failures, and wormholes)
|
||||||
if (2 * market_rnd < ship_trade_in_factor)
|
if (2 * market_rnd < ship_trade_in_factor)
|
||||||
{
|
{
|
||||||
// every eight jumps or so drop the price down towards 75%
|
// every eight jumps or so drop the price down towards 75%
|
||||||
[self reduceTradeInFactorBy:1 + (market_rnd & 3)];
|
[self reduceTradeInFactorBy:1 + (market_rnd & 3)];
|
||||||
}
|
}
|
||||||
if (malfunc)
|
|
||||||
|
if (standard && malfunc)
|
||||||
{
|
{
|
||||||
|
// some malfunctions will start fuel leaks, some will result in no witchjump at all.
|
||||||
if (randf() > 0.5)
|
if (randf() > 0.5)
|
||||||
{
|
{
|
||||||
[self setFuelLeak:[NSString stringWithFormat:@"%f", (randf() + randf()) * 5.0]];
|
[self setFuelLeak:[NSString stringWithFormat:@"%f", (randf() + randf()) * 5.0]];
|
||||||
@ -4719,37 +4711,38 @@ static GLfloat sBaseMass = 0.0;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double distance = distanceBetweenPlanetPositions(target_system_seed.d,target_system_seed.b,galaxy_coordinates.x,galaxy_coordinates.y);
|
|
||||||
//burn full fuel to create wormhole, but only take time for distance traveled
|
|
||||||
fuel -= 10.0 * distance; // fuel cost to target system
|
|
||||||
|
|
||||||
|
// set clock after "playerWillEnterWitchspace" and before removeAllEntitiesExceptPlayer, to allow escorts time to follow their mother.
|
||||||
|
double distance = distanceBetweenPlanetPositions(sTo.d,sTo.b,galaxy_coordinates.x,galaxy_coordinates.y);
|
||||||
|
ship_clock_adjust = distance * distance * (misjump ? 2700.0 : 3600.0); // LY * LY hrs - misjumps take 3/4 time of the full jump, they're not the same as a jump of half the length!
|
||||||
|
|
||||||
|
[UNIVERSE removeAllEntitiesExceptPlayer:NO];
|
||||||
|
|
||||||
|
if (standard)
|
||||||
|
{
|
||||||
|
// burn the full fuel amount to create the wormhole
|
||||||
|
fuel -= 10.0 * distance; // fuel cost to target system
|
||||||
|
}
|
||||||
if (!misjump)
|
if (!misjump)
|
||||||
{
|
{
|
||||||
system_seed = target_system_seed;
|
system_seed = sTo;
|
||||||
|
|
||||||
legalStatus /= 2; // 'another day, another system'
|
legalStatus /= 2; // 'another day, another system'
|
||||||
|
|
||||||
[self witchEnd];
|
[self witchEnd];
|
||||||
|
if (market_rnd < 8) [self erodeReputation]; // every 32 systems or so, drop back towards 'unknown'
|
||||||
if (market_rnd < 8)
|
|
||||||
[self erodeReputation]; // every 32 systems or so, drop back towards 'unknown'
|
|
||||||
ship_clock_adjust = distance * distance * 3600.0; // LY * LY hrs.
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//misjumps do not erode your reputation (perhaps for passenger contracts they should...)
|
// Misjump: move halfway there!
|
||||||
//nor do they change legal status
|
// misjumps do not change legal status.
|
||||||
|
if (randf() < 0.1) [self erodeReputation]; // once every 10 misjumps - should be much rarer than successful jumps!
|
||||||
|
|
||||||
// move sort of halfway there...
|
galaxy_coordinates.x += sTo.d;
|
||||||
galaxy_coordinates.x += target_system_seed.d;
|
galaxy_coordinates.y += sTo.b;
|
||||||
galaxy_coordinates.y += target_system_seed.b;
|
|
||||||
galaxy_coordinates.x /= 2;
|
galaxy_coordinates.x /= 2;
|
||||||
galaxy_coordinates.y /= 2;
|
galaxy_coordinates.y /= 2;
|
||||||
ship_clock_adjust = (distance * distance * 3600.0) * 3/4; // misjumps take 3/4 time of the full jump, this is not the same as a jump of half the length
|
|
||||||
[self playWitchjumpMisjump];
|
[self playWitchjumpMisjump];
|
||||||
[UNIVERSE set_up_universe_from_misjump];
|
[UNIVERSE set_up_universe_from_misjump];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2430,7 +2430,7 @@ static WormholeEntity *whole = nil;
|
|||||||
// tell the ship we're about to jump (so it can inform escorts etc).
|
// tell the ship we're about to jump (so it can inform escorts etc).
|
||||||
primaryTarget = [whole universalID];
|
primaryTarget = [whole universalID];
|
||||||
found_target = primaryTarget;
|
found_target = primaryTarget;
|
||||||
[shipAI reactToMessage:@"WITCHSPACE OKAY" context:@"performHyperSpaceExit[WithoutReplacing]"]; // must be a reaction, the ship is about to disappear
|
[shipAI reactToMessage:@"WITCHSPACE OKAY" context:@"performHyperSpaceExit"]; // must be a reaction, the ship is about to disappear
|
||||||
|
|
||||||
[self enterWormhole:whole replacing:replace]; // TODO
|
[self enterWormhole:whole replacing:replace]; // TODO
|
||||||
|
|
||||||
|
@ -137,6 +137,7 @@ enum
|
|||||||
kShip_fuelChargeRate, // fuel scoop rate & charge multiplier, float, read-only
|
kShip_fuelChargeRate, // fuel scoop rate & charge multiplier, float, read-only
|
||||||
kShip_group, // group, ShipGroup, read/write
|
kShip_group, // group, ShipGroup, read/write
|
||||||
kShip_hasHostileTarget, // has hostile target, boolean, read-only
|
kShip_hasHostileTarget, // has hostile target, boolean, read-only
|
||||||
|
kShip_hasHyperspaceMotor, // has hyperspace motor, boolean, read-only
|
||||||
kShip_hasSuspendedAI, // AI has suspended states, boolean, read-only
|
kShip_hasSuspendedAI, // AI has suspended states, boolean, read-only
|
||||||
kShip_heatInsulation, // hull heat insulation, double, read/write
|
kShip_heatInsulation, // hull heat insulation, double, read/write
|
||||||
kShip_isBeacon, // is beacon, boolean, read-only
|
kShip_isBeacon, // is beacon, boolean, read-only
|
||||||
@ -216,6 +217,7 @@ static JSPropertySpec sShipProperties[] =
|
|||||||
{ "fuelChargeRate", kShip_fuelChargeRate, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
{ "fuelChargeRate", kShip_fuelChargeRate, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||||
{ "group", kShip_group, JSPROP_PERMANENT | JSPROP_ENUMERATE },
|
{ "group", kShip_group, JSPROP_PERMANENT | JSPROP_ENUMERATE },
|
||||||
{ "hasHostileTarget", kShip_hasHostileTarget, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
{ "hasHostileTarget", kShip_hasHostileTarget, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||||
|
{ "hasHyperspaceMotor", kShip_hasHyperspaceMotor, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||||
{ "hasSuspendedAI", kShip_hasSuspendedAI, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
{ "hasSuspendedAI", kShip_hasSuspendedAI, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||||
{ "heatInsulation", kShip_heatInsulation, JSPROP_PERMANENT | JSPROP_ENUMERATE },
|
{ "heatInsulation", kShip_heatInsulation, JSPROP_PERMANENT | JSPROP_ENUMERATE },
|
||||||
{ "isBeacon", kShip_isBeacon, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
{ "isBeacon", kShip_isBeacon, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||||
@ -475,6 +477,11 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsval name, js
|
|||||||
OK = YES;
|
OK = YES;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kShip_hasHyperspaceMotor:
|
||||||
|
*outValue = BOOLToJSVal([entity hasHyperspaceMotor]);
|
||||||
|
OK = YES;
|
||||||
|
break;
|
||||||
|
|
||||||
case kShip_weaponRange:
|
case kShip_weaponRange:
|
||||||
OK = JS_NewDoubleValue(context, [entity weaponRange], outValue);
|
OK = JS_NewDoubleValue(context, [entity weaponRange], outValue);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user