38@implementation PlayerEntity (ScriptMethods)
46- (void) setScore:(
unsigned)value
58- (void) setCreditBalance:(
double)value
66 return [[
self dockedStation] name];
72 return [[
self dockedStation] displayName];
78 return [
self status] == STATUS_DOCKED && [
self dockedStation] == [UNIVERSE station];
86 if (![[
UNIVERSE commodities] goodDefined:type])
91 OOLog(
@"script.debug.note.awardCargo",
@"Going to award cargo: %d x '%@'", amount, type);
93 unit = [shipCommodityData massUnitForGood:type];
95 if ([
self status] != STATUS_DOCKED)
105 [shipCommodityData addQuantity:amount forGood:type];
112 int smaller_quantity = 1 + ((amount - 1) % amount_per_container);
113 if ([cargo
count] < [
self maxAvailableCargoSpace])
115 ShipEntity* container = [UNIVERSE newShipWithRole:@"1t-cargopod"];
123 [cargo addObject:container];
127 amount -= smaller_quantity;
131 else if (!specialCargo)
137 if ([cargo
count] < [
self maxAvailableCargoSpace])
139 ShipEntity* container = [UNIVERSE newShipWithRole:@"1t-cargopod"];
147 [cargo addObject:container];
159 int manifest_quantity = [shipCommodityData quantityForGood:type];
160 while ((amount)&&(current_cargo < [
self maxAvailableCargoSpace]))
166 [shipCommodityData setQuantity:manifest_quantity forGood:type];
168 [
self calculateCurrentCargo];
180 return galaxy_number;
187 return [UNIVERSE currentSystemID];
191- (void) setMissionChoice:(NSString *)newChoice
193 [
self setMissionChoice:newChoice keyPress:@"" withEvent:YES];
197- (void) setMissionChoice:(NSString *)newChoice withEvent:(BOOL)withEvent
199 [
self setMissionChoice:newChoice keyPress:@"" withEvent:withEvent];
203- (void) setMissionChoice:(NSString *)newChoice keyPress:(NSString *)keyPress
205 [
self setMissionChoice:newChoice keyPress:keyPress withEvent:YES];
209- (void) setMissionChoice:(NSString *)newChoice keyPress:(NSString *)keyPress withEvent:(BOOL)withEvent
211 BOOL equal = [newChoice isEqualToString:missionChoice] || (newChoice == missionChoice);
214 if (newChoice ==
nil)
216 NSString *oldChoice = missionChoice;
217 [missionChoice autorelease];
219 if (withEvent) [
self doScriptEvent:OOJSID("missionChoiceWasReset") withArgument:oldChoice];
223 [missionChoice autorelease];
224 missionChoice = [newChoice copy];
227 equal = [keyPress isEqualToString:missionKeyPress] || (keyPress == missionKeyPress);
230 [missionKeyPress autorelease];
231 missionKeyPress = [keyPress copy];
238 _missionAllowInterrupt = YES;
272 a = (a << 16) | (b << 8) | c;
273 return (
double)a / (double)0x01000000;
278- (NSDictionary *) passengerContractMarker:(
OOSystemID)system
280 return [[[NSDictionary dictionaryWithObjectsAndKeys:
281 [NSNumber numberWithInt:system], @"system",
282 MISSION_DEST_LEGACY, @"name",
283 @"orangeColor", @"markerColor",
284 @"MARKER_DIAMOND", @"markerShape",
285 nil] retain] autorelease];
289- (NSDictionary *) parcelContractMarker:(
OOSystemID)system
291 return [[[NSDictionary dictionaryWithObjectsAndKeys:
292 [NSNumber numberWithInt:system], @"system",
293 MISSION_DEST_LEGACY, @"name",
294 @"orangeColor", @"markerColor",
295 @"MARKER_PLUS", @"markerShape",
296 nil] retain] autorelease];
300- (NSDictionary *) cargoContractMarker:(
OOSystemID)system
302 return [[[NSDictionary dictionaryWithObjectsAndKeys:
303 [NSNumber numberWithInt:system], @"system",
304 MISSION_DEST_LEGACY, @"name",
305 @"orangeColor", @"markerColor",
306 @"MARKER_SQUARE", @"markerShape",
307 nil] retain] autorelease];
311- (NSDictionary *) defaultMarker:(
OOSystemID)system
313 return [[[NSDictionary dictionaryWithObjectsAndKeys:
314 [NSNumber numberWithInt:system], @"system",
315 MISSION_DEST_LEGACY, @"name",
316 @"redColor", @"markerColor",
317 @"MARKER_X", @"markerShape",
318 nil] retain] autorelease];
322- (NSDictionary *) validatedMarker:(NSDictionary *)marker
324 OOSystemID dest = [marker oo_intForKey:@"system"];
330 NSString *group = [marker oo_stringForKey:@"name" defaultValue:MISSION_DEST_LEGACY];
332 return [[[NSDictionary dictionaryWithObjectsAndKeys:
333 [NSNumber numberWithInt:dest], @"system",
335 [marker oo_stringForKey:@"markerColor" defaultValue:@"redColor"], @"markerColor",
336 [marker oo_stringForKey:@"markerShape" defaultValue:@"MARKER_X"], @"markerShape",
337 [NSNumber numberWithFloat:[marker oo_floatForKey:@"markerScale" defaultValue:1.0]], @"markerScale",
338 nil] retain] autorelease];
359 unsigned long long integerCredits = tenthsOfCredits / 10;
360 unsigned long long tenths = tenthsOfCredits % 10;
362 return [NSString stringWithFormat:@"%llu.%llu", integerCredits, tenths];
369 return [NSString stringWithFormat:@"%i", [
self legalStatus]];
376 return [NSString stringWithFormat:@"%i", [
self score]];
381- (NSString *) keyBindingDescription2:(NSString *)binding
383 if ([keyconfig2_settings objectForKey:binding] ==
nil)
388 NSArray *keyList = (NSArray*)[keyconfig2_settings objectForKey:binding];
389 return [
self getKeyBindingDescription:keyList];
393- (NSString *) getKeyBindingDescription:(NSArray *) keyList
396 NSMutableString *
final = [NSMutableString string];
397 for (i = 0; i < [keyList count]; i++) {
398 if (i != 0)
final = [NSMutableString stringWithFormat:
@"%@ or ",
final];
399 NSDictionary *def = [keyList objectAtIndex:i];
400 NSString *key = [def objectForKey:@"key"];
402 NSString *desc = [
self keyCodeDescription:k_int];
405 if ([[def objectForKey:
@"mod2"] boolValue] == YES)
final = [NSMutableString stringWithFormat:@"%@%@+", final, keyMod2Text];
406 if ([[def objectForKey:
@"mod1"] boolValue] == YES)
final = [NSMutableString stringWithFormat:@"%@%@+", final, keyMod1Text];
407 if ([[def objectForKey:
@"shift"] boolValue] == YES)
final = [NSMutableString stringWithFormat:@"%@%@+", final, keyShiftText];
408 final = [NSMutableString stringWithFormat:@"%@%@", final, desc];
415- (NSString *) keyCodeDescription:(
OOKeyCode)code
420 return DESC(
@"oolite-keycode-unset");
422 return DESC(
@"oolite-keycode-tab");
424 return DESC(
@"oolite-keycode-enter");
426 return DESC(
@"oolite-keycode-esc");
428 return DESC(
@"oolite-keycode-space");
430 return DESC(
@"oolite-keycode-f1");
432 return DESC(
@"oolite-keycode-f2");
434 return DESC(
@"oolite-keycode-f3");
436 return DESC(
@"oolite-keycode-f4");
438 return DESC(
@"oolite-keycode-f5");
440 return DESC(
@"oolite-keycode-f6");
442 return DESC(
@"oolite-keycode-f7");
444 return DESC(
@"oolite-keycode-f8");
446 return DESC(
@"oolite-keycode-f9");
448 return DESC(
@"oolite-keycode-f10");
450 return DESC(
@"oolite-keycode-f11");
452 return DESC(
@"oolite-keycode-right");
454 return DESC(
@"oolite-keycode-left");
456 return DESC(
@"oolite-keycode-down");
458 return DESC(
@"oolite-keycode-up");
460 return DESC(
@"oolite-keycode-home");
462 return DESC(
@"oolite-keycode-end");
464 return DESC(
@"oolite-keycode-insert");
466 return DESC(
@"oolite-keycode-delete");
468 return DESC(
@"oolite-keycode-pageup");
470 return DESC(
@"oolite-keycode-pagedown");
472 return DESC(
@"oolite-keycode-numpad0");
474 return DESC(
@"oolite-keycode-numpad1");
476 return DESC(
@"oolite-keycode-numpad2");
478 return DESC(
@"oolite-keycode-numpad3");
480 return DESC(
@"oolite-keycode-numpad4");
482 return DESC(
@"oolite-keycode-numpad5");
484 return DESC(
@"oolite-keycode-numpad6");
486 return DESC(
@"oolite-keycode-numpad7");
488 return DESC(
@"oolite-keycode-numpad8");
490 return DESC(
@"oolite-keycode-numpad9");
492 return DESC(
@"oolite-keycode-printscreen");
494 return DESC(
@"oolite-keycode-pause");
496 return DESC(
@"oolite-keycode-numpad/");
498 return DESC(
@"oolite-keycode-numpad=");
500 return DESC(
@"oolite-keycode-numpad-");
502 return DESC(
@"oolite-keycode-numpad*");
504 return DESC(
@"oolite-keycode-numpad.");
506 return DESC(
@"oolite-keycode-numpad+");
508 return DESC(
@"oolite-keycode-numpadenter");
511 return [NSString stringWithFormat:@"%C",code];
515- (NSString *) keyCodeDescriptionShort:(
OOKeyCode)code
520 return DESC(
@"oolite-keycode-short-unset");
522 return DESC(
@"oolite-keycode-short-tab");
524 return DESC(
@"oolite-keycode-short-enter");
526 return DESC(
@"oolite-keycode-short-esc");
528 return DESC(
@"oolite-keycode-short-space");
530 return DESC(
@"oolite-keycode-short-f1");
532 return DESC(
@"oolite-keycode-short-f2");
534 return DESC(
@"oolite-keycode-short-f3");
536 return DESC(
@"oolite-keycode-short-f4");
538 return DESC(
@"oolite-keycode-short-f5");
540 return DESC(
@"oolite-keycode-short-f6");
542 return DESC(
@"oolite-keycode-short-f7");
544 return DESC(
@"oolite-keycode-short-f8");
546 return DESC(
@"oolite-keycode-short-f9");
548 return DESC(
@"oolite-keycode-short-f10");
550 return DESC(
@"oolite-keycode-short-f11");
552 return DESC(
@"oolite-keycode-short-right");
554 return DESC(
@"oolite-keycode-short-left");
556 return DESC(
@"oolite-keycode-short-down");
558 return DESC(
@"oolite-keycode-short-up");
560 return DESC(
@"oolite-keycode-short-home");
562 return DESC(
@"oolite-keycode-short-end");
564 return DESC(
@"oolite-keycode-short-insert");
566 return DESC(
@"oolite-keycode-short-delete");
568 return DESC(
@"oolite-keycode-short-pageup");
570 return DESC(
@"oolite-keycode-short-pagedown");
572 return DESC(
@"oolite-keycode-short-numpad0");
574 return DESC(
@"oolite-keycode-short-numpad1");
576 return DESC(
@"oolite-keycode-short-numpad2");
578 return DESC(
@"oolite-keycode-short-numpad3");
580 return DESC(
@"oolite-keycode-short-numpad4");
582 return DESC(
@"oolite-keycode-short-numpad5");
584 return DESC(
@"oolite-keycode-short-numpad6");
586 return DESC(
@"oolite-keycode-short-numpad7");
588 return DESC(
@"oolite-keycode-short-numpad8");
590 return DESC(
@"oolite-keycode-short-numpad9");
592 return DESC(
@"oolite-keycode-short-printscreen");
594 return DESC(
@"oolite-keycode-short-pause");
596 return DESC(
@"oolite-keycode-short-numpad/");
598 return DESC(
@"oolite-keycode-short-numpad=");
600 return DESC(
@"oolite-keycode-short-numpad-");
602 return DESC(
@"oolite-keycode-short-numpad*");
604 return DESC(
@"oolite-keycode-short-numpad.");
606 return DESC(
@"oolite-keycode-short-numpad+");
608 return DESC(
@"oolite-keycode-short-numpadenter");
610 return [NSString stringWithFormat:@"%C",code];
619 return (Vector){ (float)internalCoordinates.x * 0.4f, (
float)internalCoordinates.y * 0.2f, 0.0f };
625 return (NSPoint){ (float)galacticCoordinates.x * 2.5f, (
float)galacticCoordinates.y * 5.0f };
#define OOLog(class, format,...)
NSString * OOStringFromDeciCredits(OOCreditsQuantity tenthsOfCredits, BOOL includeDecimal, BOOL includeSymbol)
NSString * OOCommodityType
uint64_t OOCreditsQuantity
OOCreditsQuantity OODeciCreditsFromDouble(double doubleDeciCredits)
NSPoint OOInternalCoordinatesFromGalactic(Vector galacticCoordinates)
Vector OOGalacticCoordinatesFromInternal(NSPoint internalCoordinates)
#define SCANNER_ZOOM_RATE_DOWN
void allowMissionInterrupt()
NSString * commanderKillsAsString()
OOTimeDelta scriptTimer()
unsigned systemPseudoRandom256()
BOOL dockedAtMainStation()
NSString * dockedStationName()
NSString * dockedStationDisplayName()
NSString * commanderBountyAsString()
OOSystemID currentSystemID()
double systemPseudoRandomFloat()
NSString * creditsFormattedForSubstitution()
OOGalaxyID currentGalaxyID()
unsigned systemPseudoRandom100()
NSString * creditsFormattedForLegacySubstitution()
void setScanClass:(OOScanClass sClass)
void setStatus:(OOEntityStatus stat)
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)
void seed_RNG_only_for_planet_description(Random_Seed s_seed)