Oolite
Loading...
Searching...
No Matches
ShipEntity(Private) Category Reference

Instance Methods

(void) - subEntityDied:
(void) - subEntityReallyDied:
(void) - drawDebugStuff
(void) - rescaleBy:
(void) - rescaleBy:writeToCache:
(BOOL) - setUpOneSubentity:
(BOOL) - setUpOneFlasher:
(Entity< OOStellarBody > *) - lastAegisLock
(void) - addSubEntity:
(void) - refreshEscortPositions
(HPVector) - coordinatesForEscortPosition:
(void) - setUpMixedEscorts
(void) - setUpOneEscort:inGroup:withRole:atPosition:andCount:
(void) - addSubentityToCollisionRadius:
(ShipEntity *) - launchPodWithCrew:
(OOEquipmentType *) - generateMissileEquipmentTypeFrom:
(void) - setShipHitByLaser:
(void) - noteFrustration:
(BOOL) - cloakPassive

Detailed Description

Definition at line 132 of file ShipEntity.m.

Method Documentation

◆ addSubEntity:

- (void) addSubEntity: (Entity< OOSubEntity > *) subent

Extends class ShipEntity.

Definition at line 5788 of file ShipEntity.m.

5788 :(Entity<OOSubEntity>*)sub
5789{
5790 if (sub == nil)
5791 return;
5792
5793 if (subEntities == nil)
5794 subEntities = [[NSMutableArray alloc] init];
5795 sub->isSubEntity = YES;
5796 // Order matters - need consistent state in setOwner:. -- Ahruman 2008-04-20
5797 [subEntities addObject:sub];
5798 [sub setOwner:self];
5799
5800 [self addSubentityToCollisionRadius:sub];
5801}
return nil

References ShipEntity::addSubentityToCollisionRadius:, Entity::isSubEntity, nil, and ShipEntity::setOwner:.

Referenced by setUpOneFlasher:, ShipEntity::setUpOneStandardSubentity:asTurret:, and ShipEntity::setUpSubEntities.

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

◆ addSubentityToCollisionRadius:

- (void) addSubentityToCollisionRadius: (Entity< OOSubEntity > *) subent

Extends class ShipEntity.

Definition at line 2028 of file ShipEntity.m.

2028 :(Entity<OOSubEntity>*)subent
2029{
2030 if (!subent)
2031 return;
2032
2033 double distance = HPmagnitude([subent position]) + [subent findCollisionRadius];
2034 if ([subent isKindOfClass:[ShipEntity class]]) // Solid subentity
2035 {
2036 if (distance > collision_radius) {
2037 collision_radius = distance;
2038 }
2039
2040 mass += [subent mass];
2041 }
2042 if (distance > _profileRadius) {
2043 _profileRadius = distance;
2044 }
2045}
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:260
OOINLINE OOScalar distance(Vector v1, Vector v2) INLINE_CONST_FUNC
Definition OOVector.h:280

References distance(), and HPmagnitude().

Referenced by addSubEntity:.

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

◆ cloakPassive

- (BOOL) cloakPassive

Extends class ShipEntity.

Definition at line 255 of file ShipEntity.m.

5761{
5762 return cloakPassive;
5763}

References OOLog.

Referenced by drawDebugStuff, PlayerEntity::fireMainWeapon, PlayerEntity::fireMissile, ShipEntity::fireMissileWithIdentifier:andTarget:, ShipEntity::fireTurretCannon:, ShipEntity::fireWeapon:direction:range:, and ShipEntity::launchCascadeMine.

Here is the caller graph for this function:

◆ coordinatesForEscortPosition:

- (HPVector) coordinatesForEscortPosition: (unsigned) idx

Extends class ShipEntity.

Definition at line 12038 of file ShipEntity.m.

12038 :(unsigned)idx
12039{
12040 /*
12041 This function causes problems with Thargoids: their missiles (aka Thargons) are automatically
12042 added to the escorts group, and when a mother ship dies all thargons will attach themselves
12043 as escorts to the surviving battleships. This can lead to huge escort groups.
12044 TODO: better handling of Thargoid groups:
12045 - put thargons (& all other thargon missiles) in their own non-escort group perhaps?
12046 */
12047
12048 // The _escortPositions array is always MAX_ESCORTS long.
12049 // Kludge: return the same last escort position if we have escorts above MAX_ESCORTS...
12050 idx = MIN(idx, (unsigned)(MAX_ESCORTS - 1));
12051
12052 return HPvector_add(self->position, vectorToHPVector(quaternion_rotate_vector([self normalOrientation], _escortPositions[idx])));
12053}
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
Definition OOHPVector.h:166
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:213
#define MIN(A, B)
Definition OOMaths.h:91
return self
Vector quaternion_rotate_vector(Quaternion q, Vector vector) CONST_FUNC
#define MAX_ESCORTS
Definition ShipEntity.h:76

References HPvector_add(), MAX_ESCORTS, MIN, quaternion_rotate_vector(), self, and vectorToHPVector().

Referenced by ShipEntity::setUpEscorts, setUpMixedEscorts, and ShipEntity::update:.

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

◆ drawDebugStuff

- (void) drawDebugStuff

Extends class ShipEntity.

References cloakPassive, drawDebugStuff, lastAegisLock, refreshEscortPositions, and setUpMixedEscorts.

Referenced by drawDebugStuff.

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

◆ generateMissileEquipmentTypeFrom:

- (OOEquipmentType *) generateMissileEquipmentTypeFrom: (NSString *) role

Extends class ShipEntity.

Definition at line 2971 of file ShipEntity.m.

2971 :(NSString*)role
2972{
2973 /* The generated missile equipment type provides for backward compatibility with pre-1.74 OXPs missile_roles
2974 and follows this template:
2975
2976 //NPC equipment, incompatible with player ship. Not buyable because of its TL.
2977 (
2978 100, 100000, "Missile",
2979 "EQ_X_MISSILE",
2980 "Unidentified missile type.",
2981 {
2982 is_external_store = true;
2983 }
2984 )
2985 */
2986 NSArray* itemInfo = [NSArray arrayWithObjects:@"100", @"100000", @"Missile", role, @"Unidentified missile type.",
2987 [NSDictionary dictionaryWithObjectsAndKeys:@"true", @"is_external_store", nil], nil];
2988
2991}
void addEquipmentWithInfo:(NSArray *itemInfo)
OOEquipmentType * equipmentTypeWithIdentifier:(NSString *identifier)

References OOEquipmentType::addEquipmentWithInfo:, and OOEquipmentType::equipmentTypeWithIdentifier:.

Referenced by ShipEntity::verifiedMissileTypeFromRole:.

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

◆ lastAegisLock

- (Entity< OOStellarBody > *) lastAegisLock

Extends class ShipEntity.

Definition at line 6808 of file ShipEntity.m.

6809{
6810 Entity<OOStellarBody>* stellar = [_lastAegisLock weakRefUnderlyingObject];
6811 if (stellar == nil) {
6812 [_lastAegisLock release];
6813 _lastAegisLock = nil;
6814 }
6815
6816 return stellar;
6817}

References lastAegisLock, and nil.

Referenced by ShipEntity::checkForAegis, drawDebugStuff, lastAegisLock, and ShipEntity::transitionToAegisNone.

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

◆ launchPodWithCrew:

- (ShipEntity *) launchPodWithCrew: (NSArray *) podCrew

Extends class ShipEntity.

Definition at line 2047 of file ShipEntity.m.

2047 :(NSArray*)podCrew
2048{
2049 ShipEntity* pod = nil;
2050
2051 pod = [UNIVERSE newShipWithRole:[shipinfoDictionary oo_stringForKey:@"escape_pod_role"]]; // or nil
2052 if (!pod) {
2053 // _role not defined? it might have _model defined;
2054 pod = [UNIVERSE newShipWithRole:[shipinfoDictionary oo_stringForKey:@"escape_pod_model" defaultValue:@"escape-capsule"]];
2055 if (!pod) {
2056 pod = [UNIVERSE newShipWithRole:@"escape-capsule"];
2057 OOLog(@"shipEntity.noEscapePod", @"Ship %@ has no correct escape_pod_role defined. Now using default capsule.", self);
2058 }
2059 }
2060
2061 if (pod) {
2062 [pod setOwner:self];
2063 [pod setTemperature:[self randomEjectaTemperatureWithMaxFactor:0.9]];
2064 [pod setCommodity:@"slaves" andAmount:1];
2065 [pod setCrew:podCrew];
2066 [pod switchAITo:@"oolite-shuttleAI.js"];
2067 [self dumpItem:pod]; // CLASS_CARGO, STATUS_IN_FLIGHT, AI state GLOBAL
2068 [pod release]; // release
2069 }
2070
2071 return pod;
2072}
#define OOLog(class, format,...)
Definition OOLogging.h:84
void setTemperature:(GLfloat value)
void setCrew:(NSArray *crewArray)
void switchAITo:(NSString *aiString)
void setCommodity:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)
void setOwner:(Entity *who_owns_entity)

References ShipEntity::dumpItem:, nil, OOLog, ShipEntity::randomEjectaTemperatureWithMaxFactor:, ShipEntity::setCommodity:andAmount:, ShipEntity::setCrew:, ShipEntity::setOwner:, ShipEntity::setTemperature:, and ShipEntity::switchAITo:.

Referenced by ShipEntity::launchEscapeCapsule.

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

◆ noteFrustration:

- (void) noteFrustration: (NSString *) context

Extends class ShipEntity.

Definition at line 2641 of file ShipEntity.m.

2641 :(NSString*)context
2642{
2643 [shipAI reactToMessage:@"FRUSTRATED" context:context];
2644 [self doScriptEvent:OOJSID("shipAIFrustrated") withArgument:context];
2645}

References ShipEntity::doScriptEvent:withArgument:.

Referenced by ShipEntity::behaviour_attack_broadside_target:leftside:, ShipEntity::behaviour_attack_fly_to_target:, ShipEntity::behaviour_attack_sniper:, ShipEntity::behaviour_face_destination:, ShipEntity::behaviour_flee_target:, ShipEntity::behaviour_fly_thru_navpoints:, ShipEntity::behaviour_fly_to_destination:, ShipEntity::behaviour_formation_form_up:, and ShipEntity::behaviour_intercept_target:.

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

◆ refreshEscortPositions

- (void) refreshEscortPositions

Extends class ShipEntity.

Definition at line 12005 of file ShipEntity.m.

12006{
12007 if (!_escortPositionsValid) {
12008 JSContext* context = OOJSAcquireContext();
12009 OOJSVal result;
12010 OOJSVal args[] = { OOJSValueFromDouble(context, 0), OOJSValueFromDouble(context, _maxEscortCount) };
12011 BOOL OK;
12012
12013 // Reset validity first so updateEscortFormation can be called from the update callback.
12014 _escortPositionsValid = YES;
12015
12016 uint8_t i;
12017 for (i = 0; i < _maxEscortCount; i++) {
12018 args[0] = OOJSValueFromDouble(context, i); // Numbers need not be freed.
12019 result = OOJSUndefinedValue();
12020 OK = [script callMethod:OOJSID("coordinatesForEscortPosition")
12021 inContext:context
12022 withArguments:args
12023 count:sizeof args / sizeof *args
12024 result:&result];
12025
12026 if (OK)
12027 OK = JSValueToVector(context, result, &_escortPositions[i]);
12028 OOJSFreeValue(context, result);
12029
12030 if (!OK)
12031 _escortPositions[i] = kZeroVector;
12032 }
12033
12034 OOJSRelinquishContext(context);
12035 }
12036}
BOOL JSValueToVector(JSContext *context, jsval value, Vector *outVector) NONNULL_FUNC
Definition OOJSVector.m:341
OOINLINE jsval OOJSValueFromDouble(JSContext *context, double value)
jsval OOJSVal
#define OOJSFreeValue(context, value)
#define OOJSUndefinedValue()
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
const Vector kZeroVector
Definition OOVector.m:27

References JSValueToVector(), kZeroVector, OOJSAcquireContext(), OOJSFreeValue, OOJSRelinquishContext(), OOJSUndefinedValue, OOJSValueFromDouble(), and refreshEscortPositions.

Referenced by drawDebugStuff, refreshEscortPositions, ShipEntity::setUpEscorts, setUpMixedEscorts, and ShipEntity::update:.

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

◆ rescaleBy:

- (void) rescaleBy: (GLfloat) factor

Extends class ShipEntity.

Definition at line 7784 of file ShipEntity.m.

7784 :(GLfloat)factor
7785{
7786 [self rescaleBy:factor writeToCache:YES];
7787}

References ShipEntity::rescaleBy:writeToCache:.

Here is the call graph for this function:

◆ rescaleBy:writeToCache:

- (void) rescaleBy: (GLfloat) factor
writeToCache: (BOOL) writeToCache 

Extends class ShipEntity.

Definition at line 7789 of file ShipEntity.m.

7789 :(GLfloat)factor writeToCache:(BOOL)writeToCache
7790{
7791 _scaleFactor *= factor;
7792 OOMesh* mesh = nil;
7793
7794 NSDictionary* shipDict = [self shipInfoDictionary];
7795 NSString* modelName = [shipDict oo_stringForKey:@"model"];
7796 if (modelName != nil) {
7797 mesh = [OOMesh meshWithName:modelName
7798 cacheKey:[NSString stringWithFormat:@"%@-%.3f", _shipKey, _scaleFactor]
7799 materialDictionary:[shipDict oo_dictionaryForKey:@"materials"]
7800 shadersDictionary:[shipDict oo_dictionaryForKey:@"shaders"]
7801 smooth:[shipDict oo_boolForKey:@"smooth" defaultValue:NO]
7802 shaderMacros:OODefaultShipShaderMacros()
7804 scaleFactor:factor
7805 cacheWriteable:writeToCache];
7806
7807 if (mesh == nil)
7808 return;
7809 [self setMesh:mesh];
7810 }
7811
7812 // rescale subentities
7813 Entity<OOSubEntity>* se = nil;
7814 foreach (se, [self subEntities]) {
7815 [se setPosition:HPvector_multiply_scalar([se position], factor)];
7816 [se rescaleBy:factor writeToCache:writeToCache];
7817 }
7818
7819 // rescale mass
7820 mass *= factor * factor * factor;
7821}
HPVector position
Definition Entity.m:576
void setPosition:(HPVector posn)
Definition Entity.m:608
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)
Definition OOMesh.m:242

References OOMesh::meshWithName:cacheKey:materialDictionary:shadersDictionary:smooth:shaderMacros:shaderBindingTarget:scaleFactor:cacheWriteable:, nil, Entity::position, ShipEntity::rescaleBy:writeToCache:, ShipEntity::setMesh:, Entity::setPosition:, and ShipEntity::shipInfoDictionary.

Referenced by Universe::addWreckageFrom:withRole:at:scale:lifetime:, rescaleBy:, and rescaleBy:writeToCache:.

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

◆ setShipHitByLaser:

- (void) setShipHitByLaser: (ShipEntity *) ship

Extends class ShipEntity.

Definition at line 8775 of file ShipEntity.m.

8775 :(ShipEntity*)ship
8776{
8777 if (ship != [self shipHitByLaser]) {
8778 [_shipHitByLaser release];
8779 _shipHitByLaser = [ship weakRetain];
8780 }
8781}

References OOWeakRefObject::weakRetain.

Referenced by ShipEntity::fireDirectLaserShotAt:, ShipEntity::fireLaserShotInDirection:weaponIdentifier:, and ShipEntity::fireSubentityLaserShot:.

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

◆ setUpMixedEscorts

- (void) setUpMixedEscorts

Extends class ShipEntity.

Definition at line 1619 of file ShipEntity.m.

1620{
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);
1625 return;
1626 }
1627 NSDictionary* escortDefinition = nil;
1628 NSDictionary* systeminfo = nil;
1629 OOGovernmentID government;
1630
1631 systeminfo = [UNIVERSE currentSystemData];
1632 government = [systeminfo oo_unsignedCharForKey:KEY_GOVERNMENT];
1633
1634 OOShipGroup* escortGroup = [self escortGroup];
1635 if ([self group] == nil) {
1636 [self setGroup:escortGroup]; // should probably become a copy of the escortGroup post NMSR.
1637 }
1638 [escortGroup setLeader:self];
1639 _maxEscortCount = MAX_ESCORTS;
1640 [self refreshEscortPositions];
1641
1642 uint8_t currentEscortCount = [escortGroup count] - 1; // always at least 0
1643
1644 _maxEscortCount = 0;
1645 int8_t i = 0;
1646 foreach (escortDefinition, escortRoles) {
1647 if (currentEscortCount >= MAX_ESCORTS) {
1648 break;
1649 }
1650 // int rather than uint because, at least for min, there is a
1651 // use to giving a negative value
1652 int8_t min = [escortDefinition oo_intForKey:@"min" defaultValue:0];
1653 int8_t max = [escortDefinition oo_intForKey:@"max" defaultValue:2];
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) {
1659 desired--;
1660 }
1661 }
1662 }
1663 for (i = 0; i < desired; i++) {
1664 if (currentEscortCount >= MAX_ESCORTS) {
1665 break;
1666 }
1667 if (![escortRole isEqualToString:@""]) {
1668 HPVector ex_pos = [self coordinatesForEscortPosition:currentEscortCount];
1669 ShipEntity* escorter = [UNIVERSE newShipWithRole:escortRole]; // retained
1670 if (escorter == nil) {
1671 break;
1672 }
1673 [self setUpOneEscort:escorter inGroup:escortGroup withRole:escortRole atPosition:ex_pos andCount:currentEscortCount];
1674 [escorter release];
1675 }
1676 currentEscortCount++;
1677 _maxEscortCount++;
1678 }
1679 }
1680 // done assigning escorts
1681 _pendingEscortCount = 0;
1682}
struct HPVector HPVector
#define OOLogWARN(class, format,...)
Definition OOLogging.h:126
uint8_t OOGovernmentID
Definition OOTypes.h:179
void setLeader:(ShipEntity *leader)
NSUInteger count()
unsigned Ranrot(void)

References ShipEntity::coordinatesForEscortPosition:, OOShipGroup::count, ShipEntity::escortGroup, MAX_ESCORTS, nil, OOLogWARN, Ranrot(), ShipEntity::refreshEscortPositions, ShipEntity::setGroup:, OOShipGroup::setLeader:, setUpMixedEscorts, and ShipEntity::setUpOneEscort:inGroup:withRole:atPosition:andCount:.

Referenced by drawDebugStuff, ShipEntity::setUpEscorts, and setUpMixedEscorts.

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

◆ setUpOneEscort:inGroup:withRole:atPosition:andCount:

- (void) setUpOneEscort: (ShipEntity *) escorter
inGroup: (OOShipGroup *) escortGroup
withRole: (NSString *) escortRole
atPosition: (HPVector) ex_pos
andCount: (uint8_t) currentEscortCount 

Extends class ShipEntity.

Definition at line 1684 of file ShipEntity.m.

1684 :(ShipEntity*)escorter inGroup:(OOShipGroup*)escortGroup withRole:(NSString*)escortRole atPosition:(HPVector)ex_pos andCount:(uint8_t)currentEscortCount
1685{
1686 NSString* autoAI = nil;
1687 NSString* pilotRole = nil;
1688 NSDictionary* autoAIMap = nil;
1689 NSDictionary* escortShipDict = nil;
1690 AI* escortAI = nil;
1691 NSString* defaultRole = @"escort";
1692
1693 if ([self isPolice]) {
1694 defaultRole = @"wingman";
1695 pilotRole = @"police"; // police are always insured.
1696 } else {
1697 pilotRole = bounty ? @"pirate" : @"hunter"; // hunters have insurancies, pirates not.
1698 }
1699
1700 double dd = escorter->collision_radius;
1701
1702 if (EXPECT(currentEscortCount < (uint8_t)MAX_ESCORTS)) {
1703 // spread them around a little randomly
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);
1707 } else {
1708 // Thargoid armada(!) Add more distance between the 'escorts'.
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);
1712 }
1713
1714 [escorter setPosition:ex_pos]; // minimise lollipop flash
1715
1716 if ([escorter crew] == nil) {
1717 [escorter setSingleCrewWithRole:pilotRole];
1718 }
1719
1720 [escorter setPrimaryRole:defaultRole]; // for mothership
1721 // in case this hasn't yet been set, make sure escorts get a real scan class
1722 // shouldn't happen very often, but is possible
1723 if (scanClass == CLASS_NOT_SET) {
1724 scanClass = CLASS_NEUTRAL;
1725 }
1726 [escorter setScanClass:scanClass]; // you are the same as I
1727
1728 if ([self bounty] == 0)
1729 [escorter setBounty:0 withReason:kOOLegalStatusReasonSetup]; // Avoid dirty escorts for clean mothers
1730
1731 // find the right autoAI.
1732 escortShipDict = [escorter shipInfoDictionary];
1733 autoAIMap = [ResourceManager dictionaryFromFilesNamed:@"autoAImap.plist" inFolder:@"Config" andMerge:YES];
1734 autoAI = [autoAIMap oo_stringForKey:defaultRole];
1735 if (autoAI == nil) // no 'wingman' defined in autoAImap?
1736 {
1737 autoAI = [autoAIMap oo_stringForKey:@"escort" defaultValue:@"nullAI.plist"];
1738 }
1739
1740 escortAI = [escorter getAI];
1741
1742 // Let the populator decide which AI to use, unless we have a working alternative AI & we specify auto_ai = NO !
1743 if ((escortRole && [escortShipDict oo_fuzzyBooleanForKey:@"auto_ai" defaultValue:YES])
1744 || ([[escortAI name] isEqualToString:@"nullAI.plist"] && ![autoAI isEqualToString:@"nullAI.plist"])) {
1745 [escorter switchAITo:autoAI];
1746 }
1747
1748 [escorter setGroup:escortGroup];
1749 [escorter setOwner:self]; // mark self as group leader
1750
1751 if ([self status] == STATUS_DOCKED) {
1752 [[self owner] addShipToLaunchQueue:escorter withPriority:NO];
1753 } else {
1754 [UNIVERSE addEntity:escorter]; // STATUS_IN_FLIGHT, AI state GLOBAL
1755 [escortAI setState:@"FLYING_ESCORT"]; // Begin escort flight. (If the AI doesn't define FLYING_ESCORT, this has no effect.)
1756 [escorter doScriptEvent:OOJSID("spawnedAsEscort") withArgument:self];
1757 }
1758
1759 if ([escorter heatInsulation] < [self heatInsulation])
1760 [escorter setHeatInsulation:[self heatInsulation]]; // give escorts same protection as mother.
1761 if (([escorter maxFlightSpeed] < cruiseSpeed) && ([escorter maxFlightSpeed] > cruiseSpeed * 0.3))
1762 cruiseSpeed = [escorter maxFlightSpeed] * 0.99; // adapt patrolSpeed to the slowest escort but ignore the very slow ones.
1763
1764 if (bounty) {
1765 int extra = 1 | (ranrot_rand() & 15);
1766 // if mothership is offender, make sure escorter is too.
1767 [escorter markAsOffender:extra withReason:kOOLegalStatusReasonSetup];
1768 } else {
1769 // otherwise force the escort to be clean
1770 [escorter setBounty:0 withReason:kOOLegalStatusReasonSetup];
1771 }
1772}
#define EXPECT(x)
void setState:(NSString *stateName)
Definition AI.m:303
GLfloat collision_radius
Definition Entity.h:107
void setScanClass:(OOScanClass sClass)
Definition Entity.m:738
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)
void setBounty:withReason:(OOCreditsQuantity amount,[withReason] OOLegalStatusReason reason)
NSDictionary * shipInfoDictionary()
void setSingleCrewWithRole:(NSString *crewRole)
void setGroup:(OOShipGroup *group)
void setPrimaryRole:(NSString *role)
void doScriptEvent:withArgument:(OOJSPropID message,[withArgument] id argument)
void markAsOffender:withReason:(int offence_value,[withReason] OOLegalStatusReason reason)
float randf(void)
#define ranrot_rand()
OOHPScalar x
Definition OOHPVector.h:36
OOHPScalar y
Definition OOHPVector.h:37
OOHPScalar z
Definition OOHPVector.h:38

References Entity::collision_radius, ResourceManager::dictionaryFromFilesNamed:inFolder:andMerge:, ShipEntity::doScriptEvent:withArgument:, EXPECT, ShipEntity::getAI, ShipEntity::heatInsulation, ShipEntity::markAsOffender:withReason:, MAX_ESCORTS, ShipEntity::maxFlightSpeed, nil, Entity::owner, randf(), ranrot_rand, ShipEntity::setBounty:withReason:, ShipEntity::setGroup:, ShipEntity::setHeatInsulation:, ShipEntity::setOwner:, Entity::setPosition:, ShipEntity::setPrimaryRole:, Entity::setScanClass:, ShipEntity::setSingleCrewWithRole:, AI::setState:, ShipEntity::shipInfoDictionary, ShipEntity::switchAITo:, HPVector::x, HPVector::y, and HPVector::z.

Referenced by ShipEntity::setUpEscorts, and setUpMixedEscorts.

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

◆ setUpOneFlasher:

- (BOOL) setUpOneFlasher: (NSDictionary *) subentDict

Extends class ShipEntity.

Definition at line 851 of file ShipEntity.m.

851 :(NSDictionary*)subentDict
852{
853 OOFlasherEntity* flasher = [OOFlasherEntity flasherWithDictionary:subentDict];
854 [flasher setPosition:HPvector_multiply_scalar([subentDict oo_hpvectorForKey:@"position"], _scaleFactor)];
855 [flasher rescaleBy:_scaleFactor];
856 [self addSubEntity:flasher];
857 return YES;
858}
instancetype flasherWithDictionary:(NSDictionary *dictionary)
void rescaleBy:(GLfloat factor)

References ShipEntity::addSubEntity:, OOFlasherEntity::flasherWithDictionary:, OOFlasherEntity::rescaleBy:, and Entity::setPosition:.

Referenced by setUpOneSubentity:.

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

◆ setUpOneSubentity:

- (BOOL) setUpOneSubentity: (NSDictionary *) subentDict

Extends class ShipEntity.

Definition at line 835 of file ShipEntity.m.

835 :(NSDictionary*)subentDict
836{
838
839 NSString* type = nil;
840
841 type = [subentDict oo_stringForKey:@"type"];
842 if ([type isEqualToString:@"flasher"]) {
843 return [self setUpOneFlasher:subentDict];
844 } else {
845 return [self setUpOneStandardSubentity:subentDict asTurret:[type isEqualToString:@"ball_turret"]];
846 }
847
849}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER

References nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, ShipEntity::setUpOneFlasher:, and ShipEntity::setUpOneStandardSubentity:asTurret:.

Referenced by ShipEntity::setUpSubEntities.

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

◆ subEntityDied:

- (void) subEntityDied: (ShipEntity *) sub

Extends class ShipEntity.

Definition at line 8194 of file ShipEntity.m.

8194 :(ShipEntity*)sub
8195{
8196 if ([self subEntityTakingDamage] == sub)
8197 [self setSubEntityTakingDamage:nil];
8198
8199 [sub setOwner:nil];
8200 // TODO? Recalculating collision radius should increase collision testing efficiency,
8201 // but for most ship models the difference would be marginal. -- Kaks 20110429
8202 mass -= [sub mass]; // missing subents affect fuel charge rate, etc..
8203 [subEntities removeObject:sub];
8204}

References Entity::mass, ShipEntity::setOwner:, and ShipEntity::setSubEntityTakingDamage:.

Referenced by ShipEntity::becomeExplosion.

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

◆ subEntityReallyDied:

- (void) subEntityReallyDied: (ShipEntity *) sub

Extends class ShipEntity.

Definition at line 8206 of file ShipEntity.m.

8206 :(ShipEntity*)sub
8207{
8208 if ([self subEntityTakingDamage] == sub)
8209 [self setSubEntityTakingDamage:nil];
8210
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.");
8213
8214 // Leak subentity list.
8215 subEntities = nil;
8216 }
8217}
#define OOLogERR(class, format,...)
Definition OOLogging.h:125

References nil, OOLogERR, and ShipEntity::setSubEntityTakingDamage:.

Referenced by ShipEntity::dealloc.

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

The documentation for this category was generated from the following file: