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 NSEnumerator *componentEnum =
nil;
614 NSArray *component =
nil;
615 NSString *value =
nil;
617 result = [NSMutableArray arrayWithCapacity:[rhsComponents count]];
619 for (componentEnum = [rhsComponents objectEnumerator]; (component = [componentEnum nextObject]); )
630 value = [component oo_stringAtIndex:1];
632 if ([[component objectAtIndex:0] boolValue])
634 value = [[
self performSelector:NSSelectorFromString(value)] description];
635 if (value ==
nil) value =
@"(null)";
638 [result addObject:value];
641 return [result componentsJoinedByString:@" "];
645- (NSDictionary *) missionVariables
647 return mission_variables;
651- (NSString *)missionVariableForKey:(NSString *)key
653 NSString *result =
nil;
654 if (key !=
nil) result = [mission_variables objectForKey:key];
659- (void)setMissionVariable:(NSString *)value forKey:(NSString *)key
663 if (value !=
nil) [mission_variables setObject:value forKey:key];
664 else [mission_variables removeObjectForKey:key];
669- (NSMutableDictionary *)localVariablesForMission:(NSString *)missionKey
671 NSMutableDictionary *result =
nil;
673 if (missionKey ==
nil)
return nil;
675 result = [localVariables objectForKey:missionKey];
678 result = [NSMutableDictionary dictionary];
679 [localVariables setObject:result forKey:missionKey];
686- (NSString *)localVariableForKey:(NSString *)variableName andMission:(NSString *)missionKey
688 return [[localVariables oo_dictionaryForKey:missionKey] objectForKey:variableName];
692- (void)setLocalVariable:(NSString *)value forKey:(NSString *)variableName andMission:(NSString *)missionKey
694 NSMutableDictionary *locals =
nil;
696 if (variableName !=
nil && missionKey !=
nil)
698 locals = [
self localVariablesForMission:missionKey];
701 [locals setObject:value forKey:variableName];
705 [locals removeObjectForKey:variableName];
711- (NSArray *) missionsList
713 NSEnumerator *scriptEnum =
nil;
714 NSString *scriptName =
nil;
715 NSString *vars =
nil;
716 NSMutableArray *result1 =
nil;
717 NSMutableArray *result2 =
nil;
719 result1 = [NSMutableArray array];
720 result2 = [NSMutableArray array];
722 NSArray* passengerManifest = [
self passengerList];
723 NSArray* contractManifest = [
self contractList];
724 NSArray* parcelManifest = [
self parcelList];
726 if ([passengerManifest
count] > 0)
728 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-passengers")] arrayByAddingObjectsFromArray:passengerManifest]];
731 if ([parcelManifest
count] > 0)
733 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-parcels")] arrayByAddingObjectsFromArray:parcelManifest]];
736 if ([contractManifest
count] > 0)
738 [result2 addObject:[[NSArray arrayWithObject:DESC(@"manifest-contracts")] arrayByAddingObjectsFromArray:contractManifest]];
743 for (scriptEnum = [worldScripts keyEnumerator]; (scriptName = [scriptEnum nextObject]); )
745 vars = [mission_variables objectForKey:scriptName];
749 if ([vars isKindOfClass:[NSString
class]])
751 [result1 addObject:vars];
753 else if ([vars isKindOfClass:[NSArray
class]])
756 NSArray *element =
nil;
757 foreach (element, result2)
759 if ([[element oo_stringAtIndex:0] isEqualToString:[(NSArray*)vars oo_stringAtIndex:0]])
762 [result2 removeObject:element];
763 NSRange notTheHeader;
764 notTheHeader.location = 1;
765 notTheHeader.length = [(NSArray*)vars count]-1;
766 [result2 addObject:[element arrayByAddingObjectsFromArray:[(NSArray*)vars subarrayWithRange:notTheHeader]]];
773 [result2 addObject:vars];
778 return [result1 arrayByAddingObjectsFromArray:result2];
782- (NSString*) replaceVariablesInString:(NSString*) args
784 NSMutableDictionary *locals = [
self localVariablesForMission:sCurrentMissionKey];
785 NSMutableString *resultString = [NSMutableString stringWithString: args];
786 NSString *valueString;
790 for (i = 0; i < [tokens count]; i++)
792 valueString = [tokens objectAtIndex:i];
794 if ([valueString hasPrefix:
@"mission_"] && [mission_variables objectForKey:valueString])
796 [resultString replaceOccurrencesOfString:valueString withString:[mission_variables objectForKey:valueString] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
798 else if ([locals objectForKey:valueString])
800 [resultString replaceOccurrencesOfString:valueString withString:[locals objectForKey:valueString] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
802 else if (([valueString hasSuffix:
@"_number"])||([valueString hasSuffix:
@"_bool"])||([valueString hasSuffix:
@"_string"]))
804 SEL valueselector = NSSelectorFromString(valueString);
805 if ([
self respondsToSelector:valueselector])
807 [resultString replaceOccurrencesOfString:valueString withString:[NSString stringWithFormat:@"%@", [
self performSelector:valueselector]] options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
810 else if ([valueString hasPrefix:
@"["]&&[valueString hasSuffix:
@"]"])
812 NSString* replaceString =
OOExpand(valueString);
813 [resultString replaceOccurrencesOfString:valueString withString:replaceString options:NSLiteralSearch range:NSMakeRange(0, [resultString length])];
819 return [NSString stringWithString: resultString];
825- (void) setMissionDescription:(NSString *)textKey
827 [
self setMissionDescription:textKey forMission:sCurrentMissionKey];
831- (void) setMissionDescription:(NSString *)textKey forMission:(NSString *)key
833 NSString *text = [[UNIVERSE missiontext] oo_stringForKey:textKey];
841 [
self setMissionInstructions:text forMission:key];
846- (void) setMissionInstructions:(NSString *)text forMission:(NSString *)key
855 text = [
self replaceVariablesInString: text];
857 [mission_variables setObject:text forKey:key];
861- (void) setMissionInstructionsList:(NSArray *)list forMission:(NSString *)key
869 NSString *text =
nil;
870 NSUInteger i,ct = [list count];
871 NSMutableArray *expandedList = [NSMutableArray arrayWithCapacity:ct];
872 for (i=0 ; i<ct ; i++)
874 text = [list oo_stringAtIndex:i defaultValue:nil];
878 text = [
self replaceVariablesInString: text];
879 [expandedList addObject:text];
883 [mission_variables setObject:expandedList forKey:key];
887- (void) clearMissionDescription
889 [
self clearMissionDescriptionForMission:sCurrentMissionKey];
893- (void) clearMissionDescriptionForMission:(NSString *)key
901 if (![mission_variables objectForKey:key])
return;
903 [mission_variables removeObjectForKey:key];
907- (NSString *) mission_string
913- (NSString *) status_string
919- (NSString *) gui_screen_string
925- (NSNumber *) galaxy_number
927 return [NSNumber numberWithInt:[
self currentGalaxyID]];
931- (NSNumber *) planet_number
933 return [NSNumber numberWithInt:[
self currentSystemID]];
937- (NSNumber *) score_number
939 return [NSNumber numberWithUnsignedInt:[
self score]];
943- (NSNumber *) credits_number
945 return [NSNumber numberWithDouble:[
self creditBalance]];
949- (NSNumber *) scriptTimer_number
951 return [NSNumber numberWithDouble:[
self scriptTimer]];
956- (NSNumber *) shipsFound_number
958 return [NSNumber numberWithInt:shipsFound];
962- (NSNumber *) commanderLegalStatus_number
964 return [NSNumber numberWithInt:[
self legalStatus]];
968- (void) setLegalStatus:(NSString *)valueString
970 legalStatus = [valueString intValue];
974- (NSString *) commanderLegalStatus_string
980- (NSNumber *) d100_number
983 return [NSNumber numberWithInt:d100];
987- (NSNumber *) pseudoFixedD100_number
989 return [NSNumber numberWithInt:[
self systemPseudoRandom100]];
993- (NSNumber *) d256_number
996 return [NSNumber numberWithInt:d256];
1000- (NSNumber *) pseudoFixedD256_number
1002 return [NSNumber numberWithInt:[
self systemPseudoRandom256]];
1006- (NSNumber *) clock_number
1008 return [NSNumber numberWithDouble:ship_clock];
1012- (NSNumber *) clock_secs_number
1014 return [NSNumber numberWithUnsignedLongLong:ship_clock];
1018- (NSNumber *) clock_mins_number
1020 return [NSNumber numberWithUnsignedLongLong:ship_clock / 60.0];
1024- (NSNumber *) clock_hours_number
1026 return [NSNumber numberWithUnsignedLongLong:ship_clock / 3600.0];
1030- (NSNumber *) clock_days_number
1032 return [NSNumber numberWithUnsignedLongLong:ship_clock / 86400.0];
1036- (NSNumber *) fuelLevel_number
1038 return [NSNumber numberWithFloat:floor(0.1 * fuel)];
1042- (NSString *) dockedAtMainStation_bool
1044 if ([
self dockedAtMainStation])
return @"YES";
1049- (NSString *) foundEquipment_bool
1051 return (found_equipment)?
@"YES" :
@"NO";
1055- (NSString *) sunWillGoNova_bool
1057 return ([[
UNIVERSE sun] willGoNova])?
@"YES" :
@"NO";
1061- (NSString *) sunGoneNova_bool
1063 return ([[
UNIVERSE sun] goneNova])?
@"YES" :
@"NO";
1067- (NSString *) missionChoice_string
1069 return missionChoice;
1073- (NSString *) missionKeyPress_string
1075 return missionKeyPress;
1079- (NSNumber *) dockedTechLevel_number
1084 return [
self systemTechLevel_number];
1089- (NSString *) dockedStationName_string
1091 NSString *result =
nil;
1092 if ([
self status] != STATUS_DOCKED)
return @"NONE";
1094 result = [
self dockedStationName];
1095 if (result ==
nil) result =
@"UNKNOWN";
1100- (NSString *) systemGovernment_string
1102 int government = [[
self systemGovernment_number] intValue];
1104 if (result ==
nil) result =
@"UNKNOWN";
1110- (NSNumber *) systemGovernment_number
1112 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1113 return [systeminfo objectForKey:KEY_GOVERNMENT];
1117- (NSString *) systemEconomy_string
1119 int economy = [[
self systemEconomy_number] intValue];
1121 if (result ==
nil) result =
@"UNKNOWN";
1127- (NSNumber *) systemEconomy_number
1129 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1130 return [systeminfo objectForKey:KEY_ECONOMY];
1134- (NSNumber *) systemTechLevel_number
1136 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1137 return [systeminfo objectForKey:KEY_TECHLEVEL];
1141- (NSNumber *) systemPopulation_number
1143 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1144 return [systeminfo objectForKey:KEY_POPULATION];
1148- (NSNumber *) systemProductivity_number
1150 NSDictionary *systeminfo = [UNIVERSE currentSystemData];
1151 return [systeminfo objectForKey:KEY_PRODUCTIVITY];
1155- (NSString *) commanderName_string
1157 return [
self commanderName];
1161- (NSString *) commanderRank_string
1167- (NSString *) commanderShip_string
1173- (NSString *) commanderShipDisplayName_string
1175 return [
self displayName];
1181- (NSString *) expandMessage:(NSString *)valueString
1184 very_random_seed.
a = rand() & 255;
1185 very_random_seed.
b = rand() & 255;
1186 very_random_seed.
c = rand() & 255;
1187 very_random_seed.
d = rand() & 255;
1188 very_random_seed.
e = rand() & 255;
1189 very_random_seed.
f = rand() & 255;
1191 NSString* expandedMessage =
OOExpand(valueString);
1192 return [
self replaceVariablesInString: expandedMessage];
1196- (void) commsMessage:(NSString *)valueString
1198 [UNIVERSE addCommsMessage:[
self expandMessage:valueString] forCount:4.5];
1205- (void) commsMessageByUnpiloted:(NSString *)valueString
1207 [
self commsMessage:valueString];
1211- (void) consoleMessage3s:(NSString *)valueString
1213 [UNIVERSE addMessage:[
self expandMessage:valueString] forCount: 3];
1217- (void) consoleMessage6s:(NSString *)valueString
1219 [UNIVERSE addMessage:[
self expandMessage:valueString] forCount: 6];
1223- (void) awardCredits:(NSString *)valueString
1231 int64_t award = [valueString intValue];
1234 else credits += award;
1238- (void) awardShipKills:(NSString *)valueString
1242 int value = [valueString intValue];
1243 if (0 < value) ship_kills += value;
1247- (void) awardEquipment:(NSString *)equipString
1251 if ([equipString isEqualToString:
@"EQ_FUEL"])
1253 [
self setFuel:[
self fuelCapacity]];
1258 if ([eqType isMissileOrMine])
1260 [
self mountMissileWithRole:equipString];
1262 else if([equipString hasPrefix:
@"EQ_WEAPON"] && ![equipString hasSuffix:
@"_DAMAGED"])
1264 OOLog(
kOOLogSyntaxAwardEquipment,
@"***** SCRIPT ERROR: in %@, CANNOT award undamaged weapon:'%@'. Damaged weapons can be awarded instead.", CurrentScriptDesc(), equipString);
1266 else if ([equipString hasSuffix:
@"_DAMAGED"] && [
self hasEquipmentItem:[equipString substringToIndex:[equipString length] - [
@"_DAMAGED" length]]])
1268 OOLog(
kOOLogSyntaxAwardEquipment,
@"***** SCRIPT ERROR: in %@, CANNOT award damaged equipment:'%@'. Undamaged version already equipped.", CurrentScriptDesc(), equipString);
1270 else if ([eqType canCarryMultiple] || ![
self hasEquipmentItem:equipString])
1272 [
self addEquipmentItem:equipString withValidation:YES inContext:@"scripted"];
1277- (void) removeEquipment:(NSString *)equipKey
1281 if ([equipKey isEqualToString:
@"EQ_FUEL"])
1287 if ([equipKey isEqualToString:
@"EQ_CARGO_BAY"] && [
self hasEquipmentItem:equipKey]
1288 && ([
self extraCargo] > [
self availableCargoSpace]))
1293 if ([
self hasEquipmentItem:equipKey] || [
self hasEquipmentItem:[equipKey stringByAppendingString:
@"_DAMAGED"]])
1295 [
self removeEquipmentItem:equipKey];
1301- (void) setPlanetinfo:(NSString *)key_valueString
1303 NSArray * tokens = [key_valueString componentsSeparatedByString:@"="];
1304 NSString* keyString =
nil;
1305 NSString* valueString =
nil;
1307 if ([tokens
count] != 2)
1309 OOLog(
kOOLogSyntaxSetPlanetInfo,
@"***** SCRIPT ERROR: in %@, CANNOT setPlanetinfo: '%@' (bad parameter count)", CurrentScriptDesc(), key_valueString);
1313 keyString = [[tokens objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1314 valueString = [[tokens objectAtIndex:1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1319 [UNIVERSE setSystemDataKey:keyString value:valueString fromManifest:@""];
1324- (void) setSpecificPlanetInfo:(NSString *)key_valueString
1326 NSArray * tokens = [key_valueString componentsSeparatedByString:@"="];
1327 NSString* keyString =
nil;
1328 NSString* valueString =
nil;
1331 if ([tokens
count] != 4)
1333 OOLog(
kOOLogSyntaxSetPlanetInfo,
@"***** SCRIPT ERROR: in %@, CANNOT setSpecificPlanetInfo: '%@' (bad parameter count)", CurrentScriptDesc(), key_valueString);
1337 gnum = [tokens oo_intAtIndex:0];
1338 pnum = [tokens oo_intAtIndex:1];
1339 keyString = [[tokens objectAtIndex:2] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1340 valueString = [[tokens objectAtIndex:3] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1342 [UNIVERSE setSystemDataForGalaxy:gnum planet:pnum key:keyString value:valueString fromManifest:@"" forLayer:OO_LAYER_OXP_DYNAMIC];
1346- (void) awardCargo:(NSString *)amount_typeString
1355 if ([tokens
count] != 2)
1357 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"bad parameter count");
1362 type = [tokens oo_stringAtIndex:1];
1363 if (![[
UNIVERSE commodities] goodDefined:type])
1365 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"unknown type");
1369 amount = [tokens oo_intAtIndex:0];
1372 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"negative quantity");
1376 unit = [shipCommodityData massUnitForGood:type];
1379 OOLog(
kOOLogSyntaxAwardCargo,
@"***** SCRIPT ERROR: in %@, CANNOT awardCargo: '%@' (%@)", CurrentScriptDesc(), amount_typeString,
@"cargo hold full with special cargo");
1383 [
self awardCommodityType:type amount:amount];
1387- (void) removeAllCargo
1389 [
self removeAllCargo:NO];
1392- (void) removeAllCargo:(BOOL)forceRemoval
1399 if ([
self status] != STATUS_DOCKED && !forceRemoval)
1407 foreach(type, [shipCommodityData goods])
1409 if ([shipCommodityData massUnitForGood:type] ==
UNITS_TONS)
1411 [shipCommodityData setQuantity:0 forGood:type];
1416 if (forceRemoval && [
self status] != STATUS_DOCKED)
1419 for (i = [cargo
count] - 1; i >= 0; i--)
1421 ShipEntity* canister = [cargo objectAtIndex:i];
1422 if (!canister)
break;
1425 [cargo removeObjectAtIndex:i];
1431 [
self calculateCurrentCargo];
1435- (void) useSpecialCargo:(NSString *)descriptionString
1439 [
self removeAllCargo:YES];
1441 specialCargo = [OOExpand(descriptionString) retain];
1445- (void) testForEquipment:(NSString *)equipString
1447 found_equipment = [
self hasEquipmentItem:equipString];
1451- (void) awardFuel:(NSString *)valueString
1453 int delta = 10 * [valueString floatValue];
1456 if (delta < 0 && scriptTargetFuelBeforeAward < (
unsigned)-delta) [scriptTarget
setFuel:0];
1459 [scriptTarget
setFuel:(scriptTargetFuelBeforeAward + delta)];
1464- (void) messageShipAIs:(NSString *)roles_message
1467 NSString* roleString =
nil;
1468 NSString* messageString =
nil;
1470 if ([tokens
count] < 2)
1472 OOLog(
kOOLogSyntaxMessageShipAIs,
@"***** SCRIPT ERROR: in %@, CANNOT messageShipAIs: '%@' (bad parameter count)", CurrentScriptDesc(), roles_message);
1476 roleString = [tokens objectAtIndex:0];
1477 [tokens removeObjectAtIndex:0];
1478 messageString = [tokens componentsJoinedByString:@" "];
1480 NSArray *targets = [UNIVERSE findShipsMatchingPredicate:HasPrimaryRolePredicate
1481 parameter:roleString
1486 foreach(target, targets) {
1492- (void) ejectItem:(NSString *)itemKey
1499- (void) addShips:(NSString *)roles_number
1502 NSString* roleString =
nil;
1503 NSString* numberString =
nil;
1505 if ([tokens
count] != 2)
1507 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT addShips: '%@' (expected <role> <count>)", CurrentScriptDesc(), roles_number);
1511 roleString = [tokens objectAtIndex:0];
1512 numberString = [tokens objectAtIndex:1];
1514 int number = [numberString intValue];
1517 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, can't add %i ships -- that's less than zero, y'know..", CurrentScriptDesc(), number);
1524 [UNIVERSE witchspaceShipWithPrimaryRole:roleString];
1528- (void) addSystemShips:(NSString *)roles_number_position
1531 NSString* roleString =
nil;
1532 NSString* numberString =
nil;
1533 NSString* positionString =
nil;
1535 if ([tokens
count] != 3)
1537 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT addSystemShips: '%@' (expected <role> <count> <position>)", CurrentScriptDesc(), roles_number_position);
1541 roleString = [tokens objectAtIndex:0];
1542 numberString = [tokens objectAtIndex:1];
1543 positionString = [tokens objectAtIndex:2];
1545 int number = [numberString intValue];
1546 double posn = [positionString doubleValue];
1549 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, can't add %i ships -- that's less than zero, y'know..", CurrentScriptDesc(), number);
1553 OOLog(
kOOLogNoteAddShips,
@"DEBUG: Going to add %d ships with role '%@' at a point %.3f along route1", number, roleString, posn);
1556 [UNIVERSE addShipWithRole:roleString nearRouteOneAt:posn];
1560- (void) addShipsAt:(NSString *)roles_number_system_x_y_z
1564 NSString* roleString =
nil;
1565 NSString* numberString =
nil;
1566 NSString* systemString =
nil;
1567 NSString* xString =
nil;
1568 NSString* yString =
nil;
1569 NSString* zString =
nil;
1571 if ([tokens
count] != 6)
1573 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT addShipsAt: '%@' (expected <role> <count> <coordinate-system> <x> <y> <z>)", CurrentScriptDesc(), roles_number_system_x_y_z);
1577 roleString = [tokens objectAtIndex:0];
1578 numberString = [tokens objectAtIndex:1];
1579 systemString = [tokens objectAtIndex:2];
1580 xString = [tokens objectAtIndex:3];
1581 yString = [tokens objectAtIndex:4];
1582 zString = [tokens objectAtIndex:5];
1584 HPVector posn = make_HPvector([xString doubleValue], [yString doubleValue], [zString doubleValue]);
1586 int number = [numberString intValue];
1589 OOLog(
kOOLogSyntaxAddShips,
@"----- WARNING in %@ Tried to add %i ships -- no ship added.", CurrentScriptDesc(), number);
1593 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);
1595 if (![
UNIVERSE addShips: number withRole:roleString nearPosition: posn withCoordinateSystem: systemString])
1597 OOLog(
kOOLogScriptAddShipsFailed,
@"***** SCRIPT ERROR: in %@, %@ could not add %u ships with role \"%@\
"", CurrentScriptDesc(),
@"addShipsAt:", number, roleString);
1602- (void) addShipsAtPrecisely:(NSString *)roles_number_system_x_y_z
1606 NSString* roleString =
nil;
1607 NSString* numberString =
nil;
1608 NSString* systemString =
nil;
1609 NSString* xString =
nil;
1610 NSString* yString =
nil;
1611 NSString* zString =
nil;
1613 if ([tokens
count] != 6)
1615 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@,* CANNOT addShipsAtPrecisely: '%@' (expected <role> <count> <coordinate-system> <x> <y> <z>)", CurrentScriptDesc(), roles_number_system_x_y_z);
1619 roleString = [tokens objectAtIndex:0];
1620 numberString = [tokens objectAtIndex:1];
1621 systemString = [tokens objectAtIndex:2];
1622 xString = [tokens objectAtIndex:3];
1623 yString = [tokens objectAtIndex:4];
1624 zString = [tokens objectAtIndex:5];
1626 HPVector posn = make_HPvector([xString doubleValue], [yString doubleValue], [zString doubleValue]);
1628 int number = [numberString intValue];
1631 OOLog(
kOOLogSyntaxAddShips,
@"----- WARNING: in %@, Can't add %i ships -- no ship added.", CurrentScriptDesc(), number);
1635 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);
1637 if (![
UNIVERSE addShips: number withRole:roleString atPosition: posn withCoordinateSystem: systemString])
1639 OOLog(
kOOLogScriptAddShipsFailed,
@"***** SCRIPT ERROR: in %@, %@ could not add %u ships with role '%@'", CurrentScriptDesc(),
@"addShipsAtPrecisely:", number, roleString);
1644- (void) addShipsWithinRadius:(NSString *)roles_number_system_x_y_z_r
1648 if ([tokens
count] != 7)
1650 OOLog(
kOOLogSyntaxAddShips,
@"***** SCRIPT ERROR: in %@, CANNOT 'addShipsWithinRadius: %@' (expected <role> <count> <coordinate-system> <x> <y> <z> <radius>))", CurrentScriptDesc(), roles_number_system_x_y_z_r);
1654 NSString* roleString = [tokens objectAtIndex:0];
1655 int number = [[tokens objectAtIndex:1] intValue];
1656 NSString* systemString = [tokens objectAtIndex:2];
1657 double x = [[tokens objectAtIndex:3] doubleValue];
1658 double y = [[tokens objectAtIndex:4] doubleValue];
1659 double z = [[tokens objectAtIndex:5] doubleValue];
1660 GLfloat r = [[tokens objectAtIndex:6] floatValue];
1661 HPVector posn = make_HPvector(
x,
y, z);
1665 OOLog(
kOOLogSyntaxAddShips,
@"----- WARNING: in %@, can't add %i ships -- no ship added.", CurrentScriptDesc(), number);
1669 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);
1671 if (![
UNIVERSE addShips:number withRole: roleString nearPosition: posn withCoordinateSystem: systemString withinRadius: r])
1673 OOLog(
kOOLogScriptAddShipsFailed,
@"***** SCRIPT ERROR :in %@, %@ could not add %u ships with role \"%@\
"", CurrentScriptDesc(),
@"addShipsWithinRadius:", number, roleString);
1678- (void) spawnShip:(NSString *)ship_key
1691- (void) set:(NSString *)missionvariable_value
1694 NSString *missionVariableString =
nil;
1695 NSString *valueString =
nil;
1696 BOOL hasMissionPrefix, hasLocalPrefix;
1698 if ([tokens
count] < 2)
1700 OOLog(
kOOLogSyntaxSet,
@"***** SCRIPT ERROR: in %@, CANNOT SET '%@' (expected mission_variable or local_variable followed by value expression)", CurrentScriptDesc(), missionvariable_value);
1704 missionVariableString = [tokens objectAtIndex:0];
1705 [tokens removeObjectAtIndex:0];
1706 valueString = [tokens componentsJoinedByString:@" "];
1708 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1709 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1711 if (!hasMissionPrefix && !hasLocalPrefix)
1713 OOLog(
kOOLogSyntaxSet,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1717 OOLog(
kOOLogNoteSet,
@"DEBUG: script %@ is set to %@", missionVariableString, valueString);
1719 if (hasMissionPrefix)
1721 [
self setMissionVariable:valueString forKey:missionVariableString];
1725 [
self setLocalVariable:valueString forKey:missionVariableString andMission:sCurrentMissionKey];
1730- (void) reset:(NSString *)missionvariable
1732 NSString* missionVariableString = [missionvariable stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
1733 BOOL hasMissionPrefix, hasLocalPrefix;
1735 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1736 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1738 if (hasMissionPrefix)
1740 [
self setMissionVariable:nil forKey:missionVariableString];
1742 else if (hasLocalPrefix)
1744 [
self setLocalVariable:nil forKey:missionVariableString andMission:sCurrentMissionKey];
1748 OOLog(
kOOLogSyntaxReset,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1753- (void) increment:(NSString *)missionVariableString
1755 BOOL hasMissionPrefix, hasLocalPrefix;
1758 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1759 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1761 if (hasMissionPrefix)
1763 value = [[
self missionVariableForKey:missionVariableString] intValue];
1765 [
self setMissionVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString];
1767 else if (hasLocalPrefix)
1769 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] intValue];
1771 [
self setLocalVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1775 OOLog(
kOOLogSyntaxIncrement,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1780- (void) decrement:(NSString *)missionVariableString
1782 BOOL hasMissionPrefix, hasLocalPrefix;
1785 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1786 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1788 if (hasMissionPrefix)
1790 value = [[
self missionVariableForKey:missionVariableString] intValue];
1792 [
self setMissionVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString];
1794 else if (hasLocalPrefix)
1796 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] intValue];
1798 [
self setLocalVariable:[NSString stringWithFormat:@"%d", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1802 OOLog(
kOOLogSyntaxDecrement,
@"***** SCRIPT ERROR: in %@, IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString);
1807- (void) add:(NSString *)missionVariableString_value
1809 NSString* missionVariableString =
nil;
1810 NSString* valueString;
1813 BOOL hasMissionPrefix, hasLocalPrefix;
1815 if ([tokens
count] < 2)
1817 OOLog(
kOOLogSyntaxAdd,
@"***** SCRIPT ERROR: in %@, CANNOT ADD: '%@'", CurrentScriptDesc(), missionVariableString_value);
1821 missionVariableString = [tokens objectAtIndex:0];
1822 [tokens removeObjectAtIndex:0];
1823 valueString = [tokens componentsJoinedByString:@" "];
1825 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1826 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1828 if (hasMissionPrefix)
1830 value = [[
self missionVariableForKey:missionVariableString] doubleValue];
1831 value += [valueString doubleValue];
1832 [
self setMissionVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString];
1834 else if (hasLocalPrefix)
1836 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] doubleValue];
1837 value += [valueString doubleValue];
1838 [
self setLocalVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1842 OOLog(
kOOLogSyntaxAdd,
@"***** SCRIPT ERROR: in %@, CANNOT ADD: '%@' -- IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString_value, missionVariableString_value);
1847- (void) subtract:(NSString *)missionVariableString_value
1849 NSString* missionVariableString =
nil;
1850 NSString* valueString;
1853 BOOL hasMissionPrefix, hasLocalPrefix;
1855 if ([tokens
count] < 2)
1857 OOLog(
kOOLogSyntaxSubtract,
@"***** SCRIPT ERROR: in %@, CANNOT SUBTRACT: '%@'", CurrentScriptDesc(), missionVariableString_value);
1861 missionVariableString = [tokens objectAtIndex:0];
1862 [tokens removeObjectAtIndex:0];
1863 valueString = [tokens componentsJoinedByString:@" "];
1865 hasMissionPrefix = [missionVariableString hasPrefix:@"mission_"];
1866 hasLocalPrefix = [missionVariableString hasPrefix:@"local_"];
1868 if (hasMissionPrefix)
1870 value = [[
self missionVariableForKey:missionVariableString] doubleValue];
1871 value -= [valueString doubleValue];
1872 [
self setMissionVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString];
1874 else if (hasLocalPrefix)
1876 value = [[
self localVariableForKey:missionVariableString andMission:sCurrentMissionKey] doubleValue];
1877 value -= [valueString doubleValue];
1878 [
self setLocalVariable:[NSString stringWithFormat:@"%f", value] forKey:missionVariableString andMission:sCurrentMissionKey];
1882 OOLog(
kOOLogSyntaxSubtract,
@"***** SCRIPT ERROR: in %@, CANNOT SUBTRACT: '%@' -- IDENTIFIER '%@' DOES NOT BEGIN WITH 'mission_' or 'local_'", CurrentScriptDesc(), missionVariableString_value, missionVariableString_value);
1887- (void) checkForShips:(NSString *)roleString
1889 shipsFound = [UNIVERSE countShipsWithPrimaryRole:roleString];
1893- (void) resetScriptTimer
1901- (void) addMissionText: (NSString *)textKey
1903 NSString *text =
nil;
1905 if ([textKey isEqualToString:lastTextKey])
return;
1906 [lastTextKey release];
1907 lastTextKey = [textKey copy];
1910 text = [[UNIVERSE missiontext] oo_stringForKey:textKey];
1911 if (text ==
nil)
return;
1913 text = [
self replaceVariablesInString:text];
1915 [
self addLiteralMissionText:text];
1919- (void) addLiteralMissionText:(NSString *)text
1925 NSString *para =
nil;
1926 foreach (para, [text componentsSeparatedByString:
@"\n"])
1934- (void) setMissionChoiceByTextEntry:(BOOL)enable
1937 _missionTextEntry = enable;
1942- (void) setMissionChoices:(NSString *)choicesKey
1944 NSDictionary *choicesDict = [[UNIVERSE missiontext] oo_dictionaryForKey:choicesKey];
1945 if ([choicesDict
count] == 0)
1949 [
self setMissionChoicesDictionary:choicesDict];
1953- (void) setMissionChoicesDictionary:(NSDictionary *)choicesDict
1970 NSUInteger end_row = 21;
1971 if ([[
self hud] allowBigGui])
1976 NSArray *choiceKeys = [choicesDict allKeys];
1981 for (i=0; i < [choiceKeys count]; i++)
1983 if (![[choiceKeys objectAtIndex:i] isKindOfClass:[NSString
class]])
1985 OOLog(
@"test.script.error",
@"Choices list in mission screen has non-string value %@",[choiceKeys objectAtIndex:i]);
1992 choiceKeys = [choiceKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
1995 NSInteger keysCount = [choiceKeys count];
1996 if ((end_row + 1) < [choiceKeys
count]) {
1997 OOLogERR(
kOOLogException,
@"in mission.runScreen choices: number of choices defined (%i) is greater than available lines (%i). Check HUD settings for allowBigGui.", [choiceKeys
count], (end_row + 1));
1998 keysCount = end_row + 1;
2004 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
2006 OOGUIRow choicesRow = (end_row+1) - keysCount;
2007 NSEnumerator *choiceEnum =
nil;
2008 NSString *choiceKey =
nil;
2009 id choiceValue =
nil;
2010 NSString *choiceText =
nil;
2012 BOOL selectableRowExists = NO;
2013 NSUInteger firstSelectableRow = end_row;
2015 for (choiceEnum = [choiceKeys objectEnumerator]; (choiceKey = [choiceEnum nextObject]); )
2017 choiceValue = [choicesDict objectForKey:choiceKey];
2020 BOOL selectable = YES;
2021 if ([choiceValue isKindOfClass:[NSString
class]])
2023 choiceText = [NSString stringWithFormat:@" %@ ",(NSString*)choiceValue];
2025 else if ([choiceValue isKindOfClass:[NSDictionary
class]])
2027 NSDictionary *choiceOpts = (NSDictionary*)choiceValue;
2028 choiceText = [NSString stringWithFormat:@" %@ ",[choiceOpts oo_stringForKey:@"text"]];
2029 NSString *alignmentChoice = [choiceOpts oo_stringForKey:@"alignment" defaultValue:@"CENTER"];
2030 if ([alignmentChoice isEqualToString:
@"LEFT"])
2034 else if ([alignmentChoice isEqualToString:
@"RIGHT"])
2038 id colorDesc = [choiceOpts objectForKey:@"color"];
2039 if ([choiceOpts oo_boolForKey:
@"unselectable"])
2043 if (colorDesc !=
nil)
2047 else if (!selectable)
2057 choiceText = [
self replaceVariablesInString:choiceText];
2059 if (![choiceText isEqualToString:
@" "])
2071 if (selectable && !selectableRowExists)
2073 selectableRowExists = YES;
2074 firstSelectableRow = choicesRow;
2082 if (choicesRow > (end_row + 1))
break;
2085 if (!selectableRowExists)
2096 [
self resetMissionChoice];
2100- (void) resetMissionChoice
2102 [
self setMissionChoice:nil];
2106- (void) clearMissionScreen
2108 [
self setMissionOverlayDescriptor:nil];
2109 [
self setMissionBackgroundDescriptor:nil];
2110 [
self setMissionBackgroundSpecial:nil];
2111 [
self setMissionTitle:nil];
2112 [
self setMissionMusic:nil];
2113 [
self showShipModel:nil];
2117- (void) addMissionDestination:(NSString *)destinations
2123 for (j = 0; j < [tokens count]; j++)
2125 dest = [tokens oo_intAtIndex:j];
2126 if (dest < 0 || dest > 255)
2129 [
self addMissionDestinationMarker:[
self defaultMarker:dest]];
2134- (void) removeMissionDestination:(NSString *)destinations
2140 for (j = 0; j < [tokens count]; j++)
2142 dest = [[tokens objectAtIndex:j] intValue];
2143 if (dest < 0 || dest > 255)
continue;
2145 [
self removeMissionDestinationMarker:[
self defaultMarker:dest]];
2150- (void) showShipModel:(NSString *)role
2152 if ([role isEqualToString:
@"none"] || [role length] == 0)
2154 [UNIVERSE removeDemoShips];
2158 ShipEntity *ship = [UNIVERSE makeDemoShipWithRole:role spinning:YES];
2163- (void) setMissionMusic:(NSString *)value
2165 if ([value length] == 0 || [[value lowercaseString] isEqualToString:
@"none"])
2173- (NSString *) missionTitle
2175 return _missionTitle;
2179- (void) setMissionTitle:(NSString *)value
2181 if (_missionTitle != value)
2183 [_missionTitle release];
2184 _missionTitle = [value copy];
2189- (void) setMissionImage:(NSString *)value
2191 if ([value length] != 0 && ![[value lowercaseString] isEqualToString:
@"none"])
2193 [
self setMissionOverlayDescriptor:[NSDictionary dictionaryWithObject:value forKey:@"name"]];
2197 [
self setMissionOverlayDescriptor:nil];
2203- (void) setMissionBackground:(NSString *)value
2205 if ([value length] != 0 && ![[value lowercaseString] isEqualToString:
@"none"])
2207 [
self setMissionBackgroundDescriptor:[NSDictionary dictionaryWithObject:value forKey:@"name"]];
2211 [
self setMissionBackgroundDescriptor:nil];
2216- (void) setFuelLeak:(NSString *)value
2224 fuel_leak_rate = [value doubleValue];
2225 if (fuel_leak_rate > 0)
2227 [
self playFuelLeak];
2228 [UNIVERSE addMessage:DESC(@"danger-fuel-leak") forCount:6];
2234- (NSNumber *) fuelLeakRate_number
2236 return [NSNumber numberWithFloat:[
self fuelLeakRate]];
2240- (void) setSunNovaIn:(NSString *)time_value
2242 double time_until_nova = [time_value doubleValue];
2243 [[UNIVERSE sun] setGoingNova:YES inTime: time_until_nova];
2247- (void) launchFromStation
2250 if ([
UNIVERSE autoSave]) [UNIVERSE setAutoSaveNow:YES];
2251 if ([
self status] == STATUS_DOCKING) [
self setStatus:STATUS_DOCKED];
2252 [
self leaveDock:[
self dockedStation]];
2256- (void) blowUpStation
2260 mainStation = [UNIVERSE station];
2261 if (mainStation !=
nil)
2263 [UNIVERSE unMagicMainStation];
2269- (void) sendAllShipsAway
2273 int ent_count =
UNIVERSE->n_entities;
2275 Entity* my_entities[ent_count];
2277 for (i = 0; i < ent_count; i++)
2278 my_entities[i] = [uni_entities[i] retain];
2280 for (i = 1; i < ent_count; i++)
2282 Entity* e1 = my_entities[i];
2287 if (((e_class == CLASS_NEUTRAL)||(e_class == CLASS_POLICE)||(e_class == CLASS_MILITARY)||(e_class == CLASS_THARGOID)) &&
2288 ! ([se1 isStation] && [se1 maxFlightSpeed] == 0) &&
2289 [se1 hasHyperspaceMotor])
2293 [se1
setAITo:@"exitingTraderAI.plist"];
2302 for (i = 0; i < ent_count; i++)
2304 [my_entities[i] release];
2309- (OOPlanetEntity *) addPlanet: (NSString *)planetKey
2315 NSDictionary* dict = [[UNIVERSE systemManager] getPropertiesForSystemKey:planetKey];
2318 OOLog(
@"script.error.addPlanet.keyNotFound",
@"***** ERROR: could not find an entry in planetinfo.plist for '%@'", planetKey);
2324 OOPlanetEntity *planet = [[[OOPlanetEntity alloc] initFromDictionary:dict withAtmosphere:YES andSeed:[[UNIVERSE systemManager] getRandomSeedForCurrentSystem] forSystem:system_id] autorelease];
2326 Quaternion planetOrientation;
2329 [planet setOrientation:planetOrientation];
2332 if (![dict objectForKey:
@"position"])
2334 OOLog(
@"script.error.addPlanet.noPosition",
@"***** ERROR: you must specify a position for scripted planet '%@' before it can be created", planetKey);
2338 NSString *positionString = [dict objectForKey:@"position"];
2341 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);
2344 HPVector posn = [UNIVERSE coordinatesFromCoordinateSystemString:positionString];
2345 if (posn.x || posn.y || posn.z)
2347 OOLog(
kOOLogDebugAddPlanet,
@"planet position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2352 OOLog(
kOOLogDebugAddPlanet,
@"planet position (%.2f %.2f %.2f) derived from %@", posn.x, posn.y, posn.z, positionString);
2354 [planet setPosition: posn];
2356 [UNIVERSE addEntity:planet];
2361- (OOPlanetEntity *) addMoon: (NSString *)moonKey
2367 NSDictionary* dict = [[UNIVERSE systemManager] getPropertiesForSystemKey:moonKey];
2370 OOLog(
@"script.error.addPlanet.keyNotFound",
@"***** ERROR: could not find an entry in planetinfo.plist for '%@'", moonKey);
2375 OOPlanetEntity *planet = [[[OOPlanetEntity alloc] initFromDictionary:dict withAtmosphere:NO andSeed:[[UNIVERSE systemManager] getRandomSeedForCurrentSystem] forSystem:system_id] autorelease];
2377 Quaternion planetOrientation;
2380 [planet setOrientation:planetOrientation];
2383 if (![dict objectForKey:
@"position"])
2385 OOLog(
@"script.error.addPlanet.noPosition",
@"***** ERROR: you must specify a position for scripted moon '%@' before it can be created", moonKey);
2389 NSString *positionString = [dict objectForKey:@"position"];
2392 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);
2394 HPVector posn = [UNIVERSE coordinatesFromCoordinateSystemString:positionString];
2395 if (posn.x || posn.y || posn.z)
2404 [planet setPosition: posn];
2406 [UNIVERSE addEntity:planet];
2425- (void) debugMessage:(NSString *)args
2431- (void) playSound:(NSString *) soundName
2433 [
self playLegacyScriptSound:soundName];
2439- (void) doMissionCallback
2442 _missionWithCallback = NO;
2447- (void) clearMissionScreenID
2449 [_missionScreenID release];
2450 _missionScreenID =
nil;
2454- (void) setMissionScreenID:(NSString *)msid
2456 _missionScreenID = [msid retain];
2460- (NSString *) missionScreenID
2462 return _missionScreenID;
2466- (void) endMissionScreenAndNoteOpportunity
2468 _missionAllowInterrupt = NO;
2469 [
self clearMissionScreenID];
2471 if(![
self doWorldEventUntilMissionScreen:
OOJSID(
"missionScreenEnded")])
2474 [
self doWorldEventUntilMissionScreen:OOJSID("missionScreenOpportunity")];
2479- (void) setGuiToMissionScreen
2483 [
self setMissionBackgroundSpecial:nil];
2485 [
self setMissionExitScreen:GUI_SCREEN_STATUS];
2487 [
self setGuiToMissionScreenWithCallback:NO];
2491- (void) refreshMissionScreenTextEntry
2495 NSUInteger end_row = 21;
2496 if ([[
self hud] allowBigGui])
2501 [gui
setText:[NSString stringWithFormat:DESC(@"mission-screen-text-prompt-@"), [gameView
typedString]]
forRow:end_row
align:GUI_ALIGN_LEFT];
2510- (void) setGuiToMissionScreenWithCallback:(BOOL) callback
2514 NSUInteger end_row = 21;
2515 if ([[
self hud] allowBigGui])
2523 [gui
setTitle:[
self missionTitle] ?: DESC(@"mission-information")];
2525 if (!_missionTextEntry)
2534 [
self refreshMissionScreenTextEntry];
2539 NSDictionary *background_desc = [
self missionBackgroundDescriptorOrDefault];
2542 BOOL overridden = ([
self missionBackgroundDescriptor] !=
nil);
2553 gui_screen = GUI_SCREEN_MISSION;
2557 [lastTextKey release];
2564 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO];
2565 _missionWithCallback = callback;
2566 _missionAllowInterrupt = NO;
2567 [
self noteGUIDidChangeFrom:oldScreen to:gui_screen];
2572- (void) setBackgroundFromDescriptionsKey:(NSString*) d_key
2574 NSArray * items = (NSArray *)[[
UNIVERSE descriptions] objectForKey:d_key];
2579 [
self addScene: items atOffset: kZeroVector];
2581 [
self setShowDemoShips: YES];
2585- (void) addScene:(NSArray *)items atOffset:(Vector)off
2589 if (items ==
nil)
return;
2591 for (i = 0; i < [items count]; i++)
2593 id item = [items objectAtIndex:i];
2594 if ([item isKindOfClass:[NSString
class]])
2596 [
self processSceneString:item atOffset: off];
2598 else if ([item isKindOfClass:[NSArray
class]])
2600 [
self addScene:item atOffset: off];
2602 else if ([item isKindOfClass:[NSDictionary
class]])
2604 [
self processSceneDictionary:item atOffset: off];
2610- (BOOL) processSceneDictionary:(NSDictionary *) couplet atOffset:(Vector) off
2612 NSArray *conditions = [couplet objectForKey:@"conditions"];
2613 NSArray *actions =
nil;
2614 if ([couplet objectForKey:
@"do"])
2615 actions = [NSArray arrayWithObject: [couplet objectForKey:
@"do"]];
2616 NSArray *else_actions =
nil;
2617 if ([couplet objectForKey:
@"else"])
2618 else_actions = [NSArray arrayWithObject: [couplet objectForKey:
@"else"]];
2620 if (conditions ==
nil)
2622 OOLog(
@"script.scene.couplet.badConditions",
@"***** SCENE ERROR: %@ - conditions not %@, returning %@.", [couplet description],
@" found",
@"YES and performing 'do' actions");
2626 if (![conditions isKindOfClass:[NSArray
class]])
2628 OOLog(
@"script.scene.couplet.badConditions",
@"***** SCENE ERROR: %@ - conditions not %@, returning %@.", [conditions description],
@"an array",
@"NO");
2637 if ((success) && (actions) && [actions
count])
2638 [
self addScene: actions atOffset: off];
2641 if ((!success) && (else_actions) && [else_actions
count])
2642 [
self addScene: else_actions atOffset: off];
2648- (BOOL) processSceneString:(NSString*) item atOffset:(Vector) off
2658 NSString* i_key = [(NSString*)[i_info objectAtIndex:0] lowercaseString];
2665 if ([i_key isEqualToString:
@"scene"])
2667 if ([i_info
count] != 5)
2669 NSString* scene_key = (NSString*)[i_info objectAtIndex: 1];
2670 Vector scene_offset = {0};
2671 ScanVectorFromString([[i_info subarrayWithRange:NSMakeRange(2, 3)] componentsJoinedByString:
@" "], &scene_offset);
2672 scene_offset.x += off.
x; scene_offset.y += off.
y; scene_offset.z += off.z;
2673 NSArray * scene_items = (NSArray *)[[
UNIVERSE descriptions] objectForKey:scene_key];
2678 [
self addScene: scene_items atOffset: scene_offset];
2687 if ([i_key isEqualToString:
@"ship"]||[i_key isEqualToString:
@"model"]||[i_key isEqualToString:
@"role"])
2689 if ([i_info
count] != 10)
2696 if ([i_key isEqualToString:
@"ship"]||[i_key isEqualToString:
@"model"])
2698 ship = [UNIVERSE newShipWithName:[i_info oo_stringAtIndex: 1]];
2700 else if ([i_key isEqualToString:
@"role"])
2702 ship = [UNIVERSE newShipWithRole:[i_info oo_stringAtIndex: 1]];
2709 Vector model_offset = positionOffsetForShipInRotationToAlignment(ship, model_q, [i_info oo_stringAtIndex:9]);
2710 model_p0 = vector_add(model_p0, vector_subtract(off, model_offset));
2715 [UNIVERSE setMainLightPosition:(Vector){ DEMO_LIGHT_POSITION }];
2718 [UNIVERSE addEntity: ship];
2719 [ship
setStatus: STATUS_COCKPIT_DISPLAY];
2731 if ([i_key isEqualToString:
@"player"])
2733 if ([i_info
count] != 9)
2736 ShipEntity* doppelganger = [UNIVERSE newShipWithName:[
self shipDataKey]];
2742 Vector model_offset = positionOffsetForShipInRotationToAlignment( doppelganger, model_q, (NSString*)[i_info objectAtIndex:8]);
2743 model_p0.x += off.
x - model_offset.
x;
2744 model_p0.y += off.
y - model_offset.
y;
2745 model_p0.z += off.z - model_offset.z;
2749 [doppelganger
setPosition: vectorToHPVector(model_p0)];
2750 [UNIVERSE setMainLightPosition:(Vector){ DEMO_LIGHT_POSITION }];
2753 [UNIVERSE addEntity: doppelganger];
2754 [doppelganger
setStatus: STATUS_COCKPIT_DISPLAY];
2760 [doppelganger release];
2766 if ([i_key isEqualToString:
@"local-planet"] || [i_key isEqualToString:
@"target-planet"])
2768 if ([i_info
count] != 4)
2772 if (info_system_id & 8)
2774 _sysInfoLight = (info_system_id & 2) ? (Vector){ -10000.0, 4000.0, -10000.0 } : (Vector){ -12000.0, -5000.0, -10000.0 };
2778 _sysInfoLight = (info_system_id & 2) ? (Vector){ 6000.0, -5000.0, -10000.0 } : (Vector){ 6000.0, 4000.0, -10000.0 };
2781 [UNIVERSE setMainLightPosition:_sysInfoLight];
2784 OOPlanetEntity *originalPlanet =
nil;
2785 if ([i_key isEqualToString:
@"local-planet"])
2787 originalPlanet = [UNIVERSE planet];
2791 originalPlanet = [[[OOPlanetEntity alloc] initAsMainPlanetForSystem:info_system_id] autorelease];
2793 OOPlanetEntity *doppelganger = [originalPlanet miniatureVersion];
2794 if (doppelganger ==
nil)
return NO;
2797 OOPlanetEntity* doppelganger =
nil;
2798 NSMutableDictionary *planetInfo = [NSMutableDictionary dictionaryWithDictionary:[UNIVERSE generateSystemData:target_system_seed]];
2800 if ([i_key isEqualToString:
@"local-planet"] && [
UNIVERSE sun])
2802 OOPlanetEntity *mainPlanet = [UNIVERSE planet];
2803 OOTexture *texture = [mainPlanet texture];
2806 [planetInfo setObject:texture forKey:@"_oo_textureObject"];
2807 [planetInfo oo_setBool:[mainPlanet isExplicitlyTextured] forKey:@"_oo_isExplicitlyTextured"];
2808 [planetInfo oo_setBool:YES forKey:@"mainForLocalSystem"];
2813 doppelganger = [[OOPlanetEntity alloc] initFromDictionary:planetInfo withAtmosphere:YES andSeed:target_system_seed];
2814 [doppelganger miniaturize];
2815 [doppelganger autorelease];
2817 if (doppelganger ==
nil)
return NO;
2820 ScanVectorFromString([[i_info subarrayWithRange:NSMakeRange(1, 3)] componentsJoinedByString:
@" "], &model_p0);
2823 model_p0 = vector_multiply_scalar(model_p0, 1 - 0.5 * ((60 - [doppelganger radius]) / 60));
2825 model_p0 = vector_add(model_p0, off);
2831 Quaternion model_q = { 0.83, 0.12, 0.44, 0.0 };
2834 Quaternion model_q = { 0.833492, 0.333396, 0.440611, 0.0 };
2837 [doppelganger setOrientation: model_q];
2839 [doppelganger setPosition: vectorToHPVector(model_p0)];
2842 int deltaT = floor(fmod([
self clockTimeAdjusted], 86400));
2843 [doppelganger update: deltaT];
2844 [UNIVERSE addEntity:doppelganger];
2853- (BOOL) addEqScriptForKey:(NSString *)eq_key
2855 if (eq_key ==
nil)
return NO;
2859 OOLog(
@"player.equipmentScript",
@"Added equipment %@, with the following script property: '%@'.", eq_key, scriptName);
2861 if (scriptName ==
nil)
return NO;
2863 NSMutableDictionary *properties = [NSMutableDictionary dictionary];
2866 NSArray *eqScript =
nil;
2867 foreach (eqScript, eqScripts)
2869 NSString *key = [eqScript oo_stringAtIndex:0];
2870 if ([key isEqualToString: eq_key])
return NO;
2873 [properties setObject:self forKey:@"ship"];
2874 [properties setObject:eq_key forKey:@"equipmentKey"];
2876 if (s ==
nil)
return NO;
2878 OOLog(
@"player.equipmentScript",
@"Script '%@': installation %@successful.", scriptName,(s ==
nil ?
@"un" :
@""));
2880 [eqScripts addObject:[NSArray arrayWithObjects:eq_key,s,nil]];
2881 if (primedEquipment == [eqScripts
count] - 1) primedEquipment++;
2882 OOLog(
@"player.equipmentScript",
@"Scriptable equipment available: %lu.", [eqScripts
count]);
2887- (void) removeEqScriptForKey:(NSString *)eq_key
2889 if (eq_key ==
nil)
return;
2891 NSString *key =
nil;
2892 NSUInteger i,
count = [eqScripts count];
2894 for (i = 0; i <
count; i++)
2896 key = [[eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0];
2897 if ([key isEqualToString: eq_key])
2899 [eqScripts removeObjectAtIndex:i];
2901 if (i == primedEquipment) primedEquipment =
count;
2902 else if (i < primedEquipment) primedEquipment--;
2903 if (
count == primedEquipment) primedEquipment--;
2905 OOLog(
@"player.equipmentScript",
@"Removed equipment %@, with the following script property: '%@'.", eq_key, [[
OOEquipmentType equipmentTypeWithIdentifier:eq_key] scriptName]);
2911- (NSUInteger) eqScriptIndexForKey:(NSString *)eq_key
2913 NSUInteger i,
count = [eqScripts count];
2917 for (i = 0; i <
count; i++)
2919 NSString *key = [[eqScripts oo_arrayAtIndex:i] oo_stringAtIndex:0];
2920 if ([key isEqualToString: eq_key])
return i;
2928- (void) targetNearestHostile
2930 [
self scanForHostiles];
2931 Entity *ent = [
self foundTarget];
2934 ident_engaged = YES;
2936 [
self addTarget:ent];
2941- (void) targetNearestIncomingMissile
2943 [
self scanForNearestIncomingMissile];
2944 Entity *ent = [
self foundTarget];
2947 ident_engaged = YES;
2949 [
self addTarget:ent];
2954- (void) setGalacticHyperspaceBehaviourTo:(NSString *)galacticHyperspaceBehaviourString
2957 if (ghBehaviour == GALACTIC_HYPERSPACE_BEHAVIOUR_UNKNOWN)
2959 OOLog(
@"player.setGalacticHyperspaceBehaviour.invalidInput",
2960 @"setGalacticHyperspaceBehaviourTo: called with unknown behaviour %@.", galacticHyperspaceBehaviourString);
2962 [
self setGalacticHyperspaceBehaviour:ghBehaviour];
2966- (void) setGalacticHyperspaceFixedCoordsTo:(NSString *)galacticHyperspaceFixedCoordsString
2969 if ([coord_vals
count] < 2)
2971 OOLog(
@"player.setGalacticHyperspaceFixedCoords.invalidInput",
@"%@",
2972 @"setGalacticHyperspaceFixedCoords: called with bad specifier. Defaulting to Oolite standard.");
2973 galacticHyperspaceFixedCoords.x = galacticHyperspaceFixedCoords.y = 0x60;
2976 [
self setGalacticHyperspaceFixedCoordsX:[coord_vals oo_unsignedCharAtIndex:0]
2977 y:[coord_vals oo_unsignedCharAtIndex:1]];
2994 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,...)
BOOL ScanVectorAndQuaternionFromString(NSString *xyzwxyzString, Vector *outVector, Quaternion *outQuaternion)
NSMutableArray * ScanTokensFromString(NSString *values)
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)
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)