38@implementation PlayerEntity (ScriptMethods)
45- (void)setScore:(
unsigned)value
55- (void)setCreditBalance:(
double)value
79 if (![[
UNIVERSE commodities] goodDefined:type]) {
83 OOLog(
@"script.debug.note.awardCargo",
@"Going to award cargo: %d x '%@'", amount, type);
87 if ([
self status] != STATUS_DOCKED) {
97 int smaller_quantity = 1 + ((amount - 1) % amount_per_container);
98 if ([cargo
count] < [
self maxAvailableCargoSpace]) {
99 ShipEntity* container = [UNIVERSE newShipWithRole:@"1t-cargopod"];
106 [
cargo addObject:container];
110 amount -= smaller_quantity;
113 }
else if (!specialCargo)
118 if ([cargo
count] < [
self maxAvailableCargoSpace]) {
119 ShipEntity* container = [UNIVERSE newShipWithRole:@"1t-cargopod"];
126 [
cargo addObject:container];
137 while ((amount) && (current_cargo < [
self maxAvailableCargoSpace])) {
155 return galaxy_number;
162 return [UNIVERSE currentSystemID];
165- (void)setMissionChoice:(NSString*)newChoice
170- (void)setMissionChoice:(NSString*)newChoice withEvent:(BOOL)withEvent
175- (void)setMissionChoice:(NSString*)newChoice keyPress:(NSString*)keyPress
180- (void)setMissionChoice:(NSString*)newChoice keyPress:(NSString*)keyPress withEvent:(BOOL)withEvent
182 BOOL equal = [
newChoice isEqualToString:missionChoice] || (newChoice == missionChoice);
184 if (newChoice ==
nil) {
185 NSString* oldChoice = missionChoice;
195 equal = [
keyPress isEqualToString:missionKeyPress] || (keyPress == missionKeyPress);
204 _missionAllowInterrupt = YES;
234 a = (a << 16) | (b << 8) | c;
235 return (
double)a / (double)0x01000000;
241 [
NSNumber numberWithInt:system], @"system",
242 MISSION_DEST_LEGACY, @"name",
243 @"orangeColor", @"markerColor",
244 @"MARKER_DIAMOND", @"markerShape",
245 nil] retain] autorelease];
251 [
NSNumber numberWithInt:system], @"system",
252 MISSION_DEST_LEGACY, @"name",
253 @"orangeColor", @"markerColor",
254 @"MARKER_PLUS", @"markerShape",
255 nil] retain] autorelease];
261 [
NSNumber numberWithInt:system], @"system",
262 MISSION_DEST_LEGACY, @"name",
263 @"orangeColor", @"markerColor",
264 @"MARKER_SQUARE", @"markerShape",
265 nil] retain] autorelease];
271 [
NSNumber numberWithInt:system], @"system",
272 MISSION_DEST_LEGACY, @"name",
273 @"redColor", @"markerColor",
274 @"MARKER_X", @"markerShape",
275 nil] retain] autorelease];
278- (NSDictionary*)validatedMarker:(NSDictionary*)marker
285 NSString* group = [
marker oo_stringForKey:@"name" defaultValue:MISSION_DEST_LEGACY];
288 [
NSNumber numberWithInt:dest], @"system",
290 [
marker oo_stringForKey:@"markerColor"
291 defaultValue:@"redColor"],
293 [
marker oo_stringForKey:@"markerShape"
294 defaultValue:@"MARKER_X"],
296 [
NSNumber numberWithFloat:[
marker oo_floatForKey:@"markerScale" defaultValue:1.0]], @"markerScale",
297 nil] retain] autorelease];
315 unsigned long long integerCredits = tenthsOfCredits / 10;
316 unsigned long long tenths = tenthsOfCredits % 10;
318 return [
NSString stringWithFormat:@"%llu.%llu", integerCredits, tenths];
334- (NSString*)keyBindingDescription2:(NSString*)binding
336 if ([keyconfig2_settings objectForKey:binding] ==
nil) {
340 NSArray* keyList = (NSArray*)[keyconfig2_settings objectForKey:binding];
344- (NSString*)getKeyBindingDescription:(NSArray*)keyList
348 for (i = 0; i < [
keyList count]; i++) {
351 NSDictionary* def = [
keyList objectAtIndex:i];
352 NSString* key = [
def objectForKey:@"key"];
357 if ([[def objectForKey:
@"mod2"] boolValue] == YES)
358 final = [
NSMutableString stringWithFormat:@"%@%@+", final, keyMod2Text];
359 if ([[def objectForKey:
@"mod1"] boolValue] == YES)
360 final = [
NSMutableString stringWithFormat:@"%@%@+", final, keyMod1Text];
361 if ([[def objectForKey:
@"shift"] boolValue] == YES)
362 final = [
NSMutableString stringWithFormat:@"%@%@+", final, keyShiftText];
373 return DESC(
@"oolite-keycode-unset");
375 return DESC(
@"oolite-keycode-tab");
377 return DESC(
@"oolite-keycode-enter");
379 return DESC(
@"oolite-keycode-esc");
381 return DESC(
@"oolite-keycode-space");
383 return DESC(
@"oolite-keycode-f1");
385 return DESC(
@"oolite-keycode-f2");
387 return DESC(
@"oolite-keycode-f3");
389 return DESC(
@"oolite-keycode-f4");
391 return DESC(
@"oolite-keycode-f5");
393 return DESC(
@"oolite-keycode-f6");
395 return DESC(
@"oolite-keycode-f7");
397 return DESC(
@"oolite-keycode-f8");
399 return DESC(
@"oolite-keycode-f9");
401 return DESC(
@"oolite-keycode-f10");
403 return DESC(
@"oolite-keycode-f11");
405 return DESC(
@"oolite-keycode-right");
407 return DESC(
@"oolite-keycode-left");
409 return DESC(
@"oolite-keycode-down");
411 return DESC(
@"oolite-keycode-up");
413 return DESC(
@"oolite-keycode-home");
415 return DESC(
@"oolite-keycode-end");
417 return DESC(
@"oolite-keycode-insert");
419 return DESC(
@"oolite-keycode-delete");
421 return DESC(
@"oolite-keycode-pageup");
423 return DESC(
@"oolite-keycode-pagedown");
425 return DESC(
@"oolite-keycode-numpad0");
427 return DESC(
@"oolite-keycode-numpad1");
429 return DESC(
@"oolite-keycode-numpad2");
431 return DESC(
@"oolite-keycode-numpad3");
433 return DESC(
@"oolite-keycode-numpad4");
435 return DESC(
@"oolite-keycode-numpad5");
437 return DESC(
@"oolite-keycode-numpad6");
439 return DESC(
@"oolite-keycode-numpad7");
441 return DESC(
@"oolite-keycode-numpad8");
443 return DESC(
@"oolite-keycode-numpad9");
445 return DESC(
@"oolite-keycode-printscreen");
447 return DESC(
@"oolite-keycode-pause");
449 return DESC(
@"oolite-keycode-numpad/");
451 return DESC(
@"oolite-keycode-numpad=");
453 return DESC(
@"oolite-keycode-numpad-");
455 return DESC(
@"oolite-keycode-numpad*");
457 return DESC(
@"oolite-keycode-numpad.");
459 return DESC(
@"oolite-keycode-numpad+");
461 return DESC(
@"oolite-keycode-numpadenter");
464 return [
NSString stringWithFormat:@"%C", code];
472 return DESC(
@"oolite-keycode-short-unset");
474 return DESC(
@"oolite-keycode-short-tab");
476 return DESC(
@"oolite-keycode-short-enter");
478 return DESC(
@"oolite-keycode-short-esc");
480 return DESC(
@"oolite-keycode-short-space");
482 return DESC(
@"oolite-keycode-short-f1");
484 return DESC(
@"oolite-keycode-short-f2");
486 return DESC(
@"oolite-keycode-short-f3");
488 return DESC(
@"oolite-keycode-short-f4");
490 return DESC(
@"oolite-keycode-short-f5");
492 return DESC(
@"oolite-keycode-short-f6");
494 return DESC(
@"oolite-keycode-short-f7");
496 return DESC(
@"oolite-keycode-short-f8");
498 return DESC(
@"oolite-keycode-short-f9");
500 return DESC(
@"oolite-keycode-short-f10");
502 return DESC(
@"oolite-keycode-short-f11");
504 return DESC(
@"oolite-keycode-short-right");
506 return DESC(
@"oolite-keycode-short-left");
508 return DESC(
@"oolite-keycode-short-down");
510 return DESC(
@"oolite-keycode-short-up");
512 return DESC(
@"oolite-keycode-short-home");
514 return DESC(
@"oolite-keycode-short-end");
516 return DESC(
@"oolite-keycode-short-insert");
518 return DESC(
@"oolite-keycode-short-delete");
520 return DESC(
@"oolite-keycode-short-pageup");
522 return DESC(
@"oolite-keycode-short-pagedown");
524 return DESC(
@"oolite-keycode-short-numpad0");
526 return DESC(
@"oolite-keycode-short-numpad1");
528 return DESC(
@"oolite-keycode-short-numpad2");
530 return DESC(
@"oolite-keycode-short-numpad3");
532 return DESC(
@"oolite-keycode-short-numpad4");
534 return DESC(
@"oolite-keycode-short-numpad5");
536 return DESC(
@"oolite-keycode-short-numpad6");
538 return DESC(
@"oolite-keycode-short-numpad7");
540 return DESC(
@"oolite-keycode-short-numpad8");
542 return DESC(
@"oolite-keycode-short-numpad9");
544 return DESC(
@"oolite-keycode-short-printscreen");
546 return DESC(
@"oolite-keycode-short-pause");
548 return DESC(
@"oolite-keycode-short-numpad/");
550 return DESC(
@"oolite-keycode-short-numpad=");
552 return DESC(
@"oolite-keycode-short-numpad-");
554 return DESC(
@"oolite-keycode-short-numpad*");
556 return DESC(
@"oolite-keycode-short-numpad.");
558 return DESC(
@"oolite-keycode-short-numpad+");
560 return DESC(
@"oolite-keycode-short-numpadenter");
562 return [
NSString stringWithFormat:@"%C", code];
570 return (
Vector) { (float)internalCoordinates.x * 0.4f, (
float)internalCoordinates.y * 0.2f, 0.0f };
575 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 setMissionChoice:keyPress:withEvent:(NSString *newChoice,[keyPress] NSString *keyPress,[withEvent] BOOL withEvent)
StationEntity * dockedStation()
OOCreditsQuantity deciCredits()
void calculateCurrentCargo()
NSString * keyCodeDescription:(OOKeyCode code)
NSString * getKeyBindingDescription:(NSArray *keyList)
void setStatus:(OOEntityStatus stat)
void doScriptEvent:withArgument:(OOJSPropID message,[withArgument] id argument)
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)
void seed_RNG_only_for_planet_description(Random_Seed s_seed)