Oolite
Loading...
Searching...
No Matches
PlayerEntity(Scripting) Category Reference

#include <PlayerEntityLegacyScriptEngine.h>

Instance Methods

(void) - checkScript
(void) - setScriptTarget:
(ShipEntity *) - scriptTarget
(void) - runScriptActions:withContextName:forTarget:
(void) - runUnsanitizedScriptActions:allowingAIMethods:withContextName:forTarget:
(BOOL) - scriptTestConditions:
(NSDictionary *) - missionVariables
(NSString *) - missionVariableForKey:
(void) - setMissionVariable:forKey:
(NSMutableDictionary *) - localVariablesForMission:
(NSString *) - localVariableForKey:andMission:
(void) - setLocalVariable:forKey:andMission:
(NSString *) - mission_string
(NSString *) - status_string
(NSString *) - gui_screen_string
(NSNumber *) - galaxy_number
(NSNumber *) - planet_number
(NSNumber *) - score_number
(NSNumber *) - credits_number
(NSNumber *) - scriptTimer_number
(NSNumber *) - shipsFound_number
(NSNumber *) - d100_number
(NSNumber *) - pseudoFixedD100_number
(NSNumber *) - d256_number
(NSNumber *) - pseudoFixedD256_number
(NSNumber *) - clock_number
(NSNumber *) - clock_secs_number
(NSNumber *) - clock_mins_number
(NSNumber *) - clock_hours_number
(NSNumber *) - clock_days_number
(NSNumber *) - fuelLevel_number
(NSString *) - dockedAtMainStation_bool
(NSString *) - foundEquipment_bool
(NSString *) - sunWillGoNova_bool
(NSString *) - sunGoneNova_bool
(NSString *) - missionChoice_string
(NSString *) - missionKeyPress_string
(NSNumber *) - dockedTechLevel_number
(NSString *) - dockedStationName_string
(NSNumber *) - systemGovernment_number
(NSString *) - systemGovernment_string
(NSNumber *) - systemEconomy_number
(NSString *) - systemEconomy_string
(NSNumber *) - systemTechLevel_number
(NSNumber *) - systemPopulation_number
(NSNumber *) - systemProductivity_number
(NSString *) - commanderName_string
(NSString *) - commanderRank_string
(NSString *) - commanderShip_string
(NSString *) - commanderShipDisplayName_string
(NSString *) - commanderLegalStatus_string
(NSNumber *) - commanderLegalStatus_number
(NSArray *) - missionsList
(void) - setMissionDescription:
(void) - clearMissionDescription
(void) - setMissionInstructions:forMission:
(void) - setMissionInstructionsList:forMission:
(void) - setMissionDescription:forMission:
(void) - clearMissionDescriptionForMission:
(void) - commsMessage:
(void) - commsMessageByUnpiloted:
(void) - consoleMessage3s:
(void) - consoleMessage6s:
(void) - setLegalStatus:
(void) - awardCredits:
(void) - awardShipKills:
(void) - awardEquipment:
(void) - removeEquipment:
(void) - setPlanetinfo:
(void) - setSpecificPlanetInfo:
(void) - awardCargo:
(void) - removeAllCargo
(void) - removeAllCargo:
(void) - useSpecialCargo:
(void) - testForEquipment:
(void) - awardFuel:
(void) - messageShipAIs:
(void) - ejectItem:
(void) - addShips:
(void) - addSystemShips:
(void) - addShipsAt:
(void) - addShipsAtPrecisely:
(void) - addShipsWithinRadius:
(void) - spawnShip:
(void) - set:
(void) - reset:
(void) - increment:
(void) - decrement:
(void) - add:
(void) - subtract:
(void) - checkForShips:
(void) - resetScriptTimer
(void) - addMissionText:
(void) - addLiteralMissionText:
(void) - setMissionChoiceByTextEntry:
(void) - setMissionChoices:
(void) - setMissionChoicesDictionary:
(void) - resetMissionChoice
(void) - clearMissionScreen
(void) - addMissionDestination:
(void) - removeMissionDestination:
(void) - showShipModel:
(void) - setMissionMusic:
(NSString *) - missionTitle
(void) - setMissionTitle:
(void) - setFuelLeak:
(NSNumber *) - fuelLeakRate_number
(void) - setSunNovaIn:
(void) - launchFromStation
(void) - blowUpStation
(void) - sendAllShipsAway
(OOPlanetEntity *) - addPlanet:
(OOPlanetEntity *) - addMoon:
(void) - debugOn
(void) - debugOff
(void) - debugMessage:
(NSString *) - replaceVariablesInString:
(void) - playSound:
(BOOL) - addEqScriptForKey:
(void) - removeEqScriptForKey:
(NSUInteger) - eqScriptIndexForKey:
(void) - targetNearestHostile
(void) - targetNearestIncomingMissile
(void) - setGalacticHyperspaceBehaviourTo:
(void) - setGalacticHyperspaceFixedCoordsTo:
(void) - clearMissionScreenID
(void) - setMissionScreenID:
(NSString *) - missionScreenID
(void) - setGuiToMissionScreen
(void) - refreshMissionScreenTextEntry
(void) - setGuiToMissionScreenWithCallback:
(void) - doMissionCallback
(void) - endMissionScreenAndNoteOpportunity
(void) - setBackgroundFromDescriptionsKey:
(void) - addScene:atOffset:
(BOOL) - processSceneDictionary:atOffset:
(BOOL) - processSceneString:atOffset:
(OOINLINE NSString *) - CurrentScriptDesc(void) [implementation]
(OOINLINE OOEntityStatus) - RecursiveRemapStatus [implementation]
(NSDictionary *) - worldScriptsRequiringTickle [implementation]
(BOOL) - scriptTestCondition: [implementation]
(NSString *) - expandScriptRightHandSide: [implementation]
(NSString *) - expandMessage: [implementation]
(void) - setMissionImage: [implementation]
(void) - setMissionBackground: [implementation]

Class Methods

(static NSString *) + CurrentScriptNameOr [implementation]
(static void) + PerformScriptActions [implementation]
(static void) + PerformConditionalStatment [implementation]
(static void) + PerformActionStatment [implementation]
(static BOOL) + TestScriptConditions [implementation]

Detailed Description

Definition at line 51 of file PlayerEntityLegacyScriptEngine.h.

Method Documentation

◆ add:

- (void) add: (NSString*) missionVariableString_value

Extends class PlayerEntity.

Definition at line 1581 of file PlayerEntityLegacyScriptEngine.m.

1581 :(NSString*)missionVariableString_value
1582{
1583 NSString* missionVariableString = nil;
1584 NSString* valueString;
1585 double value;
1586 NSMutableArray* tokens = ScanTokensFromString(missionVariableString_value);
1587 BOOL hasMissionPrefix, hasLocalPrefix;
1588
1589 if ([tokens count] < 2) {
1590 OOLog(kOOLogSyntaxAdd, @"***** SCRIPT ERROR: in %@, CANNOT ADD: '%@'", CurrentScriptDesc(), missionVariableString_value);
1591 return;
1592 }
1593
1594 missionVariableString = [tokens objectAtIndex:0];
1595 [tokens removeObjectAtIndex:0];
1596 valueString = [tokens componentsJoinedByString:@" "];
1597
1598 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1599 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1600
1601 if (hasMissionPrefix) {
1602 value = [[self missionVariableForKey:missionVariableString] doubleValue];
1603 value += [valueString doubleValue];
1604 [self setMissionVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString];
1605 } else if (hasLocalPrefix) {
1606 value = [[self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] doubleValue];
1607 value += [valueString doubleValue];
1608 [self setLocalVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1609 } else {
1610 OOLog(kOOLogSyntaxAdd, @"***** SCRIPT ERROR: in %@, CANNOT ADD: '%@' -- IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString_value, missionVariableString_value);
1611 }
1612}
#define OOLog(class, format,...)
Definition OOLogging.h:84
unsigned count
return nil
NSMutableArray * ScanTokensFromString(NSString *values)
static NSString *const kOOLogSyntaxAdd

References count, kOOLogSyntaxAdd, PlayerEntity::localVariableForKey:andMission:, PlayerEntity::missionVariableForKey:, nil, OOLog, ScanTokensFromString(), PlayerEntity::setLocalVariable:forKey:andMission:, and PlayerEntity::setMissionVariable:forKey:.

Here is the call graph for this function:

◆ addEqScriptForKey:

- (BOOL) addEqScriptForKey: (NSString*) eq_key

Extends class PlayerEntity.

Definition at line 2483 of file PlayerEntityLegacyScriptEngine.m.

2483 :(NSString*)eq_key
2484{
2485 if (eq_key == nil)
2486 return NO;
2487
2488 NSString* scriptName = [[OOEquipmentType equipmentTypeWithIdentifier:eq_key] scriptName];
2489
2490 OOLog(@"player.equipmentScript", @"Added equipment %@, with the following script property: '%@'.", eq_key, scriptName);
2491
2492 if (scriptName == nil)
2493 return NO;
2494
2495 NSMutableDictionary* properties = [NSMutableDictionary dictionary];
2496
2497 // no duplicates!
2498 NSArray* eqScript = nil;
2499 foreach (eqScript, eqScripts) {
2500 NSString* key = [eqScript oo_stringAtIndex:0];
2501 if ([key isEqualToString:eq_key])
2502 return NO;
2503 }
2504
2505 [properties setObject:self forKey:@"ship"];
2506 [properties setObject:eq_key forKey:@"equipmentKey"];
2507 OOScript* s = [OOScript jsScriptFromFileNamed:scriptName properties:properties];
2508 if (s == nil)
2509 return NO;
2510
2511 OOLog(@"player.equipmentScript", @"Script '%@': installation %@successful.", scriptName, (s == nil ? @"un" : @""));
2512
2513 [eqScripts addObject:[NSArray arrayWithObjects:eq_key, s, nil]];
2514 if (primedEquipment == [eqScripts count] - 1)
2515 primedEquipment++; // if primed-none, keep it as primed-none.
2516 OOLog(@"player.equipmentScript", @"Scriptable equipment available: %zu.", [eqScripts count]);
2517 return YES;
2518}
NSString * scriptName()
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
id jsScriptFromFileNamed:properties:(NSString *fileName,[properties] NSDictionary *properties)
Definition OOScript.m:177

References count, OOEquipmentType::equipmentTypeWithIdentifier:, OOScript::jsScriptFromFileNamed:properties:, nil, OOLog, and OOEquipmentType::scriptName.

Here is the call graph for this function:

◆ addLiteralMissionText:

- (void) addLiteralMissionText: (NSString*) text

Extends class PlayerEntity.

Definition at line 1678 of file PlayerEntityLegacyScriptEngine.m.

1678 :(NSString*)text
1679{
1680 if (text != nil) {
1681 GuiDisplayGen* gui = [UNIVERSE gui];
1682
1683 NSString* para = nil;
1684 foreach (para, [text componentsSeparatedByString:@"\n"]) {
1685 missionTextRow = [gui addLongText:para startingAtRow:missionTextRow align:GUI_ALIGN_LEFT];
1686 }
1687 }
1688}
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)

References GuiDisplayGen::addLongText:startingAtRow:align:, and nil.

Here is the call graph for this function:

◆ addMissionDestination:

- (void) addMissionDestination: (NSString*) destinations

Extends class PlayerEntity.

Definition at line 1843 of file PlayerEntityLegacyScriptEngine.m.

1843 :(NSString*)destinations
1844{
1845 unsigned j;
1846 int dest;
1847 NSMutableArray* tokens = ScanTokensFromString(destinations);
1848
1849 for (j = 0; j < [tokens count]; j++) {
1850 dest = [tokens oo_intAtIndex:j];
1851 if (dest < 0 || dest > 255)
1852 continue;
1853
1854 [self addMissionDestinationMarker:[self defaultMarker:dest]];
1855 }
1856}

References PlayerEntity::addMissionDestinationMarker:, PlayerEntity::defaultMarker:, and ScanTokensFromString().

Here is the call graph for this function:

◆ addMissionText:

- (void) addMissionText: (NSString*) textKey

Extends class PlayerEntity.

Definition at line 1659 of file PlayerEntityLegacyScriptEngine.m.

1659 :(NSString*)textKey
1660{
1661 NSString* text = nil;
1662
1663 if ([textKey isEqualToString:lastTextKey])
1664 return; // don't repeatedly add the same text
1665 [lastTextKey release];
1666 lastTextKey = [textKey copy];
1667
1668 // Replace literal \n in strings with line breaks and perform expansions.
1669 text = [[UNIVERSE missiontext] oo_stringForKey:textKey];
1670 if (text == nil)
1671 return;
1673 text = [self replaceVariablesInString:text];
1674
1675 [self addLiteralMissionText:text];
1676}
@ kOOExpandBackslashN
Convert literal "\\n"s to line breaks (used for missiontext.plist for historical reasons).
Random_Seed OOStringExpanderDefaultRandomSeed(void)
#define OOExpandWithOptions(seed, options, string,...)

References PlayerEntity::addLiteralMissionText:, kOOExpandBackslashN, nil, OOExpandWithOptions, OOStringExpanderDefaultRandomSeed(), and PlayerEntity::replaceVariablesInString:.

Here is the call graph for this function:

◆ addMoon:

- (OOPlanetEntity *) addMoon: (NSString*) moonKey

Extends class PlayerEntity.

Definition at line 2049 of file PlayerEntityLegacyScriptEngine.m.

2049 :(NSString*)moonKey
2050{
2051 OOLog(kOOLogNoteAddPlanet, @"DEBUG: addMoon '%@'", moonKey);
2052
2053 if (!UNIVERSE)
2054 return nil;
2055 NSDictionary* dict = [[UNIVERSE systemManager] getPropertiesForSystemKey:moonKey];
2056 if (!dict) {
2057 OOLog(@"script.error.addPlanet.keyNotFound", @"***** ERROR: could not find an entry in planetinfo.plist for '%@'", moonKey);
2058 return nil;
2059 }
2060
2061 OOLog(kOOLogDebugAddPlanet, @"DEBUG: initMoonFromDictionary: %@", dict);
2062 OOPlanetEntity* planet = [[[OOPlanetEntity alloc] initFromDictionary:dict withAtmosphere:NO andSeed:[[UNIVERSE systemManager] getRandomSeedForCurrentSystem] forSystem:system_id] autorelease];
2063
2064 Quaternion planetOrientation;
2065 if (ScanQuaternionFromString([dict objectForKey:@"orientation"], &planetOrientation)) {
2066 [planet setOrientation:planetOrientation];
2067 }
2068
2069 if (![dict objectForKey:@"position"]) {
2070 OOLog(@"script.error.addPlanet.noPosition", @"***** ERROR: you must specify a position for scripted moon '%@' before it can be created", moonKey);
2071 return nil;
2072 }
2073
2074 NSString* positionString = [dict objectForKey:@"position"];
2075 if ([positionString hasPrefix:@"abs "] && ([UNIVERSE planet] != nil || [UNIVERSE sun] != nil)) {
2076 OOLogWARN(@"script.deprecated", @"setting %@ for %@ '%@' in 'abs' inside .plists can cause compatibility issues across Oolite versions. Use coordinates relative to main system objects instead.", @"position", @"moon", moonKey);
2077 }
2078 HPVector posn = [UNIVERSE coordinatesFromCoordinateSystemString:positionString];
2079 if (posn.x || posn.y || posn.z) {
2080 OOLog(kOOLogDebugAddPlanet, @"moon position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2081 } else {
2082 ScanHPVectorFromString(positionString, &posn);
2083 OOLog(kOOLogDebugAddPlanet, @"moon position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2084 }
2085 [planet setPosition:posn];
2086
2087 [UNIVERSE addEntity:planet];
2088 return planet;
2089}
struct HPVector HPVector
#define OOLogWARN(class, format,...)
Definition OOLogging.h:126
struct Quaternion Quaternion
BOOL ScanHPVectorFromString(NSString *xyzString, HPVector *outVector)
BOOL ScanQuaternionFromString(NSString *wxyzString, Quaternion *outQuaternion)
static NSString *const kOOLogDebugAddPlanet
static NSString *const kOOLogNoteAddPlanet
#define UNIVERSE
Definition Universe.h:827
OOHPScalar x
Definition OOHPVector.h:36
OOHPScalar y
Definition OOHPVector.h:37
OOHPScalar z
Definition OOHPVector.h:38

References kOOLogDebugAddPlanet, kOOLogNoteAddPlanet, nil, OOLog, OOLogWARN, ScanHPVectorFromString(), ScanQuaternionFromString(), UNIVERSE, HPVector::x, HPVector::y, and HPVector::z.

Here is the call graph for this function:

◆ addPlanet:

- (OOPlanetEntity *) addPlanet: (NSString*) planetKey

Extends class PlayerEntity.

Definition at line 2005 of file PlayerEntityLegacyScriptEngine.m.

2005 :(NSString*)planetKey
2006{
2007 OOLog(kOOLogNoteAddPlanet, @"addPlanet: %@", planetKey);
2008
2009 if (!UNIVERSE)
2010 return nil;
2011 NSDictionary* dict = [[UNIVERSE systemManager] getPropertiesForSystemKey:planetKey];
2012 if (!dict) {
2013 OOLog(@"script.error.addPlanet.keyNotFound", @"***** ERROR: could not find an entry in planetinfo.plist for '%@'", planetKey);
2014 return nil;
2015 }
2016
2017 /*- add planet -*/
2018 OOLog(kOOLogDebugAddPlanet, @"DEBUG: initPlanetFromDictionary: %@", dict);
2019 OOPlanetEntity* planet = [[[OOPlanetEntity alloc] initFromDictionary:dict withAtmosphere:YES andSeed:[[UNIVERSE systemManager] getRandomSeedForCurrentSystem] forSystem:system_id] autorelease];
2020
2021 Quaternion planetOrientation;
2022 if (ScanQuaternionFromString([dict objectForKey:@"orientation"], &planetOrientation)) {
2023 [planet setOrientation:planetOrientation];
2024 }
2025
2026 if (![dict objectForKey:@"position"]) {
2027 OOLog(@"script.error.addPlanet.noPosition", @"***** ERROR: you must specify a position for scripted planet '%@' before it can be created", planetKey);
2028 return nil;
2029 }
2030
2031 NSString* positionString = [dict objectForKey:@"position"];
2032 if ([positionString hasPrefix:@"abs "] && ([UNIVERSE planet] != nil || [UNIVERSE sun] != nil)) {
2033 OOLogWARN(@"script.deprecated", @"setting %@ for %@ '%@' in 'abs' inside .plists can cause compatibility issues across Oolite versions. Use coordinates relative to main system objects instead.", @"position", @"planet", planetKey);
2034 }
2035
2036 HPVector posn = [UNIVERSE coordinatesFromCoordinateSystemString:positionString];
2037 if (posn.x || posn.y || posn.z) {
2038 OOLog(kOOLogDebugAddPlanet, @"planet position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2039 } else {
2040 ScanHPVectorFromString(positionString, &posn);
2041 OOLog(kOOLogDebugAddPlanet, @"planet position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2042 }
2043 [planet setPosition:posn];
2044
2045 [UNIVERSE addEntity:planet];
2046 return planet;
2047}

References kOOLogDebugAddPlanet, kOOLogNoteAddPlanet, nil, OOLog, OOLogWARN, ScanHPVectorFromString(), ScanQuaternionFromString(), UNIVERSE, HPVector::x, HPVector::y, and HPVector::z.

Here is the call graph for this function:

◆ addScene:atOffset:

- (void) addScene: (NSArray*) items
atOffset: (Vector) off 

Extends class PlayerEntity.

Definition at line 2240 of file PlayerEntityLegacyScriptEngine.m.

2240 :(NSArray*)items atOffset:(Vector)off
2241{
2242 unsigned i;
2243
2244 if (items == nil)
2245 return;
2246
2247 for (i = 0; i < [items count]; i++) {
2248 id item = [items objectAtIndex:i];
2249 if ([item isKindOfClass:[NSString class]]) {
2250 [self processSceneString:item atOffset:off];
2251 } else if ([item isKindOfClass:[NSArray class]]) {
2252 [self addScene:item atOffset:off];
2253 } else if ([item isKindOfClass:[NSDictionary class]]) {
2254 [self processSceneDictionary:item atOffset:off];
2255 }
2256 }
2257}
struct Vector Vector

References PlayerEntity::addScene:atOffset:, nil, PlayerEntity::processSceneDictionary:atOffset:, and PlayerEntity::processSceneString:atOffset:.

Here is the call graph for this function:

◆ addShips:

- (void) addShips: (NSString*) roles_number

Extends class PlayerEntity.

Definition at line 1319 of file PlayerEntityLegacyScriptEngine.m.

1319 :(NSString*)roles_number
1320{
1321 NSMutableArray* tokens = ScanTokensFromString(roles_number);
1322 NSString* roleString = nil;
1323 NSString* numberString = nil;
1324
1325 if ([tokens count] != 2) {
1326 OOLog(kOOLogSyntaxAddShips, @"***** SCRIPT ERROR: in %@, CANNOT addShips: '%@' (expected <role> <count>)", CurrentScriptDesc(), roles_number);
1327 return;
1328 }
1329
1330 roleString = [tokens objectAtIndex:0];
1331 numberString = [tokens objectAtIndex:1];
1332
1333 int number = [numberString intValue];
1334 if (number < 0) {
1335 OOLog(kOOLogSyntaxAddShips, @"***** SCRIPT ERROR: in %@, can't add %i ships -- that's less than zero, y'know..", CurrentScriptDesc(), number);
1336 return;
1337 }
1338
1339 OOLog(kOOLogNoteAddShips, @"DEBUG: Going to add %d ships with role '%@'", number, roleString);
1340
1341 while (number--)
1342 [UNIVERSE witchspaceShipWithPrimaryRole:roleString];
1343}
static NSString *const kOOLogNoteAddShips
static NSString *const kOOLogSyntaxAddShips

References count, kOOLogNoteAddShips, kOOLogSyntaxAddShips, nil, OOLog, and ScanTokensFromString().

Here is the call graph for this function:

◆ addShipsAt:

- (void) addShipsAt: (NSString*) roles_number_system_x_y_z

Extends class PlayerEntity.

Definition at line 1374 of file PlayerEntityLegacyScriptEngine.m.

1374 :(NSString*)roles_number_system_x_y_z
1375{
1376 NSMutableArray* tokens = ScanTokensFromString(roles_number_system_x_y_z);
1377
1378 NSString* roleString = nil;
1379 NSString* numberString = nil;
1380 NSString* systemString = nil;
1381 NSString* xString = nil;
1382 NSString* yString = nil;
1383 NSString* zString = nil;
1384
1385 if ([tokens count] != 6) {
1386 OOLog(kOOLogSyntaxAddShips, @"***** SCRIPT ERROR: in %@, CANNOT addShipsAt: '%@' (expected <role> <count> <coordinate-system> <x> <y> <z>)", CurrentScriptDesc(), roles_number_system_x_y_z);
1387 return;
1388 }
1389
1390 roleString = [tokens objectAtIndex:0];
1391 numberString = [tokens objectAtIndex:1];
1392 systemString = [tokens objectAtIndex:2];
1393 xString = [tokens objectAtIndex:3];
1394 yString = [tokens objectAtIndex:4];
1395 zString = [tokens objectAtIndex:5];
1396
1397 HPVector posn = make_HPvector([xString doubleValue], [yString doubleValue], [zString doubleValue]);
1398
1399 int number = [numberString intValue];
1400 if (number < 1) {
1401 OOLog(kOOLogSyntaxAddShips, @"----- WARNING in %@ Tried to add %i ships -- no ship added.", CurrentScriptDesc(), number);
1402 return;
1403 }
1404
1405 OOLog(kOOLogNoteAddShips, @"DEBUG: Going to add %d ship(s) with role '%@' at point (%.3f, %.3f, %.3f) using system %@", number, roleString, posn.x, posn.y, posn.z, systemString);
1406
1407 if (![UNIVERSE addShips:number withRole:roleString nearPosition:posn withCoordinateSystem:systemString]) {
1408 OOLog(kOOLogScriptAddShipsFailed, @"***** SCRIPT ERROR: in %@, %@ could not add %u ships with role \"%@\"", CurrentScriptDesc(), @"addShipsAt:", number, roleString);
1409 }
1410}
OOINLINE HPVector make_HPvector(OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
Definition OOHPVector.h:149
static NSString *const kOOLogScriptAddShipsFailed

References count, kOOLogNoteAddShips, kOOLogScriptAddShipsFailed, kOOLogSyntaxAddShips, make_HPvector(), nil, OOLog, ScanTokensFromString(), UNIVERSE, HPVector::x, HPVector::y, and HPVector::z.

Here is the call graph for this function:

◆ addShipsAtPrecisely:

- (void) addShipsAtPrecisely: (NSString*) roles_number_system_x_y_z

Extends class PlayerEntity.

Definition at line 1412 of file PlayerEntityLegacyScriptEngine.m.

1412 :(NSString*)roles_number_system_x_y_z
1413{
1414 NSMutableArray* tokens = ScanTokensFromString(roles_number_system_x_y_z);
1415
1416 NSString* roleString = nil;
1417 NSString* numberString = nil;
1418 NSString* systemString = nil;
1419 NSString* xString = nil;
1420 NSString* yString = nil;
1421 NSString* zString = nil;
1422
1423 if ([tokens count] != 6) {
1424 OOLog(kOOLogSyntaxAddShips, @"***** SCRIPT ERROR: in %@,* CANNOT addShipsAtPrecisely: '%@' (expected <role> <count> <coordinate-system> <x> <y> <z>)", CurrentScriptDesc(), roles_number_system_x_y_z);
1425 return;
1426 }
1427
1428 roleString = [tokens objectAtIndex:0];
1429 numberString = [tokens objectAtIndex:1];
1430 systemString = [tokens objectAtIndex:2];
1431 xString = [tokens objectAtIndex:3];
1432 yString = [tokens objectAtIndex:4];
1433 zString = [tokens objectAtIndex:5];
1434
1435 HPVector posn = make_HPvector([xString doubleValue], [yString doubleValue], [zString doubleValue]);
1436
1437 int number = [numberString intValue];
1438 if (number < 1) {
1439 OOLog(kOOLogSyntaxAddShips, @"----- WARNING: in %@, Can't add %i ships -- no ship added.", CurrentScriptDesc(), number);
1440 return;
1441 }
1442
1443 OOLog(kOOLogNoteAddShips, @"DEBUG: Going to add %d ship(s) with role '%@' precisely at point (%.3f, %.3f, %.3f) using system %@", number, roleString, posn.x, posn.y, posn.z, systemString);
1444
1445 if (![UNIVERSE addShips:number withRole:roleString atPosition:posn withCoordinateSystem:systemString]) {
1446 OOLog(kOOLogScriptAddShipsFailed, @"***** SCRIPT ERROR: in %@, %@ could not add %u ships with role '%@'", CurrentScriptDesc(), @"addShipsAtPrecisely:", number, roleString);
1447 }
1448}

References count, kOOLogNoteAddShips, kOOLogScriptAddShipsFailed, kOOLogSyntaxAddShips, make_HPvector(), nil, OOLog, ScanTokensFromString(), UNIVERSE, HPVector::x, HPVector::y, and HPVector::z.

Here is the call graph for this function:

◆ addShipsWithinRadius:

- (void) addShipsWithinRadius: (NSString*) roles_number_system_x_y_z_r

Extends class PlayerEntity.

Definition at line 1450 of file PlayerEntityLegacyScriptEngine.m.

1450 :(NSString*)roles_number_system_x_y_z_r
1451{
1452 NSMutableArray* tokens = ScanTokensFromString(roles_number_system_x_y_z_r);
1453
1454 if ([tokens count] != 7) {
1455 OOLog(kOOLogSyntaxAddShips, @"***** SCRIPT ERROR: in %@, CANNOT 'addShipsWithinRadius: %@' (expected <role> <count> <coordinate-system> <x> <y> <z> <radius>))", CurrentScriptDesc(), roles_number_system_x_y_z_r);
1456 return;
1457 }
1458
1459 NSString* roleString = [tokens objectAtIndex:0];
1460 int number = [[tokens objectAtIndex:1] intValue];
1461 NSString* systemString = [tokens objectAtIndex:2];
1462 double x = [[tokens objectAtIndex:3] doubleValue];
1463 double y = [[tokens objectAtIndex:4] doubleValue];
1464 double z = [[tokens objectAtIndex:5] doubleValue];
1465 GLfloat r = [[tokens objectAtIndex:6] floatValue];
1466 HPVector posn = make_HPvector(x, y, z);
1467
1468 if (number < 1) {
1469 OOLog(kOOLogSyntaxAddShips, @"----- WARNING: in %@, can't add %i ships -- no ship added.", CurrentScriptDesc(), number);
1470 return;
1471 }
1472
1473 OOLog(kOOLogNoteAddShips, @"DEBUG: Going to add %d ship(s) with role '%@' within %.2f radius about point (%.3f, %.3f, %.3f) using system %@", number, roleString, r, x, y, z, systemString);
1474
1475 if (![UNIVERSE addShips:number withRole:roleString nearPosition:posn withCoordinateSystem:systemString withinRadius:r]) {
1476 OOLog(kOOLogScriptAddShipsFailed, @"***** SCRIPT ERROR :in %@, %@ could not add %u ships with role \"%@\"", CurrentScriptDesc(), @"addShipsWithinRadius:", number, roleString);
1477 }
1478}
float y
float x

References count, kOOLogNoteAddShips, kOOLogScriptAddShipsFailed, kOOLogSyntaxAddShips, make_HPvector(), OOLog, ScanTokensFromString(), UNIVERSE, x, and y.

Here is the call graph for this function:

◆ addSystemShips:

- (void) addSystemShips: (NSString*) roles_number_position

Extends class PlayerEntity.

Definition at line 1345 of file PlayerEntityLegacyScriptEngine.m.

1345 :(NSString*)roles_number_position
1346{
1347 NSMutableArray* tokens = ScanTokensFromString(roles_number_position);
1348 NSString* roleString = nil;
1349 NSString* numberString = nil;
1350 NSString* positionString = nil;
1351
1352 if ([tokens count] != 3) {
1353 OOLog(kOOLogSyntaxAddShips, @"***** SCRIPT ERROR: in %@, CANNOT addSystemShips: '%@' (expected <role> <count> <position>)", CurrentScriptDesc(), roles_number_position);
1354 return;
1355 }
1356
1357 roleString = [tokens objectAtIndex:0];
1358 numberString = [tokens objectAtIndex:1];
1359 positionString = [tokens objectAtIndex:2];
1360
1361 int number = [numberString intValue];
1362 double posn = [positionString doubleValue];
1363 if (number < 0) {
1364 OOLog(kOOLogSyntaxAddShips, @"***** SCRIPT ERROR: in %@, can't add %i ships -- that's less than zero, y'know..", CurrentScriptDesc(), number);
1365 return;
1366 }
1367
1368 OOLog(kOOLogNoteAddShips, @"DEBUG: Going to add %d ships with role '%@' at a point %.3f along route1", number, roleString, posn);
1369
1370 while (number--)
1371 [UNIVERSE addShipWithRole:roleString nearRouteOneAt:posn];
1372}

References count, kOOLogNoteAddShips, kOOLogSyntaxAddShips, nil, OOLog, and ScanTokensFromString().

Here is the call graph for this function:

◆ awardCargo:

- (void) awardCargo: (NSString*) amount_typeString

Extends class PlayerEntity.

Definition at line 1180 of file PlayerEntityLegacyScriptEngine.m.

1180 :(NSString*)amount_typeString
1181{
1182 if (scriptTarget != self)
1183 return;
1184
1185 NSArray* tokens = ScanTokensFromString(amount_typeString);
1186 OOCargoQuantityDelta amount;
1187 OOCommodityType type;
1188 OOMassUnit unit;
1189
1190 if ([tokens count] != 2) {
1191 OOLog(kOOLogSyntaxAwardCargo, @"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString, @"bad parameter count");
1192 return;
1193 }
1194
1195 type = [tokens oo_stringAtIndex:1];
1196 if (![[UNIVERSE commodities] goodDefined:type]) {
1197 OOLog(kOOLogSyntaxAwardCargo, @"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString, @"unknown type");
1198 return;
1199 }
1200
1201 amount = [tokens oo_intAtIndex:0];
1202 if (amount < 0) {
1203 OOLog(kOOLogSyntaxAwardCargo, @"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString, @"negative quantity");
1204 return;
1205 }
1206
1207 unit = [shipCommodityData massUnitForGood:type];
1208 if (specialCargo && unit == UNITS_TONS) {
1209 OOLog(kOOLogSyntaxAwardCargo, @"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString, @"cargo hold full with special cargo");
1210 return;
1211 }
1212
1213 [self awardCommodityType:type amount:amount];
1214}
NSString * OOCommodityType
Definition OOTypes.h:97
int32_t OOCargoQuantityDelta
Definition OOTypes.h:156
OOMassUnit
Definition OOTypes.h:111
@ UNITS_TONS
Definition OOTypes.h:112
static NSString *const kOOLogSyntaxAwardCargo

References PlayerEntity::awardCommodityType:amount:, count, kOOLogSyntaxAwardCargo, OOLog, ScanTokensFromString(), scriptTarget, UNITS_TONS, and UNIVERSE.

Here is the call graph for this function:

◆ awardCredits:

- (void) awardCredits: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 1071 of file PlayerEntityLegacyScriptEngine.m.

1071 :(NSString*)valueString
1072{
1073 if (scriptTarget != self)
1074 return;
1075
1076 /* We can't use -longLongValue here for Mac OS X 10.4 compatibility, but
1077 we don't need to since larger values have never been supported for
1078 legacy scripts.
1079 */
1080 int64_t award = [valueString intValue];
1081 award *= 10;
1082 if (award < 0 && credits < (OOCreditsQuantity)-award)
1083 credits = 0;
1084 else
1085 credits += award;
1086}
uint64_t OOCreditsQuantity
Definition OOTypes.h:160

References scriptTarget.

Here is the call graph for this function:

◆ awardEquipment:

- (void) awardEquipment: (NSString*) equipString

Extends class PlayerEntity.

Definition at line 1098 of file PlayerEntityLegacyScriptEngine.m.

1098 :(NSString*)equipString // eg. EQ_NAVAL_ENERGY_UNIT
1099{
1100 if (scriptTarget != self)
1101 return;
1102
1103 if ([equipString isEqualToString:@"EQ_FUEL"]) {
1104 [self setFuel:[self fuelCapacity]];
1105 }
1106
1107 OOEquipmentType* eqType = [OOEquipmentType equipmentTypeWithIdentifier:equipString];
1108
1109 if ([eqType isMissileOrMine]) {
1110 [self mountMissileWithRole:equipString];
1111 } else if ([equipString hasPrefix:@"EQ_WEAPON"] && ![equipString hasSuffix:@"_DAMAGED"]) {
1112 OOLog(kOOLogSyntaxAwardEquipment, @"***** SCRIPT ERROR: in %@, CANNOT award undamaged weapon:'%@'. Damaged weapons can be awarded instead.", CurrentScriptDesc(), equipString);
1113 } else if ([equipString hasSuffix:@"_DAMAGED"] && [self hasEquipmentItem:[equipString substringToIndex:[equipString length] - [@"_DAMAGED" length]]]) {
1114 OOLog(kOOLogSyntaxAwardEquipment, @"***** SCRIPT ERROR: in %@, CANNOT award damaged equipment:'%@'. Undamaged version already equipped.", CurrentScriptDesc(), equipString);
1115 } else if ([eqType canCarryMultiple] || ![self hasEquipmentItem:equipString]) {
1116 [self addEquipmentItem:equipString withValidation:YES inContext:@"scripted"];
1117 }
1118}
static NSString *const kOOLogSyntaxAwardEquipment

References PlayerEntity::addEquipmentItem:withValidation:inContext:, OOEquipmentType::equipmentTypeWithIdentifier:, ShipEntity::fuelCapacity, kOOLogSyntaxAwardEquipment, PlayerEntity::mountMissileWithRole:, OOLog, scriptTarget, and ShipEntity::setFuel:.

Here is the call graph for this function:

◆ awardFuel:

- (void) awardFuel: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 1274 of file PlayerEntityLegacyScriptEngine.m.

1274 :(NSString*)valueString // add to fuel up to 7.0 LY
1275{
1276 int delta = 10 * [valueString floatValue];
1277 OOFuelQuantity scriptTargetFuelBeforeAward = [scriptTarget fuel];
1278
1279 if (delta < 0 && scriptTargetFuelBeforeAward < (unsigned)-delta)
1281 else {
1282 [scriptTarget setFuel:(scriptTargetFuelBeforeAward + delta)];
1283 }
1284}
uint16_t OOFuelQuantity
Definition OOTypes.h:158
void setFuel:(OOFuelQuantity amount)
OOFuelQuantity fuel

References ShipEntity::fuel, and ShipEntity::setFuel:.

Here is the call graph for this function:

◆ awardShipKills:

- (void) awardShipKills: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 1088 of file PlayerEntityLegacyScriptEngine.m.

1088 :(NSString*)valueString
1089{
1090 if (scriptTarget != self)
1091 return;
1092
1093 int value = [valueString intValue];
1094 if (0 < value)
1095 ship_kills += value;
1096}

References scriptTarget.

Here is the call graph for this function:

◆ blowUpStation

- (void) blowUpStation

Extends class PlayerEntity.

Definition at line 1959 of file PlayerEntityLegacyScriptEngine.m.

1960{
1961 StationEntity* mainStation = nil;
1962
1963 mainStation = [UNIVERSE station];
1964 if (mainStation != nil) {
1965 [UNIVERSE unMagicMainStation];
1966 [mainStation takeEnergyDamage:500000000.0 from:nil becauseOf:nil weaponIdentifier:@""]; // 500 million should do it!
1967 }
1968}
void takeEnergyDamage:from:becauseOf:weaponIdentifier:(double amount, [from] Entity *ent, [becauseOf] Entity *other, [weaponIdentifier] NSString *weaponIdentifier)

References blowUpStation, nil, and StationEntity::takeEnergyDamage:from:becauseOf:weaponIdentifier:.

Referenced by blowUpStation.

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

◆ checkForShips:

- (void) checkForShips: (NSString*) roleString

Extends class PlayerEntity.

Definition at line 1647 of file PlayerEntityLegacyScriptEngine.m.

1647 :(NSString*)roleString
1648{
1649 shipsFound = [UNIVERSE countShipsWithPrimaryRole:roleString];
1650}
static int shipsFound

References shipsFound.

◆ checkScript

- (void) checkScript

Extends class PlayerEntity.

Definition at line 266 of file PlayerEntityLegacyScriptEngine.m.

267{
268 BOOL wasRunningScript = sRunningScript;
269 OOEntityStatus status, restoreStatus;
270
271 NSDictionary* tickleScripts = [self worldScriptsRequiringTickle];
272 if ([tickleScripts count] == 0) {
273 // Quick exit if we only have JS scripts.
274 return;
275 }
276
277 [self setScriptTarget:self];
278
279 /* World scripts can potentially be invoked recursively, through
280 scriptActionOnTarget: and possibly other mechanisms. This is bad, but
281 that's the way it is. Legacy world scripts rely on only seeing certain
282 player statuses once per "event". To ensure this, we must lie about
283 the player's status when invoked recursively.
284
285 Of course, there are also methods in the game that rely on status not
286 lying. However, I don't believe any that rely on these particular
287 statuses can be legitimately invoked by scripts. The alternative would
288 be to track the "status-as-seen-by-scripts" separately from the "real"
289 status, which'd risk synchronization problems.
290
291 In summary, scriptActionOnTarget: is bad, and calling it from scripts
292 rather than AIs is very bad.
293 -- Ahruman, 20080302
294
295 Addendum: scriptActionOnTarget: is currently not in the whitelist for
296 script methods. Let's hope this doesn't turn out to be a problem.
297 -- Ahruman, 20090208
298 */
299 status = [self status];
300 restoreStatus = status;
301 @try {
302 if (sRunningScript) {
303 status = RecursiveRemapStatus(status);
304 [self setStatus:status];
305 }
306 sRunningScript = YES;
307
308 // After all that, actually running the scripts is trivial.
309 [[tickleScripts allValues] makeObjectsPerformSelector:@selector(runWithTarget:) withObject:self];
310 }
311 @catch (NSException* exception) {
312 OOLog(kOOLogException, @"***** Exception running world scripts: %@ : %@", [exception name], [exception reason]);
313 }
314
315 // Restore anti-recursion measures.
316 sRunningScript = wasRunningScript;
317 if (status != restoreStatus)
318 [self setStatus:restoreStatus];
319}
OOEntityStatus
Definition Entity.h:60
NSString *const kOOLogException
Definition OOLogging.m:600
static BOOL sRunningScript
OOINLINE OOEntityStatus RecursiveRemapStatus(OOEntityStatus status)

References checkScript, count, kOOLogException, OOLog, RecursiveRemapStatus, PlayerEntity::setScriptTarget:, ShipEntity::setStatus:, sRunningScript, Entity::status, and PlayerEntity::worldScriptsRequiringTickle.

Referenced by checkScript.

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

◆ clearMissionDescription

- (void) clearMissionDescription

Extends class PlayerEntity.

Definition at line 777 of file PlayerEntityLegacyScriptEngine.m.

778{
779 [self clearMissionDescriptionForMission:sCurrentMissionKey];
780}

References clearMissionDescription, and PlayerEntity::clearMissionDescriptionForMission:.

Referenced by clearMissionDescription.

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

◆ clearMissionDescriptionForMission:

- (void) clearMissionDescriptionForMission: (NSString*) key

Extends class PlayerEntity.

Definition at line 782 of file PlayerEntityLegacyScriptEngine.m.

782 :(NSString*)key
783{
784 if (!key) {
785 OOLogERR(kOOLogScriptMissionDescNoKey, @"in %@, mission key not set", CurrentScriptDesc());
786 return;
787 }
788
789 if (![mission_variables objectForKey:key])
790 return;
791
792 [mission_variables removeObjectForKey:key];
793}
#define OOLogERR(class, format,...)
Definition OOLogging.h:125
static NSString *const kOOLogScriptMissionDescNoKey

References kOOLogScriptMissionDescNoKey, and OOLogERR.

◆ clearMissionScreen

- (void) clearMissionScreen

Extends class PlayerEntity.

Definition at line 1833 of file PlayerEntityLegacyScriptEngine.m.

1834{
1835 [self setMissionOverlayDescriptor:nil];
1836 [self setMissionBackgroundDescriptor:nil];
1837 [self setMissionBackgroundSpecial:nil];
1838 [self setMissionTitle:nil];
1839 [self setMissionMusic:nil];
1840 [self showShipModel:nil];
1841}

References clearMissionScreen, PlayerEntity::setMissionBackgroundDescriptor:, PlayerEntity::setMissionBackgroundSpecial:, PlayerEntity::setMissionMusic:, PlayerEntity::setMissionOverlayDescriptor:, PlayerEntity::setMissionTitle:, and PlayerEntity::showShipModel:.

Referenced by clearMissionScreen.

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

◆ clearMissionScreenID

- (void) clearMissionScreenID

Extends class PlayerEntity.

Definition at line 2122 of file PlayerEntityLegacyScriptEngine.m.

2123{
2124 [_missionScreenID release];
2125 _missionScreenID = nil;
2126}

References clearMissionScreenID, and nil.

Referenced by clearMissionScreenID.

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

◆ clock_days_number

- (NSNumber *) clock_days_number

Extends class PlayerEntity.

Definition at line 898 of file PlayerEntityLegacyScriptEngine.m.

899{
900 return [NSNumber numberWithUnsignedLongLong:ship_clock / 86400.0];
901}

References clock_days_number.

Referenced by clock_days_number.

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

◆ clock_hours_number

- (NSNumber *) clock_hours_number

Extends class PlayerEntity.

Definition at line 893 of file PlayerEntityLegacyScriptEngine.m.

894{
895 return [NSNumber numberWithUnsignedLongLong:ship_clock / 3600.0];
896}

References clock_hours_number.

Referenced by clock_hours_number.

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

◆ clock_mins_number

- (NSNumber *) clock_mins_number

Extends class PlayerEntity.

Definition at line 888 of file PlayerEntityLegacyScriptEngine.m.

889{
890 return [NSNumber numberWithUnsignedLongLong:ship_clock / 60.0];
891}

References clock_mins_number.

Referenced by clock_mins_number.

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

◆ clock_number

- (NSNumber *) clock_number

Extends class PlayerEntity.

Definition at line 878 of file PlayerEntityLegacyScriptEngine.m.

879{
880 return [NSNumber numberWithDouble:ship_clock];
881}

References clock_number.

Referenced by clock_number.

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

◆ clock_secs_number

- (NSNumber *) clock_secs_number

Extends class PlayerEntity.

Definition at line 883 of file PlayerEntityLegacyScriptEngine.m.

884{
885 return [NSNumber numberWithUnsignedLongLong:ship_clock];
886}

References clock_secs_number.

Referenced by clock_secs_number.

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

◆ commanderLegalStatus_number

- (NSNumber *) commanderLegalStatus_number

Extends class PlayerEntity.

Definition at line 841 of file PlayerEntityLegacyScriptEngine.m.

842{
843 return [NSNumber numberWithInt:[self legalStatus]];
844}

References commanderLegalStatus_number, and PlayerEntity::legalStatus.

Referenced by commanderLegalStatus_number.

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

◆ commanderLegalStatus_string

- (NSString *) commanderLegalStatus_string

Extends class PlayerEntity.

Definition at line 851 of file PlayerEntityLegacyScriptEngine.m.

852{
853 return OODisplayStringFromLegalStatus(legalStatus);
854}
NSString * OODisplayStringFromLegalStatus(int legalStatus)

References commanderLegalStatus_string, and OODisplayStringFromLegalStatus().

Referenced by commanderLegalStatus_string.

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

◆ commanderName_string

- (NSString *) commanderName_string

Extends class PlayerEntity.

Definition at line 1012 of file PlayerEntityLegacyScriptEngine.m.

1013{
1014 return [self commanderName];
1015}

References PlayerEntity::commanderName, and commanderName_string.

Referenced by commanderName_string.

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

◆ commanderRank_string

- (NSString *) commanderRank_string

Extends class PlayerEntity.

Definition at line 1017 of file PlayerEntityLegacyScriptEngine.m.

1018{
1019 return OODisplayRatingStringFromKillCount([self score]);
1020}
NSString * OODisplayRatingStringFromKillCount(unsigned kills)

References commanderRank_string, and OODisplayRatingStringFromKillCount().

Referenced by commanderRank_string.

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

◆ commanderShip_string

- (NSString *) commanderShip_string

Extends class PlayerEntity.

Definition at line 1022 of file PlayerEntityLegacyScriptEngine.m.

1023{
1024 return [self name];
1025}

References commanderShip_string, and ShipEntity::name.

Referenced by commanderShip_string.

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

◆ commanderShipDisplayName_string

- (NSString *) commanderShipDisplayName_string

Extends class PlayerEntity.

Definition at line 1027 of file PlayerEntityLegacyScriptEngine.m.

1028{
1029 return [self displayName];
1030}

References commanderShipDisplayName_string, and ShipEntity::displayName.

Referenced by commanderShipDisplayName_string.

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

◆ commsMessage:

- (void) commsMessage: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 1048 of file PlayerEntityLegacyScriptEngine.m.

1048 :(NSString*)valueString
1049{
1050 [UNIVERSE addCommsMessage:[self expandMessage:valueString] forCount:4.5];
1051}

References PlayerEntity::expandMessage:.

Here is the call graph for this function:

◆ commsMessageByUnpiloted:

- (void) commsMessageByUnpiloted: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 1056 of file PlayerEntityLegacyScriptEngine.m.

1056 :(NSString*)valueString
1057{
1058 [self commsMessage:valueString];
1059}

References PlayerEntity::commsMessage:.

Here is the call graph for this function:

◆ consoleMessage3s:

- (void) consoleMessage3s: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 1061 of file PlayerEntityLegacyScriptEngine.m.

1061 :(NSString*)valueString
1062{
1063 [UNIVERSE addMessage:[self expandMessage:valueString] forCount:3];
1064}

References PlayerEntity::expandMessage:.

Here is the call graph for this function:

◆ consoleMessage6s:

- (void) consoleMessage6s: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 1066 of file PlayerEntityLegacyScriptEngine.m.

1066 :(NSString*)valueString
1067{
1068 [UNIVERSE addMessage:[self expandMessage:valueString] forCount:6];
1069}

References PlayerEntity::expandMessage:.

Here is the call graph for this function:

◆ credits_number

- (NSNumber *) credits_number

Extends class PlayerEntity.

Definition at line 825 of file PlayerEntityLegacyScriptEngine.m.

826{
827 return [NSNumber numberWithDouble:[self creditBalance]];
828}

References PlayerEntity::creditBalance, and credits_number.

Referenced by credits_number.

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

◆ CurrentScriptDesc(void)

- (OOINLINE NSString * CurrentScriptDesc(void)) (void)
implementation

Extends class PlayerEntity.

Definition at line 120 of file PlayerEntityLegacyScriptEngine.m.

121{
122 return CurrentScriptNameOr(@"<anonymous actions>");
123}
static NSString * CurrentScriptNameOr(NSString *alternative)

References CurrentScriptNameOr, and OOINLINE.

Here is the call graph for this function:

◆ CurrentScriptNameOr

+ (NSString *) CurrentScriptNameOr (NSString *) alternative
implementation

Extends class PlayerEntity.

Definition at line 112 of file PlayerEntityLegacyScriptEngine.m.

113{
115 return [NSString stringWithFormat:@"\"%@\"", sCurrentMissionKey];
116 }
117 return alternative;
118}
static NSString * sCurrentMissionKey
static NSString *const kActionTempPrefix

References kActionTempPrefix, nil, and sCurrentMissionKey.

Referenced by CurrentScriptDesc(void).

Here is the caller graph for this function:

◆ d100_number

- (NSNumber *) d100_number

Extends class PlayerEntity.

Definition at line 856 of file PlayerEntityLegacyScriptEngine.m.

857{
858 int d100 = ranrot_rand() % 100;
859 return [NSNumber numberWithInt:d100];
860}
#define ranrot_rand()

References d100_number, and ranrot_rand.

Referenced by d100_number.

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

◆ d256_number

- (NSNumber *) d256_number

Extends class PlayerEntity.

Definition at line 867 of file PlayerEntityLegacyScriptEngine.m.

868{
869 int d256 = ranrot_rand() % 256;
870 return [NSNumber numberWithInt:d256];
871}

References d256_number, and ranrot_rand.

Referenced by d256_number.

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

◆ debugMessage:

- (void) debugMessage: (NSString*) args

Extends class PlayerEntity.

Definition at line 2103 of file PlayerEntityLegacyScriptEngine.m.

2103 :(NSString*)args
2104{
2105 OOLog(kOOLogDebugMessage, @"SCRIPT debugMessage: %@", args);
2106}
static NSString *const kOOLogDebugMessage

References kOOLogDebugMessage, and OOLog.

◆ debugOff

- (void) debugOff

Extends class PlayerEntity.

Definition at line 2097 of file PlayerEntityLegacyScriptEngine.m.

2098{
2099 OOLog(kOOLogDebugOnOff, @"%@", @"SCRIPT debug messages OFF");
2101}
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
Definition OOLogging.m:172
static NSString *const kOOLogDebugOnOff
static NSString *const kOOLogDebugOnMetaClass

References debugOff, kOOLogDebugOnMetaClass, kOOLogDebugOnOff, OOLog, and OOLogSetDisplayMessagesInClass().

Referenced by debugOff.

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

◆ debugOn

- (void) debugOn

Extends class PlayerEntity.

Definition at line 2091 of file PlayerEntityLegacyScriptEngine.m.

2092{
2094 OOLog(kOOLogDebugOnOff, @"%@", @"SCRIPT debug messages ON");
2095}

References debugOn, kOOLogDebugOnMetaClass, kOOLogDebugOnOff, OOLog, and OOLogSetDisplayMessagesInClass().

Referenced by debugOn.

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

◆ decrement:

- (void) decrement: (NSString*) missionVariableString

Extends class PlayerEntity.

Definition at line 1560 of file PlayerEntityLegacyScriptEngine.m.

1560 :(NSString*)missionVariableString
1561{
1562 BOOL hasMissionPrefix, hasLocalPrefix;
1563 int value = 0;
1564
1565 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1566 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1567
1568 if (hasMissionPrefix) {
1569 value = [[self missionVariableForKey:missionVariableString] intValue];
1570 value--;
1571 [self setMissionVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString];
1572 } else if (hasLocalPrefix) {
1573 value = [[self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] intValue];
1574 value--;
1575 [self setLocalVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1576 } else {
1577 OOLog(kOOLogSyntaxDecrement, @"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1578 }
1579}
static NSString *const kOOLogSyntaxDecrement

References kOOLogSyntaxDecrement, PlayerEntity::localVariableForKey:andMission:, PlayerEntity::missionVariableForKey:, OOLog, PlayerEntity::setLocalVariable:forKey:andMission:, and PlayerEntity::setMissionVariable:forKey:.

Here is the call graph for this function:

◆ dockedAtMainStation_bool

- (NSString *) dockedAtMainStation_bool

Extends class PlayerEntity.

Definition at line 908 of file PlayerEntityLegacyScriptEngine.m.

909{
910 if ([self dockedAtMainStation])
911 return @"YES";
912 else
913 return @"NO";
914}

References dockedAtMainStation_bool.

Referenced by dockedAtMainStation_bool.

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

◆ dockedStationName_string

- (NSString *) dockedStationName_string

Extends class PlayerEntity.

Definition at line 950 of file PlayerEntityLegacyScriptEngine.m.

951{
952 NSString* result = nil;
953 if ([self status] != STATUS_DOCKED)
954 return @"NONE";
955
956 result = [self dockedStationName];
957 if (result == nil)
958 result = @"UNKNOWN";
959 return result;
960}

References PlayerEntity::dockedStationName, dockedStationName_string, and nil.

Referenced by dockedStationName_string.

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

◆ dockedTechLevel_number

- (NSNumber *) dockedTechLevel_number

Extends class PlayerEntity.

Definition at line 941 of file PlayerEntityLegacyScriptEngine.m.

942{
943 StationEntity* dockedStation = [self dockedStation];
944 if (!dockedStation) {
945 return [self systemTechLevel_number];
946 }
947 return [NSNumber numberWithUnsignedInteger:[dockedStation equivalentTechLevel]];
948}
OOTechLevelID equivalentTechLevel

References PlayerEntity::dockedStation, dockedTechLevel_number, StationEntity::equivalentTechLevel, and PlayerEntity::systemTechLevel_number.

Referenced by dockedTechLevel_number.

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

◆ doMissionCallback

- (void) doMissionCallback

Extends class PlayerEntity.

Definition at line 2115 of file PlayerEntityLegacyScriptEngine.m.

2116{
2117 // make sure we don't call the same callback twice
2118 _missionWithCallback = NO;
2120}
OOJavaScriptEngine * sharedEngine()

References doMissionCallback, OOJavaScriptEngine::runMissionCallback, and OOJavaScriptEngine::sharedEngine.

Referenced by doMissionCallback.

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

◆ ejectItem:

- (void) ejectItem: (NSString*) item_key

Extends class PlayerEntity.

Definition at line 1312 of file PlayerEntityLegacyScriptEngine.m.

1312 :(NSString*)itemKey
1313{
1314 if (scriptTarget == nil)
1315 scriptTarget = self;
1316 [scriptTarget ejectShipOfType:itemKey];
1317}
ShipEntity * ejectShipOfType:(NSString *shipKey)

References ShipEntity::ejectShipOfType:, nil, and scriptTarget.

Here is the call graph for this function:

◆ endMissionScreenAndNoteOpportunity

- (void) endMissionScreenAndNoteOpportunity

Extends class PlayerEntity.

Definition at line 2138 of file PlayerEntityLegacyScriptEngine.m.

2139{
2140 _missionAllowInterrupt = NO;
2141 [self clearMissionScreenID];
2142 // Older scripts might intercept missionScreenEnded first, and call secondary mission screens.
2143 if (![self doWorldEventUntilMissionScreen:OOJSID("missionScreenEnded")]) {
2144 // if we're here, no mission screen is running. Opportunity! :)
2145 [self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
2146 }
2147}
#define OOJSID(str)
Definition OOJSPropID.h:42

References PlayerEntity::clearMissionScreenID, PlayerEntity::doWorldEventUntilMissionScreen:, endMissionScreenAndNoteOpportunity, and OOJSID.

Referenced by endMissionScreenAndNoteOpportunity.

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

◆ eqScriptIndexForKey:

- (NSUInteger) eqScriptIndexForKey: (NSString*) eq_key

Extends class PlayerEntity.

Definition at line 2545 of file PlayerEntityLegacyScriptEngine.m.

2545 :(NSString*)eq_key
2546{
2547 NSUInteger i, count = [eqScripts count];
2548
2549 if (eq_key != nil) {
2550 for (i = 0; i < count; i++) {
2551 NSString* key = [[eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0];
2552 if ([key isEqualToString:eq_key])
2553 return i;
2554 }
2555 }
2556
2557 return count;
2558}

References count, and nil.

◆ expandMessage:

- (NSString *) expandMessage: (NSString*) valueString
implementation

Extends class PlayerEntity.

Definition at line 1034 of file PlayerEntityLegacyScriptEngine.m.

1034 :(NSString*)valueString
1035{
1036 Random_Seed very_random_seed;
1037 very_random_seed.a = rand() & 255;
1038 very_random_seed.b = rand() & 255;
1039 very_random_seed.c = rand() & 255;
1040 very_random_seed.d = rand() & 255;
1041 very_random_seed.e = rand() & 255;
1042 very_random_seed.f = rand() & 255;
1043 seed_RNG_only_for_planet_description(very_random_seed);
1044 NSString* expandedMessage = OOExpand(valueString);
1045 return [self replaceVariablesInString:expandedMessage];
1046}
#define OOExpand(string,...)
void seed_RNG_only_for_planet_description(Random_Seed s_seed)
struct Random_Seed Random_Seed

◆ expandScriptRightHandSide:

- (NSString *) expandScriptRightHandSide: (NSArray*) rhsComponents
implementation

Extends class PlayerEntity.

Definition at line 542 of file PlayerEntityLegacyScriptEngine.m.

542 :(NSArray*)rhsComponents
543{
544 NSMutableArray* result = nil;
545 NSArray* component = nil;
546 NSString* value = nil;
547
548 result = [NSMutableArray arrayWithCapacity:[rhsComponents count]];
549
550 foreach (component, rhsComponents) {
551 /* Each component is a two-element array. The second element is a
552 string. The first element is a boolean indicating whether the
553 string is a selector (true) or a literal (false).
554
555 All valid selectors return a string or an NSNumber; in either
556 case, -description gives us a useful value to substitute into
557 the expanded string.
558 */
559
560 value = [component oo_stringAtIndex:1];
561
562 if ([[component objectAtIndex:0] boolValue]) {
563 value = [[self performSelector:NSSelectorFromString(value)] description];
564 if (value == nil)
565 value = @"(null)"; // for backwards compatibility
566 }
567
568 [result addObject:value];
569 }
570
571 return [result componentsJoinedByString:@" "];
572}

◆ foundEquipment_bool

- (NSString *) foundEquipment_bool

Extends class PlayerEntity.

Definition at line 916 of file PlayerEntityLegacyScriptEngine.m.

917{
918 return (found_equipment) ? @"YES" : @"NO";
919}

References foundEquipment_bool.

Referenced by foundEquipment_bool.

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

◆ fuelLeakRate_number

- (NSNumber *) fuelLeakRate_number

Extends class PlayerEntity.

Definition at line 1938 of file PlayerEntityLegacyScriptEngine.m.

1939{
1940 return [NSNumber numberWithFloat:[self fuelLeakRate]];
1941}

References PlayerEntity::fuelLeakRate, and fuelLeakRate_number.

Referenced by fuelLeakRate_number.

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

◆ fuelLevel_number

- (NSNumber *) fuelLevel_number

Extends class PlayerEntity.

Definition at line 903 of file PlayerEntityLegacyScriptEngine.m.

904{
905 return [NSNumber numberWithFloat:floor(0.1 * fuel)];
906}

References fuelLevel_number.

Referenced by fuelLevel_number.

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

◆ galaxy_number

- (NSNumber *) galaxy_number

Extends class PlayerEntity.

Definition at line 810 of file PlayerEntityLegacyScriptEngine.m.

811{
812 return [NSNumber numberWithInt:[self currentGalaxyID]];
813}

References PlayerEntity::currentGalaxyID, and galaxy_number.

Referenced by PlayerEntity::doBookkeeping:, PlayerEntity::enterGalacticWitchspace, galaxy_number, PlayerEntity::galaxyNumber, PlayerEntity::setCommanderDataFromDictionary:, PlayerEntity::setSystemID:, PlayerEntity::setTargetSystemID:, and PlayerEntity::setUpAndConfirmOK:saveGame:.

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

◆ gui_screen_string

- (NSString *) gui_screen_string

Extends class PlayerEntity.

Definition at line 805 of file PlayerEntityLegacyScriptEngine.m.

806{
807 return OOStringFromGUIScreenID(gui_screen);
808}
NSString * OOStringFromGUIScreenID(OOGUIScreenID screen) CONST_FUNC

References gui_screen_string, and OOStringFromGUIScreenID().

Referenced by gui_screen_string.

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

◆ increment:

- (void) increment: (NSString*) missionVariableString

Extends class PlayerEntity.

Definition at line 1539 of file PlayerEntityLegacyScriptEngine.m.

1539 :(NSString*)missionVariableString
1540{
1541 BOOL hasMissionPrefix, hasLocalPrefix;
1542 int value = 0;
1543
1544 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1545 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1546
1547 if (hasMissionPrefix) {
1548 value = [[self missionVariableForKey:missionVariableString] intValue];
1549 value++;
1550 [self setMissionVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString];
1551 } else if (hasLocalPrefix) {
1552 value = [[self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] intValue];
1553 value++;
1554 [self setLocalVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1555 } else {
1556 OOLog(kOOLogSyntaxIncrement, @"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1557 }
1558}
static NSString *const kOOLogSyntaxIncrement

References kOOLogSyntaxIncrement, PlayerEntity::localVariableForKey:andMission:, PlayerEntity::missionVariableForKey:, OOLog, PlayerEntity::setLocalVariable:forKey:andMission:, and PlayerEntity::setMissionVariable:forKey:.

Here is the call graph for this function:

◆ launchFromStation

- (void) launchFromStation

Extends class PlayerEntity.

Definition at line 1949 of file PlayerEntityLegacyScriptEngine.m.

1950{
1951 // ensure autosave is ready for the next unscripted launch
1952 if ([UNIVERSE autoSave])
1953 [UNIVERSE setAutoSaveNow:YES];
1954 if ([self status] == STATUS_DOCKING)
1955 [self setStatus:STATUS_DOCKED]; // needed here to prevent the normal update from continuing with docking.
1956 [self leaveDock:[self dockedStation]];
1957}

References PlayerEntity::dockedStation, launchFromStation, PlayerEntity::leaveDock:, ShipEntity::setStatus:, and UNIVERSE.

Referenced by launchFromStation.

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

◆ localVariableForKey:andMission:

- (NSString *) localVariableForKey: (NSString*) variableName
andMission: (NSString*) missionKey 

Extends class PlayerEntity.

Definition at line 613 of file PlayerEntityLegacyScriptEngine.m.

613 :(NSString*)variableName andMission:(NSString*)missionKey
614{
615 return [[localVariables oo_dictionaryForKey:missionKey] objectForKey:variableName];
616}

◆ localVariablesForMission:

- (NSMutableDictionary *) localVariablesForMission: (NSString*) missionKey

Extends class PlayerEntity.

Definition at line 597 of file PlayerEntityLegacyScriptEngine.m.

597 :(NSString*)missionKey
598{
599 NSMutableDictionary* result = nil;
600
601 if (missionKey == nil)
602 return nil;
603
604 result = [localVariables objectForKey:missionKey];
605 if (result == nil) {
606 result = [NSMutableDictionary dictionary];
607 [localVariables setObject:result forKey:missionKey];
608 }
609
610 return result;
611}

References nil.

◆ messageShipAIs:

- (void) messageShipAIs: (NSString*) roles_message

Extends class PlayerEntity.

Definition at line 1286 of file PlayerEntityLegacyScriptEngine.m.

1286 :(NSString*)roles_message
1287{
1288 NSMutableArray* tokens = ScanTokensFromString(roles_message);
1289 NSString* roleString = nil;
1290 NSString* messageString = nil;
1291
1292 if ([tokens count] < 2) {
1293 OOLog(kOOLogSyntaxMessageShipAIs, @"***** SCRIPT ERROR: in %@, CANNOT messageShipAIs: '%@' (bad parameter count)", CurrentScriptDesc(), roles_message);
1294 return;
1295 }
1296
1297 roleString = [tokens objectAtIndex:0];
1298 [tokens removeObjectAtIndex:0];
1299 messageString = [tokens componentsJoinedByString:@" "];
1300
1301 NSArray* targets = [UNIVERSE findShipsMatchingPredicate:HasPrimaryRolePredicate
1302 parameter:roleString
1303 inRange:-1
1304 ofEntity:nil];
1305
1306 ShipEntity* target;
1307 foreach (target, targets) {
1308 [[target getAI] reactToMessage:messageString context:@"messageShipAIs:"];
1309 }
1310}
static NSString *const kOOLogSyntaxMessageShipAIs
void reactToMessage:context:(NSString *message,[context] NSString *debugContext)
Definition AI.m:363

References count, ShipEntity::getAI, kOOLogSyntaxMessageShipAIs, nil, OOLog, AI::reactToMessage:context:, and ScanTokensFromString().

Here is the call graph for this function:

◆ mission_string

- (NSString *) mission_string

Extends class PlayerEntity.

Definition at line 795 of file PlayerEntityLegacyScriptEngine.m.

796{
797 return sMissionStringValue;
798}
static NSString * sMissionStringValue

References mission_string, and sMissionStringValue.

Referenced by mission_string.

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

◆ missionChoice_string

- (NSString *) missionChoice_string

Extends class PlayerEntity.

Definition at line 931 of file PlayerEntityLegacyScriptEngine.m.

932{
933 return missionChoice;
934}

References missionChoice_string.

Referenced by missionChoice_string.

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

◆ missionKeyPress_string

- (NSString *) missionKeyPress_string

Extends class PlayerEntity.

Definition at line 936 of file PlayerEntityLegacyScriptEngine.m.

937{
938 return missionKeyPress;
939}

References missionKeyPress_string.

Referenced by missionKeyPress_string.

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

◆ missionScreenID

- (NSString *) missionScreenID

Extends class PlayerEntity.

Definition at line 2133 of file PlayerEntityLegacyScriptEngine.m.

2134{
2135 return _missionScreenID;
2136}

References missionScreenID.

Referenced by missionScreenID.

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

◆ missionsList

- (NSArray *) missionsList

Extends class PlayerEntity.

Definition at line 632 of file PlayerEntityLegacyScriptEngine.m.

633{
634 NSEnumerator* scriptEnum = nil;
635 NSString* scriptName = nil;
636 NSString* vars = nil;
637 NSMutableArray* result1 = nil;
638 NSMutableArray* result2 = nil;
639
640 result1 = [NSMutableArray array];
641 result2 = [NSMutableArray array];
642
643 NSArray* passengerManifest = [self passengerList];
644 NSArray* contractManifest = [self contractList];
645 NSArray* parcelManifest = [self parcelList];
646
647 if ([passengerManifest count] > 0) {
648 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-passengers")] arrayByAddingObjectsFromArray:passengerManifest]];
649 }
650
651 if ([parcelManifest count] > 0) {
652 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-parcels")] arrayByAddingObjectsFromArray:parcelManifest]];
653 }
654
655 if ([contractManifest count] > 0) {
656 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-contracts")] arrayByAddingObjectsFromArray:contractManifest]];
657 }
658
659 /* For proper display, array entries need to all be after string
660 * entries, so sort them now */
661 for (scriptEnum = [worldScripts keyEnumerator]; (scriptName = [scriptEnum nextObject]);) {
662 vars = [mission_variables objectForKey:scriptName];
663
664 if (vars != nil) {
665 if ([vars isKindOfClass:[NSString class]]) {
666 [result1 addObject:vars];
667 } else if ([vars isKindOfClass:[NSArray class]]) {
668 BOOL found = NO;
669 NSArray* element = nil;
670 foreach (element, result2) {
671 if ([[element oo_stringAtIndex:0] isEqualToString:[(NSArray*)vars oo_stringAtIndex:0]]) {
672
673 [result2 removeObject:element];
674 NSRange notTheHeader;
675 notTheHeader.location = 1;
676 notTheHeader.length = [(NSArray*)vars count] - 1;
677 [result2 addObject:[element arrayByAddingObjectsFromArray:[(NSArray*)vars subarrayWithRange:notTheHeader]]];
678 found = YES;
679 break;
680 }
681 }
682 if (!found) {
683 [result2 addObject:vars];
684 }
685 }
686 }
687 }
688 return [result1 arrayByAddingObjectsFromArray:result2];
689}

References PlayerEntity::contractList, count, missionsList, nil, PlayerEntity::parcelList, and PlayerEntity::passengerList.

Referenced by missionsList.

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

◆ missionTitle

- (NSString *) missionTitle

Extends class PlayerEntity.

Definition at line 1892 of file PlayerEntityLegacyScriptEngine.m.

1893{
1894 return _missionTitle;
1895}

References missionTitle.

Referenced by missionTitle.

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

◆ missionVariableForKey:

- (NSString *) missionVariableForKey: (NSString*) key

Extends class PlayerEntity.

Definition at line 579 of file PlayerEntityLegacyScriptEngine.m.

579 :(NSString*)key
580{
581 NSString* result = nil;
582 if (key != nil)
583 result = [mission_variables objectForKey:key];
584 return result;
585}

References nil.

◆ missionVariables

- (NSDictionary *) missionVariables

Extends class PlayerEntity.

Definition at line 574 of file PlayerEntityLegacyScriptEngine.m.

575{
576 return mission_variables;
577}

References missionVariables.

Referenced by missionVariables.

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

◆ PerformActionStatment

+ (void) PerformActionStatment (NSArray *) statement
(Entity *) target 
implementation

Extends class PlayerEntity.

Definition at line 165 of file PlayerEntityLegacyScriptEngine.m.

166{
167 /* A sanitized action statement takes the form of an array:
168 (false, selector [, argument])
169 The first element is always false. The second is the method selector
170 (as a string). If the method takes an argument, the third argument is
171 the argument string.
172
173 The sanitizer is responsible for ensuring that there is an argument,
174 even if it's the empty string, for any selector with a colon at the
175 end, and no arguments for selectors without colons. The runner can
176 therefore use the list's element count as a flag without examining the
177 selector.
178 */
179
180 NSString* selectorString = nil;
181 NSString* argumentString = nil;
182 NSString* expandedString = nil;
183 SEL selector = NULL;
184 NSMutableDictionary* locals = nil;
185 PlayerEntity* player = PLAYER;
186
187 selectorString = [statement objectAtIndex:1];
188 if ([statement count] > 2)
189 argumentString = [statement objectAtIndex:2];
190
191 selector = NSSelectorFromString(selectorString);
192
193 if (target == nil || ![target respondsToSelector:selector]) {
194 target = player;
195 }
196
197 if (argumentString != nil) {
198 // Method with argument; substitute [description] expressions.
199 locals = [player localVariablesForMission:sCurrentMissionKey];
200 expandedString = OOExpandDescriptionString(OOStringExpanderDefaultRandomSeed(), argumentString, nil, locals, nil, kOOExpandNoOptions);
201
202 [target performSelector:selector withObject:expandedString];
203 } else {
204 // Method without argument.
205 [target performSelector:selector];
206 }
207}
@ kOOExpandNoOptions
NSString * OOExpandDescriptionString(Random_Seed seed, NSString *string, NSDictionary *overrides, NSDictionary *legacyLocals, NSString *systemName, OOExpandOptions options)
#define PLAYER
NSMutableDictionary * localVariablesForMission:(NSString *missionKey)

References count, kOOExpandNoOptions, PlayerEntity::localVariablesForMission:, nil, OOExpandDescriptionString(), OOStringExpanderDefaultRandomSeed(), PerformActionStatment, and PLAYER.

Referenced by PerformActionStatment, and PerformScriptActions.

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

◆ PerformConditionalStatment

+ (void) PerformConditionalStatment (NSArray *) actions
(Entity *) target 
implementation

Extends class PlayerEntity.

Definition at line 142 of file PlayerEntityLegacyScriptEngine.m.

143{
144 /* A sanitized conditional statement takes the form of an array:
145 (true, conditions, trueActions, falseActions)
146 The first element is always true. The second is an array of conditions.
147 The third and four elements are actions to perform if the conditions
148 evaluate to true or false, respectively.
149 */
150
151 NSArray* conditions = nil;
152 NSArray* actions = nil;
153
154 conditions = [statement objectAtIndex:1];
155
156 if (TestScriptConditions(conditions)) {
157 actions = [statement objectAtIndex:2];
158 } else {
159 actions = [statement objectAtIndex:3];
160 }
161
162 PerformScriptActions(actions, target);
163}
static BOOL TestScriptConditions(NSArray *conditions)
static void PerformScriptActions(NSArray *actions, Entity *target)

References nil, PerformConditionalStatment, PerformScriptActions, and TestScriptConditions.

Referenced by PerformConditionalStatment, and PerformScriptActions.

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

◆ PerformScriptActions

+ (void) PerformScriptActions (NSArray *) actions
(Entity *) target 
implementation

Extends class PlayerEntity.

Definition at line 130 of file PlayerEntityLegacyScriptEngine.m.

131{
132 NSArray* statement = nil;
133 foreach (statement, actions) {
134 if ([[statement objectAtIndex:0] boolValue]) {
135 PerformConditionalStatment(statement, target);
136 } else {
137 PerformActionStatment(statement, target);
138 }
139 }
140}
static void PerformConditionalStatment(NSArray *actions, Entity *target)
static void PerformActionStatment(NSArray *statement, Entity *target)

References nil, PerformActionStatment, PerformConditionalStatment, and PerformScriptActions.

Referenced by PerformConditionalStatment, PerformScriptActions, and runScriptActions:withContextName:forTarget:.

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

◆ planet_number

- (NSNumber *) planet_number

Extends class PlayerEntity.

Definition at line 815 of file PlayerEntityLegacyScriptEngine.m.

816{
817 return [NSNumber numberWithInt:[self currentSystemID]];
818}

References PlayerEntity::currentSystemID, and planet_number.

Referenced by planet_number.

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

◆ playSound:

- (void) playSound: (NSString*) soundName

Extends class PlayerEntity.

Definition at line 2108 of file PlayerEntityLegacyScriptEngine.m.

2108 :(NSString*)soundName
2109{
2110 [self playLegacyScriptSound:soundName];
2111}

References PlayerEntity::playLegacyScriptSound:.

Here is the call graph for this function:

◆ processSceneDictionary:atOffset:

- (BOOL) processSceneDictionary: (NSDictionary*) couplet
atOffset: (Vector) off 

Extends class PlayerEntity.

Definition at line 2259 of file PlayerEntityLegacyScriptEngine.m.

2259 :(NSDictionary*)couplet atOffset:(Vector)off
2260{
2261 NSArray* conditions = [couplet objectForKey:@"conditions"];
2262 NSArray* actions = nil;
2263 if ([couplet objectForKey:@"do"])
2264 actions = [NSArray arrayWithObject:[couplet objectForKey:@"do"]];
2265 NSArray* else_actions = nil;
2266 if ([couplet objectForKey:@"else"])
2267 else_actions = [NSArray arrayWithObject:[couplet objectForKey:@"else"]];
2268 BOOL success = YES;
2269 if (conditions == nil) {
2270 OOLog(@"script.scene.couplet.badConditions", @"***** SCENE ERROR: %@ - conditions not %@, returning %@.", [couplet description], @" found", @"YES and performing 'do' actions");
2271 } else {
2272 if (![conditions isKindOfClass:[NSArray class]]) {
2273 OOLog(@"script.scene.couplet.badConditions", @"***** SCENE ERROR: %@ - conditions not %@, returning %@.", [conditions description], @"an array", @"NO");
2274 return NO;
2275 }
2276 }
2277
2278 // check conditions..
2279 success = TestScriptConditions(OOSanitizeLegacyScriptConditions(conditions, @"<scene dictionary conditions>"));
2280
2281 // perform successful actions...
2282 if ((success) && (actions) && [actions count])
2283 [self addScene:actions atOffset:off];
2284
2285 // perform unsuccessful actions
2286 if ((!success) && (else_actions) && [else_actions count])
2287 [self addScene:else_actions atOffset:off];
2288
2289 return success;
2290}
NSArray * OOSanitizeLegacyScriptConditions(NSArray *conditions, NSString *context)

References PlayerEntity::addScene:atOffset:, count, nil, OOLog, OOSanitizeLegacyScriptConditions(), and TestScriptConditions.

Here is the call graph for this function:

◆ processSceneString:atOffset:

- (BOOL) processSceneString: (NSString*) item
atOffset: (Vector) off 

Extends class PlayerEntity.

Definition at line 2292 of file PlayerEntityLegacyScriptEngine.m.

2292 :(NSString*)item atOffset:(Vector)off
2293{
2294 Vector model_p0;
2295 Quaternion model_q;
2296
2297 if (!item)
2298 return NO;
2299 NSArray* i_info = ScanTokensFromString(item);
2300 if (!i_info)
2301 return NO;
2302 NSString* i_key = [(NSString*)[i_info objectAtIndex:0] lowercaseString];
2303
2304 OOLog(kOOLogNoteProcessSceneString, @"..... processing %@ (%@)", i_info, i_key);
2305
2306 //
2307 // recursively add further scenes:
2308 //
2309 if ([i_key isEqualToString:@"scene"]) {
2310 if ([i_info count] != 5) // must be scene_key_x_y_z
2311 return NO; // 0.... 1.. 2 3 4
2312 NSString* scene_key = (NSString*)[i_info objectAtIndex:1];
2313 Vector scene_offset = { 0 };
2314 ScanVectorFromString([[i_info subarrayWithRange:NSMakeRange(2, 3)] componentsJoinedByString:@" "], &scene_offset);
2315 scene_offset.x += off.x;
2316 scene_offset.y += off.y;
2317 scene_offset.z += off.z;
2318 NSArray* scene_items = (NSArray*)[[UNIVERSE descriptions] objectForKey:scene_key];
2319 OOLog(kOOLogDebugProcessSceneStringAddScene, @"::::: adding scene: '%@'", scene_key);
2320 //
2321 if (scene_items) {
2322 [self addScene:scene_items atOffset:scene_offset];
2323 return YES;
2324 } else
2325 return NO;
2326 }
2327 //
2328 // Add ship models:
2329 //
2330 if ([i_key isEqualToString:@"ship"] || [i_key isEqualToString:@"model"] || [i_key isEqualToString:@"role"]) {
2331 if ([i_info count] != 10) // must be item_name_x_y_z_W_X_Y_Z_align
2332 {
2333 return NO; // 0... 1... 2 3 4 5 6 7 8 9....
2334 }
2335
2336 ShipEntity* ship = nil;
2337
2338 if ([i_key isEqualToString:@"ship"] || [i_key isEqualToString:@"model"]) {
2339 ship = [UNIVERSE newShipWithName:[i_info oo_stringAtIndex:1]];
2340 } else if ([i_key isEqualToString:@"role"]) {
2341 ship = [UNIVERSE newShipWithRole:[i_info oo_stringAtIndex:1]];
2342 }
2343 if (!ship)
2344 return NO;
2345
2346 ScanVectorAndQuaternionFromString([[i_info subarrayWithRange:NSMakeRange(2, 7)] componentsJoinedByString:@" "], &model_p0, &model_q);
2347
2348 Vector model_offset = positionOffsetForShipInRotationToAlignment(ship, model_q, [i_info oo_stringAtIndex:9]);
2349 model_p0 = vector_add(model_p0, vector_subtract(off, model_offset));
2350
2351 OOLog(kOOLogDebugProcessSceneStringAddModel, @"::::: adding model to scene:'%@'", ship);
2352 [ship setOrientation:model_q];
2353 [ship setPosition:vectorToHPVector(model_p0)];
2354 [UNIVERSE setMainLightPosition:(Vector) { DEMO_LIGHT_POSITION }]; // set light origin
2355 [ship setScanClass:CLASS_NO_DRAW];
2356 [ship switchAITo:@"nullAI.plist"];
2357 [UNIVERSE addEntity:ship]; // STATUS_IN_FLIGHT, AI state GLOBAL
2358 [ship setStatus:STATUS_COCKPIT_DISPLAY];
2359 [ship setRoll:0.0];
2360 [ship setPitch:0.0];
2361 [ship setVelocity:kZeroVector];
2362 [ship setBehaviour:BEHAVIOUR_STOP_STILL];
2363
2364 [ship release];
2365 return YES;
2366 }
2367 //
2368 // Add player ship model:
2369 //
2370 if ([i_key isEqualToString:@"player"]) {
2371 if ([i_info count] != 9) // must be player_x_y_z_W_X_Y_Z_align
2372 return NO; // 0..... 1 2 3 4 5 6 7 8....
2373
2374 ShipEntity* doppelganger = [UNIVERSE newShipWithName:[self shipDataKey]]; // retain count = 1
2375 if (!doppelganger)
2376 return NO;
2377
2378 ScanVectorAndQuaternionFromString([[i_info subarrayWithRange:NSMakeRange(1, 7)] componentsJoinedByString:@" "], &model_p0, &model_q);
2379
2380 Vector model_offset = positionOffsetForShipInRotationToAlignment(doppelganger, model_q, (NSString*)[i_info objectAtIndex:8]);
2381 model_p0.x += off.x - model_offset.x;
2382 model_p0.y += off.y - model_offset.y;
2383 model_p0.z += off.z - model_offset.z;
2384
2385 OOLog(kOOLogDebugProcessSceneStringAddModel, @"::::: adding model to scene:'%@'", doppelganger);
2386 [doppelganger setOrientation:model_q];
2387 [doppelganger setPosition:vectorToHPVector(model_p0)];
2388 [UNIVERSE setMainLightPosition:(Vector) { DEMO_LIGHT_POSITION }]; // set light origin
2389 [doppelganger setScanClass:CLASS_NO_DRAW];
2390 [doppelganger switchAITo:@"nullAI.plist"];
2391 [UNIVERSE addEntity:doppelganger];
2392 [doppelganger setStatus:STATUS_COCKPIT_DISPLAY];
2393 [doppelganger setRoll:0.0];
2394 [doppelganger setPitch:0.0];
2395 [doppelganger setVelocity:kZeroVector];
2396 [doppelganger setBehaviour:BEHAVIOUR_STOP_STILL];
2397
2398 [doppelganger release];
2399 return YES;
2400 }
2401 //
2402 // Add planet model: selected via gui-scene-show-planet/-local-planet
2403 //
2404 if ([i_key isEqualToString:@"local-planet"] || [i_key isEqualToString:@"target-planet"]) {
2405 if ([i_info count] != 4) // must be xxxxx-planet_x_y_z
2406 return NO; // 0........... 1 2 3
2407
2408 // sunlight position for F7 screen is chosen pseudo randomly from 4 different positions.
2409 if (info_system_id & 8) {
2410 _sysInfoLight = (info_system_id & 2) ? (Vector) { -10000.0, 4000.0, -10000.0 } : (Vector) { -12000.0, -5000.0, -10000.0 };
2411 } else {
2412 _sysInfoLight = (info_system_id & 2) ? (Vector) { 6000.0, -5000.0, -10000.0 } : (Vector) { 6000.0, 4000.0, -10000.0 };
2413 }
2414
2415 [UNIVERSE setMainLightPosition:_sysInfoLight]; // set light origin
2416
2417#if NEW_PLANETS
2418 OOPlanetEntity* originalPlanet = nil;
2419 if ([i_key isEqualToString:@"local-planet"] && [UNIVERSE sun]) {
2420 originalPlanet = [UNIVERSE planet];
2421 } else {
2422 originalPlanet = [[[OOPlanetEntity alloc] initAsMainPlanetForSystem:info_system_id] autorelease];
2423 }
2424 OOPlanetEntity* doppelganger = [originalPlanet miniatureVersion];
2425 if (doppelganger == nil)
2426 return NO;
2427
2428#else
2429 OOPlanetEntity* doppelganger = nil;
2430 NSMutableDictionary* planetInfo = [NSMutableDictionary dictionaryWithDictionary:[UNIVERSE generateSystemData:target_system_seed]];
2431
2432 if ([i_key isEqualToString:@"local-planet"] && [UNIVERSE sun]) {
2433 OOPlanetEntity* mainPlanet = [UNIVERSE planet];
2434 OOTexture* texture = [mainPlanet texture];
2435 if (texture != nil) {
2436 [planetInfo setObject:texture forKey:@"_oo_textureObject"];
2437 [planetInfo oo_setBool:[mainPlanet isExplicitlyTextured] forKey:@"_oo_isExplicitlyTextured"];
2438 [planetInfo oo_setBool:YES forKey:@"mainForLocalSystem"];
2439 //[planetInfo oo_setQuaternion:[mainPlanet orientation] forKey:@"orientation"]; // the orientation is overwritten later on, without regard for the real planet's orientation.
2440 }
2441 }
2442
2443 doppelganger = [[OOPlanetEntity alloc] initFromDictionary:planetInfo withAtmosphere:YES andSeed:target_system_seed];
2444 [doppelganger miniaturize];
2445 [doppelganger autorelease];
2446
2447 if (doppelganger == nil)
2448 return NO;
2449#endif
2450
2451 ScanVectorFromString([[i_info subarrayWithRange:NSMakeRange(1, 3)] componentsJoinedByString:@" "], &model_p0);
2452
2453 // miniature radii are roughly between 60 and 120. Place miniatures with a radius bigger than 60 a bit futher away.
2454 model_p0 = vector_multiply_scalar(model_p0, 1 - 0.5 * ((60 - [doppelganger radius]) / 60));
2455
2456 model_p0 = vector_add(model_p0, off);
2457
2458 // TODO: find better quaternion values.
2459#if NEW_PLANETS
2460 // Quaternion model_q = { 0.83, 0.365148, 0.182574, 0.0 }; // shows new planets' north pole.
2461 // Quaternion model_q = { 0.83, -0.365148, 0.182574, 0.0 }; // shows new planets' south pole.
2462 Quaternion model_q = { 0.83, 0.12, 0.44, 0.0 }; // new planets - default orientation.
2463#else
2464 // model_q = make_quaternion( M_SQRT1_2, 0.314, M_SQRT1_2, 0.0 );
2465 Quaternion model_q = { 0.833492, 0.333396, 0.440611, 0.0 };
2466#endif
2467 OOLog(kOOLogDebugProcessSceneStringAddMiniPlanet, @"::::: adding %@ to scene:'%@'", i_key, doppelganger);
2468 [doppelganger setOrientation:model_q];
2469 // HPVect: mission screen coordinates are small enough that we don't need high-precision for calculations
2470 [doppelganger setPosition:vectorToHPVector(model_p0)];
2471 /* MKW - add rotation based on current time
2472 * - necessary to duplicate the rotation already performed in PlanetEntity.m since we reset the orientation above. */
2473 int deltaT = floor(fmod([self clockTimeAdjusted], 86400));
2474 [doppelganger update:deltaT];
2475 [UNIVERSE addEntity:doppelganger];
2476
2477 return YES;
2478 }
2479
2480 return NO;
2481}
BOOL ScanVectorAndQuaternionFromString(NSString *xyzwxyzString, Vector *outVector, Quaternion *outQuaternion)
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
OOINLINE Vector vector_add(Vector a, Vector b) INLINE_CONST_FUNC
Definition OOVector.h:195
OOINLINE Vector vector_subtract(Vector a, Vector b) INLINE_CONST_FUNC
Definition OOVector.h:218
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
Definition OOVector.h:180
static NSString *const kOOLogDebugProcessSceneStringAddMiniPlanet
static NSString *const kOOLogDebugProcessSceneStringAddModel
static NSString *const kOOLogDebugProcessSceneStringAddScene
static NSString *const kOOLogNoteProcessSceneString
void setVelocity:(Vector vel)
Definition Entity.m:703
void setOrientation:(Quaternion quat)
Definition Entity.m:676
void setScanClass:(OOScanClass sClass)
Definition Entity.m:738
void setPosition:(HPVector posn)
Definition Entity.m:608
void setStatus:(OOEntityStatus stat)
void setRoll:(double amount)
void setPitch:(double amount)
void setBehaviour:(OOBehaviour cond)
void switchAITo:(NSString *aiString)
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References PlayerEntity::addScene:atOffset:, count, kOOLogDebugProcessSceneStringAddMiniPlanet, kOOLogDebugProcessSceneStringAddModel, kOOLogDebugProcessSceneStringAddScene, kOOLogNoteProcessSceneString, nil, OOLog, ScanTokensFromString(), ScanVectorAndQuaternionFromString(), ScanVectorFromString(), ShipEntity::setBehaviour:, Entity::setOrientation:, ShipEntity::setPitch:, Entity::setPosition:, ShipEntity::setRoll:, Entity::setScanClass:, ShipEntity::setStatus:, Entity::setVelocity:, ShipEntity::shipDataKey, ShipEntity::switchAITo:, UNIVERSE, vector_add(), vector_multiply_scalar(), vector_subtract(), Vector::x, Vector::y, and Vector::z.

Here is the call graph for this function:

◆ pseudoFixedD100_number

- (NSNumber *) pseudoFixedD100_number

Extends class PlayerEntity.

Definition at line 862 of file PlayerEntityLegacyScriptEngine.m.

863{
864 return [NSNumber numberWithInt:[self systemPseudoRandom100]];
865}

References pseudoFixedD100_number, and PlayerEntity::systemPseudoRandom100.

Referenced by pseudoFixedD100_number.

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

◆ pseudoFixedD256_number

- (NSNumber *) pseudoFixedD256_number

Extends class PlayerEntity.

Definition at line 873 of file PlayerEntityLegacyScriptEngine.m.

874{
875 return [NSNumber numberWithInt:[self systemPseudoRandom256]];
876}

References pseudoFixedD256_number, and PlayerEntity::systemPseudoRandom256.

Referenced by pseudoFixedD256_number.

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

◆ RecursiveRemapStatus

- (OOINLINE OOEntityStatus) RecursiveRemapStatus (OOEntityStatus) status
implementation

Extends class PlayerEntity.

Definition at line 233 of file PlayerEntityLegacyScriptEngine.m.

234{
235 // Some player stutuses should only be seen once per "event".
236 // This remaps them to something innocuous in case of recursion.
237 if (status == STATUS_DOCKING || status == STATUS_LAUNCHING || status == STATUS_ENTERING_WITCHSPACE || status == STATUS_EXITING_WITCHSPACE) {
238 return STATUS_IN_FLIGHT;
239 } else {
240 return status;
241 }
242}

References OOINLINE.

Referenced by checkScript.

Here is the caller graph for this function:

◆ refreshMissionScreenTextEntry

- (void) refreshMissionScreenTextEntry

Extends class PlayerEntity.

Definition at line 2160 of file PlayerEntityLegacyScriptEngine.m.

2161{
2162 MyOpenGLView* gameView = [UNIVERSE gameView];
2163 GuiDisplayGen* gui = [UNIVERSE gui];
2164 NSUInteger end_row = 21;
2165 if ([[self hud] allowBigGui]) {
2166 end_row = 27;
2167 }
2168
2169 [gui setText:[NSString stringWithFormat:DESC(@"mission-screen-text-prompt-@"), [gameView typedString]] forRow:end_row align:GUI_ALIGN_LEFT];
2170 [gui setColor:[OOColor cyanColor] forRow:end_row];
2171
2172 [gui setShowTextCursor:YES];
2173 [gui setCurrentRow:end_row];
2174}
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setShowTextCursor:(BOOL yesno)
void setCurrentRow:(OOGUIRow value)
NSMutableString * typedString
OOColor * cyanColor()
Definition OOColor.m:274

References OOColor::cyanColor, refreshMissionScreenTextEntry, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setCurrentRow:, GuiDisplayGen::setShowTextCursor:, GuiDisplayGen::setText:forRow:align:, and MyOpenGLView::typedString.

Referenced by refreshMissionScreenTextEntry.

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

◆ removeAllCargo

- (void) removeAllCargo

Extends class PlayerEntity.

Definition at line 1216 of file PlayerEntityLegacyScriptEngine.m.

1217{
1218 [self removeAllCargo:NO];
1219}

References removeAllCargo, and PlayerEntity::removeAllCargo:.

Referenced by removeAllCargo, and removeAllCargo:.

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

◆ removeAllCargo:

- (void) removeAllCargo: (BOOL) forceRemoval

Extends class PlayerEntity.

Definition at line 1221 of file PlayerEntityLegacyScriptEngine.m.

1221 :(BOOL)forceRemoval
1222{
1223 // Misnamed method. It only removes cargo measured in TONS, g & Kg items are not removed. --Kaks 20091004
1224 OOCommodityType type;
1225
1226 if (scriptTarget != self)
1227 return;
1228
1229 if ([self status] != STATUS_DOCKED && !forceRemoval) {
1230 OOLogWARN(kOOLogRemoveAllCargoNotDocked, @"%@removeAllCargo only works when docked.", [NSString stringWithFormat:@" in %@, ", CurrentScriptDesc()]);
1231 return;
1232 }
1233
1234 OOLog(kOOLogNoteRemoveAllCargo, @"%@ removeAllCargo", forceRemoval ? @"Forcing" : @"Going to");
1235
1236 foreach (type, [shipCommodityData goods]) {
1237 if ([shipCommodityData massUnitForGood:type] == UNITS_TONS) {
1238 [shipCommodityData setQuantity:0 forGood:type];
1239 }
1240 }
1241
1242 if (forceRemoval && [self status] != STATUS_DOCKED) {
1243 NSInteger i;
1244 for (i = [cargo count] - 1; i >= 0; i--) {
1245 ShipEntity* canister = [cargo objectAtIndex:i];
1246 if (!canister)
1247 break;
1248 // Since we are forcing cargo removal, we don't really care about the unit of measurement. Any
1249 // commodity at more than 1000kg or 1000000gr will be inside cargopods, so remove those too.
1250 [cargo removeObjectAtIndex:i];
1251 }
1252 }
1253
1254 DESTROY(specialCargo);
1255
1256 [self calculateCurrentCargo];
1257}
#define DESTROY(x)
static NSString *const kOOLogRemoveAllCargoNotDocked
static NSString *const kOOLogNoteRemoveAllCargo

References PlayerEntity::calculateCurrentCargo, count, DESTROY, kOOLogNoteRemoveAllCargo, kOOLogRemoveAllCargoNotDocked, OOLog, OOLogWARN, removeAllCargo, scriptTarget, and UNITS_TONS.

Here is the call graph for this function:

◆ removeEqScriptForKey:

- (void) removeEqScriptForKey: (NSString*) eq_key

Extends class PlayerEntity.

Definition at line 2520 of file PlayerEntityLegacyScriptEngine.m.

2520 :(NSString*)eq_key
2521{
2522 if (eq_key == nil)
2523 return;
2524
2525 NSString* key = nil;
2526 NSUInteger i, count = [eqScripts count];
2527
2528 for (i = 0; i < count; i++) {
2529 key = [[eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0];
2530 if ([key isEqualToString:eq_key]) {
2531 [eqScripts removeObjectAtIndex:i];
2532
2533 if (i == primedEquipment)
2534 primedEquipment = count; // primed-none
2535 else if (i < primedEquipment)
2536 primedEquipment--; // track the primed equipment
2537 if (count == primedEquipment)
2538 primedEquipment--; // the array has shrunk by one!
2539
2540 OOLog(@"player.equipmentScript", @"Removed equipment %@, with the following script property: '%@'.", eq_key, [[OOEquipmentType equipmentTypeWithIdentifier:eq_key] scriptName]);
2541 }
2542 }
2543}

References count, nil, and OOLog.

◆ removeEquipment:

- (void) removeEquipment: (NSString*) equipString

Extends class PlayerEntity.

Definition at line 1120 of file PlayerEntityLegacyScriptEngine.m.

1120 :(NSString*)equipKey // eg. EQ_NAVAL_ENERGY_UNIT
1121{
1122 if (scriptTarget != self)
1123 return;
1124
1125 if ([equipKey isEqualToString:@"EQ_FUEL"]) {
1126 fuel = 0;
1127 return;
1128 }
1129
1130 if ([equipKey isEqualToString:@"EQ_CARGO_BAY"] && [self hasEquipmentItem:equipKey]
1131 && ([self extraCargo] > [self availableCargoSpace])) {
1132 OOLog(kOOLogSyntaxRemoveEquipment, @"***** SCRIPT ERROR: in %@, CANNOT remove cargo bay. Too much cargo.", CurrentScriptDesc());
1133 return;
1134 }
1135 if ([self hasEquipmentItem:equipKey] || [self hasEquipmentItem:[equipKey stringByAppendingString:@"_DAMAGED"]]) {
1136 [self removeEquipmentItem:equipKey];
1137 }
1138}
static NSString *const kOOLogSyntaxRemoveEquipment

References kOOLogSyntaxRemoveEquipment, OOLog, PlayerEntity::removeEquipmentItem:, and scriptTarget.

Here is the call graph for this function:

◆ removeMissionDestination:

- (void) removeMissionDestination: (NSString*) destinations

Extends class PlayerEntity.

Definition at line 1858 of file PlayerEntityLegacyScriptEngine.m.

1858 :(NSString*)destinations
1859{
1860 unsigned j;
1861 int dest;
1862 NSMutableArray* tokens = ScanTokensFromString(destinations);
1863
1864 for (j = 0; j < [tokens count]; j++) {
1865 dest = [[tokens objectAtIndex:j] intValue];
1866 if (dest < 0 || dest > 255)
1867 continue;
1868
1869 [self removeMissionDestinationMarker:[self defaultMarker:dest]];
1870 }
1871}

References PlayerEntity::defaultMarker:, PlayerEntity::removeMissionDestinationMarker:, and ScanTokensFromString().

Here is the call graph for this function:

◆ replaceVariablesInString:

- (NSString *) replaceVariablesInString: (NSString*) args

Extends class PlayerEntity.

Definition at line 691 of file PlayerEntityLegacyScriptEngine.m.

691 :(NSString*)args
692{
693 NSMutableDictionary* locals = [self localVariablesForMission:sCurrentMissionKey];
694 NSMutableString* resultString = [NSMutableString stringWithString:args];
695 NSString* valueString;
696 unsigned i;
697 NSMutableArray* tokens = ScanTokensFromString(args);
698
699 for (i = 0; i < [tokens count]; i++) {
700 valueString = [tokens objectAtIndex:i];
701
702 if ([valueString hasPrefix:@"mission_"] && [mission_variables objectForKey:valueString]) {
703 [resultString replaceOccurrencesOfString:valueString withString:[mission_variables objectForKey:valueString] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
704 } else if ([locals objectForKey:valueString]) {
705 [resultString replaceOccurrencesOfString:valueString withString:[locals objectForKey:valueString] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
706 } else if (([valueString hasSuffix:@"_number"]) || ([valueString hasSuffix:@"_bool"]) || ([valueString hasSuffix:@"_string"])) {
707 SEL valueselector = NSSelectorFromString(valueString);
708 if ([self respondsToSelector:valueselector]) {
709 [resultString replaceOccurrencesOfString:valueString withString:[NSString stringWithFormat:@"%@", [self performSelector:valueselector]] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
710 }
711 } else if ([valueString hasPrefix:@"["] && [valueString hasSuffix:@"]"]) {
712 NSString* replaceString = OOExpand(valueString);
713 [resultString replaceOccurrencesOfString:valueString withString:replaceString options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
714 }
715 }
716
717 OOLog(kOOLogDebugReplaceVariablesInString, @"EXPANSION: \"%@\" becomes \"%@\"", args, resultString);
718
719 return [NSString stringWithString:resultString];
720}
static NSString *const kOOLogDebugReplaceVariablesInString

References kOOLogDebugReplaceVariablesInString, PlayerEntity::localVariablesForMission:, OOExpand, OOLog, and ScanTokensFromString().

Here is the call graph for this function:

◆ reset:

- (void) reset: (NSString*) missionvariable

Extends class PlayerEntity.

Definition at line 1522 of file PlayerEntityLegacyScriptEngine.m.

1522 :(NSString*)missionvariable
1523{
1524 NSString* missionVariableString = [missionvariable stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1525 BOOL hasMissionPrefix, hasLocalPrefix;
1526
1527 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1528 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1529
1530 if (hasMissionPrefix) {
1531 [self setMissionVariable:nil forKey:missionVariableString];
1532 } else if (hasLocalPrefix) {
1533 [self setLocalVariable:nil forKey:missionVariableString andMission:sCurrentMissionKey];
1534 } else {
1535 OOLog(kOOLogSyntaxReset, @"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1536 }
1537}
static NSString *const kOOLogSyntaxReset

References kOOLogSyntaxReset, OOLog, PlayerEntity::setLocalVariable:forKey:andMission:, and PlayerEntity::setMissionVariable:forKey:.

Here is the call graph for this function:

◆ resetMissionChoice

- (void) resetMissionChoice

Extends class PlayerEntity.

Definition at line 1828 of file PlayerEntityLegacyScriptEngine.m.

1829{
1830 [self setMissionChoice:nil];
1831}

References resetMissionChoice, and PlayerEntity::setMissionChoice:.

Referenced by resetMissionChoice.

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

◆ resetScriptTimer

- (void) resetScriptTimer

Extends class PlayerEntity.

Definition at line 1652 of file PlayerEntityLegacyScriptEngine.m.

1653{
1654 script_time = 0.0;
1655 script_time_check = SCRIPT_TIMER_INTERVAL;
1656 script_time_interval = SCRIPT_TIMER_INTERVAL;
1657}
#define SCRIPT_TIMER_INTERVAL

References resetScriptTimer, and SCRIPT_TIMER_INTERVAL.

Referenced by resetScriptTimer.

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

◆ runScriptActions:withContextName:forTarget:

- (void) runScriptActions: (NSArray*) sanitizedActions
withContextName: (NSString*) contextName
forTarget: (ShipEntity*) target 

Extends class PlayerEntity.

Definition at line 321 of file PlayerEntityLegacyScriptEngine.m.

321 :(NSArray*)actions withContextName:(NSString*)contextName forTarget:(ShipEntity*)target
322{
323 NSAutoreleasePool* pool = nil;
324 NSString* oldMissionKey = nil;
325 NSString* volatile theMissionKey = contextName; // Work-around for silly exception macros
326
327 pool = [[NSAutoreleasePool alloc] init];
328
329 // FIXME: does this actually make sense in the context of non-missions?
330 oldMissionKey = sCurrentMissionKey;
331 sCurrentMissionKey = theMissionKey;
332
333 @try {
334 PerformScriptActions(actions, target);
335 }
336 @catch (NSException* exception) {
337 OOLog(@"script.error.exception",
338 @"***** EXCEPTION %@: %@ while handling legacy script actions for %@",
339 [exception name],
340 [exception reason],
341 [theMissionKey hasPrefix:kActionTempPrefix] ? [target shortDescription] : theMissionKey);
342 // Suppress exception
343 }
344
345 sCurrentMissionKey = oldMissionKey;
346 [pool release];
347}

References kActionTempPrefix, nil, OOLog, PerformScriptActions, and sCurrentMissionKey.

Here is the call graph for this function:

◆ runUnsanitizedScriptActions:allowingAIMethods:withContextName:forTarget:

- (void) runUnsanitizedScriptActions: (NSArray*) unsanitizedActions
allowingAIMethods: (BOOL) allowAIMethods
withContextName: (NSString*) contextName
forTarget: (ShipEntity*) target 

Extends class PlayerEntity.

Definition at line 349 of file PlayerEntityLegacyScriptEngine.m.

349 :(NSArray*)actions allowingAIMethods:(BOOL)allowAIMethods withContextName:(NSString*)contextName forTarget:(ShipEntity*)target
350{
351 [self runScriptActions:OOSanitizeLegacyScript(actions, contextName, allowAIMethods)
352 withContextName:contextName
353 forTarget:target];
354}

References PlayerEntity::runScriptActions:withContextName:forTarget:.

Here is the call graph for this function:

◆ score_number

- (NSNumber *) score_number

Extends class PlayerEntity.

Definition at line 820 of file PlayerEntityLegacyScriptEngine.m.

821{
822 return [NSNumber numberWithUnsignedInt:[self score]];
823}

References PlayerEntity::score, and score_number.

Referenced by score_number.

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

◆ scriptTarget

- (ShipEntity *) scriptTarget

Extends class PlayerEntity.

Definition at line 228 of file PlayerEntityLegacyScriptEngine.m.

229{
230 return scriptTarget;
231}

References scriptTarget.

Referenced by awardCargo:, awardCredits:, awardEquipment:, awardShipKills:, ejectItem:, removeAllCargo:, removeEquipment:, scriptTarget, setFuelLeak:, setScriptTarget:, and useSpecialCargo:.

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

◆ scriptTestCondition:

- (BOOL) scriptTestCondition: (NSArray*) scriptCondition
implementation

Extends class PlayerEntity.

Definition at line 374 of file PlayerEntityLegacyScriptEngine.m.

374 :(NSArray*)scriptCondition
375{
376 /* Test a script condition sanitized by OOLegacyScriptWhitelist.
377
378 A sanitized condition is an array of the form:
379 (opType, rawString, selector, comparisonType, operandArray).
380
381 opType and comparisonType are NSNumbers containing OOOperationType and
382 OOComparisonType enumerators, respectively.
383
384 rawString is the original textual representation of the condition for
385 display purposes.
386
387 selector is a string, either a method selector or a mission/local
388 variable name.
389
390 operandArray is an array of operands. Each operand is itself an array
391 of two items: a boolean indicating whether it's a method selector
392 (true) or a literal string (false), and a string.
393
394 The special opType OP_FALSE doesn't require any other elements in the
395 array. All other valid opTypes require the array to have five elements.
396
397 For performance reasons, this method assumes the script condition will
398 have been generated by OOSanitizeLegacyScriptConditions() and doesn't
399 perform extensive validity checks.
400 */
401
402 OOOperationType opType;
403 NSString* selectorString = nil;
404 SEL selector = NULL;
405 OOComparisonType comparator;
406 NSArray* operandArray = nil;
407 NSString* lhsString = nil;
408 NSString* expandedRHS = nil;
409 NSArray* rhsComponents = nil;
410 NSString* rhsItem = nil;
411 NSUInteger i, count;
412 NSCharacterSet* whitespace = nil;
413 double lhsValue, rhsValue;
414 BOOL lhsFlag, rhsFlag;
415
416 opType = [scriptCondition oo_unsignedIntAtIndex:0];
417 if (opType == OP_FALSE)
418 return NO;
419
420 selectorString = [scriptCondition oo_stringAtIndex:2];
421 comparator = [scriptCondition oo_unsignedIntAtIndex:3];
422 operandArray = [scriptCondition oo_arrayAtIndex:4];
423
424 // Transform mission/local var ops into string ops.
425 if (opType == OP_MISSION_VAR) {
426 sMissionStringValue = [mission_variables objectForKey:selectorString];
427 selector = @selector(mission_string);
428 opType = OP_STRING;
429 } else if (opType == OP_LOCAL_VAR) {
430 sMissionStringValue = [[self localVariablesForMission:sCurrentMissionKey] objectForKey:selectorString];
431 selector = @selector(mission_string);
432 opType = OP_STRING;
433 } else {
434 selector = NSSelectorFromString(selectorString);
435 }
436
437 expandedRHS = [self expandScriptRightHandSide:operandArray];
438
439 if (opType == OP_STRING) {
440 lhsString = [self performSelector:selector];
441
442#define DOUBLEVAL(x) ((x != nil) ? [x doubleValue] : 0.0)
443
444 switch (comparator) {
446 return lhsString == nil;
447
448 case COMPARISON_EQUAL:
449 return [lhsString isEqualToString:expandedRHS];
450
452 return ![lhsString isEqualToString:expandedRHS];
453
455 return DOUBLEVAL(lhsString) < DOUBLEVAL(expandedRHS);
456
458 return DOUBLEVAL(lhsString) > DOUBLEVAL(expandedRHS);
459
460 case COMPARISON_ONEOF: {
461 rhsComponents = [expandedRHS componentsSeparatedByString:@","];
462 count = [rhsComponents count];
463
464 whitespace = [NSCharacterSet whitespaceCharacterSet];
465 lhsString = [lhsString stringByTrimmingCharactersInSet:whitespace];
466
467 for (i = 0; i < count; i++) {
468 rhsItem = [[rhsComponents objectAtIndex:i] stringByTrimmingCharactersInSet:whitespace];
469 if ([lhsString isEqualToString:rhsItem]) {
470 return YES;
471 }
472 }
473 }
474 return NO;
475 }
476 } else if (opType == OP_NUMBER) {
477 lhsValue = [[self performSelector:selector] doubleValue];
478
479 if (comparator == COMPARISON_ONEOF) {
480 rhsComponents = [expandedRHS componentsSeparatedByString:@","];
481 count = [rhsComponents count];
482
483 for (i = 0; i < count; i++) {
484 rhsItem = [rhsComponents objectAtIndex:i];
485 rhsValue = [rhsItem doubleValue];
486
487 if (lhsValue == rhsValue) {
488 return YES;
489 }
490 }
491
492 return NO;
493 } else {
494 rhsValue = [expandedRHS doubleValue];
495
496 switch (comparator) {
497 case COMPARISON_EQUAL:
498 return lhsValue == rhsValue;
499
501 return lhsValue != rhsValue;
502
504 return lhsValue < rhsValue;
505
507 return lhsValue > rhsValue;
508
510 case COMPARISON_ONEOF:
511 // "Can't happen" - undefined should have been caught by the sanitizer, oneof is handled above.
512 OOLog(@"script.error.unexpectedOperator", @"***** SCRIPT ERROR: in %@, operator %@ is not valid for numbers, evaluating to false.", CurrentScriptDesc(), OOComparisonTypeToString(comparator));
513 return NO;
514 }
515 }
516 } else if (opType == OP_BOOL) {
517 lhsFlag = [[self performSelector:selector] isEqualToString:@"YES"];
518 rhsFlag = [expandedRHS isEqualToString:@"YES"];
519
520 switch (comparator) {
521 case COMPARISON_EQUAL:
522 return lhsFlag == rhsFlag;
523
525 return lhsFlag != rhsFlag;
526
530 case COMPARISON_ONEOF:
531 // "Can't happen" - should have been caught by the sanitizer.
532 OOLog(@"script.error.unexpectedOperator", @"***** SCRIPT ERROR: in %@, operator %@ is not valid for booleans, evaluating to false.", CurrentScriptDesc(), OOComparisonTypeToString(comparator));
533 return NO;
534 }
535 }
536
537 // What are we doing here?
538 OOLog(@"script.error.fallthrough", @"***** SCRIPT ERROR: in %@, unhandled condition '%@' (%@). %@", CurrentScriptDesc(), [scriptCondition objectAtIndex:1], scriptCondition, @"This is an internal error, please report it.");
539 return NO;
540}
NSString * OOComparisonTypeToString(OOComparisonType type) CONST_FUNC
#define DOUBLEVAL(x)

◆ scriptTestConditions:

- (BOOL) scriptTestConditions: (NSArray*) array

Extends class PlayerEntity.

Definition at line 356 of file PlayerEntityLegacyScriptEngine.m.

356 :(NSArray*)array
357{
358 BOOL result = NO;
359
360 @try {
361 result = TestScriptConditions(array);
362 }
363 @catch (NSException* exception) {
364 OOLog(@"script.error.exception",
365 @"***** EXCEPTION %@: %@ while testing legacy script conditions.",
366 [exception name],
367 [exception reason]);
368 // Suppress exception
369 }
370
371 return result;
372}

References OOLog, and TestScriptConditions.

Here is the call graph for this function:

◆ scriptTimer_number

- (NSNumber *) scriptTimer_number

Extends class PlayerEntity.

Definition at line 830 of file PlayerEntityLegacyScriptEngine.m.

831{
832 return [NSNumber numberWithDouble:[self scriptTimer]];
833}

References PlayerEntity::scriptTimer, and scriptTimer_number.

Referenced by scriptTimer_number.

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

◆ sendAllShipsAway

- (void) sendAllShipsAway

Extends class PlayerEntity.

Definition at line 1970 of file PlayerEntityLegacyScriptEngine.m.

1971{
1972 if (!UNIVERSE)
1973 return;
1974 int ent_count = UNIVERSE->n_entities;
1975 Entity** uni_entities = UNIVERSE->sortedEntities; // grab the public sorted list
1976 Entity* my_entities[ent_count];
1977 int i;
1978 for (i = 0; i < ent_count; i++)
1979 my_entities[i] = [uni_entities[i] retain]; // retained
1980
1981 for (i = 1; i < ent_count; i++) {
1982 Entity* e1 = my_entities[i];
1983 if ([e1 isShip]) {
1984 ShipEntity* se1 = (ShipEntity*)e1;
1985 int e_class = [e1 scanClass];
1986 if (((e_class == CLASS_NEUTRAL) || (e_class == CLASS_POLICE) || (e_class == CLASS_MILITARY) || (e_class == CLASS_THARGOID)) && !([se1 isStation] && [se1 maxFlightSpeed] == 0) && // exclude only stations, not carriers.
1987 [se1 hasHyperspaceMotor]) // exclude non jumping ships. Escorts will still be able to follow a mother.
1988 {
1989 AI* se1AI = [se1 getAI];
1990 [se1 setFuel:MAX(PLAYER_MAX_FUEL, [se1 fuelCapacity])];
1991 [se1 setAITo:@"exitingTraderAI.plist"]; // lets them return to their previous state after the jump
1992 [se1AI setState:@"EXIT_SYSTEM"];
1993 // The following should prevent all ships leaving at once (freezes oolite on slower machines)
1994 [se1AI setNextThinkTime:[UNIVERSE getTime] + 3 + (ranrot_rand() & 15)];
1995 [se1 setPrimaryRole:@"oolite-none"]; // prevents new ship from appearing at witchpoint when this one leaves!
1996 }
1997 }
1998 }
1999
2000 for (i = 0; i < ent_count; i++) {
2001 [my_entities[i] release]; // released
2002 }
2003}
void setNextThinkTime:(OOTimeAbsolute ntt)
Definition AI.m:581
void setState:(NSString *stateName)
Definition AI.m:303
OOScanClass scanClass
Definition Entity.m:743
void setPrimaryRole:(NSString *role)
OOFuelQuantity fuelCapacity()
void setAITo:(NSString *aiString)

References ShipEntity::fuelCapacity, ShipEntity::getAI, Entity::scanClass, sendAllShipsAway, ShipEntity::setAITo:, ShipEntity::setFuel:, AI::setNextThinkTime:, ShipEntity::setPrimaryRole:, AI::setState:, and UNIVERSE.

Referenced by sendAllShipsAway.

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

◆ set:

- (void) set: (NSString*) missionvariable_value

Extends class PlayerEntity.

Definition at line 1489 of file PlayerEntityLegacyScriptEngine.m.

1489 :(NSString*)missionvariable_value
1490{
1491 NSMutableArray* tokens = ScanTokensFromString(missionvariable_value);
1492 NSString* missionVariableString = nil;
1493 NSString* valueString = nil;
1494 BOOL hasMissionPrefix, hasLocalPrefix;
1495
1496 if ([tokens count] < 2) {
1497 OOLog(kOOLogSyntaxSet, @"***** SCRIPT ERROR: in %@, CANNOT SET '%@' (expected mission_variable or local_variable followed by value expression)", CurrentScriptDesc(), missionvariable_value);
1498 return;
1499 }
1500
1501 missionVariableString = [tokens objectAtIndex:0];
1502 [tokens removeObjectAtIndex:0];
1503 valueString = [tokens componentsJoinedByString:@" "];
1504
1505 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1506 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1507
1508 if (!hasMissionPrefix && !hasLocalPrefix) {
1509 OOLog(kOOLogSyntaxSet, @"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1510 return;
1511 }
1512
1513 OOLog(kOOLogNoteSet, @"DEBUG: script %@ is set to %@", missionVariableString, valueString);
1514
1515 if (hasMissionPrefix) {
1516 [self setMissionVariable:valueString forKey:missionVariableString];
1517 } else {
1518 [self setLocalVariable:valueString forKey:missionVariableString andMission:sCurrentMissionKey];
1519 }
1520}
static NSString *const kOOLogSyntaxSet
static NSString *const kOOLogNoteSet

References count, kOOLogNoteSet, kOOLogSyntaxSet, nil, OOLog, ScanTokensFromString(), PlayerEntity::setLocalVariable:forKey:andMission:, and PlayerEntity::setMissionVariable:forKey:.

Here is the call graph for this function:

◆ setBackgroundFromDescriptionsKey:

- (void) setBackgroundFromDescriptionsKey: (NSString*) d_key

Extends class PlayerEntity.

Definition at line 2228 of file PlayerEntityLegacyScriptEngine.m.

2228 :(NSString*)d_key
2229{
2230 NSArray* items = (NSArray*)[[UNIVERSE descriptions] objectForKey:d_key];
2231 //
2232 if (!items)
2233 return;
2234 //
2235 [self addScene:items atOffset:kZeroVector];
2236 //
2237 [self setShowDemoShips:YES];
2238}

References PlayerEntity::addScene:atOffset:, PlayerEntity::setShowDemoShips:, and UNIVERSE.

Here is the call graph for this function:

◆ setFuelLeak:

- (void) setFuelLeak: (NSString*) value

Extends class PlayerEntity.

Definition at line 1923 of file PlayerEntityLegacyScriptEngine.m.

1923 :(NSString*)value
1924{
1925 if (scriptTarget != self) {
1927 return;
1928 }
1929
1930 fuel_leak_rate = [value doubleValue];
1931 if (fuel_leak_rate > 0) {
1932 [self playFuelLeak];
1933 [UNIVERSE addMessage:DESC(@"danger-fuel-leak") forCount:6];
1934 OOLog(kOOLogNoteFuelLeak, @"%@", @"FUEL LEAK activated!");
1935 }
1936}
static NSString *const kOOLogNoteFuelLeak

References kOOLogNoteFuelLeak, OOLog, PlayerEntity::playFuelLeak, scriptTarget, and ShipEntity::setFuel:.

Here is the call graph for this function:

◆ setGalacticHyperspaceBehaviourTo:

- (void) setGalacticHyperspaceBehaviourTo: (NSString*) galacticHyperspaceBehaviourString

Extends class PlayerEntity.

Definition at line 2582 of file PlayerEntityLegacyScriptEngine.m.

2582 :(NSString*)galacticHyperspaceBehaviourString
2583{
2584 OOGalacticHyperspaceBehaviour ghBehaviour = OOGalacticHyperspaceBehaviourFromString(galacticHyperspaceBehaviourString);
2585 if (ghBehaviour == GALACTIC_HYPERSPACE_BEHAVIOUR_UNKNOWN) {
2586 OOLog(@"player.setGalacticHyperspaceBehaviour.invalidInput",
2587 @"setGalacticHyperspaceBehaviourTo: called with unknown behaviour %@.", galacticHyperspaceBehaviourString);
2588 }
2589 [self setGalacticHyperspaceBehaviour:ghBehaviour];
2590}
OOGalacticHyperspaceBehaviour
OOGalacticHyperspaceBehaviour OOGalacticHyperspaceBehaviourFromString(NSString *string) PURE_FUNC

References OOGalacticHyperspaceBehaviourFromString(), OOLog, and PlayerEntity::setGalacticHyperspaceBehaviour:.

Here is the call graph for this function:

◆ setGalacticHyperspaceFixedCoordsTo:

- (void) setGalacticHyperspaceFixedCoordsTo: (NSString*) galacticHyperspaceFixedCoordsString

Extends class PlayerEntity.

Definition at line 2592 of file PlayerEntityLegacyScriptEngine.m.

2592 :(NSString*)galacticHyperspaceFixedCoordsString
2593{
2594 NSArray* coord_vals = ScanTokensFromString(galacticHyperspaceFixedCoordsString);
2595 if ([coord_vals count] < 2) // Will be 0 if string is nil
2596 {
2597 OOLog(@"player.setGalacticHyperspaceFixedCoords.invalidInput", @"%@",
2598 @"setGalacticHyperspaceFixedCoords: called with bad specifier. Defaulting to Oolite standard.");
2599 galacticHyperspaceFixedCoords.x = galacticHyperspaceFixedCoords.y = 0x60;
2600 }
2601
2602 [self setGalacticHyperspaceFixedCoordsX:[coord_vals oo_unsignedCharAtIndex:0]
2603 y:[coord_vals oo_unsignedCharAtIndex:1]];
2604}

References count, OOLog, ScanTokensFromString(), and PlayerEntity::setGalacticHyperspaceFixedCoordsX:y:.

Here is the call graph for this function:

◆ setGuiToMissionScreen

- (void) setGuiToMissionScreen

Extends class PlayerEntity.

Definition at line 2149 of file PlayerEntityLegacyScriptEngine.m.

2150{
2151 // reset special background as legacy scripts can't use it, and this
2152 // is only called by legacy scripts
2153 [self setMissionBackgroundSpecial:nil];
2154 // likewise exit screen target
2155 [self setMissionExitScreen:GUI_SCREEN_STATUS];
2156
2157 [self setGuiToMissionScreenWithCallback:NO];
2158}

References setGuiToMissionScreen, PlayerEntity::setGuiToMissionScreenWithCallback:, PlayerEntity::setMissionBackgroundSpecial:, and PlayerEntity::setMissionExitScreen:.

Referenced by setGuiToMissionScreen.

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

◆ setGuiToMissionScreenWithCallback:

- (void) setGuiToMissionScreenWithCallback: (BOOL) callback

Extends class PlayerEntity.

Definition at line 2176 of file PlayerEntityLegacyScriptEngine.m.

2176 :(BOOL)callback
2177{
2178 GuiDisplayGen* gui = [UNIVERSE gui];
2179 OOGUIScreenID oldScreen = gui_screen;
2180 NSUInteger end_row = 21;
2181 if ([[self hud] allowBigGui]) {
2182 end_row = 27;
2183 }
2184
2185 // GUI stuff
2186 {
2187 [gui clear];
2188 [gui setTitle:[self missionTitle] ?: DESC(@"mission-information")];
2189
2190 if (!_missionTextEntry) {
2191 [gui setText:DESC(@"press-space-commander") forRow:end_row align:GUI_ALIGN_CENTER];
2192 [gui setColor:[OOColor yellowColor] forRow:end_row];
2193 [gui setKey:@"spacebar" forRow:end_row];
2194 [gui setShowTextCursor:NO];
2195 } else {
2196 [self refreshMissionScreenTextEntry];
2197 }
2198 [gui setSelectableRange:NSMakeRange(0, 0)];
2199
2200 [gui setForegroundTextureDescriptor:[self missionOverlayDescriptorOrDefault]];
2201 NSDictionary* background_desc = [self missionBackgroundDescriptorOrDefault];
2202 [gui setBackgroundTextureDescriptor:background_desc];
2203 // must set special second as setting the descriptor resets it
2204 BOOL overridden = ([self missionBackgroundDescriptor] != nil);
2205 [gui setBackgroundTextureSpecial:[self missionBackgroundSpecial] withBackground:!overridden];
2206 }
2207 /* ends */
2208
2209 missionTextRow = 1;
2210
2211 if (gui)
2212 gui_screen = GUI_SCREEN_MISSION;
2213
2214 if (lastTextKey) {
2215 [lastTextKey release];
2216 lastTextKey = nil;
2217 }
2218
2220
2221 // the following are necessary...
2222 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
2223 _missionWithCallback = callback;
2224 _missionAllowInterrupt = NO;
2225 [self noteGUIDidChangeFrom:oldScreen to:gui_screen];
2226}
OOGUIScreenID
BOOL setForegroundTextureDescriptor:(NSDictionary *descriptor)
void setSelectableRange:(NSRange range)
void setBackgroundTextureSpecial:withBackground:(OOGUIBackgroundSpecial spec,[withBackground] BOOL withBackground)
void setTitle:(NSString *str)
BOOL setBackgroundTextureDescriptor:(NSDictionary *descriptor)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
OOColor * yellowColor()
Definition OOColor.m:279
OOMusicController * sharedController()

References GuiDisplayGen::clear, PlayerEntity::missionBackgroundDescriptor, PlayerEntity::missionBackgroundDescriptorOrDefault, PlayerEntity::missionBackgroundSpecial, PlayerEntity::missionOverlayDescriptorOrDefault, PlayerEntity::missionTitle, nil, PlayerEntity::noteGUIDidChangeFrom:to:, OOMusicController::playMissionMusic, PlayerEntity::refreshMissionScreenTextEntry, GuiDisplayGen::setBackgroundTextureDescriptor:, GuiDisplayGen::setBackgroundTextureSpecial:withBackground:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setForegroundTextureDescriptor:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setShowTextCursor:, GuiDisplayGen::setText:forRow:align:, GuiDisplayGen::setTitle:, OOMusicController::sharedController, and OOColor::yellowColor.

Here is the call graph for this function:

◆ setLegalStatus:

- (void) setLegalStatus: (NSString*) valueString

Extends class PlayerEntity.

Definition at line 846 of file PlayerEntityLegacyScriptEngine.m.

846 :(NSString*)valueString
847{
848 legalStatus = [valueString intValue];
849}

◆ setLocalVariable:forKey:andMission:

- (void) setLocalVariable: (NSString*) value
forKey: (NSString*) variableName
andMission: (NSString*) missionKey 

Extends class PlayerEntity.

Definition at line 618 of file PlayerEntityLegacyScriptEngine.m.

618 :(NSString*)value forKey:(NSString*)variableName andMission:(NSString*)missionKey
619{
620 NSMutableDictionary* locals = nil;
621
622 if (variableName != nil && missionKey != nil) {
623 locals = [self localVariablesForMission:missionKey];
624 if (value != nil) {
625 [locals setObject:value forKey:variableName];
626 } else {
627 [locals removeObjectForKey:variableName];
628 }
629 }
630}

References PlayerEntity::localVariablesForMission:, and nil.

Here is the call graph for this function:

◆ setMissionBackground:

- (void) setMissionBackground: (NSString*) value
implementation

Extends class PlayerEntity.

Definition at line 1914 of file PlayerEntityLegacyScriptEngine.m.

1914 :(NSString*)value
1915{
1916 if ([value length] != 0 && ![[value lowercaseString] isEqualToString:@"none"]) {
1917 [self setMissionBackgroundDescriptor:[NSDictionary dictionaryWithObject:value forKey:@"name"]];
1918 } else {
1919 [self setMissionBackgroundDescriptor:nil];
1920 }
1921}

References PlayerEntity::setMissionBackgroundDescriptor:.

Here is the call graph for this function:

◆ setMissionChoiceByTextEntry:

- (void) setMissionChoiceByTextEntry: (BOOL) enable

Extends class PlayerEntity.

Definition at line 1690 of file PlayerEntityLegacyScriptEngine.m.

1690 :(BOOL)enable
1691{
1692 MyOpenGLView* gameView = [UNIVERSE gameView];
1693 _missionTextEntry = enable;
1694 [gameView resetTypedString];
1695}

References MyOpenGLView::resetTypedString.

Here is the call graph for this function:

◆ setMissionChoices:

- (void) setMissionChoices: (NSString*) choicesKey

Extends class PlayerEntity.

Definition at line 1697 of file PlayerEntityLegacyScriptEngine.m.

1697 :(NSString*)choicesKey // choicesKey is a key for a dictionary of
1698{ // choices/choice phrases in missiontext.plist and also..
1699 NSDictionary* choicesDict = [[UNIVERSE missiontext] oo_dictionaryForKey:choicesKey];
1700 if ([choicesDict count] == 0) {
1701 return;
1702 }
1703 [self setMissionChoicesDictionary:choicesDict];
1704}

References count, and PlayerEntity::setMissionChoicesDictionary:.

Here is the call graph for this function:

◆ setMissionChoicesDictionary:

- (void) setMissionChoicesDictionary: (NSDictionary*) choicesDict

Extends class PlayerEntity.

Definition at line 1706 of file PlayerEntityLegacyScriptEngine.m.

1706 :(NSDictionary*)choicesDict
1707{
1708 unsigned i;
1709 bool keysOK = true;
1710 GuiDisplayGen* gui = [UNIVERSE gui];
1711 // TODO: MORE STUFF HERE
1712 //
1713 // What it does now:
1714 // find list of choices in missiontext.plist
1715 // add them to gui setting the key for each line to the key in the dict of choices
1716 // and the text of the line to the value in the dict of choices
1717 // and also set the selectable range
1718 // ++ change the mission screen's response to wait for a choice
1719 // and only if the selectable range is not present ask:
1720 // Press Space Commander...
1721 //
1722
1723 NSUInteger end_row = 21;
1724 if ([[self hud] allowBigGui]) {
1725 end_row = 27;
1726 }
1727
1728 NSArray* choiceKeys = [choicesDict allKeys];
1729 /* Guard against potential for numeric keys in dictionary, which
1730 * would cause an unhandled exception in the sorter. See
1731 * OOJavaScriptEngine::OOJSDictionaryFromJSObject for further
1732 * thoughts. - CIM 15/2/13 */
1733 for (i = 0; i < [choiceKeys count]; i++) {
1734 if (![[choiceKeys objectAtIndex:i] isKindOfClass:[NSString class]]) {
1735 OOLog(@"test.script.error", @"Choices list in mission screen has non-string value %@", [choiceKeys objectAtIndex:i]);
1736 keysOK = false;
1737 }
1738 }
1739 if (keysOK) {
1740 // only try this if they're all strings
1741 choiceKeys = [choiceKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
1742 }
1743
1744 NSInteger keysCount = [choiceKeys count];
1745 if ((end_row + 1) < [choiceKeys count]) {
1746 OOLogERR(kOOLogException, @"in mission.runScreen choices: number of choices defined (%zu) is greater than available lines (%zu). Check HUD settings for allowBigGui.", [choiceKeys count], (end_row + 1));
1747 keysCount = end_row + 1;
1748 }
1749
1750 [gui setText:@"" forRow:end_row]; // clears out the 'Press spacebar' message
1751 [gui setKey:@"" forRow:end_row]; // clears the key to enable pollDemoControls to check for a selection
1752 [gui setSelectableRange:NSMakeRange(0, 0)]; // clears the selectable range
1753 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES]; // enables mouse selection of the choices list items
1754
1755 OOGUIRow choicesRow = (end_row + 1) - keysCount;
1756 NSString* choiceKey = nil;
1757 id choiceValue = nil;
1758 NSString* choiceText = nil;
1759
1760 BOOL selectableRowExists = NO;
1761 NSUInteger firstSelectableRow = end_row;
1762
1763 foreach (choiceKey, choiceKeys) {
1764 choiceValue = [choicesDict objectForKey:choiceKey];
1765 OOGUIAlignment alignment = GUI_ALIGN_CENTER;
1766 OOColor* rowColor = [OOColor yellowColor];
1767 BOOL selectable = YES;
1768 if ([choiceValue isKindOfClass:[NSString class]]) {
1769 choiceText = [NSString stringWithFormat:@" %@ ", (NSString*)choiceValue];
1770 } else if ([choiceValue isKindOfClass:[NSDictionary class]]) {
1771 NSDictionary* choiceOpts = (NSDictionary*)choiceValue;
1772 choiceText = [NSString stringWithFormat:@" %@ ", [choiceOpts oo_stringForKey:@"text"]];
1773 NSString* alignmentChoice = [choiceOpts oo_stringForKey:@"alignment" defaultValue:@"CENTER"];
1774 if ([alignmentChoice isEqualToString:@"LEFT"]) {
1775 alignment = GUI_ALIGN_LEFT;
1776 } else if ([alignmentChoice isEqualToString:@"RIGHT"]) {
1777 alignment = GUI_ALIGN_RIGHT;
1778 }
1779 id colorDesc = [choiceOpts objectForKey:@"color"];
1780 if ([choiceOpts oo_boolForKey:@"unselectable"]) {
1781 selectable = NO;
1782 }
1783 if (colorDesc != nil) {
1784 rowColor = [OOColor colorWithDescription:colorDesc];
1785 } else if (!selectable) // different default
1786 {
1787 rowColor = [OOColor darkGrayColor];
1788 }
1789 } else {
1790 continue; // invalid type
1791 }
1792 choiceText = OOExpand(choiceText);
1793 choiceText = [self replaceVariablesInString:choiceText];
1794 // allow blank rows
1795 if (![choiceText isEqualToString:@" "]) {
1796 [gui setText:choiceText forRow:choicesRow align:alignment];
1797 if (selectable) {
1798 [gui setKey:choiceKey forRow:choicesRow];
1799 } else {
1800 [gui setKey:GUI_KEY_SKIP forRow:choicesRow];
1801 }
1802 [gui setColor:rowColor forRow:choicesRow];
1803 if (selectable && !selectableRowExists) {
1804 selectableRowExists = YES;
1805 firstSelectableRow = choicesRow;
1806 }
1807 } else {
1808 [gui setKey:GUI_KEY_SKIP forRow:choicesRow];
1809 }
1810 choicesRow++;
1811 if (choicesRow > (end_row + 1))
1812 break;
1813 }
1814
1815 if (!selectableRowExists) {
1816 // just in case choices are set but they're all blank.
1817 [gui setText:@" " forRow:end_row align:GUI_ALIGN_CENTER];
1818 [gui setKey:@"" forRow:end_row];
1819 [gui setColor:[OOColor yellowColor] forRow:end_row];
1820 }
1821
1822 [gui setSelectableRange:NSMakeRange((end_row + 1) - keysCount, keysCount)];
1823 [gui setSelectedRow:firstSelectableRow];
1824
1825 [self resetMissionChoice];
1826}
NSInteger OOGUIRow
OOGUIAlignment
@ GUI_ALIGN_RIGHT
@ GUI_ALIGN_LEFT
@ GUI_ALIGN_CENTER
BOOL setSelectedRow:(OOGUIRow row)
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
OOColor * darkGrayColor()
Definition OOColor.m:239
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135

References OOColor::colorWithDescription:, count, OOColor::darkGrayColor, GUI_ALIGN_CENTER, GUI_ALIGN_LEFT, GUI_ALIGN_RIGHT, kOOLogException, nil, OOExpand, OOLog, OOLogERR, PlayerEntity::replaceVariablesInString:, PlayerEntity::resetMissionChoice, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setText:forRow:, GuiDisplayGen::setText:forRow:align:, and OOColor::yellowColor.

Here is the call graph for this function:

◆ setMissionDescription:

- (void) setMissionDescription: (NSString*) textKey

Extends class PlayerEntity.

Definition at line 724 of file PlayerEntityLegacyScriptEngine.m.

724 :(NSString*)textKey
725{
726 [self setMissionDescription:textKey forMission:sCurrentMissionKey];
727}

References PlayerEntity::setMissionDescription:forMission:.

Here is the call graph for this function:

◆ setMissionDescription:forMission:

- (void) setMissionDescription: (NSString*) textKey
forMission: (NSString*) key 

Extends class PlayerEntity.

Definition at line 729 of file PlayerEntityLegacyScriptEngine.m.

729 :(NSString*)textKey forMission:(NSString*)key
730{
731 NSString* text = [[UNIVERSE missiontext] oo_stringForKey:textKey];
732
733 if (!text) {
734 OOLogERR(kOOLogScriptMissionDescNoText, @"in %@, no mission text set for key '%@' [UNIVERSE missiontext] is:\n%@ ", CurrentScriptDesc(), textKey, [UNIVERSE missiontext]);
735 return;
736 }
737
738 [self setMissionInstructions:text forMission:key];
739}
static NSString *const kOOLogScriptMissionDescNoText

References kOOLogScriptMissionDescNoText, OOLogERR, PlayerEntity::setMissionInstructions:forMission:, and UNIVERSE.

Here is the call graph for this function:

◆ setMissionImage:

- (void) setMissionImage: (NSString*) value
implementation

Extends class PlayerEntity.

Definition at line 1905 of file PlayerEntityLegacyScriptEngine.m.

1905 :(NSString*)value
1906{
1907 if ([value length] != 0 && ![[value lowercaseString] isEqualToString:@"none"]) {
1908 [self setMissionOverlayDescriptor:[NSDictionary dictionaryWithObject:value forKey:@"name"]];
1909 } else {
1910 [self setMissionOverlayDescriptor:nil];
1911 }
1912}

References PlayerEntity::setMissionOverlayDescriptor:.

Here is the call graph for this function:

◆ setMissionInstructions:forMission:

- (void) setMissionInstructions: (NSString*) text
forMission: (NSString*) key 

Extends class PlayerEntity.

Definition at line 742 of file PlayerEntityLegacyScriptEngine.m.

742 :(NSString*)text forMission:(NSString*)key
743{
744 if (!key) {
745 OOLogERR(kOOLogScriptMissionDescNoKey, @"in %@, mission key not set", CurrentScriptDesc());
746 return;
747 }
748
749 text = OOExpand(text);
750 text = [self replaceVariablesInString:text];
751
752 [mission_variables setObject:text forKey:key];
753}

References kOOLogScriptMissionDescNoKey, OOExpand, OOLogERR, and PlayerEntity::replaceVariablesInString:.

Here is the call graph for this function:

◆ setMissionInstructionsList:forMission:

- (void) setMissionInstructionsList: (NSArray*) list
forMission: (NSString*) key 

Extends class PlayerEntity.

Definition at line 755 of file PlayerEntityLegacyScriptEngine.m.

755 :(NSArray*)list forMission:(NSString*)key
756{
757 if (!key) {
758 OOLogERR(kOOLogScriptMissionDescNoKey, @"in %@, mission key not set", CurrentScriptDesc());
759 return;
760 }
761
762 NSString* text = nil;
763 NSUInteger i, ct = [list count];
764 NSMutableArray* expandedList = [NSMutableArray arrayWithCapacity:ct];
765 for (i = 0; i < ct; i++) {
766 text = [list oo_stringAtIndex:i defaultValue:nil];
767 if (text != nil) {
768 text = OOExpand(text);
769 text = [self replaceVariablesInString:text];
770 [expandedList addObject:text];
771 }
772 }
773
774 [mission_variables setObject:expandedList forKey:key];
775}

References kOOLogScriptMissionDescNoKey, nil, OOExpand, OOLogERR, and PlayerEntity::replaceVariablesInString:.

Here is the call graph for this function:

◆ setMissionMusic:

- (void) setMissionMusic: (NSString*) value

Extends class PlayerEntity.

Definition at line 1884 of file PlayerEntityLegacyScriptEngine.m.

1884 :(NSString*)value
1885{
1886 if ([value length] == 0 || [[value lowercaseString] isEqualToString:@"none"]) {
1887 value = nil;
1888 }
1890}
void setMissionMusic:(NSString *missionMusicName)

References nil, OOMusicController::setMissionMusic:, and OOMusicController::sharedController.

Here is the call graph for this function:

◆ setMissionScreenID:

- (void) setMissionScreenID: (NSString*) msid

Extends class PlayerEntity.

Definition at line 2128 of file PlayerEntityLegacyScriptEngine.m.

2128 :(NSString*)msid
2129{
2130 _missionScreenID = [msid retain];
2131}

◆ setMissionTitle:

- (void) setMissionTitle: (NSString*) value

Extends class PlayerEntity.

Definition at line 1897 of file PlayerEntityLegacyScriptEngine.m.

1897 :(NSString*)value
1898{
1899 if (_missionTitle != value) {
1900 [_missionTitle release];
1901 _missionTitle = [value copy];
1902 }
1903}

◆ setMissionVariable:forKey:

- (void) setMissionVariable: (NSString*) value
forKey: (NSString*) key 

Extends class PlayerEntity.

Definition at line 587 of file PlayerEntityLegacyScriptEngine.m.

587 :(NSString*)value forKey:(NSString*)key
588{
589 if (key != nil) {
590 if (value != nil)
591 [mission_variables setObject:value forKey:key];
592 else
593 [mission_variables removeObjectForKey:key];
594 }
595}

References nil.

◆ setPlanetinfo:

- (void) setPlanetinfo: (NSString*) key_valueString

Extends class PlayerEntity.

Definition at line 1140 of file PlayerEntityLegacyScriptEngine.m.

1140 :(NSString*)key_valueString // uses key=value format
1141{
1142 NSArray* tokens = [key_valueString componentsSeparatedByString:@"="];
1143 NSString* keyString = nil;
1144 NSString* valueString = nil;
1145
1146 if ([tokens count] != 2) {
1147 OOLog(kOOLogSyntaxSetPlanetInfo, @"***** SCRIPT ERROR: in %@, CANNOT setPlanetinfo: '%@' (bad parameter count)", CurrentScriptDesc(), key_valueString);
1148 return;
1149 }
1150
1151 keyString = [[tokens objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1152 valueString = [[tokens objectAtIndex:1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1153
1154 /* Legacy script planetinfo settings are now non-persistent over save/load
1155 * Virtually nothing uses them any more, and expecting them to have a
1156 * manifest and identifying what it is if so seems unnecessary */
1157 [UNIVERSE setSystemDataKey:keyString value:valueString fromManifest:@""];
1158}
static NSString *const kOOLogSyntaxSetPlanetInfo

References count, kOOLogSyntaxSetPlanetInfo, nil, and OOLog.

◆ setScriptTarget:

- (void) setScriptTarget: (ShipEntity*) ship

Extends class PlayerEntity.

Definition at line 223 of file PlayerEntityLegacyScriptEngine.m.

223 :(ShipEntity*)ship
224{
225 scriptTarget = ship;
226}

References scriptTarget.

Here is the call graph for this function:

◆ setSpecificPlanetInfo:

- (void) setSpecificPlanetInfo: (NSString*) key_valueString

Extends class PlayerEntity.

Definition at line 1160 of file PlayerEntityLegacyScriptEngine.m.

1160 :(NSString*)key_valueString // uses galaxy#=planet#=key=value
1161{
1162 NSArray* tokens = [key_valueString componentsSeparatedByString:@"="];
1163 NSString* keyString = nil;
1164 NSString* valueString = nil;
1165 int gnum, pnum;
1166
1167 if ([tokens count] != 4) {
1168 OOLog(kOOLogSyntaxSetPlanetInfo, @"***** SCRIPT ERROR: in %@, CANNOT setSpecificPlanetInfo: '%@' (bad parameter count)", CurrentScriptDesc(), key_valueString);
1169 return;
1170 }
1171
1172 gnum = [tokens oo_intAtIndex:0];
1173 pnum = [tokens oo_intAtIndex:1];
1174 keyString = [[tokens objectAtIndex:2] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1175 valueString = [[tokens objectAtIndex:3] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1176
1177 [UNIVERSE setSystemDataForGalaxy:gnum planet:pnum key:keyString value:valueString fromManifest:@"" forLayer:OO_LAYER_OXP_DYNAMIC];
1178}

References count, kOOLogSyntaxSetPlanetInfo, nil, and OOLog.

◆ setSunNovaIn:

- (void) setSunNovaIn: (NSString*) time_value

Extends class PlayerEntity.

Definition at line 1943 of file PlayerEntityLegacyScriptEngine.m.

1943 :(NSString*)time_value
1944{
1945 double time_until_nova = [time_value doubleValue];
1946 [[UNIVERSE sun] setGoingNova:YES inTime:time_until_nova];
1947}

◆ shipsFound_number

- (NSNumber *) shipsFound_number

Extends class PlayerEntity.

Definition at line 836 of file PlayerEntityLegacyScriptEngine.m.

837{
838 return [NSNumber numberWithInt:shipsFound];
839}

References shipsFound_number.

Referenced by shipsFound_number.

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

◆ showShipModel:

- (void) showShipModel: (NSString*) shipKey

Extends class PlayerEntity.

Definition at line 1873 of file PlayerEntityLegacyScriptEngine.m.

1873 :(NSString*)role
1874{
1875 if ([role isEqualToString:@"none"] || [role length] == 0) {
1876 [UNIVERSE removeDemoShips];
1877 return;
1878 }
1879
1880 ShipEntity* ship = [UNIVERSE makeDemoShipWithRole:role spinning:YES];
1881 OOLog(kOOLogNoteShowShipModel, @"::::: showShipModel:'%@' (%@) (%@)", role, ship, [ship name]);
1882}
static NSString *const kOOLogNoteShowShipModel

References kOOLogNoteShowShipModel, and OOLog.

◆ spawnShip:

- (void) spawnShip: (NSString*) ship_key

Extends class PlayerEntity.

Definition at line 1480 of file PlayerEntityLegacyScriptEngine.m.

1480 :(NSString*)ship_key
1481{
1482 if ([UNIVERSE spawnShip:ship_key]) {
1483 OOLog(kOOLogNoteAddShips, @"DEBUG: Spawned ship with shipdata key '%@'.", ship_key);
1484 } else {
1485 OOLog(kOOLogScriptAddShipsFailed, @"***** SCRIPT ERROR: in %@, could not spawn ship with shipdata key '%@'.", CurrentScriptDesc(), ship_key);
1486 }
1487}

References kOOLogNoteAddShips, kOOLogScriptAddShipsFailed, OOLog, and UNIVERSE.

◆ status_string

- (NSString *) status_string

Extends class PlayerEntity.

Definition at line 800 of file PlayerEntityLegacyScriptEngine.m.

801{
802 return OOStringFromEntityStatus([self status]);
803}
NSString * OOStringFromEntityStatus(OOEntityStatus status) CONST_FUNC

References OOStringFromEntityStatus(), and status_string.

Referenced by status_string.

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

◆ subtract:

- (void) subtract: (NSString*) missionVariableString_value

Extends class PlayerEntity.

Definition at line 1614 of file PlayerEntityLegacyScriptEngine.m.

1614 :(NSString*)missionVariableString_value
1615{
1616 NSString* missionVariableString = nil;
1617 NSString* valueString;
1618 double value;
1619 NSMutableArray* tokens = ScanTokensFromString(missionVariableString_value);
1620 BOOL hasMissionPrefix, hasLocalPrefix;
1621
1622 if ([tokens count] < 2) {
1623 OOLog(kOOLogSyntaxSubtract, @"***** SCRIPT ERROR: in %@, CANNOT SUBTRACT: '%@'", CurrentScriptDesc(), missionVariableString_value);
1624 return;
1625 }
1626
1627 missionVariableString = [tokens objectAtIndex:0];
1628 [tokens removeObjectAtIndex:0];
1629 valueString = [tokens componentsJoinedByString:@" "];
1630
1631 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1632 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1633
1634 if (hasMissionPrefix) {
1635 value = [[self missionVariableForKey:missionVariableString] doubleValue];
1636 value -= [valueString doubleValue];
1637 [self setMissionVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString];
1638 } else if (hasLocalPrefix) {
1639 value = [[self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] doubleValue];
1640 value -= [valueString doubleValue];
1641 [self setLocalVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1642 } else {
1643 OOLog(kOOLogSyntaxSubtract, @"***** SCRIPT ERROR: in %@, CANNOT SUBTRACT: '%@' -- IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString_value, missionVariableString_value);
1644 }
1645}
static NSString *const kOOLogSyntaxSubtract

References count, kOOLogSyntaxSubtract, PlayerEntity::localVariableForKey:andMission:, PlayerEntity::missionVariableForKey:, nil, OOLog, ScanTokensFromString(), PlayerEntity::setLocalVariable:forKey:andMission:, and PlayerEntity::setMissionVariable:forKey:.

Here is the call graph for this function:

◆ sunGoneNova_bool

- (NSString *) sunGoneNova_bool

Extends class PlayerEntity.

Definition at line 926 of file PlayerEntityLegacyScriptEngine.m.

927{
928 return ([[UNIVERSE sun] goneNova]) ? @"YES" : @"NO";
929}

References sunGoneNova_bool, and UNIVERSE.

Referenced by sunGoneNova_bool.

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

◆ sunWillGoNova_bool

- (NSString *) sunWillGoNova_bool

Extends class PlayerEntity.

Definition at line 921 of file PlayerEntityLegacyScriptEngine.m.

922{
923 return ([[UNIVERSE sun] willGoNova]) ? @"YES" : @"NO";
924}

References sunWillGoNova_bool, and UNIVERSE.

Referenced by sunWillGoNova_bool.

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

◆ systemEconomy_number

- (NSNumber *) systemEconomy_number

Extends class PlayerEntity.

Definition at line 988 of file PlayerEntityLegacyScriptEngine.m.

989{
990 NSDictionary* systeminfo = [UNIVERSE currentSystemData];
991 return [systeminfo objectForKey:KEY_ECONOMY];
992}

References systemEconomy_number.

Referenced by systemEconomy_number.

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

◆ systemEconomy_string

- (NSString *) systemEconomy_string

Extends class PlayerEntity.

Definition at line 978 of file PlayerEntityLegacyScriptEngine.m.

979{
980 int economy = [[self systemEconomy_number] intValue]; // 0 .. 7 (0 rich industrial .. 7 poor agricultural)
981 NSString* result = OODisplayStringFromEconomyID(economy);
982 if (result == nil)
983 result = @"UNKNOWN";
984
985 return result;
986}
NSString * OODisplayStringFromEconomyID(OOEconomyID economy)

References nil, OODisplayStringFromEconomyID(), PlayerEntity::systemEconomy_number, and systemEconomy_string.

Referenced by systemEconomy_string.

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

◆ systemGovernment_number

- (NSNumber *) systemGovernment_number

Extends class PlayerEntity.

Definition at line 972 of file PlayerEntityLegacyScriptEngine.m.

973{
974 NSDictionary* systeminfo = [UNIVERSE currentSystemData];
975 return [systeminfo objectForKey:KEY_GOVERNMENT];
976}

References systemGovernment_number.

Referenced by systemGovernment_number.

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

◆ systemGovernment_string

- (NSString *) systemGovernment_string

Extends class PlayerEntity.

Definition at line 962 of file PlayerEntityLegacyScriptEngine.m.

963{
964 int government = [[self systemGovernment_number] intValue]; // 0 .. 7 (0 anarchic .. 7 most stable)
965 NSString* result = OODisplayStringFromGovernmentID(government);
966 if (result == nil)
967 result = @"UNKNOWN";
968
969 return result;
970}
NSString * OODisplayStringFromGovernmentID(OOGovernmentID government)

References nil, OODisplayStringFromGovernmentID(), PlayerEntity::systemGovernment_number, and systemGovernment_string.

Referenced by systemGovernment_string.

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

◆ systemPopulation_number

- (NSNumber *) systemPopulation_number

Extends class PlayerEntity.

Definition at line 1000 of file PlayerEntityLegacyScriptEngine.m.

1001{
1002 NSDictionary* systeminfo = [UNIVERSE currentSystemData];
1003 return [systeminfo objectForKey:KEY_POPULATION];
1004}

References systemPopulation_number.

Referenced by systemPopulation_number.

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

◆ systemProductivity_number

- (NSNumber *) systemProductivity_number

Extends class PlayerEntity.

Definition at line 1006 of file PlayerEntityLegacyScriptEngine.m.

1007{
1008 NSDictionary* systeminfo = [UNIVERSE currentSystemData];
1009 return [systeminfo objectForKey:KEY_PRODUCTIVITY];
1010}

References systemProductivity_number.

Referenced by systemProductivity_number.

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

◆ systemTechLevel_number

- (NSNumber *) systemTechLevel_number

Extends class PlayerEntity.

Definition at line 994 of file PlayerEntityLegacyScriptEngine.m.

995{
996 NSDictionary* systeminfo = [UNIVERSE currentSystemData];
997 return [systeminfo objectForKey:KEY_TECHLEVEL];
998}

References systemTechLevel_number.

Referenced by systemTechLevel_number.

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

◆ targetNearestHostile

- (void) targetNearestHostile

Extends class PlayerEntity.

Definition at line 2560 of file PlayerEntityLegacyScriptEngine.m.

2561{
2562 [self scanForHostiles];
2563 Entity* ent = [self foundTarget];
2564 if (ent != nil) {
2565 ident_engaged = YES;
2566 missile_status = MISSILE_STATUS_TARGET_LOCKED;
2567 [self addTarget:ent];
2568 }
2569}
@ MISSILE_STATUS_TARGET_LOCKED

References PlayerEntity::addTarget:, ShipEntity::foundTarget, MISSILE_STATUS_TARGET_LOCKED, nil, ShipEntity::scanForHostiles, and targetNearestHostile.

Referenced by targetNearestHostile.

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

◆ targetNearestIncomingMissile

- (void) targetNearestIncomingMissile

Extends class PlayerEntity.

Definition at line 2571 of file PlayerEntityLegacyScriptEngine.m.

2572{
2573 [self scanForNearestIncomingMissile];
2574 Entity* ent = [self foundTarget];
2575 if (ent != nil) {
2576 ident_engaged = YES;
2577 missile_status = MISSILE_STATUS_TARGET_LOCKED;
2578 [self addTarget:ent];
2579 }
2580}

References PlayerEntity::addTarget:, ShipEntity::foundTarget, MISSILE_STATUS_TARGET_LOCKED, nil, ShipEntity::scanForNearestIncomingMissile, and targetNearestIncomingMissile.

Referenced by targetNearestIncomingMissile.

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

◆ testForEquipment:

- (void) testForEquipment: (NSString*) equipString

Extends class PlayerEntity.

Definition at line 1269 of file PlayerEntityLegacyScriptEngine.m.

1269 :(NSString*)equipString // eg. EQ_NAVAL_ENERGY_UNIT
1270{
1271 found_equipment = [self hasEquipmentItem:equipString];
1272}

References ShipEntity::hasEquipmentItem:.

Here is the call graph for this function:

◆ TestScriptConditions

+ (BOOL) TestScriptConditions (NSArray *) conditions
implementation

Extends class PlayerEntity.

Definition at line 209 of file PlayerEntityLegacyScriptEngine.m.

210{
211 NSEnumerator* condEnum = nil;
212 NSArray* condition = nil;
213 PlayerEntity* player = PLAYER;
214
215 for (condEnum = [conditions objectEnumerator]; (condition = [condEnum nextObject]);) {
216 if (![player scriptTestCondition:condition])
217 return NO;
218 }
219
220 return YES;
221}

References nil, PLAYER, and TestScriptConditions.

Referenced by PerformConditionalStatment, processSceneDictionary:atOffset:, scriptTestConditions:, and TestScriptConditions.

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

◆ useSpecialCargo:

- (void) useSpecialCargo: (NSString*) descriptionString

Extends class PlayerEntity.

Definition at line 1259 of file PlayerEntityLegacyScriptEngine.m.

1259 :(NSString*)descriptionString
1260{
1261 if (scriptTarget != self)
1262 return;
1263
1264 [self removeAllCargo:YES];
1265 OOLog(kOOLogNoteUseSpecialCargo, @"Going to useSpecialCargo:'%@'", descriptionString);
1266 specialCargo = [OOExpand(descriptionString) retain];
1267}
static NSString *const kOOLogNoteUseSpecialCargo

References kOOLogNoteUseSpecialCargo, OOLog, PlayerEntity::removeAllCargo:, and scriptTarget.

Here is the call graph for this function:

◆ worldScriptsRequiringTickle

- (NSDictionary *) worldScriptsRequiringTickle
implementation

Extends class PlayerEntity.

Definition at line 247 of file PlayerEntityLegacyScriptEngine.m.

248{
251
252 NSMutableDictionary* tickleScripts = [NSMutableDictionary dictionaryWithCapacity:[worldScripts count]];
253 NSString* scriptName;
254 foreachkey(scriptName, worldScripts)
255 {
256 OOScript* candidateScript = [worldScripts objectForKey:scriptName];
257 if ([candidateScript requiresTickle]) {
258 [tickleScripts setObject:candidateScript forKey:scriptName];
259 }
260 }
261
262 worldScriptsRequiringTickle = [tickleScripts copy];
264}
#define foreachkey(VAR, DICT)

References foreachkey, nil, and worldScriptsRequiringTickle.

Referenced by checkScript, PlayerEntity::dealloc, PlayerEntity::setUpAndConfirmOK:saveGame:, and worldScriptsRequiringTickle.

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 files: