41#import "OOConstToJSString.h"
92#import "OOJSEngineTimeManagement.h"
99#ifdef OO_DEBUG_MONITOR_ENABLED
100static NSString*
const kOOLogEntityBehaviourChanged =
@"entity.behaviour.changed";
103#if MASS_DEPENDENT_FUEL_PRICES
106#define kMassCharge 0.65
107#define kBaseCharge (1.0 - kMassCharge)
109 GLfloat baseMass = [PLAYER baseMass];
111 if (myMass <= 0.0 || baseMass <= 0.0)
117 result = roundf(result * 100.0f) / 100.0f;
122 else if (result < 0.33f)
132@interface ShipEntity (Private)
141- (void)rescaleBy:(GLfloat)factor;
142- (void)rescaleBy:(GLfloat)factor writeToCache:(BOOL)writeToCache;
144- (BOOL)setUpOneSubentity:(NSDictionary*)subentDict;
145- (BOOL)setUpOneFlasher:(NSDictionary*)subentDict;
149- (void)addSubEntity:(
Entity<OOSubEntity>*)subent;
152- (
HPVector)coordinatesForEscortPosition:(
unsigned)idx;
154- (void)setUpOneEscort:(
ShipEntity*)escorter inGroup:(
OOShipGroup*)escortGroup withRole:(NSString*)escortRole atPosition:(
HPVector)ex_pos andCount:(uint8_t)currentEscortCount;
156- (void)addSubentityToCollisionRadius:(
Entity<OOSubEntity>*)subent;
157- (
ShipEntity*)launchPodWithCrew:(NSArray*)podCrew;
164- (void)noteFrustration:(NSString*)context;
190- (id)initWithKey:(NSString*)key definition:(NSDictionary*)dict
194 NSParameterAssert(dict !=
nil);
220 if (![
self setUpShipFromDictionary:dict]) {
227 OOLog(
@"ship.sanityCheck.failed",
@"Ship %@ %@ infinite top speed, clamped to 300.",
self,
@"generated with");
235- (BOOL)setUpFromDictionary:(NSDictionary*)shipDict
255 suppressAegisMessages = NO;
257 suppressExplosion = NO;
261 _scaleFactor = [
shipDict oo_floatForKey:@"model_scale_factor" defaultValue:1.0f];
263 float defaultSpeed = isStation ? 0.0f : 160.0f;
264 maxFlightSpeed = [
shipDict oo_floatForKey:@"max_flight_speed" defaultValue:defaultSpeed];
265 max_flight_roll = [
shipDict oo_floatForKey:@"max_flight_roll" defaultValue:2.0f];
266 max_flight_pitch = [
shipDict oo_floatForKey:@"max_flight_pitch" defaultValue:1.0f];
267 max_flight_yaw = [
shipDict oo_floatForKey:@"max_flight_yaw" defaultValue:max_flight_pitch];
268 cruiseSpeed = maxFlightSpeed * 0.8f;
270 max_thrust = [
shipDict oo_floatForKey:@"thrust" defaultValue:15.0f];
273 afterburner_rate = [
shipDict oo_floatForKey:@"injector_burn_rate" defaultValue:AFTERBURNER_BURNRATE];
274 afterburner_speed_factor = [
shipDict oo_floatForKey:@"injector_speed_factor" defaultValue:7.0f];
275 if (afterburner_speed_factor < 1.0) {
276 OOLog(
@"ship.setup.injectorSpeed",
@"injector_speed_factor cannot be lower than 1.0 for %@",
self);
277 afterburner_speed_factor = 1.0;
279#if OO_VARIABLE_TORUS_SPEED
281 OOLog(
@"ship.setup.injectorSpeed",
@"injector_speed_factor cannot be higher than minimum torus speed factor (%f) for %@.",
MIN_HYPERSPEED_FACTOR,
self);
286 OOLog(
@"ship.setup.injectorSpeed",
@"injector_speed_factor cannot be higher than torus speed factor (%f) for %@.",
HYPERSPEED_FACTOR,
self);
291 maxEnergy = [shipDict oo_floatForKey:@"max_energy" defaultValue:200.0f];
292 energy_recharge_rate = [shipDict oo_floatForKey:@"energy_recharge_rate" defaultValue:1.0f];
294 _showDamage = [shipDict oo_boolForKey:@"show_damage" defaultValue:(energy_recharge_rate > 0)];
296 [
self setThrowSparks:[shipDict oo_boolForKey:@"throw_sparks" defaultValue:NO]];
298 weapon_facings = [shipDict oo_intForKey:@"weapon_facings" defaultValue:VALID_WEAPON_FACINGS] &
VALID_WEAPON_FACINGS;
300 forward_weapon_type =
OOWeaponTypeFromString([shipDict oo_stringForKey:
@"forward_weapon_type" defaultValue:
@"EQ_WEAPON_NONE"]);
302 aft_weapon_type =
OOWeaponTypeFromString([shipDict oo_stringForKey:
@"aft_weapon_type" defaultValue:
@"EQ_WEAPON_NONE"]);
304 port_weapon_type =
OOWeaponTypeFromString([shipDict oo_stringForKey:
@"port_weapon_type" defaultValue:
@"EQ_WEAPON_NONE"]);
306 starboard_weapon_type =
OOWeaponTypeFromString([shipDict oo_stringForKey:
@"starboard_weapon_type" defaultValue:
@"EQ_WEAPON_NONE"]);
308 cloaking_device_active = NO;
309 military_jammer_active = NO;
310 cloakPassive = [shipDict oo_boolForKey:@"cloak_passive" defaultValue:YES];
311 cloakAutomatic = [shipDict oo_boolForKey:@"cloak_automatic" defaultValue:YES];
313 missiles = [shipDict oo_intForKey:@"missiles" defaultValue:0];
323 for (i = 0; i < missiles; i++) {
324 missile_list[i] =
nil;
326 max_missiles = [shipDict oo_intForKey:@"max_missiles" defaultValue:missiles];
329 if (missiles > max_missiles)
330 missiles = max_missiles;
331 missile_load_time = fmax(0.0, [shipDict oo_doubleForKey:
@"missile_load_time" defaultValue:0.0]);
332 missile_launch_time = [UNIVERSE getTime] + missile_load_time;
335 equipment_weight = 0;
336 if ([shipDict oo_fuzzyBooleanForKey:
@"has_ecm"])
337 [
self addEquipmentItem:@"EQ_ECM" inContext:@"npc"];
338 if ([shipDict oo_fuzzyBooleanForKey:
@"has_scoop"])
339 [
self addEquipmentItem:@"EQ_FUEL_SCOOPS" inContext:@"npc"];
340 if ([shipDict oo_fuzzyBooleanForKey:
@"has_escape_pod"])
341 [
self addEquipmentItem:@"EQ_ESCAPE_POD" inContext:@"npc"];
342 if ([shipDict oo_fuzzyBooleanForKey:
@"has_cloaking_device"])
343 [
self addEquipmentItem:@"EQ_CLOAKING_DEVICE" inContext:@"npc"];
344 if ([shipDict oo_floatForKey:
@"has_energy_bomb"] > 0) {
353 if ([shipDict oo_fuzzyBooleanForKey:
@"has_energy_bomb"]) {
357 [
self addEquipmentItem:@"EQ_QC_MINE" inContext:@"npc"];
361 if ([shipDict oo_fuzzyBooleanForKey:
@"has_fuel_injection"])
362 [
self addEquipmentItem:@"EQ_FUEL_INJECTION" inContext:@"npc"];
365 if ([shipDict oo_fuzzyBooleanForKey:
@"has_military_jammer"])
366 [
self addEquipmentItem:@"EQ_MILITARY_JAMMER" inContext:@"npc"];
367 if ([shipDict oo_fuzzyBooleanForKey:
@"has_military_scanner_filter"])
368 [
self addEquipmentItem:@"EQ_MILITARY_SCANNER_FILTER" inContext:@"npc"];
372 canFragment = [shipDict oo_fuzzyBooleanForKey:@"fragment_chance" defaultValue:0.9];
376 isFrangible = [shipDict oo_boolForKey:@"frangible" defaultValue:YES];
378 max_cargo = [shipDict oo_unsignedIntForKey:@"max_cargo"];
379 extra_cargo = [shipDict oo_unsignedIntForKey:@"extra_cargo" defaultValue:15];
381 hyperspaceMotorSpinTime = [shipDict oo_floatForKey:@"hyperspace_motor_spin_time" defaultValue:DEFAULT_HYPERSPACE_SPIN_TIME];
382 if (![shipDict oo_boolForKey:
@"hyperspace_motor" defaultValue:YES])
383 hyperspaceMotorSpinTime = -1;
386 name = [[shipDict oo_stringForKey:@"name" defaultValue:@"?"] copy];
388 [shipUniqueName autorelease];
389 shipUniqueName = [[shipDict oo_stringForKey:@"ship_name" defaultValue:@""] copy];
391 [shipClassName autorelease];
392 shipClassName = [[shipDict oo_stringForKey:@"ship_class_name" defaultValue:name] copy];
394 [displayName autorelease];
395 displayName = [[shipDict oo_stringForKey:@"display_name" defaultValue:nil] copy];
398 NSString* modelName = [shipDict oo_stringForKey:@"model"];
399 if (modelName !=
nil) {
403 cacheKey:[NSString stringWithFormat:@"%@-%.3f", _shipKey, _scaleFactor]
406 smooth:[shipDict oo_boolForKey:@"smooth" defaultValue:NO]
417 float density = [shipDict oo_floatForKey:@"density" defaultValue:1.0f];
419 mass = (GLfloat)(density * 20.0f * [octree volume]);
424 if (default_laser_color ==
nil) {
427 [
self setLaserColor:default_laser_color];
430 OORGBAComponents defaultExhaustEmissiveColorComponents;
431 defaultExhaustEmissiveColorComponents.
r = 0.7f;
432 defaultExhaustEmissiveColorComponents.
g = 0.9f;
433 defaultExhaustEmissiveColorComponents.
b = 1.0f;
434 defaultExhaustEmissiveColorComponents.
a = 0.9f;
438 [
self setExhaustEmissiveColor:color];
440 [
self clearSubEntities];
441 [
self setUpSubEntities];
446 BOOL hasTurrets = NO;
447 NSEnumerator* subEnum = [
self shipSubEntityEnumerator];
448 ShipEntity* se =
nil;
449 while (
isWeaponNone(weapon_type) && (se = [subEnum nextObject])) {
451 if (se->
behaviour == BEHAVIOUR_TRACK_AS_TURRET) {
463 [
self setWeaponDataFromType:weapon_type];
466 [
self setWeaponDataFromType:forward_weapon_type];
471 if ([shipDict objectForKey:
@"rotational_velocity"]) {
472 subentityRotationalVelocity = [shipDict oo_quaternionForKey:@"rotational_velocity"];
476 NSString* weaponMountMode = [shipDict oo_stringForKey:@"weapon_mount_mode" defaultValue:@"single"];
477 _multiplyWeapons = [weaponMountMode isEqualToString:@"multiply"];
478 forwardWeaponOffset = [[
self getWeaponOffsetFrom:shipDict withKey:@"weapon_position_forward" inMode:weaponMountMode] retain];
479 aftWeaponOffset = [[
self getWeaponOffsetFrom:shipDict withKey:@"weapon_position_aft" inMode:weaponMountMode] retain];
480 portWeaponOffset = [[
self getWeaponOffsetFrom:shipDict withKey:@"weapon_position_port" inMode:weaponMountMode] retain];
481 starboardWeaponOffset = [[
self getWeaponOffsetFrom:shipDict withKey:@"weapon_position_starboard" inMode:weaponMountMode] retain];
486 [
self setSunGlareFilter:[shipDict oo_floatForKey:@"sun_glare_filter" defaultValue:0.97f]];
489 scriptInfo = [[shipDict oo_dictionaryForKey:@"script_info" defaultValue:nil] retain];
491 explosionType = [[shipDict oo_arrayForKey:@"explosion_type" defaultValue:nil] retain];
500- (BOOL)setUpShipFromDictionary:(NSDictionary*)shipDict
504 if (![
self setUpFromDictionary:shipDict])
527 [scan_description autorelease];
532 if ([shipDict oo_fuzzyBooleanForKey:
@"has_shield_booster"])
534 if ([shipDict oo_fuzzyBooleanForKey:
@"has_shield_enhancer"])
553 scannerRange = [
shipDict oo_floatForKey:@"scanner_range" defaultValue:(float)SCANNER_MAX_RANGE];
564 [
self setAITo:[
shipDict oo_stringForKey:@"ai_type" defaultValue:@"nullAI.plist"]];
571 NSString* cargoString = [
shipDict oo_stringForKey:@"cargo_carried"];
572 if (cargoString !=
nil) {
573 if ([cargoString isEqualToString:
@"SCARCE_GOODS"]) {
575 }
else if ([cargoString isEqualToString:
@"PLENTIFUL_GOODS"]) {
582 NSScanner* scanner = [
NSScanner scannerWithString:cargoString];
583 if ([scanner scanInt:&c_amount]) {
585 c_commodity = [[
scanner string] substringFromIndex:[
scanner scanLocation]];
586 if ([[
UNIVERSE commodities] goodDefined:c_commodity]) {
589 c_commodity = [[UNIVERSE commodities] goodNamed:c_commodity];
590 if ([[
UNIVERSE commodities] goodDefined:c_commodity]) {
596 c_commodity = [
shipDict oo_stringForKey:@"cargo_carried"];
597 if ([[
UNIVERSE commodities] goodDefined:c_commodity]) {
600 c_commodity = [[UNIVERSE commodities] goodNamed:c_commodity];
601 if ([[
UNIVERSE commodities] goodDefined:c_commodity]) {
609 cargoString = [
shipDict oo_stringForKey:@"cargo_type"];
628 [primaryRole release];
644 for (i = 0, j = 0; i <
missiles; i++) {
666 if (accuracy < -5.0f || accuracy > 10.0f) {
705 NSDictionary* cdict = [[UNIVERSE characters] objectForKey:[
shipDict oo_stringForKey:@"pilot"]];
717 reactionTime = [
shipDict oo_floatForKey:@"reaction_time" defaultValue:COMBAT_AI_STANDARD_REACTION_TIME];
724- (void)setSubIdx:(NSUInteger)value
739- (NSString*)repeatString:(NSString*)str times:(NSUInteger)times
746 for (NSUInteger i = 0; i < times; i++) {
747 [
result appendString:str];
756 NSEnumerator* subEnum =
nil;
758 NSUInteger diff, i = 0;
764 [
result appendString:@"1"];
771- (void)deserializeShipSubEntitiesFrom:(NSString*)string
774 NSInteger i, idx, start = [
subEnts count] - 1;
775 NSInteger strMaxIdx = [
string length] - 1;
779 for (i = start; i >= 0; i--) {
782 if (idx <= strMaxIdx && [[
string substringWithRange:NSMakeRange(idx, 1)] isEqualToString:
@"0"]) {
796 NSArray* plumes = [
shipDict oo_arrayForKey:@"exhaust"];
801 for (i = 0; i < [
plumes count]; i++) {
807 NSArray* subs = [
shipDict oo_arrayForKey:@"subentities"];
811 for (i = 0; i < [
subs count]; i++) {
825 NSEnumerator* exEnum =
nil;
835- (BOOL)setUpOneSubentity:(NSDictionary*)subentDict
839 NSString* type =
nil;
842 if ([type isEqualToString:
@"flasher"]) {
851- (BOOL)setUpOneFlasher:(NSDictionary*)subentDict
860- (BOOL)setUpOneStandardSubentity:(NSDictionary*)subentDict asTurret:(BOOL)asTurret
863 NSString* subentKey =
nil;
867 subentKey = [
subentDict oo_stringForKey:@"subentity_key"];
868 if (subentKey ==
nil) {
869 OOLog(
@"setup.ship.badEntry.subentities",
@"Failed to set up entity - no subentKey in %@", subentDict);
873 if (!asTurret && [
self isStation] && [subentDict oo_boolForKey:
@"is_dock"]) {
874 subentity = [UNIVERSE newDockWithName:subentKey andScaleFactor:_scaleFactor];
876 subentity = [UNIVERSE newSubentityWithName:subentKey andScaleFactor:_scaleFactor];
878 if (subentity ==
nil) {
879 OOLog(
@"setup.ship.badEntry.subentities",
@"Failed to set up entity %@", subentKey);
884 subOrientation = [
subentDict oo_quaternionForKey:@"orientation"];
913 if (!asTurret && [
self isStation] && [subentDict oo_boolForKey:
@"is_dock"]) {
914 BOOL allow_docking = [
subentDict oo_boolForKey:@"allow_docking" defaultValue:YES];
915 BOOL ddc = [
subentDict oo_boolForKey:@"disallowed_docking_collides" defaultValue:NO];
916 BOOL allow_launching = [
subentDict oo_boolForKey:@"allow_launching" defaultValue:YES];
918 BOOL virtual_dock = [
subentDict oo_boolForKey:@"_is_virtual_dock" defaultValue:NO];
934 return [[
self primaryRole] isEqualToString:@"oolite-template-cargopod"];
937- (void)setUpCargoType:(NSString*)cargoString
1068 [subEntities makeObjectsPerformSelector:@selector(setOwner:) withObject:nil];
1069 [subEntities release];
1075 float density = [[
self shipInfoDictionary] oo_floatForKey:@"density" defaultValue:1.0f];
1096 NSString* subtype =
nil;
1097 if ([
self behaviour] == BEHAVIOUR_TRACK_AS_TURRET)
1098 subtype =
@"(turret)";
1100 subtype =
@"(subentity)";
1102 return [
NSString stringWithFormat:@"\"%@\" position: %@ %@", [
self name], HPVectorDescription([
self position]), subtype];
1108 return [
NSString stringWithFormat:@"\"%@\"", [
self name]];
1116- (void)setSunGlareFilter:(GLfloat)newValue
1126- (void)setAccuracy:(GLfloat)new_accuracy
1128 if (new_accuracy < 0.0f &&
scanClass == CLASS_MISSILE) {
1130 }
else if (new_accuracy < -5.0f) {
1131 new_accuracy = -5.0;
1132 }
else if (new_accuracy > 10.0f) {
1133 new_accuracy = 10.0;
1184- (void)setScriptedMisjump:(BOOL)newValue
1194- (void)setScriptedMisjumpRange:(GLfloat)newValue
1201 return [[subEntities copy] autorelease];
1206 return [subEntities count];
1209- (BOOL)hasSubEntity:(
Entity<OOSubEntity>*)sub
1211 return [subEntities containsObject:sub];
1221 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isShip)];
1226 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isFlasher)];
1231 return [[
self subEntities] objectEnumeratorFilteredWithSelector:@selector(isExhaust)];
1257 if (![
self hasSubEntity:sub]) {
1258 OOLog(
@"ship.subentity.sanityCheck.failed.details",
@"Attempt to set subentity taking damage of %@ to %@, which is not a subentity.", [
self shortDescription], sub);
1260 }
else if (![sub
isShip]) {
1261 OOLog(
@"ship.subentity.sanityCheck.failed",
@"Attempt to set subentity taking damage of %@ to %@, which is not a ship.", [
self shortDescription], sub);
1334 hitEntity[0] =
self;
1337 NSEnumerator* subEnum =
nil;
1347 GLfloat hitSub = [
se->octree isHitByLine:w0 v1:w1];
1348 if (hitSub && (hit_distance == 0 || hit_distance > hitSub)) {
1349 hit_distance = hitSub;
1356 return hit_distance;
1390 [subEntities makeObjectsPerformSelector:@selector(wasAddedToUniverse)];
1397 [subEntities makeObjectsPerformSelector:@selector(wasRemovedFromUniverse)];
1410- (void)setBeaconCode:(NSString*)bcode
1412 if ([bcode length] == 0)
1416 [_beaconCode release];
1432- (void)setBeaconLabel:(NSString*)blabel
1434 if ([blabel length] == 0)
1438 [_beaconLabel release];
1457 NSUInteger length = [beaconCode length];
1460 NSArray* iconData = [[UNIVERSE descriptions] oo_arrayForKey:beaconCode];
1461 if (iconData !=
nil)
1486- (void)setPrevBeacon:(
Entity<OOBeaconEntity>*)beaconShip
1494- (void)setNextBeacon:(
Entity<OOBeaconEntity>*)beaconShip
1502#define kBoulderRole (@"boulder")
1504- (void)setIsBoulder:(BOOL)flag
1519 if ([
self hasRole:
@"asteroid"] || [
self isBoulder]) {
1538 OOLogWARN(
@"ship.setUp.escortShipCircularReference",
1539 @"Ship %@ requested escorts, when it is an escort ship itself. Avoiding possible circular reference overflow by ignoring escort setup.",
self);
1548 NSString* defaultRole =
@"escort";
1549 NSString* escortRole =
nil;
1550 NSString* escortShipKey =
nil;
1556 if ([
self hasPrimaryRole:
@"police"] || [
self hasPrimaryRole:
@"hunter"]) {
1565 defaultRole =
@"wingman";
1567 escortRole = [shipinfoDictionary oo_stringForKey:@"escort_role" defaultValue:nil];
1568 if (escortRole ==
nil)
1569 escortRole = [shipinfoDictionary oo_stringForKey:@"escort-role" defaultValue:defaultRole];
1570 if (![escortRole isEqualToString:defaultRole]) {
1571 if (![[
UNIVERSE newShipWithRole:escortRole] autorelease]) {
1572 escortRole = defaultRole;
1576 escortShipKey = [shipinfoDictionary oo_stringForKey:@"escort_ship" defaultValue:nil];
1577 if (escortShipKey ==
nil)
1578 escortShipKey = [shipinfoDictionary oo_stringForKey:@"escort-ship"];
1580 if (escortShipKey !=
nil) {
1581 if (![[
UNIVERSE newShipWithName:escortShipKey] autorelease]) {
1582 escortShipKey =
nil;
1584 escortRole = [
NSString stringWithFormat:@"[%@]", escortShipKey];
1604 escorter = [UNIVERSE newShipWithRole:escortRole];
1606 if (escorter ==
nil)
1621 NSArray* escortRoles = [
shipinfoDictionary oo_arrayForKey:@"escort_roles" defaultValue:nil];
1622 if (escortRoles ==
nil) {
1623 OOLogWARN(
@"eship.setUp.escortShipRoles",
1624 @"Ship %@ has bad escort_roles definition.",
self);
1627 NSDictionary* escortDefinition =
nil;
1628 NSDictionary* systeminfo =
nil;
1631 systeminfo = [UNIVERSE currentSystemData];
1632 government = [
systeminfo oo_unsignedCharForKey:KEY_GOVERNMENT];
1635 if ([
self group] ==
nil) {
1644 _maxEscortCount = 0;
1646 foreach (escortDefinition, escortRoles) {
1654 NSString* escortRole = [
escortDefinition oo_stringForKey:@"role" defaultValue:@"escort"];
1655 int8_t desired = max;
1656 if (min < desired) {
1657 for (i = min; i < max; i++) {
1658 if (
Ranrot() % 11 < government + 2) {
1663 for (i = 0; i < desired; i++) {
1667 if (![escortRole isEqualToString:
@""]) {
1669 ShipEntity* escorter = [UNIVERSE newShipWithRole:escortRole];
1670 if (escorter ==
nil) {
1676 currentEscortCount++;
1681 _pendingEscortCount = 0;
1684- (void)setUpOneEscort:(
ShipEntity*)escorter inGroup:(
OOShipGroup*)escortGroup withRole:(NSString*)escortRole atPosition:(
HPVector)ex_pos andCount:(uint8_t)currentEscortCount
1686 NSString* autoAI =
nil;
1687 NSString* pilotRole =
nil;
1688 NSDictionary* autoAIMap =
nil;
1689 NSDictionary* escortShipDict =
nil;
1691 NSString* defaultRole =
@"escort";
1693 if ([
self isPolice]) {
1694 defaultRole =
@"wingman";
1695 pilotRole =
@"police";
1697 pilotRole = bounty ?
@"pirate" :
@"hunter";
1704 ex_pos.
x += dd * 6.0 * (
randf() - 0.5);
1705 ex_pos.
y += dd * 6.0 * (
randf() - 0.5);
1706 ex_pos.
z += dd * 6.0 * (
randf() - 0.5);
1709 ex_pos.
x += dd * 12.0 * (
randf() - 0.5);
1710 ex_pos.
y += dd * 12.0 * (
randf() - 0.5);
1711 ex_pos.
z += dd * 12.0 * (
randf() - 0.5);
1716 if ([escorter crew] ==
nil) {
1723 if (scanClass == CLASS_NOT_SET) {
1724 scanClass = CLASS_NEUTRAL;
1728 if ([
self bounty] == 0)
1734 autoAI = [
autoAIMap oo_stringForKey:defaultRole];
1737 autoAI = [
autoAIMap oo_stringForKey:@"escort" defaultValue:@"nullAI.plist"];
1743 if ((escortRole && [escortShipDict oo_fuzzyBooleanForKey:
@"auto_ai" defaultValue:YES])
1744 || ([[escortAI name] isEqualToString:
@"nullAI.plist"] && ![autoAI isEqualToString:
@"nullAI.plist"])) {
1751 if ([
self status] == STATUS_DOCKED) {
1752 [[
self owner] addShipToLaunchQueue:escorter withPriority:NO];
1754 [UNIVERSE addEntity:escorter];
1759 if ([escorter heatInsulation] < [
self heatInsulation])
1761 if (([escorter maxFlightSpeed] < cruiseSpeed) && ([escorter maxFlightSpeed] > cruiseSpeed * 0.3))
1784- (void)setShipDataKey:(NSString*)key
1795#define MAKE_VECTOR_ARRAY(v) [[[OONativeVector alloc] initWithVector:v] autorelease]
1797- (NSArray*)getWeaponOffsetFrom:(NSDictionary*)dict withKey:(NSString*)key inMode:(NSString*)mode
1800 if ([
mode isEqualToString:
@"single"]) {
1802 return [
NSArray arrayWithObject:MAKE_VECTOR_ARRAY(offset)];
1804 NSArray* offsets = [
dict oo_arrayForKey:key defaultValue:nil];
1805 if (offsets ==
nil) {
1807 return [
NSArray arrayWithObject:MAKE_VECTOR_ARRAY(offset)];
1811 for (i = 0; i < [
offsets count]; i++) {
1813 [
output addObject:MAKE_VECTOR_ARRAY(offset)];
1815 return [
NSArray arrayWithArray:output];
1852 return CLASS_NO_DRAW;
1861 if (
status == STATUS_COCKPIT_DISPLAY ||
status == STATUS_DEAD ||
status == STATUS_BEING_SCOOPED) {
1897 withOrigin:relative_position_of_other
1898 andIJK:relative_ijk_of_other]) {
1906 for (i = 0; i < n_subs; i++) {
1917 for (i = 0; i < n_subs; i++) {
1925 if ((prime_subs) && (other_subs)) {
1927 for (i = 0; i < n_osubs; i++) {
1931 for (j = 0; j < n_psubs; j++) {
1944- (BOOL)checkCloseCollisionWith:(
Entity*)other
1955 if ([
self canScoop:otherShip])
1963 NSString* other_key = [
NSString stringWithFormat:@"%d", otherID];
1969 [closeContactsInfo setObject:[
NSString stringWithFormat:@"%f %f %f", rpos.x, rpos.y, rpos.z] forKey:other_key];
1991 if (otherShip !=
nil) {
2014 while ((father) && (father != last) && (father !=
NO_TARGET)) {
2028- (void)addSubentityToCollisionRadius:(
Entity<OOSubEntity>*)subent
2034 if ([subent isKindOfClass:[
ShipEntity class]])
2051 pod = [UNIVERSE newShipWithRole:[
shipinfoDictionary oo_stringForKey:@"escape_pod_role"]];
2054 pod = [UNIVERSE newShipWithRole:[
shipinfoDictionary oo_stringForKey:@"escape_pod_model" defaultValue:@"escape-capsule"]];
2056 pod = [UNIVERSE newShipWithRole:@"escape-capsule"];
2057 OOLog(
@"shipEntity.noEscapePod",
@"Ship %@ has no correct escape_pod_role defined. Now using default capsule.",
self);
2077 OOLog(
@"shipEntity.notDict",
@"Ship %@ was not set up from dictionary.",
self);
2086 OOLog(
@"shipEntity.notDict",
@"Ship %@ was not set up from dictionary.",
self);
2087 [UNIVERSE removeEntity:
self];
2092 OOLog(
@"ship.sanityCheck.failed",
@"Ship %@ %@ infinite top speed, clamped to 300.",
self,
@"had");
2106 [
self setOrientation:quaternion_multiply(q2, quaternion_multiply(q1, demoStartOrientation))];
2128 OOLog(
@"ship.sanityCheck.failed",
@"Ship %@ %@ with scanClass CLASS_NOT_SET; forced to CLASS_NEUTRAL.",
self, [
self primaryRole]);
2148 if ((target) && ([target
scanClass] == CLASS_POLICE)) {
2156 NSString* other_key =
nil;
2160 NSDictionary* closeContactsTemp = [[
NSDictionary alloc] initWithDictionary:closeContactsInfo];
2164 if ((other !=
nil) && (other->
isShip)) {
2170 Vector pos0 = { 0, 0, 0 };
2175 if ((pos0.
x < 0.0) && (pos1.
x > 0.0)) {
2178 if ((pos0.
x > 0.0) && (pos1.
x < 0.0)) {
2181 if ((pos0.
y < 0.0) && (pos1.
y > 0.0)) {
2184 if ((pos0.
y > 0.0) && (pos1.
y < 0.0)) {
2187 if ((pos0.
z < 0.0) && (pos1.
z > 0.0)) {
2190 if ((pos0.
z > 0.0) && (pos1.
z < 0.0)) {
2194 [closeContactsInfo removeObjectForKey:other_key];
2197 [closeContactsInfo removeObjectForKey:other_key];
2205#ifdef OO_DEBUG_MONITOR_ENABLED
2232 double external_temp = 0.0;
2238 double alt1 = sun_cr * sun_cr / sun_zd;
2241 external_temp *= 100;
2340 [PLAYER setScriptTarget:
self];
2342 if ([
self status] != STATUS_DEAD)
2343 [PLAYER doScriptEvent:OOJSID("shipSpawned") withArgument:
self];
2355 if ([
self status] == STATUS_LAUNCHING) {
2358 StationEntity* stationLaunchedFrom = [UNIVERSE nearestEntityMatchingPredicate:IsStationPredicate parameter:NULL relativeToEntity:
self];
2395 if ([
self status] == STATUS_BEING_SCOOPED) {
2407 if ([
self status] == STATUS_COCKPIT_DISPLAY) {
2411 if ((range2 > 1.0) || (
velocity.z > 0.0))
2440 OOLog(
@"ship.sanityCheck.failed",
@"Ship %@ escorting %@ with wrong scanclass!",
self, leader);
2451 qf.
w *= (1.0 - delta_t);
2487 BOOL applyThrust = YES;
2489 case BEHAVIOUR_TUMBLE:
2493 case BEHAVIOUR_STOP_STILL:
2494 case BEHAVIOUR_STATION_KEEPING:
2498 case BEHAVIOUR_IDLE:
2505 case BEHAVIOUR_TRACTORED:
2509 case BEHAVIOUR_TRACK_TARGET:
2513 case BEHAVIOUR_INTERCEPT_TARGET:
2514 case BEHAVIOUR_COLLECT_TARGET:
2518 case BEHAVIOUR_ATTACK_TARGET:
2522 case BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX:
2523 case BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE:
2527 case BEHAVIOUR_ATTACK_MINING_TARGET:
2531 case BEHAVIOUR_ATTACK_FLY_TO_TARGET:
2535 case BEHAVIOUR_ATTACK_FLY_FROM_TARGET:
2539 case BEHAVIOUR_ATTACK_BREAK_OFF_TARGET:
2543 case BEHAVIOUR_ATTACK_SLOW_DOGFIGHT:
2547 case BEHAVIOUR_RUNNING_DEFENSE:
2551 case BEHAVIOUR_ATTACK_BROADSIDE:
2555 case BEHAVIOUR_ATTACK_BROADSIDE_LEFT:
2559 case BEHAVIOUR_ATTACK_BROADSIDE_RIGHT:
2563 case BEHAVIOUR_CLOSE_TO_BROADSIDE_RANGE:
2567 case BEHAVIOUR_CLOSE_WITH_TARGET:
2571 case BEHAVIOUR_ATTACK_SNIPER:
2575 case BEHAVIOUR_EVASIVE_ACTION:
2576 case BEHAVIOUR_FLEE_EVASIVE_ACTION:
2580 case BEHAVIOUR_FLEE_TARGET:
2584 case BEHAVIOUR_FLY_RANGE_FROM_DESTINATION:
2588 case BEHAVIOUR_FACE_DESTINATION:
2592 case BEHAVIOUR_LAND_ON_PLANET:
2596 case BEHAVIOUR_FORMATION_FORM_UP:
2600 case BEHAVIOUR_FLY_TO_DESTINATION:
2604 case BEHAVIOUR_FLY_FROM_DESTINATION:
2605 case BEHAVIOUR_FORMATION_BREAK:
2609 case BEHAVIOUR_AVOID_COLLISION:
2613 case BEHAVIOUR_TRACK_AS_TURRET:
2618 case BEHAVIOUR_FLY_THRU_NAVPOINTS:
2622 case BEHAVIOUR_SCRIPTED_AI:
2623 case BEHAVIOUR_SCRIPTED_ATTACK_AI:
2627 case BEHAVIOUR_ENERGY_BOMB_COUNTDOWN:
2641- (void)noteFrustration:(NSString*)context
2643 [
shipAI reactToMessage:@"FRUSTRATED" context:context];
2651 if ([other isKindOfClass:[
ShipEntity class]]) {
2675 if (hunter == groupLeader) {
2699- (BOOL)hasOneEquipmentItem:(NSString*)itemKey includeWeapons:(BOOL)includeWeapons whileLoading:(BOOL)loading
2701 if ([
self hasOneEquipmentItem:itemKey includeMissiles:includeWeapons whileLoading:loading])
2705 NSString* damaged = [
itemKey stringByAppendingString:@"_DAMAGED"];
2710 if (includeWeapons) {
2714 if ([
self hasPrimaryWeapon:weaponType])
2722- (BOOL)hasOneEquipmentItem:(NSString*)itemKey includeMissiles:(BOOL)includeMissiles whileLoading:(BOOL)loading
2728 NSString* damaged = [
itemKey stringByAppendingString:@"_DAMAGED"];
2733 if (includeMissiles &&
missiles > 0) {
2735 if ([itemKey isEqualToString:
@"thargon"])
2736 itemKey =
@"EQ_THARGON";
2748 NSEnumerator* subEntEnum =
nil;
2752 [[
aft_weapon_type identifier] isEqualToString:[weaponType identifier]] ||
2759 if ([subEntity hasPrimaryWeapon:weaponType])
2766- (NSUInteger)countEquipmentItem:(NSString*)eqkey
2769 NSUInteger
count = 0;
2771 if ([eqkey isEqualToString:eq]) {
2778- (BOOL)hasEquipmentItem:(
id)equipmentKeys includeWeapons:(BOOL)includeWeapons whileLoading:(BOOL)loading
2781 if ([equipmentKeys isKindOfClass:[NSString
class]]) {
2784 NSParameterAssert([equipmentKeys isKindOfClass:[NSArray
class]] || [equipmentKeys isKindOfClass:[NSSet
class]]);
2787 foreach (key, equipmentKeys) {
2788 if ([
self hasOneEquipmentItem:key includeWeapons:includeWeapons whileLoading:loading])
2796- (BOOL)hasEquipmentItem:(
id)equipmentKeys
2803- (BOOL)hasEquipmentItemProviding:(NSString*)equipmentType
2805 NSString* key =
nil;
2807 if ([key isEqualToString:equipmentType]) {
2812 if (et !=
nil && [et provides:equipmentType]) {
2820- (NSString*)equipmentItemProviding:(NSString*)equipmentType
2822 NSString* key =
nil;
2824 if ([key isEqualToString:equipmentType]) {
2826 return [[
key copy] autorelease];
2829 if (et !=
nil && [et provides:equipmentType]) {
2830 return [[
key copy] autorelease];
2837- (BOOL)hasAllEquipment:(
id)equipmentKeys includeWeapons:(BOOL)includeWeapons whileLoading:(BOOL)loading
2839 NSEnumerator* keyEnum =
nil;
2846 if ([equipmentKeys isKindOfClass:[NSString
class]])
2847 equipmentKeys = [
NSArray arrayWithObject:equipmentKeys];
2848 else if (![equipmentKeys isKindOfClass:[NSArray
class]] && ![equipmentKeys isKindOfClass:[NSSet
class]])
2851 for (keyEnum = [equipmentKeys objectEnumerator]; (key = [
keyEnum nextObject]);) {
2852 if (![
self hasOneEquipmentItem:key includeWeapons:includeWeapons whileLoading:loading])
2859- (BOOL)hasAllEquipment:(
id)equipmentKeys
2874- (void)setHyperspaceSpinTime:(
float)new
2879- (BOOL)canAddEquipment:(NSString*)equipmentKey inContext:(NSString*)context
2881 if ([equipmentKey hasSuffix:
@"_DAMAGED"]) {
2885 NSString* lcEquipmentKey = [
equipmentKey lowercaseString];
2886 if ([equipmentKey hasSuffix:
@"MISSILE"] || [equipmentKey hasSuffix:
@"MINE"] || ([
self isThargoid] && ([lcEquipmentKey hasPrefix:
@"thargon"] || [lcEquipmentKey hasSuffix:
@"thargon"]))) {
2893 if (![eqType canCarryMultiple] && [
self hasEquipmentItem:equipmentKey])
2895 if (![
self equipmentValidToAdd:equipmentKey inContext:context])
2918 while (
isWeaponNone(weaponType) && (subEntity = [subEntEnum nextObject])) {
2986 NSArray* itemInfo = [
NSArray arrayWithObjects:@"100", @"100000", @"Missile", role, @"Unidentified missile type.",
2987 [
NSDictionary dictionaryWithObjectsAndKeys:@"true", @"is_external_store", nil], nil];
3000 foreach (eqType, eqTypes) {
3002 if ([eqType canCarryMultiple]) {
3003 NSString* damagedIdentifier = [[
eqType identifier] stringByAppendingString:@"_DAMAGED"];
3004 NSUInteger i,
count = 0;
3007 for (i = 0; i <
count; i++) {
3008 [
quip addObject:eqType];
3012 if ([
self hasEquipmentItem:[eqType identifier]] || isDamaged) {
3013 [
quip addObject:eqType];
3022 [
quip addObject:eqType];
3025 return [[
quip copy] autorelease];
3028- (BOOL)equipmentValidToAdd:(NSString*)equipmentKey inContext:(NSString*)context
3033- (BOOL)equipmentValidToAdd:(NSString*)equipmentKey whileLoading:(BOOL)loading inContext:(NSString*)context
3036 BOOL validationForDamagedEquipment = NO;
3038 if ([equipmentKey hasSuffix:
@"_DAMAGED"]) {
3051 if ([
self hasEquipmentItem:[eqType damagedIdentifier]]) {
3052 validationForDamagedEquipment = YES;
3059 if ([eqType requiresMountedPylon] && [
self missileCount] == 0 && !loading)
3061 if ([
self availableCargoSpace] < [eqType requiredCargoSpace] && !validationForDamagedEquipment && !loading)
3063 if ([eqType requiresEquipment] !=
nil && ![
self hasAllEquipment:[eqType requiresEquipment] includeWeapons:YES whileLoading:loading])
3065 if ([eqType requiresAnyEquipment] !=
nil && ![
self hasEquipmentItem:[eqType requiresAnyEquipment] includeWeapons:YES whileLoading:loading])
3067 if ([eqType incompatibleEquipment] !=
nil && [
self hasEquipmentItem:[eqType incompatibleEquipment] includeWeapons:YES whileLoading:loading])
3069 if ([eqType requiresCleanLegalRecord] && [
self legalStatus] != 0 && !loading)
3071 if ([eqType requiresNonCleanLegalRecord] && [
self legalStatus] == 0 && !loading)
3075 if ([eqType requiresFullFuel] && [
self fuel] < [
self fuelCapacity] && !loading)
3077 if ([eqType requiresNonFullFuel] && [
self fuel] >= [
self fuelCapacity] && !loading)
3082 if (condition_script !=
nil) {
3083 OOJSScript* condScript = [UNIVERSE getConditionScript:condition_script];
3084 if (condScript !=
nil)
3088 BOOL allow_addition = NO;
3095 count:sizeof args / sizeof *args
3107 if (OK && !allow_addition) {
3118 if (![eqType isAvailableToPlayer])
3120 if (![eqType isAvailableToAll]) {
3125 [
options addObjectsFromArray:[[
shipyardInfo oo_dictionaryForKey:KEY_STANDARD_EQUIPMENT] oo_arrayForKey:KEY_EQUIPMENT_EXTRAS]];
3126 if (![options containsObject:equipmentKey])
3130 if (![eqType isAvailableToNPCs])
3169- (BOOL)addEquipmentItem:(NSString*)equipmentKey inContext:(NSString*)context
3174- (BOOL)addEquipmentItem:(NSString*)equipmentKey withValidation:(BOOL)validateAddition inContext:(NSString*)context
3177 NSString* lcEquipmentKey = [
equipmentKey lowercaseString];
3178 NSString* damagedKey;
3180 BOOL isRepairedEquipment = NO;
3182 if ([lcEquipmentKey isEqualToString:
@"thargon"])
3183 equipmentKey =
@"EQ_THARGON";
3186 if (validateAddition == YES && ![
self canAddEquipment:equipmentKey inContext:context])
3189 if ([equipmentKey hasSuffix:
@"_DAMAGED"]) {
3194 if (![eqType canCarryMultiple]) {
3195 damagedKey = [
equipmentKey stringByAppendingString:@"_DAMAGED"];
3196 if ([
_equipment containsObject:damagedKey]) {
3197 [_equipment removeObject:damagedKey];
3198 isRepairedEquipment = YES;
3208 if ([eqType isMissileOrMine] || ([
self isThargoid] && isEqThargon)) {
3222 if ([equipmentKey hasPrefix:
@"EQ_WEAPON"] && ![equipmentKey hasSuffix:
@"_DAMAGED"]) {
3230 if (![equipmentKey isEqualToString:
@"EQ_PASSENGER_BERTH"] && !isRepairedEquipment) {
3241 if ([equipmentKey isEqual:
@"EQ_CARGO_BAY"]) {
3243 }
else if ([equipmentKey isEqualToString:
@"EQ_SHIELD_BOOSTER"]) {
3246 if ([equipmentKey isEqualToString:
@"EQ_SHIELD_ENHANCER"]) {
3252 [_equipment addObject:equipmentKey];
3259 return [_equipment objectEnumerator];
3264 return [_equipment count];
3267- (void)removeEquipmentItem:(NSString*)equipmentKey
3269 NSString* equipmentTypeCheckKey = equipmentKey;
3270 NSString* lcEquipmentKey = [
equipmentKey lowercaseString];
3271 NSUInteger equipmentIndex = NSNotFound;
3273 if ([equipmentKey hasSuffix:
@"_DAMAGED"]) {
3280 if ([eqType isMissileOrMine] || ([
self isThargoid] && ([lcEquipmentKey hasSuffix:
@"thargon"] || [lcEquipmentKey hasPrefix:
@"thargon"]))) {
3283 if ([
_equipment containsObject:equipmentKey]) {
3284 if (![equipmentKey isEqualToString:
@"EQ_PASSENGER_BERTH"]) {
3288 if ([equipmentKey isEqualToString:
@"EQ_CLOAKING_DEVICE"]) {
3294 if ([equipmentKey isEqualToString:
@"EQ_SHIELD_BOOSTER"]) {
3298 }
else if ([equipmentKey isEqualToString:
@"EQ_SHIELD_ENHANCER"]) {
3303 }
else if ([equipmentKey isEqual:
@"EQ_CARGO_BAY"]) {
3309 if (![equipmentKey hasSuffix:
@"_DAMAGED"] && ![eqType canCarryMultiple]) {
3310 NSString* damagedKey = [
equipmentKey stringByAppendingString:@"_DAMAGED"];
3311 if ([
_equipment containsObject:damagedKey]) {
3312 equipmentIndex = [_equipment indexOfObject:damagedKey];
3313 if (equipmentIndex != NSNotFound) {
3315 [_equipment removeObjectAtIndex:equipmentIndex];
3320 equipmentIndex = [_equipment indexOfObject:equipmentKey];
3321 if (equipmentIndex != NSNotFound) {
3322 [_equipment removeObjectAtIndex:equipmentIndex];
3343 if ([[
missile_list[i] identifier] isEqualTo:identifier]) {
3357 NSString* eqRole =
nil;
3358 NSString* shipKey =
nil;
3361 BOOL isRandomMissile = [
role isEqualToString:@"missile"];
3363 if (isRandomMissile) {
3365 shipKey = [UNIVERSE randomShipKeyForRoleRespectingConditions:role];
3367 OOLogWARN(
@"ship.setUp.missiles",
@"%@ \"%@\
" used in ship \"%@\" needs a valid %@.plist entry.%@",
@"random missile", shipKey, [
self name],
@"shipdata",
@"Trying another missile.");
3371 shipKey = [UNIVERSE randomShipKeyForRoleRespectingConditions:role];
3373 OOLogWARN(
@"ship.setUp.missiles",
@"%@ \"%@\
" used in ship \"%@\" needs a valid %@.plist entry.%@",
@"missile_role", role, [
self name],
@"shipdata",
@" Using defaults instead.");
3380 if (eqRole ==
nil) {
3381 missile = [UNIVERSE newShipWithName:shipKey];
3383 if (isRandomMissile)
3384 OOLogWARN(
@"ship.setUp.missiles",
@"%@ \"%@\
" used in ship \"%@\" needs a valid %@.plist entry.%@",
@"random missile", shipKey, [
self name],
@"shipdata",
@"Trying another missile.");
3386 OOLogWARN(
@"ship.setUp.missiles",
@"%@ \"%@\
" used in ship \"%@\" needs a valid %@.plist entry.%@",
@"missile_role", role, [
self name],
@"shipdata",
@" Using defaults instead.");
3389 if (isRandomMissile)
3395 if (isRandomMissile) {
3398 foreach (value, [[missile
roleSet] roles]) {
3399 role = (NSString*)value;
3402 if ([missileType isMissileOrMine])
3406 if (![missileType isMissileOrMine]) {
3414 OOLogWARN(
@"ship.setUp.missiles",
@"%@ \"%@\
" used in ship \"%@\" needs a valid %@.plist entry.%@", (isRandomMissile ?
@"random missile" :
@"missile_role"), role, [
self name],
@"equipment",
@" Enabling compatibility mode.");
3421 if ([eqRole isEqualToString:
@""]) {
3423 if (isRandomMissile)
3436 NSString* role =
nil;
3437 double chance =
randf();
3438 BOOL thargoidMissile = NO;
3443 if (missileType ==
nil) {
3450 float randomSelectionChance = chance;
3452 randomSelectionChance = 0.0f;
3457 if (missileType ==
nil)
3469 role =
@"EQ_MISSILE";
3475 if (missileType ==
nil)
3476 OOLogERR(
@"ship.setUp.missiles",
@"could not resolve missile / mine type for ship \"%@\
". Original missile role:\"%@\".", [
self name],
_missileRole);
3479 thargoidMissile = [
self isThargoid] && ([
role hasSuffix:@"thargon"] || [
role hasPrefix:@"thargon"]);
3481 if (thargoidMissile || (!thargoidMissile && [missileType isMissileOrMine])) {
3484 OOLogWARN(
@"ship.setUp.missiles",
@"missile_role \"%@\
" is not a valid missile / mine type for ship \"%@\".%@", [missileType identifier], [
self name],
@" No missile selected.");
3491 [_equipment release];
3630 float boostFactor = 1.0f;
3632 boostFactor += 1.0f;
3634 boostFactor += 1.0f;
3671- (void)setAfterburnerFactor:(GLfloat)new
3676- (void)setAfterburnerRate:(GLfloat)new
3686- (void)setMaxThrust:(GLfloat)new
3700- (void)behaviour_stop_still:(
double)delta_t
3708- (void)behaviour_idle:(
double)delta_t
3724- (void)behaviour_tumble:(
double)delta_t
3729- (void)behaviour_tractored:(
double)delta_t
3733 if ((hauler) && ([hauler
isShip])) {
3745 GLfloat moment = delta_t * 0.25 * tf;
3752 moment = delta_t * 0.5 * tf;
3758 moment = (d2 > 0.0) ? delta_t * 5.0 * tf / d2 : 0.0;
3765 if ([
self status] == STATUS_BEING_SCOOPED) {
3805- (void)behaviour_track_target:(
double)delta_t
3812 if ([
self hasProximityAlertIgnoringTarget:YES]) {
3817- (void)behaviour_intercept_target:(
double)delta_t
3820 if (
behaviour == BEHAVIOUR_INTERCEPT_TARGET) {
3837 double eta = range / (
flightSpeed - target_speed);
3839 double last_distance = last_success_factor;
3881 if ([
self hasProximityAlertIgnoringTarget:YES]) {
3886- (void)behaviour_attack_break_off_target:(
double)delta_t
3911 if ([
self hasProximityAlertIgnoringTarget:NO]) {
3931 behaviour = BEHAVIOUR_ATTACK_SLOW_DOGFIGHT;
3935 behaviour = BEHAVIOUR_ATTACK_SLOW_DOGFIGHT;
3937 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
3944- (void)behaviour_attack_slow_dogfight:(
double)delta_t
3950 if ([
self hasProximityAlertIgnoringTarget:YES]) {
3964 }
else if (aspect < -0.5) {
3967 }
else if (aspect < 0.3) {
3974 if (aspect > 0.85) {
3975 behaviour = BEHAVIOUR_ATTACK_BREAK_OFF_TARGET;
3996- (void)behaviour_evasive_action:(
double)delta_t
4024 if (
behaviour == BEHAVIOUR_FLEE_EVASIVE_ACTION) {
4038- (void)behaviour_attack_target:(
double)delta_t
4057 BOOL hasTurrets = NO;
4060 while (
isWeaponNone(forward_weapon_real_type) && (se = [subEnum nextObject])) {
4063 if (se->
behaviour == BEHAVIOUR_TRACK_AS_TURRET) {
4067 if (
isWeaponNone(forward_weapon_real_type) && hasTurrets) {
4073 if ([forward_weapon_real_type isTurretLaser]) {
4074 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
4083 BOOL weapons_heating = NO;
4084 if (!forward_weapon_ready && !aft_weapon_ready && !port_weapon_ready && !starboard_weapon_ready) {
4085 weapons_heating = YES;
4095 if (!forward_weapon_ready && !aft_weapon_ready && !port_weapon_ready && !starboard_weapon_ready) {
4099 behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
4100 }
else if (aspect > 0) {
4101 if (in_good_range) {
4105 behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
4109 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4115 behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
4117 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4125 [
self setEvasiveJink:(range + COMBAT_JINK_OFFSET - relativeSpeed / max_flight_pitch)];
4126 behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
4131 if (nearby && aft_weapon_ready) {
4134 }
else if (nearby && (port_weapon_ready || starboard_weapon_ready)) {
4137 }
else if (nearby) {
4148 [
self setEvasiveJink:(range + COMBAT_JINK_OFFSET - relativeSpeed / max_flight_pitch)];
4152 behaviour = BEHAVIOUR_ATTACK_BREAK_OFF_TARGET;
4154 behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
4156 }
else if (forward_weapon_ready) {
4165 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX;
4167 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
4169 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4171 }
else if (port_weapon_ready || starboard_weapon_ready) {
4174 }
else if (aft_weapon_ready && midrange) {
4179 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4187- (void)behaviour_attack_broadside:(
double)delta_t
4209 behaviour = BEHAVIOUR_ATTACK_BROADSIDE_RIGHT;
4212 behaviour = BEHAVIOUR_ATTACK_BROADSIDE_LEFT;
4217 behaviour = BEHAVIOUR_ATTACK_BROADSIDE_RIGHT;
4220 behaviour = BEHAVIOUR_ATTACK_BROADSIDE_LEFT;
4228 behaviour = BEHAVIOUR_CLOSE_TO_BROADSIDE_RANGE;
4235- (void)behaviour_attack_broadside_left:(
double)delta_t
4240- (void)behaviour_attack_broadside_right:(
double)delta_t
4245- (void)behaviour_attack_broadside_target:(
double)delta_t leftside:(BOOL)leftside
4258 behaviour = BEHAVIOUR_CLOSE_TO_BROADSIDE_RANGE;
4264 if (![
self hasProximityAlertIgnoringTarget:YES]) {
4281 if (range <= slow_down_range)
4291 behaviour = BEHAVIOUR_ATTACK_BROADSIDE_RIGHT;
4297 behaviour = BEHAVIOUR_ATTACK_BROADSIDE_LEFT;
4316 behaviour = BEHAVIOUR_ATTACK_FLY_FROM_TARGET;
4338- (void)behaviour_close_to_broadside_range:(
double)delta_t
4343 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4355 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
4365 behaviour = BEHAVIOUR_CLOSE_TO_BROADSIDE_RANGE;
4369- (void)behaviour_close_with_target:(
double)delta_t
4374 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4385 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
4390 if (range <= COMBAT_IN_RANGE_FACTOR * weaponRange || frustration > 5.0) {
4393 behaviour = BEHAVIOUR_CLOSE_WITH_TARGET;
4397- (void)behaviour_attack_sniper:(
double)delta_t
4404 if (![rawTarget
isShip]) {
4414 if (range < 15000) {
4461- (void)behaviour_fly_to_target_six:(
double)delta_t
4472 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4486 BOOL closeQuickly = (canBurn && range >
weaponRange);
4493 if (![rawTarget
isShip]) {
4503 if (range < slow_down_range && (
behaviour == BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX)) {
4504 if (range < back_off_range) {
4511 if ((range < 0.5 *
distance) && (
behaviour == BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX))
4512 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
4514 if (range < back_off_range) {
4524 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4530 if (
behaviour == BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX) {
4536 if (
behaviour == BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE) {
4541 GLfloat spacing = 2000.0;
4544 spacing = 2000.0 + (
accuracy * 500.0);
4559 if (
success_factor > last_success_factor || confidenceFactor < 0.85)
4566 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET;
4582- (void)behaviour_attack_mining_target:(
double)delta_t
4611- (void)behaviour_attack_fly_to_target:(
double)delta_t
4623 if (![rawTarget
isShip]) {
4631 if (![
self hasProximityAlertIgnoringTarget:YES]) {
4656 if (range <= slow_down_range) {
4657 if (range < back_off_range) {
4672 if (aspect > -0.25) {
4724 if ([target
behaviour] != BEHAVIOUR_FLEE_TARGET && [target
behaviour] != BEHAVIOUR_FLEE_EVASIVE_ACTION) {
4733- (void)behaviour_attack_fly_from_target:(
double)delta_t
4751 if (
randf() < 0.3) {
4757 if (
randf() < 0.3) {
4787 if ([
self hasProximityAlertIgnoringTarget:YES])
4794 if (aspect > 0.99999 || aspect < -0.999) {
4801- (void)behaviour_running_defense:(
double)delta_t
4812 behaviour = BEHAVIOUR_CLOSE_WITH_TARGET;
4814 behaviour = BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE;
4827 if ([
self hasProximityAlertIgnoringTarget:YES])
4840- (void)behaviour_flee_target:(
double)delta_t
4860 if (range > last_range)
4883 float qbomb_chance = 0.01 * delta_t;
4884 if (
randf() < qbomb_chance) {
4903- (void)behaviour_fly_range_from_destination:(
double)delta_t
4907 behaviour = BEHAVIOUR_FLY_FROM_DESTINATION;
4912 behaviour = BEHAVIOUR_FLY_TO_DESTINATION;
4914 if ([
self hasProximityAlertIgnoringTarget:YES]) {
4920- (void)behaviour_face_destination:(
double)delta_t
4930 if (confidenceFactor >= max_cos &&
flightPitch == 0.0) {
4937 behaviour = BEHAVIOUR_FLY_TO_DESTINATION;
4962 if ([
self hasProximityAlertIgnoringTarget:YES]) {
4967- (void)behaviour_land_on_planet:(
double)delta_t
4972 OOPlanetEntity* planet = [UNIVERSE entityForUniversalID:planetForLanding];
4989 if (confidenceFactor >= max_cos &&
flightSpeed == 0.0) {
4997 if ([
self hasProximityAlertIgnoringTarget:YES]) {
5002- (void)behaviour_formation_form_up:(
double)delta_t
5010 if ((eta < 5.0) && (leadShip) && (leadShip->
isShip))
5044 if ([
self hasProximityAlertIgnoringTarget:YES]) {
5049- (void)behaviour_fly_to_destination:(
double)delta_t
5071 if (confidenceFactor < 0.2)
5072 confidenceFactor = 0.2;
5089 minTurnSpeedFactor /= 10.0;
5091 minTurnSpeedFactor /= 10.0;
5105 if ((station_for_docking) && (station_for_docking->
isStation)) {
5106 float rollMatch =
dot_product([station_for_docking portUpVectorForShip:
self], [
self upVector]);
5107 if (rollMatch < MAX_COS && rollMatch > -
MAX_COS) {
5112 desired_speed = [dockingInstructions oo_floatForKey:@"speed"];
5131 if ([
self hasProximityAlertIgnoringTarget:YES]) {
5136- (void)behaviour_fly_from_destination:(
double)delta_t
5150 if ([
self hasProximityAlertIgnoringTarget:YES]) {
5155- (void)behaviour_avoid_collision:(
double)delta_t
5173- (void)behaviour_track_as_turret:(
double)delta_t
5195 while ((target = [[targetEnum nextObject] weakRefUnderlyingObject])) {
5223- (void)behaviour_fly_thru_navpoints:(
double)delta_t
5243 BOOL in_cone = (r0 > 0.5 * r1);
5255 if (navpoint_plus_index == 0) {
5262 double last_dist2 = last_success_factor;
5279 if (dist2 < last_dist2)
5300- (void)behaviour_scripted_ai:(
double)delta_t
5306 NSDictionary* result =
nil;
5316 OOLog(
@"ai.error",
@"Could not call scriptedAI in ship script of %@, reverting to idle",
self);
5325 if (!JS_IsObject(rval) && !JS_IsNull(rval)) {
5327 if (!JSVAL_IS_OBJECT(rval)) {
5329 OOLog(
@"ai.error",
@"Invalid return value of scriptedAI in ship script of %@, reverting to idle",
self);
5345 if ([result objectForKey:
@"stickRollFactor"] !=
nil) {
5357 if ([result objectForKey:
@"stickPitchFactor"] !=
nil) {
5369 if ([result objectForKey:
@"stickYawFactor"] !=
nil) {
5384 if ([result objectForKey:
@"desiredSpeedFactor"] !=
nil) {
5395 if (
behaviour == BEHAVIOUR_SCRIPTED_ATTACK_AI) {
5396 NSString* chosen_weapon = [
result oo_stringForKey:@"chosenWeapon" defaultValue:@"FORWARD"];
5399 if ([chosen_weapon isEqualToString:
@"FORWARD"]) {
5401 }
else if ([chosen_weapon isEqualToString:
@"AFT"]) {
5403 }
else if ([chosen_weapon isEqualToString:
@"PORT"]) {
5405 }
else if ([chosen_weapon isEqualToString:
@"STARBOARD"]) {
5416- (void)setReactionTime:(
float)newReactionTime
5424 if (target ==
nil) {
5437 if (target ==
nil) {
5500- (void)drawImmediate:(
bool)immediate translucent:(
bool)translucent
5511#ifdef OO_DEBUG_MONITOR_ENABLED
5529 NSAssert3([subEntity
owner] ==
self,
@"Subentity ownership broke - %@ should be owned by %@ but is owned by %@.", subEntity,
self, [subEntity
owner]);
5536#ifdef OO_DEBUG_MONITOR_ENABLED
5537- (void)drawDebugStuff
5540 if (0 && reportAIMessages) {
5544 Entity* pTarget = [
self primaryTarget];
5545 if (pTarget !=
nil) {
5550 Entity* sTarget = [
self targetStation];
5551 if (sTarget != pTarget && [sTarget isStation]) {
5552 OODebugDrawPoint(
HPVectorToVector([sTarget position]), [OOColor cyanColor]);
5555 Entity* fTarget = [
self foundTarget];
5556 if (fTarget !=
nil && fTarget != pTarget && fTarget != sTarget) {
5557 OODebugDrawPoint(
HPVectorToVector([fTarget position]), [OOColor magentaColor]);
5563- (void)drawSubEntityImmediate:(
bool)immediate translucent:(
bool)translucent
5578#ifdef OO_DEBUG_MONITOR_ENABLED
5601- (GLfloat*)scannerDisplayColorForShip:(
ShipEntity*)otherShip isHostile:(BOOL)isHostile flash:(BOOL)flash scannerDisplayColor1:(
OOColor*)scannerDisplayColor1 scannerDisplayColor2:(
OOColor*)scannerDisplayColor2 scannerDisplayColorH1:(
OOColor*)scannerDisplayColorH1 scannerDisplayColorH2:(
OOColor*)scannerDisplayColorH2
5607 if (scannerDisplayColorH1 || scannerDisplayColorH2) {
5608 if (scannerDisplayColorH1 && !scannerDisplayColorH2) {
5612 if (!scannerDisplayColorH1 && scannerDisplayColorH2) {
5616 if (scannerDisplayColorH1 && scannerDisplayColorH2) {
5667 case CLASS_THARGOID:
5682 case CLASS_MILITARY:
5683 if ((isHostile) && (flash))
5727- (void)setScannerDisplayColorHostile1:(
OOColor*)color
5736- (void)setScannerDisplayColorHostile2:(
OOColor*)color
5765- (void)setCloaked:(BOOL)cloak
5778- (void)setAutoCloak:(BOOL)automatic
5788- (void)addSubEntity:(
Entity<OOSubEntity>*)sub
5793 if (subEntities ==
nil)
5817- (void)applyThrust:(
double)delta_t
5830 GLfloat vscale = fmaxf((velmag - dt_thrust) / velmag, 0.0f);
5855 if (isUsingAfterburner)
5874- (void)applyRoll:(GLfloat)roll1 andClimb:(GLfloat)climb1
5890- (void)applyRoll:(GLfloat)roll1 climb:(GLfloat)climb1 andYaw:(GLfloat)yaw1
5892 if ((roll1 == 0.0) && (climb1 == 0.0) && (yaw1 == 0.0) && (!
hasRotated))
5908- (void)applyAttitudeChanges:(
double)delta_t
5922 [previousCondition release];
5928 [previousCondition oo_setInteger:behaviour forKey:@"behaviour"];
5931 [previousCondition setObject:[[
self primaryTarget] weakSelf] forKey:@"primaryTarget"];
5933 [previousCondition oo_setFloat:desired_range forKey:@"desired_range"];
5934 [previousCondition oo_setFloat:desired_speed forKey:@"desired_speed"];
5935 [previousCondition oo_setHPVector:_destination forKey:@"destination"];
5952 behaviour = [previousCondition oo_intForKey:@"behaviour"];
5954 _primaryTarget = [[previousCondition objectForKey:@"primaryTarget"] weakRetain];
5956 desired_range = [previousCondition oo_floatForKey:@"desired_range"];
5957 desired_speed = [previousCondition oo_floatForKey:@"desired_speed"];
5958 _destination = [previousCondition oo_hpvectorForKey:@"destination"];
5960 [previousCondition release];
5974- (void)setMessageTime:(
double)value
5988 if (
self == [
_group leader])
6020#ifdef OO_DEBUG_MONITOR_ENABLED
6023 return _escortGroup;
6047 return [[
NSArray array] objectEnumerator];
6070- (void)setPendingEscortCount:(uint8_t)count
6080- (void)setMaxEscortCount:(uint8_t)newCount
6087 NSUInteger
count = 0;
6090 while ((se = [subEnum nextObject])) {
6114 if ([other
mass] < 2000)
6135 double d2 = d_forward * d_forward + d_up * d_up + d_right * d_right;
6142 if (
behaviour == BEHAVIOUR_AVOID_COLLISION)
6145 if ((prox) && (prox != other)) {
6149 if (sa_prox < sa_other)
6183 return [
NSString stringWithFormat:@"%@: %@", name, shipUniqueName];
6185 return [
NSString stringWithFormat:@"%@: %@", shipClassName, shipUniqueName];
6203 NSString* desc =
nil;
6205 case CLASS_NEUTRAL: {
6209 legal_i = (legal <= 50) ? 1 : 2;
6211 desc = [[[UNIVERSE descriptions] oo_arrayForKey:@"legal_status"] oo_stringAtIndex:legal_i];
6214 case CLASS_THARGOID:
6215 desc =
DESC(
@"legal-desc-alien");
6219 desc =
DESC(
@"legal-desc-system-vessel");
6222 case CLASS_MILITARY:
6223 desc =
DESC(
@"legal-desc-military-vessel");
6233- (void)setName:(NSString*)inName
6239- (void)setShipUniqueName:(NSString*)inName
6241 [shipUniqueName release];
6245- (void)setShipClassName:(NSString*)inName
6247 [shipClassName release];
6251- (void)setDisplayName:(NSString*)inName
6253 [displayName release];
6257- (void)setScanDescription:(NSString*)inName
6259 [scan_description release];
6266 return DESC(
@"unknown-target");
6271- (BOOL)hasRole:(NSString*)role
6283- (void)addRole:(NSString*)role
6288- (void)addRole:(NSString*)role withProbability:(
float)probability
6290 if (![
self hasRole:role]) {
6296 if (newRoles !=
nil) {
6303- (void)removeRole:(NSString*)role
6305 if ([
self hasRole:role]) {
6307 if (newRoles !=
nil) {
6320 [primaryRole retain];
6321 OOLog(
@"ship.noPrimaryRole",
@"%@ had no primary role, randomly selected \"%@\
".", [
self name],
primaryRole);
6328- (void)setPrimaryRole:(NSString*)role
6331 [primaryRole release];
6336- (BOOL)hasPrimaryRole:(NSString*)role
6344 return [
self scanClass] == CLASS_POLICE;
6349 return [
self scanClass] == CLASS_THARGOID;
6354 return [UNIVERSE role:[
self primaryRole] isInCategory:@"oolite-trader"];
6359 return [UNIVERSE role:[
self primaryRole] isInCategory:@"oolite-pirate"];
6364 return ([[
self primaryRole] hasSuffix:
@"MISSILE"] || [
self hasPrimaryRole:
@"missile"]);
6379 return [UNIVERSE role:[
self primaryRole] isInCategory:@"oolite-escort"];
6384 return [UNIVERSE role:[
self primaryRole] isInCategory:@"oolite-shuttle"];
6389 return behaviour == BEHAVIOUR_TRACK_AS_TURRET;
6394 return [UNIVERSE roleIsPirateVictim:[
self primaryRole]];
6410 case BEHAVIOUR_ATTACK_TARGET:
6411 case BEHAVIOUR_ATTACK_FLY_TO_TARGET:
6412 case BEHAVIOUR_ATTACK_FLY_FROM_TARGET:
6413 case BEHAVIOUR_RUNNING_DEFENSE:
6414 case BEHAVIOUR_FLEE_TARGET:
6415 case BEHAVIOUR_ATTACK_BREAK_OFF_TARGET:
6416 case BEHAVIOUR_ATTACK_SLOW_DOGFIGHT:
6417 case BEHAVIOUR_EVASIVE_ACTION:
6418 case BEHAVIOUR_FLEE_EVASIVE_ACTION:
6419 case BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX:
6421 case BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE:
6422 case BEHAVIOUR_ATTACK_BROADSIDE:
6423 case BEHAVIOUR_ATTACK_BROADSIDE_LEFT:
6424 case BEHAVIOUR_ATTACK_BROADSIDE_RIGHT:
6425 case BEHAVIOUR_CLOSE_TO_BROADSIDE_RANGE:
6426 case BEHAVIOUR_CLOSE_WITH_TARGET:
6427 case BEHAVIOUR_ATTACK_SNIPER:
6428 case BEHAVIOUR_SCRIPTED_ATTACK_AI:
6449 int old_behaviour = [previousCondition oo_intForKey:@"behaviour"];
6465- (void)setWeaponRange:(GLfloat)value
6491- (void)setEnergyRechargeRate:(GLfloat)new
6501- (void)setWeaponRechargeRate:(
float)value
6506- (void)setWeaponEnergy:(
float)value
6521- (void)setScannerRange:(GLfloat)value
6541- (void)setReportAIMessages:(BOOL)yn
6574 return centerDistance - 1.35 * r * r;
6585 OOPlanetEntity* e1 = i1;
6586 OOPlanetEntity* e2 = i2;
6592 return NSOrderedAscending;
6594 return NSOrderedDescending;
6596 return NSOrderedSame;
6606 OOPlanetEntity *planet =
nil, *bestPlanet =
nil;
6607 float bestRange = INFINITY;
6613 foreach (planet, [
UNIVERSE planets]) {
6619 if (range < bestRange) {
6620 bestPlanet = planet;
6644 OOPlanetEntity* result =
nil;
6645 OOPlanetEntity* planet =
nil;
6646 NSArray* bodies =
nil;
6647 NSArray* planets =
nil;
6650 bodies = [UNIVERSE planets];
6653 for (i = 0; i < [
bodies count]; i++) {
6654 planet = [
bodies objectAtIndex:i];
6656 planets = [
planets arrayByAddingObject:planet];
6659 if ([planets
count] == 0)
6662 planets = [
planets sortedArrayUsingFunction:ComparePlanetsBySurfaceDistance context:
self];
6663 result = [
planets objectAtIndex:0];
6671 BOOL sunGoneNova = [[UNIVERSE sun] goneNova];
6673 if (nearest ==
nil) {
6682 float cr2 = cr * cr;
6722 OOPlanetEntity* mainPlanet = [UNIVERSE planet];
6726 if (d2 < cr2 * 9.0f) {
6727 nearest = mainPlanet;
6811 if (stellar ==
nil) {
6813 _lastAegisLock =
nil;
6819- (void)setLastAegisLock:(
Entity<OOStellarBody>*)lastAegisLock
6847 if ([
self status] == stat)
6850 if (stat == STATUS_LAUNCHING) {
6855- (void)setLaunchDelay:(
double)delay
6865- (void)setCrew:(NSArray*)crewArray
6879- (void)setSingleCrewWithRole:(NSString*)crewRole
6895 foreach (crewMember,
crew) {
6897 [
result addObject:crewDict];
6902- (void)setStateMachine:(NSString*)smName
6924 return [[
self shipInfoDictionary] oo_fuzzyBooleanForKey:@"auto_ai" defaultValue:YES];
6929 return [[[
self getAI]
name] isEqualToString:@"nullAI.plist"];
6934 return [[
self shipInfoDictionary] oo_fuzzyBooleanForKey:@"auto_weapons" defaultValue:NO];
6937- (void)setShipScript:(NSString*)script_name
6939 NSMutableDictionary* properties =
nil;
6940 NSArray* actions =
nil;
6949 actions = [shipinfoDictionary oo_arrayForKey:@"launch_actions"];
6953 [
properties setObject:actions forKey:@"legacy_launchActions"];
6957 actions = [shipinfoDictionary oo_arrayForKey:@"script_actions"];
6961 [
properties setObject:actions forKey:@"legacy_scriptActions"];
6965 actions = [shipinfoDictionary oo_arrayForKey:@"death_actions"];
6969 [
properties setObject:actions forKey:@"legacy_deathActions"];
6973 actions = [shipinfoDictionary oo_arrayForKey:@"setup_actions"];
6977 [
properties setObject:actions forKey:@"legacy_setupActions"];
7015#if MASS_DEPENDENT_FUEL_PRICES
7021 OOLog(
@"fuelPrices",
@"\"%@\
" fuel charge rate: %.2f (mass ratio: %.2f/%.2f)", [
self shipDataKey], rate,
mass, [
PLAYER baseMass]);
7027- (void)applySticks:(
double)delta_t
7030 double rate1 = 2.0 * delta_t;
7031 double rate2 = 4.0 * delta_t;
7032 double rate3 = 4.0 * delta_t;
7076- (void)setRoll:(
double)amount
7081- (void)setRawRoll:(
double)amount
7086- (void)setPitch:(
double)amount
7091- (void)setYaw:(
double)amount
7096- (void)setThrust:(
double)amount
7101- (void)setThrustForDemo:(
float)factor
7116 if ((
scanClass == CLASS_THARGOID ||
scanClass == CLASS_STATION) && reason != kOOLegalStatusReasonSetup && reason != kOOLegalStatusReasonByScript) {
7119 if (
scanClass == CLASS_POLICE && amount != 0) {
7140 ShipScriptEvent(context,
self,
"shipBountyChanged", amountVal, reasonVal);
7161 return (
int)[
self bounty];
7166 if (co_type !=
nil) {
7170 NSString* tmp = [
co_type copy];
7180 if (co_type ==
nil) {
7187 OOMassUnit unit = [[UNIVERSE commodityMarket] massUnitForGood:co_type];
7192 else if (unit ==
UNITS_GRAMS && co_amount > 1000000)
7193 co_amount = 1000000;
7227 NSUInteger result = [[
self cargo] count];
7228 NSAssert(result < UINT32_MAX,
@"Cargo quantity out of bounds.");
7249 NSArray* goods = [[UNIVERSE commodityMarket] goods];
7250 NSUInteger i, j, commodityCount = [
goods count];
7253 for (i = 0; i < commodityCount; i++) {
7254 quantityInHold[
i] = 0;
7256 for (i = 0; i < [cargo count]; i++) {
7257 ShipEntity* container = [cargo objectAtIndex:i];
7262 for (i = 0; i < commodityCount; i++) {
7263 if (quantityInHold[i] > 0) {
7265 good = [
goods objectAtIndex:i];
7267 [
commodity setObject:good forKey:@"commodity"];
7268 [
commodity setObject:[
NSNumber numberWithUnsignedInt:quantityInHold[
i]] forKey:@"quantity"];
7269 [
commodity setObject:[[UNIVERSE commodityMarket] nameForGood:good] forKey:@"displayName"];
7270 [
commodity setObject:DisplayStringForMassUnitForCommodity(good) forKey:@"unit"];
7271 [
list addObject:commodity];
7275 return [[
list copy] autorelease];
7278- (void)setCargo:(NSArray*)some_cargo
7280 [cargo removeAllObjects];
7281 [cargo addObjectsFromArray:some_cargo];
7284- (BOOL)addCargo:(NSArray*)some_cargo
7289 [cargo addObjectsFromArray:some_cargo];
7298 foreach (pod,
cargo) {
7303 if (found < amount) {
7308 NSUInteger i = [cargo count] - 1;
7310 while (amount > 0) {
7313 [cargo removeObjectAtIndex:i];
7336 NSArray* newCargo =
nil;
7356 newCargo = [UNIVERSE getContainersOfCommodity:[shipinfoDictionary oo_stringForKey:@"cargo_carried"] how_much:num];
7359 newCargo = [UNIVERSE getContainersOfGoods:num scarce:NO legal:YES];
7362 newCargo = [UNIVERSE getContainersOfGoods:num scarce:YES legal:YES];
7365 newCargo = [UNIVERSE getContainersOfCommodity:@"Narcotics" how_much:num];
7368 newCargo = [UNIVERSE getContainersOfGoods:num scarce:YES legal:NO];
7371 newCargo = [UNIVERSE getContainersOfGoods:(Ranrot() % (1 + num / 2)) scarce:YES legal:NO];
7384- (void)setSpeed:(
double)amount
7389- (void)setDesiredSpeed:(
double)amount
7404- (void)setDesiredRange:(
double)amount
7414- (void)increase_flight_speed:(
double)delta
7416 double factor = 1.0;
7426- (void)decrease_flight_speed:(
double)delta
7428 double factor = 1.0;
7440- (void)increase_flight_roll:(
double)delta
7449- (void)decrease_flight_roll:(
double)delta
7458- (void)increase_flight_pitch:(
double)delta
7467- (void)decrease_flight_pitch:(
double)delta
7476- (void)increase_flight_yaw:(
double)delta
7485- (void)decrease_flight_yaw:(
double)delta
7534- (void)setMaxFlightPitch:(GLfloat)new
7539- (void)setMaxFlightSpeed:(GLfloat)new
7544- (void)setMaxFlightRoll:(GLfloat)new
7549- (void)setMaxFlightYaw:(GLfloat)new
7566- (void)setTemperature:(GLfloat)value
7576- (float)randomEjectaTemperatureWithMaxFactor:(
float)factor
7578 const float kRange = 0.02f;
7582 float adjusted = parentTemp * (
bellf(5) * (kRange * 2.0f) - kRange + factor);
7598- (void)setHeatInsulation:(GLfloat)value
7608- (void)dealEnergyDamage:(GLfloat)baseDamage atRange:(GLfloat)range withBias:(GLfloat)velocityBias
7613 OOLog(
@"missile.damage.calc",
@"Range: %f | Damage: %f | MaxRange: %f", range, baseDamage, maxRange);
7615 NSArray* targets = [UNIVERSE entitiesWithinRange:maxRange ofEntity:
self];
7616 if ([targets
count] > 0) {
7618 for (i = 0; i < [
targets count]; i++) {
7622 double d = (
magnitude(p2) - ecr) / range;
7624 double localDamage = baseDamage;
7625 OOLog(
@"missile.damage.calc",
@"Base damage: %f", baseDamage);
7626 if (velocityBias > 0) {
7634 if (vMag > 1000.0) {
7640 localDamage += vMag * velocityBias;
7641 OOLog(
@"missile.damage.calc",
@"Velocity magnitude + sign: %f , %f",
magnitude(v2), vSign);
7642 OOLog(
@"missile.damage.calc",
@"Velocity magnitude factor: %f", vMag);
7643 OOLog(
@"missile.damage.calc",
@"Velocity corrected damage: %f", localDamage);
7645 double damage = (d > 1) ? localDamage / (d * d) : localDamage;
7665 NSDictionary* explosion = [UNIVERSE explosionSetting:@"oolite-default-ship-explosion"];
7673 OOStandardsDeprecated([NSString stringWithFormat:
@"dealEnergyDamageWithinDesiredRange is deprecated for %@",
self]);
7675 NSArray* targets = [UNIVERSE entitiesWithinRange:(desired_range < SCANNER_MAX_RANGE ? desired_range : SCANNER_MAX_RANGE) ofEntity:
self];
7676 if ([targets
count] > 0) {
7678 for (i = 0; i < [
targets count]; i++) {
7689- (void)dealMomentumWithinDesiredRange:(
double)amount
7691 NSArray* targets = [UNIVERSE entitiesWithinRange:desired_range ofEntity:
self];
7692 if ([targets
count] > 0) {
7694 for (i = 0; i < [
targets count]; i++) {
7716- (void)setHulk:(BOOL)isNowHulk
7725 if (amount < 0 || (amount == 0 && [[
UNIVERSE gameController] isGamePaused]))
7734 ShipScriptEvent(context,
self,
"shipTakingDamage", amountVal, entityVal, typeVal);
7740 if (
behaviour == BEHAVIOUR_FLEE_TARGET) {
7743 behaviour = BEHAVIOUR_FLEE_EVASIVE_ACTION;
7754 if ([
self status] == STATUS_DEAD)
7757 [PLAYER setScriptTarget:
self];
7784- (void)rescaleBy:(GLfloat)factor
7789- (void)rescaleBy:(GLfloat)factor writeToCache:(BOOL)writeToCache
7791 _scaleFactor *= factor;
7795 NSString* modelName = [
shipDict oo_stringForKey:@"model"];
7796 if (modelName !=
nil) {
7814 foreach (se, [
self subEntities]) {
7820 mass *= factor * factor * factor;
7829 int speed_low = 200;
7831 NSArray* jetsam =
nil;
7832 unsigned cargo_chance = 70;
7833 jetsam = [
NSArray arrayWithArray:cargo];
7834 [cargo removeAllObjects];
7835 unsigned limit = 15;
7837 NSUInteger n_jetsam = [
jetsam count];
7839 for (i = 0; i < n_jetsam; i++) {
7840 if (
Ranrot() % 100 < cargo_chance)
7843 if (cargo_chance > 10) {
7852 ShipEntity* container = [UNIVERSE reifyCargoPod:cargoObj];
7865 v.
x = 0.1 * ((
ranrot_rand() % speed_low) - speed_low / 2);
7866 v.
y = 0.1 * ((
ranrot_rand() % speed_low) - speed_low / 2);
7867 v.
z = 0.1 * ((
ranrot_rand() % speed_low) - speed_low / 2);
7874 [UNIVERSE addEntity:container];
7877 if ([containerAI hasSuspendedStateMachines])
7890- (void)setIsWreckage:(BOOL)isw
7905 if (parent !=
nil) {
7911 [UNIVERSE addEntity:this_ship];
7924 int speed_low = 200;
7925 GLfloat n_alloys = sqrtf(sqrtf(
mass / 6000.0f));
7926 NSUInteger numAlloys = 0;
7929 if ([
self status] == STATUS_DEAD) {
7930 [UNIVERSE removeEntity:
self];
7945 [UNIVERSE addEntity:ring];
7967 NSString* explosionKey =
@"oolite-default-ship-explosion";
7968 NSDictionary* explosion =
nil;
7970 explosion = [UNIVERSE explosionSetting:explosionKey];
7975 for (NSUInteger i = 0; i < [explosionType count]; i++) {
7976 explosionKey = [explosionType oo_stringAtIndex:i defaultValue:nil];
7977 if (explosionKey !=
nil) {
7979 if ([explosionKey isEqualToString:
@"oolite-builtin-flash"]) {
7981 }
else if ([explosionKey isEqualToString:
@"oolite-builtin-slowcloud"]) {
7983 }
else if ([explosionKey isEqualToString:
@"oolite-builtin-fastspark"]) {
7986 explosion = [UNIVERSE explosionSetting:explosionKey];
8001 if ([
self hasRole:
@"asteroid"] || [
self isBoulder]) {
8003 NSString* defaultRole =
@"boulder";
8004 float defaultSpeed = 50.0;
8006 defaultRole =
@"splinter";
8007 defaultSpeed = 20.0;
8012 [PLAYER addRoleForMining];
8016 NSString* debrisRole = [[
self shipInfoDictionary] oo_stringForKey:@"debris_role" defaultValue:defaultRole];
8017 for (i = 0; i < n_rocks; i++) {
8018 ShipEntity* rock = [UNIVERSE newShipWithRole:debrisRole];
8022 v.
x = ((
randf() * r_speed) - r_speed / 2);
8023 v.
y = ((
randf() * r_speed) - r_speed / 2);
8024 v.
z = ((
randf() * r_speed) - r_speed / 2);
8043 [UNIVERSE addEntity:rock];
8053 if ((n_alloys &&
canFragment) || canReleaseSubWreckage) {
8054 NSUInteger n_wreckage = 0;
8059 NSUInteger maxWrecks = 3;
8060 if (n_alloys == 0) {
8062 n_wreckage = (
mass > 600.0 &&
randf() < 0.2) ? 2 : 0;
8064 n_wreckage = (n_alloys < maxWrecks) ? floorf(
randf() * (n_alloys + 2)) : maxWrecks;
8068 for (i = 0; i < n_wreckage; i++) {
8072 GLfloat lifetime = 750.0 *
randf() + 250.0 * i + 100.0;
8073 ShipEntity* wreck = [UNIVERSE addWreckageFrom:
self withRole:@"wreckage" at:rpos scale:1.0 lifetime:lifetime / 2];
8077 n_alloys =
randf() * n_alloys;
8085 else if (!add_debris) {
8086 n_alloys = (n_alloys > 1.0) ? 1.0 : 0.0;
8090 numAlloys = floorf(n_alloys);
8094 for (i = 0; i < numAlloys; i++) {
8095 ShipEntity* plate = [UNIVERSE newShipWithRole:@"alloy"];
8106 v.
x = 0.1 * ((
ranrot_rand() % speed_low) - speed_low / 2);
8107 v.
y = 0.1 * ((
ranrot_rand() % speed_low) - speed_low / 2);
8108 v.
z = 0.1 * ((
ranrot_rand() % speed_low) - speed_low / 2);
8116 [UNIVERSE addEntity:plate];
8141 OOLog(
@"becomeExplosion.suspectedGhost.confirm",
@"%@",
@"Ship spotted with isPlayer set when not actually the player.");
8149 [UNIVERSE removeEntity:
self];
8160 [UNIVERSE removeEntity:
self];
8167 NSArray* targets = [UNIVERSE entitiesWithinRange:SCANNER_MAX_RANGE ofEntity:
self];
8168 if ([targets
count] > 0) {
8170 for (i = 0; i < [
targets count]; i++) {
8184 [subEntities removeObject:exhaust];
8190 [subEntities removeObject:flasher];
8196 if ([
self subEntityTakingDamage] == sub)
8208 if ([
self subEntityTakingDamage] == sub)
8211 if ([
self hasSubEntity:sub]) {
8212 OOLogERR(
@"shipEntity.bug.subEntityRetainUnderflow",
@"Subentity of %@ died while still in subentity list! This is bad. Leaking subentity list to avoid crash. %@",
self,
@"This is an internal error, please report it.");
8219- (
Vector)positionOffsetForAlignment:(NSString*)align
8221 NSString* padAlign = [
NSString stringWithFormat:@"%@---", align];
8223 switch ([padAlign characterAtIndex:0]) {
8235 switch ([padAlign characterAtIndex:1]) {
8247 switch ([padAlign characterAtIndex:2]) {
8264 NSString* padAlign = [
NSString stringWithFormat:@"%@---", align];
8270 switch ([padAlign characterAtIndex:0]) {
8273 result.
x = 0.5 * (arbb.
min.
x + arbb.
max.
x);
8276 result.
x = arbb.
max.
x;
8279 result.
x = arbb.
min.
x;
8282 switch ([padAlign characterAtIndex:1]) {
8285 result.
y = 0.5 * (arbb.
min.
y + arbb.
max.
y);
8288 result.
y = arbb.
max.
y;
8291 result.
y = arbb.
min.
y;
8294 switch ([padAlign characterAtIndex:2]) {
8297 result.
z = 0.5 * (arbb.
min.
z + arbb.
max.
z);
8300 result.
z = arbb.
max.
z;
8303 result.
z = arbb.
min.
z;
8309- (void)becomeLargeExplosion:(
double)factor
8312 if ([
self status] == STATUS_DEAD)
8319 float how_many = factor;
8320 while (how_many > 0.5f) {
8326 while (how_many > 0.5f) {
8343 [UNIVERSE removeEntity:
self];
8355- (NSComparisonResult)compareBeaconCodeWith:(
Entity<OOBeaconEntity>*)other
8357 return [[
self beaconCode] compare:[
other beaconCode] options:NSCaseInsensitiveSearch];
8386 while (
isWeaponNone(forward_weapon_real_type) && (se = [subEnum nextObject])) {
8429- (void)setEntityPersonalityInt:(uint16_t)value
8437- (void)setSuppressExplosion:(BOOL)suppress
8463 while ((scan) && (scan->
isShip == NO))
8473 scan = scan->z_previous;
8474 while ((scan) && (scan->isShip == NO))
8475 scan = scan->z_previous;
8479 while ((scan) && (scan->
isShip == NO))
8487 scan = scan->z_next;
8488 while ((scan) && (scan->isShip == NO))
8489 scan = scan->z_next;
8551 if (result ==
nil || ![
self isValidTarget:result]) {
8567 if (result ==
nil || ![
self isValidTarget:result]) {
8574- (void)setPrimaryAggressor:(
Entity*)targetEntity
8583 if (result ==
nil || ![
self isValidTarget:result]) {
8590- (void)setLastEscortTarget:(
Entity*)targetEntity
8599 if (result ==
nil || ![
self isValidTarget:result]) {
8615 if (result ==
nil || ![
self isValidTarget:result]) {
8622- (void)setRememberedShip:(
Entity*)targetEntity
8631 if (result ==
nil || ![
self isValidTarget:result]) {
8638- (void)setTargetStation:(
Entity*)targetEntity
8649 if (target ==
nil) {
8654 if (tstatus == STATUS_ENTERING_WITCHSPACE || tstatus == STATUS_IN_HOLD || tstatus == STATUS_DOCKED || tstatus == STATUS_DEAD)
8669 if (targetEntity ==
self)
8671 if (targetEntity !=
nil) {
8684 if (targetEntity !=
nil)
8708 if (target ==
nil) {
8711 if (![
self isValidTarget:target]) {
8731 || ![
self isValidTarget:result]) {
8759 BOOL isFriendly = NO;
8763 if ((otherShip ==
self) || ([
self isPolice] && [otherShip
isPolice]) || ([
self isThargoid] && [otherShip
isThargoid]) || (myGroup !=
nil && otherGroup !=
nil && (myGroup == otherGroup || [otherGroup leader] ==
self)) || ([
self scanClass] == CLASS_MILITARY && [otherShip
scanClass] == CLASS_MILITARY)) {
8777 if (ship != [
self shipHitByLaser]) {
8788 if ([
self isDefenseTarget:ship]) {
8823 if ([
self isDefenseTarget:target]) {
8867- (
HPVector)distance_twelve:(GLfloat)dist withOffset:(GLfloat)offset
8870 twelve.
x += dist *
v_up.x;
8871 twelve.
y += dist *
v_up.y;
8872 twelve.
z += dist *
v_up.z;
8879- (void)trackOntoTarget:(
double)delta_t withDForward:(GLfloat)dp
8889 vector_to_target = [
self vectorTo:target];
8891 GLfloat range2 =
magnitude2(vector_to_target);
8893 GLfloat max_cos = sqrt(1 - targetRadius * targetRadius / range2);
8898 if (vector_to_target.
x || vector_to_target.
y || vector_to_target.
z)
8901 vector_to_target.
z = 1.0;
8916- (double)ballTrackLeadingTarget:(
double)delta_t atTarget:(
Entity*)target
8926 double aim_cos, ref_cos;
8938 while ((father) && (father != last) && (father !=
NO_TARGET)) {
8989- (void)setEvasiveJink:(GLfloat)z
9012- (void)evasiveAction:(
double)delta_t
9025 if (agreement > -0.3 && agreement < 0.3) {
9043- (double)trackPrimaryTarget:(
double)delta_t retreat:(BOOL)retreat
9065 GLfloat d_forward, d_up, d_right;
9078 vy = targetShip->
v_up;
9096 GLfloat dist_adjust_factor = 1.0;
9099 if (range > 2000.0) {
9100 dist_adjust_factor = range / 2000.0;
9102 dist_adjust_factor *= 3;
9105 if (
jink.x == 0.0 &&
behaviour != BEHAVIOUR_RUNNING_DEFENSE) {
9112 relPos.
x += (
jink.x * vx.
x +
jink.y * vy.
x +
jink.z * vz.
x) * dist_adjust_factor;
9113 relPos.
y += (
jink.x * vx.
y +
jink.y * vy.
y +
jink.z * vz.
y) * dist_adjust_factor;
9128 double reverse = (retreat) ? -1.0 : 1.0;
9130 double min_d = 0.004;
9132 double r_max_factor = 0.125;
9138 r_max_factor = 1.0 / max_factor;
9142 r_max_factor /= 3.0;
9146 if (min_d < 0.001) {
9149 r_max_factor /= 2.0;
9158 if (d_forward * reverse > max_cos)
9171 if (reverse * d_up > 0)
9179 if ((d_forward < max_cos) || (retreat))
9181 if (d_forward < -max_cos)
9187 int factor = sqrt(fabs(d_right) / fabs(min_d));
9188 if (factor > max_factor)
9189 factor = max_factor;
9190 if (d_right > min_d)
9192 if (d_right < -min_d)
9195 if (d_up < -min_d) {
9196 int factor = sqrt(fabs(d_right) / fabs(min_d));
9197 if (factor > max_factor)
9198 factor = max_factor;
9199 if (d_right > min_d)
9201 if (d_right < -min_d)
9206 int factor = sqrt(fabs(d_up) / fabs(min_d));
9207 if (factor > max_factor)
9208 factor = max_factor;
9217 if (fabs(d_right) < fabs(
stick_roll) * delta_t) {
9244 d_forward *= d_forward;
9246 if (d_forward < 0.0)
9255- (double)trackSideTarget:(
double)delta_t leftside:(BOOL)leftside
9273 GLfloat d_forward, d_up, d_right;
9290 double reverse = (leftside) ? -1.0 : 1.0;
9292 double min_d = 0.004;
9297 double r_max_factor = 0.125;
9303 if (d_right * reverse > max_cos)
9305 return d_right * reverse;
9314 if ((d_right * reverse < max_cos))
9316 if (d_right < -max_cos)
9318 d_forward = min_d * 2.0;
9321 if (d_forward > min_d) {
9322 int factor = sqrt(fabs(d_up) / fabs(min_d));
9323 if (factor > max_factor)
9324 factor = max_factor;
9330 if (d_forward < -min_d) {
9331 int factor = sqrt(fabs(d_up) / fabs(min_d));
9332 if (factor > max_factor)
9333 factor = max_factor;
9340 if (fabs(
stick_pitch) == 0.0 || fabs(d_forward) > 0.5) {
9342 int factor = sqrt(fabs(d_forward) / fabs(min_d));
9343 if (factor > max_factor)
9344 factor = max_factor;
9345 if (d_forward > min_d)
9347 if (d_forward < -min_d) {
9348 if (factor < max_factor / 2.0)
9362 return d_right * reverse;
9365- (double)missileTrackPrimaryTarget:(
double)delta_t
9368 GLfloat d_forward, d_up, d_right;
9370 BOOL inPursuit = YES;
9372 if (!target || ![target
isShip])
9375 double damping = 0.5 * delta_t;
9386 float missileSpeed = (float)[
self speed];
9392 if (missileSpeed > 0.01f &&
accuracy > 0.0f) {
9396 float lead =
magnitude(relPos) / missileSpeed;
9400 relPos.
x += (lead * leading.
x * (
accuracy / 10.0f));
9401 relPos.
y += (lead * leading.
y * (
accuracy / 10.0f));
9402 relPos.
z += (lead * leading.
z * (
accuracy / 10.0f));
9454 if (d_forward < 0.0)
9459- (double)trackDestination:(
double)delta_t retreat:(BOOL)retreat
9462 GLfloat d_forward, d_up, d_right;
9470 double reverse = 1.0;
9471 double reversePlayer = 1.0;
9473 double min_d = 0.004;
9475 double precision = we_are_docking ? 0.25 : 0.9025;
9495 if (range2 > desired_range2) {
9496 max_cos = sqrt(1 - precision * desired_range2 / range2);
9497 if (max_cos >= 0.99999) {
9518 if (reverse * d_up > 0)
9526 if ((d_forward < max_cos) || (retreat))
9529 if (d_forward <= -max_cos || (retreat && d_forward >= max_cos))
9535 int factor = sqrt(fabs(d_right) / fabs(min_d));
9538 if (d_right > min_d)
9540 if (d_right < -min_d)
9542 if (fabs(d_right) < fabs(
stick_roll) * delta_t)
9546 if (d_up < -min_d) {
9547 int factor = sqrt(fabs(d_right) / fabs(min_d));
9550 if (d_right > min_d)
9552 if (d_right < -min_d)
9554 if (fabs(d_right) < fabs(
stick_roll) * delta_t)
9559 int factor = sqrt(fabs(d_up) / fabs(min_d));
9581 if ((station_for_docking) && (station_for_docking->
isStation)) {
9591 d_forward *= d_forward;
9593 if (d_forward < 0.0)
9602- (GLfloat)rollToMatchUp:(
Vector)up_vec rotating:(GLfloat)match_roll
9608 match_roll = -match_roll;
9609 sinTheta = -sinTheta;
9612 if (cosTheta < 0.0f) {
9613 cosTheta = -cosTheta;
9614 sinTheta = -sinTheta;
9617 if (sinTheta > 0.0f) {
9619 return cosTheta * cosTheta * match_roll + sinTheta * sinTheta *
max_flight_roll;
9622 return cosTheta * cosTheta * match_roll - sinTheta * sinTheta *
max_flight_roll;
9684 if (target ==
nil || [
self isDefenseTarget:target] || ![target
isShip]) {
9704 while ((target = [[defTargets nextObject] weakRefUnderlyingObject])) {
9705 if ([target
status] == STATUS_DEAD) {
9732- (double)rangeToSecondaryTarget:(
Entity*)target
9760- (BOOL)hasProximityAlertIgnoringTarget:(BOOL)ignore_target
9773 GLfloat best_cos = 0.99999;
9776 best_cos = 0.999999;
9778 basic_aim /= 1.0 + ((GLfloat)[
self missedShots] / 4.0);
9782 best_cos = 0.9999999;
9790 basic_aim *= 1.3 +
randf();
9799 GLfloat sunGlareAngularSize = atan([sun radius] /
HPdistance([
self position], [sun
position])) * SUN_GLARE_MULT_FACTOR + (SUN_GLARE_ADD_FACTOR);
9801 if (glareLevel > 0.1f) {
9803 basic_aim *= (1.0 + glareLevel * 3.0);
9805 if (glareLevel > 0.5f) {
9813 GLfloat max_cos = sqrt(1 - (basic_aim * basic_aim / 100000000.0));
9815 if (max_cos < best_cos) {
9822- (GLfloat)lookingAtSunWithThresholdAngleCos:(GLfloat)thresholdAngleCos
9825 GLfloat measuredCos = 999.0f, measuredCosAbs;
9826 GLfloat sunBrightness = 0.0f;
9850 measuredCosAbs = fabs(measuredCos);
9851 if (thresholdAngleCos <= measuredCosAbs && measuredCosAbs <= 1.0f)
9853 sunBrightness = (measuredCos - thresholdAngleCos) / (1.0f - thresholdAngleCos);
9854 if (sunBrightness < 0.0f)
9855 sunBrightness = 0.0f;
9857 return sunBrightness * sunBrightness * sunBrightness;
9865 GLfloat d2, radius, astq;
9867 if ([weapon_type isTurretLaser]) {
9874 if ([target
status] == STATUS_DEAD)
9885 switch (direction) {
9916 astq = sqrt(1.0 - radius * radius / (d2 * 9));
9918 return (fabs(dq) >= astq);
9924 switch (direction) {
9947 NSUInteger multiplier = 1;
9957 if (![weapon_type isTurretLaser]) {
9963 if (![
self onTarget:direction withWeapon:weapon_type])
9968 if ([weapon_type isTurretLaser]) {
9979 switch (direction) {
10005 if ([se fireSubentityLaserShot:range]) {
10018- (BOOL)fireMainWeapon:(
double)range
10035 BOOL hasTurrets = NO;
10036 while (
isWeaponNone(weapon_type) && (se = [subEnum nextObject])) {
10039 if (se->
behaviour == BEHAVIOUR_TRACK_AS_TURRET) {
10057- (BOOL)fireAftWeapon:(
double)range
10066- (BOOL)firePortWeapon:(
double)range
10075- (BOOL)fireStarboardWeapon:(
double)range
10094- (BOOL)fireTurretCannon:(
double)range
10118 while ((father) && (father != last) && (father !=
NO_TARGET)) {
10133 energy:weapon_damage
10134 duration:weaponRange / TURRET_SHOT_SPEED
10135 color:laser_color];
10137 [
shot autorelease];
10138 [UNIVERSE addEntity:shot];
10171- (BOOL)fireSubentityLaserShot:(
double)range
10180 NSAssert([parent isShipWithSubEntityShip:
self],
@"-fireSubentityLaserShot: called on ship which is not a subentity.");
10197 ShipEntity* victim = [UNIVERSE firstShipHitByLaserFromShip:
self inDirection:direction offset:kZeroVector gettingRangeFound:&hitAtRange];
10204 if (victim !=
nil) {
10208 [PLAYER addRoleForAggression:victim];
10221 [
shot setRange:hitAtRange];
10224 [UNIVERSE addLaserHitEffectsAt:flash_pos against:victim damage:weapon_damage color:laser_color];
10235 if (
dot_product(shotDirection, victimDirection) > 0.995)
10238 [PLAYER addRoleForAggression:victim];
10248 [UNIVERSE addEntity:shot];
10254- (BOOL)fireDirectLaserShot:(
double)range
10257 if (my_target ==
nil)
10270 while ((target = [[targetEnum nextObject] weakRefUnderlyingObject])) {
10288 GLfloat hit_at_range;
10296 GLfloat acc_factor = (10.0 -
accuracy) * 0.001;
10298 q_laser.
x += acc_factor * (
randf() - 0.5);
10299 q_laser.
y += acc_factor * (
randf() - 0.5);
10300 q_laser.
z += acc_factor * (
randf() - 0.5);
10306 ShipEntity* victim = [UNIVERSE firstShipHitByLaserFromShip:
self inDirection:WEAPON_FACING_FORWARD offset:kZeroVector gettingRangeFound:&hit_at_range];
10320 if (victim !=
nil) {
10328 if (hit_at_range * hit_at_range < range_limit2) {
10331 [
shot setRange:hit_at_range];
10334 [UNIVERSE addLaserHitEffectsAt:flash_pos against:victim damage:weapon_damage color:laser_color];
10338 [UNIVERSE addEntity:shot];
10347 NSArray* laserPortOffset =
nil;
10348 switch (direction) {
10366 return laserPortOffset;
10369- (BOOL)fireLaserShotInDirection:(
OOWeaponFacing)direction weaponIdentifier:(NSString*)weaponIdentifier
10372 GLfloat hit_at_range;
10373 NSUInteger i, barrels;
10379 NSMutableArray* shotEntities = [
NSMutableArray arrayWithCapacity:barrels];
10384 effective_damage /= (GLfloat)barrels;
10387 for (i = 0; i < barrels; i++) {
10392 ShipEntity* victim = [UNIVERSE firstShipHitByLaserFromShip:
self inDirection:direction offset:laserPortOffset gettingRangeFound:&hit_at_range];
10404 if (victim !=
nil) {
10407 [PLAYER addRoleForAggression:victim];
10425 if (hit_at_range * hit_at_range < range_limit2) {
10428 [
shot setRange:hit_at_range];
10431 [UNIVERSE addLaserHitEffectsAt:flash_pos against:victim damage:effective_damage color:laser_color];
10454 [PLAYER addRoleForAggression:victim];
10456 [
victim setPrimaryAggressor:
self];
10457 [
victim setFoundTarget:
self];
10458 [
victim reactToAIMessage:@"ATTACKER_MISSED" context:@"attacker narrowly misses"];
10459 [
victim doScriptEvent:OOJSID("shipBeingAttackedUnsuccessfully") withArgument:
self];
10465 [UNIVERSE addEntity:shot];
10477- (void)adjustMissedShots:(
int)delta
10509 float m = (w < h) ? 0.25 * w : 0.25 * h;
10519 duration:2.0 + 3.0 * randf()
10524 [UNIVERSE addEntity:spark];
10530- (void)considerFiringMissile:(
double)delta_t
10532 int missile_chance = 0;
10533 int rhs = 3.2 / delta_t;
10538 if (
missiles > missile_chance * hurt_factor) {
10552 start = [shipinfoDictionary oo_vectorForKey:@"missile_launch_position" defaultValue:start];
10557 if (start.
x == 0.0f && start.
y == 0.0f && start.
z <= 0.0f)
10559 OOLog(
@"ship.missileLaunch.invalidPosition",
@"***** ERROR: The missile_launch_position defines a position %@ behind the %@. In future versions such missiles may explode on launch because they have to travel through the ship.", VectorDescription(start),
self);
10587 double throw_speed = 250.0f;
10607 if (identifier ==
nil) {
10611 missile = [UNIVERSE newShipWithRole:identifier];
10620 missile = [UNIVERSE newShipWithRole:identifier];
10652 if ([missile
scanClass] == CLASS_THARGOID) {
10682 [UNIVERSE addEntity:missile];
10707- (void)setIsMissileFlag:(BOOL)newValue
10739 [UNIVERSE addEntity:ecmDevice];
10768 [
self setSpeed:maxFlightSpeed + 300];
10769 ShipEntity* bomb = [UNIVERSE newShipWithRole:@"energy-bomb"];
10779 double random_roll =
randf() - 0.5;
10780 double random_pitch =
randf() - 0.5;
10785 double eject_speed = -800.0;
10787 eject_speed *= 0.5 * (
randf() - 0.5);
10789 eject_speed *= 0.5 * (
randf() - 0.5);
10801 [UNIVERSE addEntity:bomb];
10821 unsigned n_pods, i;
10822 NSMutableArray* passengers =
nil;
10830 n_pods = [shipinfoDictionary oo_unsignedIntForKey:@"has_escape_pod"];
10839 for (i = 0; i < [crew count]; i++) {
10852 for (i = 1; i < n_pods; i++) {
10868 if (jetto !=
nil) {
10882 if (preferred ==
nil) {
10883 jetto = [[[cargo objectAtIndex:0] retain] autorelease];
10886 for (i = 0; i < [cargo count]; i++) {
10888 jetto = [[[cargo objectAtIndex:i] retain] autorelease];
10895 jetto = [[[cargo objectAtIndex:0] retain] autorelease];
10899 if (jetto !=
nil) {
10901 [cargo removeObjectAtIndex:i];
10921 ShipEntity* jetto = [UNIVERSE reifyCargoPod:cargoObj];
10930 double eject_reaction = -eject_speed * [
jetto mass] / [
self mass];
10934 Vector vel, v_eject, v_eject_normal;
10936 double jetto_roll = 0;
10937 double jetto_pitch = 0;
10945 start = [shipinfoDictionary oo_vectorForKey:@"aft_eject_position" defaultValue:start];
10957 v_eject_normal = v_eject;
10973 jetto_roll = ((
ranrot_rand() % 1024) - 512.0) / 1024.0;
10974 jetto_pitch = ((
ranrot_rand() % 1024) - 512.0) / 1024.0;
10984 [UNIVERSE addEntity:jetto];
10987 if ([jettoAI hasSuspendedStateMachines])
11009 ent = [[[collidingEntities objectAtIndex:0] retain] autorelease];
11010 [collidingEntities removeObjectAtIndex:0];
11016 [
self getDestroyedBy:ent damageType:[
ent isSun] ? kOODamageTypeHitASun : kOODamageTypeHitAPlanet];
11039 BOOL otherIsStation = other == [UNIVERSE station];
11044 if ([
self canScoop:other]) {
11048 if ([other canScoop:
self]) {
11049 [
other scoopIn:
self];
11068 if (otherParent !=
nil) {
11083 GLfloat v1a = sqrt(v2b * v2b * m2 / m1);
11098 dam1 = m2 * v2b * v2b / 50000000;
11099 dam2 = m1 * v2b * v2b / 50000000;
11112 if (otherParent !=
nil) {
11115 [
other adjustVelocity:vel2a];
11120 BOOL selfDestroyed = (dam1 >
energy);
11121 BOOL otherDestroyed = (dam2 > [
other energy]) && !otherIsStation;
11128 [
other adjustVelocity:vel2a];
11136 [
other takeScrapeDamage:dam2 from:
self];
11139 if (otherDestroyed)
11146 if (!selfDestroyed && !otherDestroyed) {
11147 float t = 10.0 * [UNIVERSE getTimeDelta];
11152 if (!otherIsStation) {
11162 [
other doScriptEvent:OOJSID("shipCollided") withArgument:
self andReactToAIMessage:@"COLLISION"];
11187- (void)addImpactMoment:(
Vector)moment fraction:(GLfloat)howmuch
11222 if ([
self status] == STATUS_BEING_SCOOPED)
11225 [
self setAITo:@"nullAI.plist"];
11238 if (other != scooper && (
id)
self == [scooper
primaryTarget]) {
11246 [
other getTractoredBy:
self];
11258- (void)scoopUpProcess:(
ShipEntity*)other processEvents:(BOOL)procEvents processMessages:(BOOL)procMessages
11274 co_type = [
other commodityType];
11275 co_amount = [
other commodityAmount];
11283 [
other doScriptEvent:OOJSID("shipWasScooped") withArgument:
self];
11287 co_type = [
other commodityType];
11288 co_amount = [
other commodityAmount];
11292 [UNIVERSE clearPreviousMessage];
11293 NSString* shipName = [
other displayName];
11294 [UNIVERSE addMessage:OOExpandKey(@"scripted-item-scooped", shipName) forCount:4];
11296 [
other setCommodityForPod:nil andAmount:0];
11316 if (co_type ==
nil && co_amount > 0) {
11317 co_type = [UNIVERSE getRandomCommodity];
11318 co_amount = [UNIVERSE getRandomAmountOfCommodity:co_type];
11321 if (co_amount > 0) {
11322 [
other setCommodity:co_type andAmount:co_amount];
11326 if ([other
crew]) {
11328 [UNIVERSE clearPreviousMessage];
11330 for (i = 0; i < [[
other crew] count]; i++) {
11334 [UNIVERSE addMessage:OOExpandKey(@"scoop-captured-character", characterName) forCount:4.5];
11335 }
else if ([rescuee insuranceCredits]) {
11336 [UNIVERSE addMessage:OOExpandKey(@"scoop-rescued-character", characterName) forCount:4.5];
11338 [UNIVERSE addMessage:DESC(@"scoop-got-slave") forCount:4.5];
11347 [UNIVERSE clearPreviousMessage];
11348 [UNIVERSE addMessage:[UNIVERSE describeCommodity:co_type amount:co_amount] forCount:4.5];
11352 [cargo insertObject:other atIndex:0];
11354 [
other performTumble];
11365 if ([other
status] != STATUS_IN_HOLD) {
11366 if ([
cargo containsObject:other]) {
11367 [cargo removeObject:other];
11387 [UNIVERSE removeEntity:other];
11390- (BOOL)cascadeIfAppropriateWithDamageAmount:(
double)amount cascadeOwner:(
Entity*)owner
11394 case CLASS_WORMHOLE:
11397 case CLASS_VISUAL_EFFECT:
11405 case CLASS_STATION:
11409 case CLASS_MILITARY:
11410 case CLASS_THARGOID:
11411 case CLASS_MISSILE:
11412 case CLASS_NOT_SET:
11413 case CLASS_NO_DRAW:
11414 case CLASS_NEUTRAL:
11417 if (energy < amount && energy > 10 && [
self countsAsKill]) {
11427- (void)takeEnergyDamage:(
double)amount from:(
Entity*)ent becauseOf:(
Entity*)other weaponIdentifier:(NSString*)weaponIdentifier
11429 if ([
self status] == STATUS_DEAD)
11459 if ((other) && ([other
isShip])) {
11463 if (hunter !=
nil && [
self owner] != hunter)
11477 if (hunter !=
nil) {
11501 if (groupLeader !=
self) {
11509 NSEnumerator* groupEnum =
nil;
11512 for (groupEnum = [
group mutationSafeEnumerator]; (otherPirate = [
groupEnum nextObject]);) {
11513 if (otherPirate !=
self &&
randf() < 0.5)
11520 }
else if (iAmTheLaw) {
11521 NSEnumerator* groupEnum =
nil;
11524 for (groupEnum = [
group mutationSafeEnumerator]; (otherPolice = [
groupEnum nextObject]);) {
11525 if (otherPolice !=
self) {
11536 if (iAmTheLaw && !uAreTheLaw) {
11545 if ([hunter
behaviour] == BEHAVIOUR_ATTACK_FLY_TO_TARGET)
11555 damageType = kOODamageTypeRemoved;
11556 else if (energyMine)
11557 damageType = kOODamageTypeCascadeWeapon;
11589 OOLog(
@"ShipEntity.abandonShip.failed",
@"%@",
@"Player cannot abandon ship while docked.");
11594 OOLog(
@"ShipEntity.abandonShip.failed",
@"Ship abandonment was requested for %@, but this ship does not carry escape pod(s).",
self);
11603 while ([
self hasEquipmentItemProviding:
@"EQ_ESCAPE_POD"]) {
11606 [
self setAITo:@"nullAI.plist"];
11620 NSEnumerator* escortEnum =
nil;
11627 if ([escort
owner] ==
self)
11639 while ([
self hasEquipmentItemProviding:
@"EQ_ESCAPE_POD"]) {
11645 OOLog(
@"ShipEntity.abandonShip.notPossible",
@"Ship %@ cannot be abandoned at this time.",
self);
11650- (void)takeScrapeDamage:(
double)amount from:(
Entity*)ent
11652 if ([
self status] == STATUS_DEAD)
11655 if ([
self status] == STATUS_LAUNCHING || [ent
status] == STATUS_LAUNCHING) {
11665 float frag_chance = [
ent mass] * 10 / [
self mass];
11672 if (
randf() < frag_chance) {
11687- (void)takeHeatDamage:(
double)amount
11689 if ([
self status] == STATUS_DEAD)
11719 [dockingInstructions autorelease];
11727 [UNIVERSE removeEntity:
self];
11733 if (station ==
nil)
11748 if ([
self status] == STATUS_ENTERING_WITCHSPACE) {
11776 [UNIVERSE addWitchspaceJumpEffectForShip:
self];
11779 if (![[
UNIVERSE sun] willGoNova]) {
11781 [UNIVERSE witchspaceShipWithPrimaryRole:[
self primaryRole]];
11784 [UNIVERSE removeEntity:
self];
11794 GLfloat min_d1 = [UNIVERSE safeWitchspaceExitDistance];
11796 while (fabs(d1) < min_d1) {
11801 HPVector exitposition = [UNIVERSE getWitchspaceExitPosition];
11802 exitposition.
x += v1.
x * d1;
11803 exitposition.
y += v1.
y * d1;
11804 exitposition.
z += v1.
z * d1;
11812 orientation = [UNIVERSE getWitchspaceExitRotation];
11828 [
self setStatus:STATUS_EXITING_WITCHSPACE];
11831 [UNIVERSE addWitchspaceJumpEffectForShip:
self];
11836- (void)markAsOffender:(
int)offence_value
11847 if ((
scanClass == CLASS_THARGOID ||
scanClass == CLASS_STATION) && reason != kOOLegalStatusReasonSetup && reason != kOOLegalStatusReasonByScript) {
11855 bounty |= offence_value;
11859 ShipScriptEvent(context,
self,
"shipBountyChanged", amountVal, reasonVal);
11875 [
se setActive:YES];
11924 if ([
self bounty] == 0 && [potentialEscort
bounty] != 0)
11938 if (
self == other_ship)
11942 if ([
self status] != STATUS_IN_FLIGHT)
11947 if ([
shipAI stackDepth] > 3) {
11948 OOLog(
@"ship.escort.reject",
@"%@ rejecting escort %@ because AI stack depth is %zu.",
self, other_ship, [
shipAI stackDepth]);
11952 if ([
self canAcceptEscort:other_ship]) {
11960 if (
_maxEscortCount == 0 && ([
self hasPrimaryRole:
@"police"] || [
self hasPrimaryRole:
@"hunter"] || [
self hasRole:
@"thargoid-mothership"])) {
11978 OOLog(
@"ship.escort.accept",
@"%@ accepting escort %@.",
self, other_ship);
11981 [
other_ship doScriptEvent:OOJSID("escortAccepted") withArgument:
self];
11985 OOLog(
@"ship.escort.reject",
@"%@ already got max escorts(%zu). Escort rejected: %@.",
self,
escortCount, other_ship);
11988 OOLog(
@"ship.escort.reject",
@"%@ failed canAcceptEscort for escort %@.",
self, other_ship);
12007 if (!_escortPositionsValid) {
12014 _escortPositionsValid = YES;
12017 for (i = 0; i < _maxEscortCount; i++) {
12020 OK = [
script callMethod:OOJSID("coordinatesForEscortPosition")
12023 count:sizeof args / sizeof *args
12060 NSMutableSet* idleEscorts =
nil;
12061 unsigned deployCount;
12084 if (![[[escort
getAI]
name] isEqualToString:
@"interceptAI.plist"] && ![escort
hasNewAI]) {
12100 foreach (escort, idleEscorts) {
12105 if (--deployCount == 0)
12124 float delay = i++ * 3.0 + 1.5;
12130 if ([escort
owner] ==
self)
12147- (void)setTargetToNearestStationIncludingHostiles:(BOOL)includeHostiles
12160 int ent_count =
UNIVERSE->n_entities;
12164 int station_count = 0;
12165 for (i = 0; i < ent_count; i++)
12171 for (i = 0; i < station_count; i++) {
12174 if (range2 < nearest2 && (includeHostiles || ![thing isHostileTo:
self])) {
12179 for (i = 0; i < station_count; i++)
12180 [my_entities[i] release];
12207 if (!system_station) {
12231 [
planet welcomeShuttle:
self];
12237 OOLog(
@"planet.collide.shuttleLanded",
@"DEBUG: %@ landed on planet %@",
self, planet);
12241 [UNIVERSE removeEntity:
self];
12247 [[UNIVERSE findEntitiesMatchingPredicate:IsStationPredicate
12251 makeObjectsPerformSelector:@selector(abortDockingForShip:)
12262 [[UNIVERSE findShipsMatchingPredicate:HasRolePredicate
12263 parameter:@"tharglet"
12264 inRange:SCANNER_MAX_RANGE
12266 makeObjectsPerformSelector:@selector(sendAIMessage:)
12267 withObject:@"THARGOID_DESTROYED"];
12295 if (!aggressor_ship)
12300 NSArray* authorities =
nil;
12303 authorities = [UNIVERSE findShipsMatchingPredicate:AuthorityPredicate
12307 foreach (auth, authorities) {
12315- (void)sendMessage:(NSString*)message_text toShip:(
ShipEntity*)other_ship withUnpilotedOverride:(BOOL)unpilotedOverride
12317 if (!other_ship || !message_text)
12319 if (!
crew && !unpilotedOverride)
12326 NSString* expandedMessage =
OOExpand(message_text);
12332 [UNIVERSE resetCommsLogColor];
12337- (void)sendExpandedMessage:(NSString*)message_text toShip:(
ShipEntity*)other_ship
12339 if (!other_ship || !
crew)
12343 [lastRadioMessage autorelease];
12353 very_random_seed.
a = rand() & 255;
12354 very_random_seed.
b = rand() & 255;
12355 very_random_seed.
c = rand() & 255;
12356 very_random_seed.
d = rand() & 255;
12357 very_random_seed.
e = rand() & 255;
12358 very_random_seed.
f = rand() & 255;
12361 NSDictionary* specials = [
NSDictionary dictionaryWithObjectsAndKeys:
12370- (void)broadcastAIMessage:(NSString*)ai_message
12372 NSString* expandedMessage =
OOExpand(ai_message);
12382- (void)broadcastMessage:(NSString*)message_text withUnpilotedOverride:(BOOL)unpilotedOverride
12384 NSString* expandedMessage =
OOExpand(message_text);
12386 if (!
crew && !unpilotedOverride)
12404 [UNIVERSE resetCommsLogColor];
12418- (void)receiveCommsMessage:(NSString*)message_text from:(
ShipEntity*)other
12424- (void)commsMessage:(NSString*)valueString withUnpilotedOverride:(BOOL)unpilotedOverride
12427 very_random_seed.
a = rand() & 255;
12428 very_random_seed.
b = rand() & 255;
12429 very_random_seed.
c = rand() & 255;
12430 very_random_seed.
d = rand() & 255;
12431 very_random_seed.
e = rand() & 255;
12432 very_random_seed.
f = rand() & 255;
12456- (void)interpretAIMessage:(NSString*)ms
12462 int switcher_id = [(
NSString*)[
tokens objectAtIndex:1] intValue];
12463 Entity* switcher = [UNIVERSE entityForUniversalID:switcher_id];
12464 int rescuer_id = [(
NSString*)[
tokens objectAtIndex:2] intValue];
12465 Entity* rescuer = [UNIVERSE entityForUniversalID:rescuer_id];
12487- (void)spawn:(NSString*)roles_number
12490 NSString* roleString =
nil;
12491 NSString* numberString =
nil;
12494 if ([tokens
count] != 2) {
12499 roleString = [
tokens oo_stringAtIndex:0];
12500 numberString = [
tokens oo_stringAtIndex:1];
12522 int ent_count =
UNIVERSE->n_entities;
12527 int ship_count = 0;
12528 for (i = 0; i < ent_count; i++)
12529 if ((uni_entities[i]->
isShip) && (uni_entities[i] !=
self))
12532 for (i = 0; (i < ship_count) && (result ==
NO_TARGET); i++) {
12541 for (i = 0; i < ship_count; i++)
12542 [my_entities[i] release];
12552- (void)setTrackCloseContacts:(BOOL)value
12558 [closeContactsInfo release];
12567#if OO_SALVAGE_SUPPORT
12569- (void)claimAsSalvage
12573 OOLog(
@"claimAsSalvage.called",
@"claimAsSalvage called on %@ %@", [
self name], [
self roleSet]);
12576 if (![
self isHulk]) {
12577 OOLog(
@"claimAsSalvage.failed.notHulk",
@"claimAsSalvage failed because not a hulk");
12582 [
self setTargetToSystemStation];
12583 if ([
self primaryTarget] ==
nil) {
12584 OOLog(
@"claimAsSalvage.failed.noStation",
@"claimAsSalvage failed because did not find a station");
12589 StationEntity* station = (StationEntity*)[
self primaryTarget];
12590 OOLog(
@"claimAsSalvage.requestingPilot",
@"claimAsSalvage asking station to launch a pilot boat");
12592 [
self setReportAIMessages:YES];
12593 OOLog(
@"claimAsSalvage.success",
@"claimAsSalvage setting own state machine to capturedShipAI.plist");
12594 [
self setAITo:@"capturedShipAI.plist"];
12597- (void)sendCoordinatesToPilot
12600 ShipEntity *scanShip, *pilot;
12602 n_scanned_ships = 0;
12604 OOLog(
@"ship.pilotage",
@"searching for pilot boat");
12605 while (scan && (scan->
isShip == NO)) {
12612 scanShip = (ShipEntity*)scan;
12614 if ([
self hasRole:
@"pilot"] == YES) {
12615 if ([scanShip primaryTarget] ==
nil) {
12616 OOLog(
@"ship.pilotage",
@"found pilot boat with no target, will use this one");
12624 while (scan && (scan->
isShip == NO)) {
12629 if (pilot !=
nil) {
12630 OOLog(
@"ship.pilotage",
@"becoming pilot target and setting AI");
12633 [pilot
setAITo:@"pilotAI.plist"];
12634 [
self reactToAIMessage:@"FOUND_PILOT" context:@"flight update"];
12638- (void)pilotArrived
12641 [
self reactToAIMessage:@"PILOT_ARRIVED" context:@"flight update"];
12645#ifdef OO_DEBUG_MONITOR_ENABLED
12646- (void)dumpSelfState
12648 NSMutableArray* flags =
nil;
12649 NSString* flagsString =
nil;
12651 [
super dumpSelfState];
12653 OOLog(
@"dumpState.shipEntity",
@"Type: %@", [
self shipDataKey]);
12654 OOLog(
@"dumpState.shipEntity",
@"Name: %@", name);
12655 OOLog(
@"dumpState.shipEntity",
@"Display Name: %@", [
self displayName]);
12656 OOLog(
@"dumpState.shipEntity",
@"Roles: %@", [
self roleSet]);
12657 OOLog(
@"dumpState.shipEntity",
@"Primary role: %@", primaryRole);
12658 OOLog(
@"dumpState.shipEntity",
@"Script: %@", script);
12659 OOLog(
@"dumpState.shipEntity",
@"Subentity count: %zu", [
self subEntityCount]);
12661 id target = [
self primaryTarget];
12663 target =
@"<none>";
12664 OOLog(
@"dumpState.shipEntity",
@"Target: %@", target);
12665 OOLog(
@"dumpState.shipEntity",
@"Destination: %@", HPVectorDescription(_destination));
12666 OOLog(
@"dumpState.shipEntity",
@"Other destination: %@", HPVectorDescription(coordinates));
12667 OOLog(
@"dumpState.shipEntity",
@"Waypoint count: %u", number_of_navpoints);
12668 OOLog(
@"dumpState.shipEntity",
@"Desired speed: %g", desired_speed);
12669 OOLog(
@"dumpState.shipEntity",
@"Thrust: %g", thrust);
12670 if ([
self escortCount] != 0)
12671 OOLog(
@"dumpState.shipEntity",
@"Escort count: %u", [
self escortCount]);
12672 OOLog(
@"dumpState.shipEntity",
@"Fuel: %i", fuel);
12673 OOLog(
@"dumpState.shipEntity",
@"Fuel accumulator: %g", fuel_accumulator);
12674 OOLog(
@"dumpState.shipEntity",
@"Missile count: %u", missiles);
12677 OOLog(
@"dumpState.shipEntity.ai",
@"%@",
@"AI:");
12681 [shipAI dumpState];
12683 @catch (
id exception) {
12687 OOLog(
@"dumpState.shipEntity",
@"Accuracy: %g", accuracy);
12688 OOLog(
@"dumpState.shipEntity",
@"Jink position: %@", VectorDescription(jink));
12689 OOLog(
@"dumpState.shipEntity",
@"Frustration: %g", frustration);
12690 OOLog(
@"dumpState.shipEntity",
@"Success factor: %g", success_factor);
12691 OOLog(
@"dumpState.shipEntity",
@"Shots fired: %u", shot_counter);
12692 OOLog(
@"dumpState.shipEntity",
@"Time since shot: %g", [
self shotTime]);
12693 OOLog(
@"dumpState.shipEntity",
@"Spawn time: %g (%g seconds ago)", [
self spawnTime], [
self timeElapsedSinceSpawn]);
12694 if ([
self isBeacon]) {
12695 OOLog(
@"dumpState.shipEntity",
@"Beacon code: %@", [
self beaconCode]);
12697 OOLog(
@"dumpState.shipEntity",
@"Hull temperature: %g", ship_temperature);
12698 OOLog(
@"dumpState.shipEntity",
@"Heat insulation: %g", [
self heatInsulation]);
12700 flags = [NSMutableArray array];
12701#define ADD_FLAG_IF_SET(x) \
12703 [flags addObject:@ #x]; \
12718 flagsString = [flags count] ? [flags componentsJoinedByString:@", "] : (NSString*)
@"none";
12719 OOLog(
@"dumpState.shipEntity",
@"Flags: %@", flagsString);
12733- (void)overrideScriptInfo:(NSDictionary*)override
12737 else if (
override !=
nil) {
12738 NSMutableDictionary* newInfo = [
NSMutableDictionary dictionaryWithDictionary:scriptInfo];
12739 [
newInfo addEntriesFromDictionary:override];
12740 [scriptInfo release];
12794 withArgument:(
id)argument1
12795 andArgument:(
id)argument2
12807- (void)doScriptEvent:(
OOJSPropID)message withArguments:(NSArray*)arguments
12816 argv = malloc(
sizeof *argv * argc);
12817 if (argv != NULL) {
12818 for (i = 0; i != argc; ++i) {
12819 argv[
i] = [[
arguments objectAtIndex:i] oo_jsValueInContext:context];
12831 if (argv != NULL) {
12832 for (i = 0; i != argc; ++i) {
12836 JS_RemoveValueRoot(context, &argv[i]);
12852- (void)doScriptEvent:(
OOJSPropID)message inContext:(JSContext*)context withArguments:(
OOJSVal*)argv count:(
int)argc
12859- (void)reactToAIMessage:(NSString*)message context:(NSString*)debugContext
12864- (void)sendAIMessage:(NSString*)message
12869- (void)doScriptEvent:(
OOJSPropID)scriptEvent andReactToAIMessage:(NSString*)aiMessage
12875- (void)doScriptEvent:(
OOJSPropID)scriptEvent withArgument:(
id)argument andReactToAIMessage:(NSString*)aiMessage
12885 if ([
self status] == STATUS_DOCKED) {
12896 if ([
self status] == STATUS_DOCKED) {
12906 foreach (ship, sEnum) {
12916 if (ptarget !=
nil && [ptarget
isShip]) {
12927 while ((ship = [sEnum nextObject])) {
12937 while ((ship = [sEnum nextObject])) {
12954#ifdef OO_DEBUG_MONITOR_ENABLED
12955- (NSString*)descriptionForObjDump
12957 NSString* desc = [
super descriptionForObjDump];
12958 desc = [NSString stringWithFormat:@"%@ mass %g", desc, [
self mass]];
12959 if (![
self isPlayer]) {
12960 desc = [NSString stringWithFormat:@"%@ AI: %@", desc, [[
self getAI] shortDescriptionComponents]];
12968@implementation Entity (SubEntityRelationship)
12975- (void)drawSubEntityImmediate:(
bool)immediate translucent:(
bool)translucent
12982@implementation ShipEntity (SubEntityRelationship)
12986 assert([
self isShip]);
12988 if (![other isShip])
12990 if (![other isSubEntity])
12992 if ([other owner] !=
self)
12997 if (![
self hasSubEntity:(
ShipEntity*)other]) {
12998 OOLogERR(
@"ship.subentity.sanityCheck.failed",
@"%@ thinks it's a subentity of %@, but the supposed parent does not agree. %@", [other shortDescription], [
self shortDescription],
@"This is an internal error, please report it.");
13011 static NSDictionary* macros =
nil;
13013 if (macros ==
nil) {
13023 static NSSet* entityWhitelist =
nil;
13024 static NSSet* shipWhitelist =
nil;
13025 static NSSet* playerShipWhitelist =
nil;
13026 static NSSet* visualEffectWhitelist =
nil;
13028 if (entityWhitelist ==
nil) {
13030 entityWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_entity_binding_methods"]];
13031 shipWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_ship_binding_methods"]];
13032 playerShipWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_player_ship_binding_methods"]];
13033 visualEffectWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_visual_effect_binding_methods"]];
13036 if ([bindingTarget isKindOfClass:[
Entity class]]) {
13037 if ([entityWhitelist containsObject:propertyName])
13039 if ([bindingTarget isShip]) {
13040 if ([shipWhitelist containsObject:propertyName])
13043 if ([bindingTarget isPlayerLikeShip]) {
13044 if ([playerShipWhitelist containsObject:propertyName])
13047 if ([bindingTarget isVisualEffect]) {
13048 if ([visualEffectWhitelist containsObject:propertyName])
13063 return weapon ==
nil || [[weapon
identifier] isEqualToString:@"EQ_WEAPON_NONE"];
#define NO_DRAW_DISTANCE_FACTOR
OOScanClass OOScanClassFromString(NSString *string) PURE_FUNC
#define SCANNER_MAX_RANGE
#define SCANNER_MAX_RANGE2
#define ADD_FLAG_IF_SET(x)
OOINLINE void bounding_box_add_vector(BoundingBox *box, Vector vec) ALWAYS_INLINE_FUNC NONNULL_FUNC
Vector OORandomPositionInBoundingBox(BoundingBox bb)
OOINLINE jsval OOJSValueFromLegalStatusReason(JSContext *context, OOLegalStatusReason value)
OOINLINE jsval OOJSValueFromShipDamageType(JSContext *context, OOShipDamageType value)
OOCargoType StringToCargoType(NSString *string) PURE_FUNC
NSString * OOStringFromLegalStatusReason(OOLegalStatusReason reason)
#define OODebugDrawBoundingBox(box)
void OOStandardsDeprecated(NSString *message)
BOOL OOEnforceStandards(void)
OOINLINE float OOLerp(float v0, float v1, float fraction) INLINE_CONST_FUNC
OOINLINE float OOClamp_0_max_f(float value, float max) INLINE_CONST_FUNC
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
#define foreachkey(VAR, DICT)
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdot_product(HPVector first, HPVector second) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_subtract(HPVector a, HPVector b) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_multiply_scalar(HPVector v, OOHPScalar s) INLINE_CONST_FUNC
const HPVector kZeroHPVector
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
OOINLINE Vector HPVectorToVector(HPVector v) INLINE_CONST_FUNC
OOINLINE HPVector make_HPvector(OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal(HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_normal_or_zbasis(HPVector vec) INLINE_CONST_FUNC
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
HPVector OOHPVectorRandomSpatial(OOHPScalar maxLength)
#define HPvector_between(a, b)
OOINLINE OOHPScalar HPmagnitude2(HPVector vec) INLINE_CONST_FUNC
OOINLINE OOHPScalar HPdistance(HPVector v1, HPVector v2) INLINE_CONST_FUNC
OOINLINE HPVector OOHPVectorInterpolate(HPVector a, HPVector b, OOHPScalar where) INLINE_CONST_FUNC
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
BOOL JSValueToVector(JSContext *context, jsval value, Vector *outVector) NONNULL_FUNC
OOINLINE jsval OOJSValueFromDouble(JSContext *context, double value)
#define OOJSFreeValue(context, value)
#define OOJSUndefinedValue()
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
id OOJSNativeObjectFromJSObject(JSContext *context, JSObject *object)
OOINLINE BOOL OOJSValueToBOOL(JSContext *context, jsval value)
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
#define OOJSAddGCValueRoot(context, root, name)
void OOLogPushIndent(void)
#define OOLogWARN(class, format,...)
#define OOLogERR(class, format,...)
void OOLogPopIndent(void)
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
#define OOLog(class, format,...)
const OOMatrix kIdentityMatrix
HPVector OOHPVectorMultiplyMatrix(HPVector v, OOMatrix m) CONST_FUNC
Vector OOVectorMultiplyMatrix(Vector v, OOMatrix m) CONST_FUNC
void OOGLPushModelView(void)
void OOGLTranslateModelView(Vector vector)
void OOGLMultModelView(OOMatrix matrix)
OOMatrix OOGLPopModelView(void)
#define OOVerifyOpenGLState()
Quaternion quaternion_rotation_between(Vector v0, Vector v1) CONST_FUNC
OOINLINE bool quaternion_equal(Quaternion a, Quaternion b) INLINE_CONST_FUNC
void quaternion_rotate_about_x(Quaternion *quat, OOScalar angle) NONNULL_FUNC
Vector vector_forward_from_quaternion(Quaternion quat) CONST_FUNC
Vector quaternion_rotate_vector(Quaternion q, Vector vector) CONST_FUNC
OOINLINE Quaternion make_quaternion(OOScalar qw, OOScalar qx, OOScalar qy, OOScalar qz) INLINE_CONST_FUNC
OOINLINE Quaternion quaternion_conjugate(Quaternion q) INLINE_CONST_FUNC
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle) NONNULL_FUNC
const Quaternion kIdentityQuaternion
void quaternion_rotate_about_z(Quaternion *quat, OOScalar angle) NONNULL_FUNC
Quaternion quaternion_multiply(Quaternion q1, Quaternion q2) CONST_FUNC
OOINLINE void quaternion_normalize(Quaternion *quat) NONNULL_FUNC ALWAYS_INLINE_FUNC
Vector vector_up_from_quaternion(Quaternion quat) CONST_FUNC
void quaternion_rotate_about_y(Quaternion *quat, OOScalar angle) NONNULL_FUNC
const Quaternion kZeroQuaternion
void quaternion_set_random(Quaternion *quat) NONNULL_FUNC
Vector vector_right_from_quaternion(Quaternion quat) CONST_FUNC
@ STELLAR_TYPE_NORMAL_PLANET
Random_Seed OOStringExpanderDefaultRandomSeed(void)
NSString * OOExpandDescriptionString(Random_Seed seed, NSString *string, NSDictionary *overrides, NSDictionary *legacyLocals, NSString *systemName, OOExpandOptions options)
#define OOExpand(string,...)
NSMutableArray * ScanTokensFromString(NSString *values)
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
OOINLINE Vector resolveVectorInIJK(Vector v0, Triangle ijk)
uint8_t OOWeaponFacingSet
NSString * OOCommodityType
@ AEGIS_CLOSE_TO_MAIN_PLANET
@ AEGIS_CLOSE_TO_ANY_PLANET
uint64_t OOCreditsQuantity
#define VALID_WEAPON_FACINGS
@ CARGO_FLAG_FULL_CONTRABAND
@ CARGO_FLAG_FULL_PLENTIFUL
@ CARGO_FLAG_FULL_UNIFORM
@ CARGO_FLAG_FULL_MEDICAL
@ CARGO_FLAG_FULL_PASSENGERS
@ WEAPON_FACING_STARBOARD
OOINLINE Vector vector_add(Vector a, Vector b) INLINE_CONST_FUNC
#define vector_between(a, b)
OOINLINE Vector vector_subtract(Vector a, Vector b) INLINE_CONST_FUNC
OOINLINE OOScalar magnitude(Vector vec) INLINE_CONST_FUNC
OOINLINE Vector vector_normal_or_zbasis(Vector vec) INLINE_CONST_FUNC
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
OOINLINE OOScalar dot_product(Vector first, Vector second) INLINE_CONST_FUNC
OOINLINE Vector vector_normal_or_fallback(Vector vec, Vector fallback) INLINE_CONST_FUNC
OOINLINE bool vector_equal(Vector a, Vector b) INLINE_CONST_FUNC
const Vector kBasisYVector
OOINLINE Vector cross_product(Vector first, Vector second) INLINE_CONST_FUNC
OOINLINE void scale_vector(Vector *outVector, OOScalar factor) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE OOScalar magnitude2(Vector vec) INLINE_CONST_FUNC
const Vector kBasisZVector
const Vector kBasisXVector
OOINLINE OOScalar distance(Vector v1, Vector v2) INLINE_CONST_FUNC
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
OOINLINE Vector vector_normal(Vector vec) INLINE_CONST_FUNC
static GLfloat scripted_color[4]
static BOOL isHitByOctree(Octree_details axialDetails, Octree_details otherDetails, Vector delta, Triangle other_ijk)
static NSString *const kOOLogSyntaxAddShips
#define HYPERSPEED_FACTOR
@ SCOOP_STATUS_NOT_INSTALLED
#define MIN_HYPERSPEED_FACTOR
#define INITIAL_SHOT_TIME
#define COMBAT_BROADSIDE_IN_RANGE_FACTOR
OOEquipmentType * OOWeaponType
BOOL isWeaponNone(OOWeaponType weapon)
#define COMBAT_AI_TRACKS_CLOSER
#define SHIP_COOLING_FACTOR
#define CLOAKING_DEVICE_MIN_ENERGY
#define COMBAT_AI_WEAPON_TEMP_READY
OOWeaponType OOWeaponTypeFromEquipmentIdentifierStrict(NSString *string) PURE_FUNC
#define COMBAT_BROADSIDE_RANGE_FACTOR
#define COMBAT_AI_WEAPON_TEMP_USABLE
#define TURRET_SHOT_RANGE
#define COMBAT_AI_ISNT_AWFUL
#define TURRET_MINIMUM_COS
NSDictionary * OODefaultShipShaderMacros(void)
#define SHIP_MIN_CABIN_TEMP
#define CLOAKING_DEVICE_START_ENERGY
#define NPC_MAX_WEAPON_TEMP
#define COMBAT_AI_FLEES_BETTER_2
#define MILITARY_JAMMER_ENERGY_RATE
#define CLOAKING_DEVICE_ENERGY_RATE
#define AIMS_AGGRESSOR_SWITCHED_TARGET
#define COMBAT_AI_DOGFIGHTER
#define WEAPON_COOLING_FACTOR
#define ENTITY_PERSONALITY_MAX
GLfloat getWeaponRangeFromType(OOWeaponType weapon_type)
#define SHIP_MAX_CABIN_TEMP
#define MILITARY_JAMMER_MIN_ENERGY
#define COMBAT_AI_FLEES_BETTER
#define TURRET_SHOT_SPEED
#define COMBAT_IN_RANGE_FACTOR
#define COMBAT_OUT_RANGE_FACTOR
#define COMBAT_WEAPON_RANGE_FACTOR
#define COMBAT_AI_CONFIDENCE_FACTOR
#define COMBAT_AI_IS_SMART
NSString * OOStringFromBehaviour(OOBehaviour behaviour) CONST_FUNC
OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC
#define BASELINE_SHIELD_LEVEL
#define SHIPENTITY_MAX_MISSILES
#define MAX_LANDING_SPEED2
#define SHIP_THRUST_FACTOR
OOWeaponType OOWeaponTypeFromString(NSString *string) PURE_FUNC
#define ShipScriptEvent(context, ship, event,...)
#define WEAPON_COOLING_CUTOUT
#define SHIP_INSULATION_FACTOR
#define SHIP_ENERGY_DAMAGE_TO_HEAT_FACTOR
static ShipEntity * doOctreesCollide(ShipEntity *prime, ShipEntity *other)
static GLfloat mascem_color1[4]
static GLfloat neutral_color[4]
static GLfloat cargo_color[4]
static GLfloat hostile_color[4]
static GLfloat missile_color[4]
static GLfloat police_color1[4]
BOOL OOUniformBindingPermitted(NSString *propertyName, id bindingTarget)
static GLfloat mascem_color2[4]
static GLfloat calcFuelChargeRate(GLfloat myMass)
static GLfloat jammed_color[4]
static GLfloat friendly_color[4]
static GLfloat police_color2[4]
#define PROXIMITY_AVOID_DISTANCE_FACTOR
Entity< OOStellarBody > * lastAegisLock()
void refreshEscortPositions()
void setOwner:(ShipEntity *ship)
void exitStateMachineWithMessage:(NSString *message)
void message:(NSString *ms)
void setState:afterDelay:(NSString *stateName,[afterDelay] NSTimeInterval delay)
void setState:(NSString *stateName)
void reactToMessage:context:(NSString *message,[context] NSString *debugContext)
void setDimensionsAndCorridor:ddc:launching:(BOOL docking,[ddc] BOOL ddc,[launching] BOOL launching)
BOOL validForAddToUniverse()
void wasAddedToUniverse()
OOUniversalID universalID
HPVector absolutePositionForSubentity()
NSMutableArray * collisionArray()
NSMutableArray * collidingEntities
void setVelocity:(Vector vel)
void moveForward:(double amount)
void setOrientation:(Quaternion quat)
void update:(OOTimeDelta delta_t)
GLfloat collisionRadius()
void setOwner:(Entity *ent)
void orientationChanged()
void setScanClass:(OOScanClass sClass)
void drawSubEntityImmediate:translucent:(bool immediate, [translucent] bool translucent)
void setDistanceTravelled:(GLfloat value)
GLfloat cam_zero_distance
GLfloat distanceTravelled
NSString * descriptionComponents()
ShipEntity * rootShipEntity()
void setEnergy:(GLfloat amount)
Quaternion normalOrientation()
ShipEntity * parentEntity()
void takeEnergyDamage:from:becauseOf:weaponIdentifier:(double amount,[from] Entity *ent,[becauseOf] Entity *other,[weaponIdentifier] NSString *weaponIdentifier)
Vector vectorTo:(Entity *entity)
Vector relativePosition()
void setStatus:(OOEntityStatus stat)
void setPosition:(HPVector posn)
OOMatrix drawRotationMatrix()
id fragmentBurstFromEntity:(Entity *entity)
OOCharacter * characterWithDictionary:(NSDictionary *c_dict)
void setLegalStatus:(int value)
NSDictionary * infoForScripting()
OOCharacter * randomCharacterWithRole:andOriginalSystem:(NSString *c_role,[andOriginalSystem] OOSystemID s)
OOColor * colorWithRGBAComponents:(OORGBAComponents components)
OOColor * brightColorWithDescription:(id description)
OOColor * colorWithDescription:(id description)
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
OOColor * colorWithHue:saturation:brightness:alpha:(float hue,[saturation] float saturation,[brightness] float brightness,[alpha] float alpha)
void setBindingTarget:(id< OOWeakReferenceSupport > target)
double findCollisionRadius()
void setDrawable:(OODrawable *drawable)
void drawImmediate:translucent:(bool immediate, [translucent] bool translucent)
NSString * conditionScript()
GLfloat weaponEnergyUse()
GLfloat weaponShotTemperature()
void addEquipmentWithInfo:(NSArray *itemInfo)
void setMissileRegistryRole:forShip:(NSString *roles,[forShip] NSString *shipKey)
OOCargoQuantity requiredCargoSpace()
NSString * getMissileRegistryRoleForShip:(NSString *shipKey)
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)
NSArray * allEquipmentTypes()
GLfloat weaponRechargeRate()
double findCollisionRadius()
id exhaustForShip:withDefinition:andScale:(ShipEntity *ship,[withDefinition] NSArray *definition,[andScale] float scale)
instancetype explosionCloudFromEntity:withSettings:(Entity *entity,[withSettings] NSDictionary *settings)
instancetype explosionCloudFromEntity:withSize:andSettings:(Entity *entity,[withSize] float size,[andSettings] NSDictionary *settings)
instancetype explosionFlashFromEntity:(Entity *entity)
instancetype flasherWithDictionary:(NSDictionary *dictionary)
void rescaleBy:(GLfloat factor)
BOOL callMethod:inContext:withArguments:count:result:(jsid methodID,[inContext] JSContext *context,[withArguments] jsval *argv,[count] intN argc,[result] jsval *outResult)
instancetype laserFromShip:direction:offset:(ShipEntity *ship,[direction] OOWeaponFacing direction,[offset] Vector offset)
void setColor:(OOColor *color)
BoundingBox findBoundingBoxRelativeToPosition:ri:rj:rk:selfPosition:si:sj:sk:(Vector opv,[ri] Vector ri,[rj] Vector rj,[rk] Vector rk,[selfPosition] Vector position,[si] Vector si,[sj] Vector sj,[sk] Vector sk)
BoundingBox findSubentityBoundingBoxWithPosition:rotMatrix:(Vector position,[rotMatrix] OOMatrix rotMatrix)
instancetype meshWithName:cacheKey:materialDictionary:shadersDictionary:smooth:shaderMacros:shaderBindingTarget:scaleFactor:cacheWriteable:(NSString *name,[cacheKey] NSString *cacheKey,[materialDictionary] NSDictionary *materialDict,[shadersDictionary] NSDictionary *shadersDict,[smooth] BOOL smooth,[shaderMacros] NSDictionary *macros,[shaderBindingTarget] id< OOWeakReferenceSupport > object,[scaleFactor] float factor,[cacheWriteable] BOOL cacheWriteable)
instancetype quiriumCascadeFromShip:(ShipEntity *ship)
instancetype ringFromEntity:(Entity *sourceEntity)
id roleSetWithAddedRoleIfNotSet:probability:(NSString *role,[probability] float probability)
instancetype roleSetWithString:(NSString *roleString)
BOOL hasRole:(NSString *role)
id roleSetWithAddedRole:probability:(NSString *role,[probability] float probability)
instancetype roleSetWithRole:probability:(NSString *role,[probability] float probability)
id roleSetWithRemovedRole:(NSString *role)
id jsScriptFromFileNamed:properties:(NSString *fileName,[properties] NSDictionary *properties)
BOOL addShip:(ShipEntity *ship)
void setLeader:(ShipEntity *leader)
NSEnumerator * mutationSafeEnumerator()
instancetype groupWithName:(NSString *name)
NSEnumerator * objectEnumerator()
BOOL removeShip:(ShipEntity *ship)
NSDictionary * shipyardInfoForKey:(NSString *key)
OOShipRegistry * sharedRegistry()
id fragmentBurstFromEntity:(Entity *entity)
OOWeakReference * weakSelf
id weakRefUnderlyingObject()
void addObject:(id< OOWeakReferenceSupport > object)
NSEnumerator * objectEnumerator()
BOOL containsObject:(id< OOWeakReferenceSupport > object)
void removeObject:(id< OOWeakReferenceSupport > object)
GLfloat isHitByLine:v1:(Vector v0,[v1] Vector v1)
void setScriptTarget:(ShipEntity *ship)
void receiveCommsMessage:from:(NSString *message_text, [from] ShipEntity *other)
void adjustTradeInFactorBy:(int value)
NSDictionary * materialDefaults()
NSDictionary * whitelistDictionary()
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)
void behaviour_fly_to_destination:(double delta_t)
BOOL firePortWeapon:(double range)
void setWeaponEnergy:(float value)
OOWeaponFacingSet weapon_facings
BOOL isExplicitlyUnpiloted()
BOOL suppressFlightNotifications()
OOTimeAbsolute last_shot_time
void suppressTargetLost()
void behaviour_stop_still:(double delta_t)
void behaviour_evasive_action:(double delta_t)
GLfloat laserHeatLevelAft()
BOOL hasAllEquipment:includeWeapons:whileLoading:(id equipmentKeys,[includeWeapons] BOOL includeWeapons,[whileLoading] BOOL loading)
OOCargoQuantity commodity_amount
Vector positionOffsetForShipInRotationToAlignment(ShipEntity *ship, Quaternion q, NSString *align)
void setCommsMessageColor()
unsigned suppressExplosion
Entity * rememberedShip()
void removeRole:(NSString *role)
NSUInteger passengerCount()
void setSuppressExplosion:(BOOL suppress)
OOWeakReference * _targetStation
void setBounty:withReasonAsString:(OOCreditsQuantity amount,[withReasonAsString] NSString *reason)
void getDestroyedBy:damageType:(Entity *whom,[damageType] OOShipDamageType type)
void setCargo:(NSArray *some_cargo)
unsigned trackCloseContacts
double missileTrackPrimaryTarget:(double delta_t)
void doScriptEvent:(OOJSPropID message)
BOOL canStillTrackPrimaryTarget()
void setMesh:(OOMesh *mesh)
void setScannerDisplayColor1:(OOColor *color1)
BOOL validForAddToUniverse()
NSComparisonResult ComparePlanetsBySurfaceDistance(id i1, id i2, void *context)
BOOL addEquipmentItem:inContext:(NSString *equipmentKey,[inContext] NSString *context)
void setShipHitByLaser:(ShipEntity *ship)
OOCommodityType commodity_type
double trackPrimaryTarget:retreat:(double delta_t,[retreat] BOOL retreat)
void landOnPlanet:(OOPlanetEntity *planet)
HPVector absoluteTractorPosition()
void setTargetStation:(Entity *targetEntity)
void setLastAegisLock:(Entity< OOStellarBody > *lastAegisLock)
BOOL setUpOneStandardSubentity:asTurret:(NSDictionary *subentDict,[asTurret] BOOL asTurret)
void resumePostProximityAlert()
OOEquipmentType * selectMissile()
void decrease_flight_speed:(double delta)
NSArray * spawnShipsWithRole:count:(NSString *role,[count] NSUInteger count)
GLfloat currentAimTolerance()
void behaviour_tractored:(double delta_t)
void transitionToAegisNone()
OOTimeAbsolute aiScriptWakeTime
void setBounty:withReason:(OOCreditsQuantity amount,[withReason] OOLegalStatusReason reason)
void refreshEscortPositions()
float randomEjectaTemperatureWithMaxFactor:(float factor)
void evasiveAction:(double delta_t)
void addTarget:(Entity *targetEntity)
void setPrimaryAggressor:(Entity *targetEntity)
float shieldBoostFactor()
void noteKilledBy:damageType:(Entity *whom,[damageType] OOShipDamageType type)
NSArray * allDefenseTargets()
float weaponRechargeRate()
void broadcastHitByLaserFrom:(ShipEntity *aggressor_ship)
id primaryTargetWithoutValidityCheck()
void setDesiredSpeed:(double amount)
NSUInteger defenseTargetCount()
ShipEntity ** scannedShips()
void collectBountyFor:(ShipEntity *other)
void behaviour_close_to_broadside_range:(double delta_t)
NSDictionary * shipInfoDictionary()
void removeEquipmentItem:(NSString *equipmentKey)
void setTargetToSystemStation()
float hyperspaceSpinTime()
void setUpCargoType:(NSString *cargoString)
NSUInteger passengerCapacity()
void setLaserColor:(OOColor *color)
void behaviour_fly_thru_navpoints:(double delta_t)
NSDictionary * scriptInfo
OOColor * scanner_display_color_hostile2
void setFuel:(OOFuelQuantity amount)
void rescaleBy:writeToCache:(GLfloat factor, [writeToCache] BOOL writeToCache)
void setThankedShip:(Entity *targetEntity)
GLfloat rollToMatchUp:rotating:(Vector up_vec,[rotating] GLfloat match_roll)
void removeTarget:(Entity *targetEntity)
GLfloat scriptedMisjumpRange()
OOTimeAbsolute cargo_dump_time
void takeEnergyDamage:from:becauseOf:weaponIdentifier:(double amount, [from] Entity *ent, [becauseOf] Entity *other, [weaponIdentifier] NSString *weaponIdentifier)
void calculateTrackingCurve()
BOOL _escortPositionsValid
NSArray * contractListForScripting()
void considerFiringMissile:(double delta_t)
OOWeakReference * _thankedShip
OOSystemID destination_system
OOWeakReference * _rememberedShip
unsigned reportAIMessages
OOWeaponFacing currentWeaponFacing
unsigned isNearPlanetSurface
GLfloat rangeToDestination()
void setStatus:(OOEntityStatus stat)
OOTimeAbsolute trackingCurveTimes[4]
NSDictionary * dockingInstructions
id initWithKey:definition:(NSString *key,[definition] NSDictionary *dict)
OOTimeAbsolute shipAIScriptWakeTime()
void behaviour_attack_broadside_target:leftside:(double delta_t,[leftside] BOOL leftside)
void behaviour_fly_from_destination:(double delta_t)
GLfloat weapon_damage_override
NSUInteger equipmentCount()
void broadcastEnergyBlastImminent()
ShipEntity * doOctreesCollide(ShipEntity *prime, ShipEntity *other)
int numberOfScannedShips()
HPVector coordinatesForEscortPosition:(unsigned idx)
void behaviour_attack_broadside_right:(double delta_t)
void behaviour_formation_form_up:(double delta_t)
void behaviour_scripted_ai:(double delta_t)
GLfloat weapon_energy_use
BOOL witchspaceLeavingEffects()
GLfloat afterburner_speed_factor
BOOL addEquipmentItem:withValidation:inContext:(NSString *equipmentKey,[withValidation] BOOL validateAddition,[inContext] NSString *context)
void applySticks:(double delta_t)
void behaviour_land_on_planet:(double delta_t)
GLfloat lookingAtSunWithThresholdAngleCos:(GLfloat thresholdAngleCos)
void noteFrustration:(NSString *context)
ShipEntity * scanned_ships[MAX_SCAN_NUMBER+1]
void setEvasiveJink:(GLfloat z)
void setRoll:(double amount)
void setThrust:(double amount)
OOAlertCondition alertCondition()
GLfloat _scriptedMisjumpRange
NSDictionary * shipinfoDictionary
BOOL collideWithShip:(ShipEntity *other)
ShipEntity * subEntityTakingDamage()
void broadcastThargoidDestroyed()
OOShipGroup * escortGroup()
BOOL hasOneEquipmentItem:includeWeapons:whileLoading:(NSString *itemKey,[includeWeapons] BOOL includeMissiles,[whileLoading] BOOL loading)
void setSpeed:(double amount)
void takeScrapeDamage:from:(double amount,[from] Entity *ent)
void behaviour_intercept_target:(double delta_t)
BOOL hasMilitaryShieldEnhancer()
OOTimeAbsolute getDemoStartTime()
void setSingleCrewWithRole:(NSString *crewRole)
void setScannerDisplayColorHostile1:(OOColor *color1)
NSEnumerator * escortEnumerator()
OOEquipmentType * verifiedMissileTypeFromRole:(NSString *role)
unsigned suppressAegisMessages
NSMutableArray * _equipment
void setTargetToNearestStationIncludingHostiles:(BOOL includeHostiles)
int checkShipsInVicinityForWitchJumpExit()
NSUInteger missileCount()
void setGroup:(OOShipGroup *group)
void scoopIn:(ShipEntity *other)
void applyAttitudeChanges:(double delta_t)
GLfloat laserHeatLevelStarboard()
BOOL fireLaserShotInDirection:weaponIdentifier:(OOWeaponFacing direction,[weaponIdentifier] NSString *weaponIdentifier)
void setSubEntityTakingDamage:(ShipEntity *sub)
BOOL fireDirectLaserShotAt:(Entity *my_target)
OOEquipmentType * generateMissileEquipmentTypeFrom:(NSString *role)
void setEscortDestination:(HPVector dest)
OOColor * scanner_display_color2
OOCargoQuantity availableCargoSpace()
void behaviour_attack_fly_to_target:(double delta_t)
OOWeakReference * _subEntityTakingDamage
void addImpactMoment:fraction:(Vector moment,[fraction] GLfloat howmuch)
OOWeakReference * _primaryAggressor
void behaviour_attack_broadside_left:(double delta_t)
static float SurfaceDistanceSqared(Entity *reference, Entity< OOStellarBody > *stellar)
void receiveCommsMessage:from:(NSString *message_text,[from] ShipEntity *other)
void setDisplayName:(NSString *inName)
unsigned number_of_navpoints
double rangeToSecondaryTarget:(Entity *target)
OOColor * scannerDisplayColor2()
void setAccuracy:(GLfloat new_accuracy)
float maxForwardShieldLevel()
void wasAddedToUniverse()
NSArray * portWeaponOffset
Quaternion subentityRotationalVelocity
float hyperspaceMotorSpinTime
OOCargoType dumpItem:(ShipEntity *jetto)
NSString * repeatString:times:(NSString *str, [times] NSUInteger times)
BOOL fireDirectLaserDefensiveShot()
GLint entityPersonalityInt()
OOShipGroup * stationGroup()
Entity * primaryAggressor()
OOTimeDelta missile_load_time
void setPrimaryRole:(NSString *role)
void releaseCargoPodsDebris()
OOWeaponType weaponTypeIDForFacing:strict:(OOWeaponFacing facing,[strict] BOOL strict)
void validateDefenseTargets()
void subEntityDied:(ShipEntity *sub)
BOOL fireStarboardWeapon:(double range)
double trackSideTarget:leftside:(double delta_t,[leftside] BOOL leftside)
NSArray * equipmentListForScripting()
OOWeakSet * _collisionExceptions
void behaviour_close_with_target:(double delta_t)
OOWeaponType aft_weapon_type
void deactivateCloakingDevice()
void setUpOneEscort:inGroup:withRole:atPosition:andCount:(ShipEntity *escorter, [inGroup] OOShipGroup *escortGroup, [withRole] NSString *escortRole, [atPosition] HPVector ex_pos, [andCount] uint8_t currentEscortCount)
void increase_flight_speed:(double delta)
BoundingBox totalBoundingBox
Entity * entityForShaderProperties()
OOCreditsQuantity removeMissiles()
OOWeakReference * _lastAegisLock
void wasRemovedFromUniverse()
void setShipScript:(NSString *script_name)
NSString * scanDescription()
void behaviour_idle:(double delta_t)
BOOL hasEquipmentItem:(id equipmentKeys)
OOWeakReference * _lastEscortTarget
NSEnumerator * defenseTargetEnumerator()
NSMutableDictionary * previousCondition
NSString * descriptionComponents()
BOOL removeExternalStore:(OOEquipmentType *eqType)
void updateTrackingCurve()
OOWeakReference * _primaryTarget
void broadcastMessage:withUnpilotedOverride:(NSString *message_text,[withUnpilotedOverride] BOOL unpilotedOverride)
NSArray * starboardWeaponOffset
void setTargetToNearestFriendlyStation()
BOOL activateCloakingDevice()
NSEnumerator * equipmentEnumerator()
void drawImmediate:translucent:(bool immediate, [translucent] bool translucent)
void setHeatInsulation:(GLfloat value)
void resetExhaustPlumes()
void setScannerDisplayColor2:(OOColor *color2)
void behaviour_attack_break_off_target:(double delta_t)
OOFuelQuantity fuelCapacity()
float shieldRechargeRate()
OOEquipmentType * missile_list[SHIPENTITY_MAX_MISSILES]
ShipEntity * dumpCargoItem:(OOCommodityType preferred)
id< OOHUDBeaconIcon > _beaconDrawable
NSArray * parcelListForScripting()
HPVector calculateTargetPosition()
OOAegisStatus aegis_status
void checkScannerIgnoringUnpowered()
BOOL hasMilitaryScannerFilter()
void setLastEscortTarget:(Entity *targetEntity)
void behaviour_fly_to_target_six:(double delta_t)
NSArray * cargoListForScripting()
BoundingBox findBoundingBoxRelativeToPosition:i:j:k:(HPVector opv,[i] Vector i,[j] Vector j,[k] Vector k)
void respondToAttackFrom:becauseOf:(Entity *from,[becauseOf] Entity *other)
NSEnumerator * flasherEnumerator()
Entity * proximityAlert()
NSMutableDictionary * closeContactsInfo
void scoopUpProcess:processEvents:processMessages:(ShipEntity *other,[processEvents] BOOL proc_events,[processMessages] BOOL proc_messages)
BOOL hasEquipmentItemProviding:(NSString *equipmentType)
NSString * scan_description
StationEntity * targetStation()
GLfloat distance2_scanned_ships[MAX_SCAN_NUMBER+1]
uint16_t entity_personality
NSString * serializeShipSubEntities()
void setPitch:(double amount)
void behaviour_running_defense:(double delta_t)
void behaviour_tumble:(double delta_t)
NSString * identFromShip:(ShipEntity *otherShip)
BOOL fireTurretCannon:(double range)
OOWeakReference * _proximityAlert
OOAlertCondition realAlertCondition()
OOTimeAbsolute missile_launch_time
GLfloat forward_weapon_temp
BOOL cascadeIfAppropriateWithDamageAmount:cascadeOwner:(double amount,[cascadeOwner] Entity *owner)
uint32_t randomSeedForShaders()
void doScriptEvent:withArgument:andArgument:(OOJSPropID message,[withArgument] id argument1,[andArgument] id argument2)
static BOOL AuthorityPredicate(Entity *entity, void *parameter)
void removeAllEquipment()
void broadcastAIMessage:(NSString *ai_message)
ShipEntity * fireMissile()
NSString * shipUniqueName
void removeDefenseTarget:(Entity *target)
OOCargoQuantity likely_cargo
OOTimeDelta missileLoadTime()
NSString * scanDescriptionForScripting()
void setBeaconCode:(NSString *bcode)
NSUInteger missileCapacity()
OOColor * exhaust_emissive_color
void dealEnergyDamageWithinDesiredRange()
void enterWormhole:(WormholeEntity *w_hole)
double approachAspectToPrimaryTarget()
double ballTrackLeadingTarget:atTarget:(double delta_t,[atTarget] Entity *target)
BOOL isValidTarget:(Entity *target)
static BOOL IsBehaviourHostile(OOBehaviour behaviour)
BOOL equipmentValidToAdd:whileLoading:inContext:(NSString *equipmentKey,[whileLoading] BOOL loading,[inContext] NSString *context)
OOPlanetEntity * findNearestPlanet()
OOCommodityType dumpCargo()
GLfloat starboard_weapon_temp
void setAITo:(NSString *aiString)
void sendMessage:toShip:withUnpilotedOverride:(NSString *message_text,[toShip] ShipEntity *other_ship,[withUnpilotedOverride] BOOL unpilotedOverride)
void applyThrust:(double delta_t)
OOColor * scannerDisplayColorHostile2()
float energyRechargeRate()
void setWeaponDataFromType:(OOWeaponType weapon_type)
BOOL isTemplateCargoPod()
ShipEntity * launchEscapeCapsule()
void behaviour_attack_mining_target:(double delta_t)
NSEnumerator * shipSubEntityEnumerator()
BOOL hasDockingComputer()
void noteTargetDestroyed:(ShipEntity *target)
void addRole:(NSString *role)
Vector missileLaunchPosition()
NSEnumerator * exhaustEnumerator()
void behaviour_attack_broadside:(double delta_t)
NSArray * aftWeaponOffset
NSArray * laserPortOffset:(OOWeaponFacing direction)
void setWeaponRange:(GLfloat value)
ShipEntity * launchPodWithCrew:(NSArray *podCrew)
void behaviour_attack_sniper:(double delta_t)
void doScriptEvent:inContext:withArguments:count:(OOJSPropID message,[inContext] JSContext *context,[withArguments] jsval *argv,[count] int argc)
void adjustVelocity:(Vector xVel)
NSArray * forwardWeaponOffset
Entity< OOStellarBody > * findNearestStellarBody()
float maxAftShieldLevel()
OOColor * scanner_display_color1
void setWeaponRechargeRate:(float value)
NSString * equipmentItemProviding:(NSString *equipmentType)
NSArray * passengerListForScripting()
void setEscortGroup:(OOShipGroup *group)
NSArray * collisionExceptions()
OOWeaponFacingSet weaponFacings()
NSString * shortDescriptionComponents()
void behaviour_face_destination:(double delta_t)
NSEnumerator * subEntityEnumerator()
void sendExpandedMessage:toShip:(NSString *message_text,[toShip] ShipEntity *other_ship)
float randomEjectaTemperature()
OOWeaponType starboard_weapon_type
void addSubentityToCollisionRadius:(Entity< OOSubEntity > *subent)
void doScriptEvent:andReactToAIMessage:(OOJSPropID scriptEvent,[andReactToAIMessage] NSString *aiMessage)
void setScriptedMisjumpRange:(GLfloat newValue)
void behaviour_track_target:(double delta_t)
unsigned scripted_misjump
void behaviour_attack_target:(double delta_t)
OOColor * scannerDisplayColorHostile1()
void setEntityPersonalityInt:(uint16_t value)
void setReportAIMessages:(BOOL yn)
void removeAllDefenseTargets()
BOOL hasGalacticHyperdrive()
BOOL fireDirectLaserShot:(double range)
OOColor * exhaustEmissiveColor()
void setTrackCloseContacts:(BOOL value)
void behaviour_avoid_collision:(double delta_t)
OOTimeAbsolute demoStartTime
void updateEscortFormation()
unsigned military_jammer_active
void setSubIdx:(NSUInteger value)
OOCargoQuantity commodityAmount()
GLfloat weapon_shot_temperature
void noteLostTargetAndGoIdle()
GLfloat energy_recharge_rate
void overrideScriptInfo:(NSDictionary *override)
OOCargoQuantity maxAvailableCargoSpace()
OOColor * default_laser_color
void orientationChanged()
float weapon_recharge_rate
void update:(OOTimeDelta delta_t)
uint8_t pendingEscortCount()
void setTemperature:(GLfloat value)
void dealMomentumWithinDesiredRange:(double amount)
void noteTakingDamage:from:type:(double amount,[from] Entity *entity,[type] OOShipDamageType type)
OOSystemID destinationSystem()
void adjustMissedShots:(int delta)
void setScriptedMisjump:(BOOL newValue)
ShipEntity * shipHitByLaser()
Quaternion subEntityRotationalVelocity()
OOShipGroup * _escortGroup
HPVector trackingCurveCoeffs[3]
GLfloat laserHeatLevelPort()
BOOL fireAftWeapon:(double range)
void takeHeatDamage:(double amount)
ShipEntity * fireMissileWithIdentifier:andTarget:(NSString *identifier,[andTarget] Entity *target)
float afterburnerFactor()
void doScriptEvent:withArgument:(OOJSPropID message,[withArgument] id argument)
void processBehaviour:(OOTimeDelta delta_t)
void setCloaked:(BOOL cloak)
double trackDestination:retreat:(double delta_t,[retreat] BOOL retreat)
void setIsBoulder:(BOOL flag)
OOEquipmentType * weaponTypeForFacing:strict:(OOWeaponFacing facing,[strict] BOOL strict)
NSArray * crewForScripting()
void setCrew:(NSArray *crewArray)
void setCommodityForPod:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)
OOWeaponType port_weapon_type
void markAsOffender:withReason:(int offence_value,[withReason] OOLegalStatusReason reason)
BOOL fireMainWeapon:(double range)
Entity< OOBeaconEntity > * nextBeacon()
double maxHyperspaceDistance()
void subEntityReallyDied:(ShipEntity *sub)
OOCargoQuantity max_cargo
void setBehaviour:(OOBehaviour cond)
NSUInteger maxShipSubEntities()
NSUInteger subEntityCount()
void setIsMissileFlag:(BOOL newValue)
void scoopUp:(ShipEntity *other)
void switchAITo:(NSString *aiString)
BOOL setUpOneSubentity:(NSDictionary *subentDict)
NSString * shipDataKeyAutoRole()
BOOL hasHyperspaceMotor()
uint8_t _pendingEscortCount
OOAegisStatus checkForAegis()
GLfloat laserHeatLevelForward()
void setHulk:(BOOL isNowHulk)
id< OOHUDBeaconIcon > beaconDrawable()
void setTargetToNearestStation()
Quaternion demoStartOrientation
void setBeaconLabel:(NSString *blabel)
double rangeToPrimaryTarget()
Triangle absoluteIJKForSubentity()
void behaviour_flee_target:(double delta_t)
OOCargoQuantity cargoQuantityOnBoard()
unsigned next_navpoint_index
void reactToAIMessage:context:(NSString *message,[context] NSString *debugContext)
void setFoundTarget:(Entity *targetEntity)
BOOL withinStationAegis()
void setScannerDisplayColorHostile2:(OOColor *color2)
OOWeakReference * _nextBeacon
BOOL setUpOneFlasher:(NSDictionary *subentDict)
GLfloat entityPersonality()
OOPlanetEntity * findNearestPlanetExcludingMoons()
OOWeakSet * _defenseTargets
void applyRoll:climb:andYaw:(GLfloat roll1, [climb] GLfloat climb1, [andYaw] GLfloat yaw1)
OOColor * scanner_display_color_hostile1
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)
unsigned docking_match_rotation
void behaviour_fly_range_from_destination:(double delta_t)
void behaviour_attack_fly_from_target:(double delta_t)
OOWeaponType forward_weapon_type
unsigned cloaking_device_active
BOOL hasEquipmentItem:includeWeapons:whileLoading:(id equipmentKeys,[includeWeapons] BOOL includeWeapons,[whileLoading] BOOL loading)
OOCargoQuantity extra_cargo
void startTrackingCurve()
NSMutableArray * subEntities
void addRole:withProbability:(NSString *role,[withProbability] float probability)
OOCargoQuantity equipment_weight
void enterWormhole:replacing:(WormholeEntity *w_hole,[replacing] BOOL replacing)
unsigned _explicitlyUnpiloted
HPVector trackingCurvePositions[4]
GLfloat weaponRecoveryTime()
OOWeakReference * _prevBeacon
OOCommodityType commodityType()
void setOwner:(Entity *who_owns_entity)
BoundingBox findSubentityBoundingBox()
void behaviour_track_as_turret:(double delta_t)
BOOL hasExpandedCargoBay()
NSUInteger countEquipmentItem:(NSString *eqkey)
void doScriptEvent:withArgument:andReactToAIMessage:(OOJSPropID scriptEvent,[withArgument] id argument,[andReactToAIMessage] NSString *aiMessage)
OOWeakReference * _foundTarget
Entity< OOBeaconEntity > * prevBeacon()
Entity< OOStellarBody > * lastAegisLock()
void behaviour_attack_slow_dogfight:(double delta_t)
NSString * lastRadioMessage
Entity * lastEscortTarget()
OOColor * scannerDisplayColor1()
NSUInteger _maxShipSubIdx
void addSubEntity:(Entity< OOSubEntity > *sub)
OOScript * shipAIScript()
unsigned haveExecutedSpawnAction
void setReference:(Vector v)
static float SurfaceDistanceSqaredV(HPVector reference, Entity< OOStellarBody > *stellar)
void disengageAutopilot()
BOOL fireWeapon:direction:range:(OOWeaponType weapon_type, [direction] OOWeaponFacing direction, [range] double range)
void launchShip:(ShipEntity *ship)
Vector portUpVectorForShip:(ShipEntity *ship)
void launchShipWithRole:(NSString *role)
void noteDockedShip:(ShipEntity *ship)
BOOL suckInShip:(ShipEntity *ship)
void setMisjumpWithRange:(GLfloat range)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void seed_RNG_only_for_planet_description(Random_Seed s_seed)