Oolite 1.91.0.7665-250419-c535bfe
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
PlayerEntity(OOPrivate) Category Reference

Instance Methods

(void) - setExtraEquipmentFromFlags
 
(void) - doTradeIn:forPriceFactor:
 
(void) - updateMovementFlags
 
(void) - updateAlertCondition
 
(void) - updateFuelScoops:
 
(void) - updateClocks:
 
(void) - checkScriptsIfAppropriate
 
(void) - updateTrumbles:
 
(void) - performAutopilotUpdates:
 
(void) - performInFlightUpdates:
 
(void) - performWitchspaceCountdownUpdates:
 
(void) - performWitchspaceExitUpdates:
 
(void) - performLaunchingUpdates:
 
(void) - performDockingUpdates:
 
(void) - performDeadUpdates:
 
(void) - gameOverFadeToBW
 
(void) - updateTargeting
 
(void) - showGameOver
 
(void) - updateWormholes
 
(void) - updateAlertConditionForNearbyEntities
 
(BOOL) - checkEntityForMassLock:withScanClass:
 
(void) - showMarketScreenHeaders
 
(void) - showMarketScreenDataLine:forGood:inMarket:holdQuantity:
 
(void) - showMarketCashAndLoadLine
 
(BOOL) - tryBuyingItem:
 
(NSArray *) - contractsListForScriptingFromArray:forCargo:
 
(void) - prepareMarkedDestination:markers:
 
(void) - witchStart
 
(void) - witchJumpTo:misjump:
 
(void) - witchEnd
 
(double) - hyperspaceJumpDistance
 
(OOFuelQuantity- fuelRequiredForJump
 
(void) - noteCompassLostTarget
 

Detailed Description

Definition at line 113 of file PlayerEntity.m.

Method Documentation

◆ checkEntityForMassLock:withScanClass:

- (BOOL) checkEntityForMassLock: (Entity *) ent
withScanClass: (int) scanClass 

Extends class PlayerEntity.

Definition at line 3362 of file PlayerEntity.m.

3362 :(Entity *)ent withScanClass:(int)theirClass
3363{
3364 BOOL massLocked = NO;
3365 BOOL entIsCloakedShip = [ent isShip] && [(ShipEntity *)ent isCloaked];
3366
3367 if (EXPECT_NOT([ent isStellarObject]))
3368 {
3369 Entity<OOStellarBody> *stellar = (Entity<OOStellarBody> *)ent;
3370 if (EXPECT([stellar planetType] != STELLAR_TYPE_MINIATURE))
3371 {
3372 double dist = stellar->zero_distance;
3373 double rad = stellar->collision_radius;
3374 double factor = ([stellar isSun]) ? 2.0 : 4.0;
3375 // plus ensure mass lock when 25 km or less from the surface of small stellar bodies
3376 // dist is a square distance so it needs to be compared to (rad+25000) * (rad+25000)!
3377 if (dist < rad*rad*factor || dist < rad*rad + 50000*rad + 625000000 )
3378 {
3379 massLocked = YES;
3380 }
3381 }
3382 }
3383 else if (theirClass != CLASS_NO_DRAW)
3384 {
3385 if (EXPECT_NOT (entIsCloakedShip))
3386 {
3387 theirClass = CLASS_NO_DRAW;
3388 }
3389 }
3390
3391 if (!massLocked && ent->zero_distance <= SCANNER_MAX_RANGE2)
3392 {
3393 switch (theirClass)
3394 {
3395 case CLASS_NO_DRAW:
3396 // cloaked ships do mass lock! - Nikos 20200718
3397 if (entIsCloakedShip && ![ent isPlayer])
3398 {
3399 massLocked = YES;
3400 }
3401 break;
3402 case CLASS_PLAYER:
3403 case CLASS_BUOY:
3404 case CLASS_ROCK:
3405 case CLASS_CARGO:
3406 case CLASS_MINE:
3407 case CLASS_VISUAL_EFFECT:
3408 break;
3409
3410 case CLASS_THARGOID:
3411 case CLASS_MISSILE:
3412 case CLASS_STATION:
3413 case CLASS_POLICE:
3414 case CLASS_MILITARY:
3415 case CLASS_WORMHOLE:
3416 default:
3417 massLocked = YES;
3418 break;
3419 }
3420 }
3421
3422 return massLocked;
3423}
#define SCANNER_MAX_RANGE2
Definition Entity.h:52
#define EXPECT_NOT(x)
#define EXPECT(x)
@ STELLAR_TYPE_MINIATURE
GLfloat collision_radius
Definition Entity.h:111
BOOL isSun()
Definition Entity.m:167
GLfloat zero_distance
Definition Entity.h:108
unsigned isShip
Definition Entity.m:131
BOOL isCloaked()
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

References Entity::collision_radius, EXPECT, EXPECT_NOT, ShipEntity::isCloaked, Entity::isShip, Entity::isSun, SCANNER_MAX_RANGE2, STELLAR_TYPE_MINIATURE, and Entity::zero_distance.

Referenced by updateAlertConditionForNearbyEntities.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkScriptsIfAppropriate

- (void) checkScriptsIfAppropriate

Extends class PlayerEntity.

Definition at line 3546 of file PlayerEntity.m.

3547{
3548 if (script_time <= script_time_check) return;
3549
3550 if ([self status] != STATUS_IN_FLIGHT)
3551 {
3552 switch (gui_screen)
3553 {
3554 // Screens where no world script tickles are performed
3555 case GUI_SCREEN_MAIN:
3556 case GUI_SCREEN_INTRO1:
3557 case GUI_SCREEN_SHIPLIBRARY:
3558 case GUI_SCREEN_KEYBOARD:
3559 case GUI_SCREEN_NEWGAME:
3560 case GUI_SCREEN_OXZMANAGER:
3561 case GUI_SCREEN_MARKET:
3562 case GUI_SCREEN_MARKETINFO:
3563 case GUI_SCREEN_OPTIONS:
3564 case GUI_SCREEN_GAMEOPTIONS:
3565 case GUI_SCREEN_LOAD:
3566 case GUI_SCREEN_SAVE:
3567 case GUI_SCREEN_SAVE_OVERWRITE:
3568 case GUI_SCREEN_STICKMAPPER:
3569 case GUI_SCREEN_STICKPROFILE:
3570 case GUI_SCREEN_MISSION:
3571 case GUI_SCREEN_REPORT:
3572 case GUI_SCREEN_KEYBOARD_CONFIRMCLEAR:
3573 case GUI_SCREEN_KEYBOARD_CONFIG:
3574 case GUI_SCREEN_KEYBOARD_ENTRY:
3575 case GUI_SCREEN_KEYBOARD_LAYOUT:
3576 return;
3577
3578 // Screens from which it's safe to jump to the mission screen
3579// case GUI_SCREEN_CONTRACTS:
3580 case GUI_SCREEN_EQUIP_SHIP:
3581 case GUI_SCREEN_INTERFACES:
3582 case GUI_SCREEN_MANIFEST:
3583 case GUI_SCREEN_SHIPYARD:
3584 case GUI_SCREEN_LONG_RANGE_CHART:
3585 case GUI_SCREEN_SHORT_RANGE_CHART:
3586 case GUI_SCREEN_STATUS:
3587 case GUI_SCREEN_SYSTEM_DATA:
3588 // Test passed, we can run scripts. Nothing to do here.
3589 break;
3590 }
3591 }
3592
3593 // Test either passed or never ran, run scripts.
3594 [self checkScript];
3595 script_time_check += script_time_interval;
3596}

References PlayerEntity::checkScript, and checkScriptsIfAppropriate.

Referenced by checkScriptsIfAppropriate, setExtraEquipmentFromFlags, and PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contractsListForScriptingFromArray:forCargo:

- (NSArray *) contractsListForScriptingFromArray: (NSArray *) contractsArray
forCargo: (BOOL) forCargo 

Extends class PlayerEntity.

Definition at line 8436 of file PlayerEntity.m.

8436 :(NSArray *) contracts_array forCargo:(BOOL)forCargo
8437{
8438 NSMutableArray *result = [NSMutableArray array];
8439 NSUInteger i;
8440
8441 for (i = 0; i < [contracts_array count]; i++)
8442 {
8443 NSMutableDictionary *contract = [NSMutableDictionary dictionaryWithCapacity:10];
8444 NSDictionary *dict = [contracts_array oo_dictionaryAtIndex:i];
8445 if (forCargo)
8446 {
8447 // commodity, quantity - keep consistency between .manifest and .contracts
8448 [contract setObject:[dict oo_stringForKey:CARGO_KEY_TYPE] forKey:@"commodity"];
8449 [contract setObject:[NSNumber numberWithUnsignedInt:[dict oo_intForKey:CARGO_KEY_AMOUNT]] forKey:@"quantity"];
8450 [contract setObject:[dict oo_stringForKey:CARGO_KEY_DESCRIPTION] forKey:@"description"];
8451 }
8452 else
8453 {
8454 [contract setObject:[dict oo_stringForKey:PASSENGER_KEY_NAME] forKey:PASSENGER_KEY_NAME];
8455 [contract setObject:[NSNumber numberWithUnsignedInt:[dict oo_unsignedIntForKey:CONTRACT_KEY_RISK]] forKey:CONTRACT_KEY_RISK];
8456 }
8457
8458 OOSystemID planet = [dict oo_intForKey:CONTRACT_KEY_DESTINATION];
8459 NSString *planetName = [UNIVERSE getSystemName:planet];
8460 [contract setObject:[NSNumber numberWithUnsignedInt:planet] forKey:CONTRACT_KEY_DESTINATION];
8461 [contract setObject:planetName forKey:@"destinationName"];
8462 planet = [dict oo_intForKey:CONTRACT_KEY_START];
8463 planetName = [UNIVERSE getSystemName: planet];
8464 [contract setObject:[NSNumber numberWithUnsignedInt:planet] forKey:CONTRACT_KEY_START];
8465 [contract setObject:planetName forKey:@"startName"];
8466
8467 int dest_eta = [dict oo_doubleForKey:CONTRACT_KEY_ARRIVAL_TIME] - ship_clock;
8468 [contract setObject:[NSNumber numberWithInt:dest_eta] forKey:@"eta"];
8469 [contract setObject:[UNIVERSE shortTimeDescription:dest_eta] forKey:@"etaDescription"];
8470 [contract setObject:[NSNumber numberWithInt:[dict oo_intForKey:CONTRACT_KEY_PREMIUM]] forKey:CONTRACT_KEY_PREMIUM];
8471 [contract setObject:[NSNumber numberWithInt:[dict oo_intForKey:CONTRACT_KEY_FEE]] forKey:CONTRACT_KEY_FEE];
8472 [result addObject:contract];
8473 }
8474
8475 return [[result copy] autorelease]; // return an immutable copy
8476}
int16_t OOSystemID
Definition OOTypes.h:211

Referenced by PlayerEntity::contractListForScripting, PlayerEntity::parcelListForScripting, and PlayerEntity::passengerListForScripting.

+ Here is the caller graph for this function:

◆ doTradeIn:forPriceFactor:

- (void) doTradeIn: (OOCreditsQuantity) tradeInValue
forPriceFactor: (double) priceFactor 

Extends class PlayerEntity.

Definition at line 10704 of file PlayerEntity.m.

10704 :(OOCreditsQuantity)tradeInValue forPriceFactor:(double)priceFactor
10705{
10706 if (tradeInValue != 0)
10707 {
10708 if (priceFactor < 1.0) tradeInValue *= priceFactor;
10709 credits += tradeInValue;
10710 }
10711}
uint64_t OOCreditsQuantity
Definition OOTypes.h:182

Referenced by tryBuyingItem:.

+ Here is the caller graph for this function:

◆ fuelRequiredForJump

- (OOFuelQuantity) fuelRequiredForJump

Extends class PlayerEntity.

Definition at line 7508 of file PlayerEntity.m.

7509{
7510 return 10.0 * MAX(0.1, [self hyperspaceJumpDistance]);
7511}
#define MAX(A, B)
Definition OOMaths.h:114

References fuelRequiredForJump, hyperspaceJumpDistance, and MAX.

Referenced by PlayerEntity::dialHyperRange, PlayerEntity::enterWitchspace, fuelRequiredForJump, PlayerEntity::hasSufficientFuelForJump, and setExtraEquipmentFromFlags.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gameOverFadeToBW

- (void) gameOverFadeToBW

Extends class PlayerEntity.

Definition at line 3984 of file PlayerEntity.m.

3985{
3986 float secondsToBWFadeOut = [[NSUserDefaults standardUserDefaults] oo_floatForKey:@"gameover-seconds-to-bw-fadeout" defaultValue:5.0f];
3987 if ([UNIVERSE detailLevel] >= DETAIL_LEVEL_SHADERS && secondsToBWFadeOut > 0.0f)
3988 {
3989 MyOpenGLView *gameView = [UNIVERSE gameView];
3990 static float originalColorSaturation = -1.0f;
3991 if (originalColorSaturation == -1.0f) originalColorSaturation = [gameView colorSaturation];
3992 if ([self shotTime] < secondsToBWFadeOut)
3993 {
3994 // fade to black & white within secondsToBWFadeOut, independently of
3995 // frame rate and original color saturation
3996 if (fps_counter != 0)
3997 {
3998 [gameView adjustColorSaturation:-(originalColorSaturation * (1.0f / secondsToBWFadeOut) * [UNIVERSE timeAccelerationFactor] / fps_counter)];
3999 }
4000 }
4001
4002 if ([self shotTime] > kDeadResetTime)
4003 {
4004 // make sure to subtract the current saturation because if the user presses space to skip
4005 // the game over screen before the transition to b/w has been completed, whatever is left
4006 // will be added to the original saturation, resulting in an oversaturated image
4007 [gameView adjustColorSaturation:originalColorSaturation - [gameView colorSaturation]];
4008 originalColorSaturation = -1.0f;
4009 }
4010 }
4011}
@ DETAIL_LEVEL_SHADERS
Definition OOTypes.h:246
static float const kDeadResetTime
#define UNIVERSE
Definition Universe.h:840
void adjustColorSaturation:(float colorSaturationAdjustment)
float colorSaturation()

References MyOpenGLView::adjustColorSaturation:, MyOpenGLView::colorSaturation, DETAIL_LEVEL_SHADERS, gameOverFadeToBW, kDeadResetTime, and UNIVERSE.

Referenced by gameOverFadeToBW, performDeadUpdates:, and setExtraEquipmentFromFlags.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hyperspaceJumpDistance

- (double) hyperspaceJumpDistance

Extends class PlayerEntity.

Definition at line 7501 of file PlayerEntity.m.

7502{
7503 NSPoint targetCoordinates = PointFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:[self nextHopTargetSystemID] inGalaxy:galaxy_number]);
7504 return distanceBetweenPlanetPositions(targetCoordinates.x,targetCoordinates.y,galaxy_coordinates.x,galaxy_coordinates.y);
7505}
NSPoint PointFromString(NSString *xyString)
OOINLINE double distanceBetweenPlanetPositions(int x1, int y1, int x2, int y2) INLINE_CONST_FUNC

References distanceBetweenPlanetPositions(), hyperspaceJumpDistance, PointFromString(), and UNIVERSE.

Referenced by fuelRequiredForJump, hyperspaceJumpDistance, setExtraEquipmentFromFlags, and PlayerEntity::witchJumpChecklist:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noteCompassLostTarget

- (void) noteCompassLostTarget

Extends class PlayerEntity.

Definition at line 7520 of file PlayerEntity.m.

7521{
7522 if ([[self hud] isCompassActive])
7523 {
7524 // "the compass, it says we're lost!" :)
7525 JSContext *context = OOJSAcquireContext();
7526 jsval jsmode = OOJSValueFromCompassMode(context, [self compassMode]);
7527 ShipScriptEvent(context, self, "compassTargetChanged", JSVAL_VOID, jsmode);
7528 OOJSRelinquishContext(context);
7529
7530 [[self hud] setCompassActive:NO]; // ensure a target change when returning to normal space.
7531 }
7532}
OOINLINE jsval OOJSValueFromCompassMode(JSContext *context, OOCompassMode value)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
#define ShipScriptEvent(context, ship, event,...)

References PlayerEntity::hud, noteCompassLostTarget, OOJSAcquireContext(), OOJSRelinquishContext(), OOJSValueFromCompassMode(), HeadUpDisplay::setCompassActive:, and ShipScriptEvent.

Referenced by PlayerEntity::enterGalacticWitchspace, PlayerEntity::enterWitchspace, noteCompassLostTarget, and setExtraEquipmentFromFlags.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performAutopilotUpdates:

- (void) performAutopilotUpdates: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3612 of file PlayerEntity.m.

3612 :(OOTimeDelta)delta_t
3613{
3614 [self processBehaviour:delta_t];
3615 [self applyVelocity:delta_t];
3616 [self doBookkeeping:delta_t];
3617}
double OOTimeDelta
Definition OOTypes.h:224

References Entity::applyVelocity:, PlayerEntity::doBookkeeping:, and ShipEntity::processBehaviour:.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performDeadUpdates:

- (void) performDeadUpdates: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3968 of file PlayerEntity.m.

3968 :(OOTimeDelta)delta_t
3969{
3970 [UNIVERSE terminatePostFX:OO_POSTFX_CLOAK];
3971 if ([UNIVERSE ECMVisualFXEnabled]) [UNIVERSE terminatePostFX:OO_POSTFX_CRTBADSIGNAL];
3972
3973 [self gameOverFadeToBW];
3974
3975 if ([self shotTime] > kDeadResetTime)
3976 {
3977 BOOL was_mouse_control_on = mouse_control_on;
3978 [UNIVERSE handleGameOver]; // we restart the UNIVERSE
3979 mouse_control_on = was_mouse_control_on;
3980 }
3981}

References PlayerEntity::gameOverFadeToBW, kDeadResetTime, and UNIVERSE.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performDockingUpdates:

- (void) performDockingUpdates: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3955 of file PlayerEntity.m.

3955 :(OOTimeDelta)delta_t
3956{
3957 if ([UNIVERSE breakPatternOver])
3958 {
3959 [self docked]; // bookkeeping for docking
3960 }
3961
3962 // if cloak or ecm visual effects are playing while docking, terminate them
3963 [UNIVERSE terminatePostFX:OO_POSTFX_CLOAK];
3964 if ([UNIVERSE ECMVisualFXEnabled]) [UNIVERSE terminatePostFX:OO_POSTFX_CRTBADSIGNAL];
3965}

References PlayerEntity::docked, and UNIVERSE.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performInFlightUpdates:

- (void) performInFlightUpdates: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3764 of file PlayerEntity.m.

3764 :(OOTimeDelta)delta_t
3765{
3767
3768 // do flight routines
3770 UPDATE_STAGE(@"applying newtonian drift");
3772
3773 [self applyVelocity:delta_t];
3774
3775 GLfloat thrust_factor = 1.0;
3776 if (flightSpeed > maxFlightSpeed)
3777 {
3778 if (afterburner_engaged)
3779 {
3780 thrust_factor = [self afterburnerFactor];
3781 }
3782 else
3783 {
3784 thrust_factor = HYPERSPEED_FACTOR;
3785 }
3786 }
3787
3788
3789 GLfloat velmag = magnitude(velocity);
3790 GLfloat velmag2 = velmag - (float)delta_t * thrust * thrust_factor;
3791 if (velmag > 0)
3792 {
3793 UPDATE_STAGE(@"applying power braking");
3794
3795 if (velmag > VELOCITY_CLEANUP_MIN)
3796 {
3797 GLfloat rate;
3798 // Fix up extremely ridiculous speeds that can happen in collisions or explosions
3799 if (velmag > VELOCITY_CLEANUP_FULL) rate = VELOCITY_CLEANUP_RATE;
3801 velmag2 -= velmag * rate;
3802 }
3803 if (velmag2 < 0.0f) velocity = kZeroVector;
3804 else velocity = vector_multiply_scalar(velocity, velmag2 / velmag);
3805
3806 }
3807
3808 UPDATE_STAGE(@"updating joystick");
3809 [self applyRoll:(float)delta_t*flightRoll andClimb:(float)delta_t*flightPitch];
3810 if (flightYaw != 0.0)
3811 {
3812 [self applyYaw:(float)delta_t*flightYaw];
3813 }
3814
3815 UPDATE_STAGE(@"applying para-newtonian thrust");
3816 [self moveForward:delta_t*flightSpeed];
3817
3818 UPDATE_STAGE(@"updating targeting");
3819 [self updateTargeting];
3820
3822}
const Vector kZeroVector
Definition OOVector.m:28
#define HYPERSPEED_FACTOR
#define VELOCITY_CLEANUP_MIN
#define STAGE_TRACKING_END
#define UPDATE_STAGE(x)
#define VELOCITY_CLEANUP_RATE
#define STAGE_TRACKING_BEGIN
#define VELOCITY_CLEANUP_FULL

References ShipEntity::afterburnerFactor, PlayerEntity::applyRoll:andClimb:, Entity::applyVelocity:, PlayerEntity::applyYaw:, HYPERSPEED_FACTOR, kZeroVector, PlayerEntity::moveForward:, STAGE_TRACKING_BEGIN, STAGE_TRACKING_END, UPDATE_STAGE, PlayerEntity::updateTargeting, VELOCITY_CLEANUP_FULL, VELOCITY_CLEANUP_MIN, and VELOCITY_CLEANUP_RATE.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performLaunchingUpdates:

- (void) performLaunchingUpdates: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3932 of file PlayerEntity.m.

3932 :(OOTimeDelta)delta_t
3933{
3934 if (![UNIVERSE breakPatternHide])
3935 {
3936 flightRoll = launchRoll; // synchronise player's & launching station's spins.
3937 [self doBookkeeping:delta_t]; // don't show ghost exhaust plumes from previous docking!
3938 }
3939
3940 if ([UNIVERSE breakPatternOver])
3941 {
3942 // time to check the legacy scripts!
3943 [self checkScript];
3944 // next check in 10s
3945
3946 [self setStatus:STATUS_IN_FLIGHT];
3947
3948 [self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
3949 StationEntity *stationLaunchedFrom = [UNIVERSE nearestEntityMatchingPredicate:IsStationPredicate parameter:NULL relativeToEntity:self];
3950 [self doScriptEvent:OOJSID("shipLaunchedFromStation") withArgument:stationLaunchedFrom];
3951 }
3952}

References PlayerEntity::checkScript, PlayerEntity::doBookkeeping:, ShipEntity::doScriptEvent:withArgument:, PlayerEntity::setDockingClearanceStatus:, ShipEntity::setStatus:, and UNIVERSE.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performWitchspaceCountdownUpdates:

- (void) performWitchspaceCountdownUpdates: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3825 of file PlayerEntity.m.

3825 :(OOTimeDelta)delta_t
3826{
3828
3829 UPDATE_STAGE(@"doing bookkeeping");
3830 [self doBookkeeping:delta_t];
3831
3832 UPDATE_STAGE(@"updating countdown timer");
3833 witchspaceCountdown = fdim(witchspaceCountdown, delta_t);
3834
3835 // damaged gal drive? abort!
3836 /* TODO: this check should possibly be hasEquipmentItemProviding:,
3837 * but if it was we'd need to know which item was actually doing
3838 * the providing so it could be removed. */
3839 if (EXPECT_NOT(galactic_witchjump && ![self hasEquipmentItem:@"EQ_GAL_DRIVE"]))
3840 {
3841 galactic_witchjump = NO;
3842 [self setStatus:STATUS_IN_FLIGHT];
3843 [self playHyperspaceAborted];
3844 ShipScriptEventNoCx(self, "playerJumpFailed", OOJSSTR("malfunction"));
3845 return;
3846 }
3847
3848 int seconds = round(witchspaceCountdown);
3849 if (galactic_witchjump)
3850 {
3851 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-galactic-in-x-seconds", seconds) forCount:1.0];
3852 }
3853 else
3854 {
3855 NSString *destination = [UNIVERSE getSystemName:[self nextHopTargetSystemID]];
3856 [UNIVERSE displayCountdownMessage:OOExpandKey(@"witch-to-x-in-y-seconds", seconds, destination) forCount:1.0];
3857 }
3858
3859 if (witchspaceCountdown == 0.0)
3860 {
3861 UPDATE_STAGE(@"preloading planet textures");
3862 if (!galactic_witchjump)
3863 {
3864 /* Note: planet texture preloading is done twice for hyperspace jumps:
3865 once when starting the countdown and once at the beginning of the
3866 jump. The reason is that the preloading may have been skipped the
3867 first time because of rate limiting (see notes at
3868 -preloadPlanetTexturesForSystem:). There is no significant overhead
3869 from doing it twice thanks to the texture cache.
3870 -- Ahruman 2009-12-19
3871 */
3872 [UNIVERSE preloadPlanetTexturesForSystem:target_system_id];
3873 }
3874 else
3875 {
3876 // FIXME: preload target system for galactic jump?
3877 }
3878
3879 UPDATE_STAGE(@"JUMP!");
3880 if (galactic_witchjump) [self enterGalacticWitchspace];
3881 else [self enterWitchspace];
3882 galactic_witchjump = NO;
3883 }
3884
3886}
#define OOJSSTR(str)
#define ShipScriptEventNoCx(ship, event,...)

References PlayerEntity::doBookkeeping:, PlayerEntity::enterGalacticWitchspace, PlayerEntity::enterWitchspace, EXPECT_NOT, PlayerEntity::nextHopTargetSystemID, OOJSSTR, PlayerEntity::playHyperspaceAborted, ShipEntity::setStatus:, ShipScriptEventNoCx, STAGE_TRACKING_BEGIN, STAGE_TRACKING_END, and UPDATE_STAGE.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performWitchspaceExitUpdates:

- (void) performWitchspaceExitUpdates: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3889 of file PlayerEntity.m.

3889 :(OOTimeDelta)delta_t
3890{
3891 if ([UNIVERSE breakPatternOver])
3892 {
3893 [self resetExhaustPlumes];
3894 // time to check the script!
3895 [self checkScript];
3896 // next check in 10s
3897 [self resetScriptTimer]; // reset the in-system timer
3898
3899 // announce arrival
3900 if ([UNIVERSE planet])
3901 {
3902 [UNIVERSE addMessage:[NSString stringWithFormat:@" %@. ",[UNIVERSE getSystemName:system_id]] forCount:3.0];
3903 // and reset the compass
3904 if ([self hasEquipmentItemProviding:@"EQ_ADVANCED_COMPASS"])
3905 compassMode = COMPASS_MODE_PLANET;
3906 else
3907 compassMode = COMPASS_MODE_BASIC;
3908 }
3909 else
3910 {
3911 if ([UNIVERSE inInterstellarSpace]) [UNIVERSE addMessage:DESC(@"witch-engine-malfunction") forCount:3.0]; // if sun gone nova, print nothing
3912 }
3913
3914 [self setStatus:STATUS_IN_FLIGHT];
3915
3916 // If we are exiting witchspace after a scripted misjump. then make sure it gets reset now.
3917 // Scripted misjump situations should have a lifespan of one jump only, to keep things
3918 // simple - Nikos 20090728
3919 if ([self scriptedMisjump]) [self setScriptedMisjump:NO];
3920 // similarly reset the misjump range to the traditional 0.5
3921 [self setScriptedMisjumpRange:0.5];
3922
3923 [self doScriptEvent:OOJSID("shipExitedWitchspace") withArgument:[self jumpCause]];
3924
3925 [self doBookkeeping:delta_t]; // arrival frame updates
3926
3927 suppressAegisMessages=NO;
3928 }
3929}

References PlayerEntity::checkScript, PlayerEntity::doBookkeeping:, ShipEntity::doScriptEvent:withArgument:, PlayerEntity::jumpCause, ShipEntity::resetExhaustPlumes, PlayerEntity::resetScriptTimer, ShipEntity::setScriptedMisjump:, ShipEntity::setScriptedMisjumpRange:, ShipEntity::setStatus:, and UNIVERSE.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareMarkedDestination:markers:

- (void) prepareMarkedDestination: (NSMutableDictionary *)
markers: (NSDictionary *) marker 

Extends class PlayerEntity.

Definition at line 8727 of file PlayerEntity.m.

8727 :(NSMutableDictionary *)markers :(NSDictionary *)marker
8728{
8729 NSNumber *key = [NSNumber numberWithInt:[marker oo_intForKey:@"system"]];
8730 NSMutableArray *list = [markers objectForKey:key];
8731 if (list == nil)
8732 {
8733 list = [NSMutableArray arrayWithObject:marker];
8734 }
8735 else
8736 {
8737 [list addObject:marker];
8738 }
8739 [markers setObject:list forKey:key];
8740}
return nil

References nil.

◆ setExtraEquipmentFromFlags

- (void) setExtraEquipmentFromFlags

Extends class PlayerEntity.

References checkScriptsIfAppropriate, fuelRequiredForJump, gameOverFadeToBW, hyperspaceJumpDistance, noteCompassLostTarget, setExtraEquipmentFromFlags, showGameOver, showMarketCashAndLoadLine, showMarketScreenHeaders, updateAlertCondition, updateAlertConditionForNearbyEntities, updateMovementFlags, updateTargeting, updateWormholes, witchEnd, and witchStart.

Referenced by setExtraEquipmentFromFlags.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showGameOver

- (void) showGameOver

Extends class PlayerEntity.

Definition at line 4056 of file PlayerEntity.m.

4057{
4058 [hud resetGuis:[NSDictionary dictionaryWithObject:[NSDictionary dictionary] forKey:@"message_gui"]];
4059 NSString *scoreMS = [NSString stringWithFormat:OOExpandKey(@"gameoverscreen-score-@"),
4060 KillCountToRatingAndKillString(ship_kills)];
4061
4062 [UNIVERSE displayMessage:OOExpandKey(@"gameoverscreen-game-over") forCount:kDeadResetTime];
4063 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4064 [UNIVERSE displayMessage:scoreMS forCount:kDeadResetTime];
4065 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4066 [UNIVERSE displayMessage:OOExpandKey(@"gameoverscreen-press-space") forCount:kDeadResetTime];
4067 [UNIVERSE displayMessage:@" " forCount:kDeadResetTime];
4068 [UNIVERSE displayMessage:@"" forCount:kDeadResetTime];
4069 [self resetShotTime];
4070}

References ShipEntity::resetShotTime, and showGameOver.

Referenced by PlayerEntity::doBookkeeping:, PlayerEntity::getDestroyedBy:damageType:, setExtraEquipmentFromFlags, and showGameOver.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMarketCashAndLoadLine

- (void) showMarketCashAndLoadLine

Extends class PlayerEntity.

Definition at line 11354 of file PlayerEntity.m.

11355{
11356 GuiDisplayGen *gui = [UNIVERSE gui];
11357 OOCargoQuantity currentCargo = current_cargo;
11358 OOCargoQuantity cargoCapacity = [self maxAvailableCargoSpace];
11359 [gui setText:OOExpandKey(@"market-cash-and-load", credits, currentCargo, cargoCapacity) forRow:GUI_ROW_MARKET_CASH];
11360 [gui setColor:[gui colorFromSetting:kGuiMarketCashColor defaultValue:[OOColor yellowColor]] forRow:GUI_ROW_MARKET_CASH];
11361}
uint32_t OOCargoQuantity
Definition OOTypes.h:176
OOColor * colorFromSetting:defaultValue:(NSString *setting,[defaultValue] OOColor *def)
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
OOColor * yellowColor()
Definition OOColor.m:292

References GuiDisplayGen::colorFromSetting:defaultValue:, ShipEntity::maxAvailableCargoSpace, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setText:forRow:, showMarketCashAndLoadLine, and OOColor::yellowColor.

Referenced by setExtraEquipmentFromFlags, PlayerEntity::setGuiToMarketInfoScreen, PlayerEntity::setGuiToMarketScreen, and showMarketCashAndLoadLine.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMarketScreenDataLine:forGood:inMarket:holdQuantity:

- (void) showMarketScreenDataLine: (OOGUIRow) row
forGood: (OOCommodityType) good
inMarket: (OOCommodityMarket *) localMarket
holdQuantity: (OOCargoQuantity) quantity 

Extends class PlayerEntity.

Definition at line 10960 of file PlayerEntity.m.

10960 :(OOGUIRow)row forGood:(OOCommodityType)good inMarket:(OOCommodityMarket *)localMarket holdQuantity:(OOCargoQuantity)quantity
10961{
10962 GuiDisplayGen *gui = [UNIVERSE gui];
10963 NSString* desc = [NSString stringWithFormat:@" %@ ", [shipCommodityData nameForGood:good]];
10964 OOCargoQuantity available_units = [localMarket quantityForGood:good];
10965 OOCargoQuantity units_in_hold = quantity;
10966 OOCreditsQuantity pricePerUnit = [localMarket priceForGood:good];
10967 OOMassUnit unit = [shipCommodityData massUnitForGood:good];
10968
10969 NSString *available = OOPadStringToEms(((available_units > 0) ? (NSString *)[NSString stringWithFormat:@"%d",available_units] : DESC(@"commodity-quantity-none")), 2.5);
10970
10971 NSUInteger priceDecimal = pricePerUnit % 10;
10972 NSString *price = [NSString stringWithFormat:@" %@.%lu ",OOPadStringToEms([NSString stringWithFormat:@"%lu",(unsigned long)(pricePerUnit/10)],2.5),priceDecimal];
10973
10974 // this works with up to 9999 tons of gemstones. Any more than that, they deserve the formatting they get! :)
10975
10976 NSString *owned = OOPadStringToEms((units_in_hold > 0) ? (NSString *)[NSString stringWithFormat:@"%d",units_in_hold] : DESC(@"commodity-quantity-none"), 4.5);
10977 NSString *units = DisplayStringForMassUnit(unit);
10978 NSString *units_available = [NSString stringWithFormat:@" %@ %@ ",available, units];
10979 NSString *units_owned = [NSString stringWithFormat:@" %@ %@ ",owned, units];
10980
10981 NSUInteger import_legality = [localMarket importLegalityForGood:good];
10982 NSUInteger export_legality = [localMarket exportLegalityForGood:good];
10983 NSString *legaldesc = nil;
10984 if (import_legality == 0)
10985 {
10986 if (export_legality == 0)
10987 {
10988 legaldesc = DESC(@"oolite-legality-clear");
10989 }
10990 else
10991 {
10992 legaldesc = DESC(@"oolite-legality-import");
10993 }
10994 }
10995 else
10996 {
10997 if (export_legality == 0)
10998 {
10999 legaldesc = DESC(@"oolite-legality-export");
11000 }
11001 else
11002 {
11003 legaldesc = DESC(@"oolite-legality-neither");
11004 }
11005 }
11006 legaldesc = [NSString stringWithFormat:@" %@ ",legaldesc];
11007
11008 NSString *extradesc = [shipCommodityData shortCommentForGood:good];
11009
11010 [gui setKey:good forRow:row];
11011 [gui setColor:[gui colorFromSetting:kGuiMarketCommodityColor defaultValue:nil] forRow:row];
11012 [gui setArray:[NSArray arrayWithObjects: desc, extradesc, price, units_available, units_owned, legaldesc, nil] forRow:row++];
11013
11014}
NSInteger OOGUIRow
NSString * DisplayStringForMassUnit(OOMassUnit unit)
NSString * OOPadStringToEms(NSString *string, float numEms)
NSString * OOCommodityType
Definition OOTypes.h:106
OOMassUnit
Definition OOTypes.h:123
#define DESC(key)
Definition Universe.h:846
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
NSUInteger exportLegalityForGood:(OOCommodityType good)
NSUInteger importLegalityForGood:(OOCommodityType good)
OOCargoQuantity quantityForGood:(OOCommodityType good)
OOCreditsQuantity priceForGood:(OOCommodityType good)

References GuiDisplayGen::colorFromSetting:defaultValue:, DESC, DisplayStringForMassUnit(), OOCommodityMarket::exportLegalityForGood:, OOCommodityMarket::importLegalityForGood:, nil, OOPadStringToEms(), OOCommodityMarket::priceForGood:, OOCommodityMarket::quantityForGood:, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setColor:forRow:, and GuiDisplayGen::setKey:forRow:.

Referenced by PlayerEntity::setGuiToMarketInfoScreen, and PlayerEntity::setGuiToMarketScreen.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMarketScreenHeaders

- (void) showMarketScreenHeaders

Extends class PlayerEntity.

Definition at line 10938 of file PlayerEntity.m.

10939{
10940 GuiDisplayGen *gui = [UNIVERSE gui];
10941 OOGUITabSettings tab_stops;
10942 tab_stops[0] = 0;
10943 tab_stops[1] = 137;
10944 tab_stops[2] = 187;
10945 tab_stops[3] = 267;
10946 tab_stops[4] = 321;
10947 tab_stops[5] = 431;
10948 [gui overrideTabs:tab_stops from:kGuiMarketTabs length:6];
10949 [gui setTabStops:tab_stops];
10950
10951 [gui setColor:[gui colorFromSetting:kGuiMarketHeadingColor defaultValue:[OOColor greenColor]] forRow:GUI_ROW_MARKET_KEY];
10952 [gui setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
10953 OOPadStringToEms(DESC(@"for-sale-column-title"),3.75), OOPadStringToEms(DESC(@"in-hold-column-title"),5.75), DESC(@"oolite-legality-column-title"), DESC(@"oolite-extras-column-title"), nil] forRow:GUI_ROW_MARKET_KEY];
10954 [gui setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), DESC(@"oolite-extras-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
10955 OOPadStringToEms(DESC(@"for-sale-column-title"),3.75), OOPadStringToEms(DESC(@"in-hold-column-title"),5.75), DESC(@"oolite-legality-column-title"), nil] forRow:GUI_ROW_MARKET_KEY];
10956
10957}
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
void overrideTabs:from:length:(OOGUITabSettings stops,[from] NSString *setting,[length] NSUInteger len)
void setTabStops:(OOGUITabSettings stops)
OOColor * greenColor()
Definition OOColor.m:274

References GuiDisplayGen::colorFromSetting:defaultValue:, OOColor::greenColor, GuiDisplayGen::overrideTabs:from:length:, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setTabStops:, and showMarketScreenHeaders.

Referenced by setExtraEquipmentFromFlags, PlayerEntity::setGuiToMarketInfoScreen, PlayerEntity::setGuiToMarketScreen, and showMarketScreenHeaders.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tryBuyingItem:

- (BOOL) tryBuyingItem: (NSString *) eqKey

Extends class PlayerEntity.

Definition at line 10344 of file PlayerEntity.m.

10344 :(NSString *)eqKey
10345{
10346 // note this doesn't check the availability by tech-level
10347 OOEquipmentType *eqType = [OOEquipmentType equipmentTypeWithIdentifier:eqKey];
10348 OOCreditsQuantity pricePerUnit = [eqType price];
10349 NSString *eqKeyDamaged = [eqType damagedIdentifier];
10350 double price = pricePerUnit;
10351 double priceFactor = 1.0;
10352 OOCreditsQuantity tradeIn = 0;
10353 BOOL isRepair = NO;
10354
10355 // repairs cost 50%
10356 if ([self hasEquipmentItem:eqKeyDamaged])
10357 {
10358 price /= 2.0;
10359 isRepair = YES;
10360 }
10361
10362 if ([eqKey isEqualToString:@"EQ_RENOVATION"])
10363 {
10364 price = [self renovationCosts];
10365 }
10366
10367 price = [self adjustPriceByScriptForEqKey:eqKey withCurrent:price];
10368
10369 StationEntity *dockedStation = [self dockedStation];
10370 if (dockedStation)
10371 {
10372 priceFactor = [dockedStation equipmentPriceFactor];
10373 }
10374
10375 price *= priceFactor; // increased prices at some stations
10376
10377 if (price > credits)
10378 {
10379 return NO;
10380 }
10381
10382 if ([eqType isPrimaryWeapon])
10383 {
10384 if (chosen_weapon_facing == WEAPON_FACING_NONE)
10385 {
10386 [self setGuiToEquipShipScreen:0 selectingFacingFor:eqKey]; // reset
10387 return YES;
10388 }
10389
10391 OOWeaponType current_weapon = nil;
10392
10393 NSUInteger multiplier = 1;
10394
10395 switch (chosen_weapon_facing)
10396 {
10398 current_weapon = forward_weapon_type;
10399 forward_weapon_type = chosen_weapon;
10400 if (_multiplyWeapons)
10401 {
10402 multiplier = [forwardWeaponOffset count];
10403 }
10404 break;
10405
10406 case WEAPON_FACING_AFT:
10407 current_weapon = aft_weapon_type;
10408 aft_weapon_type = chosen_weapon;
10409 if (_multiplyWeapons)
10410 {
10411 multiplier = [aftWeaponOffset count];
10412 }
10413 break;
10414
10415 case WEAPON_FACING_PORT:
10416 current_weapon = port_weapon_type;
10417 port_weapon_type = chosen_weapon;
10418 if (_multiplyWeapons)
10419 {
10420 multiplier = [portWeaponOffset count];
10421 }
10422 break;
10423
10425 current_weapon = starboard_weapon_type;
10426 starboard_weapon_type = chosen_weapon;
10427 if (_multiplyWeapons)
10428 {
10429 multiplier = [starboardWeaponOffset count];
10430 }
10431 break;
10432
10433 case WEAPON_FACING_NONE:
10434 break;
10435 }
10436
10437 price *= multiplier;
10438
10439 if (price > credits)
10440 {
10441 // not enough money - ensure that weapon
10442 // type is reset to what it was before
10443 // the attempt to buy took place
10444 switch (chosen_weapon_facing)
10445 {
10447 forward_weapon_type = current_weapon;
10448 break;
10449 case WEAPON_FACING_AFT:
10450 aft_weapon_type = current_weapon;
10451 break;
10452 case WEAPON_FACING_PORT:
10453 port_weapon_type = current_weapon;
10454 break;
10456 starboard_weapon_type = current_weapon;
10457 break;
10458 case WEAPON_FACING_NONE:
10459 break;
10460 }
10461 return NO;
10462 }
10463 credits -= price;
10464
10465 // Refund current_weapon
10466 if (current_weapon != nil)
10467 {
10468 tradeIn = [UNIVERSE getEquipmentPriceForKey:OOEquipmentIdentifierFromWeaponType(current_weapon)] * multiplier;
10469 }
10470
10471 [self doTradeIn:tradeIn forPriceFactor:priceFactor];
10472 // If equipped, remove damaged weapon after repairs. -- But there's no way we should get a damaged weapon. Ever.
10473 [self removeEquipmentItem:eqKeyDamaged];
10474 return YES;
10475 }
10476
10477 if ([eqType isMissileOrMine] && missiles >= max_missiles)
10478 {
10479 OOLog(@"equip.buy.mounted.failed.full", @"%@", @"rejecting missile because already full");
10480 return NO;
10481 }
10482
10483 // NSFO!
10484 //unsigned passenger_space = [[OOEquipmentType equipmentTypeWithIdentifier:@"EQ_PASSENGER_BERTH"] requiredCargoSpace];
10485 //if (passenger_space == 0) passenger_space = PASSENGER_BERTH_SPACE;
10486
10487 if ([eqKey isEqualToString:@"EQ_PASSENGER_BERTH"] && [self availableCargoSpace] < PASSENGER_BERTH_SPACE)
10488 {
10489 return NO;
10490 }
10491
10492 if ([eqKey isEqualToString:@"EQ_FUEL"])
10493 {
10494#if MASS_DEPENDENT_FUEL_PRICES
10495 OOCreditsQuantity creditsForRefuel = ([self fuelCapacity] - [self fuel]) * pricePerUnit * [self fuelChargeRate];
10496#else
10497 OOCreditsQuantity creditsForRefuel = ([self fuelCapacity] - [self fuel]) * pricePerUnit;
10498#endif
10499 if (credits >= creditsForRefuel) // Ensure we don't overflow
10500 {
10501 credits -= creditsForRefuel;
10502 fuel = [self fuelCapacity];
10503 return YES;
10504 }
10505 else
10506 {
10507 return NO;
10508 }
10509 }
10510
10511 // check energy unit replacement
10512 if ([eqKey hasSuffix:@"ENERGY_UNIT"] && [self energyUnitType] != ENERGY_UNIT_NONE)
10513 {
10514 switch ([self energyUnitType])
10515 {
10516 case ENERGY_UNIT_NAVAL :
10517 [self removeEquipmentItem:@"EQ_NAVAL_ENERGY_UNIT"];
10518 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_NAVAL_ENERGY_UNIT"] / 2; // 50 % refund
10519 break;
10521 [self removeEquipmentItem:@"EQ_NAVAL_ENERGY_UNIT_DAMAGED"];
10522 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_NAVAL_ENERGY_UNIT"] / 4; // half of the working one
10523 break;
10524 case ENERGY_UNIT_NORMAL :
10525 [self removeEquipmentItem:@"EQ_ENERGY_UNIT"];
10526 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_ENERGY_UNIT"] * 3 / 4; // 75 % refund
10527 break;
10529 [self removeEquipmentItem:@"EQ_ENERGY_UNIT_DAMAGED"];
10530 tradeIn = [UNIVERSE getEquipmentPriceForKey:@"EQ_ENERGY_UNIT"] * 3 / 8; // half of the working one
10531 break;
10532
10533 default:
10534 break;
10535 }
10536 [self doTradeIn:tradeIn forPriceFactor:priceFactor];
10537 }
10538
10539 // maintain ship
10540 if ([eqKey isEqualToString:@"EQ_RENOVATION"])
10541 {
10542 OOTechLevelID techLevel = NSNotFound;
10543 if (dockedStation != nil) techLevel = [dockedStation equivalentTechLevel];
10544 if (techLevel == NSNotFound) techLevel = [[UNIVERSE currentSystemData] oo_unsignedIntForKey:KEY_TECHLEVEL];
10545
10546 credits -= price;
10547 ship_trade_in_factor += 5 + techLevel; // you get better value at high-tech repair bases
10548 if (ship_trade_in_factor > 100) ship_trade_in_factor = 100;
10549
10550 [self clearSubEntities];
10551 [self setUpSubEntities];
10552
10553 return YES;
10554 }
10555
10556 if ([eqKey hasSuffix:@"MISSILE"] || [eqKey hasSuffix:@"MINE"])
10557 {
10558 ShipEntity* weapon = [[UNIVERSE newShipWithRole:eqKey] autorelease];
10559 if (weapon) OOLog(kOOLogBuyMountedOK, @"Got ship for mounted weapon role %@", eqKey);
10560 else OOLog(kOOLogBuyMountedFailed, @"Could not find ship for mounted weapon role %@", eqKey);
10561
10562 BOOL mounted_okay = [self mountMissile:weapon];
10563 if (mounted_okay)
10564 {
10565 credits -= price;
10566 [self safeAllMissiles];
10567 [self tidyMissilePylons];
10568 [self setActiveMissile:0];
10569 }
10570 return mounted_okay;
10571 }
10572
10573 if ([eqKey isEqualToString:@"EQ_PASSENGER_BERTH"])
10574 {
10575 [self changePassengerBerths:+1];
10576 credits -= price;
10577 return YES;
10578 }
10579
10580 if ([eqKey isEqualToString:@"EQ_PASSENGER_BERTH_REMOVAL"])
10581 {
10582 [self changePassengerBerths:-1];
10583 credits -= price;
10584 return YES;
10585 }
10586
10587 if ([eqKey isEqualToString:@"EQ_MISSILE_REMOVAL"])
10588 {
10589 credits -= price;
10590 tradeIn += [self removeMissiles];
10591 [self doTradeIn:tradeIn forPriceFactor:priceFactor];
10592 return YES;
10593 }
10594
10595 if ([self canAddEquipment:eqKey inContext:@"purchase"])
10596 {
10597 credits -= price;
10598 [self addEquipmentItem:eqKey withValidation:NO inContext:@"purchase"]; // no need to validate twice.
10599 if (isRepair)
10600 {
10601 [self doScriptEvent:OOJSID("equipmentRepaired") withArgument:eqKey];
10602 }
10603 return YES;
10604 }
10605
10606 return NO;
10607}
#define OOLog(class, format,...)
Definition OOLogging.h:88
return self
NSUInteger OOTechLevelID
Definition OOTypes.h:204
@ WEAPON_FACING_FORWARD
Definition OOTypes.h:229
@ WEAPON_FACING_NONE
Definition OOTypes.h:234
@ WEAPON_FACING_AFT
Definition OOTypes.h:230
@ WEAPON_FACING_PORT
Definition OOTypes.h:231
@ WEAPON_FACING_STARBOARD
Definition OOTypes.h:232
@ ENERGY_UNIT_NORMAL
Definition OOTypes.h:137
@ ENERGY_UNIT_NAVAL_DAMAGED
Definition OOTypes.h:134
@ ENERGY_UNIT_NAVAL
Definition OOTypes.h:138
@ ENERGY_UNIT_NONE
Definition OOTypes.h:132
@ ENERGY_UNIT_NORMAL_DAMAGED
Definition OOTypes.h:133
static NSString *const kOOLogBuyMountedOK
static NSString *const kOOLogBuyMountedFailed
OOEquipmentType * OOWeaponType
Definition ShipEntity.h:168
OOWeaponType OOWeaponTypeFromEquipmentIdentifierStrict(NSString *string) PURE_FUNC
#define PASSENGER_BERTH_SPACE
Definition Universe.h:152
NSString * damagedIdentifier()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
OOCreditsQuantity price()
OOTechLevelID equivalentTechLevel
float equipmentPriceFactor

References PlayerEntity::addEquipmentItem:withValidation:inContext:, PlayerEntity::adjustPriceByScriptForEqKey:withCurrent:, PlayerEntity::changePassengerBerths:, ShipEntity::clearSubEntities, OOEquipmentType::damagedIdentifier, PlayerEntity::dockedStation, ShipEntity::doScriptEvent:withArgument:, PlayerEntity::doTradeIn:forPriceFactor:, ENERGY_UNIT_NAVAL, ENERGY_UNIT_NAVAL_DAMAGED, ENERGY_UNIT_NONE, ENERGY_UNIT_NORMAL, ENERGY_UNIT_NORMAL_DAMAGED, StationEntity::equipmentPriceFactor, OOEquipmentType::equipmentTypeWithIdentifier:, StationEntity::equivalentTechLevel, ShipEntity::fuel, ShipEntity::fuelCapacity, kOOLogBuyMountedFailed, kOOLogBuyMountedOK, PlayerEntity::mountMissile:, nil, OOLog, OOWeaponTypeFromEquipmentIdentifierStrict(), PASSENGER_BERTH_SPACE, OOEquipmentType::price, PlayerEntity::removeEquipmentItem:, PlayerEntity::removeMissiles, PlayerEntity::renovationCosts, PlayerEntity::safeAllMissiles, PlayerEntity::setActiveMissile:, PlayerEntity::setGuiToEquipShipScreen:selectingFacingFor:, ShipEntity::setUpSubEntities, PlayerEntity::tidyMissilePylons, WEAPON_FACING_AFT, WEAPON_FACING_FORWARD, WEAPON_FACING_NONE, WEAPON_FACING_PORT, and WEAPON_FACING_STARBOARD.

+ Here is the call graph for this function:

◆ updateAlertCondition

- (void) updateAlertCondition

Extends class PlayerEntity.

Definition at line 3426 of file PlayerEntity.m.

3427{
3428 [self updateAlertConditionForNearbyEntities];
3429 /* TODO: update alert condition once per frame. Tried this before, but
3430 there turned out to be complications. See mailing list archive.
3431 -- Ahruman 20070802
3432 */
3433 OOAlertCondition cond = [self alertCondition];
3434 OOTimeAbsolute t = [UNIVERSE getTime];
3435 if (cond != lastScriptAlertCondition)
3436 {
3437 ShipScriptEventNoCx(self, "alertConditionChanged", INT_TO_JSVAL(cond), INT_TO_JSVAL(lastScriptAlertCondition));
3438 lastScriptAlertCondition = cond;
3439 }
3440 /* Update heuristic assessment of whether player is fleeing */
3441 if (cond == ALERT_CONDITION_DOCKED || cond == ALERT_CONDITION_GREEN || (cond == ALERT_CONDITION_YELLOW && energy == maxEnergy))
3442 {
3443 fleeing_status = PLAYER_FLEEING_NONE;
3444 }
3445 else if (fleeing_status == PLAYER_FLEEING_UNLIKELY && (energy > maxEnergy*0.6 || cond != ALERT_CONDITION_RED))
3446 {
3447 fleeing_status = PLAYER_FLEEING_NONE;
3448 }
3449 else if ((fleeing_status == PLAYER_FLEEING_MAYBE || fleeing_status == PLAYER_FLEEING_UNLIKELY) && cargo_dump_time > last_shot_time)
3450 {
3451 fleeing_status = PLAYER_FLEEING_CARGO;
3452 }
3453 else if (fleeing_status == PLAYER_FLEEING_MAYBE && last_shot_time + 10 > t)
3454 {
3455 fleeing_status = PLAYER_FLEEING_NONE;
3456 }
3457 else if (fleeing_status == PLAYER_FLEEING_LIKELY && last_shot_time + 10 > t)
3458 {
3459 fleeing_status = PLAYER_FLEEING_UNLIKELY;
3460 }
3461 else if (fleeing_status == PLAYER_FLEEING_NONE && cond == ALERT_CONDITION_RED && last_shot_time + 10 < t && flightSpeed > 0.75*maxFlightSpeed)
3462 {
3463 fleeing_status = PLAYER_FLEEING_MAYBE;
3464 }
3465 else if ((fleeing_status == PLAYER_FLEEING_MAYBE || fleeing_status == PLAYER_FLEEING_CARGO) && cond == ALERT_CONDITION_RED && last_shot_time + 10 < t && flightSpeed > 0.75*maxFlightSpeed && energy < maxEnergy * 0.5 && (forward_shield < [self maxForwardShieldLevel]*0.25 || aft_shield < [self maxAftShieldLevel]*0.25))
3466 {
3467 fleeing_status = PLAYER_FLEEING_LIKELY;
3468 }
3469}
double OOTimeAbsolute
Definition OOTypes.h:223
@ PLAYER_FLEEING_MAYBE
@ PLAYER_FLEEING_LIKELY
@ PLAYER_FLEEING_NONE
@ PLAYER_FLEEING_CARGO
@ PLAYER_FLEEING_UNLIKELY
OOAlertCondition
Definition ShipEntity.h:172
@ ALERT_CONDITION_GREEN
Definition ShipEntity.h:176
@ ALERT_CONDITION_RED
Definition ShipEntity.h:178
@ ALERT_CONDITION_YELLOW
Definition ShipEntity.h:177
@ ALERT_CONDITION_DOCKED
Definition ShipEntity.h:175

References ALERT_CONDITION_DOCKED, ALERT_CONDITION_GREEN, ALERT_CONDITION_RED, ALERT_CONDITION_YELLOW, PlayerEntity::alertCondition, PLAYER_FLEEING_CARGO, PLAYER_FLEEING_LIKELY, PLAYER_FLEEING_MAYBE, PLAYER_FLEEING_NONE, PLAYER_FLEEING_UNLIKELY, ShipScriptEventNoCx, updateAlertCondition, and PlayerEntity::updateAlertConditionForNearbyEntities.

Referenced by setExtraEquipmentFromFlags, PlayerEntity::setMassLockable:, PlayerEntity::update:, and updateAlertCondition.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateAlertConditionForNearbyEntities

- (void) updateAlertConditionForNearbyEntities

Extends class PlayerEntity.

Definition at line 3215 of file PlayerEntity.m.

3216{
3217 if (![self isInSpace] || [self status] == STATUS_DOCKING)
3218 {
3219 [self clearAlertFlags];
3220 // not needed while docked
3221 return;
3222 }
3223
3224 int i, ent_count = UNIVERSE->n_entities;
3225 Entity **uni_entities = UNIVERSE->sortedEntities; // grab the public sorted list
3226 Entity *my_entities[ent_count];
3227 Entity *scannedEntity = nil;
3228 for (i = 0; i < ent_count; i++)
3229 {
3230 my_entities[i] = [uni_entities[i] retain]; // retained
3231 }
3232 BOOL massLocked = NO;
3233 BOOL foundHostiles = NO;
3234#if OO_VARIABLE_TORUS_SPEED
3235 BOOL needHyperspeedNearest = YES;
3236 double hsnDistance = 0;
3237#endif
3238 for (i = 0; i < ent_count; i++) // scanner lollypops
3239 {
3240 scannedEntity = my_entities[i];
3241
3242#if OO_VARIABLE_TORUS_SPEED
3243 if (EXPECT_NOT(needHyperspeedNearest))
3244 {
3245 // not visual effects, waypoints, ships, etc.
3246 if (scannedEntity != self && [scannedEntity canCollide] && (![scannedEntity isShip] || ![self collisionExceptedFor:(ShipEntity *) scannedEntity]))
3247 {
3248 hsnDistance = sqrt(scannedEntity->zero_distance)-[scannedEntity collisionRadius];
3249 needHyperspeedNearest = NO;
3250 }
3251 }
3252 else if ([scannedEntity isStellarObject])
3253 {
3254 // planets, stars might be closest surface even if not
3255 // closest centre. That could be true of others, but the
3256 // error is negligible there.
3257 double thisHSN = sqrt(scannedEntity->zero_distance)-[scannedEntity collisionRadius];
3258 if (thisHSN < hsnDistance)
3259 {
3260 hsnDistance = thisHSN;
3261 }
3262 }
3263#endif
3264
3265 if (scannedEntity->zero_distance < SCANNER_MAX_RANGE2 || !scannedEntity->isShip)
3266 {
3267 int theirClass = [scannedEntity scanClass];
3268 // here we could also force masslock for higher than yellow alert, but
3269 // if we are going to hand over masslock control to scripting, might as well
3270 // hand it over fully
3271 if ([self massLockable] /*|| alertFlags > ALERT_FLAG_YELLOW_LIMIT*/)
3272 {
3273 massLocked |= [self checkEntityForMassLock:scannedEntity withScanClass:theirClass]; // we just need one masslocker..
3274 }
3275 if (theirClass != CLASS_NO_DRAW)
3276 {
3277 if (theirClass == CLASS_THARGOID || [scannedEntity isCascadeWeapon])
3278 {
3279 foundHostiles = YES;
3280 }
3281 else if ([scannedEntity isShip])
3282 {
3283 ShipEntity *ship = (ShipEntity *)scannedEntity;
3284 foundHostiles |= (([ship hasHostileTarget])&&([ship primaryTarget] == self));
3285 }
3286 }
3287 }
3288 }
3289#if OO_VARIABLE_TORUS_SPEED
3290 if (EXPECT_NOT(needHyperspeedNearest))
3291 {
3292 // this case should only occur in an otherwise empty
3293 // interstellar space - unlikely but possible
3294 hyperspeedFactor = MIN_HYPERSPEED_FACTOR;
3295 }
3296 else
3297 {
3298 // once nearest object is >4x scanner range
3299 // start increasing torus speed
3300 double factor = hsnDistance/(4*SCANNER_MAX_RANGE);
3301 if (factor < 1.0)
3302 {
3303 hyperspeedFactor = MIN_HYPERSPEED_FACTOR;
3304 }
3305 else
3306 {
3307 hyperspeedFactor = MIN_HYPERSPEED_FACTOR * sqrt(factor);
3308 if (hyperspeedFactor > MAX_HYPERSPEED_FACTOR)
3309 {
3310 // caps out at ~10^8m from nearest object
3311 // which takes ~10 minutes of flying
3312 hyperspeedFactor = MAX_HYPERSPEED_FACTOR;
3313 }
3314 }
3315 }
3316#endif
3317
3318 [self setAlertFlag:ALERT_FLAG_MASS_LOCK to:massLocked];
3319
3320 [self setAlertFlag:ALERT_FLAG_HOSTILES to:foundHostiles];
3321
3322 for (i = 0; i < ent_count; i++)
3323 {
3324 [my_entities[i] release]; // released
3325 }
3326
3327 BOOL energyCritical = NO;
3328 if (energy < 64 && energy < maxEnergy * 0.8)
3329 {
3330 energyCritical = YES;
3331 }
3332 [self setAlertFlag:ALERT_FLAG_ENERGY to:energyCritical];
3333
3334 [self setAlertFlag:ALERT_FLAG_TEMP to:([self hullHeatLevel] > .90)];
3335
3336 [self setAlertFlag:ALERT_FLAG_ALT to:([self dialAltitude] < .10)];
3337
3338}
#define SCANNER_MAX_RANGE
Definition Entity.h:51
#define MAX_HYPERSPEED_FACTOR
#define MIN_HYPERSPEED_FACTOR
BOOL hasHostileTarget()

References PlayerEntity::checkEntityForMassLock:withScanClass:, PlayerEntity::clearAlertFlags, Entity::collisionRadius, PlayerEntity::dialAltitude, EXPECT_NOT, ShipEntity::hasHostileTarget, ShipEntity::hullHeatLevel, Entity::isShip, MAX_HYPERSPEED_FACTOR, MIN_HYPERSPEED_FACTOR, nil, ShipEntity::primaryTarget, Entity::scanClass, SCANNER_MAX_RANGE, SCANNER_MAX_RANGE2, PlayerEntity::setAlertFlag:to:, UNIVERSE, updateAlertConditionForNearbyEntities, and Entity::zero_distance.

Referenced by setExtraEquipmentFromFlags, updateAlertCondition, and updateAlertConditionForNearbyEntities.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateClocks:

- (void) updateClocks: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3486 of file PlayerEntity.m.

3486 :(OOTimeDelta)delta_t
3487{
3488 // shot time updates are still needed here for STATUS_DEAD!
3489 shot_time += delta_t;
3490 script_time += delta_t;
3491 unsigned prev_day = floor(ship_clock / 86400);
3492 ship_clock += delta_t;
3493 if (ship_clock_adjust > 0.0) // adjust for coming out of warp (add LY * LY hrs)
3494 {
3495 double fine_adjust = delta_t * 7200.0;
3496 if (ship_clock_adjust > 86400) // more than a day
3497 fine_adjust = delta_t * 115200.0; // 16 times faster
3498 if (ship_clock_adjust > 0)
3499 {
3500 if (fine_adjust > ship_clock_adjust)
3501 fine_adjust = ship_clock_adjust;
3502 ship_clock += fine_adjust;
3503 ship_clock_adjust -= fine_adjust;
3504 }
3505 else
3506 {
3507 if (fine_adjust < ship_clock_adjust)
3508 fine_adjust = ship_clock_adjust;
3509 ship_clock -= fine_adjust;
3510 ship_clock_adjust += fine_adjust;
3511 }
3512 }
3513 else
3514 ship_clock_adjust = 0.0;
3515
3516 unsigned now_day = floor(ship_clock / 86400.0);
3517 while (prev_day < now_day)
3518 {
3519 prev_day++;
3520 [self doScriptEvent:OOJSID("dayChanged") withArgument:[NSNumber numberWithUnsignedInt:prev_day]];
3521 // not impossible that at ultra-low frame rates two of these will
3522 // happen in a single update.
3523 }
3524
3525 //fps
3526 if (ship_clock > fps_check_time)
3527 {
3528 if (![self clockAdjusting])
3529 {
3530 fps_counter = (int)([UNIVERSE timeAccelerationFactor] * floor([UNIVERSE framesDoneThisUpdate] / (fps_check_time - last_fps_check_time)));
3531 last_fps_check_time = fps_check_time;
3532 fps_check_time = ship_clock + MINIMUM_GAME_TICK;
3533 }
3534 else
3535 {
3536 // Good approximation for when the clock is adjusting and proper fps calculation
3537 // cannot be performed.
3538 fps_counter = (int)([UNIVERSE timeAccelerationFactor] * floor(1.0 / delta_t));
3539 fps_check_time = ship_clock + MINIMUM_GAME_TICK;
3540 }
3541 [UNIVERSE resetFramesDoneThisUpdate]; // Reset frame counter
3542 }
3543}
#define MINIMUM_GAME_TICK

References ShipEntity::doScriptEvent:withArgument:, int(), MINIMUM_GAME_TICK, and UNIVERSE.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFuelScoops:

- (void) updateFuelScoops: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3472 of file PlayerEntity.m.

3472 :(OOTimeDelta)delta_t
3473{
3474 if (scoopsActive)
3475 {
3476 [self updateFuelScoopSoundWithInterval:delta_t];
3477 if (![self scoopOverride])
3478 {
3479 scoopsActive = NO;
3480 [self updateFuelScoopSoundWithInterval:delta_t];
3481 }
3482 }
3483}

References PlayerEntity::updateFuelScoopSoundWithInterval:.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateMovementFlags

- (void) updateMovementFlags

Extends class PlayerEntity.

Definition at line 3206 of file PlayerEntity.m.

3207{
3208 hasMoved = !HPvector_equal(position, lastPosition);
3209 hasRotated = !quaternion_equal(orientation, lastOrientation);
3210 lastPosition = position;
3211 lastOrientation = orientation;
3212}

References updateMovementFlags.

Referenced by setExtraEquipmentFromFlags, PlayerEntity::update:, and updateMovementFlags.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTargeting

- (void) updateTargeting

Extends class PlayerEntity.

Definition at line 4146 of file PlayerEntity.m.

4147{
4149
4150 // check for lost ident target and ensure the ident system is actually scanning
4151 UPDATE_STAGE(@"checking ident target");
4152 if (ident_engaged && [self primaryTarget] != nil)
4153 {
4154 if (![self isValidTarget:[self primaryTarget]])
4155 {
4156 if (!suppressTargetLost)
4157 {
4158 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
4159 [self playTargetLost];
4160 [self noteLostTarget];
4161 }
4162 else
4163 {
4164 suppressTargetLost = NO;
4165 }
4166
4167 DESTROY(_primaryTarget);
4168 }
4169 }
4170
4171 // check each unlaunched missile's target still exists and is in-range
4172 UPDATE_STAGE(@"checking missile targets");
4173 if (missile_status != MISSILE_STATUS_SAFE)
4174 {
4175 unsigned i;
4176 for (i = 0; i < max_missiles; i++)
4177 {
4178 if ([missile_entity[i] primaryTarget] != nil &&
4179 ![self isValidTarget:[missile_entity[i] primaryTarget]])
4180 {
4181 [UNIVERSE addMessage:DESC(@"target-lost") forCount:3.0];
4182 [self playTargetLost];
4183 [missile_entity[i] removeTarget:nil];
4184 if (i == activeMissile)
4185 {
4186 [self noteLostTarget];
4187 DESTROY(_primaryTarget);
4188 missile_status = MISSILE_STATUS_ARMED;
4189 }
4190 } else if (i == activeMissile && [missile_entity[i] primaryTarget] == nil) {
4191 missile_status = MISSILE_STATUS_ARMED;
4192 }
4193 }
4194 }
4195
4196 // if we don't have a primary target, and we're scanning, then check for a new
4197 // target to lock on to
4198 UPDATE_STAGE(@"looking for new target");
4199 if ([self primaryTarget] == nil &&
4200 (ident_engaged || missile_status != MISSILE_STATUS_SAFE) &&
4201 ([self status] == STATUS_IN_FLIGHT || [self status] == STATUS_WITCHSPACE_COUNTDOWN))
4202 {
4203 Entity *target = [UNIVERSE firstEntityTargetedByPlayer];
4204 if ([self isValidTarget:target])
4205 {
4206 [self addTarget:target];
4207 }
4208 }
4209
4210 // If our primary target is a wormhole, check to see if we have additional
4211 // information
4212 UPDATE_STAGE(@"checking for additional wormhole information");
4213 if ([[self primaryTarget] isWormhole])
4214 {
4215 WormholeEntity *wh = [self primaryTarget];
4216 switch ([wh scanInfo])
4217 {
4218 case WH_SCANINFO_NONE:
4219 OOLog(kOOLogInconsistentState, @"%@", @"Internal Error - WH_SCANINFO_NONE reached in [PlayerEntity updateTargeting:]");
4220 [self dumpState];
4221 [wh dumpState];
4222 // Workaround a reported hit of the assert here. We really
4223 // should work out how/why this could happen though and fix
4224 // the underlying cause.
4225 // - MKW 2011.03.11
4226 //assert([wh scanInfo] != WH_SCANINFO_NONE);
4227 [wh setScannedAt:[self clockTimeAdjusted]];
4228 break;
4230 if ([self clockTimeAdjusted] > [wh scanTime] + 2)
4231 {
4232 [wh setScanInfo:WH_SCANINFO_COLLAPSE_TIME];
4233 //[UNIVERSE addCommsMessage:[NSString stringWithFormat:DESC(@"wormhole-collapse-time-computed"),
4234 // [UNIVERSE getSystemName:[wh destination]]] forCount:5.0];
4235 }
4236 break;
4238 if([self clockTimeAdjusted] > [wh scanTime] + 4)
4239 {
4240 [wh setScanInfo:WH_SCANINFO_ARRIVAL_TIME];
4241 [UNIVERSE addCommsMessage:[NSString stringWithFormat:DESC(@"wormhole-arrival-time-computed-@"),
4242 ClockToString([wh estimatedArrivalTime], NO)] forCount:5.0];
4243 }
4244 break;
4246 if ([self clockTimeAdjusted] > [wh scanTime] + 7)
4247 {
4248 [wh setScanInfo:WH_SCANINFO_DESTINATION];
4249 [UNIVERSE addCommsMessage:[NSString stringWithFormat:DESC(@"wormhole-destination-computed-@"),
4250 [UNIVERSE getSystemName:[wh destination]]] forCount:5.0];
4251 }
4252 break;
4254 if ([self clockTimeAdjusted] > [wh scanTime] + 10)
4255 {
4256 [wh setScanInfo:WH_SCANINFO_SHIP];
4257 // TODO: Extract last ship from wormhole and display its name
4258 }
4259 break;
4260 case WH_SCANINFO_SHIP:
4261 break;
4262 }
4263 }
4264
4266}
#define DESTROY(x)
Definition OOCocoa.h:77
NSString *const kOOLogInconsistentState
Definition OOLogging.m:650
@ MISSILE_STATUS_ARMED
@ MISSILE_STATUS_SAFE
@ WH_SCANINFO_NONE
@ WH_SCANINFO_SCANNED
@ WH_SCANINFO_SHIP
@ WH_SCANINFO_ARRIVAL_TIME
@ WH_SCANINFO_DESTINATION
@ WH_SCANINFO_COLLAPSE_TIME
void dumpState()
Definition Entity.m:996
double estimatedArrivalTime()
OOSystemID destination
void setScannedAt:(double time)
void setScanInfo:(WORMHOLE_SCANINFO scanInfo)

References PlayerEntity::addTarget:, PlayerEntity::clockTimeAdjusted, WormholeEntity::destination, DESTROY, Entity::dumpState, WormholeEntity::estimatedArrivalTime, kOOLogInconsistentState, MISSILE_STATUS_ARMED, MISSILE_STATUS_SAFE, nil, ShipEntity::noteLostTarget, OOLog, PlayerEntity::playTargetLost, ShipEntity::primaryTarget, WormholeEntity::setScanInfo:, WormholeEntity::setScannedAt:, STAGE_TRACKING_BEGIN, STAGE_TRACKING_END, UPDATE_STAGE, updateTargeting, WH_SCANINFO_ARRIVAL_TIME, WH_SCANINFO_COLLAPSE_TIME, WH_SCANINFO_DESTINATION, WH_SCANINFO_NONE, WH_SCANINFO_SCANNED, and WH_SCANINFO_SHIP.

Referenced by performInFlightUpdates:, setExtraEquipmentFromFlags, and updateTargeting.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTrumbles:

- (void) updateTrumbles: (OOTimeDelta) delta_t

Extends class PlayerEntity.

Definition at line 3599 of file PlayerEntity.m.

3599 :(OOTimeDelta)delta_t
3600{
3601 OOTrumble **trumbles = [self trumbleArray];
3602 NSUInteger i;
3603
3604 for (i = [self trumbleCount] ; i > 0; i--)
3605 {
3606 OOTrumble* trum = trumbles[i - 1];
3607 [trum updateTrumble:delta_t];
3608 }
3609}
void updateTrumble:(double delta_t)
Definition OOTrumble.m:494

References PlayerEntity::trumbleArray, and OOTrumble::updateTrumble:.

Referenced by PlayerEntity::update:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateWormholes

- (void) updateWormholes

Extends class PlayerEntity.

Definition at line 13243 of file PlayerEntity.m.

13244{
13245 assert(scannedWormholes != nil);
13246
13247 if ([scannedWormholes count] == 0)
13248 return;
13249
13250 double now = [self clockTimeAdjusted];
13251
13252 NSMutableArray * savedWormholes = [[NSMutableArray alloc] initWithCapacity:[scannedWormholes count]];
13253 NSEnumerator * wormholes = [scannedWormholes objectEnumerator];
13254 WormholeEntity *wh;
13255
13256 while ((wh = (WormholeEntity*)[wormholes nextObject]))
13257 {
13258 // TODO: Start drawing wormhole exit a few seconds before the first
13259 // ship is disgorged.
13260 if ([wh arrivalTime] > now)
13261 {
13262 [savedWormholes addObject:wh];
13263 }
13264 else if (NSEqualPoints(galaxy_coordinates, [wh destinationCoordinates]))
13265 {
13266 [wh disgorgeShips];
13267 if ([[wh shipsInTransit] count] > 0)
13268 {
13269 [savedWormholes addObject:wh];
13270 }
13271 }
13272 // Else wormhole has expired in another system, let it expire
13273 }
13274
13275 [scannedWormholes release];
13276 scannedWormholes = savedWormholes;
13277}
unsigned count

References PlayerEntity::clockTimeAdjusted, count, WormholeEntity::disgorgeShips, nil, and updateWormholes.

Referenced by setExtraEquipmentFromFlags, PlayerEntity::update:, and updateWormholes.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ witchEnd

- (void) witchEnd

Extends class PlayerEntity.

Definition at line 7393 of file PlayerEntity.m.

7394{
7395 [UNIVERSE setSystemTo:system_id];
7396 galaxy_coordinates = [[UNIVERSE systemManager] getCoordinatesForSystem:system_id inGalaxy:galaxy_number];
7397
7398 [UNIVERSE setUpUniverseFromWitchspace];
7399 [[UNIVERSE planet] update: 2.34375 * market_rnd]; // from 0..10 minutes
7400 [[UNIVERSE station] update: 2.34375 * market_rnd]; // from 0..10 minutes
7401
7402 chart_centre_coordinates = galaxy_coordinates;
7403 target_chart_centre = chart_centre_coordinates;
7404}

References witchEnd.

Referenced by PlayerEntity::enterGalacticWitchspace, setExtraEquipmentFromFlags, witchEnd, and witchJumpTo:misjump:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ witchJumpTo:misjump:

- (void) witchJumpTo: (OOSystemID) sTo
misjump: (BOOL) misjump 

Extends class PlayerEntity.

Definition at line 7775 of file PlayerEntity.m.

7775 :(OOSystemID)sTo misjump:(BOOL)misjump
7776{
7777 [self witchStart];
7778 if (info_system_id == system_id)
7779 {
7780 [self setInfoSystemID: sTo moveChart: YES];
7781 }
7782 //wear and tear on all jumps (inc misjumps, failures, and wormholes)
7783 if (2 * market_rnd < ship_trade_in_factor)
7784 {
7785 // every eight jumps or so drop the price down towards 75%
7786 [self adjustTradeInFactorBy:-(1 + (market_rnd & 3))];
7787 }
7788
7789 // set clock after "playerWillEnterWitchspace" and before removeAllEntitiesExceptPlayer, to allow escorts time to follow their mother.
7790 NSPoint destCoords = PointFromString([[UNIVERSE systemManager] getProperty:@"coordinates" forSystem:sTo inGalaxy:galaxy_number]);
7791 double distance = distanceBetweenPlanetPositions(destCoords.x,destCoords.y,galaxy_coordinates.x,galaxy_coordinates.y);
7792
7793 // if we just escaped a system gone nova, make sure all nova parameters are reset
7794 OOSunEntity *theSun = [UNIVERSE sun];
7795 if (theSun && [theSun goneNova])
7796 {
7797 [theSun resetNova];
7798 }
7799
7800 [UNIVERSE removeAllEntitiesExceptPlayer];
7801 if (!misjump)
7802 {
7803 ship_clock_adjust += distance * distance * 3600.0;
7804 [self setSystemID:sTo];
7805 [self setBounty:(legalStatus/2) withReason:kOOLegalStatusReasonNewSystem]; // 'another day, another system'
7806 [self witchEnd];
7807 if (market_rnd < 8) [self erodeReputation]; // every 32 systems or so, drop back towards 'unknown'
7808 }
7809 else
7810 {
7811 // Misjump: move halfway there!
7812 // misjumps do not change legal status.
7813 if (randf() < 0.1) [self erodeReputation]; // once every 10 misjumps - should be much rarer than successful jumps!
7814
7815 [wormhole setMisjump];
7816 // just in case, but this has usually been set already
7817
7818 // and now the wormhole has travel time and coordinates calculated
7819 // so rather than duplicate the calculation we'll just ask it...
7820 NSPoint dest = [wormhole destinationCoordinates];
7821 galaxy_coordinates.x = dest.x;
7822 galaxy_coordinates.y = dest.y;
7823
7824 ship_clock_adjust += [wormhole travelTime];
7825
7826 [self playWitchjumpMisjump];
7827 [UNIVERSE setUpUniverseFromMisjump];
7828 }
7829}
float randf(void)

References PlayerEntity::adjustTradeInFactorBy:, distanceBetweenPlanetPositions(), PlayerEntity::erodeReputation, PlayerEntity::playWitchjumpMisjump, PointFromString(), randf(), OOSunEntity::resetNova, PlayerEntity::setBounty:withReason:, PlayerEntity::setInfoSystemID:moveChart:, PlayerEntity::setSystemID:, UNIVERSE, PlayerEntity::witchEnd, and PlayerEntity::witchStart.

Referenced by PlayerEntity::enterWitchspace, and PlayerEntity::enterWormhole:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ witchStart

- (void) witchStart

Extends class PlayerEntity.

Definition at line 7348 of file PlayerEntity.m.

7349{
7350 // chances of entering witchspace with autopilot on are very low, but as Berlios bug #18307 has shown us, entirely possible
7351 // so in such cases we need to ensure that at least the docking music stops playing
7352 if (autopilot_engaged) [self disengageAutopilot];
7353
7354 if (![hud nonlinearScanner])
7355 {
7356 [hud setScannerZoom: 1.0];
7357 }
7358 [self safeAllMissiles];
7359
7360 OOViewID previousViewDirection = [UNIVERSE viewDirection];
7361 [UNIVERSE setViewDirection:VIEW_FORWARD];
7362 [self noteSwitchToView:VIEW_FORWARD fromView:previousViewDirection]; // notifies scripts of the switch
7363
7364 currentWeaponFacing = WEAPON_FACING_FORWARD;
7365 [self currentWeaponStats];
7366
7367 [self transitionToAegisNone];
7368 suppressAegisMessages=YES;
7369 hyperspeed_engaged = NO;
7370
7371 if ([self primaryTarget] != nil)
7372 {
7373 [self noteLostTarget]; // losing target? Fire lost target event!
7374 DESTROY(_primaryTarget);
7375 }
7376
7377 scanner_zoom_rate = 0.0f;
7378 [UNIVERSE setDisplayText:NO];
7379
7380 if ( ![self wormhole] && !galactic_witchjump) // galactic hyperspace does not generate a wormhole
7381 {
7382 OOLog(kOOLogInconsistentState, @"%@", @"Internal Error : Player entering witchspace with no wormhole.");
7383 }
7384 [UNIVERSE allShipsDoScriptEvent:OOJSID("playerWillEnterWitchspace") andReactToAIMessage:@"PLAYER WITCHSPACE"];
7385
7386 // set the new market seed now!
7387 // reseeding the RNG should be completely unnecessary here
7388// ranrot_srand((uint32_t)[[NSDate date] timeIntervalSince1970]); // seed randomiser by time
7389 market_rnd = ranrot_rand() & 255; // random factor for market values is reset
7390}
OOViewID
Definition OOTypes.h:43
#define ranrot_rand()

References PlayerEntity::currentWeaponStats, DESTROY, PlayerEntity::disengageAutopilot, kOOLogInconsistentState, nil, ShipEntity::noteLostTarget, PlayerEntity::noteSwitchToView:fromView:, OOLog, ranrot_rand, PlayerEntity::safeAllMissiles, ShipEntity::transitionToAegisNone, WEAPON_FACING_FORWARD, and witchStart.

Referenced by PlayerEntity::enterGalacticWitchspace, setExtraEquipmentFromFlags, witchJumpTo:misjump:, and witchStart.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this category was generated from the following file: