Oolite
Loading...
Searching...
No Matches
OOJSPlayerShip.m
Go to the documentation of this file.
1/*
2
3OOJSPlayerShip.m (QuickJS-ng)
4
5Oolite
6Copyright (C) 2004-2013 Giles C Williams and contributors
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21MA 02110-1301, USA.
22
23*/
24
26#import "HeadUpDisplay.h"
28#import "OOJSEntity.h"
29#import "OOJSPlayer.h"
30#import "OOJSQuaternion.h"
31#import "OOJSShip.h"
32#import "OOJSVector.h"
39#import "PlayerEntitySound.h"
40#import "StationEntity.h"
41
42#import "OOConstToJSString.h"
43#import "OOConstToString.h"
44#import "OOEquipmentType.h"
46#import "OOJSEquipmentInfo.h"
47
48static JSClassID sPlayerShipClassID;
49
50static JSClassDef sPlayerShipClass = {
51 .class_name = "PlayerShip",
52 .finalizer = OOJSObjectWrapperFinalize,
53};
54
57
85
86static BOOL ValidateContracts(JSContext* context, int argc, JSValueConst* argv, BOOL isCargo, OOSystemID* start, OOSystemID* destination, double* eta, double* fee, double* premium, NSString* functionName, unsigned* risk);
87
88enum {
89 // Property IDs
90 kPlayerShip_activeMissile, // index in 'missiles' array of current active missile
91 kPlayerShip_aftShield, // aft shield charge level, nonnegative float, read/write
92 kPlayerShip_aftShieldRechargeRate, // aft shield recharge rate, positive float, read-only
93 kPlayerShip_chartHightlightMode, // what type of information is being shown on the chart
94 kPlayerShip_compassMode, // compass mode, string, read/write
95 kPlayerShip_compassTarget, // object targeted by the compass, entity, read/write
96 kPlayerShip_compassType, // basic / advanced, string, read/write
97 kPlayerShip_currentWeapon, // shortcut property to _aftWeapon, etc. overrides kShip generic version
98 kPlayerShip_crosshairs, // custom plist file defining crosshairs
99 kPlayerShip_cursorCoordinates, // cursor coordinates (unscaled), Vector3D, read only
100 kPlayerShip_cursorCoordinatesInLY, // cursor coordinates (in LY), Vector3D, read only
101 kPlayerShip_docked, // docked, boolean, read-only
102 kPlayerShip_dockedStation, // docked station, entity, read-only
103 kPlayerShip_fastEquipmentA, // fast equipment A, string, read/write
104 kPlayerShip_fastEquipmentB, // fast equipment B, string, read/write
105 kPlayerShip_forwardShield, // forward shield charge level, nonnegative float, read/write
106 kPlayerShip_forwardShieldRechargeRate, // forward shield recharge rate, positive float, read-only
107 kPlayerShip_fuelLeakRate, // fuel leak rate, float, read/write
108 kPlayerShip_galacticHyperspaceBehaviour, // can be standard, all systems reachable or fixed coordinates, integer, read-only
109 kPlayerShip_galacticHyperspaceFixedCoords, // used when fixed coords behaviour is selected, Vector3D, read/write
110 kPlayerShip_galacticHyperspaceFixedCoordsInLY, // used when fixed coords behaviour is selected, Vector3D, read/write
111 kPlayerShip_galaxyCoordinates, // galaxy coordinates (unscaled), Vector3D, read only
112 kPlayerShip_galaxyCoordinatesInLY, // galaxy coordinates (in LY), Vector3D, read only
113 kPlayerShip_hud, // hud name identifier, string, read/write
114 kPlayerShip_hudAllowsBigGui, // hud big gui, string, read only
115 kPlayerShip_hudHidden, // hud visibility, boolean, read/write
116 kPlayerShip_injectorsEngaged, // injectors in use, boolean, read-only
117 kPlayerShip_massLockable, // mass-lockability of player ship, read/write
118 kPlayerShip_maxAftShield, // maximum aft shield charge level, positive float, read-only
119 kPlayerShip_maxForwardShield, // maximum forward shield charge level, positive float, read-only
120 kPlayerShip_messageGuiTextColor, // message gui standard text color, array, read/write
121 kPlayerShip_messageGuiTextCommsColor, // message gui incoming comms text color, array, read/write
122 kPlayerShip_multiFunctionDisplays, // mfd count, positive int, read-only
123 kPlayerShip_multiFunctionDisplayList, // active mfd list, array, read-only
124 kPlayerShip_missilesOnline, // bool (false for ident mode, true for missile mode)
125 kPlayerShip_pitch, // pitch (overrules Ship)
126 kPlayerShip_price, // idealised trade-in value decicredits, positive int, read-only
127 kPlayerShip_primedEquipment, // currently primed equipment, string, read/write
128 kPlayerShip_renovationCost, // int read-only current renovation cost
129 kPlayerShip_reticleColorTarget, // Reticle color for normal targets, array, read/write
130 kPlayerShip_reticleColorTargetSensitive, // Reticle color for targets picked up when sensitive mode is on, array, read/write
131 kPlayerShip_reticleColorWormhole, // REticle color for wormholes, array, read/write
132 kPlayerShip_renovationMultiplier, // float read-only multiplier for renovation costs
133 kPlayerShip_reticleTargetSensitive, // target box changes color when primary target in crosshairs, boolean, read/write
134 kPlayerShip_roll, // roll (overrules Ship)
136 kPlayerShip_scannerMinimalistic, // essentially scanner without gridlines
137 kPlayerShip_scannerNonLinear, // non linear scanner setting, boolean, read/write
138 kPlayerShip_scannerUltraZoom, // scanner zoom in powers of 2, boolean, read/write
140 kPlayerShip_serviceLevel, // servicing level, positive int 75-100, read-only
141 kPlayerShip_specialCargo, // special cargo, string, read-only
142 kPlayerShip_targetSystem, // target system id, int, read-write
143 kPlayerShip_nextSystem, // next hop system id, read-only
144 kPlayerShip_infoSystem, // info (F7 screen) system id, int, read-write
145 kPlayerShip_previousSystem, // previous system id, read-only
146 kPlayerShip_torusEngaged, // torus in use, boolean, read-only
147 kPlayerShip_viewDirection, // view direction identifier, string, read-only
148 kPlayerShip_viewPositionAft, // view position offset, vector, read-only
149 kPlayerShip_viewPositionForward, // view position offset, vector, read-only
150 kPlayerShip_viewPositionPort, // view position offset, vector, read-only
151 kPlayerShip_viewPositionStarboard, // view position offset, vector, read-only
152 kPlayerShip_weaponsOnline, // weapons online status, boolean, read-only
153 kPlayerShip_yaw, // yaw (overrules Ship)
154};
155
156static const JSCFunctionListEntry sPlayerShipProperties[] = {
157 // JS name, getter, setter, ID
186 // manifest defined in OOJSManifest.m
223};
224
225static const JSCFunctionListEntry sPlayerShipMethods[] = {
226 // JS name, min args, function
227 JS_CFUNC_DEF("addParcel", 0, PlayerShipAddParcel),
228 JS_CFUNC_DEF("addPassenger", 0, PlayerShipAddPassenger),
229 JS_CFUNC_DEF("awardContract", 0, PlayerShipAwardContract),
230 JS_CFUNC_DEF("awardEquipmentToCurrentPylon", 1, PlayerShipAwardEquipmentToCurrentPylon),
231 JS_CFUNC_DEF("beginHyperspaceCountdown", 0, PlayerShipBeginHyperspaceCountdown),
232 JS_CFUNC_DEF("cancelDockingRequest", 1, PlayerShipCancelDockingRequest),
233 JS_CFUNC_DEF("cancelHyperspaceCountdown", 0, PlayerShipCancelHyperspaceCountdown),
234 JS_CFUNC_DEF("beginGalacticHyperspaceCountdown", 1, PlayerShipBeginGalacticHyperspaceCountdown),
235 JS_CFUNC_DEF("disengageAutopilot", 0, PlayerShipDisengageAutopilot),
236 JS_CFUNC_DEF("engageAutopilotToStation", 1, PlayerShipEngageAutopilotToStation),
237 JS_CFUNC_DEF("hideHUDSelector", 1, PlayerShipHideHUDSelector),
238 JS_CFUNC_DEF("launch", 0, PlayerShipLaunch),
239 JS_CFUNC_DEF("removeAllCargo", 0, PlayerShipRemoveAllCargo),
240 JS_CFUNC_DEF("removeContract", 2, PlayerShipRemoveContract),
241 JS_CFUNC_DEF("removeParcel", 1, PlayerShipRemoveParcel),
242 JS_CFUNC_DEF("removePassenger", 1, PlayerShipRemovePassenger),
243 JS_CFUNC_DEF("requestDockingClearance", 1, PlayerShipRequestDockingClearance),
244 JS_CFUNC_DEF("resetCustomView", 0, PlayerShipResetCustomView),
245 JS_CFUNC_DEF("resetScannerZoom", 0, PlayerShipResetScannerZoom),
246 JS_CFUNC_DEF("setCustomView", 2, PlayerShipSetCustomView),
247 JS_CFUNC_DEF("setCustomHUDDial", 2, PlayerShipSetCustomHUDDial),
248 JS_CFUNC_DEF("setMultiFunctionDisplay", 1, PlayerShipSetMultiFunctionDisplay),
249 JS_CFUNC_DEF("setMultiFunctionText", 1, PlayerShipSetMultiFunctionText),
250 JS_CFUNC_DEF("setPrimedEquipment", 1, PlayerShipSetPrimedEquipment),
251 JS_CFUNC_DEF("showHUDSelector", 1, PlayerShipShowHUDSelector),
252 JS_CFUNC_DEF("takeInternalDamage", 0, PlayerShipTakeInternalDamage),
253 JS_CFUNC_DEF("useSpecialCargo", 1, PlayerShipUseSpecialCargo),
254};
255
256void InitOOJSPlayerShip(JSContext* context, JSValueConst global)
257{
259
260 JSValue shipPrototype = JS_GetClassProto(context, JSShipClassID());
261 NSCAssert(JS_IsObject(shipPrototype), @"Ship must be initialized before PlayerShip.");
262 OOJSInitClass(context, global, sPlayerShipClassID, shipPrototype, OOJSUnconstructableConstruct, 0,
264 JS_FreeValue(context, shipPrototype);
265
268
269 PlayerEntity* player = [PlayerEntity sharedPlayer]; // NOTE: at time of writing, this creates the player entity. Don't use PLAYER here.
270
271 // Create ship object as a property of the player object.
272 JSValue playerObject = JS_GetPropertyStr(context, global, "player");
273 NSCAssert(JS_IsObject(playerObject), @"Player must be initialized before PlayerShip.");
274
275 JSValue shipObject = JS_NewObjectClass(context, (int)sPlayerShipClassID);
276 JS_SetOpaque(shipObject, OOConsumeReference([player weakRetain]));
277 // The player object's property and the player entity each own a reference.
278 JS_DefinePropertyValueStr(context, playerObject, "ship", JS_DupValue(context, shipObject), OOJS_PROP_READONLY);
279 [player setJSSelf:shipObject context:context];
280
281 JS_FreeValue(context, shipObject);
282 JS_FreeValue(context, playerObject);
283 // Analyzer: object leaked. [Expected, object is retained by JS object.]
284}
285
286JSClassID JSPlayerShipClassID(void)
287{
288 return sPlayerShipClassID;
289}
290
292{
293 JSContext* context = OOJSAcquireContext();
294 JSValue playerObject = JSPlayerObject();
295 JSValue result = JS_GetPropertyStr(context, playerObject, "ship");
296 JS_FreeValue(context, playerObject);
297 OOJSRelinquishContext(context);
298 return result;
299}
300
301@implementation PlayerEntity (OOJavaScriptExtensions)
302
303- (NSString*)oo_jsClassName
304{
305 return @"PlayerShip";
306}
307
308- (JSClassID)oo_jsClassID
309{
310 return sPlayerShipClassID;
311}
312
313- (void)setJSSelf:(JSValueConst)val context:(JSContext*)context
314{
315 // Drop any previous wrapper (and its reset observer).
316 [self deleteJSSelf];
317
318 // Released by -deleteJSSelf when the JavaScript engine resets.
319 _jsSelf = JS_DupValue(context, val);
320
321 [[NSNotificationCenter defaultCenter] addObserver:self
322 selector:@selector(deleteJSSelf)
323 name:kOOJavaScriptEngineWillResetNotification
325}
326
327@end
328
330{
331 OOJS_NATIVE_ENTER(context)
332
333 /* SpiderMonkey compared this with the prototype. The prototype (like any
334 object that isn't player.ship, such as the this of a detached getter
335 call) has no private weak reference to the player.
336 */
337 if (EXPECT_NOT(OOIsPlayerStale() || JS_GetOpaque(this, sPlayerShipClassID) == NULL)) {
338 return JS_UNDEFINED;
339 }
340
341 id result = nil;
343
344 switch (magic) {
346 return JS_NewNumber(context, [player activeMissile]);
347
349 return JS_NewNumber(context, [player fuelLeakRate]);
350
352 return OOJSValueFromBOOL([player isDocked]);
353
355 result = [player dockedStation];
356 break;
357
359 result = [player specialCargo];
360 break;
361
363 result = [[[player hud] reticleColorForIndex:OO_RETICLE_COLOR_TARGET] normalizedArray];
364 break;
365
367 result = [[[player hud] reticleColorForIndex:OO_RETICLE_COLOR_TARGET_SENSITIVE] normalizedArray];
368 break;
369
371 result = [[[player hud] reticleColorForIndex:OO_RETICLE_COLOR_WORMHOLE] normalizedArray];
372 break;
373
375 return OOJSValueFromBOOL([[player hud] reticleTargetSensitive]);
376
378 return OOJSValueFromGalacticHyperspaceBehaviour(context, [player galacticHyperspaceBehaviour]);
379
381 OOJS_RETURN_WITH_HELPER(NSPointToVectorJSValue, [player galacticHyperspaceFixedCoords]);
382
384 OOJS_RETURN_VECTOR(OOGalacticCoordinatesFromInternal([player galacticHyperspaceFixedCoords]));
385
387 result = [player fastEquipmentA];
388 break;
389
391 result = [player fastEquipmentB];
392 break;
393
395 result = [player currentPrimedEquipment];
396 break;
397
399 return JS_NewNumber(context, [player forwardShieldLevel]);
400
402 return JS_NewNumber(context, [player aftShieldLevel]);
403
405 return JS_NewNumber(context, [player maxForwardShieldLevel]);
406
408 return JS_NewNumber(context, [player maxAftShieldLevel]);
409
411 // No distinction made internally
412 return JS_NewNumber(context, [player forwardShieldRechargeRate]);
413
415 // No distinction made internally
416 return JS_NewNumber(context, [player aftShieldRechargeRate]);
417
419 return JS_NewNumber(context, [[player hud] mfdCount]);
420
422 result = [player multiFunctionDisplayList];
423 break;
424
426 return OOJSValueFromBOOL(![player dialIdentEngaged]);
427
429 result = OOStringFromLongRangeChartMode([player longRangeChartMode]);
430 break;
431
433 OOJS_RETURN_WITH_HELPER(NSPointToVectorJSValue, [player galaxy_coordinates]);
434
436 OOJS_RETURN_VECTOR(OOGalacticCoordinatesFromInternal([player galaxy_coordinates]));
437
439 OOJS_RETURN_WITH_HELPER(NSPointToVectorJSValue, [player cursor_coordinates]);
440
442 OOJS_RETURN_VECTOR(OOGalacticCoordinatesFromInternal([player cursor_coordinates]));
443
445 return JS_NewInt32(context, [player targetSystemID]);
446
448 return JS_NewInt32(context, [player nextHopTargetSystemID]);
449
451 return JS_NewInt32(context, [player infoSystemID]);
452
454 return JS_NewInt32(context, [player previousSystemID]);
455
457 OORouteType route = [player ANAMode];
458 switch (route) {
460 result = @"OPTIMIZED_BY_TIME";
461 break;
463 result = @"OPTIMIZED_BY_JUMPS";
464 break;
466 result = @"OPTIMIZED_BY_NONE";
467 break;
468 }
469 break;
470 }
471
473 return OOJSValueFromBOOL([[player hud] minimalisticScanner]);
474
476 return OOJSValueFromBOOL([[player hud] nonlinearScanner]);
477
479 return OOJSValueFromBOOL([[player hud] scannerUltraZoom]);
480
482 return OOJSValueFromBOOL([player scoopOverride]);
483
485 return OOJSValueFromBOOL([player injectorsEngaged]);
486
488 return OOJSValueFromBOOL([player massLockable]);
489
491 return OOJSValueFromBOOL([player hyperspeedEngaged]);
492
494 result = [player compassTarget];
495 break;
496
498 result = [OOStringFromCompassMode([player compassMode]) isEqualToString:@"COMPASS_MODE_BASIC"] ? @"OO_COMPASSTYPE_BASIC" : @"OO_COMPASSTYPE_ADVANCED";
499 break;
500
502 return OOJSValueFromCompassMode(context, [player compassMode]);
503
504 case kPlayerShip_hud:
505 result = [[player hud] hudName];
506 break;
507
509 result = [[player hud] crosshairDefinition];
510 break;
511
513 return OOJSValueFromBOOL([[player hud] allowBigGui]);
514
516 return OOJSValueFromBOOL([[player hud] isHidden]);
517
519 return OOJSValueFromBOOL([player weaponsOnline]);
520
522 return OOJSValueFromViewID(context, [UNIVERSE viewDirection]);
523
525 OOJS_RETURN_VECTOR([player viewpointOffsetAft]);
526
528 OOJS_RETURN_VECTOR([player viewpointOffsetForward]);
529
531 OOJS_RETURN_VECTOR([player viewpointOffsetPort]);
532
534 OOJS_RETURN_VECTOR([player viewpointOffsetStarboard]);
535
537 result = [player weaponTypeForFacing:[player currentWeaponFacing] strict:NO];
538 break;
539
541 return JS_NewNumber(context, [UNIVERSE tradeInValueForCommanderDictionary:[player commanderDataDictionary]]);
542
544 return JS_NewNumber(context, [player tradeInFactor]);
545
547 return JS_NewNumber(context, [player renovationCosts]);
548
550 return JS_NewNumber(context, [player renovationFactor]);
551
552 // make roll, pitch, yaw reported to JS use same +/- convention as
553 // for NPC ships
555 return JS_NewNumber(context, -[player flightPitch]);
556
557 case kPlayerShip_roll:
558 return JS_NewNumber(context, -[player flightRoll]);
559
560 case kPlayerShip_yaw:
561 return JS_NewNumber(context, -[player flightYaw]);
562
564 result = [[[UNIVERSE messageGUI] textColor] normalizedArray];
565 break;
566
568 result = [[[UNIVERSE messageGUI] textCommsColor] normalizedArray];
569 break;
570
571 default:
573 return OOJSNativeFailure(context);
574 }
575
576 return OOJSValueFromNativeObject(context, result);
577
579}
580
582{
583 OOJS_NATIVE_ENTER(context)
584
586 return JS_UNDEFINED;
587
589 double fValue;
590 int bValue;
591 int32_t iValue;
592 NSString* sValue = nil;
594 Vector vValue;
595 OOColor* colorForScript = nil;
596 Entity* eValue = nil;
597
598 switch (magic) {
600 if (JS_ToFloat64(context, &fValue, value) == 0) {
601 [player setFuelLeakRate:fValue];
602 return JS_UNDEFINED;
603 }
604 break;
605
607 if ((bValue = JS_ToBool(context, value)) >= 0) {
608 [player setMassLockable:bValue];
609 return JS_UNDEFINED;
610 }
611 break;
612
614 if ((bValue = JS_ToBool(context, value)) >= 0) {
615 [[player hud] setReticleTargetSensitive:bValue];
616 return JS_UNDEFINED;
617 }
618 break;
619
621 sValue = OOStringFromJSValue(context, value);
622 if (sValue != nil) {
624 if (chartMode > OOLRC_MODE_UNKNOWN) {
625 [player setLongRangeChartMode:chartMode];
626 [player doScriptEvent:OOJSID("chartHighlightModeChanged") withArgument:OOStringFromLongRangeChartMode([player longRangeChartMode])];
627 return JS_UNDEFINED;
628 } else {
629 OOJSReportError(context, @"Unknown chart hightlight mode specified - must be either OOLRC_MODE_SUNCOLOR, OOLRC_MODE_ECONOMY, OOLRC_MODE_GOVERNMENT or OOLRC_MODE_TECHLEVEL.");
630 }
631 }
632 return OOJSNativeFailure(context); // not reachable if successfully set
633 break;
634
636 sValue = OOStringFromJSValue(context, value);
637 if (sValue != nil) {
639 [player setCompassMode:mode];
640 [player validateCompassTarget];
641 return JS_UNDEFINED;
642 }
643 break;
644
646 sValue = OOStringFromJSValue(context, value);
647 if (sValue != nil) {
648 if ([sValue isEqualToString:@"OO_COMPASSTYPE_BASIC"]) {
649 [player setCompassMode:COMPASS_MODE_BASIC];
650 } else if ([sValue isEqualToString:@"OO_COMPASSTYPE_ADVANCED"]) {
651 if (![player hasEquipmentItemProviding:@"EQ_ADVANCED_COMPASS"]) {
652 OOJSReportWarning(context, @"Advanced Compass type requested and set but player ship does not carry the EQ_ADVANCED_COMPASS equipment or has it damaged.");
653 }
654 [player setCompassMode:COMPASS_MODE_PLANET];
655 } else {
656 OOJSReportError(context, @"Unknown compass type specified - must be either OO_COMPASSTYPE_BASIC or OO_COMPASSTYPE_ADVANCED.");
657 return OOJSNativeFailure(context);
658 }
659 return JS_UNDEFINED;
660 }
661 break;
662
664 // can't change compass target in basic mode
665 if (![player hasEquipmentItemProviding:@"EQ_ADVANCED_COMPASS"]) {
666 OOJSReportError(context, @"Compass target cannot be set with a basic compass.");
667 return OOJSNativeFailure(context);
668 }
669 // make sure we have a valid entity
670 if (!JS_IsNull(value) && JSValueToEntity(context, value, &eValue)) {
671 Entity* current = [player compassTarget];
672 [player setNextCompassMode];
673 [player validateCompassTarget];
674 // cycle the targets until we either get back to the start (entity not found) or we find the one we're looking for
675 while ([player compassTarget] != current && [player compassTarget] != eValue) {
676 [player setNextCompassMode];
677 [player validateCompassTarget];
678 }
679 // SpiderMonkey returned NO (stopping the script without an error) if the target wasn't found.
680 if ([player compassTarget] == current)
681 return OOJSNativeFailure(context);
682 return JS_UNDEFINED;
683 } else {
684 OOJSReportError(context, @"Invalid compass target entity provided.");
685 return OOJSNativeFailure(context);
686 }
687 break;
688
690 ghBehaviour = OOGalacticHyperspaceBehaviourFromJSValue(context, value);
691 if (ghBehaviour != GALACTIC_HYPERSPACE_BEHAVIOUR_UNKNOWN) {
692 [player setGalacticHyperspaceBehaviour:ghBehaviour];
693 return JS_UNDEFINED;
694 }
695 break;
696
698 if (JSValueToVector(context, value, &vValue)) {
699 NSPoint coords = { vValue.x, vValue.y };
700 [player setGalacticHyperspaceFixedCoords:coords];
701 return JS_UNDEFINED;
702 }
703 break;
704
706 if (JSValueToVector(context, value, &vValue)) {
707 NSPoint coords = OOInternalCoordinatesFromGalactic(vValue);
708 [player setGalacticHyperspaceFixedCoords:coords];
709 return JS_UNDEFINED;
710 }
711 break;
712
714 sValue = OOStringFromJSValue(context, value);
715 if (sValue != nil) {
716 [player setFastEquipmentA:sValue];
717 return JS_UNDEFINED;
718 }
719 break;
720
722 sValue = OOStringFromJSValue(context, value);
723 if (sValue != nil) {
724 [player setFastEquipmentB:sValue];
725 return JS_UNDEFINED;
726 }
727 break;
728
730 sValue = OOStringFromJSValue(context, value);
731 if (sValue != nil) {
732 // As before, failure stops the script without an error.
733 if (![player setPrimedEquipment:sValue showMessage:NO])
734 return OOJSNativeFailure(context);
735 return JS_UNDEFINED;
736 }
737 break;
738
740 if (JS_ToFloat64(context, &fValue, value) == 0) {
741 if (!isnan(fValue)) // guard against undefined
742 {
743 [player decrease_flight_pitch:[player flightPitch] + fValue];
744 }
745 return JS_UNDEFINED;
746 }
747 break;
748
749 case kPlayerShip_roll:
750 if (JS_ToFloat64(context, &fValue, value) == 0) {
751 if (!isnan(fValue)) // guard against undefined
752 {
753 [player decrease_flight_roll:[player flightRoll] + fValue];
754 }
755 return JS_UNDEFINED;
756 }
757 break;
758
759 case kPlayerShip_yaw:
760 if (JS_ToFloat64(context, &fValue, value) == 0) {
761 if (!isnan(fValue)) // guard against undefined
762 {
763 [player decrease_flight_yaw:[player flightYaw] + fValue];
764 }
765 return JS_UNDEFINED;
766 }
767 break;
768
770 if (JS_ToFloat64(context, &fValue, value) == 0) {
771 [player setForwardShieldLevel:fValue];
772 return JS_UNDEFINED;
773 }
774 break;
775
777 if (JS_ToFloat64(context, &fValue, value) == 0) {
778 [player setAftShieldLevel:fValue];
779 return JS_UNDEFINED;
780 }
781 break;
782
784 if (JS_ToFloat64(context, &fValue, value) == 0) {
785 [player setMaxForwardShieldLevel:fValue];
786 return JS_UNDEFINED;
787 }
788 break;
789
791 if (JS_ToFloat64(context, &fValue, value) == 0) {
792 [player setMaxAftShieldLevel:fValue];
793 return JS_UNDEFINED;
794 }
795 break;
796
798 if (JS_ToFloat64(context, &fValue, value) == 0) {
799 [player setForwardShieldRechargeRate:fValue];
800 return JS_UNDEFINED;
801 }
802 break;
803
805 if (JS_ToFloat64(context, &fValue, value) == 0) {
806 [player setAftShieldRechargeRate:fValue];
807 return JS_UNDEFINED;
808 }
809 break;
810
812 if ((bValue = JS_ToBool(context, value)) >= 0) {
813 [[player hud] setMinimalisticScanner:bValue];
814 return JS_UNDEFINED;
815 }
816 break;
817
819 if ((bValue = JS_ToBool(context, value)) >= 0) {
820 [[player hud] setNonlinearScanner:bValue];
821 return JS_UNDEFINED;
822 }
823 break;
824
826 if ((bValue = JS_ToBool(context, value)) >= 0) {
827 [[player hud] setScannerUltraZoom:bValue];
828 return JS_UNDEFINED;
829 }
830 break;
831
833 if ((bValue = JS_ToBool(context, value)) >= 0) {
834 [player setScoopOverride:bValue];
835 return JS_UNDEFINED;
836 }
837 break;
838
839 case kPlayerShip_hud:
840 sValue = OOStringFromJSValue(context, value);
841 if (sValue != nil) {
842 [player switchHudTo:sValue]; // EMMSTRAN: logged error should be a JS warning.
843 return JS_UNDEFINED;
844 } else {
845 [player resetHud];
846 return JS_UNDEFINED;
847 }
848 break;
849
851 sValue = OOStringFromJSValue(context, value);
852 if (sValue == nil) {
853 // reset HUD back to its plist settings
854 NSString* hud = [[[player hud] hudName] retain];
855 [player switchHudTo:hud];
856 [hud release];
857 return JS_UNDEFINED;
858 } else {
859 if (![[player hud] setCrosshairDefinition:sValue]) {
860 OOJSReportWarning(context, @"Crosshair definition file %@ not found or invalid", sValue);
861 }
862 return JS_UNDEFINED;
863 }
864 break;
865
867 if ((bValue = JS_ToBool(context, value)) >= 0) {
868 [[player hud] setHidden:bValue];
869 return JS_UNDEFINED;
870 }
871 break;
872
874 if (JS_ToFloat64(context, &fValue, value) == 0) {
875 int newLevel = (int)fValue;
876 [player adjustTradeInFactorBy:(newLevel - [player tradeInFactor])];
877 return JS_UNDEFINED;
878 }
879 /* The SpiderMonkey version fell through to currentWeapon here (which
880 removed the current weapon) if the conversion threw. Report the bad
881 value instead.
882 */
883 break;
884
886 BOOL exists = NO;
887 sValue = JSValueToEquipmentKeyRelaxed(context, value, &exists);
888 if (!exists || sValue == nil) {
889 sValue = @"EQ_WEAPON_NONE";
890 }
891 [player setWeaponMount:[player currentWeaponFacing] toWeapon:sValue inContext:@"scripted"];
892 return JS_UNDEFINED;
893 }
894
896 /* This first check is essential: if removed, it would be
897 * possible to make jumps of arbitrary length - CIM */
898 if ([player status] != STATUS_ENTERING_WITCHSPACE) {
899 /* These checks though similar are less important. The
900 * consequences of allowing jump destination to be set in
901 * flight are not as severe and do not allow the 7LY limit to
902 * be broken. Nevertheless, it is not allowed. - CIM */
903 // (except when compiled in debugging mode)
904#ifndef OO_DUMP_PLANETINFO
905 if (EXPECT_NOT([player status] != STATUS_DOCKED && [player status] != STATUS_LAUNCHING)) {
906 OOJSReportError(context, @"player.ship.targetSystem is read-only unless called when docked.");
907 return OOJSNativeFailure(context);
908 }
909#endif
910
911 if (OOJSValueToInt32(context, value, &iValue)) {
912 if (iValue >= 0 && iValue < OO_SYSTEMS_PER_GALAXY) {
913 [player setTargetSystemID:iValue];
914 return JS_UNDEFINED;
915 } else {
916 return OOJSNativeFailure(context);
917 }
918 }
919 /* The SpiderMonkey version fell through to infoSystem, which
920 converted the value again, failed again and reported the bad
921 value.
922 */
923 break;
924 } else {
925 OOJSReportError(context, @"player.ship.targetSystem is read-only unless called when docked.");
926 return OOJSNativeFailure(context);
927 }
928
930 if (OOJSValueToInt32(context, value, &iValue)) {
931 if (iValue >= 0 && iValue < OO_SYSTEMS_PER_GALAXY) {
932 [player setInfoSystemID:iValue moveChart:YES];
933 return JS_UNDEFINED;
934 } else {
935 return OOJSNativeFailure(context);
936 }
937 }
938 break;
939
941 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, value)];
942 if (colorForScript != nil || JS_IsNull(value)) {
943 [[UNIVERSE messageGUI] setTextColor:colorForScript];
944 return JS_UNDEFINED;
945 }
946 break;
947
949 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, value)];
950 if (colorForScript != nil || JS_IsNull(value)) {
951 [[UNIVERSE messageGUI] setTextCommsColor:colorForScript];
952 return JS_UNDEFINED;
953 }
954 break;
955
957 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, value)];
958 if (colorForScript != nil || JS_IsNull(value)) {
959 if (![[player hud] setReticleColorForIndex:OO_RETICLE_COLOR_TARGET toColor:colorForScript])
960 return OOJSNativeFailure(context);
961 return JS_UNDEFINED;
962 }
963 break;
964
966 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, value)];
967 if (colorForScript != nil || JS_IsNull(value)) {
968 if (![[player hud] setReticleColorForIndex:OO_RETICLE_COLOR_TARGET_SENSITIVE toColor:colorForScript])
969 return OOJSNativeFailure(context);
970 return JS_UNDEFINED;
971 }
972 break;
973
975 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, value)];
976 if (colorForScript != nil || JS_IsNull(value)) {
977 if (![[player hud] setReticleColorForIndex:OO_RETICLE_COLOR_WORMHOLE toColor:colorForScript])
978 return OOJSNativeFailure(context);
979 return JS_UNDEFINED;
980 }
981 break;
982
983 default:
985 return OOJSNativeFailure(context);
986 }
987
989 return OOJSNativeFailure(context);
990
992}
993
994// *** Methods ***
995
996// launch()
1009
1010// removeAllCargo()
1012{
1013 OOJS_NATIVE_ENTER(context)
1014
1017
1019
1020 if ([player isDocked]) {
1021 [player removeAllCargo];
1023 } else {
1024 OOJSReportError(context, @"PlayerShip.removeAllCargo only works when docked.");
1025 return OOJSNativeFailure(context);
1026 }
1027
1029}
1030
1031// useSpecialCargo(name : String)
1033{
1034 OOJS_NATIVE_ENTER(context)
1035
1038
1040 NSString* name = nil;
1041
1042 if (argc > 0)
1043 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1044 if (EXPECT_NOT(name == nil)) {
1045 OOJSReportBadArguments(context, @"PlayerShip", @"useSpecialCargo", MIN(argc, 1), OOJS_ARGV, nil, @"string (special cargo description)");
1046 return OOJSNativeFailure(context);
1047 }
1048
1049 [player useSpecialCargo:OOStringFromJSValue(context, OOJS_ARGV[0])];
1051
1053}
1054
1055// engageAutopilotToStation(stationForDocking : Station) : Boolean
1057{
1058 OOJS_NATIVE_ENTER(context)
1059
1062
1064 StationEntity* stationForDocking = nil;
1065
1066 if (argc > 0)
1067 stationForDocking = OOJSNativeObjectOfClassFromJSValue(context, OOJS_ARGV[0], [StationEntity class]);
1068 if (stationForDocking == nil) {
1069 OOJSReportBadArguments(context, @"PlayerShip", @"engageAutopilot", MIN(argc, 1), OOJS_ARGV, nil, @"station");
1070 return OOJSNativeFailure(context);
1071 }
1072
1073 OOJS_RETURN_BOOL([player engageAutopilotToStation:stationForDocking]);
1074
1076}
1077
1078// disengageAutopilot()
1091
1093{
1094 OOJS_NATIVE_ENTER(context)
1095
1098
1100 StationEntity* stationForDocking = nil;
1101
1102 if (argc > 0)
1103 stationForDocking = OOJSNativeObjectOfClassFromJSValue(context, OOJS_ARGV[0], [StationEntity class]);
1104 if (stationForDocking == nil) {
1105 OOJSReportBadArguments(context, @"PlayerShip", @"requestDockingClearance", MIN(argc, 1), OOJS_ARGV, nil, @"station");
1106 return OOJSNativeFailure(context);
1107 }
1108
1109 [player requestDockingClearance:stationForDocking];
1111
1113}
1114
1116{
1117 OOJS_NATIVE_ENTER(context)
1118
1121
1123 StationEntity* stationForDocking = nil;
1124
1125 if (argc > 0)
1126 stationForDocking = OOJSNativeObjectOfClassFromJSValue(context, OOJS_ARGV[0], [StationEntity class]);
1127 if (stationForDocking == nil) {
1128 OOJSReportBadArguments(context, @"PlayerShip", @"cancelDockingRequest", MIN(argc, 1), OOJS_ARGV, nil, @"station");
1129 return OOJSNativeFailure(context);
1130 }
1131
1132 [player cancelDockingRequest:stationForDocking];
1134
1136}
1137
1138// awardEquipmentToCurrentPylon(externalTank: equipmentInfoExpression) : Boolean
1140{
1141 OOJS_NATIVE_ENTER(context)
1142
1145
1147 NSString* key = nil;
1148 OOEquipmentType* eqType = nil;
1149
1150 if (argc > 0)
1151 key = JSValueToEquipmentKey(context, OOJS_ARGV[0]);
1152 if (key != nil)
1154 if (EXPECT_NOT(![eqType isMissileOrMine])) {
1155 OOJSReportBadArguments(context, @"PlayerShip", @"awardEquipmentToCurrentPylon", MIN(argc, 1), OOJS_ARGV, nil, @"equipment type (external store)");
1156 return OOJSNativeFailure(context);
1157 }
1158
1159 OOJS_RETURN_BOOL([player assignToActivePylon:key]);
1160
1162}
1163
1164// addPassenger(name: string, start: int, destination: int, ETA: double, fee: double) : Boolean
1166{
1167 OOJS_NATIVE_ENTER(context)
1168
1170 NSString* name = nil;
1171 OOSystemID start = 0, destination = 0;
1172 double eta = 0.0, fee = 0.0, advance = 0.0;
1173 unsigned risk = 0;
1174
1175 if (argc < 5) {
1176 OOJSReportBadArguments(context, @"PlayerShip", @"addPassenger", argc, OOJS_ARGV, nil, @"name, start, destination, ETA, fee");
1177 return OOJSNativeFailure(context);
1178 }
1179
1180 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1181 if (EXPECT_NOT(name == nil)) {
1182 OOJSReportBadArguments(context, @"PlayerShip", @"addPassenger", 1, &OOJS_ARGV[0], nil, @"string");
1183 return OOJSNativeFailure(context);
1184 }
1185
1186 if (!ValidateContracts(context, argc, OOJS_ARGV, NO, &start, &destination, &eta, &fee, &advance, @"addPassenger", &risk))
1187 return OOJSNativeFailure(context); // always go through validate contracts (passenger)
1188
1189 // Ensure there's space.
1190 if ([player passengerCount] >= [player passengerCapacity])
1191 OOJS_RETURN_BOOL(NO);
1192
1193 BOOL OK = [player addPassenger:name start:start destination:destination eta:eta fee:fee advance:advance risk:risk];
1194 OOJS_RETURN_BOOL(OK);
1195
1197}
1198
1199// removePassenger(name :string)
1201{
1202 OOJS_NATIVE_ENTER(context)
1203
1205 NSString* name = nil;
1206 BOOL OK = YES;
1207
1208 if (argc > 0)
1209 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1210 if (EXPECT_NOT(name == nil)) {
1211 OOJSReportBadArguments(context, @"PlayerShip", @"removePassenger", MIN(argc, 1), OOJS_ARGV, nil, @"string");
1212 return OOJSNativeFailure(context);
1213 }
1214
1215 OK = [player passengerCount] > 0 && [name length] > 0;
1216 if (OK)
1217 OK = [player removePassenger:name];
1218
1219 OOJS_RETURN_BOOL(OK);
1220
1222}
1223
1224// addParcel(description: string, start: int, destination: int, ETA: double, fee: double) : Boolean
1226{
1227 OOJS_NATIVE_ENTER(context)
1228
1230 NSString* name = nil;
1231 OOSystemID start = 0, destination = 0;
1232 double eta = 0.0, fee = 0.0, premium = 0.0;
1233 unsigned risk = 0;
1234
1235 if (argc < 5) {
1236 OOJSReportBadArguments(context, @"PlayerShip", @"addParcel", argc, OOJS_ARGV, nil, @"name, start, destination, ETA, fee");
1237 return OOJSNativeFailure(context);
1238 }
1239
1240 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1241 if (EXPECT_NOT(name == nil)) {
1242 OOJSReportBadArguments(context, @"PlayerShip", @"addParcel", 1, &OOJS_ARGV[0], nil, @"string");
1243 return OOJSNativeFailure(context);
1244 }
1245
1246 if (!ValidateContracts(context, argc, OOJS_ARGV, NO, &start, &destination, &eta, &fee, &premium, @"addParcel", &risk))
1247 return OOJSNativeFailure(context); // always go through validate contracts (passenger/parcel mode)
1248
1249 // Ensure there's space.
1250
1251 BOOL OK = [player addParcel:name start:start destination:destination eta:eta fee:fee premium:premium risk:risk];
1252 OOJS_RETURN_BOOL(OK);
1253
1255}
1256
1257// removeParcel(description :string)
1259{
1260 OOJS_NATIVE_ENTER(context)
1261
1263 NSString* name = nil;
1264 BOOL OK = YES;
1265
1266 if (argc > 0)
1267 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1268 if (EXPECT_NOT(name == nil)) {
1269 OOJSReportBadArguments(context, @"PlayerShip", @"removeParcel", MIN(argc, 1), OOJS_ARGV, nil, @"string");
1270 return OOJSNativeFailure(context);
1271 }
1272
1273 OK = [player parcelCount] > 0 && [name length] > 0;
1274 if (OK)
1275 OK = [player removeParcel:name];
1276
1277 OOJS_RETURN_BOOL(OK);
1278
1280}
1281
1282// awardContract(quantity: int, commodity: string, start: int, destination: int, eta: double, fee: double) : Boolean
1284{
1285 OOJS_NATIVE_ENTER(context)
1286
1288 NSString* key = nil;
1289 int32_t qty = 0;
1290 OOSystemID start = 0, destination = 0;
1291 double eta = 0.0, fee = 0.0, premium = 0.0;
1292
1293 if (argc < 6) {
1294 OOJSReportBadArguments(context, @"PlayerShip", @"awardContract", argc, OOJS_ARGV, nil, @"quantity, commodity, start, destination, ETA, fee");
1295 return OOJSNativeFailure(context);
1296 }
1297
1298 if (!OOJSValueToInt32(context, OOJS_ARGV[0], &qty)) {
1299 OOJSReportBadArguments(context, @"PlayerShip", @"awardContract", 1, &OOJS_ARGV[0], nil, @"positive integer (cargo quantity)");
1300 return OOJSNativeFailure(context);
1301 }
1302
1303 key = OOStringFromJSValue(context, OOJS_ARGV[1]);
1304 if (EXPECT_NOT(key == nil)) {
1305 OOJSReportBadArguments(context, @"PlayerShip", @"awardContract", 1, &OOJS_ARGV[1], nil, @"string (commodity identifier)");
1306 return OOJSNativeFailure(context);
1307 }
1308
1309 if (!ValidateContracts(context, argc, OOJS_ARGV, YES, &start, &destination, &eta, &fee, &premium, @"awardContract", NULL))
1310 return OOJSNativeFailure(context); // always go through validate contracts (cargo)
1311
1312 BOOL OK = [player awardContract:qty commodity:key start:start destination:destination eta:eta fee:fee premium:premium];
1313 OOJS_RETURN_BOOL(OK);
1314
1316}
1317
1318// removeContract(commodity: string, destination: int)
1320{
1321 OOJS_NATIVE_ENTER(context)
1322
1324 NSString* key = nil;
1325 int32_t dest = 0;
1326
1327 if (argc < 2) {
1328 OOJSReportBadArguments(context, @"PlayerShip", @"removeContract", argc, OOJS_ARGV, nil, @"commodity, destination");
1329 return OOJSNativeFailure(context);
1330 }
1331
1332 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1333
1334 if (EXPECT_NOT(key == nil)) {
1335 OOJSReportBadArguments(context, @"PlayerShip", @"removeContract", 1, &OOJS_ARGV[0], nil, @"string (commodity identifier)");
1336 return OOJSNativeFailure(context);
1337 }
1338
1339 if (!OOJSValueToInt32(context, OOJS_ARGV[1], &dest) || dest < 0 || dest > 255) {
1340 OOJSReportBadArguments(context, @"PlayerShip", @"removeContract", 1, &OOJS_ARGV[1], nil, @"system ID");
1341 return OOJSNativeFailure(context);
1342 }
1343
1344 BOOL OK = [player removeContract:key destination:(unsigned)dest];
1345 OOJS_RETURN_BOOL(OK);
1346
1348}
1349
1350// setCustomView(position:vector, orientation:quaternion [, weapon:string])
1352{
1353 OOJS_NATIVE_ENTER(context)
1354
1356
1357 if (argc < 2) {
1358 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomView", argc, OOJS_ARGV, nil, @"position, orientiation, [weapon]");
1359 return OOJSNativeFailure(context);
1360 }
1361
1362 // must be in custom view
1363 if ([UNIVERSE viewDirection] != VIEW_CUSTOM) {
1364 OOJSReportError(context, @"PlayerShip.setCustomView only works when custom view is active.");
1365 return OOJSNativeFailure(context);
1366 }
1367
1368 NSMutableDictionary* viewData = [NSMutableDictionary dictionaryWithCapacity:3];
1369
1370 Vector position = kZeroVector;
1371 BOOL gotpos = JSValueToVector(context, OOJS_ARGV[0], &position);
1372 if (!gotpos) {
1373 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomView", argc, OOJS_ARGV, nil, @"position, orientiation, [weapon]");
1374 return OOJSNativeFailure(context);
1375 }
1376 NSString* positionstr = [[NSString alloc] initWithFormat:@"%f %f %f", position.x, position.y, position.z];
1377
1378 Quaternion orientation = kIdentityQuaternion;
1379 BOOL gotquat = JSValueToQuaternion(context, OOJS_ARGV[1], &orientation);
1380 if (!gotquat) {
1381 [positionstr release]; // (Leaked in the SpiderMonkey version.)
1382 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomView", argc, OOJS_ARGV, nil, @"position, orientiation, [weapon]");
1383 return OOJSNativeFailure(context);
1384 }
1385 NSString* orientationstr = [[NSString alloc] initWithFormat:@"%f %f %f %f", orientation.w, orientation.x, orientation.y, orientation.z];
1386
1387 [viewData setObject:positionstr forKey:@"view_position"];
1388 [viewData setObject:orientationstr forKey:@"view_orientation"];
1389
1390 if (argc > 2) {
1391 NSString* facing = OOStringFromJSValue(context, OOJS_ARGV[2]);
1392 [viewData setObject:facing forKey:@"weapon_facing"];
1393 }
1394
1395 [player setCustomViewDataFromDictionary:viewData withScaling:NO];
1396 [player noteSwitchToView:VIEW_CUSTOM fromView:VIEW_CUSTOM];
1397
1398 [positionstr release];
1399 [orientationstr release];
1400
1401 OOJS_RETURN_BOOL(YES);
1403}
1404
1405// resetCustomView()
1407{
1408 OOJS_NATIVE_ENTER(context)
1409
1411
1412 // must be in custom view
1413 if ([UNIVERSE viewDirection] != VIEW_CUSTOM) {
1414 OOJSReportError(context, @"PlayerShip.setCustomView only works when custom view is active.");
1415 return OOJSNativeFailure(context);
1416 }
1417
1418 [player resetCustomView];
1419 [player noteSwitchToView:VIEW_CUSTOM fromView:VIEW_CUSTOM];
1420
1421 OOJS_RETURN_BOOL(YES);
1423}
1424
1425// resetScannerZoom()
1427{
1428 OOJS_NATIVE_ENTER(context)
1429
1431
1432 [player resetScannerZoom];
1433
1436}
1437
1438// takeInternalDamage()
1440{
1441 OOJS_NATIVE_ENTER(context)
1442
1444
1445 BOOL took = [player takeInternalDamage];
1446
1447 OOJS_RETURN_BOOL(took);
1449}
1450
1451// beginHyperspaceCountdown([int: spin_time])
1453{
1454 OOJS_NATIVE_ENTER(context)
1455
1457 int32_t spin_time;
1458 int32_t witchspaceSpinUpTime = 0;
1459 BOOL begun = NO;
1460 if (argc < 1) {
1461 witchspaceSpinUpTime = 0;
1462#ifdef OO_DUMP_PLANETINFO
1463 // quick intersystem jumps for debugging
1464 witchspaceSpinUpTime = 1;
1465#endif
1466 } else {
1467 if (!OOJSValueToInt32(context, OOJS_ARGV[0], &spin_time) || spin_time < 5 || spin_time > 60) {
1468 OOJSReportBadArguments(context, @"PlayerShip", @"beginHyperspaceCountdown", 1, &OOJS_ARGV[0], nil, @"between 5 and 60 seconds");
1469 return OOJSNativeFailure(context);
1470 }
1471 if (spin_time < 5) {
1472 witchspaceSpinUpTime = 5;
1473 } else {
1474 witchspaceSpinUpTime = spin_time;
1475 }
1476 }
1477 if ([player hasHyperspaceMotor] && [player status] == STATUS_IN_FLIGHT && [player witchJumpChecklist:false]) {
1478 [player beginWitchspaceCountdown:witchspaceSpinUpTime];
1479 begun = YES;
1480 }
1481 OOJS_RETURN_BOOL(begun);
1483}
1484
1485// cancelHyperspaceCountdown()
1487{
1488 OOJS_NATIVE_ENTER(context)
1489
1491
1492 BOOL cancelled = NO;
1493 if ([player hasHyperspaceMotor] && [player status] == STATUS_WITCHSPACE_COUNTDOWN) {
1495 [player setJumpType:false];
1496 cancelled = YES;
1497 }
1498
1499 OOJS_RETURN_BOOL(cancelled);
1501}
1502
1504{
1505 OOJS_NATIVE_ENTER(context)
1506
1508 int32_t spin_time;
1509 int32_t witchspaceSpinUpTime = 5;
1510 BOOL begun = NO;
1511 if (argc == 1) {
1512
1513 if (!OOJSValueToInt32(context, OOJS_ARGV[0], &spin_time) || spin_time < 5 || spin_time > 60) {
1514 OOJSReportBadArguments(context, @"PlayerShip", @"beginGalacticHyperspaceCountdown", 1, &OOJS_ARGV[0], nil, @"between 5 and 60 seconds");
1515 return OOJSNativeFailure(context);
1516 }
1517 if (spin_time < 5) {
1518 witchspaceSpinUpTime = 5;
1519 } else {
1520 witchspaceSpinUpTime = spin_time;
1521 }
1522 }
1523 if ([player hasEquipmentItemProviding:@"EQ_GAL_DRIVE"] && [player status] == STATUS_IN_FLIGHT && [player witchJumpChecklist:true]) {
1524 [player setJumpType:YES];
1525 [player setWitchspaceCountdown:witchspaceSpinUpTime];
1526 [player setStatus:STATUS_WITCHSPACE_COUNTDOWN];
1527 [player playGalacticHyperspace];
1528 // say it!
1529 [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"witch-galactic-in-f-seconds"), witchspaceSpinUpTime] forCount:1.0];
1530 begun = YES;
1531 }
1532 OOJS_RETURN_BOOL(begun);
1534}
1535
1536// setMultiFunctionDisplay(index,key)
1538{
1539 OOJS_NATIVE_ENTER(context)
1540
1541 NSString* key = nil;
1542 uint32_t index = 0;
1544 BOOL OK = YES;
1545
1546 if (argc > 0) {
1547 if (JS_ToUint32(context, &index, OOJS_ARGV[0]) != 0) {
1548 OOJSReportBadArguments(context, @"PlayerShip", @"setMultiFunctionDisplay", MIN(argc, 1), OOJS_ARGV, nil, @"number (index) [, string (key)]");
1549 return OOJSNativeFailure(context);
1550 }
1551 }
1552
1553 if (argc > 1) {
1554 key = OOStringFromJSValue(context, OOJS_ARGV[1]);
1555 }
1556
1557 OK = [player setMultiFunctionDisplay:index toKey:key];
1558
1559 OOJS_RETURN_BOOL(OK);
1560
1562}
1563
1564// setMultiFunctionText(key,value)
1566{
1567 OOJS_NATIVE_ENTER(context)
1568
1569 NSString* key = nil;
1570 NSString* value = nil;
1572 int reflow = NO;
1573
1574 if (argc > 0) {
1575 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1576 }
1577 if (key == nil) {
1578 OOJSReportBadArguments(context, @"PlayerShip", @"setMultiFunctionText", MIN(argc, 1), OOJS_ARGV, nil, @"string (key) [, string (text)]");
1579 return OOJSNativeFailure(context);
1580 }
1581 if (argc > 1) {
1582 value = OOStringFromJSValue(context, OOJS_ARGV[1]);
1583 }
1584 if (argc > 2 && EXPECT_NOT((reflow = JS_ToBool(context, OOJS_ARGV[2])) < 0)) {
1585 OOJSReportBadArguments(context, @"setMultiFunctionText", @"reflow", argc, OOJS_ARGV, nil, @"boolean");
1586 return OOJSNativeFailure(context);
1587 }
1588
1589 if (!reflow) {
1590 [player setMultiFunctionText:value forKey:key];
1591 } else {
1592 GuiDisplayGen* gui = [UNIVERSE gui];
1593 NSString* formatted = [gui reflowTextForMFD:value];
1594 [player setMultiFunctionText:formatted forKey:key];
1595 }
1596
1598
1600}
1601
1602// setPrimedEquipment(key, [noMessage])
1604{
1605 OOJS_NATIVE_ENTER(context)
1606
1607 NSString* key = nil;
1609 int showMsg = YES;
1610
1611 if (argc > 0) {
1612 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1613 }
1614 if (key == nil) {
1615 OOJSReportBadArguments(context, @"PlayerShip", @"setPrimedEquipment", MIN(argc, 1), OOJS_ARGV, nil, @"string (key)");
1616 return OOJSNativeFailure(context);
1617 }
1618 if (argc > 1 && EXPECT_NOT((showMsg = JS_ToBool(context, OOJS_ARGV[1])) < 0)) {
1619 OOJSReportBadArguments(context, @"PlayerShip", @"setPrimedEquipment", MIN(argc, 2), OOJS_ARGV, nil, @"boolean");
1620 return OOJSNativeFailure(context);
1621 }
1622
1623 OOJS_RETURN_BOOL([player setPrimedEquipment:key showMessage:showMsg]);
1624
1626}
1627
1628// setCustomHUDDial(key,value)
1630{
1631 OOJS_NATIVE_ENTER(context)
1632
1633 NSString* key = nil;
1634 id value = nil;
1636
1637 if (argc > 0) {
1638 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1639 }
1640 if (key == nil) {
1641 OOJSReportBadArguments(context, @"PlayerShip", @"setCustomHUDDial", MIN(argc, 1), OOJS_ARGV, nil, @"string (key), value]");
1642 return OOJSNativeFailure(context);
1643 }
1644 if (argc > 1) {
1645 value = OOJSNativeObjectFromJSValue(context, OOJS_ARGV[1]);
1646 } else {
1647 value = @"";
1648 }
1649
1650 [player setDialCustom:value forKey:key];
1651
1653
1655}
1656
1658{
1659 OOJS_NATIVE_ENTER(context)
1660
1661 NSString* key = nil;
1663
1664 if (argc > 0) {
1665 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1666 }
1667 if (key == nil) {
1668 OOJSReportBadArguments(context, @"PlayerShip", @"hideHUDSelector", MIN(argc, 1), OOJS_ARGV, nil, @"string (selector)");
1669 return OOJSNativeFailure(context);
1670 }
1671 [[player hud] setHiddenSelector:key hidden:YES];
1672
1674
1676}
1677
1679{
1680 OOJS_NATIVE_ENTER(context)
1681
1682 NSString* key = nil;
1684
1685 if (argc > 0) {
1686 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
1687 }
1688 if (key == nil) {
1689 OOJSReportBadArguments(context, @"PlayerShip", @"hideHUDSelector", MIN(argc, 1), OOJS_ARGV, nil, @"string (selector)");
1690 return OOJSNativeFailure(context);
1691 }
1692 [[player hud] setHiddenSelector:key hidden:NO];
1693
1695
1697}
1698
1699static BOOL ValidateContracts(JSContext* context, int argc, JSValueConst* argv, BOOL isCargo, OOSystemID* start, OOSystemID* destination, double* eta, double* fee, double* premium, NSString* functionName, unsigned* risk)
1700{
1702
1703 NSCParameterAssert(context != NULL && argv != NULL && start != NULL && destination != NULL && eta != NULL && fee != NULL);
1704
1705 uint32_t uValue;
1706 int offset = isCargo ? 2 : 1;
1707 double fValue;
1708 int32_t iValue;
1709
1710 if (!OOJSValueToInt32(context, argv[offset + 0], &iValue) || iValue < 0 || iValue > kOOMaximumSystemID) {
1711 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &argv[offset + 0], nil, @"system ID");
1712 return NO;
1713 }
1714 *start = iValue;
1715
1716 if (!OOJSValueToInt32(context, argv[offset + 1], &iValue) || iValue < 0 || iValue > kOOMaximumSystemID) {
1717 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &argv[offset + 1], nil, @"system ID");
1718 return NO;
1719 }
1720 *destination = iValue;
1721
1722 if (JS_ToFloat64(context, &fValue, argv[offset + 2]) != 0 || !isfinite(fValue) || fValue <= [PLAYER clockTime]) {
1723 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &argv[offset + 2], nil, @"number (future time)");
1724 return NO;
1725 }
1726 *eta = fValue;
1727
1728 if (JS_ToFloat64(context, &fValue, argv[offset + 3]) != 0 || !isfinite(fValue) || fValue < 0.0) {
1729 OOJSReportBadArguments(context, @"PlayerShip", functionName, 1, &argv[offset + 3], nil, @"number (credits quantity)");
1730 return NO;
1731 }
1732 *fee = fValue;
1733
1734 // Optional arguments: as before, invalid values are ignored. Don't leave a conversion error pending.
1735 if (argc > offset + 4) {
1736 if (JS_ToFloat64(context, &fValue, argv[offset + 4]) != 0)
1737 JS_FreeValue(context, JS_GetException(context));
1738 else if (isfinite(fValue) && fValue >= 0.0)
1739 *premium = fValue;
1740 }
1741
1742 if (!isCargo) {
1743 if (argc > offset + 5) {
1744 if (JS_ToUint32(context, &uValue, argv[offset + 5]) != 0)
1745 JS_FreeValue(context, JS_GetException(context));
1746 else
1747 *risk = uValue;
1748 }
1749 }
1750
1751 return YES;
1752
1754}
@ OO_RETICLE_COLOR_TARGET
@ OO_RETICLE_COLOR_WORMHOLE
@ OO_RETICLE_COLOR_TARGET_SENSITIVE
OOINLINE jsval OOJSValueFromGalacticHyperspaceBehaviour(JSContext *context, OOGalacticHyperspaceBehaviour value)
OOINLINE jsval OOJSValueFromViewID(JSContext *context, OOViewID value)
OOINLINE OOGalacticHyperspaceBehaviour OOGalacticHyperspaceBehaviourFromJSValue(JSContext *context, jsval value)
OOINLINE OOCompassMode OOCompassModeFromJSValue(JSContext *context, jsval value)
OOINLINE jsval OOJSValueFromCompassMode(JSContext *context, OOCompassMode value)
NSString * OOStringFromLongRangeChartMode(OOLongRangeChartMode chartMode)
OOLongRangeChartMode OOLongRangeChartModeFromString(NSString *string)
id OOConsumeReference(id OO_NS_CONSUMED value)
#define EXPECT_NOT(x)
#define OOJS_PROFILE_EXIT
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
#define OOJS_PROFILE_ENTER
OOINLINE BOOL OOIsPlayerStale(void)
Definition OOJSEntity.h:63
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:133
NSString * JSValueToEquipmentKeyRelaxed(JSContext *context, jsval value, BOOL *outExists)
NSString * JSValueToEquipmentKey(JSContext *context, jsval value)
static JSBool PlayerShipSetPrimedEquipment(JSContext *context, uintN argc, jsval *vp)
static JSFunctionSpec sPlayerShipMethods[]
static JSBool PlayerShipEngageAutopilotToStation(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAddParcel(JSContext *context, uintN argc, jsval *vp)
static JSClass sPlayerShipClass
static JSBool PlayerShipBeginHyperspaceCountdown(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetCustomView(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipTakeInternalDamage(JSContext *context, uintN argc, jsval *vp)
static BOOL ValidateContracts(JSContext *context, uintN argc, jsval *vp, BOOL isCargo, OOSystemID *start, OOSystemID *destination, double *eta, double *fee, double *premium, NSString *functionName, unsigned *risk)
static JSBool PlayerShipResetScannerZoom(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipHideHUDSelector(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetCustomHUDDial(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipUseSpecialCargo(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipCancelDockingRequest(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveContract(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemoveAllCargo(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAddPassenger(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipResetCustomView(JSContext *context, uintN argc, jsval *vp)
JSObject * JSPlayerShipObject(void)
static JSBool PlayerShipAwardContract(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool PlayerShipRemoveParcel(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipDisengageAutopilot(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRemovePassenger(JSContext *context, uintN argc, jsval *vp)
@ kPlayerShip_docked
@ kPlayerShip_compassMode
@ kPlayerShip_serviceLevel
@ kPlayerShip_cursorCoordinates
@ kPlayerShip_reticleTargetSensitive
@ kPlayerShip_maxForwardShield
@ kPlayerShip_dockedStation
@ kPlayerShip_targetSystem
@ kPlayerShip_roll
@ kPlayerShip_massLockable
@ kPlayerShip_scannerNonLinear
@ kPlayerShip_hud
@ kPlayerShip_injectorsEngaged
@ kPlayerShip_activeMissile
@ kPlayerShip_galacticHyperspaceBehaviour
@ kPlayerShip_fuelLeakRate
@ kPlayerShip_viewPositionAft
@ kPlayerShip_cursorCoordinatesInLY
@ kPlayerShip_torusEngaged
@ kPlayerShip_reticleColorTargetSensitive
@ kPlayerShip_aftShield
@ kPlayerShip_chartHightlightMode
@ kPlayerShip_yaw
@ kPlayerShip_scoopOverride
@ kPlayerShip_currentWeapon
@ kPlayerShip_missilesOnline
@ kPlayerShip_pitch
@ kPlayerShip_fastEquipmentA
@ kPlayerShip_messageGuiTextCommsColor
@ kPlayerShip_multiFunctionDisplayList
@ kPlayerShip_price
@ kPlayerShip_viewPositionForward
@ kPlayerShip_galaxyCoordinates
@ kPlayerShip_compassType
@ kPlayerShip_compassTarget
@ kPlayerShip_galaxyCoordinatesInLY
@ kPlayerShip_infoSystem
@ kPlayerShip_multiFunctionDisplays
@ kPlayerShip_galacticHyperspaceFixedCoordsInLY
@ kPlayerShip_fastEquipmentB
@ kPlayerShip_nextSystem
@ kPlayerShip_scannerUltraZoom
@ kPlayerShip_viewPositionStarboard
@ kPlayerShip_messageGuiTextColor
@ kPlayerShip_renovationCost
@ kPlayerShip_crosshairs
@ kPlayerShip_scannerMinimalistic
@ kPlayerShip_routeMode
@ kPlayerShip_galacticHyperspaceFixedCoords
@ kPlayerShip_weaponsOnline
@ kPlayerShip_reticleColorTarget
@ kPlayerShip_maxAftShield
@ kPlayerShip_viewPositionPort
@ kPlayerShip_hudAllowsBigGui
@ kPlayerShip_specialCargo
@ kPlayerShip_forwardShieldRechargeRate
@ kPlayerShip_viewDirection
@ kPlayerShip_reticleColorWormhole
@ kPlayerShip_forwardShield
@ kPlayerShip_primedEquipment
@ kPlayerShip_aftShieldRechargeRate
@ kPlayerShip_hudHidden
@ kPlayerShip_renovationMultiplier
@ kPlayerShip_previousSystem
void InitOOJSPlayerShip(JSContext *context, JSObject *global)
static JSBool PlayerShipShowHUDSelector(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetMultiFunctionText(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipRequestDockingClearance(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSPropertySpec sPlayerShipProperties[]
static JSBool PlayerShipBeginGalacticHyperspaceCountdown(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipSetMultiFunctionDisplay(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipLaunch(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipCancelHyperspaceCountdown(JSContext *context, uintN argc, jsval *vp)
static JSBool PlayerShipAwardEquipmentToCurrentPylon(JSContext *context, uintN argc, jsval *vp)
JSObject * JSPlayerObject(void)
Definition OOJSPlayer.m:170
PlayerEntity * OOPlayerForScripting(void)
Definition OOJSPlayer.m:175
BOOL JSValueToQuaternion(JSContext *context, jsval value, Quaternion *outQuaternion) NONNULL_FUNC
BOOL JSValueToVector(JSContext *context, jsval value, Vector *outVector) NONNULL_FUNC
Definition OOJSVector.m:341
BOOL NSPointToVectorJSValue(JSContext *context, NSPoint point, jsval *outValue) NONNULL_FUNC
Definition OOJSVector.m:328
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
void OOJSReportWarning(JSContext *context, NSString *format,...)
#define OOJS_RETURN_WITH_HELPER(helper, value)
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
#define OOJS_RETURN_BOOL(v)
OOINLINE BOOL OOJSValueToInt32(JSContext *context, jsval value, int32_t *outValue)
id OOJSNativeObjectOfClassFromJSValue(JSContext *context, jsval value, Class requiredClass)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READONLY
void OOJSRegisterSubclass(JSClass *subclass, JSClass *superclass)
OOINLINE JSContext * OOJSAcquireContext(void)
void OOJSReportError(JSContext *context, NSString *format,...)
#define OOJS_ARGV
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
OOINLINE void OOJSRelinquishContext(JSContext *context)
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define OOJS_RETURN_VOID
#define OOJS_RETURN_VECTOR(value)
#define MIN(A, B)
Definition OOMaths.h:91
return nil
const Quaternion kIdentityQuaternion
#define OO_SYSTEMS_PER_GALAXY
OOLongRangeChartMode
Definition OOTypes.h:45
@ kOOMaximumSystemID
Definition OOTypes.h:187
OORouteType
Definition OOTypes.h:31
@ OPTIMIZED_BY_NONE
Definition OOTypes.h:32
@ OPTIMIZED_BY_JUMPS
Definition OOTypes.h:33
@ OPTIMIZED_BY_TIME
Definition OOTypes.h:34
int16_t OOSystemID
Definition OOTypes.h:183
OOCompassMode
Definition OOTypes.h:129
const Vector kZeroVector
Definition OOVector.m:27
NSPoint OOInternalCoordinatesFromGalactic(Vector galacticCoordinates)
Vector OOGalacticCoordinatesFromInternal(NSPoint internalCoordinates)
OOGalacticHyperspaceBehaviour
#define PLAYER
static JSClassID sPlayerShipClassID
JSClassID JSPlayerShipClassID(void)
JSClassID JSShipClassID(void)
Definition OOJSShip.m:576
#define OOJS_PROPERTY_RW(name, getter, setter, magic)
JSValue OOJSNativeFailure(JSContext *context)
JSClassID OOJSRegisterClass(JSClassID *ioClassID, const JSClassDef *classDef)
Definition OOJSClasses.m:61
#define OOJS_SETTER_ARGS
#define OOJS_PROPERTY_RO(name, getter, magic)
JSValueConst OOJSInitClass(JSContext *context, JSValueConst global, JSClassID classID, JSValueConst parentPrototype, JSCFunction *constructor, int constructorArgCount, const JSCFunctionListEntry *properties, size_t propertyCount, const JSCFunctionListEntry *methods, size_t methodCount, const JSCFunctionListEntry *staticMethods, size_t staticMethodCount)
#define OOJS_GETTER_ARGS
#define OOJS_NATIVE_ARGS
#define OOJS_COUNT(array)
#define UNIVERSE
Definition Universe.h:827
NSString * reflowTextForMFD:(NSString *input)
void setHidden:(BOOL newValue)
void setReticleTargetSensitive:(BOOL newReticleTargetSensitiveValue)
void setNonlinearScanner:(BOOL newValue)
NSString * hudName
void setScannerUltraZoom:(BOOL newValue)
NSString * crosshairDefinition
void setHiddenSelector:hidden:(NSString *selectorName,[hidden] BOOL hide)
OOColor * reticleColorForIndex:(NSUInteger idx)
void setMinimalisticScanner:(BOOL newValue)
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135
NSArray * normalizedArray()
Definition OOColor.m:465
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
OOJavaScriptEngine * sharedEngine()
void setNextCompassMode()
void setMaxAftShieldLevel:(float new)
void setForwardShieldLevel:(GLfloat level)
BOOL setMultiFunctionDisplay:toKey:(NSUInteger index,[toKey] NSString *key)
void setMultiFunctionText:forKey:(NSString *text,[forKey] NSString *key)
void setAftShieldRechargeRate:(float new)
OOWeakReference * compassTarget
void setAftShieldLevel:(GLfloat level)
OOLongRangeChartMode longRangeChartMode
NSUInteger passengerCount()
void setGalacticHyperspaceFixedCoords:(NSPoint point)
StationEntity * dockedStation()
NSString * specialCargo
void useSpecialCargo:(NSString *descriptionString)
BOOL switchHudTo:(NSString *hudFileName)
void setJSSelf:context:(JSObject *val,[context] JSContext *context)
void setFastEquipmentA:(NSString *eqKey)
OORouteType ANAMode()
void setFastEquipmentB:(NSString *eqKey)
void beginWitchspaceCountdown:(int spin_time)
BOOL setWeaponMount:toWeapon:inContext:(OOWeaponFacing facing,[toWeapon] NSString *eqKey,[inContext] NSString *context)
BOOL removeParcel:(NSString *Name)
void setInfoSystemID:moveChart:(OOSystemID sid,[moveChart] BOOL moveChart)
void cancelDockingRequest:(StationEntity *stationForDocking)
BOOL addPassenger:start:destination:eta:fee:advance:risk:(NSString *Name,[start] unsigned start,[destination] unsigned destination,[eta] double eta,[fee] double fee,[advance] double advance,[risk] unsigned risk)
BOOL takeInternalDamage()
NSUInteger parcelCount()
void setDialCustom:forKey:(id value,[forKey] NSString *key)
NSString * fastEquipmentA()
NSString * currentPrimedEquipment()
NSArray * multiFunctionDisplayList()
void setFuelLeakRate:(float value)
void setJumpType:(BOOL isGalacticJump)
HeadUpDisplay * hud
void setLongRangeChartMode:(OOLongRangeChartMode mode)
BOOL addParcel:start:destination:eta:fee:premium:risk:(NSString *Name,[start] unsigned start,[destination] unsigned destination,[eta] double eta,[fee] double fee,[premium] double premium,[risk] unsigned risk)
void setCompassMode:(OOCompassMode value)
void setScoopOverride:(BOOL newValue)
NSString * fastEquipmentB()
void disengageAutopilot()
void validateCompassTarget()
void setGalacticHyperspaceBehaviour:(OOGalacticHyperspaceBehaviour galacticHyperspaceBehaviour)
BOOL removePassenger:(NSString *Name)
void setWitchspaceCountdown:(int spin_time)
BOOL awardContract:commodity:start:destination:eta:fee:premium:(unsigned qty,[commodity] NSString *commodity,[start] unsigned start,[destination] unsigned destination,[eta] double eta,[fee] double fee,[premium] double premium)
BOOL removeContract:destination:(NSString *commodity,[destination] unsigned destination)
void setCustomViewDataFromDictionary:withScaling:(NSDictionary *viewDict,[withScaling] BOOL withScaling)
void requestDockingClearance:(StationEntity *stationForDocking)
void noteSwitchToView:fromView:(OOViewID toView,[fromView] OOViewID fromView)
void adjustTradeInFactorBy:(int value)
OOCompassMode compassMode
void setForwardShieldRechargeRate:(float new)
void setMassLockable:(BOOL newValue)
OOEquipmentType * weaponTypeForFacing:strict:(OOWeaponFacing facing, [strict] BOOL strict)
PlayerEntity * sharedPlayer()
void setTargetSystemID:(OOSystemID sid)
void setMaxForwardShieldLevel:(float new)
void decrease_flight_roll:(double delta)
OOWeaponFacing currentWeaponFacing
void setStatus:(OOEntityStatus stat)
void decrease_flight_yaw:(double delta)
GLfloat flightPitch
void doScriptEvent:withArgument:(OOJSPropID message,[withArgument] id argument)
void decrease_flight_pitch:(double delta)
GLfloat flightRoll
GLfloat flightYaw
voidpf uLong offset
Definition ioapi.h:132
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const char int mode
Definition ioapi.h:125
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33