Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
ShipEntity.h
Go to the documentation of this file.
1/*
2
3 ShipEntity.h
4
5 Entity subclass representing a ship, or various other flying things like cargo
6 pods and stations (a subclass).
7
8 Oolite
9 Copyright (C) 2004-2013 Giles C Williams and contributors
10
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 MA 02110-1301, USA.
25
26 */
27
29#import "OOPlanetEntity.h"
30#import "OOJSPropID.h"
31
35
36#define MAX_TARGETS 24
37#define RAIDER_MAX_CARGO 5
38#define MERCHANTMAN_MAX_CARGO 125
39
40#define PIRATES_PREFER_PLAYER YES
41
42#define TURRET_MINIMUM_COS 0.20f
43
44#define SHIP_THRUST_FACTOR 5.0f
45#define AFTERBURNER_BURNRATE 0.25f
46
47#define CLOAKING_DEVICE_ENERGY_RATE 12.8f
48#define CLOAKING_DEVICE_MIN_ENERGY 128
49#define CLOAKING_DEVICE_START_ENERGY 0.75f
50
51#define MILITARY_JAMMER_ENERGY_RATE 3
52#define MILITARY_JAMMER_MIN_ENERGY 128
53
54#define COMBAT_IN_RANGE_FACTOR 0.035f
55#define COMBAT_BROADSIDE_IN_RANGE_FACTOR 0.020f
56#define COMBAT_OUT_RANGE_FACTOR 0.500f
57#define COMBAT_BROADSIDE_RANGE_FACTOR 0.900f
58#define COMBAT_WEAPON_RANGE_FACTOR 1.200f
59#define COMBAT_JINK_OFFSET 500.0f
60
61#define SHIP_COOLING_FACTOR 0.1f
62// heat taken from energy damage depends on mass
63// but limit maximum rate since masses vary so much
64// Cobra III ~=215000
65#define SHIP_ENERGY_DAMAGE_TO_HEAT_FACTOR (mass > 400000 ? 200000 / mass : 0.5)
66#define SHIP_INSULATION_FACTOR 0.00175f
67#define SHIP_MAX_CABIN_TEMP 256.0f
68#define SHIP_MIN_CABIN_TEMP 60.0f
69#define EJECTA_TEMP_FACTOR 0.85f
70#define DEFAULT_HYPERSPACE_SPIN_TIME 15.0f
71
72#define SUN_TEMPERATURE 1250.0f
73
74#define MAX_ESCORTS 16
75#define ESCORT_SPACING_FACTOR 3.0
76
77#define SHIPENTITY_MAX_MISSILES 32
78
79#define TURRET_TYPICAL_ENERGY 25.0f
80#define TURRET_SHOT_SPEED 2000.0f
81#define TURRET_SHOT_DURATION 3.0
82#define TURRET_SHOT_RANGE (TURRET_SHOT_SPEED * TURRET_SHOT_DURATION)
83#define TURRET_SHOT_FREQUENCY (TURRET_SHOT_DURATION * TURRET_SHOT_DURATION * TURRET_SHOT_DURATION / 100.0)
84
85#define NPC_PLASMA_SPEED 1500.0f
86#define MAIN_PLASMA_DURATION 5.0
87#define NPC_PLASMA_RANGE (MAIN_PLASMA_DURATION * NPC_PLASMA_SPEED)
88
89#define PLAYER_PLASMA_SPEED 1000.0f
90#define PLAYER_PLASMA_RANGE (MAIN_PLASMA_DURATION * PLAYER_PLASMA_SPEED)
91
92#define TRACTOR_FORCE 2500.0f
93
94#define AIMS_AGGRESSOR_SWITCHED_TARGET @"AGGRESSOR_SWITCHED_TARGET"
95
96// number of vessels considered when scanning around
97#define MAX_SCAN_NUMBER 32
98
99#define BASELINE_SHIELD_LEVEL 128.0f // Max shield level with no boosters.
100#define INITIAL_SHOT_TIME 100.0
101
102#define MIN_FUEL 0 // minimum fuel required for afterburner use
103#ifdef OO_DUMP_PLANETINFO
104// debugging planetinfo needs rapid jumping
105#define MAX_JUMP_RANGE 150.0
106#else
107#define MAX_JUMP_RANGE 7.0 // the 7 ly limit
108#endif
109
110#define ENTITY_PERSONALITY_MAX 0x7FFFU
111#define ENTITY_PERSONALITY_INVALID 0xFFFFU
112
113
114#define WEAPON_COOLING_FACTOR 6.0f
115#define NPC_MAX_WEAPON_TEMP 256.0f
116#define WEAPON_COOLING_CUTOUT 0.85f
117
118#define COMBAT_AI_WEAPON_TEMP_READY 0.25f * NPC_MAX_WEAPON_TEMP
119#define COMBAT_AI_WEAPON_TEMP_USABLE WEAPON_COOLING_CUTOUT * NPC_MAX_WEAPON_TEMP
120// factor determining how close to target AI has to be to be confident in aim
121// higher factor makes confident at longer ranges
122#define COMBAT_AI_CONFIDENCE_FACTOR 1250000.0f
123#define COMBAT_AI_ISNT_AWFUL 0.0f
124// removes BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX/TWELVE (unless thargoid)
125#define COMBAT_AI_IS_SMART 5.0f
126// adds BEHAVIOUR_(FLEE_)EVASIVE_ACTION
127#define COMBAT_AI_FLEES_BETTER 6.0f
128// adds BEHAVIOUR_ATTACK_BREAK_OFF_TARGET
129#define COMBAT_AI_DOGFIGHTER 6.5f
130// adds BEHAVIOUR_ATTACK_SLOW_DOGFIGHT
131#define COMBAT_AI_TRACKS_CLOSER 7.5f
132#define COMBAT_AI_USES_SNIPING 8.5f
133// adds BEHAVIOUR_ATTACK_SNIPER
134#define COMBAT_AI_FLEES_BETTER_2 9.0f
135// AI reacts to changes in target path in about 1.5 seconds.
136#define COMBAT_AI_STANDARD_REACTION_TIME 1.5f
137
138
139
140#define MAX_LANDING_SPEED 50.0
141#define MAX_LANDING_SPEED2 (MAX_LANDING_SPEED * MAX_LANDING_SPEED)
142
143#define MAX_COS 0.995 // cos(5 degrees) is close enough in most cases for navigation
144#define MAX_COS2 (MAX_COS * MAX_COS)
145
146
147#define ENTRY(label, value) label = value,
148
149typedef enum OOBehaviour
150{
151#include "OOBehaviour.tbl"
153
154#undef ENTRY
155
156
157/*typedef enum
158{
159 WEAPON_NONE = 0U,
160 WEAPON_PLASMA_CANNON = 1,
161 WEAPON_PULSE_LASER = 2,
162 WEAPON_BEAM_LASER = 3,
163 WEAPON_MINING_LASER = 4,
164 WEAPON_MILITARY_LASER = 5,
165 WEAPON_THARGOID_LASER = 10,
166 WEAPON_UNDEFINED
167 } OOWeaponType; */
169
170
171typedef enum
172{
173 // Alert conditions are used by player and station entities.
174 // NOTE: numerical values are available to scripts and shaders.
180
181
182typedef enum
183{
184#define DIFF_STRING_ENTRY(label, string) label,
185#include "OOShipDamageType.tbl"
186#undef DIFF_STRING_ENTRY
187
188 kOOShipDamageTypeDefault = kOODamageTypeEnergy
190
191
193{
194@public
195 // derived variables
196 OOTimeDelta shot_time; // time elapsed since last shot was fired
198 // navigation
199 Vector v_forward, v_up, v_right; // unit vectors derived from the direction faced
201 // variables which are controlled by AI
202 HPVector _destination; // for flying to/from a set point
204 GLfloat desired_range; // range to which to journey/scan
205 GLfloat desired_speed; // speed at which to travel
206 // next three used to set desired attitude, flightRoll etc. gradually catch up to target
207 GLfloat stick_roll; // stick roll
208 GLfloat stick_pitch; // stick pitch
209 GLfloat stick_yaw; // stick yaw
210 OOBehaviour behaviour; // ship's behavioural state
212 BoundingBox totalBoundingBox; // records ship configuration
214@protected
215 //set-up
216 NSDictionary *shipinfoDictionary;
220 //scripting
225 //docking instructions
226 NSDictionary *dockingInstructions;
236 // per ship-type variables
237 //
238 GLfloat maxFlightSpeed; // top speed (160.0 for player) (200.0 for fast raider)
239 GLfloat max_flight_roll; // maximum roll rate (2.0 for player) (3.0 for fast raider)
240 GLfloat max_flight_pitch; // maximum pitch rate (1.0 for player) (1.5 for fast raider) also radians/sec for (* turrets *)
242 GLfloat cruiseSpeed; // 80% of top speed
244 GLfloat max_thrust; // acceleration
245 GLfloat thrust; // acceleration
246 float hyperspaceMotorSpinTime; // duration of hyperspace countdown
248 unsigned military_jammer_active: 1, // military_jammer
252 pitching_over: 1, // set to YES if executing a sharp loop
253 rolling_over: 1, // set to YES if executing a sharp roll
254 reportAIMessages: 1, // normally NO, suppressing AI message reporting
256 being_mined: 1, // normally NO, set to Yes when fired on by mining laser
258 being_fined: 1,
260 isHulk: 1, // This is used to distinguish abandoned ships from cargo
262 isNearPlanetSurface: 1, // check for landing on planet
263 isFrangible: 1, // frangible => subEntities can be damaged individually
264 cloaking_device_active: 1, // cloaking_device
265 cloakPassive: 1, // cloak deactivates when main weapons or missiles are fired
266 cloakAutomatic: 1, // cloak activates itself automatic during attack
267 canFragment: 1, // Can it break into wreckage?
268 isWreckage: 1, // Is it wreckage?
269 _showDamage: 1, // Show damage?
270 suppressExplosion: 1, // Avoid exploding on death (script hook)
271 suppressAegisMessages: 1, // No script/AI messages sent by -checkForAegis,
272 isMissile: 1, // Whether this was launched by fireMissile (used to track submunitions).
273 _explicitlyUnpiloted: 1, // Is meant to not have crew
274 hasScoopMessage: 1, // suppress scoop messages when false.
276 // scripting
283 GLfloat _scriptedMisjumpRange;
285 GLfloat sunGlareFilter; // Range 0.0 - 1.0, where 0 means no sun glare filter, 1 means glare fully filtered
287 OOFuelQuantity fuel; // witch-space fuel
290 GLfloat afterburner_rate;
293 OOCargoQuantity likely_cargo; // likely amount of cargo (for pirates, this is what is spilled as loot)
294 OOCargoQuantity max_cargo; // capacity of cargo hold
295 OOCargoQuantity extra_cargo; // capacity of cargo hold extension (if any)
296 OOCargoQuantity equipment_weight; // amount of equipment using cargo space (excluding passenger_berth & extra_cargo_bay)
297 OOCargoType cargo_type; // if this is scooped, this is indicates contents
298 OOCargoFlag cargo_flag; // indicates contents for merchantmen
299 OOCreditsQuantity bounty; // bounty (if any)
301 GLfloat energy_recharge_rate; // recharge rate for energy banks
303 OOWeaponFacingSet weapon_facings; // weapon mounts available (bitmask)
304 OOWeaponType forward_weapon_type; // type of forward weapon (allows lasers, plasma cannon, others)
305 OOWeaponType aft_weapon_type; // type of aft weapon (allows lasers, plasma cannon, others)
306 OOWeaponType port_weapon_type; // type of port weapon
307 OOWeaponType starboard_weapon_type; // type of starboard weapon
308 GLfloat weapon_damage; // energy damage dealt by weapon
309 GLfloat weapon_damage_override; // custom energy damage dealt by front laser, if applicable
310 GLfloat weaponRange; // range of the weapon (in meters)
311 OOWeaponFacing currentWeaponFacing; // not necessarily the same as view for the player
313 GLfloat weapon_energy_use, weapon_temp, weapon_shot_temperature; // active weapon temp, delta-temp
316 GLfloat scannerRange; // typically 25600
318 unsigned missiles; // number of on-board missiles
319 unsigned max_missiles; // number of missile pylons
320 NSString *_missileRole;
321 OOTimeDelta missile_load_time; // minimum time interval between missile launches
322 OOTimeAbsolute missile_launch_time; // time of last missile launch
324 AI *shipAI; // ship's AI system
326 NSString *name; // descriptive name
327 NSString *shipUniqueName; // uniqish name e.g. "Terror of Lave"
328 NSString *shipClassName; // e.g. "Cobra III"
329 NSString *displayName; // name shown on screen
330 NSString *scan_description; // scan class name
331 OORoleSet *roleSet; // Roles a ship can take, eg. trader, hunter, police, pirate, scavenger &c.
332 NSString *primaryRole; // "Main" role of the ship.
334 NSArray *explosionType; // explosion.plist entries
336 // AI stuff
337 Vector jink; // x and y set factors for offsetting a pursuing ship's position
338 HPVector coordinates; // for flying to/from a set point
339 Vector reference; // a direction vector of magnitude 1 (* turrets *)
341 NSUInteger _subIdx; // serialisation index - used only if this ship is a subentity
342 NSUInteger _maxShipSubIdx; // serialisation index - the number of ship subentities inside the shipdata
343 double launch_time; // time at which launched
344 double launch_delay; // delay for thinking after launch
347 GLfloat frustration, // degree of dissatisfaction with the current behavioural state, factor used to test this
350 int patrol_counter; // keeps track of where the ship is along a patrol route
352 NSMutableDictionary *previousCondition; // restored after collision avoidance
354 // derived variables
355 float weapon_recharge_rate; // time between shots
356 int shot_counter; // number of shots fired
357 OOTimeAbsolute cargo_dump_time; // time cargo was last dumped
358 OOTimeAbsolute last_shot_time; // time shot was last fired
360 NSMutableArray *cargo; // cargo containers go in here
362 OOCommodityType commodity_type; // type of commodity in a container
363 OOCargoQuantity commodity_amount; // 1 if unit is TONNES (0), possibly more if precious metals KILOGRAMS (1)
364 // or gem stones GRAMS (2)
365
366 // navigation
367 GLfloat flightSpeed; // current speed
368 GLfloat flightRoll; // current roll rate
369 GLfloat flightPitch; // current pitch rate
370 GLfloat flightYaw; // current yaw rate
372 GLfloat accuracy;
377 OOAegisStatus aegis_status; // set to YES when within the station's protective zone
381 double messageTime; // counts down the seconds a radio message is active for
383 double next_spark_time; // time of next spark when throwing sparks
385 Vector collision_vector; // direction of colliding thing.
387 GLfloat _scaleFactor; // scale factor for size variation
389
390 BOOL _multiplyWeapons; // multiply instead of splitting weapons
391 //position of gun ports
392 NSArray *forwardWeaponOffset,
397 // crew (typically one OOCharacter - the pilot)
398 NSArray *crew;
400 // close contact / collision tracking
401 NSMutableDictionary *closeContactsInfo;
403 NSString *lastRadioMessage;
405 // scooping...
406 Vector tractor_position;
408 // from player entity moved here now we're doing more complex heat stuff
409 float ship_temperature;
411 // for advanced scanning etc.
412 ShipEntity *scanned_ships[MAX_SCAN_NUMBER + 1];
413 GLfloat distance2_scanned_ships[MAX_SCAN_NUMBER + 1];
416 // advanced navigation
417 HPVector navpoints[32];
421 // Collision detection
422 Octree *octree;
424#ifndef NDEBUG
425 // DEBUGGING
427#endif
428
429 uint16_t entity_personality; // Per-entity random number. Exposed to shaders and scripts.
430 NSDictionary *scriptInfo; // script_info dictionary from shipdata.plist, exposed to scripts.
432 NSMutableArray *subEntities;
433 OOEquipmentType *missile_list[SHIPENTITY_MAX_MISSILES];
435 // various types of target
436 OOWeakReference *_primaryTarget; // for combat or rendezvous
437 OOWeakReference *_primaryAggressor; // recorded after attack
440 OOWeakReference *_lastEscortTarget; // last target an escort was deployed after
441 OOWeakReference *_thankedShip; // last ship thanked
442 OOWeakReference *_rememberedShip; // ship being remembered
443 OOWeakReference *_proximityAlert; // a ShipEntity within 2x collision_radius
445 // Stuff for the target tracking curve. The ship records the position of the target every reactionTime/2 seconds, then fits a curve to the
446 // last three recorded positions. Instead of tracking the primary target's actual position it uses the curve to calculate the target's position.
447 // This introduces a small amount of lag to the target tracking making the NPC more human.
448 float reactionTime;
453
454
455@private
456 OOWeakReference *_subEntityTakingDamage; // frangible => subEntities can be damaged individually
458 NSString *_shipKey;
460 NSMutableArray *_equipment;
463 OOWeakReference *_lastAegisLock; // remember last aegis planet/sun
469 // Cache of ship-relative positions, managed by -coordinatesForEscortPosition:.
470 Vector _escortPositions[MAX_ESCORTS];
473 OOWeakSet *_defenseTargets; // defense targets
475 // ships in this set can't be collided with
478 GLfloat _profileRadius;
480 OOWeakReference *_shipHitByLaser; // entity hit by the last laser shot
482 // beacons
483 NSString *_beaconCode;
484 NSString *_beaconLabel;
487 id <OOHUDBeaconIcon> _beaconDrawable;
489 double _nextAegisCheck;
491 // Demo ship state
492 BOOL isDemoShip;
497
498// ship brains
499- (void) setStateMachine:(NSString *)ai_desc;
500- (void) setAI:(AI *)ai;
501- (AI *) getAI;
502- (BOOL) hasAutoAI;
503- (BOOL) hasNewAI;
504- (void) setShipScript:(NSString *)script_name;
505- (void) removeScript;
506- (OOScript *) shipScript;
507- (OOScript *) shipAIScript;
508- (OOTimeAbsolute) shipAIScriptWakeTime;
509- (void) setAIScriptWakeTime:(OOTimeAbsolute) t;
510- (double) frustration;
511- (void) setLaunchDelay:(double)delay;
512
513- (void) interpretAIMessage:(NSString *)message;
514
515- (GLfloat)accuracy;
516- (void)setAccuracy:(GLfloat) new_accuracy;
517
518- (OOMesh *)mesh;
519- (void)setMesh:(OOMesh *)mesh;
520
521- (BoundingBox) totalBoundingBox;
522
523- (Vector) forwardVector;
524- (Vector) upVector;
525- (Vector) rightVector;
526
527- (NSArray *)subEntities;
528- (NSUInteger) subEntityCount;
529- (BOOL) hasSubEntity:(Entity<OOSubEntity> *)sub;
530
531- (NSEnumerator *)subEntityEnumerator;
532- (NSEnumerator *)shipSubEntityEnumerator;
533- (NSEnumerator *)flasherEnumerator;
534- (NSEnumerator *)exhaustEnumerator;
535
536- (ShipEntity *) subEntityTakingDamage;
537- (void) setSubEntityTakingDamage:(ShipEntity *)sub;
538
539- (void) clearSubEntities; // Releases and clears subentity array, after making sure subentities don't think ship is owner.
540
541- (Quaternion) subEntityRotationalVelocity;
542- (void) setSubEntityRotationalVelocity:(Quaternion)rv;
543
544// subentities management
545- (NSString *) serializeShipSubEntities;
546- (void) deserializeShipSubEntitiesFrom:(NSString *)string;
547- (NSUInteger) maxShipSubEntities;
548- (void) setSubIdx:(NSUInteger)value;
549- (NSUInteger) subIdx;
550
551- (Octree *) octree;
552- (float) volume;
553
554// octree collision hunting
555- (GLfloat)doesHitLine:(HPVector)v0 :(HPVector)v1;
556- (GLfloat)doesHitLine:(HPVector)v0 :(HPVector)v1 :(ShipEntity**)hitEntity;
557- (GLfloat)doesHitLine:(HPVector)v0 :(HPVector)v1 withPosition:(HPVector)o andIJK:(Vector)i :(Vector)j :(Vector)k; // for subentities
558
559- (BoundingBox) findBoundingBoxRelativeToPosition:(HPVector)opv InVectors:(Vector)i :(Vector)j :(Vector)k;
560
561- (HPVector)absoluteTractorPosition;
562
563// beacons // definitions now in <OOBeaconEntity> protocol
564
565- (void) setIsBoulder:(BOOL)flag;
566- (BOOL) isBoulder;
567- (BOOL) isMinable;
568
569- (BOOL) countsAsKill;
570
571- (void) setUpEscorts;
572- (void) updateEscortFormation;
573
574- (id)initWithKey:(NSString *)key definition:(NSDictionary *)dict;
575- (BOOL)setUpFromDictionary:(NSDictionary *) shipDict;
576- (BOOL)setUpShipFromDictionary:(NSDictionary *) shipDict;
577- (BOOL)setUpSubEntities;
578- (BOOL) setUpOneStandardSubentity:(NSDictionary *) subentDict asTurret:(BOOL)asTurret;
579- (GLfloat)frustumRadius;
580
581- (NSString *) shipDataKey;
582- (NSString *) shipDataKeyAutoRole;
583- (void)setShipDataKey:(NSString *)key;
584
585- (NSDictionary *)shipInfoDictionary;
586
587- (NSArray *) getWeaponOffsetFrom:(NSDictionary *)dict withKey:(NSString *)key inMode:(NSString *)mode;
588- (NSArray *) aftWeaponOffset;
589- (NSArray *) forwardWeaponOffset;
590- (NSArray *) portWeaponOffset;
591- (NSArray *) starboardWeaponOffset;
592- (BOOL) hasAutoWeapons;
593
594- (BOOL) isFrangible;
595- (BOOL) suppressFlightNotifications;
596
597- (void) respondToAttackFrom:(Entity *)from becauseOf:(Entity *)other;
598
599// Equipment
600- (OOWeaponFacingSet) weaponFacings;
601- (BOOL) hasEquipmentItem:(id)equipmentKeys includeWeapons:(BOOL)includeWeapons whileLoading:(BOOL)loading; // This can take a string or an set or array of strings. If a collection, returns YES if ship has _any_ of the specified equipment. If includeWeapons is NO, missiles and primary weapons are not checked.
602- (BOOL) hasEquipmentItem:(id)equipmentKeys; // Short for hasEquipmentItem:foo includeWeapons:NO whileLoading:NO
603- (NSUInteger) countEquipmentItem:(NSString *)eqkey;
604- (NSString *) equipmentItemProviding:(NSString *)equipmentType;
605- (BOOL) hasEquipmentItemProviding:(NSString *)equipmentType;
606- (BOOL) hasAllEquipment:(id)equipmentKeys includeWeapons:(BOOL)includeWeapons whileLoading:(BOOL)loading; // Like hasEquipmentItem:includeWeapons:, but requires _all_ elements in collection.
607- (BOOL) hasAllEquipment:(id)equipmentKeys; // Short for hasAllEquipment:foo includeWeapons:NO
608- (BOOL) setWeaponMount:(OOWeaponFacing)facing toWeapon:(NSString *)eqKey;
609- (BOOL) canAddEquipment:(NSString *)equipmentKey inContext:(NSString *)context; // Test ability to add equipment, taking equipment-specific constriants into account.
610- (BOOL) equipmentValidToAdd:(NSString *)equipmentKey inContext:(NSString *)context; // Actual test if equipment satisfies validation criteria.
611- (BOOL) equipmentValidToAdd:(NSString *)equipmentKey whileLoading:(BOOL)loading inContext:(NSString *)context;
612- (BOOL) addEquipmentItem:(NSString *)equipmentKey inContext:(NSString *)context;
613- (BOOL) addEquipmentItem:(NSString *)equipmentKey withValidation:(BOOL)validateAddition inContext:(NSString *)context;
614- (BOOL) hasHyperspaceMotor;
615- (float) hyperspaceSpinTime;
616- (void) setHyperspaceSpinTime:(float)new;
617
618
619- (NSEnumerator *) equipmentEnumerator;
620- (NSUInteger) equipmentCount;
621- (void) removeEquipmentItem:(NSString *)equipmentKey;
622- (void) removeAllEquipment;
623- (OOEquipmentType *) selectMissile;
624- (OOCreditsQuantity) removeMissiles;
625
626// Internal, subject to change. Use the methods above instead.
627- (BOOL) hasOneEquipmentItem:(NSString *)itemKey includeWeapons:(BOOL)includeMissiles whileLoading:(BOOL)loading;
628- (BOOL) hasOneEquipmentItem:(NSString *)itemKey includeMissiles:(BOOL)includeMissiles whileLoading:(BOOL)loading;
629- (BOOL) hasPrimaryWeapon:(OOWeaponType)weaponType;
630- (BOOL) removeExternalStore:(OOEquipmentType *)eqType;
631
632// Passengers and parcels - not supported for NPCs, but interface is here for genericity.
633- (NSUInteger) parcelCount;
634- (NSUInteger) passengerCount;
635- (NSUInteger) passengerCapacity;
636
637- (NSUInteger) missileCount;
638- (NSUInteger) missileCapacity;
639
640- (NSUInteger) extraCargo;
641
642// Tests for the various special-cased equipment items
643// (Nowadays, more convenience methods)
644- (BOOL) hasScoop;
645- (BOOL) hasFuelScoop;
646- (BOOL) hasCargoScoop;
647- (BOOL) hasECM;
648- (BOOL) hasCloakingDevice;
649- (BOOL) hasMilitaryScannerFilter;
650- (BOOL) hasMilitaryJammer;
651- (BOOL) hasExpandedCargoBay;
652- (BOOL) hasShieldBooster;
653- (BOOL) hasMilitaryShieldEnhancer;
654- (BOOL) hasHeatShield;
655- (BOOL) hasFuelInjection;
656- (BOOL) hasCascadeMine;
657- (BOOL) hasEscapePod;
658- (BOOL) hasDockingComputer;
659- (BOOL) hasGalacticHyperdrive;
660
661// Shield information derived from equipment. NPCs can't have shields, but that should change at some point.
662- (float) shieldBoostFactor;
663- (float) maxForwardShieldLevel;
664- (float) maxAftShieldLevel;
665- (float) shieldRechargeRate;
666
667- (double) maxHyperspaceDistance;
668- (float) afterburnerFactor;
669- (float) afterburnerRate;
670- (void) setAfterburnerFactor:(GLfloat)new;
671- (void) setAfterburnerRate:(GLfloat)new;
672- (float) maxThrust;
673- (float) thrust;
674
675- (void) setMaxThrust:(GLfloat)new;
676- (void) setMaxFlightPitch:(GLfloat)new;
677- (void) setMaxFlightSpeed:(GLfloat)new;
678- (void) setMaxFlightRoll:(GLfloat)new;
679- (void) setMaxFlightYaw:(GLfloat)new;
680- (void) setEnergyRechargeRate:(GLfloat)new;
681
682
683- (void) processBehaviour:(OOTimeDelta)delta_t;
684// Behaviours
685- (void) behaviour_stop_still:(double) delta_t;
686- (void) behaviour_idle:(double) delta_t;
687- (void) behaviour_tumble:(double) delta_t;
688- (void) behaviour_tractored:(double) delta_t;
689- (void) behaviour_track_target:(double) delta_t;
690- (void) behaviour_intercept_target:(double) delta_t;
691- (void) behaviour_attack_target:(double) delta_t;
692- (void) behaviour_attack_slow_dogfight:(double) delta_t;
693- (void) behaviour_evasive_action:(double) delta_t;
694- (void) behaviour_attack_break_off_target:(double) delta_t;
695- (void) behaviour_fly_to_target_six:(double) delta_t;
696- (void) behaviour_attack_mining_target:(double) delta_t;
697- (void) behaviour_attack_fly_to_target:(double) delta_t;
698- (void) behaviour_attack_fly_from_target:(double) delta_t;
699- (void) behaviour_running_defense:(double) delta_t;
700- (void) behaviour_flee_target:(double) delta_t;
701- (void) behaviour_attack_broadside:(double) delta_t;
702- (void) behaviour_attack_broadside_left:(double) delta_t;
703- (void) behaviour_attack_broadside_right:(double) delta_t;
704- (void) behaviour_close_to_broadside_range:(double) delta_t;
705- (void) behaviour_close_with_target:(double) delta_t;
706- (void) behaviour_attack_broadside_target:(double) delta_t leftside:(BOOL)leftside;
707- (void) behaviour_attack_sniper:(double) delta_t;
708- (void) behaviour_fly_range_from_destination:(double) delta_t;
709- (void) behaviour_face_destination:(double) delta_t;
710- (void) behaviour_land_on_planet:(double) delta_t;
711- (void) behaviour_formation_form_up:(double) delta_t;
712- (void) behaviour_fly_to_destination:(double) delta_t;
713- (void) behaviour_fly_from_destination:(double) delta_t;
714- (void) behaviour_avoid_collision:(double) delta_t;
715- (void) behaviour_track_as_turret:(double) delta_t;
716- (void) behaviour_fly_thru_navpoints:(double) delta_t;
717- (void) behaviour_scripted_ai:(double) delta_t;
718
719- (float) reactionTime;
720- (void) setReactionTime: (float) newReactionTime;
721- (HPVector) calculateTargetPosition;
722- (void) startTrackingCurve;
723- (void) updateTrackingCurve;
724- (void) calculateTrackingCurve;
725
726- (GLfloat *) scannerDisplayColorForShip:(ShipEntity*)otherShip :(BOOL)isHostile :(BOOL)flash :(OOColor *)scannerDisplayColor1 :(OOColor *)scannerDisplayColor2 :(OOColor *)scannerDisplayColorH1 :(OOColor *)scannerDisplayColorH2;
727- (void)setScannerDisplayColor1:(OOColor *)color1;
728- (void)setScannerDisplayColor2:(OOColor *)color2;
729- (OOColor *)scannerDisplayColor1;
730- (OOColor *)scannerDisplayColor2;
731- (void)setScannerDisplayColorHostile1:(OOColor *)color1;
732- (void)setScannerDisplayColorHostile2:(OOColor *)color2;
733- (OOColor *)scannerDisplayColorHostile1;
734- (OOColor *)scannerDisplayColorHostile2;
735
736- (BOOL)isCloaked;
737- (void)setCloaked:(BOOL)cloak;
738- (BOOL)hasAutoCloak;
739- (void)setAutoCloak:(BOOL)automatic;
740
741- (void) applyThrust:(double) delta_t;
742- (void) applyAttitudeChanges:(double) delta_t;
743
744- (void) avoidCollision;
745- (void) resumePostProximityAlert;
746
747- (double) messageTime;
748- (void) setMessageTime:(double) value;
749
750- (OOShipGroup *) group;
751- (void) setGroup:(OOShipGroup *)group;
752
753- (OOShipGroup *) escortGroup;
754- (void) setEscortGroup:(OOShipGroup *)group; // Only for use in unconventional set-up situations.
755
756- (OOShipGroup *) stationGroup; // should probably be defined in stationEntity.m
757
758- (BOOL) hasEscorts;
759- (NSEnumerator *) escortEnumerator;
760- (NSArray *) escortArray;
761
762- (uint8_t) escortCount;
763
764// Pending escort count: number of escorts to set up "later".
765- (uint8_t) pendingEscortCount;
766- (void) setPendingEscortCount:(uint8_t)count;
767
768// allow adjustment of escort numbers from shipdata.plist levels
769- (uint8_t) maxEscortCount;
770- (void) setMaxEscortCount:(uint8_t)newCount;
771
772- (NSUInteger) turretCount;
773
774- (NSString *) name;
775- (NSString *) shipUniqueName;
776- (NSString *) shipClassName;
777- (NSString *) displayName;
778- (NSString *) scanDescription;
779- (NSString *) scanDescriptionForScripting;
780- (void) setName:(NSString *)inName;
781- (void) setShipUniqueName:(NSString *)inName;
782- (void) setShipClassName:(NSString *)inName;
783- (void) setDisplayName:(NSString *)inName;
784- (void) setScanDescription:(NSString *)inName;
785- (NSString *) identFromShip:(ShipEntity*) otherShip; // name displayed to other ships
786
787- (BOOL) hasRole:(NSString *)role;
788- (OORoleSet *)roleSet;
789
790- (void) addRole:(NSString *)role;
791- (void) addRole:(NSString *)role withProbability:(float)probability;
792- (void) removeRole:(NSString *)role;
793
794- (NSString *)primaryRole;
795- (void)setPrimaryRole:(NSString *)role;
796- (BOOL)hasPrimaryRole:(NSString *)role;
797
798- (BOOL)isPolice; // Scan class is CLASS_POLICE
799- (BOOL)isThargoid; // Scan class is CLASS_THARGOID
800- (BOOL)isTrader; // Primary role is "trader" || isPlayer
801- (BOOL)isPirate; // Primary role is "pirate"
802- (BOOL)isMissile; // Primary role has suffix "MISSILE"
803- (BOOL)isMine; // Primary role has suffix "MINE"
804- (BOOL)isWeapon; // isMissile || isWeapon
805- (BOOL)isEscort; // Primary role is "escort" or "wingman"
806- (BOOL)isShuttle; // Primary role is "shuttle"
807- (BOOL)isTurret; // Behaviour is BEHAVIOUR_TRACK_AS_TURRET
808- (BOOL)isPirateVictim; // Primary role is listed in pirate-victim-roles.plist
809- (BOOL)isExplicitlyUnpiloted; // Has unpiloted = yes in its shipdata.plist entry
810- (BOOL)isUnpiloted; // Explicitly unpiloted, hulk, rock, cargo, debris etc; an open-ended criterion that may grow.
811
812- (OOAlertCondition) alertCondition; // quick calc for shaders
813- (OOAlertCondition) realAlertCondition; // full calculation for scripting
814- (BOOL) hasHostileTarget;
815- (BOOL) isHostileTo:(Entity *)entity;
816
817// defense target handling
818- (NSUInteger) defenseTargetCount;
819- (NSArray *) allDefenseTargets;
820- (NSEnumerator *) defenseTargetEnumerator;
821- (void) validateDefenseTargets;
822- (BOOL) addDefenseTarget:(Entity *)target;
823- (BOOL) isDefenseTarget:(Entity *)target;
824- (void) removeDefenseTarget:(Entity *)target;
825- (void) removeAllDefenseTargets;
826
827// collision exceptions
828- (NSArray *) collisionExceptions;
829- (void) addCollisionException:(ShipEntity *)ship;
830- (void) removeCollisionException:(ShipEntity *)ship;
831- (BOOL) collisionExceptedFor:(ShipEntity *)ship;
832
833
834
835- (GLfloat) weaponRange;
836- (void) setWeaponRange:(GLfloat) value;
837- (void) setWeaponDataFromType:(OOWeaponType)weapon_type;
838- (float) energyRechargeRate; // final rate after energy units
839- (float) weaponRechargeRate;
840- (void) setWeaponRechargeRate:(float)value;
841- (void) setWeaponEnergy:(float)value;
842- (OOWeaponFacing) currentWeaponFacing;
843
844- (GLfloat) scannerRange;
845- (void) setScannerRange:(GLfloat)value;
846
847- (Vector) reference;
848- (void) setReference:(Vector)v;
849
850- (BOOL) reportAIMessages;
851- (void) setReportAIMessages:(BOOL)yn;
852
853- (void) transitionToAegisNone;
854- (OOPlanetEntity *) findNearestPlanet;
855- (Entity<OOStellarBody> *) findNearestStellarBody; // NOTE: includes sun.
856- (OOPlanetEntity *) findNearestPlanetExcludingMoons;
857- (OOAegisStatus) checkForAegis;
858- (void) forceAegisCheck;
859- (BOOL) withinStationAegis;
860- (void) setLastAegisLock:(Entity<OOStellarBody> *)lastAegisLock;
861
862- (OOSystemID) homeSystem;
863- (OOSystemID) destinationSystem;
864- (void) setHomeSystem:(OOSystemID)s;
865- (void) setDestinationSystem:(OOSystemID)s;
866
867
868- (NSArray *) crew;
869- (NSArray *) crewForScripting;
870- (void) setCrew:(NSArray *)crewArray;
875- (void) setSingleCrewWithRole:(NSString *)crewRole;
876
877// Fuel and capacity in tenths of light-years.
878- (OOFuelQuantity) fuel;
879- (void) setFuel:(OOFuelQuantity)amount;
880- (OOFuelQuantity) fuelCapacity;
881
882- (GLfloat) fuelChargeRate;
883
884- (void) setRoll:(double)amount;
885- (void) setRawRoll:(double)amount; // does not multiply by PI/2
886- (void) setPitch:(double)amount;
887- (void) setYaw:(double)amount;
888- (void) setThrust:(double)amount;
889- (void) applySticks:(double)delta_t;
890
891
892- (void)setThrustForDemo:(float)factor;
893
894/*
895 Sets the bounty on this ship to amount.
896 Does not check to see if the ship is allowed to have a bounty, for example if it is police.
897 */
898- (void) setBounty:(OOCreditsQuantity)amount;
899- (void) setBounty:(OOCreditsQuantity)amount withReason:(OOLegalStatusReason)reason;
900- (void) setBounty:(OOCreditsQuantity)amount withReasonAsString:(NSString *)reason;
901- (OOCreditsQuantity) bounty;
902
903- (int) legalStatus;
904
905- (BOOL) isTemplateCargoPod;
906- (void) setUpCargoType:(NSString *)cargoString;
907- (void) setCommodity:(OOCommodityType)co_type andAmount:(OOCargoQuantity)co_amount;
908- (void) setCommodityForPod:(OOCommodityType)co_type andAmount:(OOCargoQuantity)co_amount;
909- (OOCommodityType) commodityType;
910- (OOCargoQuantity) commodityAmount;
911
912- (OOCargoQuantity) maxAvailableCargoSpace;
913- (void) setMaxAvailableCargoSpace:(OOCargoQuantity)new;
914- (OOCargoQuantity) availableCargoSpace;
915- (OOCargoQuantity) cargoQuantityOnBoard;
916- (OOCargoType) cargoType;
917- (NSArray *) cargoListForScripting;
918- (NSMutableArray *) cargo;
919- (void) setCargo:(NSArray *)some_cargo;
920- (BOOL) addCargo:(NSArray *) some_cargo;
921- (BOOL) removeCargo:(OOCommodityType)commodity amount:(OOCargoQuantity) amount;
922- (BOOL) showScoopMessage;
923
924- (NSArray *) passengerListForScripting;
925- (NSArray *) parcelListForScripting;
926- (NSArray *) contractListForScripting;
927- (NSArray *) equipmentListForScripting;
928- (OOWeaponType) weaponTypeIDForFacing:(OOWeaponFacing)facing strict:(BOOL)strict;
929- (OOEquipmentType *) weaponTypeForFacing:(OOWeaponFacing)facing strict:(BOOL)strict;
930- (NSArray *) missilesList;
931
932- (OOCargoFlag) cargoFlag;
933- (void) setCargoFlag:(OOCargoFlag)flag;
934
935- (void) setSpeed:(double)amount;
936- (double) desiredSpeed;
937- (void) setDesiredSpeed:(double)amount;
938- (double) desiredRange;
939- (void) setDesiredRange:(double)amount;
940
941- (double) cruiseSpeed;
942
943- (Vector) thrustVector;
944- (void) setTotalVelocity:(Vector)vel; // Set velocity to vel - thrustVector, effectively setting the instanteneous velocity to vel.
945
946- (void) increase_flight_speed:(double)delta;
947- (void) decrease_flight_speed:(double)delta;
948- (void) increase_flight_roll:(double)delta;
949- (void) decrease_flight_roll:(double)delta;
950- (void) increase_flight_pitch:(double)delta;
951- (void) decrease_flight_pitch:(double)delta;
952- (void) increase_flight_yaw:(double)delta;
953- (void) decrease_flight_yaw:(double)delta;
954
955- (GLfloat) flightRoll;
956- (GLfloat) flightPitch;
957- (GLfloat) flightYaw;
958- (GLfloat) flightSpeed;
959- (GLfloat) maxFlightPitch;
960- (GLfloat) maxFlightSpeed;
961- (GLfloat) maxFlightRoll;
962- (GLfloat) maxFlightYaw;
963- (GLfloat) speedFactor;
964
965- (GLfloat) temperature;
966- (void) setTemperature:(GLfloat) value;
967- (GLfloat) heatInsulation;
968- (void) setHeatInsulation:(GLfloat) value;
969
970- (float) randomEjectaTemperature;
971- (float) randomEjectaTemperatureWithMaxFactor:(float)factor;
972
973// the percentage of damage taken (100 is destroyed, 0 is fine)
974- (int) damage;
975
976- (void) dealEnergyDamage:(GLfloat) baseDamage atRange:(GLfloat) range withBias:(GLfloat) velocityBias;
977- (void) dealEnergyDamageWithinDesiredRange;
978- (void) dealMomentumWithinDesiredRange:(double)amount;
979
980// Dispatch shipTakingDamage() event.
981- (void) noteTakingDamage:(double)amount from:(Entity *)entity type:(OOShipDamageType)type;
982// Dispatch shipDied() and possibly shipKilledOther() events. This is only for use by getDestroyedBy:damageType:, but needs to be visible to PlayerEntity's version.
983- (void) noteKilledBy:(Entity *)whom damageType:(OOShipDamageType)type;
984
985- (void) getDestroyedBy:(Entity *)whom damageType:(OOShipDamageType)type;
986- (void) becomeExplosion;
987- (void) becomeLargeExplosion:(double) factor;
988- (void) becomeEnergyBlast;
989- (void) broadcastEnergyBlastImminent;
990- (void) setIsWreckage:(BOOL)isw;
991- (BOOL) showDamage;
992
993- (Vector) positionOffsetForAlignment:(NSString*) align;
994Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q, NSString* align);
996- (void) collectBountyFor:(ShipEntity *)other;
997
998- (BoundingBox) findSubentityBoundingBox;
999
1000- (Triangle) absoluteIJKForSubentity;
1001
1002- (GLfloat)weaponRecoveryTime;
1003- (GLfloat)laserHeatLevel;
1004- (GLfloat)laserHeatLevelAft;
1005- (GLfloat)laserHeatLevelForward;
1006- (GLfloat)laserHeatLevelPort;
1007- (GLfloat)laserHeatLevelStarboard;
1008- (GLfloat)hullHeatLevel;
1009- (GLfloat)entityPersonality;
1010- (GLint)entityPersonalityInt;
1011- (void) setEntityPersonalityInt:(uint16_t)value;
1012
1013- (void)setSuppressExplosion:(BOOL)suppress;
1014
1015- (void) resetExhaustPlumes;
1016
1017- (void) removeExhaust:(OOExhaustPlumeEntity *)exhaust;
1018- (void) removeFlasher:(OOFlasherEntity *)flasher;
1019
1020
1021/*-----------------------------------------
1022
1023 AI piloting methods
1024
1025 -----------------------------------------*/
1026
1027- (void) checkScanner;
1028- (void) checkScannerIgnoringUnpowered;
1029- (ShipEntity**) scannedShips;
1030- (int) numberOfScannedShips;
1031
1032- (Entity *)foundTarget;
1033- (Entity *)primaryAggressor;
1034- (Entity *)lastEscortTarget;
1035- (Entity *)thankedShip;
1036- (Entity *)rememberedShip;
1037- (Entity *)proximityAlert;
1038- (void) setFoundTarget:(Entity *) targetEntity;
1039- (void) setPrimaryAggressor:(Entity *) targetEntity;
1040- (void) setLastEscortTarget:(Entity *) targetEntity;
1041- (void) setThankedShip:(Entity *) targetEntity;
1042- (void) setRememberedShip:(Entity *) targetEntity;
1043- (void) setProximityAlert:(ShipEntity *) targetEntity;
1044- (void) setTargetStation:(Entity *) targetEntity;
1045- (BOOL) isValidTarget:(Entity *) target;
1046- (void) addTarget:(Entity *) targetEntity;
1047- (void) removeTarget:(Entity *) targetEntity;
1048- (BOOL) canStillTrackPrimaryTarget;
1049- (id) primaryTarget;
1050- (id) primaryTargetWithoutValidityCheck;
1051- (StationEntity *) targetStation;
1052
1053- (BOOL) isFriendlyTo:(ShipEntity *)otherShip;
1054
1055- (ShipEntity *) shipHitByLaser;
1056
1057- (void) noteLostTarget;
1058- (void) noteLostTargetAndGoIdle;
1059- (void) noteTargetDestroyed:(ShipEntity *)target;
1060
1061- (OOBehaviour) behaviour;
1062- (void) setBehaviour:(OOBehaviour) cond;
1063
1064- (void) trackOntoTarget:(double) delta_t withDForward: (GLfloat) dp;
1065
1066- (double) ballTrackLeadingTarget:(double) delta_t atTarget:(Entity *)target;
1067
1068- (GLfloat) rollToMatchUp:(Vector) up_vec rotating:(GLfloat) match_roll;
1069
1070- (GLfloat) rangeToDestination;
1071- (double) trackDestination:(double) delta_t :(BOOL) retreat;
1072
1073- (void) setCoordinate:(HPVector)coord;
1074- (HPVector) coordinates;
1075- (HPVector) destination;
1076- (HPVector) distance_six: (GLfloat) dist;
1077- (HPVector) distance_twelve: (GLfloat) dist withOffset:(GLfloat)offset;
1078
1079- (void) setEvasiveJink:(GLfloat) z;
1080- (void) evasiveAction:(double) delta_t;
1081- (double) trackPrimaryTarget:(double) delta_t :(BOOL) retreat;
1082- (double) trackSideTarget:(double) delta_t :(BOOL) leftside;
1083- (double) missileTrackPrimaryTarget:(double) delta_t;
1084
1085//return 0.0 if there is no primary target
1086- (double) rangeToPrimaryTarget;
1087- (double) approachAspectToPrimaryTarget;
1088- (double) rangeToSecondaryTarget:(Entity *)target;
1089- (BOOL) hasProximityAlertIgnoringTarget:(BOOL)ignore_target;
1090- (GLfloat) currentAimTolerance;
1091/* This method returns a value between 0.0f and 1.0f, depending on how directly our view point
1092 faces the sun and is used for generating the "staring at the sun" glare effect. 0.0f means that
1093 we are not facing the sun, 1.0f means that we are looking directly at it. The cosine of the
1094 threshold angle between view point and sun, below which we consider the ship as looking
1095 at the sun, is passed as parameter to the method.
1096*/
1097- (GLfloat) lookingAtSunWithThresholdAngleCos:(GLfloat) thresholdAngleCos;
1098
1099- (BOOL) onTarget:(OOWeaponFacing)direction withWeapon:(OOWeaponType)weapon;
1100
1101- (OOTimeDelta) shotTime;
1102- (void) resetShotTime;
1103
1104- (BOOL) fireMainWeapon:(double)range;
1105- (BOOL) fireAftWeapon:(double)range;
1106- (BOOL) firePortWeapon:(double)range;
1107- (BOOL) fireStarboardWeapon:(double)range;
1108- (BOOL) fireTurretCannon:(double)range;
1109- (void) setLaserColor:(OOColor *)color;
1110- (void) setExhaustEmissiveColor:(OOColor *)color;
1111- (OOColor *)laserColor;
1112- (OOColor *)exhaustEmissiveColor;
1113- (BOOL) fireSubentityLaserShot:(double)range;
1114- (BOOL) fireDirectLaserShot:(double)range;
1115- (BOOL) fireDirectLaserDefensiveShot;
1116- (BOOL) fireDirectLaserShotAt:(Entity *)my_target;
1117- (NSArray *) laserPortOffset:(OOWeaponFacing)direction;
1118- (BOOL) fireLaserShotInDirection:(OOWeaponFacing)direction weaponIdentifier:(NSString *)weaponIdentifier;
1119- (void) adjustMissedShots:(int)delta;
1120- (int) missedShots;
1121- (void) considerFiringMissile:(double)delta_t;
1122- (Vector) missileLaunchPosition;
1123- (ShipEntity *) fireMissile;
1124- (ShipEntity *) fireMissileWithIdentifier:(NSString *) identifier andTarget:(Entity *) target;
1125- (BOOL) isMissileFlagSet;
1126- (void) setIsMissileFlag:(BOOL)newValue;
1127- (OOTimeDelta) missileLoadTime;
1128- (void) setMissileLoadTime:(OOTimeDelta)newMissileLoadTime;
1129- (void) noticeECM;
1130- (BOOL) fireECM;
1131- (BOOL) cascadeIfAppropriateWithDamageAmount:(double)amount cascadeOwner:(Entity *)owner;
1132- (BOOL) activateCloakingDevice;
1133- (void) deactivateCloakingDevice;
1134- (BOOL) launchCascadeMine;
1135- (ShipEntity *) launchEscapeCapsule;
1136- (OOCommodityType) dumpCargo;
1137- (ShipEntity *) dumpCargoItem:(OOCommodityType)preferred;
1138- (OOCargoType) dumpItem: (ShipEntity*) jetto;
1139
1140- (void) manageCollisions;
1141- (BOOL) collideWithShip:(ShipEntity *)other;
1142- (void) adjustVelocity:(Vector) xVel;
1143- (void) addImpactMoment:(Vector) moment fraction:(GLfloat) howmuch;
1144- (BOOL) canScoop:(ShipEntity *)other;
1145- (void) getTractoredBy:(ShipEntity *)other;
1146- (void) scoopIn:(ShipEntity *)other;
1147- (void) scoopUp:(ShipEntity *)other;
1148- (void) scoopUpProcess:(ShipEntity *)other processEvents:(BOOL) proc_events processMessages:(BOOL) proc_messages;
1149
1150- (BOOL) abandonShip;
1151
1152- (void) takeScrapeDamage:(double) amount from:(Entity *) ent;
1153- (void) takeHeatDamage:(double) amount;
1154
1155- (void) enterDock:(StationEntity *)station;
1156- (void) leaveDock:(StationEntity *)station;
1157
1158- (void) enterWormhole:(WormholeEntity *) w_hole;
1159- (void) enterWormhole:(WormholeEntity *) w_hole replacing:(BOOL)replacing;
1160- (void) enterWitchspace;
1161- (void) leaveWitchspace;
1162- (BOOL) witchspaceLeavingEffects;
1163
1164/*
1165 Mark this ship as an offender, this is different to setBounty as some ships such as police
1166 are not markable. The final bounty may not be equal to existing bounty plus offence_value.
1167 */
1168- (void) markAsOffender:(int)offence_value;
1169- (void) markAsOffender:(int)offence_value withReason:(OOLegalStatusReason)reason;
1170
1171- (void) switchLightsOn;
1172- (void) switchLightsOff;
1173- (BOOL) lightsActive;
1174
1175- (void) setDestination:(HPVector) dest;
1176- (void) setEscortDestination:(HPVector) dest;
1177
1178- (BOOL) canAcceptEscort:(ShipEntity *)potentialEscort;
1179- (BOOL) acceptAsEscort:(ShipEntity *) other_ship;
1180- (void) deployEscorts;
1181- (void) dockEscorts;
1182
1183- (void) setTargetToNearestFriendlyStation;
1184- (void) setTargetToNearestStation;
1185- (void) setTargetToSystemStation;
1186
1187- (void) landOnPlanet:(OOPlanetEntity *)planet;
1188
1189- (void) abortDocking;
1190- (NSDictionary *) dockingInstructions;
1191
1192- (void) broadcastThargoidDestroyed;
1193
1194- (void) broadcastHitByLaserFrom:(ShipEntity*) aggressor_ship;
1195
1196// Sun glare filter - 0 for no filter, 1 for full filter
1197- (GLfloat) sunGlareFilter;
1198- (void) setSunGlareFilter:(GLfloat)newValue;
1199
1200// Unpiloted ships cannot broadcast messages, unless the unpilotedOverride is set to YES.
1201- (void) sendExpandedMessage:(NSString *) message_text toShip:(ShipEntity*) other_ship;
1202- (void) sendMessage:(NSString *) message_text toShip:(ShipEntity*) other_ship withUnpilotedOverride:(BOOL)unpilotedOverride;
1203- (void) broadcastAIMessage:(NSString *) ai_message;
1204- (void) broadcastMessage:(NSString *) message_text withUnpilotedOverride:(BOOL) unpilotedOverride;
1205- (void) setCommsMessageColor;
1206- (void) receiveCommsMessage:(NSString *) message_text from:(ShipEntity *) other;
1207- (void) commsMessage:(NSString *)valueString withUnpilotedOverride:(BOOL)unpilotedOverride;
1208
1209- (BOOL) markedForFines;
1210- (BOOL) markForFines;
1211
1212- (BOOL) isMining;
1213
1214- (void) spawn:(NSString *)roles_number;
1215
1216- (int) checkShipsInVicinityForWitchJumpExit;
1217
1218- (BOOL) trackCloseContacts;
1219- (void) setTrackCloseContacts:(BOOL) value;
1220
1221/*
1222 * Changes a ship to a hulk, for example when the pilot ejects.
1223 * Aso unsets hulkiness for example when a new pilot gets in.
1224 */
1225- (void) setHulk:(BOOL) isNowHulk;
1226- (BOOL) isHulk;
1227#if OO_SALVAGE_SUPPORT
1228- (void) claimAsSalvage;
1229- (void) sendCoordinatesToPilot;
1230- (void) pilotArrived;
1231#endif
1232
1233
1234
1235- (OOJSScript *) script;
1236- (NSDictionary *) scriptInfo;
1237- (void) overrideScriptInfo:(NSDictionary *)override; // Add items from override (if not nil) to scriptInfo, replacing in case of duplicates. Used for subentities.
1238
1239- (BOOL) scriptedMisjump;
1240- (void) setScriptedMisjump:(BOOL)newValue;
1241- (GLfloat) scriptedMisjumpRange;
1242- (void) setScriptedMisjumpRange:(GLfloat)newValue;
1243
1244
1245- (Entity *)entityForShaderProperties;
1246
1247// Demo ship
1248- (void) setDemoShip: (OOScalar) demoRate;
1249- (BOOL) isDemoShip;
1250- (void) setDemoStartTime: (OOTimeAbsolute) time;
1251
1252/* *** Script events.
1253 For NPC ships, these call doEvent: on the ship script.
1254 For the player, they do that and also call doWorldScriptEvent:.
1255*/
1256- (void) doScriptEvent:(jsid)message;
1257- (void) doScriptEvent:(jsid)message withArgument:(id)argument;
1258- (void) doScriptEvent:(jsid)message withArgument:(id)argument1 andArgument:(id)argument2;
1259- (void) doScriptEvent:(jsid)message withArguments:(NSArray *)arguments;
1260- (void) doScriptEvent:(jsid)message withArguments:(jsval *)argv count:(uintN)argc;
1261- (void) doScriptEvent:(jsid)message inContext:(JSContext *)context withArguments:(jsval *)argv count:(uintN)argc;
1262
1263/* Convenience to send an event with raw JS values, for example:
1264 ShipScriptEventNoCx(ship, "doSomething", INT_TO_JSVAL(42));
1265*/
1266#define ShipScriptEvent(context, ship, event, ...) do { \
1267jsval argv[] = { __VA_ARGS__ }; \
1268uintN argc = sizeof argv / sizeof *argv; \
1269[ship doScriptEvent:OOJSID(event) inContext:context withArguments:argv count:argc]; \
1270} while (0)
1271
1272#define ShipScriptEventNoCx(ship, event, ...) do { \
1273jsval argv[] = { __VA_ARGS__ }; \
1274uintN argc = sizeof argv / sizeof *argv; \
1275[ship doScriptEvent:OOJSID(event) withArguments:argv count:argc]; \
1276} while (0)
1277
1278- (void) reactToAIMessage:(NSString *)message context:(NSString *)debugContext; // Immediate message
1279- (void) sendAIMessage:(NSString *)message; // Queued message
1280- (void) doScriptEvent:(jsid)scriptEvent andReactToAIMessage:(NSString *)aiMessage;
1281- (void) doScriptEvent:(jsid)scriptEvent withArgument:(id)argument andReactToAIMessage:(NSString *)aiMessage;
1282
1283@end
1284
1285
1286#ifndef NDEBUG
1287@interface ShipEntity (Debug)
1290
1291@end
1292#endif
1293
1294
1295@interface Entity (SubEntityRelationship)
1297/* For the common case of testing whether foo is a ship, bar is a ship, bar
1298 is a subentity of foo and this relationship is represented sanely.
1299*/
1300- (BOOL) isShipWithSubEntityShip:(Entity *)other;
1301
1302@end
1303
1304
1305NSDictionary *OODefaultShipShaderMacros(void);
1306
1307GLfloat getWeaponRangeFromType(OOWeaponType weapon_type);
1308
1309// Defined in OOConstToString.m
1310NSString *OOStringFromBehaviour(OOBehaviour behaviour) CONST_FUNC;
1311
1312// Weapon strings prefixed with EQ_, used in shipyard.plist.
1314OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC; // Uses suffix match for backwards compatibility.
1317
1318
1321
1322BOOL isWeaponNone(OOWeaponType weapon);
1323
1324NSString *OODisplayStringFromAlertCondition(OOAlertCondition alertCondition);
1325
1327
#define PURE_FUNC
#define CONST_FUNC
GLfloat OOScalar
Definition OOMaths.h:64
uint16_t OOFuelQuantity
Definition OOTypes.h:179
uint8_t OOWeaponFacingSet
Definition OOTypes.h:237
NSString * OOCommodityType
Definition OOTypes.h:106
OOAegisStatus
Definition OOTypes.h:60
OOLegalStatusReason
Definition OOTypes.h:157
uint64_t OOCreditsQuantity
Definition OOTypes.h:182
uint16_t OOUniversalID
Definition OOTypes.h:189
int16_t OOSystemID
Definition OOTypes.h:211
OOCargoType
Definition OOTypes.h:69
uint32_t OOCargoQuantity
Definition OOTypes.h:176
double OOTimeDelta
Definition OOTypes.h:224
OOCargoFlag
Definition OOTypes.h:109
double OOTimeAbsolute
Definition OOTypes.h:223
OOWeaponFacing
Definition OOTypes.h:228
OOEquipmentType * OOWeaponType
Definition ShipEntity.h:168
BOOL isWeaponNone(OOWeaponType weapon)
OOAlertCondition
Definition ShipEntity.h:172
@ ALERT_CONDITION_GREEN
Definition ShipEntity.h:176
@ ALERT_CONDITION_RED
Definition ShipEntity.h:178
@ ALERT_CONDITION_YELLOW
Definition ShipEntity.h:177
@ ALERT_CONDITION_DOCKED
Definition ShipEntity.h:175
OOWeaponType OOWeaponTypeFromEquipmentIdentifierStrict(NSString *string) PURE_FUNC
OOWeaponType OOWeaponTypeFromEquipmentIdentifierLegacy(NSString *string)
NSDictionary * OODefaultShipShaderMacros(void)
GLfloat getWeaponRangeFromType(OOWeaponType weapon_type)
NSString * OOStringFromShipDamageType(OOShipDamageType type) CONST_FUNC
OOBehaviour
Definition ShipEntity.h:150
NSString * OOStringFromWeaponType(OOWeaponType weapon) CONST_FUNC
NSString * OOEquipmentIdentifierFromWeaponType(OOWeaponType weapon) CONST_FUNC
NSString * OODisplayStringFromAlertCondition(OOAlertCondition alertCondition)
NSString * OOStringFromBehaviour(OOBehaviour behaviour) CONST_FUNC
OOWeaponType OOWeaponTypeFromEquipmentIdentifierSloppy(NSString *string) PURE_FUNC
OOShipDamageType
Definition ShipEntity.h:183
@ kOOShipDamageTypeDefault
Definition ShipEntity.h:188
OOWeaponType OOWeaponTypeFromString(NSString *string) PURE_FUNC
OOShipGroup * rawEscortGroup()
Definition AI.h:38
OOWeaponFacingSet weapon_facings
Definition ShipEntity.h:304
OOTimeAbsolute last_shot_time
Definition ShipEntity.h:359
OOCargoQuantity commodity_amount
Definition ShipEntity.h:364
BOOL isDemoShip
Definition ShipEntity.h:493
unsigned suppressExplosion
Definition ShipEntity.h:271
GLfloat weapon_damage
Definition ShipEntity.h:309
OOWeakReference * _targetStation
Definition ShipEntity.h:439
unsigned trackCloseContacts
Definition ShipEntity.h:262
double launch_delay
Definition ShipEntity.h:345
double next_spark_time
Definition ShipEntity.h:384
OOColor * laser_color
Definition ShipEntity.h:229
Vector tractor_position
Definition ShipEntity.h:407
unsigned noRocks
Definition ShipEntity.h:281
OOCargoFlag cargo_flag
Definition ShipEntity.h:299
OOCommodityType commodity_type
Definition ShipEntity.h:363
NSMutableArray * cargo
Definition ShipEntity.h:361
unsigned isMissile
Definition ShipEntity.h:273
unsigned _lightsActive
Definition ShipEntity.h:282
OOTimeAbsolute aiScriptWakeTime
Definition ShipEntity.h:224
OOWeakReference * _shipHitByLaser
Definition ShipEntity.h:481
Vector v_forward
Definition ShipEntity.h:200
unsigned haveStartedJSAI
Definition ShipEntity.h:280
int _missed_shots
Definition ShipEntity.h:376
GLfloat pitch_tolerance
Definition ShipEntity.h:374
GLfloat stick_pitch
Definition ShipEntity.h:209
unsigned rolling_over
Definition ShipEntity.h:254
NSDictionary * scriptInfo
Definition ShipEntity.h:431
OOColor * scanner_display_color_hostile2
Definition ShipEntity.h:235
OOTimeAbsolute cargo_dump_time
Definition ShipEntity.h:358
BOOL _escortPositionsValid
Definition ShipEntity.h:472
GLfloat frustration
Definition ShipEntity.h:348
OOWeakReference * _thankedShip
Definition ShipEntity.h:442
OOSystemID destination_system
Definition ShipEntity.h:380
OOWeakReference * _rememberedShip
Definition ShipEntity.h:443
unsigned reportAIMessages
Definition ShipEntity.h:255
OOWeaponFacing currentWeaponFacing
Definition ShipEntity.h:312
unsigned isNearPlanetSurface
Definition ShipEntity.h:263
unsigned hasScoopMessage
Definition ShipEntity.h:275
OOTimeAbsolute trackingCurveTimes[4]
Definition ShipEntity.h:451
NSDictionary * dockingInstructions
Definition ShipEntity.h:227
GLfloat weapon_damage_override
Definition ShipEntity.h:310
GLfloat weaponRange
Definition ShipEntity.h:311
GLfloat weapon_energy_use
Definition ShipEntity.h:314
uint8_t _maxEscortCount
Definition ShipEntity.h:468
GLfloat afterburner_speed_factor
Definition ShipEntity.h:292
GLfloat aft_weapon_temp
Definition ShipEntity.h:315
ShipEntity * scanned_ships[MAX_SCAN_NUMBER+1]
Definition ShipEntity.h:413
unsigned isFrangible
Definition ShipEntity.h:264
GLfloat _scriptedMisjumpRange
Definition ShipEntity.h:284
GLfloat max_flight_pitch
Definition ShipEntity.h:241
Vector jink
Definition ShipEntity.h:338
NSDictionary * shipinfoDictionary
Definition ShipEntity.h:217
unsigned _showDamage
Definition ShipEntity.h:270
unsigned isWreckage
Definition ShipEntity.h:269
unsigned suppressAegisMessages
Definition ShipEntity.h:272
NSMutableArray * _equipment
Definition ShipEntity.h:461
OORoleSet * roleSet
Definition ShipEntity.h:332
NSString * primaryRole
Definition ShipEntity.h:333
GLfloat port_weapon_temp
Definition ShipEntity.h:315
NSString * _missileRole
Definition ShipEntity.h:321
OOColor * scanner_display_color2
Definition ShipEntity.h:233
unsigned cloakAutomatic
Definition ShipEntity.h:267
unsigned missiles
Definition ShipEntity.h:319
float reactionTime
Definition ShipEntity.h:449
OOWeakReference * _subEntityTakingDamage
Definition ShipEntity.h:457
OOWeakReference * _primaryAggressor
Definition ShipEntity.h:438
unsigned number_of_navpoints
Definition ShipEntity.h:420
unsigned being_fined
Definition ShipEntity.h:259
NSString * name
Definition ShipEntity.h:327
unsigned max_missiles
Definition ShipEntity.h:320
HPVector _destination
Definition ShipEntity.h:203
GLfloat stick_yaw
Definition ShipEntity.h:210
NSArray * portWeaponOffset
Definition ShipEntity.h:395
Quaternion subentityRotationalVelocity
Definition ShipEntity.h:219
float hyperspaceMotorSpinTime
Definition ShipEntity.h:247
NSString * shipClassName
Definition ShipEntity.h:329
GLfloat flightPitch
Definition ShipEntity.h:370
OOTimeDelta missile_load_time
Definition ShipEntity.h:322
OOShipGroup * _group
Definition ShipEntity.h:466
GLfloat flightSpeed
Definition ShipEntity.h:368
OOWeakSet * _collisionExceptions
Definition ShipEntity.h:477
OOWeaponType aft_weapon_type
Definition ShipEntity.h:306
BoundingBox totalBoundingBox
Definition ShipEntity.h:213
Vector v_up
Definition ShipEntity.h:200
OOUniversalID planetForLanding
Definition ShipEntity.h:346
OOWeakReference * _lastAegisLock
Definition ShipEntity.h:464
OOWeakReference * _lastEscortTarget
Definition ShipEntity.h:441
NSMutableDictionary * previousCondition
Definition ShipEntity.h:353
GLfloat _scaleFactor
Definition ShipEntity.h:388
OOWeakReference * _primaryTarget
Definition ShipEntity.h:437
NSArray * starboardWeaponOffset
Definition ShipEntity.h:396
GLfloat desired_range
Definition ShipEntity.h:205
HPVector coordinates
Definition ShipEntity.h:339
OOFuelQuantity fuel
Definition ShipEntity.h:288
OOEquipmentType * missile_list[SHIPENTITY_MAX_MISSILES]
Definition ShipEntity.h:434
OOCreditsQuantity bounty
Definition ShipEntity.h:300
id< OOHUDBeaconIcon > _beaconDrawable
Definition ShipEntity.h:488
OOAegisStatus aegis_status
Definition ShipEntity.h:378
NSMutableDictionary * closeContactsInfo
Definition ShipEntity.h:402
NSString * scan_description
Definition ShipEntity.h:331
GLfloat sunGlareFilter
Definition ShipEntity.h:286
GLfloat distance2_scanned_ships[MAX_SCAN_NUMBER+1]
Definition ShipEntity.h:414
uint16_t entity_personality
Definition ShipEntity.h:430
OOWeakReference * _proximityAlert
Definition ShipEntity.h:444
OOTimeAbsolute missile_launch_time
Definition ShipEntity.h:323
GLfloat accuracy
Definition ShipEntity.h:373
GLfloat forward_weapon_temp
Definition ShipEntity.h:315
NSString * shipUniqueName
Definition ShipEntity.h:328
unsigned being_mined
Definition ShipEntity.h:257
OOCargoQuantity likely_cargo
Definition ShipEntity.h:294
OOColor * exhaust_emissive_color
Definition ShipEntity.h:231
Vector reference
Definition ShipEntity.h:340
OOSystemID home_system
Definition ShipEntity.h:379
Vector _escortPositions[MAX_ESCORTS]
Definition ShipEntity.h:471
GLfloat thrust
Definition ShipEntity.h:246
GLfloat starboard_weapon_temp
Definition ShipEntity.h:315
OOTimeDelta shot_time
Definition ShipEntity.h:197
HPVector navpoints[32]
Definition ShipEntity.h:418
OOCargoType cargo_type
Definition ShipEntity.h:298
GLfloat stick_roll
Definition ShipEntity.h:208
unsigned pitching_over
Definition ShipEntity.h:253
NSUInteger _subIdx
Definition ShipEntity.h:342
NSArray * aftWeaponOffset
Definition ShipEntity.h:394
NSArray * forwardWeaponOffset
Definition ShipEntity.h:393
OOColor * scanner_display_color1
Definition ShipEntity.h:232
GLfloat weapon_temp
Definition ShipEntity.h:314
OOBehaviour behaviour
Definition ShipEntity.h:211
unsigned cloakPassive
Definition ShipEntity.h:266
float _heatInsulation
Definition ShipEntity.h:462
OOWeaponType starboard_weapon_type
Definition ShipEntity.h:308
OOJSScript * script
Definition ShipEntity.h:222
unsigned scripted_misjump
Definition ShipEntity.h:278
float ship_temperature
Definition ShipEntity.h:410
GLfloat aim_tolerance
Definition ShipEntity.h:375
OOTimeAbsolute demoStartTime
Definition ShipEntity.h:495
unsigned military_jammer_active
Definition ShipEntity.h:249
GLfloat weapon_shot_temperature
Definition ShipEntity.h:314
GLfloat max_flight_yaw
Definition ShipEntity.h:242
GLfloat energy_recharge_rate
Definition ShipEntity.h:302
OOColor * default_laser_color
Definition ShipEntity.h:230
double launch_time
Definition ShipEntity.h:344
float weapon_recharge_rate
Definition ShipEntity.h:356
GLfloat max_thrust
Definition ShipEntity.h:245
OOShipGroup * _escortGroup
Definition ShipEntity.h:467
GLfloat max_flight_roll
Definition ShipEntity.h:240
HPVector trackingCurveCoeffs[3]
Definition ShipEntity.h:452
int patrol_counter
Definition ShipEntity.h:351
BOOL _multiplyWeapons
Definition ShipEntity.h:391
int shot_counter
Definition ShipEntity.h:357
GLfloat afterburner_rate
Definition ShipEntity.h:291
GLfloat desired_speed
Definition ShipEntity.h:206
double messageTime
Definition ShipEntity.h:382
NSString * _beaconCode
Definition ShipEntity.h:484
OOWeaponType port_weapon_type
Definition ShipEntity.h:307
OOCargoQuantity max_cargo
Definition ShipEntity.h:295
Octree * octree
Definition ShipEntity.h:423
uint8_t _pendingEscortCount
Definition ShipEntity.h:469
unsigned canFragment
Definition ShipEntity.h:268
unsigned isHulk
Definition ShipEntity.h:261
OOJSScript * aiScript
Definition ShipEntity.h:223
Quaternion demoStartOrientation
Definition ShipEntity.h:496
unsigned next_navpoint_index
Definition ShipEntity.h:419
OOWeakReference * _nextBeacon
Definition ShipEntity.h:487
NSString * _beaconLabel
Definition ShipEntity.h:485
OOWeakSet * _defenseTargets
Definition ShipEntity.h:474
GLfloat fuel_accumulator
Definition ShipEntity.h:289
unsigned n_scanned_ships
Definition ShipEntity.h:415
OOColor * scanner_display_color_hostile1
Definition ShipEntity.h:234
unsigned docking_match_rotation
Definition ShipEntity.h:251
OOWeaponType forward_weapon_type
Definition ShipEntity.h:305
Vector collision_vector
Definition ShipEntity.h:386
NSArray * crew
Definition ShipEntity.h:399
unsigned cloaking_device_active
Definition ShipEntity.h:265
GLfloat flightRoll
Definition ShipEntity.h:369
OOCargoQuantity extra_cargo
Definition ShipEntity.h:296
OOScalar demoRate
Definition ShipEntity.h:494
NSMutableArray * subEntities
Definition ShipEntity.h:433
OOCargoQuantity equipment_weight
Definition ShipEntity.h:297
unsigned _explicitlyUnpiloted
Definition ShipEntity.h:274
HPVector trackingCurvePositions[4]
Definition ShipEntity.h:450
GLfloat scannerRange
Definition ShipEntity.h:317
OOWeakReference * _prevBeacon
Definition ShipEntity.h:486
GLfloat maxFlightSpeed
Definition ShipEntity.h:239
NSArray * explosionType
Definition ShipEntity.h:335
GLfloat _profileRadius
Definition ShipEntity.h:479
NSString * displayName
Definition ShipEntity.h:330
GLfloat success_factor
Definition ShipEntity.h:349
OOWeakReference * _foundTarget
Definition ShipEntity.h:440
NSString * lastRadioMessage
Definition ShipEntity.h:404
NSUInteger _maxShipSubIdx
Definition ShipEntity.h:343
NSString * _shipKey
Definition ShipEntity.h:459
double _nextAegisCheck
Definition ShipEntity.h:490
OOBehaviour debugLastBehaviour
Definition ShipEntity.h:427
GLfloat flightYaw
Definition ShipEntity.h:371
unsigned haveExecutedSpawnAction
Definition ShipEntity.h:279
Vector v_right
Definition ShipEntity.h:200
GLfloat cruiseSpeed
Definition ShipEntity.h:243
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque