96#define ACTIONS_TEMP_PREFIX "__oolite_actions_temp"
105@interface PlayerEntity (ScriptingPrivate)
107- (BOOL) scriptTestCondition:(NSArray *)scriptCondition;
108- (NSString *) expandScriptRightHandSide:(NSArray *)rhsComponents;
110- (void) scriptActions:(NSArray *)actions forTarget:(
ShipEntity *)target missionKey:(NSString *)missionKey;
111- (NSString *) expandMessage:(NSString *)valueString;
116@implementation PlayerEntity (Scripting)
123 return [NSString stringWithFormat:@"\"%@\"", sCurrentMissionKey];
131 return CurrentScriptNameOr(
@"<anonymous actions>");
135static void PerformScriptActions(NSArray *actions,
Entity *target);
136static void PerformConditionalStatment(NSArray *actions,
Entity *target);
137static void PerformActionStatment(NSArray *statement,
Entity *target);
138static BOOL TestScriptConditions(NSArray *conditions);
141static void PerformScriptActions(NSArray *actions,
Entity *target)
143 NSArray *statement =
nil;
144 foreach (statement, actions)
146 if ([[statement objectAtIndex:0] boolValue])
148 PerformConditionalStatment(statement, target);
152 PerformActionStatment(statement, target);
158static void PerformConditionalStatment(NSArray *statement,
Entity *target)
167 NSArray *conditions =
nil;
168 NSArray *actions =
nil;
170 conditions = [statement objectAtIndex:1];
172 if (TestScriptConditions(conditions))
174 actions = [statement objectAtIndex:2];
178 actions = [statement objectAtIndex:3];
181 PerformScriptActions(actions, target);
185static void PerformActionStatment(NSArray *statement,
Entity *target)
200 NSString *selectorString =
nil;
201 NSString *argumentString =
nil;
202 NSString *expandedString =
nil;
204 NSMutableDictionary *locals =
nil;
207 selectorString = [statement objectAtIndex:1];
208 if ([statement
count] > 2) argumentString = [statement objectAtIndex:2];
210 selector = NSSelectorFromString(selectorString);
212 if (target ==
nil || ![target respondsToSelector:selector])
217 if (argumentString !=
nil)
223 [target performSelector:selector withObject:expandedString];
228 [target performSelector:selector];
233static BOOL TestScriptConditions(NSArray *conditions)
235 NSEnumerator *condEnum =
nil;
236 NSArray *condition =
nil;
239 for (condEnum = [conditions objectEnumerator]; (condition = [condEnum nextObject]); )
241 if (![player scriptTestCondition:condition])
return NO;
264 if (status == STATUS_DOCKING ||
265 status == STATUS_LAUNCHING ||
266 status == STATUS_ENTERING_WITCHSPACE ||
267 status == STATUS_EXITING_WITCHSPACE)
269 return STATUS_IN_FLIGHT;
282- (NSDictionary *) worldScriptsRequiringTickle
284 if (worldScriptsRequiringTickle !=
nil)
return worldScriptsRequiringTickle;
286 NSMutableDictionary *tickleScripts = [NSMutableDictionary dictionaryWithCapacity:[worldScripts count]];
287 NSString *scriptName;
290 OOScript *candidateScript = [worldScripts objectForKey:scriptName];
291 if ([candidateScript requiresTickle])
293 [tickleScripts setObject:candidateScript forKey:scriptName];
297 worldScriptsRequiringTickle = [tickleScripts copy];
298 return worldScriptsRequiringTickle;
307 NSDictionary *tickleScripts = [
self worldScriptsRequiringTickle];
308 if ([tickleScripts
count] == 0)
314 [
self setScriptTarget:self];
336 status = [
self status];
337 restoreStatus = status;
342 status = RecursiveRemapStatus(status);
343 [
self setStatus:status];
348 [[tickleScripts allValues] makeObjectsPerformSelector:@selector(runWithTarget:) withObject:self];
350 @catch (NSException *exception)
352 OOLog(
kOOLogException,
@"***** Exception running world scripts: %@ : %@", [exception name], [exception reason]);
357 if (status != restoreStatus) [
self setStatus:restoreStatus];
361- (void)runScriptActions:(NSArray *)actions withContextName:(NSString *)contextName forTarget:(
ShipEntity *)target
363 NSAutoreleasePool *pool =
nil;
364 NSString *oldMissionKey =
nil;
365 NSString *
volatile theMissionKey = contextName;
367 pool = [[NSAutoreleasePool alloc] init];
375 PerformScriptActions(actions, target);
377 @catch (NSException *exception)
379 OOLog(
@"script.error.exception",
380 @"***** EXCEPTION %@: %@ while handling legacy script actions for %@",
383 [theMissionKey hasPrefix:
kActionTempPrefix] ? [target shortDescription] : theMissionKey);
392- (void) runUnsanitizedScriptActions:(NSArray *)actions allowingAIMethods:(BOOL)allowAIMethods withContextName:(NSString *)contextName forTarget:(
ShipEntity *)target
394 [
self runScriptActions:OOSanitizeLegacyScript(actions, contextName, allowAIMethods)
395 withContextName:contextName
400- (BOOL) scriptTestConditions:(NSArray *)array
406 result = TestScriptConditions(array);
408 @catch (NSException *exception)
410 OOLog(
@"script.error.exception",
411 @"***** EXCEPTION %@: %@ while testing legacy script conditions.",
421- (BOOL) scriptTestCondition:(NSArray *)scriptCondition
450 NSString *selectorString =
nil;
453 NSArray *operandArray =
nil;
454 NSString *lhsString =
nil;
455 NSString *expandedRHS =
nil;
456 NSArray *rhsComponents =
nil;
457 NSString *rhsItem =
nil;
459 NSCharacterSet *whitespace =
nil;
460 double lhsValue, rhsValue;
461 BOOL lhsFlag, rhsFlag;
463 opType = [scriptCondition oo_unsignedIntAtIndex:0];
466 selectorString = [scriptCondition oo_stringAtIndex:2];
467 comparator = [scriptCondition oo_unsignedIntAtIndex:3];
468 operandArray = [scriptCondition oo_arrayAtIndex:4];
474 selector =
@selector(mission_string);
479 sMissionStringValue = [[
self localVariablesForMission:sCurrentMissionKey] objectForKey:selectorString];
480 selector =
@selector(mission_string);
485 selector = NSSelectorFromString(selectorString);
488 expandedRHS = [
self expandScriptRightHandSide:operandArray];
492 lhsString = [
self performSelector:selector];
494 #define DOUBLEVAL(x) ((x != nil) ? [x doubleValue] : 0.0)
499 return lhsString ==
nil;
502 return [lhsString isEqualToString:expandedRHS];
505 return ![lhsString isEqualToString:expandedRHS];
515 rhsComponents = [expandedRHS componentsSeparatedByString:@","];
516 count = [rhsComponents count];
518 whitespace = [NSCharacterSet whitespaceCharacterSet];
519 lhsString = [lhsString stringByTrimmingCharactersInSet:whitespace];
521 for (i = 0; i <
count; i++)
523 rhsItem = [[rhsComponents objectAtIndex:i] stringByTrimmingCharactersInSet:whitespace];
524 if ([lhsString isEqualToString:rhsItem])
535 lhsValue = [[
self performSelector:selector] doubleValue];
539 rhsComponents = [expandedRHS componentsSeparatedByString:@","];
540 count = [rhsComponents count];
542 for (i = 0; i <
count; i++)
544 rhsItem = [rhsComponents objectAtIndex:i];
545 rhsValue = [rhsItem doubleValue];
547 if (lhsValue == rhsValue)
557 rhsValue = [expandedRHS doubleValue];
562 return lhsValue == rhsValue;
565 return lhsValue != rhsValue;
568 return lhsValue < rhsValue;
571 return lhsValue > rhsValue;
576 OOLog(
@"script.error.unexpectedOperator",
@"***** SCRIPT ERROR: in %@, operator %@ is not valid for numbers, evaluating to false.", CurrentScriptDesc(),
OOComparisonTypeToString(comparator));
583 lhsFlag = [[
self performSelector:selector] isEqualToString:@"YES"];
584 rhsFlag = [expandedRHS isEqualToString:@"YES"];
589 return lhsFlag == rhsFlag;
592 return lhsFlag != rhsFlag;
599 OOLog(
@"script.error.unexpectedOperator",
@"***** SCRIPT ERROR: in %@, operator %@ is not valid for booleans, evaluating to false.", CurrentScriptDesc(),
OOComparisonTypeToString(comparator));
605 OOLog(
@"script.error.fallthrough",
@"***** SCRIPT ERROR: in %@, unhandled condition '%@' (%@). %@", CurrentScriptDesc(), [scriptCondition objectAtIndex:1], scriptCondition,
@"This is an internal error, please report it.");
610- (NSString *) expandScriptRightHandSide:(NSArray *)rhsComponents
612 NSMutableArray *result =
nil;
613 NSArray *component =
nil;
614 NSString *value =
nil;
616 result = [NSMutableArray arrayWithCapacity:[rhsComponents count]];
618 foreach (component, rhsComponents)
629 value = [component oo_stringAtIndex:1];
631 if ([[component objectAtIndex:0] boolValue])
633 value = [[
self performSelector:NSSelectorFromString(value)] description];
634 if (value ==
nil) value =
@"(null)";
637 [result addObject:value];
640 return [result componentsJoinedByString:@" "];
644- (NSDictionary *) missionVariables
646 return mission_variables;
650- (NSString *)missionVariableForKey:(NSString *)key
652 NSString *result =
nil;
653 if (key !=
nil) result = [mission_variables objectForKey:key];
658- (void)setMissionVariable:(NSString *)value forKey:(NSString *)key
662 if (value !=
nil) [mission_variables setObject:value forKey:key];
663 else [mission_variables removeObjectForKey:key];
668- (NSMutableDictionary *)localVariablesForMission:(NSString *)missionKey
670 NSMutableDictionary *result =
nil;
672 if (missionKey ==
nil)
return nil;
674 result = [localVariables objectForKey:missionKey];
677 result = [NSMutableDictionary dictionary];
678 [localVariables setObject:result forKey:missionKey];
685- (NSString *)localVariableForKey:(NSString *)variableName andMission:(NSString *)missionKey
687 return [[localVariables oo_dictionaryForKey:missionKey] objectForKey:variableName];
691- (void)setLocalVariable:(NSString *)value forKey:(NSString *)variableName andMission:(NSString *)missionKey
693 NSMutableDictionary *locals =
nil;
695 if (variableName !=
nil && missionKey !=
nil)
697 locals = [
self localVariablesForMission:missionKey];
700 [locals setObject:value forKey:variableName];
704 [locals removeObjectForKey:variableName];
710- (NSArray *) missionsList
712 NSEnumerator *scriptEnum =
nil;
713 NSString *scriptName =
nil;
714 NSString *vars =
nil;
715 NSMutableArray *result1 =
nil;
716 NSMutableArray *result2 =
nil;
718 result1 = [NSMutableArray array];
719 result2 = [NSMutableArray array];
721 NSArray* passengerManifest = [
self passengerList];
722 NSArray* contractManifest = [
self contractList];
723 NSArray* parcelManifest = [
self parcelList];
725 if ([passengerManifest
count] > 0)
727 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-passengers")] arrayByAddingObjectsFromArray:passengerManifest]];
730 if ([parcelManifest
count] > 0)
732 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-parcels")] arrayByAddingObjectsFromArray:parcelManifest]];
735 if ([contractManifest
count] > 0)
737 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-contracts")] arrayByAddingObjectsFromArray:contractManifest]];
742 for (scriptEnum = [worldScripts keyEnumerator]; (scriptName = [scriptEnum nextObject]); )
744 vars = [mission_variables objectForKey:scriptName];
748 if ([vars isKindOfClass:[NSString class]])
750 [result1 addObject:vars];
752 else if ([vars isKindOfClass:[NSArray class]])
755 NSArray *element =
nil;
756 foreach (element, result2)
758 if ([[element oo_stringAtIndex:0] isEqualToString:[(NSArray*)vars oo_stringAtIndex:0]])
761 [result2 removeObject:element];
762 NSRange notTheHeader;
763 notTheHeader.location = 1;
764 notTheHeader.length = [(NSArray*)vars count]-1;
765 [result2 addObject:[element arrayByAddingObjectsFromArray:[(NSArray*)vars subarrayWithRange:notTheHeader]]];
772 [result2 addObject:vars];
777 return [result1 arrayByAddingObjectsFromArray:result2];
781- (NSString*) replaceVariablesInString:(NSString*) args
783 NSMutableDictionary *locals = [
self localVariablesForMission:sCurrentMissionKey];
784 NSMutableString *resultString = [NSMutableString stringWithString: args];
785 NSString *valueString;
789 for (i = 0; i < [tokens count]; i++)
791 valueString = [tokens objectAtIndex:i];
793 if ([valueString hasPrefix:
@"mission_"] && [mission_variables objectForKey:valueString])
795 [resultString replaceOccurrencesOfString:valueString withString:[mission_variables objectForKey:valueString] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
797 else if ([locals objectForKey:valueString])
799 [resultString replaceOccurrencesOfString:valueString withString:[locals objectForKey:valueString] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
801 else if (([valueString hasSuffix:
@"_number"])||([valueString hasSuffix:
@"_bool"])||([valueString hasSuffix:
@"_string"]))
803 SEL valueselector = NSSelectorFromString(valueString);
804 if ([
self respondsToSelector:valueselector])
806 [resultString replaceOccurrencesOfString:valueString withString:[NSString stringWithFormat:@"%@", [
self performSelector:valueselector]] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
809 else if ([valueString hasPrefix:
@"["]&&[valueString hasSuffix:
@"]"])
811 NSString* replaceString =
OOExpand(valueString);
812 [resultString replaceOccurrencesOfString:valueString withString:replaceString options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
818 return [NSString stringWithString: resultString];
824- (void) setMissionDescription:(NSString *)textKey
826 [
self setMissionDescription:textKey forMission:sCurrentMissionKey];
830- (void) setMissionDescription:(NSString *)textKey forMission:(NSString *)key
832 NSString *text = [[UNIVERSE missiontext] oo_stringForKey:textKey];
840 [
self setMissionInstructions:text forMission:key];
845- (void) setMissionInstructions:(NSString *)text forMission:(NSString *)key
854 text = [
self replaceVariablesInString: text];
856 [mission_variables setObject:text forKey:key];
860- (void) setMissionInstructionsList:(NSArray *)list forMission:(NSString *)key
868 NSString *text =
nil;
869 NSUInteger i,ct = [list count];
870 NSMutableArray *expandedList = [NSMutableArray arrayWithCapacity:ct];
871 for (i=0 ; i<ct ; i++)
873 text = [list oo_stringAtIndex:i defaultValue:nil];
877 text = [
self replaceVariablesInString: text];
878 [expandedList addObject:text];
882 [mission_variables setObject:expandedList forKey:key];
886- (void) clearMissionDescription
888 [
self clearMissionDescriptionForMission:sCurrentMissionKey];
892- (void) clearMissionDescriptionForMission:(NSString *)key
900 if (![mission_variables objectForKey:key]) return;
902 [mission_variables removeObjectForKey:key];
906- (NSString *) mission_string
912- (NSString *) status_string
918- (NSString *) gui_screen_string
924- (NSNumber *) galaxy_number
926 return [NSNumber numberWithInt:[
self currentGalaxyID]];
930- (NSNumber *) planet_number
932 return [NSNumber numberWithInt:[
self currentSystemID]];
936- (NSNumber *) score_number
938 return [NSNumber numberWithUnsignedInt:[
self score]];
942- (NSNumber *) credits_number
944 return [NSNumber numberWithDouble:[
self creditBalance]];
948- (NSNumber *) scriptTimer_number
950 return [NSNumber numberWithDouble:[
self scriptTimer]];
955- (NSNumber *) shipsFound_number
957 return [NSNumber numberWithInt:shipsFound];
961- (NSNumber *) commanderLegalStatus_number
963 return [NSNumber numberWithInt:[
self legalStatus]];
967- (void) setLegalStatus:(NSString *)valueString
969 legalStatus = [valueString intValue];
973- (NSString *) commanderLegalStatus_string
979- (NSNumber *) d100_number
982 return [NSNumber numberWithInt:d100];
986- (NSNumber *) pseudoFixedD100_number
988 return [NSNumber numberWithInt:[
self systemPseudoRandom100]];
992- (NSNumber *) d256_number
995 return [NSNumber numberWithInt:d256];
999- (NSNumber *) pseudoFixedD256_number
1001 return [NSNumber numberWithInt:[
self systemPseudoRandom256]];
1005- (NSNumber *) clock_number
1007 return [NSNumber numberWithDouble:ship_clock];
1011- (NSNumber *) clock_secs_number
1013 return [NSNumber numberWithUnsignedLongLong:ship_clock];
1017- (NSNumber *) clock_mins_number
1019 return [NSNumber numberWithUnsignedLongLong:ship_clock / 60.0];
1023- (NSNumber *) clock_hours_number
1025 return [NSNumber numberWithUnsignedLongLong:ship_clock / 3600.0];
1029- (NSNumber *) clock_days_number
1031 return [NSNumber numberWithUnsignedLongLong:ship_clock / 86400.0];
1035- (NSNumber *) fuelLevel_number
1037 return [NSNumber numberWithFloat:floor(0.1 * fuel)];
1041- (NSString *) dockedAtMainStation_bool
1043 if ([
self dockedAtMainStation])
return @"YES";
1048- (NSString *) foundEquipment_bool
1050 return (found_equipment)?
@"YES" :
@"NO";
1054- (NSString *) sunWillGoNova_bool
1056 return ([[
UNIVERSE sun] willGoNova])?
@"YES" :
@"NO";
1060- (NSString *) sunGoneNova_bool
1062 return ([[
UNIVERSE sun] goneNova])?
@"YES" :
@"NO";
1066- (NSString *) missionChoice_string
1068 return missionChoice;
1072- (NSString *) missionKeyPress_string
1074 return missionKeyPress;
1078- (NSNumber *) dockedTechLevel_number
1083 return [
self systemTechLevel_number];
1088- (NSString *) dockedStationName_string
1090 NSString *result =
nil;
1091 if ([
self status] != STATUS_DOCKED)
return @"NONE";
1093 result = [
self dockedStationName];
1094 if (result ==
nil) result =
@"UNKNOWN";
1099- (NSString *) systemGovernment_string
1101 int government = [[
self systemGovernment_number] intValue];
1103 if (result ==
nil) result =
@"UNKNOWN";
1109- (NSNumber *) systemGovernment_number
1111 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1112 return [systeminfo objectForKey:KEY_GOVERNMENT];
1116- (NSString *) systemEconomy_string
1118 int economy = [[
self systemEconomy_number] intValue];
1120 if (result ==
nil) result =
@"UNKNOWN";
1126- (NSNumber *) systemEconomy_number
1128 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1129 return [systeminfo objectForKey:KEY_ECONOMY];
1133- (NSNumber *) systemTechLevel_number
1135 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1136 return [systeminfo objectForKey:KEY_TECHLEVEL];
1140- (NSNumber *) systemPopulation_number
1142 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1143 return [systeminfo objectForKey:KEY_POPULATION];
1147- (NSNumber *) systemProductivity_number
1149 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1150 return [systeminfo objectForKey:KEY_PRODUCTIVITY];
1154- (NSString *) commanderName_string
1156 return [
self commanderName];
1160- (NSString *) commanderRank_string
1166- (NSString *) commanderShip_string
1172- (NSString *) commanderShipDisplayName_string
1174 return [
self displayName];
1180- (NSString *) expandMessage:(NSString *)valueString
1183 very_random_seed.
a = rand() & 255;
1184 very_random_seed.
b = rand() & 255;
1185 very_random_seed.
c = rand() & 255;
1186 very_random_seed.
d = rand() & 255;
1187 very_random_seed.
e = rand() & 255;
1188 very_random_seed.
f = rand() & 255;
1190 NSString* expandedMessage =
OOExpand(valueString);
1191 return [
self replaceVariablesInString: expandedMessage];
1195- (void) commsMessage:(NSString *)valueString
1197 [UNIVERSE addCommsMessage:[
self expandMessage:valueString] forCount:4.5];
1204- (void) commsMessageByUnpiloted:(NSString *)valueString
1206 [
self commsMessage:valueString];
1210- (void) consoleMessage3s:(NSString *)valueString
1212 [UNIVERSE addMessage:[
self expandMessage:valueString] forCount: 3];
1216- (void) consoleMessage6s:(NSString *)valueString
1218 [UNIVERSE addMessage:[
self expandMessage:valueString] forCount: 6];
1222- (void) awardCredits:(NSString *)valueString
1230 int64_t award = [valueString intValue];
1233 else credits += award;
1237- (void) awardShipKills:(NSString *)valueString
1241 int value = [valueString intValue];
1242 if (0 < value) ship_kills += value;
1246- (void) awardEquipment:(NSString *)equipString
1250 if ([equipString isEqualToString:
@"EQ_FUEL"])
1252 [
self setFuel:[
self fuelCapacity]];
1257 if ([eqType isMissileOrMine])
1259 [
self mountMissileWithRole:equipString];
1261 else if([equipString hasPrefix:
@"EQ_WEAPON"] && ![equipString hasSuffix:
@"_DAMAGED"])
1263 OOLog(
kOOLogSyntaxAwardEquipment,
@"***** SCRIPT ERROR: in %@, CANNOT award undamaged weapon:'%@'. Damaged weapons can be awarded instead.", CurrentScriptDesc(), equipString);
1265 else if ([equipString hasSuffix:
@"_DAMAGED"] && [
self hasEquipmentItem:[equipString substringToIndex:[equipString length] - [
@"_DAMAGED" length]]])
1267 OOLog(
kOOLogSyntaxAwardEquipment,
@"***** SCRIPT ERROR: in %@, CANNOT award damaged equipment:'%@'. Undamaged version already equipped.", CurrentScriptDesc(), equipString);
1269 else if ([eqType canCarryMultiple] || ![
self hasEquipmentItem:equipString])
1271 [
self addEquipmentItem:equipString withValidation:YES inContext:@"scripted"];
1276- (void) removeEquipment:(NSString *)equipKey
1280 if ([equipKey isEqualToString:
@"EQ_FUEL"])
1286 if ([equipKey isEqualToString:
@"EQ_CARGO_BAY"] && [
self hasEquipmentItem:equipKey]
1287 && ([
self extraCargo] > [
self availableCargoSpace]))
1292 if ([
self hasEquipmentItem:equipKey] || [
self hasEquipmentItem:[equipKey stringByAppendingString:
@"_DAMAGED"]])
1294 [
self removeEquipmentItem:equipKey];
1300- (void) setPlanetinfo:(NSString *)key_valueString
1302 NSArray * tokens = [key_valueString componentsSeparatedByString:@"="];
1303 NSString* keyString =
nil;
1304 NSString* valueString =
nil;
1306 if ([tokens
count] != 2)
1308 OOLog(
kOOLogSyntaxSetPlanetInfo,
@"***** SCRIPT ERROR: in %@, CANNOT setPlanetinfo: '%@' (bad parameter count)", CurrentScriptDesc(), key_valueString);
1312 keyString = [[tokens objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1313 valueString = [[tokens objectAtIndex:1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1318 [UNIVERSE setSystemDataKey:keyString value:valueString fromManifest:@""];
1323- (void) setSpecificPlanetInfo:(NSString *)key_valueString
1325 NSArray * tokens = [key_valueString componentsSeparatedByString:@"="];
1326 NSString* keyString =
nil;
1327 NSString* valueString =
nil;
1330 if ([tokens
count] != 4)
1332 OOLog(
kOOLogSyntaxSetPlanetInfo,
@"***** SCRIPT ERROR: in %@, CANNOT setSpecificPlanetInfo: '%@' (bad parameter count)", CurrentScriptDesc(), key_valueString);
1336 gnum = [tokens oo_intAtIndex:0];
1337 pnum = [tokens oo_intAtIndex:1];
1338 keyString = [[tokens objectAtIndex:2] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1339 valueString = [[tokens objectAtIndex:3] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1341 [UNIVERSE setSystemDataForGalaxy:gnum planet:pnum key:keyString value:valueString fromManifest:@"" forLayer:OO_LAYER_OXP_DYNAMIC];
1345- (void) awardCargo:(NSString *)amount_typeString
1354 if ([tokens
count] != 2)
1356 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"bad parameter count");
1361 type = [tokens oo_stringAtIndex:1];
1362 if (![[
UNIVERSE commodities] goodDefined:type])
1364 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"unknown type");
1368 amount = [tokens oo_intAtIndex:0];
1371 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"negative quantity");
1375 unit = [shipCommodityData massUnitForGood:type];
1378 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"cargo hold full with special cargo");
1382 [
self awardCommodityType:type amount:amount];
1386- (void) removeAllCargo
1388 [
self removeAllCargo:NO];
1391- (void) removeAllCargo:(BOOL)forceRemoval
1398 if ([
self status] != STATUS_DOCKED && !forceRemoval)
1406 foreach (type, [shipCommodityData goods])
1408 if ([shipCommodityData massUnitForGood:type] ==
UNITS_TONS)
1410 [shipCommodityData setQuantity:0 forGood:type];
1415 if (forceRemoval && [
self status] != STATUS_DOCKED)
1418 for (i = [cargo
count] - 1; i >= 0; i--)
1420 ShipEntity* canister = [cargo objectAtIndex:i];
1421 if (!canister)
break;
1424 [cargo removeObjectAtIndex:i];
1430 [
self calculateCurrentCargo];
1434- (void) useSpecialCargo:(NSString *)descriptionString
1438 [
self removeAllCargo:YES];
1440 specialCargo = [OOExpand(descriptionString) retain];
1444- (void) testForEquipment:(NSString *)equipString
1446 found_equipment = [
self hasEquipmentItem:equipString];
1450- (void) awardFuel:(NSString *)valueString
1452 int delta = 10 * [valueString floatValue];
1455 if (delta < 0 && scriptTargetFuelBeforeAward < (
unsigned)-delta) [scriptTarget
setFuel:0];
1458 [scriptTarget
setFuel:(scriptTargetFuelBeforeAward + delta)];
1463- (void) messageShipAIs:(NSString *)roles_message
1466 NSString* roleString =
nil;
1467 NSString* messageString =
nil;
1469 if ([tokens
count] < 2)
1471 OOLog(
kOOLogSyntaxMessageShipAIs,
@"***** SCRIPT ERROR: in %@, CANNOT messageShipAIs: '%@' (bad parameter count)", CurrentScriptDesc(), roles_message);
1475 roleString = [tokens objectAtIndex:0];
1476 [tokens removeObjectAtIndex:0];
1477 messageString = [tokens componentsJoinedByString:@" "];
1479 NSArray *targets = [UNIVERSE findShipsMatchingPredicate:HasPrimaryRolePredicate
1480 parameter:roleString
1485 foreach(target, targets) {
1491- (void) ejectItem:(NSString *)itemKey
1498- (void) addShips:(NSString *)roles_number
1501 NSString* roleString =
nil;
1502 NSString* numberString =
nil;
1504 if ([tokens
count] != 2)
1506 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT addShips: '%@' (expected <role> <count>)", CurrentScriptDesc(), roles_number);
1510 roleString = [tokens objectAtIndex:0];
1511 numberString = [tokens objectAtIndex:1];
1513 int number = [numberString intValue];
1516 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, can't add %i ships -- that's less than zero, y'know..", CurrentScriptDesc(), number);
1523 [UNIVERSE witchspaceShipWithPrimaryRole:roleString];
1527- (void) addSystemShips:(NSString *)roles_number_position
1530 NSString* roleString =
nil;
1531 NSString* numberString =
nil;
1532 NSString* positionString =
nil;
1534 if ([tokens
count] != 3)
1536 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT addSystemShips: '%@' (expected <role> <count> <position>)", CurrentScriptDesc(), roles_number_position);
1540 roleString = [tokens objectAtIndex:0];
1541 numberString = [tokens objectAtIndex:1];
1542 positionString = [tokens objectAtIndex:2];
1544 int number = [numberString intValue];
1545 double posn = [positionString doubleValue];
1548 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, can't add %i ships -- that's less than zero, y'know..", CurrentScriptDesc(), number);
1552 OOLog(
kOOLogNoteAddShips,
@"DEBUG: Going to add %d ships with role '%@' at a point %.3f along route1", number, roleString, posn);
1555 [UNIVERSE addShipWithRole:roleString nearRouteOneAt:posn];
1559- (void) addShipsAt:(NSString *)roles_number_system_x_y_z
1563 NSString* roleString =
nil;
1564 NSString* numberString =
nil;
1565 NSString* systemString =
nil;
1566 NSString* xString =
nil;
1567 NSString* yString =
nil;
1568 NSString* zString =
nil;
1570 if ([tokens
count] != 6)
1572 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT addShipsAt: '%@' (expected <role> <count> <coordinate-system> <x> <y> <z>)", CurrentScriptDesc(), roles_number_system_x_y_z);
1576 roleString = [tokens objectAtIndex:0];
1577 numberString = [tokens objectAtIndex:1];
1578 systemString = [tokens objectAtIndex:2];
1579 xString = [tokens objectAtIndex:3];
1580 yString = [tokens objectAtIndex:4];
1581 zString = [tokens objectAtIndex:5];
1583 HPVector posn = make_HPvector([xString doubleValue], [yString doubleValue], [zString doubleValue]);
1585 int number = [numberString intValue];
1588 OOLog(
kOOLogSyntaxAddShips,
@"----- WARNING in %@ Tried to add %i ships -- no ship added.", CurrentScriptDesc(), number);
1592 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);
1594 if (![
UNIVERSE addShips: number withRole:roleString nearPosition: posn withCoordinateSystem: systemString])
1596 OOLog(
kOOLogScriptAddShipsFailed,
@"***** SCRIPT ERROR: in %@, %@ could not add %u ships with role \"%@\
"", CurrentScriptDesc(),
@"addShipsAt:", number, roleString);
1601- (void) addShipsAtPrecisely:(NSString *)roles_number_system_x_y_z
1605 NSString* roleString =
nil;
1606 NSString* numberString =
nil;
1607 NSString* systemString =
nil;
1608 NSString* xString =
nil;
1609 NSString* yString =
nil;
1610 NSString* zString =
nil;
1612 if ([tokens
count] != 6)
1614 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@,* CANNOT addShipsAtPrecisely: '%@' (expected <role> <count> <coordinate-system> <x> <y> <z>)", CurrentScriptDesc(), roles_number_system_x_y_z);
1618 roleString = [tokens objectAtIndex:0];
1619 numberString = [tokens objectAtIndex:1];
1620 systemString = [tokens objectAtIndex:2];
1621 xString = [tokens objectAtIndex:3];
1622 yString = [tokens objectAtIndex:4];
1623 zString = [tokens objectAtIndex:5];
1625 HPVector posn = make_HPvector([xString doubleValue], [yString doubleValue], [zString doubleValue]);
1627 int number = [numberString intValue];
1630 OOLog(
kOOLogSyntaxAddShips,
@"----- WARNING: in %@, Can't add %i ships -- no ship added.", CurrentScriptDesc(), number);
1634 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);
1636 if (![
UNIVERSE addShips: number withRole:roleString atPosition: posn withCoordinateSystem: systemString])
1638 OOLog(
kOOLogScriptAddShipsFailed,
@"***** SCRIPT ERROR: in %@, %@ could not add %u ships with role '%@'", CurrentScriptDesc(),
@"addShipsAtPrecisely:", number, roleString);
1643- (void) addShipsWithinRadius:(NSString *)roles_number_system_x_y_z_r
1647 if ([tokens
count] != 7)
1649 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT 'addShipsWithinRadius: %@' (expected <role> <count> <coordinate-system> <x> <y> <z> <radius>))", CurrentScriptDesc(), roles_number_system_x_y_z_r);
1653 NSString* roleString = [tokens objectAtIndex:0];
1654 int number = [[tokens objectAtIndex:1] intValue];
1655 NSString* systemString = [tokens objectAtIndex:2];
1656 double x = [[tokens objectAtIndex:3] doubleValue];
1657 double y = [[tokens objectAtIndex:4] doubleValue];
1658 double z = [[tokens objectAtIndex:5] doubleValue];
1659 GLfloat r = [[tokens objectAtIndex:6] floatValue];
1660 HPVector posn = make_HPvector(
x,
y, z);
1664 OOLog(
kOOLogSyntaxAddShips,
@"----- WARNING: in %@, can't add %i ships -- no ship added.", CurrentScriptDesc(), number);
1668 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);
1670 if (![
UNIVERSE addShips:number withRole: roleString nearPosition: posn withCoordinateSystem: systemString withinRadius: r])
1672 OOLog(
kOOLogScriptAddShipsFailed,
@"***** SCRIPT ERROR :in %@, %@ could not add %u ships with role \"%@\
"", CurrentScriptDesc(),
@"addShipsWithinRadius:", number, roleString);
1677- (void) spawnShip:(NSString *)ship_key
1690- (void) set:(NSString *)missionvariable_value
1693 NSString *missionVariableString =
nil;
1694 NSString *valueString =
nil;
1695 BOOL hasMissionPrefix, hasLocalPrefix;
1697 if ([tokens
count] < 2)
1699 OOLog(
kOOLogSyntaxSet,
@"***** SCRIPT ERROR: in %@, CANNOT SET '%@' (expected mission_variable or local_variable followed by value expression)", CurrentScriptDesc(), missionvariable_value);
1703 missionVariableString = [tokens objectAtIndex:0];
1704 [tokens removeObjectAtIndex:0];
1705 valueString = [tokens componentsJoinedByString:@" "];
1707 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1708 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1710 if (!hasMissionPrefix && !hasLocalPrefix)
1712 OOLog(
kOOLogSyntaxSet,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1716 OOLog(
kOOLogNoteSet,
@"DEBUG: script %@ is set to %@", missionVariableString, valueString);
1718 if (hasMissionPrefix)
1720 [
self setMissionVariable:valueString forKey:missionVariableString];
1724 [
self setLocalVariable:valueString forKey:missionVariableString andMission:sCurrentMissionKey];
1729- (void) reset:(NSString *)missionvariable
1731 NSString* missionVariableString = [missionvariable stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1732 BOOL hasMissionPrefix, hasLocalPrefix;
1734 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1735 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1737 if (hasMissionPrefix)
1739 [
self setMissionVariable:nil forKey:missionVariableString];
1741 else if (hasLocalPrefix)
1743 [
self setLocalVariable:nil forKey:missionVariableString andMission:sCurrentMissionKey];
1747 OOLog(
kOOLogSyntaxReset,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1752- (void) increment:(NSString *)missionVariableString
1754 BOOL hasMissionPrefix, hasLocalPrefix;
1757 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1758 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1760 if (hasMissionPrefix)
1762 value = [[
self missionVariableForKey:missionVariableString] intValue];
1764 [
self setMissionVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString];
1766 else if (hasLocalPrefix)
1768 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] intValue];
1770 [
self setLocalVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1774 OOLog(
kOOLogSyntaxIncrement,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1779- (void) decrement:(NSString *)missionVariableString
1781 BOOL hasMissionPrefix, hasLocalPrefix;
1784 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1785 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1787 if (hasMissionPrefix)
1789 value = [[
self missionVariableForKey:missionVariableString] intValue];
1791 [
self setMissionVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString];
1793 else if (hasLocalPrefix)
1795 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] intValue];
1797 [
self setLocalVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1801 OOLog(
kOOLogSyntaxDecrement,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1806- (void) add:(NSString *)missionVariableString_value
1808 NSString* missionVariableString =
nil;
1809 NSString* valueString;
1812 BOOL hasMissionPrefix, hasLocalPrefix;
1814 if ([tokens
count] < 2)
1816 OOLog(
kOOLogSyntaxAdd,
@"***** SCRIPT ERROR: in %@, CANNOT ADD: '%@'", CurrentScriptDesc(), missionVariableString_value);
1820 missionVariableString = [tokens objectAtIndex:0];
1821 [tokens removeObjectAtIndex:0];
1822 valueString = [tokens componentsJoinedByString:@" "];
1824 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1825 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1827 if (hasMissionPrefix)
1829 value = [[
self missionVariableForKey:missionVariableString] doubleValue];
1830 value += [valueString doubleValue];
1831 [
self setMissionVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString];
1833 else if (hasLocalPrefix)
1835 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] doubleValue];
1836 value += [valueString doubleValue];
1837 [
self setLocalVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1841 OOLog(
kOOLogSyntaxAdd,
@"***** SCRIPT ERROR: in %@, CANNOT ADD: '%@' -- IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString_value, missionVariableString_value);
1846- (void) subtract:(NSString *)missionVariableString_value
1848 NSString* missionVariableString =
nil;
1849 NSString* valueString;
1852 BOOL hasMissionPrefix, hasLocalPrefix;
1854 if ([tokens
count] < 2)
1856 OOLog(
kOOLogSyntaxSubtract,
@"***** SCRIPT ERROR: in %@, CANNOT SUBTRACT: '%@'", CurrentScriptDesc(), missionVariableString_value);
1860 missionVariableString = [tokens objectAtIndex:0];
1861 [tokens removeObjectAtIndex:0];
1862 valueString = [tokens componentsJoinedByString:@" "];
1864 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1865 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1867 if (hasMissionPrefix)
1869 value = [[
self missionVariableForKey:missionVariableString] doubleValue];
1870 value -= [valueString doubleValue];
1871 [
self setMissionVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString];
1873 else if (hasLocalPrefix)
1875 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] doubleValue];
1876 value -= [valueString doubleValue];
1877 [
self setLocalVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1881 OOLog(
kOOLogSyntaxSubtract,
@"***** SCRIPT ERROR: in %@, CANNOT SUBTRACT: '%@' -- IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString_value, missionVariableString_value);
1886- (void) checkForShips:(NSString *)roleString
1888 shipsFound = [UNIVERSE countShipsWithPrimaryRole:roleString];
1892- (void) resetScriptTimer
1900- (void) addMissionText: (NSString *)textKey
1902 NSString *text =
nil;
1904 if ([textKey isEqualToString:lastTextKey]) return;
1905 [lastTextKey release];
1906 lastTextKey = [textKey copy];
1909 text = [[UNIVERSE missiontext] oo_stringForKey:textKey];
1910 if (text ==
nil)
return;
1912 text = [
self replaceVariablesInString:text];
1914 [
self addLiteralMissionText:text];
1918- (void) addLiteralMissionText:(NSString *)text
1924 NSString *para =
nil;
1925 foreach (para, [text componentsSeparatedByString:
@"\n"])
1933- (void) setMissionChoiceByTextEntry:(BOOL)enable
1936 _missionTextEntry = enable;
1941- (void) setMissionChoices:(NSString *)choicesKey
1943 NSDictionary *choicesDict = [[UNIVERSE missiontext] oo_dictionaryForKey:choicesKey];
1944 if ([choicesDict
count] == 0)
1948 [
self setMissionChoicesDictionary:choicesDict];
1952- (void) setMissionChoicesDictionary:(NSDictionary *)choicesDict
1969 NSUInteger end_row = 21;
1970 if ([[
self hud] allowBigGui])
1975 NSArray *choiceKeys = [choicesDict allKeys];
1980 for (i=0; i < [choiceKeys count]; i++)
1982 if (![[choiceKeys objectAtIndex:i] isKindOfClass:[NSString class]])
1984 OOLog(
@"test.script.error",
@"Choices list in mission screen has non-string value %@",[choiceKeys objectAtIndex:i]);
1991 choiceKeys = [choiceKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
1994 NSInteger keysCount = [choiceKeys count];
1995 if ((end_row + 1) < [choiceKeys
count]) {
1996 OOLogERR(
kOOLogException,
@"in mission.runScreen choices: number of choices defined (%llu) is greater than available lines (%llu). Check HUD settings for allowBigGui.", [choiceKeys
count], (end_row + 1));
1997 keysCount = end_row + 1;
2003 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
2005 OOGUIRow choicesRow = (end_row+1) - keysCount;
2006 NSString *choiceKey =
nil;
2007 id choiceValue =
nil;
2008 NSString *choiceText =
nil;
2010 BOOL selectableRowExists = NO;
2011 NSUInteger firstSelectableRow = end_row;
2013 foreach (choiceKey, choiceKeys)
2015 choiceValue = [choicesDict objectForKey:choiceKey];
2018 BOOL selectable = YES;
2019 if ([choiceValue isKindOfClass:[NSString class]])
2021 choiceText = [NSString stringWithFormat:@" %@ ",(NSString*)choiceValue];
2023 else if ([choiceValue isKindOfClass:[NSDictionary class]])
2025 NSDictionary *choiceOpts = (NSDictionary*)choiceValue;
2026 choiceText = [NSString stringWithFormat:@" %@ ",[choiceOpts oo_stringForKey:@"text"]];
2027 NSString *alignmentChoice = [choiceOpts oo_stringForKey:@"alignment" defaultValue:@"CENTER"];
2028 if ([alignmentChoice isEqualToString:
@"LEFT"])
2032 else if ([alignmentChoice isEqualToString:
@"RIGHT"])
2036 id colorDesc = [choiceOpts objectForKey:@"color"];
2037 if ([choiceOpts oo_boolForKey:
@"unselectable"])
2041 if (colorDesc !=
nil)
2045 else if (!selectable)
2055 choiceText = [
self replaceVariablesInString:choiceText];
2057 if (![choiceText isEqualToString:
@" "])
2069 if (selectable && !selectableRowExists)
2071 selectableRowExists = YES;
2072 firstSelectableRow = choicesRow;
2080 if (choicesRow > (end_row + 1))
break;
2083 if (!selectableRowExists)
2094 [
self resetMissionChoice];
2098- (void) resetMissionChoice
2100 [
self setMissionChoice:nil];
2104- (void) clearMissionScreen
2106 [
self setMissionOverlayDescriptor:nil];
2107 [
self setMissionBackgroundDescriptor:nil];
2108 [
self setMissionBackgroundSpecial:nil];
2109 [
self setMissionTitle:nil];
2110 [
self setMissionMusic:nil];
2111 [
self showShipModel:nil];
2115- (void) addMissionDestination:(NSString *)destinations
2121 for (j = 0; j < [tokens count]; j++)
2123 dest = [tokens oo_intAtIndex:j];
2124 if (dest < 0 || dest > 255)
2127 [
self addMissionDestinationMarker:[
self defaultMarker:dest]];
2132- (void) removeMissionDestination:(NSString *)destinations
2138 for (j = 0; j < [tokens count]; j++)
2140 dest = [[tokens objectAtIndex:j] intValue];
2141 if (dest < 0 || dest > 255)
continue;
2143 [
self removeMissionDestinationMarker:[
self defaultMarker:dest]];
2148- (void) showShipModel:(NSString *)role
2150 if ([role isEqualToString:
@"none"] || [role length] == 0)
2152 [UNIVERSE removeDemoShips];
2156 ShipEntity *ship = [UNIVERSE makeDemoShipWithRole:role spinning:YES];
2161- (void) setMissionMusic:(NSString *)value
2163 if ([value length] == 0 || [[value lowercaseString] isEqualToString:
@"none"])
2171- (NSString *) missionTitle
2173 return _missionTitle;
2177- (void) setMissionTitle:(NSString *)value
2179 if (_missionTitle != value)
2181 [_missionTitle release];
2182 _missionTitle = [value copy];
2187- (void) setMissionImage:(NSString *)value
2189 if ([value length] != 0 && ![[value lowercaseString] isEqualToString:
@"none"])
2191 [
self setMissionOverlayDescriptor:[NSDictionary dictionaryWithObject:value forKey:@"name"]];
2195 [
self setMissionOverlayDescriptor:nil];
2201- (void) setMissionBackground:(NSString *)value
2203 if ([value length] != 0 && ![[value lowercaseString] isEqualToString:
@"none"])
2205 [
self setMissionBackgroundDescriptor:[NSDictionary dictionaryWithObject:value forKey:@"name"]];
2209 [
self setMissionBackgroundDescriptor:nil];
2214- (void) setFuelLeak:(NSString *)value
2222 fuel_leak_rate = [value doubleValue];
2223 if (fuel_leak_rate > 0)
2225 [
self playFuelLeak];
2226 [UNIVERSE addMessage:DESC(@"danger-fuel-leak") forCount:6];
2232- (NSNumber *) fuelLeakRate_number
2234 return [NSNumber numberWithFloat:[
self fuelLeakRate]];
2238- (void) setSunNovaIn:(NSString *)time_value
2240 double time_until_nova = [time_value doubleValue];
2241 [[UNIVERSE sun] setGoingNova:YES inTime: time_until_nova];
2245- (void) launchFromStation
2248 if ([
UNIVERSE autoSave]) [UNIVERSE setAutoSaveNow:YES];
2249 if ([
self status] == STATUS_DOCKING) [
self setStatus:STATUS_DOCKED];
2250 [
self leaveDock:[
self dockedStation]];
2254- (void) blowUpStation
2258 mainStation = [UNIVERSE station];
2259 if (mainStation !=
nil)
2261 [UNIVERSE unMagicMainStation];
2267- (void) sendAllShipsAway
2271 int ent_count =
UNIVERSE->n_entities;
2273 Entity* my_entities[ent_count];
2275 for (i = 0; i < ent_count; i++)
2276 my_entities[i] = [uni_entities[i] retain];
2278 for (i = 1; i < ent_count; i++)
2280 Entity* e1 = my_entities[i];
2285 if (((e_class == CLASS_NEUTRAL)||(e_class == CLASS_POLICE)||(e_class == CLASS_MILITARY)||(e_class == CLASS_THARGOID)) &&
2286 ! ([se1 isStation] && [se1 maxFlightSpeed] == 0) &&
2287 [se1 hasHyperspaceMotor])
2291 [se1
setAITo:@"exitingTraderAI.plist"];
2300 for (i = 0; i < ent_count; i++)
2302 [my_entities[i] release];
2313 NSDictionary* dict = [[UNIVERSE systemManager] getPropertiesForSystemKey:planetKey];
2316 OOLog(
@"script.error.addPlanet.keyNotFound",
@"***** ERROR: could not find an entry in planetinfo.plist for '%@'", planetKey);
2322 OOPlanetEntity *planet = [[[
OOPlanetEntity alloc] initFromDictionary:dict withAtmosphere:YES andSeed:[[UNIVERSE systemManager] getRandomSeedForCurrentSystem] forSystem:system_id] autorelease];
2324 Quaternion planetOrientation;
2330 if (![dict objectForKey:
@"position"])
2332 OOLog(
@"script.error.addPlanet.noPosition",
@"***** ERROR: you must specify a position for scripted planet '%@' before it can be created", planetKey);
2336 NSString *positionString = [dict objectForKey:@"position"];
2339 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);
2342 HPVector posn = [UNIVERSE coordinatesFromCoordinateSystemString:positionString];
2343 if (posn.x || posn.y || posn.z)
2345 OOLog(
kOOLogDebugAddPlanet,
@"planet position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2350 OOLog(
kOOLogDebugAddPlanet,
@"planet position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2354 [UNIVERSE addEntity:planet];
2365 NSDictionary* dict = [[UNIVERSE systemManager] getPropertiesForSystemKey:moonKey];
2368 OOLog(
@"script.error.addPlanet.keyNotFound",
@"***** ERROR: could not find an entry in planetinfo.plist for '%@'", moonKey);
2373 OOPlanetEntity *planet = [[[
OOPlanetEntity alloc] initFromDictionary:dict withAtmosphere:NO andSeed:[[UNIVERSE systemManager] getRandomSeedForCurrentSystem] forSystem:system_id] autorelease];
2375 Quaternion planetOrientation;
2381 if (![dict objectForKey:
@"position"])
2383 OOLog(
@"script.error.addPlanet.noPosition",
@"***** ERROR: you must specify a position for scripted moon '%@' before it can be created", moonKey);
2387 NSString *positionString = [dict objectForKey:@"position"];
2390 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);
2392 HPVector posn = [UNIVERSE coordinatesFromCoordinateSystemString:positionString];
2393 if (posn.x || posn.y || posn.z)
2404 [UNIVERSE addEntity:planet];
2423- (void) debugMessage:(NSString *)args
2429- (void) playSound:(NSString *) soundName
2431 [
self playLegacyScriptSound:soundName];
2437- (void) doMissionCallback
2440 _missionWithCallback = NO;
2445- (void) clearMissionScreenID
2447 [_missionScreenID release];
2448 _missionScreenID =
nil;
2452- (void) setMissionScreenID:(NSString *)msid
2454 _missionScreenID = [msid retain];
2458- (NSString *) missionScreenID
2460 return _missionScreenID;
2464- (void) endMissionScreenAndNoteOpportunity
2466 _missionAllowInterrupt = NO;
2467 [
self clearMissionScreenID];
2469 if(![
self doWorldEventUntilMissionScreen:
OOJSID(
"missionScreenEnded")])
2472 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
2477- (void) setGuiToMissionScreen
2481 [
self setMissionBackgroundSpecial:nil];
2483 [
self setMissionExitScreen:GUI_SCREEN_STATUS];
2485 [
self setGuiToMissionScreenWithCallback:NO];
2489- (void) refreshMissionScreenTextEntry
2493 NSUInteger end_row = 21;
2494 if ([[
self hud] allowBigGui])
2499 [gui
setText:[NSString stringWithFormat:DESC(@"mission-screen-text-prompt-@"), [gameView
typedString]]
forRow:end_row
align:GUI_ALIGN_LEFT];
2508- (void) setGuiToMissionScreenWithCallback:(BOOL) callback
2512 NSUInteger end_row = 21;
2513 if ([[
self hud] allowBigGui])
2521 [gui
setTitle:[
self missionTitle] ?: DESC(@"mission-information")];
2523 if (!_missionTextEntry)
2532 [
self refreshMissionScreenTextEntry];
2537 NSDictionary *background_desc = [
self missionBackgroundDescriptorOrDefault];
2540 BOOL overridden = ([
self missionBackgroundDescriptor] !=
nil);
2551 gui_screen = GUI_SCREEN_MISSION;
2555 [lastTextKey release];
2562 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
2563 _missionWithCallback = callback;
2564 _missionAllowInterrupt = NO;
2565 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
2570- (void) setBackgroundFromDescriptionsKey:(NSString*) d_key
2572 NSArray * items = (NSArray *)[[
UNIVERSE descriptions] objectForKey:d_key];
2577 [
self addScene: items atOffset: kZeroVector];
2579 [
self setShowDemoShips: YES];
2583- (void) addScene:(NSArray *)items atOffset:(Vector)off
2587 if (items ==
nil)
return;
2589 for (i = 0; i < [items count]; i++)
2591 id item = [items objectAtIndex:i];
2592 if ([item isKindOfClass:[NSString class]])
2594 [
self processSceneString:item atOffset: off];
2596 else if ([item isKindOfClass:[NSArray class]])
2598 [
self addScene:item atOffset: off];
2600 else if ([item isKindOfClass:[NSDictionary class]])
2602 [
self processSceneDictionary:item atOffset: off];
2608- (BOOL) processSceneDictionary:(NSDictionary *) couplet atOffset:(Vector) off
2610 NSArray *conditions = [couplet objectForKey:@"conditions"];
2611 NSArray *actions =
nil;
2612 if ([couplet objectForKey:
@"do"])
2613 actions = [NSArray arrayWithObject: [couplet objectForKey:
@"do"]];
2614 NSArray *else_actions =
nil;
2615 if ([couplet objectForKey:
@"else"])
2616 else_actions = [NSArray arrayWithObject: [couplet objectForKey:
@"else"]];
2618 if (conditions ==
nil)
2620 OOLog(
@"script.scene.couplet.badConditions",
@"***** SCENE ERROR: %@ - conditions not %@, returning %@.", [couplet description],
@" found",
@"YES and performing 'do' actions");
2624 if (![conditions isKindOfClass:[NSArray class]])
2626 OOLog(
@"script.scene.couplet.badConditions",
@"***** SCENE ERROR: %@ - conditions not %@, returning %@.", [conditions description],
@"an array",
@"NO");
2635 if ((success) && (actions) && [actions
count])
2636 [
self addScene: actions atOffset: off];
2639 if ((!success) && (else_actions) && [else_actions
count])
2640 [
self addScene: else_actions atOffset: off];
2646- (BOOL) processSceneString:(NSString*) item atOffset:(Vector) off
2656 NSString* i_key = [(NSString*)[i_info objectAtIndex:0] lowercaseString];
2663 if ([i_key isEqualToString:
@"scene"])
2665 if ([i_info
count] != 5)
2667 NSString* scene_key = (NSString*)[i_info objectAtIndex: 1];
2668 Vector scene_offset = {0};
2669 ScanVectorFromString([[i_info subarrayWithRange:NSMakeRange(2, 3)] componentsJoinedByString:
@" "], &scene_offset);
2670 scene_offset.x += off.
x; scene_offset.y += off.
y; scene_offset.z += off.z;
2671 NSArray * scene_items = (NSArray *)[[
UNIVERSE descriptions] objectForKey:scene_key];
2676 [
self addScene: scene_items atOffset: scene_offset];
2685 if ([i_key isEqualToString:
@"ship"]||[i_key isEqualToString:
@"model"]||[i_key isEqualToString:
@"role"])
2687 if ([i_info
count] != 10)
2694 if ([i_key isEqualToString:
@"ship"]||[i_key isEqualToString:
@"model"])
2696 ship = [UNIVERSE newShipWithName:[i_info oo_stringAtIndex: 1]];
2698 else if ([i_key isEqualToString:
@"role"])
2700 ship = [UNIVERSE newShipWithRole:[i_info oo_stringAtIndex: 1]];
2707 Vector model_offset = positionOffsetForShipInRotationToAlignment(ship, model_q, [i_info oo_stringAtIndex:9]);
2708 model_p0 = vector_add(model_p0, vector_subtract(off, model_offset));
2713 [UNIVERSE setMainLightPosition:(Vector){ DEMO_LIGHT_POSITION }];
2716 [UNIVERSE addEntity: ship];
2717 [ship
setStatus: STATUS_COCKPIT_DISPLAY];
2729 if ([i_key isEqualToString:
@"player"])
2731 if ([i_info
count] != 9)
2734 ShipEntity* doppelganger = [UNIVERSE newShipWithName:[
self shipDataKey]];
2740 Vector model_offset = positionOffsetForShipInRotationToAlignment( doppelganger, model_q, (NSString*)[i_info objectAtIndex:8]);
2741 model_p0.x += off.
x - model_offset.
x;
2742 model_p0.y += off.
y - model_offset.
y;
2743 model_p0.z += off.z - model_offset.z;
2747 [doppelganger
setPosition: vectorToHPVector(model_p0)];
2748 [UNIVERSE setMainLightPosition:(Vector){ DEMO_LIGHT_POSITION }];
2751 [UNIVERSE addEntity: doppelganger];
2752 [doppelganger
setStatus: STATUS_COCKPIT_DISPLAY];
2758 [doppelganger release];
2764 if ([i_key isEqualToString:
@"local-planet"] || [i_key isEqualToString:
@"target-planet"])
2766 if ([i_info
count] != 4)
2770 if (info_system_id & 8)
2772 _sysInfoLight = (info_system_id & 2) ? (Vector){ -10000.0, 4000.0, -10000.0 } : (Vector){ -12000.0, -5000.0, -10000.0 };
2776 _sysInfoLight = (info_system_id & 2) ? (Vector){ 6000.0, -5000.0, -10000.0 } : (Vector){ 6000.0, 4000.0, -10000.0 };
2779 [UNIVERSE setMainLightPosition:_sysInfoLight];
2783 if ([i_key isEqualToString:
@"local-planet"] && [
UNIVERSE sun])
2785 originalPlanet = [UNIVERSE planet];
2789 originalPlanet = [[[
OOPlanetEntity alloc] initAsMainPlanetForSystem:info_system_id] autorelease];
2792 if (doppelganger ==
nil)
return NO;
2796 NSMutableDictionary *planetInfo = [NSMutableDictionary dictionaryWithDictionary:[UNIVERSE generateSystemData:target_system_seed]];
2798 if ([i_key isEqualToString:
@"local-planet"] && [
UNIVERSE sun])
2801 OOTexture *texture = [mainPlanet texture];
2804 [planetInfo setObject:texture forKey:@"_oo_textureObject"];
2805 [planetInfo oo_setBool:[mainPlanet isExplicitlyTextured] forKey:@"_oo_isExplicitlyTextured"];
2806 [planetInfo oo_setBool:YES forKey:@"mainForLocalSystem"];
2811 doppelganger = [[
OOPlanetEntity alloc] initFromDictionary:planetInfo withAtmosphere:YES andSeed:target_system_seed];
2812 [doppelganger miniaturize];
2813 [doppelganger autorelease];
2815 if (doppelganger ==
nil)
return NO;
2818 ScanVectorFromString([[i_info subarrayWithRange:NSMakeRange(1, 3)] componentsJoinedByString:
@" "], &model_p0);
2821 model_p0 = vector_multiply_scalar(model_p0, 1 - 0.5 * ((60 - [doppelganger radius]) / 60));
2823 model_p0 = vector_add(model_p0, off);
2829 Quaternion model_q = { 0.83, 0.12, 0.44, 0.0 };
2832 Quaternion model_q = { 0.833492, 0.333396, 0.440611, 0.0 };
2837 [doppelganger
setPosition: vectorToHPVector(model_p0)];
2840 int deltaT = floor(fmod([
self clockTimeAdjusted], 86400));
2841 [doppelganger
update: deltaT];
2842 [UNIVERSE addEntity:doppelganger];
2851- (BOOL) addEqScriptForKey:(NSString *)eq_key
2853 if (eq_key ==
nil)
return NO;
2857 OOLog(
@"player.equipmentScript",
@"Added equipment %@, with the following script property: '%@'.", eq_key, scriptName);
2859 if (scriptName ==
nil)
return NO;
2861 NSMutableDictionary *properties = [NSMutableDictionary dictionary];
2864 NSArray *eqScript =
nil;
2865 foreach (eqScript, eqScripts)
2867 NSString *key = [eqScript oo_stringAtIndex:0];
2868 if ([key isEqualToString: eq_key]) return NO;
2871 [properties setObject:self forKey:@"ship"];
2872 [properties setObject:eq_key forKey:@"equipmentKey"];
2874 if (s ==
nil)
return NO;
2876 OOLog(
@"player.equipmentScript",
@"Script '%@': installation %@successful.", scriptName,(s ==
nil ?
@"un" :
@""));
2878 [eqScripts addObject:[NSArray arrayWithObjects:eq_key,s,nil]];
2879 if (primedEquipment == [eqScripts
count] - 1) primedEquipment++;
2880 OOLog(
@"player.equipmentScript",
@"Scriptable equipment available: %llu.", [eqScripts
count]);
2885- (void) removeEqScriptForKey:(NSString *)eq_key
2887 if (eq_key ==
nil)
return;
2889 NSString *key =
nil;
2890 NSUInteger i,
count = [eqScripts count];
2892 for (i = 0; i <
count; i++)
2894 key = [[eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0];
2895 if ([key isEqualToString: eq_key])
2897 [eqScripts removeObjectAtIndex:i];
2899 if (i == primedEquipment) primedEquipment =
count;
2900 else if (i < primedEquipment) primedEquipment--;
2901 if (
count == primedEquipment) primedEquipment--;
2903 OOLog(
@"player.equipmentScript",
@"Removed equipment %@, with the following script property: '%@'.", eq_key, [[
OOEquipmentType equipmentTypeWithIdentifier:eq_key] scriptName]);
2909- (NSUInteger) eqScriptIndexForKey:(NSString *)eq_key
2911 NSUInteger i,
count = [eqScripts count];
2915 for (i = 0; i <
count; i++)
2917 NSString *key = [[eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0];
2918 if ([key isEqualToString: eq_key]) return i;
2926- (void) targetNearestHostile
2928 [
self scanForHostiles];
2929 Entity *ent = [
self foundTarget];
2932 ident_engaged = YES;
2934 [
self addTarget:ent];
2939- (void) targetNearestIncomingMissile
2941 [
self scanForNearestIncomingMissile];
2942 Entity *ent = [
self foundTarget];
2945 ident_engaged = YES;
2947 [
self addTarget:ent];
2952- (void) setGalacticHyperspaceBehaviourTo:(NSString *)galacticHyperspaceBehaviourString
2955 if (ghBehaviour == GALACTIC_HYPERSPACE_BEHAVIOUR_UNKNOWN)
2957 OOLog(
@"player.setGalacticHyperspaceBehaviour.invalidInput",
2958 @"setGalacticHyperspaceBehaviourTo: called with unknown behaviour %@.", galacticHyperspaceBehaviourString);
2960 [
self setGalacticHyperspaceBehaviour:ghBehaviour];
2964- (void) setGalacticHyperspaceFixedCoordsTo:(NSString *)galacticHyperspaceFixedCoordsString
2967 if ([coord_vals
count] < 2)
2969 OOLog(
@"player.setGalacticHyperspaceFixedCoords.invalidInput",
@"%@",
2970 @"setGalacticHyperspaceFixedCoords: called with bad specifier. Defaulting to Oolite standard.");
2971 galacticHyperspaceFixedCoords.x = galacticHyperspaceFixedCoords.y = 0x60;
2974 [
self setGalacticHyperspaceFixedCoordsX:[coord_vals oo_unsignedCharAtIndex:0]
2975 y:[coord_vals oo_unsignedCharAtIndex:1]];
2992 return @"<error: invalid comparison type>";
NSString * OOStringFromEntityStatus(OOEntityStatus status) CONST_FUNC
#define foreachkey(VAR, DICT)
NSString * OODisplayStringFromEconomyID(OOEconomyID economy)
NSString * OODisplayStringFromGovernmentID(OOGovernmentID government)
NSArray * OOSanitizeLegacyScriptConditions(NSArray *conditions, NSString *context)
#define OOLogWARN(class, format,...)
#define OOLogERR(class, format,...)
NSString *const kOOLogException
#define OOLog(class, format,...)
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
@ kOOExpandBackslashN
Convert literal "\\n"s to line breaks (used for missiontext.plist for historical reasons).
Random_Seed OOStringExpanderDefaultRandomSeed(void)
#define OOExpandWithOptions(seed, options, string,...)
NSString * OOExpandDescriptionString(Random_Seed seed, NSString *string, NSDictionary *overrides, NSDictionary *legacyLocals, NSString *systemName, OOExpandOptions options)
#define OOExpand(string,...)
NSMutableArray * ScanTokensFromString(NSString *values)
BOOL ScanVectorAndQuaternionFromString(NSString *xyzwxyzString, Vector *outVector, Quaternion *outQuaternion)
BOOL ScanHPVectorFromString(NSString *xyzString, HPVector *outVector)
BOOL ScanQuaternionFromString(NSString *wxyzString, Quaternion *outQuaternion)
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
NSString * OOCommodityType
uint64_t OOCreditsQuantity
int32_t OOCargoQuantityDelta
NSString * OOComparisonTypeToString(OOComparisonType type) CONST_FUNC
static NSString *const kOOLogSyntaxSet
static NSString *const kOOLogRemoveAllCargoNotDocked
static NSString *const kOOLogSyntaxIncrement
static NSString *const kOOLogNoteSet
static NSString *const kOOLogDebugOnOff
static NSString *const kOOLogNoteUseSpecialCargo
static NSString *const kOOLogSyntaxSetPlanetInfo
static NSString * sCurrentMissionKey
static NSString *const kOOLogSyntaxReset
static NSString *const kOOLogNoteRemoveAllCargo
static NSString *const kOOLogSyntaxAwardEquipment
static NSString *const kOOLogSyntaxDecrement
static NSString *const kOOLogDebugReplaceVariablesInString
static NSString *const kOOLogSyntaxSubtract
static NSString *const kOOLogDebugProcessSceneStringAddMiniPlanet
static NSString *const kOOLogDebugProcessSceneStringAddModel
static NSString *const kOOLogSyntaxRemoveEquipment
static NSString *const kOOLogDebugAddPlanet
static NSString *const kOOLogScriptMissionDescNoKey
static ShipEntity * scriptTarget
static NSString *const kOOLogScriptMissionDescNoText
static NSString *const kOOLogDebugOnMetaClass
static NSString *const kOOLogNoteShowShipModel
static NSString *const kOOLogDebugProcessSceneStringAddScene
static NSString *const kOOLogSyntaxAwardCargo
static NSString *const kOOLogNoteAddShips
static BOOL sRunningScript
static NSString *const kOOLogDebugMessage
static NSString * sMissionStringValue
static NSString *const kOOLogScriptAddShipsFailed
#define ACTIONS_TEMP_PREFIX
static NSString *const kOOLogSyntaxMessageShipAIs
static NSString *const kOOLogSyntaxAdd
static NSString *const kOOLogNoteFuelLeak
static NSString *const kOOLogNoteAddPlanet
static NSString *const kOOLogSyntaxAddShips
static NSString *const kOOLogNoteProcessSceneString
static NSString *const kActionTempPrefix
OOGalacticHyperspaceBehaviour
OOGalacticHyperspaceBehaviour OOGalacticHyperspaceBehaviourFromString(NSString *string) PURE_FUNC
NSString * OODisplayRatingStringFromKillCount(unsigned kills)
#define SCRIPT_TIMER_INTERVAL
@ MISSILE_STATUS_TARGET_LOCKED
NSString * OODisplayStringFromLegalStatus(int legalStatus)
NSString * OOStringFromGUIScreenID(OOGUIScreenID screen) CONST_FUNC
static NSString * CurrentScriptNameOr(NSString *alternative)
OOINLINE OOEntityStatus RecursiveRemapStatus(OOEntityStatus status)
void setNextThinkTime:(OOTimeAbsolute ntt)
void setState:(NSString *stateName)
void reactToMessage:context:(NSString *message,[context] NSString *debugContext)
void setVelocity:(Vector vel)
void setOrientation:(Quaternion quat)
void setScanClass:(OOScanClass sClass)
void setPosition:(HPVector posn)
BOOL setSelectedRow:(OOGUIRow row)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
BOOL setForegroundTextureDescriptor:(NSDictionary *descriptor)
void setSelectableRange:(NSRange range)
void setBackgroundTextureSpecial:withBackground:(OOGUIBackgroundSpecial spec,[withBackground] BOOL withBackground)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setTitle:(NSString *str)
void setShowTextCursor:(BOOL yesno)
void setCurrentRow:(OOGUIRow value)
BOOL setBackgroundTextureDescriptor:(NSDictionary *descriptor)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
NSMutableString * typedString
OOColor * darkGrayColor()
OOColor * colorWithDescription:(id description)
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
OOJavaScriptEngine * sharedEngine()
void runMissionCallback()
OOMusicController * sharedController()
void setMissionMusic:(NSString *missionMusicName)
instancetype miniatureVersion()
void setOrientation:(Quaternion quat)
void update:(OOTimeDelta delta_t)
id jsScriptFromFileNamed:properties:(NSString *fileName,[properties] NSDictionary *properties)
NSMutableDictionary * localVariablesForMission:(NSString *missionKey)
void setFuel:(OOFuelQuantity amount)
void setStatus:(OOEntityStatus stat)
void setRoll:(double amount)
void setPrimaryRole:(NSString *role)
OOFuelQuantity fuelCapacity()
void setPitch:(double amount)
void setAITo:(NSString *aiString)
ShipEntity * ejectShipOfType:(NSString *shipKey)
void setBehaviour:(OOBehaviour cond)
void switchAITo:(NSString *aiString)
OOTechLevelID equivalentTechLevel
void takeEnergyDamage:from:becauseOf:weaponIdentifier:(double amount, [from] Entity *ent, [becauseOf] Entity *other, [weaponIdentifier] NSString *weaponIdentifier)
void seed_RNG_only_for_planet_description(Random_Seed s_seed)