Improve handling of player being carried through witchspace on board another ship.

Doesn't yet get misjumps by the carrier correct, but normal jumps should work properly.


git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5021 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Chris Morris 2012-06-18 21:54:58 +00:00
parent fbecc5e3ec
commit 61c35b4e59
7 changed files with 65 additions and 8 deletions

View File

@ -842,6 +842,8 @@ typedef enum
- (NSArray *) scannedWormholes;
- (WormholeEntity *) wormhole;
- (void) setWormhole:(WormholeEntity *)newWormhole;
- (void) addScannedWormhole:(WormholeEntity*)wormhole;
@end

View File

@ -125,7 +125,6 @@ static GLfloat sBaseMass = 0.0;
- (void) updateTargeting;
- (BOOL) isValidTarget:(Entity*)target;
- (void) showGameOver;
- (void) addScannedWormhole:(WormholeEntity*)wormhole;
- (void) updateWormholes;
// Shopping
@ -502,9 +501,24 @@ static GLfloat sBaseMass = 0.0;
- (WormholeEntity *) wormhole
{
return wormhole;
return wormhole;
}
- (void) setWormhole:(WormholeEntity*)newWormhole
{
[wormhole release];
if (newWormhole != nil)
{
wormhole = [newWormhole retain];
}
else
{
wormhole = nil;
}
}
- (NSDictionary *) commanderDataDictionary
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];

View File

@ -11762,8 +11762,11 @@ static BOOL AuthorityPredicate(Entity *entity, void *parameter)
ShipEntity* ship = my_entities[i];
Vector delta = vector_between(position, ship->position);
GLfloat d2 = magnitude2(delta);
if ((k * [ship mass] > d2)&&(d2 < SCANNER_MAX_RANGE2)) // if you go off scanner from a blocker - it ceases to block
result = [ship universalID];
if (![ship isPlayer] || ![PLAYER isDocked])
{ // player doesn't block if docked
if ((k * [ship mass] > d2)&&(d2 < SCANNER_MAX_RANGE2)) // if you go off scanner from a blocker - it ceases to block
result = [ship universalID];
}
}
for (i = 0; i < ship_count; i++)
[my_entities[i] release]; // released

View File

@ -2440,7 +2440,7 @@
else if ([targEnt isPlayer])
whole = [PLAYER wormhole];
}
if (!whole)
{
// locate nearest wormhole

View File

@ -251,10 +251,18 @@ static void DrawWormholeCorona(GLfloat inner_radius, GLfloat outer_radius, int s
[ship setStatus:STATUS_ENTERING_WITCHSPACE];
[ship doScriptEvent:OOJSID("shipWillEnterWormhole")];
[[ship getAI] message:@"ENTERED_WITCHSPACE"];
[UNIVERSE removeEntity:ship];
[[ship getAI] clearStack]; // get rid of any preserved states
if ([ship isStation])
{
if ([PLAYER dockedStation] && [PLAYER dockedStation] == (StationEntity*)ship)
{ // the carrier has jumped while the player is docked
[UNIVERSE carryPlayerOn:(StationEntity*)ship inWormhole:self];
}
}
return YES;
}

View File

@ -42,7 +42,7 @@ MA 02110-1301, USA.
@class GameController, CollisionRegion, MyOpenGLView, GuiDisplayGen,
Entity, ShipEntity, StationEntity, OOPlanetEntity, OOSunEntity,
PlayerEntity, OORoleSet;
PlayerEntity, OORoleSet, WormholeEntity;
typedef BOOL (*EntityFilterPredicate)(Entity *entity, void *parameter);
@ -339,6 +339,7 @@ typedef uint8_t OOEconomyID; // 0..7
- (void) pauseGame;
- (BOOL) isGamePaused;
- (void) carryPlayerOn:(StationEntity*)carrier inWormhole:(WormholeEntity*)wormhole;
- (void) setUpUniverseFromStation;
- (void) setUpUniverseFromWitchspace;
- (void) setUpUniverseFromMisjump;

View File

@ -537,6 +537,35 @@ GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEVEL, DOC
}
- (void) carryPlayerOn:(StationEntity*)carrier inWormhole:(WormholeEntity*)wormhole
{
PlayerEntity *player = PLAYER;
Random_Seed dest = [wormhole destination];
[player setWormhole:wormhole];
[player addScannedWormhole:wormhole];
ShipScriptEventNoCx(player, "shipWillEnterWitchspace", OOJSSTR("carried"));
[self allShipsDoScriptEvent:OOJSID("playerWillEnterWitchspace") andReactToAIMessage:@"PLAYER WITCHSPACE"];
[player addToAdjustTime:[wormhole travelTime]];
// clear old entities
[self removeAllEntitiesExceptPlayer];
[player setSystem_seed:dest];
[self setSystemTo: dest];
[self setUpSpace];
// which will kick the ship out of the wormhole with the
// player still aboard
[player doScriptEvent:OOJSID("shipWillExitWitchspace")];
[player doScriptEvent:OOJSID("shipExitedWitchspace")];
[player setWormhole:nil];
}
- (void) setUpUniverseFromStation
{
if (![self sun])