Oolite
Loading...
Searching...
No Matches
OOJSShip.m File Reference
Include dependency graph for OOJSShip.m:

Go to the source code of this file.

Macros

#define GET_THIS_SHIP(THISENT)

Enumerations

enum  {
  kShip_accuracy = -128 , kShip_aftWeapon , kShip_AI , kShip_AIScript ,
  kShip_AIScriptWakeTime , kShip_AIState , kShip_AIFoundTarget , kShip_AIPrimaryAggressor ,
  kShip_alertCondition , kShip_autoAI , kShip_autoWeapons , kShip_beaconCode ,
  kShip_beaconLabel , kShip_boundingBox , kShip_bounty , kShip_cargoList ,
  kShip_cargoSpaceAvailable , kShip_cargoSpaceCapacity , kShip_cargoSpaceUsed , kShip_collisionExceptions ,
  kShip_contracts , kShip_commodity , kShip_commodityAmount , kShip_cloakAutomatic ,
  kShip_crew , kShip_cruiseSpeed , kShip_currentWeapon , kShip_dataKey ,
  kShip_defenseTargets , kShip_desiredRange , kShip_desiredSpeed , kShip_destination ,
  kShip_destinationSystem , kShip_displayName , kShip_dockingInstructions , kShip_energyRechargeRate ,
  kShip_entityPersonality , kShip_equipment , kShip_escortGroup , kShip_escorts ,
  kShip_exhaustEmissiveColor , kShip_exhausts , kShip_extraCargo , kShip_flashers ,
  kShip_forwardWeapon , kShip_fuel , kShip_fuelChargeRate , kShip_group ,
  kShip_hasHostileTarget , kShip_hasHyperspaceMotor , kShip_hasSuspendedAI , kShip_heading ,
  kShip_heatInsulation , kShip_homeSystem , kShip_hyperspaceSpinTime , kShip_injectorBurnRate ,
  kShip_injectorSpeedFactor , kShip_isBeacon , kShip_isBoulder , kShip_isCargo ,
  kShip_isCloaked , kShip_isDerelict , kShip_isFrangible , kShip_isFleeing ,
  kShip_isJamming , kShip_isMinable , kShip_isMine , kShip_isMissile ,
  kShip_isPiloted , kShip_isPirate , kShip_isPirateVictim , kShip_isPolice ,
  kShip_isRock , kShip_isThargoid , kShip_isTurret , kShip_isTrader ,
  kShip_isWeapon , kShip_laserHeatLevel , kShip_laserHeatLevelAft , kShip_laserHeatLevelForward ,
  kShip_laserHeatLevelPort , kShip_laserHeatLevelStarboard , kShip_lightsActive , kShip_markedForFines ,
  kShip_maxEscorts , kShip_maxPitch , kShip_maxSpeed , kShip_maxRoll ,
  kShip_maxYaw , kShip_maxThrust , kShip_missileCapacity , kShip_missileLoadTime ,
  kShip_missiles , kShip_name , kShip_parcelCount , kShip_parcels ,
  kShip_passengerCapacity , kShip_passengerCount , kShip_passengers , kShip_pitch ,
  kShip_portWeapon , kShip_potentialCollider , kShip_primaryRole , kShip_reactionTime ,
  kShip_reportAIMessages , kShip_roleWeights , kShip_roles , kShip_roll ,
  kShip_savedCoordinates , kShip_scanDescription , kShip_scannerDisplayColor1 , kShip_scannerDisplayColor2 ,
  kShip_scannerHostileDisplayColor1 , kShip_scannerHostileDisplayColor2 , kShip_scannerRange , kShip_script ,
  kShip_scriptedMisjump , kShip_scriptedMisjumpRange , kShip_scriptInfo , kShip_shipClassName ,
  kShip_shipUniqueName , kShip_speed , kShip_starboardWeapon , kShip_subEntities ,
  kShip_subEntityCapacity , kShip_subEntityRotation , kShip_sunGlareFilter , kShip_target ,
  kShip_temperature , kShip_thrust , kShip_thrustVector , kShip_trackCloseContacts ,
  kShip_vectorForward , kShip_vectorRight , kShip_vectorUp , kShip_velocity ,
  kShip_weaponFacings , kShip_weaponPositionAft , kShip_weaponPositionForward , kShip_weaponPositionPort ,
  kShip_weaponPositionStarboard , kShip_weaponRange , kShip_withinStationAegis , kShip_yaw
}

Functions

static JSBool ShipGetProperty (JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool ShipSetProperty (JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool ShipSetScript (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSetAI (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSwitchAI (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipExitAI (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipReactToAIMessage (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSendAIMessage (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipDeployEscorts (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipDockEscorts (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipHasRole (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipEjectItem (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipEjectSpecificItem (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipDumpCargo (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipAddCargoEntity (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSpawn (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipDealEnergyDamage (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipExplode (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRemove (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRunLegacyScriptActions (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipCommsMessage (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipFireECM (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipAbandonShip (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipCanAwardEquipment (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipAwardEquipment (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipAdjustCargo (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRequestHelpFromGroup (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPatrolReportIn (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRemoveEquipment (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRestoreSubEntities (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipHasEquipmentProviding (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipEquipmentStatus (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSetEquipmentStatus (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSelectNewMissile (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipFireMissile (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipFindNearestStation (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSetBounty (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSetCargo (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSetMaterials (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSetShaders (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipExitSystem (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipUpdateEscortFormation (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipClearDefenseTargets (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipAddDefenseTarget (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRemoveDefenseTarget (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipAddCollisionException (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRemoveCollisionException (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipGetMaterials (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipGetShaders (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipBecomeCascadeExplosion (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipBroadcastCascadeImminent (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipBroadcastDistressMessage (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipOfferToEscort (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipMarkTargetForFines (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipEnterWormhole (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipNotifyGroupOfWormhole (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipThrowSpark (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformAttack (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformCollect (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformEscort (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformFaceDestination (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformFlee (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformFlyToRangeFromDestination (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformHold (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformIdle (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformIntercept (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformLandOnPlanet (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformMining (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformScriptedAI (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformScriptedAttackAI (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformStop (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipPerformTumble (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRequestDockingInstructions (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipRecallDockingInstructions (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipCheckCourseToDestination (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipGetSafeCourseToDestination (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipCheckScanner (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipThreatAssessment (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipDamageAssessment (JSContext *context, uintN argc, jsval *vp)
static double ShipThreatAssessmentWeapon (OOWeaponType wt)
static JSBool ShipSetCargoType (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipSetCrew (JSContext *context, uintN argc, jsval *vp)
static BOOL RemoveOrExplodeShip (JSContext *context, uintN argc, jsval *vp, BOOL explode)
static JSBool ShipSetMaterialsInternal (JSContext *context, uintN argc, jsval *vp, ShipEntity *thisEnt, BOOL fromShaders)
static JSBool ShipStaticKeysForRole (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipStaticKeys (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipStaticRoles (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipStaticRoleIsInCategory (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipStaticShipDataForKey (JSContext *context, uintN argc, jsval *vp)
static JSBool ShipStaticSetShipDataForKey (JSContext *context, uintN argc, jsval *vp)
void InitOOJSShip (JSContext *context, JSObject *global)
JSClass * JSShipClass (void)
JSObject * JSShipPrototype (void)

Variables

static JSObject * sShipPrototype
static JSClass sShipClass
static JSPropertySpec sShipProperties []
static JSFunctionSpec sShipMethods []
static JSFunctionSpec sShipStaticMethods []

Macro Definition Documentation

◆ GET_THIS_SHIP

#define GET_THIS_SHIP ( THISENT)
Value:
do { \
if (EXPECT_NOT(!JSShipGetShipEntity(context, OOJS_THIS, &THISENT))) \
return NO; /* Exception */ \
if (OOIsStaleEntity(THISENT)) \
} while (0)
#define EXPECT_NOT(x)
OOINLINE BOOL OOIsStaleEntity(Entity *entity)
Definition OOJSEntity.h:69
#define OOJS_THIS
#define OOJS_RETURN_VOID

Definition at line 1823 of file OOJSShip.m.

1823#define GET_THIS_SHIP(THISENT) \
1824 do { \
1825 if (EXPECT_NOT(!JSShipGetShipEntity(context, OOJS_THIS, &THISENT))) \
1826 return NO; /* Exception */ \
1827 if (OOIsStaleEntity(THISENT)) \
1828 OOJS_RETURN_VOID; \
1829 } while (0)

Referenced by RemoveOrExplodeShip(), RemoveOrExplodeShip(), ShipAbandonShip(), ShipAbandonShip(), ShipAddCargoEntity(), ShipAddCargoEntity(), ShipAddCollisionException(), ShipAddCollisionException(), ShipAddDefenseTarget(), ShipAddDefenseTarget(), ShipAdjustCargo(), ShipAdjustCargo(), ShipAwardEquipment(), ShipAwardEquipment(), ShipBecomeCascadeExplosion(), ShipBecomeCascadeExplosion(), ShipBroadcastCascadeImminent(), ShipBroadcastCascadeImminent(), ShipBroadcastDistressMessage(), ShipBroadcastDistressMessage(), ShipCanAwardEquipment(), ShipCanAwardEquipment(), ShipCheckCourseToDestination(), ShipCheckCourseToDestination(), ShipCheckScanner(), ShipCheckScanner(), ShipClearDefenseTargets(), ShipClearDefenseTargets(), ShipCommsMessage(), ShipCommsMessage(), ShipDamageAssessment(), ShipDamageAssessment(), ShipDealEnergyDamage(), ShipDealEnergyDamage(), ShipDeployEscorts(), ShipDeployEscorts(), ShipDockEscorts(), ShipDockEscorts(), ShipDumpCargo(), ShipDumpCargo(), ShipEjectItem(), ShipEjectItem(), ShipEjectSpecificItem(), ShipEjectSpecificItem(), ShipEnterWormhole(), ShipEnterWormhole(), ShipEquipmentStatus(), ShipEquipmentStatus(), ShipExitAI(), ShipExitAI(), ShipExitSystem(), ShipExitSystem(), ShipFindNearestStation(), ShipFindNearestStation(), ShipFireECM(), ShipFireECM(), ShipFireMissile(), ShipFireMissile(), ShipGetMaterials(), ShipGetMaterials(), ShipGetSafeCourseToDestination(), ShipGetSafeCourseToDestination(), ShipGetShaders(), ShipGetShaders(), ShipHasEquipmentProviding(), ShipHasEquipmentProviding(), ShipHasRole(), ShipHasRole(), ShipMarkTargetForFines(), ShipMarkTargetForFines(), ShipNotifyGroupOfWormhole(), ShipNotifyGroupOfWormhole(), ShipOfferToEscort(), ShipOfferToEscort(), ShipPatrolReportIn(), ShipPatrolReportIn(), ShipPerformAttack(), ShipPerformAttack(), ShipPerformCollect(), ShipPerformCollect(), ShipPerformEscort(), ShipPerformEscort(), ShipPerformFaceDestination(), ShipPerformFaceDestination(), ShipPerformFlee(), ShipPerformFlee(), ShipPerformFlyToRangeFromDestination(), ShipPerformFlyToRangeFromDestination(), ShipPerformHold(), ShipPerformHold(), ShipPerformIdle(), ShipPerformIdle(), ShipPerformIntercept(), ShipPerformIntercept(), ShipPerformLandOnPlanet(), ShipPerformLandOnPlanet(), ShipPerformMining(), ShipPerformMining(), ShipPerformScriptedAI(), ShipPerformScriptedAI(), ShipPerformScriptedAttackAI(), ShipPerformScriptedAttackAI(), ShipPerformStop(), ShipPerformStop(), ShipPerformTumble(), ShipPerformTumble(), ShipReactToAIMessage(), ShipReactToAIMessage(), ShipRecallDockingInstructions(), ShipRecallDockingInstructions(), ShipRemove(), ShipRemove(), ShipRemoveCollisionException(), ShipRemoveCollisionException(), ShipRemoveDefenseTarget(), ShipRemoveDefenseTarget(), ShipRemoveEquipment(), ShipRemoveEquipment(), ShipRequestDockingInstructions(), ShipRequestDockingInstructions(), ShipRequestHelpFromGroup(), ShipRequestHelpFromGroup(), ShipRestoreSubEntities(), ShipRestoreSubEntities(), ShipRunLegacyScriptActions(), ShipRunLegacyScriptActions(), ShipSelectNewMissile(), ShipSelectNewMissile(), ShipSendAIMessage(), ShipSendAIMessage(), ShipSetAI(), ShipSetAI(), ShipSetBounty(), ShipSetBounty(), ShipSetCargo(), ShipSetCargo(), ShipSetCargoType(), ShipSetCargoType(), ShipSetCrew(), ShipSetCrew(), ShipSetEquipmentStatus(), ShipSetEquipmentStatus(), ShipSetMaterials(), ShipSetMaterials(), ShipSetMaterialsInternal(), ShipSetMaterialsInternal(), ShipSetScript(), ShipSetScript(), ShipSetShaders(), ShipSetShaders(), ShipSpawn(), ShipSpawn(), ShipSwitchAI(), ShipSwitchAI(), ShipThreatAssessment(), ShipThreatAssessment(), ShipThrowSpark(), ShipThrowSpark(), ShipUpdateEscortFormation(), and ShipUpdateEscortFormation().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kShip_accuracy 
kShip_aftWeapon 
kShip_AI 
kShip_AIScript 
kShip_AIScriptWakeTime 
kShip_AIState 
kShip_AIFoundTarget 
kShip_AIPrimaryAggressor 
kShip_alertCondition 
kShip_autoAI 
kShip_autoWeapons 
kShip_beaconCode 
kShip_beaconLabel 
kShip_boundingBox 
kShip_bounty 
kShip_cargoList 
kShip_cargoSpaceAvailable 
kShip_cargoSpaceCapacity 
kShip_cargoSpaceUsed 
kShip_collisionExceptions 
kShip_contracts 
kShip_commodity 
kShip_commodityAmount 
kShip_cloakAutomatic 
kShip_crew 
kShip_cruiseSpeed 
kShip_currentWeapon 
kShip_dataKey 
kShip_defenseTargets 
kShip_desiredRange 
kShip_desiredSpeed 
kShip_destination 
kShip_destinationSystem 
kShip_displayName 
kShip_dockingInstructions 
kShip_energyRechargeRate 
kShip_entityPersonality 
kShip_equipment 
kShip_escortGroup 
kShip_escorts 
kShip_exhaustEmissiveColor 
kShip_exhausts 
kShip_extraCargo 
kShip_flashers 
kShip_forwardWeapon 
kShip_fuel 
kShip_fuelChargeRate 
kShip_group 
kShip_hasHostileTarget 
kShip_hasHyperspaceMotor 
kShip_hasSuspendedAI 
kShip_heading 
kShip_heatInsulation 
kShip_homeSystem 
kShip_hyperspaceSpinTime 
kShip_injectorBurnRate 
kShip_injectorSpeedFactor 
kShip_isBeacon 
kShip_isBoulder 
kShip_isCargo 
kShip_isCloaked 
kShip_isDerelict 
kShip_isFrangible 
kShip_isFleeing 
kShip_isJamming 
kShip_isMinable 
kShip_isMine 
kShip_isMissile 
kShip_isPiloted 
kShip_isPirate 
kShip_isPirateVictim 
kShip_isPolice 
kShip_isRock 
kShip_isThargoid 
kShip_isTurret 
kShip_isTrader 
kShip_isWeapon 
kShip_laserHeatLevel 
kShip_laserHeatLevelAft 
kShip_laserHeatLevelForward 
kShip_laserHeatLevelPort 
kShip_laserHeatLevelStarboard 
kShip_lightsActive 
kShip_markedForFines 
kShip_maxEscorts 
kShip_maxPitch 
kShip_maxSpeed 
kShip_maxRoll 
kShip_maxYaw 
kShip_maxThrust 
kShip_missileCapacity 
kShip_missileLoadTime 
kShip_missiles 
kShip_name 
kShip_parcelCount 
kShip_parcels 
kShip_passengerCapacity 
kShip_passengerCount 
kShip_passengers 
kShip_pitch 
kShip_portWeapon 
kShip_potentialCollider 
kShip_primaryRole 
kShip_reactionTime 
kShip_reportAIMessages 
kShip_roleWeights 
kShip_roles 
kShip_roll 
kShip_savedCoordinates 
kShip_scanDescription 
kShip_scannerDisplayColor1 
kShip_scannerDisplayColor2 
kShip_scannerHostileDisplayColor1 
kShip_scannerHostileDisplayColor2 
kShip_scannerRange 
kShip_script 
kShip_scriptedMisjump 
kShip_scriptedMisjumpRange 
kShip_scriptInfo 
kShip_shipClassName 
kShip_shipUniqueName 
kShip_speed 
kShip_starboardWeapon 
kShip_subEntities 
kShip_subEntityCapacity 
kShip_subEntityRotation 
kShip_sunGlareFilter 
kShip_target 
kShip_temperature 
kShip_thrust 
kShip_thrustVector 
kShip_trackCloseContacts 
kShip_vectorForward 
kShip_vectorRight 
kShip_vectorUp 
kShip_velocity 
kShip_weaponFacings 
kShip_weaponPositionAft 
kShip_weaponPositionForward 
kShip_weaponPositionPort 
kShip_weaponPositionStarboard 
kShip_weaponRange 
kShip_withinStationAegis 
kShip_yaw 

Definition at line 177 of file OOJSShip.m.

177 {
178 // Property IDs
179 kShip_accuracy = -128, // the ship's accuracy, float, read/write
180 kShip_aftWeapon, // the ship's aft weapon, equipmentType, read/write
181 kShip_AI, // AI state machine name, string, read-only
182 kShip_AIScript, // AI script, Script, read-only
183 kShip_AIScriptWakeTime, // next wakeup time, integer, read/write
184 kShip_AIState, // AI state machine state, string, read/write
185 kShip_AIFoundTarget, // AI "found target", entity, read/write
186 kShip_AIPrimaryAggressor, // AI "primary aggressor", entity, read/write
187 kShip_alertCondition, // number 0-3, read-only, combat alert level
188 kShip_autoAI, // bool, read-only, auto_ai from shipdata
189 kShip_autoWeapons, // bool, read-only, auto_weapons from shipdata
190 kShip_beaconCode, // beacon code, string, read/write
191 kShip_beaconLabel, // beacon label, string, read/write
192 kShip_boundingBox, // boundingBox, vector, read-only
193 kShip_bounty, // bounty, unsigned int, read/write
194 kShip_cargoList, // cargo on board, array of objects, read-only
195 kShip_cargoSpaceAvailable, // free cargo space, integer, read-only
196 kShip_cargoSpaceCapacity, // maximum cargo, integer, read/write
197 kShip_cargoSpaceUsed, // cargo on board, integer, read-only
198 kShip_collisionExceptions, // collision exception list, array, read-only
199 kShip_contracts, // cargo contracts contracts, array - strings & whatnot, read only
200 kShip_commodity, // commodity of a ship, read only
201 kShip_commodityAmount, // commodityAmount of a ship, read only
202 kShip_cloakAutomatic, // should cloack start by itself or by script, read/write
203 kShip_crew, // crew, list, read only
204 kShip_cruiseSpeed, // desired cruising speed, number, read only
205 kShip_currentWeapon, // the ship's active weapon, equipmentType, read/write
206 kShip_dataKey, // string, read-only, shipdata.plist key
207 kShip_defenseTargets, // array, read-only, defense targets
208 kShip_desiredRange, // desired Range, double, read/write
209 kShip_desiredSpeed, // AI desired flight speed, double, read/write
210 kShip_destination, // flight destination, Vector, read/write
211 kShip_destinationSystem, // destination system, number, read/write
212 kShip_displayName, // name displayed on screen, string, read/write
213 kShip_dockingInstructions, // name displayed on screen, string, read/write
214 kShip_energyRechargeRate, // energy recharge rate, float, read-only
215 kShip_entityPersonality, // per-ship random number, int, read-only
216 kShip_equipment, // the ship's equipment, array of EquipmentInfo, read only
217 kShip_escortGroup, // group, ShipGroup, read-only
218 kShip_escorts, // deployed escorts, array of Ship, read-only
219 kShip_exhaustEmissiveColor, // exhaust emissive color, array, read/write
220 kShip_exhausts, // exhausts, array, read-only
221 kShip_extraCargo, // cargo space increase granted by large cargo bay, int, read-only
222 kShip_flashers, // flashers, array, read-only
223 kShip_forwardWeapon, // the ship's forward weapon, equipmentType, read/write
224 kShip_fuel, // fuel, float, read/write
225 kShip_fuelChargeRate, // fuel scoop rate & charge multiplier, float, read-only
226 kShip_group, // group, ShipGroup, read/write
227 kShip_hasHostileTarget, // has hostile target, boolean, read-only
228 kShip_hasHyperspaceMotor, // has hyperspace motor, boolean, read-only
229 kShip_hasSuspendedAI, // AI has suspended states, boolean, read-only
230 kShip_heading, // forwardVector of a ship, read-only
231 kShip_heatInsulation, // hull heat insulation, double, read/write
232 kShip_homeSystem, // home system, number, read/write
233 kShip_hyperspaceSpinTime, // hyperspace spin time, float, read/write
234 kShip_injectorBurnRate, // injector burn rate, number, read/write dLY/s
235 kShip_injectorSpeedFactor, // injector speed factor, number, read/write
236 kShip_isBeacon, // is beacon, boolean, read-only
237 kShip_isBoulder, // is a boulder (generates splinters), boolean, read/write
238 kShip_isCargo, // contains cargo, boolean, read-only
239 kShip_isCloaked, // cloaked, boolean, read/write (if cloaking device installed)
240 kShip_isDerelict, // is an abandoned ship, boolean, read-only
241 kShip_isFrangible, // frangible, boolean, read-only
242 kShip_isFleeing, // is fleeing, boolean, read-only
243 kShip_isJamming, // jamming scanners, boolean, read/write (if jammer installed)
244 kShip_isMinable, // is a sensible target for mining, boolean, read-only
245 kShip_isMine, // is mine, boolean, read-only
246 kShip_isMissile, // is missile, boolean, read-only
247 kShip_isPiloted, // is piloted, boolean, read-only (includes stations)
248 kShip_isPirate, // is pirate, boolean, read-only
249 kShip_isPirateVictim, // is pirate victim, boolean, read-only
250 kShip_isPolice, // is police, boolean, read-only
251 kShip_isRock, // is a rock (hermits included), boolean, read-only
252 kShip_isThargoid, // is thargoid, boolean, read-only
253 kShip_isTurret, // is turret, boolean, read-only
254 kShip_isTrader, // is trader, boolean, read-only
255 kShip_isWeapon, // is missile or mine, boolean, read-only
256 kShip_laserHeatLevel, // active laser temperature, float, read-only
257 kShip_laserHeatLevelAft, // aft laser temperature, float, read-only
258 kShip_laserHeatLevelForward, // fore laser temperature, float, read-only
259 kShip_laserHeatLevelPort, // port laser temperature, float, read-only
260 kShip_laserHeatLevelStarboard, // starboard laser temperature, float, read-only
261 kShip_lightsActive, // flasher/shader light flag, boolean, read/write
262 kShip_markedForFines, // has been marked for fines
263 kShip_maxEscorts, // maximum escort count, int, read/write
264 kShip_maxPitch, // maximum flight pitch, double, read-only
265 kShip_maxSpeed, // maximum flight speed, double, read-only
266 kShip_maxRoll, // maximum flight roll, double, read-only
267 kShip_maxYaw, // maximum flight yaw, double, read-only
268 kShip_maxThrust, // maximum thrust, double, read-only
269 kShip_missileCapacity, // max missiles capacity, integer, read-only
270 kShip_missileLoadTime, // missile load time, double, read/write
271 kShip_missiles, // the ship's missiles / external storage, array of equipmentTypes, read only
272 kShip_name, // name, string, read-only
273 kShip_parcelCount, // number of parcels on ship, integer, read-only
274 kShip_parcels, // parcel contracts, array - strings & whatnot, read only
275 kShip_passengerCapacity, // amount of passenger space on ship, integer, read-only
276 kShip_passengerCount, // number of passengers on ship, integer, read-only
277 kShip_passengers, // passengers contracts, array - strings & whatnot, read only
278 kShip_pitch, // pitch level, float, read-only
279 kShip_portWeapon, // the ship's port weapon, equipmentType, read/write
280 kShip_potentialCollider, // "proximity alert" ship, Entity, read-only
281 kShip_primaryRole, // Primary role, string, read/write
282 kShip_reactionTime, // AI reaction time, read/write
283 kShip_reportAIMessages, // report AI messages, boolean, read/write
284 kShip_roleWeights, // roles and weights, dictionary, read-only
285 kShip_roles, // roles, array, read-only
286 kShip_roll, // roll level, float, read-only
287 kShip_savedCoordinates, // coordinates in system space for AI use, Vector, read/write
288 kShip_scanDescription, // STE scan class label, string, read/write
289 kShip_scannerDisplayColor1, // color of lollipop shown on scanner, array, read/write
290 kShip_scannerDisplayColor2, // color of lollipop shown on scanner when flashing, array, read/write
291 kShip_scannerHostileDisplayColor1, // color of lollipop shown on scanner, array, read/write
292 kShip_scannerHostileDisplayColor2, // color of lollipop shown on scanner when flashing, array, read/write
293 kShip_scannerRange, // scanner range, double, read-only
294 kShip_script, // script, Script, read-only
295 kShip_scriptedMisjump, // next jump will miss if set to true, boolean, read/write
296 kShip_scriptedMisjumpRange, // 0..1 range of next misjump, float, read/write
297 kShip_scriptInfo, // arbitrary data for scripts, dictionary, read-only
298 kShip_shipClassName, // ship type name, string, read/write
299 kShip_shipUniqueName, // uniqish name, string, read/write
300 kShip_speed, // current flight speed, double, read-only
301 kShip_starboardWeapon, // the ship's starboard weapon, equipmentType, read/write
302 kShip_subEntities, // subentities, array of Ship, read-only
303 kShip_subEntityCapacity, // max subentities for this ship, int, read-only
304 kShip_subEntityRotation, // subentity rotation velocity, quaternion, read/write
305 kShip_sunGlareFilter, // sun glare filter multiplier, float, read/write
306 kShip_target, // target, Ship, read/write
307 kShip_temperature, // hull temperature, double, read/write
308 kShip_thrust, // the ship's thrust, double, read/write
309 kShip_thrustVector, // thrust-related component of velocity, vector, read-only
310 kShip_trackCloseContacts, // generate close contact events, boolean, read/write
311 kShip_vectorForward, // forwardVector of a ship, read-only
312 kShip_vectorRight, // rightVector of a ship, read-only
313 kShip_vectorUp, // upVector of a ship, read-only
314 kShip_velocity, // velocity, vector, read/write
315 kShip_weaponFacings, // available facings, int, read-only
316 kShip_weaponPositionAft, // weapon offset, vector, read-only
317 kShip_weaponPositionForward, // weapon offset, vector, read-only
318 kShip_weaponPositionPort, // weapon offset, vector, read-only
319 kShip_weaponPositionStarboard, // weapon offset, vector, read-only
320 kShip_weaponRange, // weapon range, double, read-only
321 kShip_withinStationAegis, // within main station aegis, boolean, read/write
322 kShip_yaw, // yaw level, float, read-only
323};
@ kShip_isMissile
Definition OOJSShip.m:246
@ kShip_AIScriptWakeTime
Definition OOJSShip.m:183
@ kShip_weaponPositionPort
Definition OOJSShip.m:318
@ kShip_hyperspaceSpinTime
Definition OOJSShip.m:233
@ kShip_cargoSpaceUsed
Definition OOJSShip.m:197
@ kShip_destination
Definition OOJSShip.m:210
@ kShip_escorts
Definition OOJSShip.m:218
@ kShip_fuelChargeRate
Definition OOJSShip.m:225
@ kShip_missileCapacity
Definition OOJSShip.m:269
@ kShip_collisionExceptions
Definition OOJSShip.m:198
@ kShip_target
Definition OOJSShip.m:306
@ kShip_commodityAmount
Definition OOJSShip.m:201
@ kShip_autoWeapons
Definition OOJSShip.m:189
@ kShip_weaponFacings
Definition OOJSShip.m:315
@ kShip_subEntityCapacity
Definition OOJSShip.m:303
@ kShip_isFleeing
Definition OOJSShip.m:242
@ kShip_group
Definition OOJSShip.m:226
@ kShip_potentialCollider
Definition OOJSShip.m:280
@ kShip_thrustVector
Definition OOJSShip.m:309
@ kShip_AIState
Definition OOJSShip.m:184
@ kShip_accuracy
Definition OOJSShip.m:179
@ kShip_autoAI
Definition OOJSShip.m:188
@ kShip_isFrangible
Definition OOJSShip.m:241
@ kShip_maxPitch
Definition OOJSShip.m:264
@ kShip_alertCondition
Definition OOJSShip.m:187
@ kShip_hasHostileTarget
Definition OOJSShip.m:227
@ kShip_passengers
Definition OOJSShip.m:277
@ kShip_maxEscorts
Definition OOJSShip.m:263
@ kShip_exhaustEmissiveColor
Definition OOJSShip.m:219
@ kShip_weaponRange
Definition OOJSShip.m:320
@ kShip_cloakAutomatic
Definition OOJSShip.m:202
@ kShip_isRock
Definition OOJSShip.m:251
@ kShip_subEntities
Definition OOJSShip.m:302
@ kShip_injectorSpeedFactor
Definition OOJSShip.m:235
@ kShip_laserHeatLevelAft
Definition OOJSShip.m:257
@ kShip_AIPrimaryAggressor
Definition OOJSShip.m:186
@ kShip_escortGroup
Definition OOJSShip.m:217
@ kShip_maxThrust
Definition OOJSShip.m:268
@ kShip_isBoulder
Definition OOJSShip.m:237
@ kShip_displayName
Definition OOJSShip.m:212
@ kShip_scanDescription
Definition OOJSShip.m:288
@ kShip_dataKey
Definition OOJSShip.m:206
@ kShip_reportAIMessages
Definition OOJSShip.m:283
@ kShip_lightsActive
Definition OOJSShip.m:261
@ kShip_desiredSpeed
Definition OOJSShip.m:209
@ kShip_crew
Definition OOJSShip.m:203
@ kShip_isCargo
Definition OOJSShip.m:238
@ kShip_commodity
Definition OOJSShip.m:200
@ kShip_velocity
Definition OOJSShip.m:314
@ kShip_forwardWeapon
Definition OOJSShip.m:223
@ kShip_reactionTime
Definition OOJSShip.m:282
@ kShip_beaconLabel
Definition OOJSShip.m:191
@ kShip_extraCargo
Definition OOJSShip.m:221
@ kShip_heatInsulation
Definition OOJSShip.m:231
@ kShip_vectorForward
Definition OOJSShip.m:311
@ kShip_heading
Definition OOJSShip.m:230
@ kShip_currentWeapon
Definition OOJSShip.m:205
@ kShip_roles
Definition OOJSShip.m:285
@ kShip_weaponPositionForward
Definition OOJSShip.m:317
@ kShip_shipClassName
Definition OOJSShip.m:298
@ kShip_equipment
Definition OOJSShip.m:216
@ kShip_starboardWeapon
Definition OOJSShip.m:301
@ kShip_cargoList
Definition OOJSShip.m:194
@ kShip_name
Definition OOJSShip.m:272
@ kShip_defenseTargets
Definition OOJSShip.m:207
@ kShip_scannerDisplayColor2
Definition OOJSShip.m:290
@ kShip_vectorRight
Definition OOJSShip.m:312
@ kShip_markedForFines
Definition OOJSShip.m:262
@ kShip_AIScript
Definition OOJSShip.m:182
@ kShip_laserHeatLevelPort
Definition OOJSShip.m:259
@ kShip_passengerCount
Definition OOJSShip.m:276
@ kShip_roleWeights
Definition OOJSShip.m:284
@ kShip_weaponPositionAft
Definition OOJSShip.m:316
@ kShip_scriptedMisjump
Definition OOJSShip.m:295
@ kShip_shipUniqueName
Definition OOJSShip.m:299
@ kShip_isBeacon
Definition OOJSShip.m:236
@ kShip_isMine
Definition OOJSShip.m:245
@ kShip_scriptInfo
Definition OOJSShip.m:297
@ kShip_vectorUp
Definition OOJSShip.m:313
@ kShip_isWeapon
Definition OOJSShip.m:255
@ kShip_temperature
Definition OOJSShip.m:307
@ kShip_injectorBurnRate
Definition OOJSShip.m:234
@ kShip_isPirate
Definition OOJSShip.m:248
@ kShip_scannerDisplayColor1
Definition OOJSShip.m:289
@ kShip_bounty
Definition OOJSShip.m:193
@ kShip_hasHyperspaceMotor
Definition OOJSShip.m:228
@ kShip_cargoSpaceCapacity
Definition OOJSShip.m:196
@ kShip_isJamming
Definition OOJSShip.m:243
@ kShip_contracts
Definition OOJSShip.m:199
@ kShip_maxYaw
Definition OOJSShip.m:267
@ kShip_AIFoundTarget
Definition OOJSShip.m:185
@ kShip_isThargoid
Definition OOJSShip.m:252
@ kShip_isTrader
Definition OOJSShip.m:254
@ kShip_portWeapon
Definition OOJSShip.m:279
@ kShip_yaw
Definition OOJSShip.m:322
@ kShip_isPiloted
Definition OOJSShip.m:247
@ kShip_beaconCode
Definition OOJSShip.m:190
@ kShip_savedCoordinates
Definition OOJSShip.m:287
@ kShip_scannerHostileDisplayColor2
Definition OOJSShip.m:292
@ kShip_AI
Definition OOJSShip.m:181
@ kShip_sunGlareFilter
Definition OOJSShip.m:305
@ kShip_weaponPositionStarboard
Definition OOJSShip.m:319
@ kShip_boundingBox
Definition OOJSShip.m:192
@ kShip_scriptedMisjumpRange
Definition OOJSShip.m:296
@ kShip_homeSystem
Definition OOJSShip.m:232
@ kShip_laserHeatLevelStarboard
Definition OOJSShip.m:260
@ kShip_withinStationAegis
Definition OOJSShip.m:321
@ kShip_roll
Definition OOJSShip.m:286
@ kShip_speed
Definition OOJSShip.m:300
@ kShip_cargoSpaceAvailable
Definition OOJSShip.m:195
@ kShip_script
Definition OOJSShip.m:294
@ kShip_laserHeatLevelForward
Definition OOJSShip.m:258
@ kShip_laserHeatLevel
Definition OOJSShip.m:256
@ kShip_aftWeapon
Definition OOJSShip.m:180
@ kShip_exhausts
Definition OOJSShip.m:220
@ kShip_passengerCapacity
Definition OOJSShip.m:275
@ kShip_maxRoll
Definition OOJSShip.m:266
@ kShip_isPirateVictim
Definition OOJSShip.m:249
@ kShip_isDerelict
Definition OOJSShip.m:240
@ kShip_scannerHostileDisplayColor1
Definition OOJSShip.m:291
@ kShip_missileLoadTime
Definition OOJSShip.m:270
@ kShip_energyRechargeRate
Definition OOJSShip.m:214
@ kShip_trackCloseContacts
Definition OOJSShip.m:310
@ kShip_isCloaked
Definition OOJSShip.m:239
@ kShip_missiles
Definition OOJSShip.m:271
@ kShip_destinationSystem
Definition OOJSShip.m:211
@ kShip_isTurret
Definition OOJSShip.m:253
@ kShip_scannerRange
Definition OOJSShip.m:293
@ kShip_isPolice
Definition OOJSShip.m:250
@ kShip_isMinable
Definition OOJSShip.m:244
@ kShip_thrust
Definition OOJSShip.m:308
@ kShip_hasSuspendedAI
Definition OOJSShip.m:229
@ kShip_maxSpeed
Definition OOJSShip.m:265
@ kShip_fuel
Definition OOJSShip.m:224
@ kShip_pitch
Definition OOJSShip.m:278
@ kShip_entityPersonality
Definition OOJSShip.m:215
@ kShip_cruiseSpeed
Definition OOJSShip.m:204
@ kShip_desiredRange
Definition OOJSShip.m:208
@ kShip_dockingInstructions
Definition OOJSShip.m:213
@ kShip_parcels
Definition OOJSShip.m:274
@ kShip_parcelCount
Definition OOJSShip.m:273
@ kShip_flashers
Definition OOJSShip.m:222
@ kShip_subEntityRotation
Definition OOJSShip.m:304
@ kShip_primaryRole
Definition OOJSShip.m:281

Function Documentation

◆ InitOOJSShip()

void InitOOJSShip ( JSContext * context,
JSObject * global )

Definition at line 575 of file OOJSShip.m.

576{
580}
OOINLINE JSClass * JSEntityClass(void)
Definition OOJSEntity.h:42
OOINLINE JSObject * JSEntityPrototype(void)
Definition OOJSEntity.h:43
static JSFunctionSpec sShipStaticMethods[]
Definition OOJSShip.m:562
static JSFunctionSpec sShipMethods[]
Definition OOJSShip.m:476
static JSClass sShipClass
Definition OOJSShip.m:153
static JSPropertySpec sShipProperties[]
Definition OOJSShip.m:325
static JSObject * sShipPrototype
Definition OOJSShip.m:53
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
void OOJSRegisterSubclass(JSClass *subclass, JSClass *superclass)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)

References InitOOJSShip(), JSEntityClass(), JSEntityPrototype(), OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSRegisterSubclass(), OOJSUnconstructableConstruct(), sShipClass, sShipMethods, sShipProperties, sShipPrototype, and sShipStaticMethods.

Referenced by OOJavaScriptEngine(Private)::createMainThreadContext, InitOOJSShip(), and InitOOJSShip().

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

◆ JSShipClass()

JSClass * JSShipClass ( void )

Definition at line 582 of file OOJSShip.m.

583{
584 return &sShipClass;
585}

References sShipClass.

Referenced by ShipEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, InitOOJSDock(), InitOOJSPlayerShip(), and InitOOJSStation().

Here is the caller graph for this function:

◆ JSShipPrototype()

JSObject * JSShipPrototype ( void )

Definition at line 587 of file OOJSShip.m.

588{
589 return sShipPrototype;
590}

References sShipPrototype.

Referenced by ShipEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, InitOOJSDock(), InitOOJSPlayerShip(), and InitOOJSStation().

Here is the caller graph for this function:

◆ RemoveOrExplodeShip()

BOOL RemoveOrExplodeShip ( JSContext * context,
uintN argc,
jsval * vp,
BOOL explode )
static

Definition at line 3090 of file OOJSShip.m.

3091{
3093
3094 ShipEntity* thisEnt = nil;
3095
3096 GET_THIS_SHIP(thisEnt);
3097
3098 if (EXPECT_NOT([thisEnt isPlayer])) {
3099 NSCAssert(explode, @"RemoveOrExplodeShip(): shouldn't be called for player with !explode."); // player.ship.remove() is blocked by caller.
3100 PlayerEntity* player = (PlayerEntity*)thisEnt;
3101
3102 if ([player isDocked]) {
3103 OOJSReportError(context, @"Cannot explode() player's ship while docked.");
3104 return NO;
3105 }
3106 }
3107
3108 if (thisEnt == (ShipEntity*)[UNIVERSE station]) {
3109 // Allow exploding of main station (e.g. nova mission)
3110 [UNIVERSE unMagicMainStation];
3111 }
3112
3113 if (EXPECT_NOT([thisEnt status] == STATUS_DOCKED)) {
3114 /* If it's in the launch queue and hasn't yet been added to
3115 * the universe, set the status to DEAD (so it gets removed
3116 * from the launch queue) */
3117 [thisEnt setStatus:STATUS_DEAD];
3118 /* No shipDied event occurs in this place - it never really
3119 * existed. This case is just to prevent an error from the
3120 * usual code branch - removing ships while they're still
3121 * docked is not recommended. */
3122 } else {
3123 [thisEnt setSuppressExplosion:!explode];
3124 [thisEnt setEnergy:1];
3125 [thisEnt takeEnergyDamage:500000000.0 from:nil becauseOf:nil weaponIdentifier:@""];
3126 }
3127
3129
3131}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
#define GET_THIS_SHIP(THISENT)
Definition OOJSShip.m:1823
void OOJSReportError(JSContext *context, NSString *format,...)
return nil
#define UNIVERSE
Definition Universe.h:827

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_VOID, OOJSReportError(), and UNIVERSE.

Referenced by ShipExplode(), ShipExplode(), ShipRemove(), and ShipRemove().

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

◆ ShipAbandonShip()

JSBool ShipAbandonShip ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2395 of file OOJSShip.m.

2396{
2397 OOJS_NATIVE_ENTER(context)
2398
2399 ShipEntity* thisEnt = nil;
2400
2401 GET_THIS_SHIP(thisEnt);
2402 OOJS_RETURN_BOOL([thisEnt hasEscapePod] && [thisEnt abandonShip]);
2403
2405}
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
#define OOJS_RETURN_BOOL(v)

References GET_THIS_SHIP, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJS_RETURN_BOOL.

◆ ShipAddCargoEntity()

JSBool ShipAddCargoEntity ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2089 of file OOJSShip.m.

2090{
2091 OOJS_NATIVE_ENTER(context)
2092 ShipEntity* thisEnt = nil;
2093 ShipEntity* target = nil;
2094 JSBool procEvents = NO;
2095 JSBool procMessages = NO;
2096
2097 GET_THIS_SHIP(thisEnt);
2098
2099 if (EXPECT_NOT([thisEnt isPlayer] && [(PlayerEntity*)thisEnt isDocked])) {
2100 OOJSReportWarningForCaller(context, @"PlayerShip", @"addCargoEntity", @"Can't add cargo entity while docked, ignoring.");
2101 return NO;
2102 }
2103 if (EXPECT_NOT(argc == 0 || JSVAL_IS_NULL(OOJS_ARGV[0]) || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &target))) {
2104 OOJSReportBadArguments(context, @"PlayerShip", @"addCargoEntity", MIN(argc, 1U), OOJS_ARGV, nil, @"scoopable entity.");
2105 return NO;
2106 }
2107 if ([target scanClass] != CLASS_CARGO) {
2108 OOJSReportWarningForCaller(context, @"PlayerShip", @"addCargoEntity", @"Scoopable entity not cargo.");
2109 return NO;
2110 }
2111 if ([target status] != STATUS_IN_FLIGHT) {
2112 OOJSReportWarningForCaller(context, @"PlayerShip", @"addCargoEntity", @"Scoopable entity not in flight.");
2113 return NO;
2114 }
2115 if (argc >= 2 && EXPECT_NOT(!JS_ValueToBoolean(context, OOJS_ARGV[1], &procEvents))) {
2116 OOJSReportBadArguments(context, @"PlayerShip", @"addCargoEntity", MIN(argc, 2U), OOJS_ARGV, nil, @"boolean");
2117 return NO;
2118 }
2119 if (argc == 3 && EXPECT_NOT(!JS_ValueToBoolean(context, OOJS_ARGV[2], &procMessages))) {
2120 OOJSReportBadArguments(context, @"PlayerShip", @"addCargoEntity", MIN(argc, 3U), OOJS_ARGV, nil, @"boolean");
2121 return NO;
2122 }
2123
2124 // scoop the object, but don't process any events/messages unless requested
2125 OOJS_BEGIN_FULL_NATIVE(context)
2126 [thisEnt scoopUpProcess:target processEvents:procEvents processMessages:procMessages];
2128
2129 OOJS_RETURN_BOOL([target status] == STATUS_IN_HOLD);
2130
2132}
#define OOJS_END_FULL_NATIVE
#define OOJS_BEGIN_FULL_NATIVE(context)
void OOJSReportWarningForCaller(JSContext *context, NSString *scriptClass, NSString *function, NSString *format,...)
#define OOJS_ARGV
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define MIN(A, B)
Definition OOMaths.h:91
void scoopUpProcess:processEvents:processMessages:(ShipEntity *other,[processEvents] BOOL proc_events,[processMessages] BOOL proc_messages)

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportWarningForCaller(), and ShipEntity::scoopUpProcess:processEvents:processMessages:.

Here is the call graph for this function:

◆ ShipAddCollisionException()

JSBool ShipAddCollisionException ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3186 of file OOJSShip.m.

3187{
3189
3190 ShipEntity* thisEnt = nil;
3191 ShipEntity* target = nil;
3192
3193 GET_THIS_SHIP(thisEnt);
3194 if (EXPECT_NOT(argc == 0 || (argc > 0 && (JSVAL_IS_NULL(OOJS_ARGV[0]) || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &target))))) {
3195 OOJSReportBadArguments(context, @"Ship", @"addCollisionException", 1U, OOJS_ARGV, nil, @"other ship");
3196 return NO;
3197 }
3198
3199 // have to do it both ways because it's not defined which order
3200 // the collisions get tested in. More efficient to add both ways
3201 // than to test both ways
3202 [thisEnt addCollisionException:target];
3203 [target addCollisionException:thisEnt];
3204
3206
3208}
void addCollisionException:(ShipEntity *ship)

References ShipEntity::addCollisionException:, EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_VOID, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipAddDefenseTarget()

JSBool ShipAddDefenseTarget ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3146 of file OOJSShip.m.

3147{
3149
3150 ShipEntity* thisEnt = nil;
3151 ShipEntity* target = nil;
3152
3153 GET_THIS_SHIP(thisEnt);
3154 if (EXPECT_NOT(argc == 0 || (argc > 0 && (JSVAL_IS_NULL(OOJS_ARGV[0]) || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &target))))) {
3155 OOJSReportBadArguments(context, @"Ship", @"addDefenseTarget", 1U, OOJS_ARGV, nil, @"target");
3156 return NO;
3157 }
3158
3159 [thisEnt addDefenseTarget:target];
3160
3162
3164}

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_VOID, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipAdjustCargo()

JSBool ShipAdjustCargo ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3728 of file OOJSShip.m.

3729{
3731
3732 ShipEntity* thisEnt = nil;
3733 NSString* commodity = @"";
3734 int32 adjustment = 0;
3735
3736 GET_THIS_SHIP(thisEnt);
3737
3738 if (argc < 2) {
3739 OOJSReportBadArguments(context, @"Ship", @"adjustCargo", argc, OOJS_ARGV, nil, @"commodity, amount");
3740 return NO;
3741 }
3742
3743 commodity = OOStringFromJSValue(context, OOJS_ARGV[0]);
3744 if (!JS_ValueToInt32(context, OOJS_ARGV[1], &adjustment)) {
3745 OOJSReportBadArguments(context, @"Ship", @"adjustCargo", argc, OOJS_ARGV, nil, @"commodity, amount");
3746 return NO;
3747 }
3748
3749 if ([thisEnt cargoType] != CARGO_NOT_CARGO || [thisEnt isPlayer]) {
3750 OOJSReportError(context, @"ship.adjustCargo may only be used on NPC cargo carriers");
3751 return NO;
3752 }
3753
3754 BOOL ok = YES;
3755
3756 if (adjustment > 0) {
3757 NSArray* cargo = [UNIVERSE getContainersOfCommodity:commodity how_much:adjustment]; // non-reified templates
3758 ok = [thisEnt addCargo:cargo];
3759 } else if (adjustment < 0) {
3760 OOCargoQuantity r = (OOCargoQuantity)(-adjustment);
3761 ok = [thisEnt removeCargo:commodity amount:r];
3762 }
3763
3764 OOJS_RETURN_BOOL(ok);
3765
3767}
NSString * OOStringFromJSValue(JSContext *context, jsval value)
@ CARGO_NOT_CARGO
Definition OOTypes.h:61
uint32_t OOCargoQuantity
Definition OOTypes.h:155

References CARGO_NOT_CARGO, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportError(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipAwardEquipment()

JSBool ShipAwardEquipment ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2454 of file OOJSShip.m.

2455{
2456 OOJS_NATIVE_ENTER(context)
2457
2458 ShipEntity* thisEnt = nil;
2459 OOEquipmentType* eqType = nil;
2460 NSString* identifier = nil;
2461 BOOL OK = YES;
2462 BOOL berth;
2463 BOOL isRepair = NO;
2464
2465 GET_THIS_SHIP(thisEnt);
2466
2467 if (argc > 0)
2468 eqType = JSValueToEquipmentType(context, OOJS_ARGV[0]);
2469 if (EXPECT_NOT(eqType == nil)) {
2470 OOJSReportBadArguments(context, @"Ship", @"awardEquipment", MIN(argc, 1U), OOJS_ARGV, nil, @"equipment type");
2471 return NO;
2472 }
2473
2474 // Check that equipment is permitted.
2475 identifier = [eqType identifier];
2476 berth = [identifier isEqualToString:@"EQ_PASSENGER_BERTH"];
2477 if (berth) {
2478 OK = [thisEnt availableCargoSpace] >= [eqType requiredCargoSpace];
2479 } else if ([identifier isEqualToString:@"EQ_FUEL"]) {
2480 OK = NO;
2481 } else {
2482 OK = [eqType canCarryMultiple] || ![thisEnt hasEquipmentItem:identifier];
2483 }
2484
2485 if (OK) {
2486 if ([thisEnt isPlayer]) {
2487 PlayerEntity* player = (PlayerEntity*)thisEnt;
2488
2489 if ([identifier isEqualToString:@"EQ_MISSILE_REMOVAL"]) {
2490 [player removeMissiles];
2491 } else if ([eqType isMissileOrMine]) {
2492 OK = [player mountMissileWithRole:identifier];
2493 } else if (berth) {
2494 OK = [player changePassengerBerths:+1];
2495 } else if ([identifier isEqualToString:@"EQ_PASSENGER_BERTH_REMOVAL"]) {
2496 OK = [player changePassengerBerths:-1];
2497 } else {
2498 isRepair = [thisEnt hasEquipmentItem:[identifier stringByAppendingString:@"_DAMAGED"]];
2499 OK = [player addEquipmentItem:identifier withValidation:YES inContext:@"scripted"];
2500 if (OK && isRepair) {
2501 [player doScriptEvent:OOJSID("equipmentRepaired") withArgument:identifier];
2502 }
2503 }
2504 } else {
2505 if ([identifier isEqualToString:@"EQ_MISSILE_REMOVAL"]) {
2506 [thisEnt removeMissiles];
2507 }
2508 // no passenger handling for NPCs. EQ_CARGO_BAY is dealt with inside addEquipmentItem
2509 else if (!berth && ![identifier isEqualToString:@"EQ_PASSENGER_BERTH_REMOVAL"]) {
2510 OK = [thisEnt addEquipmentItem:identifier withValidation:YES inContext:@"scripted"];
2511 } else {
2512 OK = NO;
2513 }
2514 }
2515 }
2516
2517 OOJS_RETURN_BOOL(OK);
2518
2520}
OOEquipmentType * JSValueToEquipmentType(JSContext *context, jsval value)
OOCargoQuantity requiredCargoSpace()
NSString * identifier()
BOOL addEquipmentItem:withValidation:inContext:(NSString *equipmentKey, [withValidation] BOOL validateAddition, [inContext] NSString *context)
BOOL changePassengerBerths:(int addRemove)
OOCreditsQuantity removeMissiles()
BOOL mountMissileWithRole:(NSString *role)
BOOL addEquipmentItem:withValidation:inContext:(NSString *equipmentKey,[withValidation] BOOL validateAddition,[inContext] NSString *context)
OOCargoQuantity availableCargoSpace()
OOCreditsQuantity removeMissiles()
BOOL hasEquipmentItem:(id equipmentKeys)
void doScriptEvent:withArgument:(OOJSPropID message,[withArgument] id argument)

References PlayerEntity::addEquipmentItem:withValidation:inContext:, ShipEntity::addEquipmentItem:withValidation:inContext:, ShipEntity::availableCargoSpace, OOEquipmentType::canCarryMultiple, PlayerEntity::changePassengerBerths:, ShipEntity::doScriptEvent:withArgument:, EXPECT_NOT, GET_THIS_SHIP, ShipEntity::hasEquipmentItem:, OOEquipmentType::identifier, JSValueToEquipmentType(), MIN, PlayerEntity::mountMissileWithRole:, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), PlayerEntity::removeMissiles, ShipEntity::removeMissiles, and OOEquipmentType::requiredCargoSpace.

Here is the call graph for this function:

◆ ShipBecomeCascadeExplosion()

JSBool ShipBecomeCascadeExplosion ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3281 of file OOJSShip.m.

3282{
3284
3285 ShipEntity* thisEnt = nil;
3286 GET_THIS_SHIP(thisEnt);
3287 [thisEnt becomeEnergyBlast];
3288
3290
3292}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipBroadcastCascadeImminent()

JSBool ShipBroadcastCascadeImminent ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3268 of file OOJSShip.m.

3269{
3271
3272 ShipEntity* thisEnt = nil;
3273 GET_THIS_SHIP(thisEnt);
3274 [thisEnt broadcastEnergyBlastImminent];
3275
3277
3279}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipBroadcastDistressMessage()

JSBool ShipBroadcastDistressMessage ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3657 of file OOJSShip.m.

3658{
3660
3661 ShipEntity* thisEnt = nil;
3662 GET_THIS_SHIP(thisEnt);
3663 [thisEnt broadcastDistressMessageWithDumping:NO];
3664
3666
3668}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipCanAwardEquipment()

JSBool ShipCanAwardEquipment ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2408 of file OOJSShip.m.

2409{
2410 OOJS_NATIVE_ENTER(context)
2411
2412 ShipEntity* thisEnt = nil;
2413 NSString* key = nil;
2414 NSString* ctx = @"scripted";
2415 BOOL result;
2416 BOOL exists;
2417
2418 GET_THIS_SHIP(thisEnt);
2419
2420 if (argc > 0)
2421 key = JSValueToEquipmentKeyRelaxed(context, OOJS_ARGV[0], &exists);
2422 if (EXPECT_NOT(key == nil)) {
2423 OOJSReportBadArguments(context, @"Ship", @"canAwardEquipment", MIN(argc, 1U), OOJS_ARGV, nil, @"equipment type");
2424 return NO;
2425 }
2426
2427 if (exists) {
2428 if (argc > 1) {
2429 ctx = OOStringFromJSValue(context, OOJS_ARGV[1]);
2430 if (![ctx isEqualToString:@"scripted"] && ![ctx isEqualToString:@"purchase"] && ![ctx isEqualToString:@"newShip"] && ![ctx isEqualToString:@"npc"]) {
2431 OOJSReportBadArguments(context, @"Ship", @"canAwardEquipment", MIN(argc, 2U), OOJS_ARGV, nil, @"context");
2432 return NO;
2433 }
2434 }
2435 result = YES;
2436
2437 // can't add fuel as equipment.
2438 if ([key isEqualToString:@"EQ_FUEL"])
2439 result = NO;
2440
2441 if (result)
2442 result = [thisEnt canAddEquipment:key inContext:ctx];
2443 } else {
2444 // Unknown type.
2445 result = NO;
2446 }
2447
2448 OOJS_RETURN_BOOL(result);
2449
2451}
NSString * JSValueToEquipmentKeyRelaxed(JSContext *context, jsval value, BOOL *outExists)
BOOL canAddEquipment:inContext:(NSString *equipmentKey,[inContext] NSString *context)

References ShipEntity::canAddEquipment:inContext:, EXPECT_NOT, GET_THIS_SHIP, JSValueToEquipmentKeyRelaxed(), MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipCheckCourseToDestination()

JSBool ShipCheckCourseToDestination ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3670 of file OOJSShip.m.

3671{
3673
3674 ShipEntity* thisEnt = nil;
3675 GET_THIS_SHIP(thisEnt);
3676
3677 Entity* hazard = [UNIVERSE hazardOnRouteFromEntity:thisEnt toDistance:[thisEnt desiredRange] fromPoint:[thisEnt destination]];
3678
3679 OOJS_RETURN_OBJECT(hazard);
3680
3682}
#define OOJS_RETURN_OBJECT(o)

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_OBJECT.

◆ ShipCheckScanner()

JSBool ShipCheckScanner ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3698 of file OOJSShip.m.

3699{
3701
3702 ShipEntity* thisEnt = nil;
3703 JSBool onlyCheckPowered = NO;
3704
3705 GET_THIS_SHIP(thisEnt);
3706
3707 if (argc > 0 && EXPECT_NOT(!JS_ValueToBoolean(context, OOJS_ARGV[0], &onlyCheckPowered))) {
3708 OOJSReportBadArguments(context, @"Ship", @"checkScanner", argc, OOJS_ARGV, nil, @"boolean");
3709 return NO;
3710 }
3711
3712 if (onlyCheckPowered) {
3713 [thisEnt checkScannerIgnoringUnpowered];
3714 } else {
3715 [thisEnt checkScanner];
3716 }
3717 ShipEntity** scannedShips = [thisEnt scannedShips];
3718 unsigned num = [thisEnt numberOfScannedShips];
3719 NSMutableArray* scanResult = [NSMutableArray array];
3720 for (unsigned i = 0; i < num; i++) {
3721 [scanResult addObject:scannedShips[i]];
3722 }
3723 OOJS_RETURN_OBJECT(scanResult);
3724
3726}

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_OBJECT, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipClearDefenseTargets()

JSBool ShipClearDefenseTargets ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3133 of file OOJSShip.m.

3134{
3136
3137 ShipEntity* thisEnt = nil;
3138 GET_THIS_SHIP(thisEnt);
3139 [thisEnt removeAllDefenseTargets];
3140
3142
3144}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipCommsMessage()

JSBool ShipCommsMessage ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2346 of file OOJSShip.m.

2347{
2348 OOJS_NATIVE_ENTER(context)
2349
2350 ShipEntity* thisEnt = nil;
2351 NSString* message = nil;
2352 ShipEntity* target = nil;
2353
2354 GET_THIS_SHIP(thisEnt);
2355
2356 if (argc > 0)
2357 message = OOStringFromJSValue(context, OOJS_ARGV[0]);
2358 if (EXPECT_NOT(message == nil || (argc > 1 && (JSVAL_IS_NULL(OOJS_ARGV[1]) || !JSVAL_IS_OBJECT(OOJS_ARGV[1]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[1]), &target))))) {
2359 OOJSReportBadArguments(context, @"Ship", @"commsMessage", MIN(argc, 1U), OOJS_ARGV, nil, @"message and optional target");
2360 return NO;
2361 }
2362
2363 if (argc < 2) {
2364 [thisEnt commsMessage:message withUnpilotedOverride:YES]; // generic broadcast
2365 } else if (target != nil) // Not stale reference
2366 {
2367 [thisEnt sendMessage:message toShip:target withUnpilotedOverride:YES]; // ship-to-ship narrowcast
2368 }
2370
2372}
void sendMessage:toShip:withUnpilotedOverride:(NSString *message_text,[toShip] ShipEntity *other_ship,[withUnpilotedOverride] BOOL unpilotedOverride)
void commsMessage:withUnpilotedOverride:(NSString *valueString,[withUnpilotedOverride] BOOL unpilotedOverride)

References ShipEntity::commsMessage:withUnpilotedOverride:, EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOStringFromJSValue(), and ShipEntity::sendMessage:toShip:withUnpilotedOverride:.

Here is the call graph for this function:

◆ ShipDamageAssessment()

JSBool ShipDamageAssessment ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3770 of file OOJSShip.m.

3771{
3773
3774 ShipEntity* thisEnt = nil;
3775 int assessment = 0;
3776
3777 GET_THIS_SHIP(thisEnt);
3778
3779 // if could have missiles but doesn't, consumables low
3780 if ([thisEnt missileCapacity] > 0 && [[thisEnt missilesList] count] == 0) {
3781 assessment++;
3782 }
3783 // if has injectors but fuel is low, consumables low
3784 // if no injectors, not a problem
3785 if ([thisEnt hasFuelInjection] && [thisEnt fuel] < 35) {
3786 assessment++;
3787 }
3788
3789 /* TODO: when NPC equipment can be damaged in combat, assess this
3790 * here */
3791
3792 OOJS_RETURN_INT(assessment);
3793
3795}
#define OOJS_RETURN_INT(v)
unsigned count

References count, GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_INT.

◆ ShipDealEnergyDamage()

JSBool ShipDealEnergyDamage ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2228 of file OOJSShip.m.

2229{
2230 OOJS_NATIVE_ENTER(context)
2231
2232 ShipEntity* thisEnt = nil;
2233 jsdouble baseDamage;
2234 jsdouble range;
2235 jsdouble velocityBias = 0.0;
2236 BOOL gotDamage;
2237 BOOL gotRange;
2238 BOOL gotVBias;
2239 GET_THIS_SHIP(thisEnt);
2240
2241 if (argc < 2) {
2242 OOJSReportBadArguments(context, @"Ship", @"dealEnergyDamage", argc, OOJS_ARGV, nil, @"damage and range needed");
2243 return NO;
2244 }
2245
2246 gotDamage = JS_ValueToNumber(context, OOJS_ARGV[0], &baseDamage);
2247 if (EXPECT_NOT(!gotDamage || baseDamage < 0)) {
2248 OOJSReportBadArguments(context, @"Ship", @"dealEnergyDamage", argc, OOJS_ARGV, nil, @"damage must be positive");
2249 return NO;
2250 }
2251 gotRange = JS_ValueToNumber(context, OOJS_ARGV[1], &range);
2252 if (EXPECT_NOT(!gotRange || range < 0)) {
2253 OOJSReportBadArguments(context, @"Ship", @"dealEnergyDamage", argc, OOJS_ARGV, nil, @"range must be positive");
2254 return NO;
2255 }
2256 if (argc >= 3) {
2257 gotVBias = JS_ValueToNumber(context, OOJS_ARGV[2], &velocityBias);
2258 if (!gotVBias) {
2259 OOJSReportBadArguments(context, @"Ship", @"dealEnergyDamage", argc, OOJS_ARGV, nil, @"velocity bias must be a number");
2260 return NO;
2261 }
2262 }
2263
2264 [thisEnt dealEnergyDamage:(GLfloat)baseDamage atRange:(GLfloat)range withBias:(GLfloat)velocityBias];
2265
2267
2269}

References ShipEntity::dealEnergyDamage:atRange:withBias:, EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipDeployEscorts()

JSBool ShipDeployEscorts ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1993 of file OOJSShip.m.

1994{
1995 OOJS_NATIVE_ENTER(context)
1996
1997 ShipEntity* thisEnt = nil;
1998
1999 GET_THIS_SHIP(thisEnt);
2000
2001 [thisEnt deployEscorts];
2003
2005}
void deployEscorts()

References ShipEntity::deployEscorts, GET_THIS_SHIP, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJS_RETURN_VOID.

Here is the call graph for this function:

◆ ShipDockEscorts()

JSBool ShipDockEscorts ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2008 of file OOJSShip.m.

2009{
2010 OOJS_NATIVE_ENTER(context)
2011
2012 ShipEntity* thisEnt = nil;
2013
2014 GET_THIS_SHIP(thisEnt);
2015
2016 [thisEnt dockEscorts];
2018
2020}
void dockEscorts()

References ShipEntity::dockEscorts, GET_THIS_SHIP, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJS_RETURN_VOID.

Here is the call graph for this function:

◆ ShipDumpCargo()

JSBool ShipDumpCargo ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2157 of file OOJSShip.m.

2158{
2159 OOJS_NATIVE_ENTER(context)
2160
2161 ShipEntity* thisEnt = nil;
2162 OOCommodityType pref = nil;
2163
2164 GET_THIS_SHIP(thisEnt);
2165
2166 if (EXPECT_NOT([thisEnt isPlayer] && [(PlayerEntity*)thisEnt isDocked])) {
2167 OOJSReportWarningForCaller(context, @"PlayerShip", @"dumpCargo", @"Can't dump cargo while docked, ignoring.");
2169 }
2170
2171 if (argc > 1) {
2172 pref = OOStringFromJSValue(context, OOJS_ARGV[1]);
2173 }
2174
2175 // NPCs can queue multiple items to dump
2176 if (!EXPECT_NOT([thisEnt isPlayer])) {
2177 int32 i, count = 1;
2178 BOOL gotCount = YES;
2179 if (argc > 0)
2180 gotCount = JS_ValueToInt32(context, OOJS_ARGV[0], &count);
2181 if (EXPECT_NOT(!gotCount || count < 1 || count > 64)) {
2182 OOJSReportBadArguments(context, @"Ship", @"dumpCargo", MIN(argc, 1U), OOJS_ARGV, nil, @"optional quantity (1 to 64), optional preferred commodity");
2183 return NO;
2184 }
2185
2186 for (i = 1; i < count; i++) {
2187 [thisEnt performSelector:@selector(dumpCargo) withObject:nil afterDelay:0.75 * i]; // drop 3 canisters per 2 seconds
2188 }
2189 }
2190
2191 OOJS_RETURN_OBJECT([thisEnt dumpCargoItem:pref]);
2192
2194}
#define OOJS_RETURN_NULL
NSString * OOCommodityType
Definition OOTypes.h:97

References count, EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_NULL, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), OOJSReportWarningForCaller(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipEjectItem()

JSBool ShipEjectItem ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2067 of file OOJSShip.m.

2068{
2069 OOJS_NATIVE_ENTER(context)
2070
2071 ShipEntity* thisEnt = nil;
2072 NSString* role = nil;
2073
2074 GET_THIS_SHIP(thisEnt);
2075
2076 if (argc > 0)
2077 role = OOStringFromJSValue(context, OOJS_ARGV[0]);
2078 if (EXPECT_NOT(role == nil)) {
2079 OOJSReportBadArguments(context, @"Ship", @"ejectItem", MIN(argc, 1U), OOJS_ARGV, nil, @"string (role)");
2080 return NO;
2081 }
2082
2083 OOJS_RETURN_OBJECT([thisEnt ejectShipOfRole:role]);
2084
2086}

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipEjectSpecificItem()

JSBool ShipEjectSpecificItem ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2135 of file OOJSShip.m.

2136{
2137 OOJS_NATIVE_ENTER(context)
2138
2139 ShipEntity* thisEnt = nil;
2140 NSString* itemKey = nil;
2141
2142 GET_THIS_SHIP(thisEnt);
2143
2144 if (argc > 0)
2145 itemKey = OOStringFromJSValue(context, OOJS_ARGV[0]);
2146 if (EXPECT_NOT(itemKey == nil)) {
2147 OOJSReportBadArguments(context, @"Ship", @"ejectSpecificItem", MIN(argc, 1U), OOJS_ARGV, nil, @"string (ship key)");
2148 return NO;
2149 }
2150
2151 OOJS_RETURN_OBJECT([thisEnt ejectShipOfType:itemKey]);
2152
2154}

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipEnterWormhole()

JSBool ShipEnterWormhole ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3370 of file OOJSShip.m.

3371{
3373
3374 ShipEntity* thisEnt = nil;
3375 Entity* hole = nil;
3376
3377 if ([PLAYER status] != STATUS_ENTERING_WITCHSPACE) {
3378 OOJSReportError(context, @"Cannot use this function while player's ship not entering witchspace.");
3379 return NO;
3380 }
3381
3382 GET_THIS_SHIP(thisEnt);
3383 if (EXPECT_NOT(argc == 0 || (argc > 0 && !JSVAL_IS_NULL(OOJS_ARGV[0]) && (!JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !OOJSEntityGetEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &hole))))) {
3384 [thisEnt enterPlayerWormhole];
3385 } else {
3386 if (![hole isWormhole]) {
3387 OOJSReportBadArguments(context, @"Ship", @"enterWormhole", 1U, OOJS_ARGV, nil, @"[wormhole]");
3388 return NO;
3389 }
3390
3391 [thisEnt enterWormhole:(WormholeEntity*)hole];
3392 }
3393
3395
3397}
#define PLAYER

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOJSReportError(), and PLAYER.

Here is the call graph for this function:

◆ ShipEquipmentStatus()

JSBool ShipEquipmentStatus ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2683 of file OOJSShip.m.

2684{
2685 OOJS_NATIVE_ENTER(context)
2686
2687 /*
2688 Interned string constants.
2689 Interned strings are guaranteed to survive for the lifetime of the JS
2690 runtime, which lasts as long as Oolite is running.
2691 */
2692 static jsval strOK, strDamaged, strUnavailable, strUnknown;
2693 static BOOL inited = NO;
2694 if (EXPECT_NOT(!inited)) {
2695 inited = YES;
2696 strOK = STRING_TO_JSVAL(JS_InternString(context, "EQUIPMENT_OK"));
2697 strDamaged = STRING_TO_JSVAL(JS_InternString(context, "EQUIPMENT_DAMAGED"));
2698 strUnavailable = STRING_TO_JSVAL(JS_InternString(context, "EQUIPMENT_UNAVAILABLE"));
2699 strUnknown = STRING_TO_JSVAL(JS_InternString(context, "EQUIPMENT_UNKNOWN"));
2700 }
2701
2702 ShipEntity* thisEnt = nil;
2703 NSString* key = nil;
2704 JSBool asDict = NO;
2705 NSDictionary* dict = nil;
2706
2707 GET_THIS_SHIP(thisEnt);
2708
2709 if (argc > 0)
2710 key = JSValueToEquipmentKey(context, OOJS_ARGV[0]);
2711 if (argc > 1)
2712 JS_ValueToBoolean(context, OOJS_ARGV[1], &asDict);
2713 if (EXPECT_NOT(key == nil)) {
2714 if (argc > 0 && JSVAL_IS_STRING(OOJS_ARGV[0])) {
2715 if (asDict) {
2716 dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:1], @"EQUIPMENT_UNKNOWN", nil];
2717 OOJS_RETURN_OBJECT(dict);
2718 } else {
2719 OOJS_RETURN(strUnknown);
2720 }
2721 }
2722
2723 OOJSReportBadArguments(context, @"Ship", @"equipmentStatus", MIN(argc, 1U), &OOJS_ARGV[0], nil, @"equipment type");
2724 return NO;
2725 }
2726
2727 if (asDict) {
2728 dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInteger:[thisEnt countEquipmentItem:key]], @"EQUIPMENT_OK", [NSNumber numberWithUnsignedInteger:[thisEnt countEquipmentItem:[key stringByAppendingString:@"_DAMAGED"]]], @"EQUIPMENT_DAMAGED", nil];
2729 OOJS_RETURN_OBJECT(dict);
2730 } else {
2731 if ([thisEnt hasEquipmentItem:key includeWeapons:YES whileLoading:NO])
2732 OOJS_RETURN(strOK);
2733 else if ([thisEnt hasEquipmentItem:[key stringByAppendingString:@"_DAMAGED"]])
2734 OOJS_RETURN(strDamaged);
2735
2736 OOJS_RETURN(strUnavailable);
2737 }
2739}
NSString * JSValueToEquipmentKey(JSContext *context, jsval value)
#define OOJS_RETURN(v)
NSUInteger countEquipmentItem:(NSString *eqkey)

References ShipEntity::countEquipmentItem:, EXPECT_NOT, GET_THIS_SHIP, JSValueToEquipmentKey(), MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN, OOJS_RETURN_OBJECT, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipExitAI()

JSBool ShipExitAI ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1910 of file OOJSShip.m.

1911{
1912 OOJS_NATIVE_ENTER(context)
1913
1914 ShipEntity* thisEnt = nil;
1915 AI* thisAI = nil;
1916 NSString* message = nil;
1917
1918 GET_THIS_SHIP(thisEnt);
1919 if (EXPECT_NOT([thisEnt isPlayer])) {
1920 OOJSReportErrorForCaller(context, @"Ship", @"exitAI", @"Not valid for player ship.");
1921 return NO;
1922 }
1923 thisAI = [thisEnt getAI];
1924
1925 if ([thisAI hasSuspendedStateMachines]) {
1926 if (argc > 0) {
1927 message = OOStringFromJSValue(context, OOJS_ARGV[0]);
1928 }
1929 // Else AI will default to RESTARTED.
1930
1931 [thisAI exitStateMachineWithMessage:message];
1932 } else {
1933 OOJSReportWarningForCaller(context, @"Ship", @"exitAI()", @"Cannot exit current AI state machine because there are no suspended state machines.");
1934 }
1936
1938}
void OOJSReportErrorForCaller(JSContext *context, NSString *scriptClass, NSString *function, NSString *format,...)
Definition AI.h:35
void exitStateMachineWithMessage:(NSString *message)
Definition AI.m:268

References AI::exitStateMachineWithMessage:, EXPECT_NOT, GET_THIS_SHIP, ShipEntity::getAI, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportErrorForCaller(), OOJSReportWarningForCaller(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipExitSystem()

JSBool ShipExitSystem ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3049 of file OOJSShip.m.

3050{
3051 OOJS_NATIVE_ENTER(context)
3052
3053 ShipEntity* thisEnt = nil;
3054 int32 systemID = -1;
3055 BOOL OK = NO;
3056
3057 GET_THIS_SHIP(thisEnt);
3058 if (EXPECT_NOT([thisEnt isPlayer])) {
3059 OOJSReportErrorForCaller(context, @"Ship", @"exitSystem", @"Not valid for player ship.");
3060 return NO;
3061 }
3062
3063 if (argc > 0) {
3064 if (!JS_ValueToInt32(context, OOJS_ARGV[0], &systemID) || systemID < 0 || 255 < systemID) {
3065 OOJSReportBadArguments(context, @"Ship", @"exitSystem", MIN(argc, 1U), OOJS_ARGV, nil, @"system ID");
3066 return NO;
3067 }
3068 }
3069
3070 OK = [thisEnt performHyperSpaceToSpecificSystem:systemID]; // -1 == random destination system
3071
3072 OOJS_RETURN_BOOL(OK);
3073
3075}
BOOL performHyperSpaceToSpecificSystem:(OOSystemID systemID)

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportErrorForCaller(), and ShipEntity::performHyperSpaceToSpecificSystem:.

Here is the call graph for this function:

◆ ShipExplode()

JSBool ShipExplode ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2272 of file OOJSShip.m.

2273{
2274 OOJS_NATIVE_ENTER(context)
2275
2276 return RemoveOrExplodeShip(context, argc, vp, YES);
2277
2279}
static BOOL RemoveOrExplodeShip(JSContext *context, uintN argc, jsval *vp, BOOL explode)
Definition OOJSShip.m:3090

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and RemoveOrExplodeShip().

Here is the call graph for this function:

◆ ShipFindNearestStation()

JSBool ShipFindNearestStation ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2781 of file OOJSShip.m.

2782{
2783 OOJS_NATIVE_ENTER(context)
2784
2785 ShipEntity* thisEnt = nil;
2786 StationEntity* result = nil;
2787
2788 GET_THIS_SHIP(thisEnt);
2789
2790 double sdist, distance = 1E32;
2791
2792 StationEntity* se = nil;
2793 foreach (se, [UNIVERSE stations]) {
2794 sdist = HPdistance2([thisEnt position], [se position]);
2795
2796 if (sdist < distance) {
2797 distance = sdist;
2798 result = se;
2799 }
2800 }
2801
2802 OOJS_RETURN_OBJECT(result);
2803
2805}
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
Definition OOHPVector.h:293
OOINLINE OOScalar distance(Vector v1, Vector v2) INLINE_CONST_FUNC
Definition OOVector.h:280

References distance(), GET_THIS_SHIP, HPdistance2(), nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, and UNIVERSE.

Here is the call graph for this function:

◆ ShipFireECM()

JSBool ShipFireECM ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2375 of file OOJSShip.m.

2376{
2377 OOJS_NATIVE_ENTER(context)
2378
2379 ShipEntity* thisEnt = nil;
2380 BOOL OK;
2381
2382 GET_THIS_SHIP(thisEnt);
2383
2384 OK = [thisEnt fireECM];
2385 if (!OK) {
2386 OOJSReportWarning(context, @"Ship %@ was requested to fire ECM burst but does not carry ECM equipment.", [thisEnt oo_jsDescription]);
2387 }
2388
2389 OOJS_RETURN_BOOL(OK);
2390
2392}
void OOJSReportWarning(JSContext *context, NSString *format,...)

References ShipEntity::fireECM, GET_THIS_SHIP, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, and OOJSReportWarning().

Here is the call graph for this function:

◆ ShipFireMissile()

JSBool ShipFireMissile ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2761 of file OOJSShip.m.

2762{
2763 OOJS_NATIVE_ENTER(context)
2764
2765 ShipEntity* thisEnt = nil;
2766 id result = nil;
2767
2768 GET_THIS_SHIP(thisEnt);
2769
2770 if (argc > 0)
2771 result = [thisEnt fireMissileWithIdentifier:OOStringFromJSValue(context, OOJS_ARGV[0]) andTarget:[thisEnt primaryTarget]];
2772 else
2773 result = [thisEnt fireMissile];
2774
2775 OOJS_RETURN_OBJECT(result);
2776
2778}
ShipEntity * fireMissile()
ShipEntity * fireMissileWithIdentifier:andTarget:(NSString *identifier,[andTarget] Entity *target)

References ShipEntity::fireMissile, ShipEntity::fireMissileWithIdentifier:andTarget:, GET_THIS_SHIP, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, and ShipEntity::primaryTarget.

Here is the call graph for this function:

◆ ShipGetMaterials()

JSBool ShipGetMaterials ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3233 of file OOJSShip.m.

3234{
3236
3237 ShipEntity* thisEnt = nil;
3238 NSObject* result = nil;
3239
3240 GET_THIS_SHIP(thisEnt);
3241
3242 result = [[thisEnt mesh] materials];
3243 if (result == nil)
3244 result = [NSDictionary dictionary];
3245 OOJS_RETURN_OBJECT(result);
3246
3248}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_OBJECT.

◆ ShipGetProperty()

JSBool ShipGetProperty ( JSContext * context,
JSObject * this,
jsid propID,
jsval * value )
static

Definition at line 592 of file OOJSShip.m.

593{
594 if (!JSID_IS_INT(propID))
595 return YES;
596
597 OOJS_NATIVE_ENTER(context)
598
599 ShipEntity* entity = nil;
600 id result = nil;
601
602 if (EXPECT_NOT(!JSShipGetShipEntity(context, this, &entity)))
603 return NO;
604 if (OOIsStaleEntity(entity)) {
605 *value = JSVAL_VOID;
606 return YES;
607 }
608
609 switch (JSID_TO_INT(propID)) {
610 case kShip_name:
611 result = [entity name];
612 break;
613
615 result = [entity displayName];
616 break;
617
619 result = [entity shipUniqueName];
620 break;
621
623 result = [entity shipClassName];
624 break;
625
627 result = [entity scanDescriptionForScripting];
628 break;
629
630 case kShip_roles:
631 result = [[entity roleSet] sortedRoles];
632 break;
633
635 result = [[entity roleSet] rolesAndProbabilities];
636 break;
637
639 result = [entity primaryRole];
640 break;
641
642 case kShip_AI:
643 result = [[entity getAI] name];
644 break;
645
646 case kShip_AIState:
647 result = [[entity getAI] state];
648 break;
649
651 result = [entity foundTarget];
652 break;
653
655 result = [entity primaryAggressor];
656 break;
657
659 return JS_NewNumberValue(context, [entity realAlertCondition], value);
660
661 case kShip_autoAI:
662 *value = OOJSValueFromBOOL([entity hasAutoAI]);
663 return YES;
664
666 *value = OOJSValueFromBOOL([entity hasAutoWeapons]);
667 return YES;
668
669 case kShip_accuracy:
670 return JS_NewNumberValue(context, [entity accuracy], value);
671
672 case kShip_fuel:
673 return JS_NewNumberValue(context, [entity fuel] * 0.1, value);
674
676 return JS_NewNumberValue(context, [entity fuelChargeRate], value);
677
678 case kShip_bounty:
679 return JS_NewNumberValue(context, [entity bounty], value);
680 return YES;
681
683 result = [entity subEntitiesForScript];
684 break;
685
686 case kShip_exhausts:
687 result = [[entity exhaustEnumerator] allObjects];
688 break;
689
690 case kShip_flashers:
691 result = [[entity flasherEnumerator] allObjects];
692 break;
693
695 return JS_NewNumberValue(context, [entity maxShipSubEntities], value);
696 return YES;
697
699 return QuaternionToJSValue(context, [entity subEntityRotationalVelocity], value);
700
702 *value = OOJSValueFromBOOL([[entity getAI] hasSuspendedStateMachines]);
703 return YES;
704
705 case kShip_target:
706 result = [entity primaryTarget];
707 break;
708
710 [entity validateDefenseTargets];
711 result = [NSMutableArray arrayWithCapacity:[entity defenseTargetCount]];
712 NSEnumerator* defTargets = [entity defenseTargetEnumerator];
713 Entity* target = nil;
714 while ((target = [[defTargets nextObject] weakRefUnderlyingObject])) {
715 [result addObject:target];
716 }
717 break;
718 }
719
720 case kShip_crew:
721 result = [entity crewForScripting];
722 break;
723
724 case kShip_escorts:
725 result = [[entity escortGroup] memberArrayExcludingLeader];
726 break;
727
728 case kShip_group:
729 result = [entity group];
730 break;
731
733 result = [entity escortGroup];
734 break;
735
737 return JS_NewNumberValue(context, [entity temperature] / SHIP_MAX_CABIN_TEMP, value);
738
740 return JS_NewNumberValue(context, [entity heatInsulation], value);
741
742 case kShip_heading:
743 return VectorToJSValue(context, [entity forwardVector], value);
744
746 return JS_NewNumberValue(context, [entity energyRechargeRate], value);
747
749 *value = INT_TO_JSVAL([entity entityPersonalityInt]);
750 return YES;
751
752 case kShip_isBeacon:
753 *value = OOJSValueFromBOOL([entity isBeacon]);
754 return YES;
755
756 case kShip_beaconCode:
757 result = [entity beaconCode];
758 break;
759
761 result = [entity beaconLabel];
762 break;
763
765 *value = OOJSValueFromBOOL([entity isFrangible]);
766 return YES;
767
768 case kShip_isCloaked:
769 *value = OOJSValueFromBOOL([entity isCloaked]);
770 return YES;
771
773 *value = OOJSValueFromBOOL([entity hasAutoCloak]);
774 return YES;
775
776 case kShip_isJamming:
777 *value = OOJSValueFromBOOL([entity isJammingScanning]);
778 return YES;
779
781 result = [entity proximityAlert];
782 break;
783
785 *value = OOJSValueFromBOOL([entity hasHostileTarget]);
786 return YES;
787
789 *value = OOJSValueFromBOOL([entity hasHyperspaceMotor]);
790 return YES;
791
793 return JS_NewNumberValue(context, [entity hyperspaceSpinTime], value);
794
796 return JS_NewNumberValue(context, [entity weaponRange], value);
797
799 if ([entity isPlayer]) {
800 PlayerEntity* pent = (PlayerEntity*)entity;
801 return JS_NewNumberValue(context, [pent availableFacings], value);
802 }
803 return JS_NewNumberValue(context, [entity weaponFacings], value);
804
806 result = [entity aftWeaponOffset];
807 break;
808
810 result = [entity forwardWeaponOffset];
811 break;
812 // return VectorToJSValue(context, [entity forwardWeaponOffset], value);
813
815 result = [entity portWeaponOffset];
816 break;
817
819 result = [entity starboardWeaponOffset];
820 break;
821
823 return JS_NewNumberValue(context, [entity scannerRange], value);
824
826 return JS_NewNumberValue(context, [entity reactionTime], value);
827
829 *value = OOJSValueFromBOOL([entity reportAIMessages]);
830 return YES;
831
833 *value = OOJSValueFromBOOL([entity withinStationAegis]);
834 return YES;
835
837 *value = INT_TO_JSVAL([entity maxAvailableCargoSpace]);
838 return YES;
839
841 *value = INT_TO_JSVAL([entity maxAvailableCargoSpace] - [entity availableCargoSpace]);
842 return YES;
843
845 *value = INT_TO_JSVAL([entity availableCargoSpace]);
846 return YES;
847
848 case kShip_cargoList:
849 result = [entity cargoListForScripting];
850 break;
851
852 case kShip_extraCargo:
853 return JS_NewNumberValue(context, [entity extraCargo], value);
854 return YES;
855
856 case kShip_commodity:
857 if ([entity commodityAmount] > 0) {
858 result = [entity commodityType];
859 }
860 break;
861
863 *value = INT_TO_JSVAL([entity commodityAmount]);
864 return YES;
865
867 result = [entity collisionExceptions];
868 break;
869
870 case kShip_speed:
871 return JS_NewNumberValue(context, [entity flightSpeed], value);
872
874 return JS_NewNumberValue(context, [entity cruiseSpeed], value);
875
876 case kShip_dataKey:
877 result = [entity shipDataKey];
878 break;
879
881 return JS_NewNumberValue(context, [entity desiredRange], value);
882
884 return JS_NewNumberValue(context, [entity desiredSpeed], value);
885
887 return HPVectorToJSValue(context, [entity destination], value);
888
890 *value = OOJSValueFromBOOL([entity markedForFines]);
891 return YES;
892
893 case kShip_maxEscorts:
894 return JS_NewNumberValue(context, [entity maxEscortCount], value);
895
896 case kShip_maxPitch:
897 return JS_NewNumberValue(context, [entity maxFlightPitch], value);
898
899 case kShip_maxSpeed:
900 return JS_NewNumberValue(context, [entity maxFlightSpeed], value);
901
902 case kShip_maxRoll:
903 return JS_NewNumberValue(context, [entity maxFlightRoll], value);
904
905 case kShip_maxYaw:
906 return JS_NewNumberValue(context, [entity maxFlightYaw], value);
907
909 return JS_NewNumberValue(context, [entity afterburnerRate], value);
910
912 return JS_NewNumberValue(context, [entity afterburnerFactor], value);
913
914 case kShip_script:
915 result = [entity shipScript];
916 break;
917
918 case kShip_AIScript:
919 result = [entity shipAIScript];
920 break;
921
923 return JS_NewNumberValue(context, [entity shipAIScriptWakeTime], value);
924 break;
925
927 return JS_NewNumberValue(context, [entity destinationSystem], value);
928 break;
929
930 case kShip_homeSystem:
931 return JS_NewNumberValue(context, [entity homeSystem], value);
932 break;
933
934 case kShip_isPirate:
935 *value = OOJSValueFromBOOL([entity isPirate]);
936 return YES;
937
938 case kShip_isPolice:
939 *value = OOJSValueFromBOOL([entity isPolice]);
940 return YES;
941
942 case kShip_isThargoid:
943 *value = OOJSValueFromBOOL([entity isThargoid]);
944 return YES;
945
946 case kShip_isTurret:
947 *value = OOJSValueFromBOOL([entity isTurret]);
948 return YES;
949
950 case kShip_isTrader:
951 *value = OOJSValueFromBOOL([entity isTrader]);
952 return YES;
953
955 *value = OOJSValueFromBOOL([entity isPirateVictim]);
956 return YES;
957
958 case kShip_isMissile:
959 *value = OOJSValueFromBOOL([entity isMissile]);
960 return YES;
961
962 case kShip_isMine:
963 *value = OOJSValueFromBOOL([entity isMine]);
964 return YES;
965
966 case kShip_isWeapon:
967 *value = OOJSValueFromBOOL([entity isWeapon]);
968 return YES;
969
970 case kShip_isRock:
971 *value = OOJSValueFromBOOL([entity scanClass] == CLASS_ROCK); // hermits and asteroids!
972 return YES;
973
974 case kShip_isMinable:
975 *value = OOJSValueFromBOOL([entity isMinable]);
976 return YES;
977
978 case kShip_isBoulder:
979 *value = OOJSValueFromBOOL([entity isBoulder]);
980 return YES;
981
982 case kShip_isFleeing:
983 if ([entity isPlayer]) {
984 *value = OOJSValueFromBOOL([(PlayerEntity*)entity fleeingStatus] >= PLAYER_FLEEING_CARGO);
985 } else {
986 *value = OOJSValueFromBOOL([entity behaviour] == BEHAVIOUR_FLEE_TARGET || [entity behaviour] == BEHAVIOUR_FLEE_EVASIVE_ACTION);
987 }
988 return YES;
989
990 case kShip_isCargo:
991 *value = OOJSValueFromBOOL([entity scanClass] == CLASS_CARGO && [entity commodityAmount] > 0);
992 return YES;
993
994 case kShip_isDerelict:
995 *value = OOJSValueFromBOOL([entity isHulk]);
996 return YES;
997
998 case kShip_isPiloted:
999 *value = OOJSValueFromBOOL([entity isPlayer] || [[entity crew] count] > 0);
1000 return YES;
1001
1003 *value = OOJSValueFromBOOL([entity scriptedMisjump]);
1004 return YES;
1005
1007 return JS_NewNumberValue(context, [entity scriptedMisjumpRange], value);
1008
1009 case kShip_scriptInfo:
1010 result = [entity scriptInfo];
1011 if (result == nil)
1012 result = [NSDictionary dictionary]; // empty rather than null
1013 break;
1014
1016 return JS_NewNumberValue(context, [entity sunGlareFilter], value);
1017
1019 *value = OOJSValueFromBOOL([entity trackCloseContacts]);
1020 return YES;
1021
1023 return JS_NewNumberValue(context, [entity passengerCount], value);
1024
1025 case kShip_parcelCount:
1026 return JS_NewNumberValue(context, [entity parcelCount], value);
1027
1029 return JS_NewNumberValue(context, [entity passengerCapacity], value);
1030
1032 return JS_NewNumberValue(context, [entity missileCapacity], value);
1033
1035 return JS_NewNumberValue(context, [entity missileLoadTime], value);
1036
1038 return HPVectorToJSValue(context, [entity coordinates], value);
1039
1040 case kShip_equipment:
1041 result = [entity equipmentListForScripting];
1042 break;
1043
1045 result = [entity weaponTypeForFacing:[entity currentWeaponFacing] strict:YES];
1046 break;
1047
1049 result = [entity weaponTypeForFacing:WEAPON_FACING_FORWARD strict:YES];
1050 break;
1051
1052 case kShip_aftWeapon:
1053 result = [entity weaponTypeForFacing:WEAPON_FACING_AFT strict:YES];
1054 break;
1055
1056 case kShip_portWeapon:
1057 result = [entity weaponTypeForFacing:WEAPON_FACING_PORT strict:YES];
1058 break;
1059
1061 result = [entity weaponTypeForFacing:WEAPON_FACING_STARBOARD strict:YES];
1062 break;
1063
1065 return JS_NewNumberValue(context, [entity laserHeatLevel], value);
1066
1068 return JS_NewNumberValue(context, [entity laserHeatLevelAft], value);
1069
1071 return JS_NewNumberValue(context, [entity laserHeatLevelForward], value);
1072
1074 return JS_NewNumberValue(context, [entity laserHeatLevelPort], value);
1075
1077 return JS_NewNumberValue(context, [entity laserHeatLevelStarboard], value);
1078
1079 case kShip_missiles:
1080 result = [entity missilesList];
1081 break;
1082
1083 case kShip_passengers:
1084 result = [entity passengerListForScripting];
1085 break;
1086
1087 case kShip_parcels:
1088 result = [entity parcelListForScripting];
1089 break;
1090
1091 case kShip_contracts:
1092 result = [entity contractListForScripting];
1093 break;
1094
1096 result = [entity dockingInstructions];
1097 break;
1098
1100 result = [[entity scannerDisplayColor1] normalizedArray];
1101 break;
1102
1104 result = [[entity scannerDisplayColor2] normalizedArray];
1105 break;
1106
1108 result = [[entity scannerDisplayColorHostile1] normalizedArray];
1109 break;
1110
1112 result = [[entity scannerDisplayColorHostile2] normalizedArray];
1113 break;
1114
1116 result = [[entity exhaustEmissiveColor] normalizedArray];
1117 break;
1118
1119 case kShip_maxThrust:
1120 return JS_NewNumberValue(context, [entity maxThrust], value);
1121
1122 case kShip_thrust:
1123 return JS_NewNumberValue(context, [entity thrust], value);
1124
1125 case kShip_lightsActive:
1126 *value = OOJSValueFromBOOL([entity lightsActive]);
1127 return YES;
1128
1129 case kShip_vectorRight:
1130 return VectorToJSValue(context, [entity rightVector], value);
1131
1133 return VectorToJSValue(context, [entity forwardVector], value);
1134
1135 case kShip_vectorUp:
1136 return VectorToJSValue(context, [entity upVector], value);
1137
1138 case kShip_velocity:
1139 return VectorToJSValue(context, [entity velocity], value);
1140
1141 case kShip_thrustVector:
1142 return VectorToJSValue(context, [entity thrustVector], value);
1143
1144 case kShip_pitch:
1145 return JS_NewNumberValue(context, [entity flightPitch], value);
1146
1147 case kShip_roll:
1148 return JS_NewNumberValue(context, [entity flightRoll], value);
1149
1150 case kShip_yaw:
1151 return JS_NewNumberValue(context, [entity flightYaw], value);
1152
1153 case kShip_boundingBox: {
1154 Vector bbvect;
1155 BoundingBox box;
1156
1157 if ([entity isSubEntity]) {
1158 box = [entity boundingBox];
1159 } else {
1160 box = [entity totalBoundingBox];
1161 }
1162 bounding_box_get_dimensions(box, &bbvect.x, &bbvect.y, &bbvect.z);
1163 return VectorToJSValue(context, bbvect, value);
1164 }
1165
1166 default:
1167 OOJSReportBadPropertySelector(context, this, propID, sShipProperties);
1168 return NO;
1169 }
1170
1171 *value = OOJSValueFromNativeObject(context, result);
1172 return YES;
1173
1175}
OOINLINE void bounding_box_get_dimensions(BoundingBox bb, GLfloat *xSize, GLfloat *ySize, GLfloat *zSize) ALWAYS_INLINE_FUNC
BOOL QuaternionToJSValue(JSContext *context, Quaternion quaternion, jsval *outValue) NONNULL_FUNC
BOOL HPVectorToJSValue(JSContext *context, HPVector vector, jsval *outValue) NONNULL_FUNC
Definition OOJSVector.m:310
BOOL VectorToJSValue(JSContext *context, Vector vector, jsval *outValue) NONNULL_FUNC
Definition OOJSVector.m:264
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
@ PLAYER_FLEEING_CARGO
#define SHIP_MAX_CABIN_TEMP
Definition ShipEntity.h:69
NSString * name()
Definition AI.m:329
NSString * state()
Definition AI.m:339
BoundingBox boundingBox
Definition Entity.m:666
NSArray * normalizedArray()
Definition OOColor.m:465
NSArray * sortedRoles()
Definition OORoleSet.m:163
NSDictionary * rolesAndProbabilities()
Definition OORoleSet.m:168
NSArray * memberArrayExcludingLeader()
NSUInteger defenseTargetCount()
NSString * beaconLabel()
NSDictionary * scriptInfo
OOScript * shipScript()
NSArray * contractListForScripting()
OOWeaponFacing currentWeaponFacing
NSDictionary * dockingInstructions
OOShipGroup * escortGroup()
NSString * shipDataKey()
OORoleSet * roleSet
NSString * primaryRole
NSString * beaconCode()
OOShipGroup * group()
OOColor * scannerDisplayColor2()
NSString * name
NSArray * portWeaponOffset
NSString * shipClassName
Entity * primaryAggressor()
void validateDefenseTargets()
NSArray * equipmentListForScripting()
BoundingBox totalBoundingBox
NSEnumerator * defenseTargetEnumerator()
NSArray * starboardWeaponOffset
NSArray * parcelListForScripting()
NSArray * cargoListForScripting()
NSEnumerator * flasherEnumerator()
Entity * proximityAlert()
NSString * shipUniqueName
NSString * scanDescriptionForScripting()
OOColor * scannerDisplayColorHostile2()
NSArray * missilesList()
NSEnumerator * exhaustEnumerator()
NSArray * aftWeaponOffset
NSArray * forwardWeaponOffset
NSArray * passengerListForScripting()
NSArray * collisionExceptions()
OOColor * scannerDisplayColorHostile1()
OOColor * exhaustEmissiveColor()
OOEquipmentType * weaponTypeForFacing:strict:(OOWeaponFacing facing,[strict] BOOL strict)
NSArray * crewForScripting()
OOCommodityType commodityType()
NSString * displayName
Entity * foundTarget()
OOColor * scannerDisplayColor1()
OOScript * shipAIScript()
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References ShipEntity::aftWeaponOffset, ShipEntity::beaconCode, ShipEntity::beaconLabel, bounding_box_get_dimensions(), Entity::boundingBox, ShipEntity::cargoListForScripting, ShipEntity::collisionExceptions, ShipEntity::commodityType, ShipEntity::contractListForScripting, count, ShipEntity::crewForScripting, ShipEntity::currentWeaponFacing, ShipEntity::defenseTargetCount, ShipEntity::defenseTargetEnumerator, ShipEntity::displayName, ShipEntity::dockingInstructions, ShipEntity::equipmentListForScripting, ShipEntity::escortGroup, ShipEntity::exhaustEmissiveColor, ShipEntity::exhaustEnumerator, EXPECT_NOT, ShipEntity::flasherEnumerator, ShipEntity::forwardWeaponOffset, ShipEntity::foundTarget, ShipEntity::getAI, ShipEntity::group, HPVectorToJSValue(), kShip_accuracy, kShip_aftWeapon, kShip_AI, kShip_AIFoundTarget, kShip_AIPrimaryAggressor, kShip_AIScript, kShip_AIScriptWakeTime, kShip_AIState, kShip_alertCondition, kShip_autoAI, kShip_autoWeapons, kShip_beaconCode, kShip_beaconLabel, kShip_boundingBox, kShip_bounty, kShip_cargoList, kShip_cargoSpaceAvailable, kShip_cargoSpaceCapacity, kShip_cargoSpaceUsed, kShip_cloakAutomatic, kShip_collisionExceptions, kShip_commodity, kShip_commodityAmount, kShip_contracts, kShip_crew, kShip_cruiseSpeed, kShip_currentWeapon, kShip_dataKey, kShip_defenseTargets, kShip_desiredRange, kShip_desiredSpeed, kShip_destination, kShip_destinationSystem, kShip_displayName, kShip_dockingInstructions, kShip_energyRechargeRate, kShip_entityPersonality, kShip_equipment, kShip_escortGroup, kShip_escorts, kShip_exhaustEmissiveColor, kShip_exhausts, kShip_extraCargo, kShip_flashers, kShip_forwardWeapon, kShip_fuel, kShip_fuelChargeRate, kShip_group, kShip_hasHostileTarget, kShip_hasHyperspaceMotor, kShip_hasSuspendedAI, kShip_heading, kShip_heatInsulation, kShip_homeSystem, kShip_hyperspaceSpinTime, kShip_injectorBurnRate, kShip_injectorSpeedFactor, kShip_isBeacon, kShip_isBoulder, kShip_isCargo, kShip_isCloaked, kShip_isDerelict, kShip_isFleeing, kShip_isFrangible, kShip_isJamming, kShip_isMinable, kShip_isMine, kShip_isMissile, kShip_isPiloted, kShip_isPirate, kShip_isPirateVictim, kShip_isPolice, kShip_isRock, kShip_isThargoid, kShip_isTrader, kShip_isTurret, kShip_isWeapon, kShip_laserHeatLevel, kShip_laserHeatLevelAft, kShip_laserHeatLevelForward, kShip_laserHeatLevelPort, kShip_laserHeatLevelStarboard, kShip_lightsActive, kShip_markedForFines, kShip_maxEscorts, kShip_maxPitch, kShip_maxRoll, kShip_maxSpeed, kShip_maxThrust, kShip_maxYaw, kShip_missileCapacity, kShip_missileLoadTime, kShip_missiles, kShip_name, kShip_parcelCount, kShip_parcels, kShip_passengerCapacity, kShip_passengerCount, kShip_passengers, kShip_pitch, kShip_portWeapon, kShip_potentialCollider, kShip_primaryRole, kShip_reactionTime, kShip_reportAIMessages, kShip_roles, kShip_roleWeights, kShip_roll, kShip_savedCoordinates, kShip_scanDescription, kShip_scannerDisplayColor1, kShip_scannerDisplayColor2, kShip_scannerHostileDisplayColor1, kShip_scannerHostileDisplayColor2, kShip_scannerRange, kShip_script, kShip_scriptedMisjump, kShip_scriptedMisjumpRange, kShip_scriptInfo, kShip_shipClassName, kShip_shipUniqueName, kShip_speed, kShip_starboardWeapon, kShip_subEntities, kShip_subEntityCapacity, kShip_subEntityRotation, kShip_sunGlareFilter, kShip_target, kShip_temperature, kShip_thrust, kShip_thrustVector, kShip_trackCloseContacts, kShip_vectorForward, kShip_vectorRight, kShip_vectorUp, kShip_velocity, kShip_weaponFacings, kShip_weaponPositionAft, kShip_weaponPositionForward, kShip_weaponPositionPort, kShip_weaponPositionStarboard, kShip_weaponRange, kShip_withinStationAegis, kShip_yaw, OOShipGroup::memberArrayExcludingLeader, ShipEntity::missilesList, AI::name, ShipEntity::name, nil, OOColor::normalizedArray, OOIsStaleEntity(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSValueFromBOOL(), OOJSValueFromNativeObject(), ShipEntity::parcelListForScripting, ShipEntity::passengerListForScripting, PLAYER_FLEEING_CARGO, ShipEntity::portWeaponOffset, ShipEntity::primaryAggressor, ShipEntity::primaryRole, ShipEntity::primaryTarget, ShipEntity::proximityAlert, QuaternionToJSValue(), OORoleSet::rolesAndProbabilities, ShipEntity::roleSet, ShipEntity::scanDescriptionForScripting, ShipEntity::scannerDisplayColor1, ShipEntity::scannerDisplayColor2, ShipEntity::scannerDisplayColorHostile1, ShipEntity::scannerDisplayColorHostile2, ShipEntity::scriptInfo, SHIP_MAX_CABIN_TEMP, ShipEntity::shipAIScript, ShipEntity::shipClassName, ShipEntity::shipDataKey, ShipEntity::shipScript, ShipEntity::shipUniqueName, OORoleSet::sortedRoles, sShipProperties, ShipEntity::starboardWeaponOffset, AI::state, ShipEntity::subEntitiesForScript, ShipEntity::totalBoundingBox, ShipEntity::validateDefenseTargets, VectorToJSValue(), ShipEntity::weaponTypeForFacing:strict:, Vector::x, Vector::y, and Vector::z.

Here is the call graph for this function:

◆ ShipGetSafeCourseToDestination()

JSBool ShipGetSafeCourseToDestination ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3684 of file OOJSShip.m.

3685{
3687
3688 ShipEntity* thisEnt = nil;
3689 GET_THIS_SHIP(thisEnt);
3690
3691 HPVector waypoint = [UNIVERSE getSafeVectorFromEntity:thisEnt toDistance:[thisEnt desiredRange] fromPoint:[thisEnt destination]];
3692
3693 OOJS_RETURN_HPVECTOR(waypoint);
3694
3696}
#define OOJS_RETURN_HPVECTOR(value)

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_HPVECTOR.

◆ ShipGetShaders()

JSBool ShipGetShaders ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3251 of file OOJSShip.m.

3252{
3254
3255 ShipEntity* thisEnt = nil;
3256 NSObject* result = nil;
3257
3258 GET_THIS_SHIP(thisEnt);
3259
3260 result = [[thisEnt mesh] shaders];
3261 if (result == nil)
3262 result = [NSDictionary dictionary];
3263 OOJS_RETURN_OBJECT(result);
3264
3266}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_OBJECT.

◆ ShipHasEquipmentProviding()

JSBool ShipHasEquipmentProviding ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2023 of file OOJSShip.m.

2024{
2025 OOJS_NATIVE_ENTER(context)
2026
2027 ShipEntity* thisEnt = nil;
2028 NSString* equipment = nil;
2029
2030 GET_THIS_SHIP(thisEnt);
2031
2032 if (argc > 0)
2033 equipment = OOStringFromJSValue(context, OOJS_ARGV[0]);
2034 if (EXPECT_NOT(equipment == nil)) {
2035 OOJSReportBadArguments(context, @"Ship", @"hasEquipmentProviding", MIN(argc, 1U), OOJS_ARGV, nil, @"string (equipment)");
2036 return NO;
2037 }
2038
2039 OOJS_RETURN_BOOL([thisEnt hasEquipmentItemProviding:equipment]);
2040
2042}

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipHasRole()

JSBool ShipHasRole ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2045 of file OOJSShip.m.

2046{
2047 OOJS_NATIVE_ENTER(context)
2048
2049 ShipEntity* thisEnt = nil;
2050 NSString* role = nil;
2051
2052 GET_THIS_SHIP(thisEnt);
2053
2054 if (argc > 0)
2055 role = OOStringFromJSValue(context, OOJS_ARGV[0]);
2056 if (EXPECT_NOT(role == nil)) {
2057 OOJSReportBadArguments(context, @"Ship", @"hasRole", MIN(argc, 1U), OOJS_ARGV, nil, @"string (role)");
2058 return NO;
2059 }
2060
2061 OOJS_RETURN_BOOL([thisEnt hasRole:role]);
2062
2064}

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), and OOStringFromJSValue().

Here is the call graph for this function:

◆ ShipMarkTargetForFines()

JSBool ShipMarkTargetForFines ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3351 of file OOJSShip.m.

3352{
3354
3355 ShipEntity* thisEnt = nil;
3356
3357 GET_THIS_SHIP(thisEnt);
3358
3359 ShipEntity* ship = [thisEnt primaryTarget];
3360 BOOL ok = NO;
3361 if ((ship != nil) && ([ship status] != STATUS_DEAD) && ([ship status] != STATUS_DOCKED)) {
3362 ok = [ship markForFines];
3363 }
3364
3365 OOJS_RETURN_BOOL(ok);
3366
3368}
BOOL markForFines()

References GET_THIS_SHIP, ShipEntity::markForFines, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_BOOL.

Here is the call graph for this function:

◆ ShipNotifyGroupOfWormhole()

JSBool ShipNotifyGroupOfWormhole ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3399 of file OOJSShip.m.

3400{
3402
3403 ShipEntity* thisEnt = nil;
3404 GET_THIS_SHIP(thisEnt);
3405
3406 [thisEnt wormholeEntireGroup];
3407
3409
3411}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipOfferToEscort()

JSBool ShipOfferToEscort ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3294 of file OOJSShip.m.

3295{
3297
3298 ShipEntity* thisEnt = nil;
3299 ShipEntity* mother = nil;
3300
3301 GET_THIS_SHIP(thisEnt);
3302 if (EXPECT_NOT(argc == 0 || (argc > 0 && (JSVAL_IS_NULL(OOJS_ARGV[0]) || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &mother))))) {
3303 OOJSReportBadArguments(context, @"Ship", @"offerToEscort", 1U, OOJS_ARGV, nil, @"target");
3304 return NO;
3305 }
3306
3307 BOOL result = [thisEnt suggestEscortTo:mother];
3308
3309 OOJS_RETURN_BOOL(result);
3310
3312}

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_BOOL, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipPatrolReportIn()

JSBool ShipPatrolReportIn ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3329 of file OOJSShip.m.

3330{
3332
3333 ShipEntity* thisEnt = nil;
3334 ShipEntity* target = nil;
3335
3336 GET_THIS_SHIP(thisEnt);
3337 if (EXPECT_NOT(argc == 0 || (argc > 0 && (JSVAL_IS_NULL(OOJS_ARGV[0]) || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &target))))) {
3338 OOJSReportBadArguments(context, @"Ship", @"addDefenseTarget", 1U, OOJS_ARGV, nil, @"target");
3339 return NO;
3340 }
3341 if ([target isStation]) {
3342 StationEntity* station = (StationEntity*)target;
3343 [station acceptPatrolReportFrom:thisEnt];
3344 }
3345
3347
3349}
void acceptPatrolReportFrom:(ShipEntity *patrol_ship)

References StationEntity::acceptPatrolReportFrom:, EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_VOID, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipPerformAttack()

JSBool ShipPerformAttack ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3426 of file OOJSShip.m.

3427{
3429
3430 ShipEntity* thisEnt = nil;
3431 GET_THIS_SHIP(thisEnt);
3432 [thisEnt performAttack];
3433
3435
3437}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformCollect()

JSBool ShipPerformCollect ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3439 of file OOJSShip.m.

3440{
3442
3443 ShipEntity* thisEnt = nil;
3444 GET_THIS_SHIP(thisEnt);
3445 [thisEnt performCollect];
3446
3448
3450}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformEscort()

JSBool ShipPerformEscort ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3452 of file OOJSShip.m.

3453{
3455
3456 ShipEntity* thisEnt = nil;
3457 GET_THIS_SHIP(thisEnt);
3458 [thisEnt performEscort];
3459
3461
3463}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformFaceDestination()

JSBool ShipPerformFaceDestination ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3465 of file OOJSShip.m.

3466{
3468
3469 ShipEntity* thisEnt = nil;
3470 GET_THIS_SHIP(thisEnt);
3471 [thisEnt performFaceDestination];
3472
3474
3476}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformFlee()

JSBool ShipPerformFlee ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3478 of file OOJSShip.m.

3479{
3481
3482 ShipEntity* thisEnt = nil;
3483 GET_THIS_SHIP(thisEnt);
3484 [thisEnt performFlee];
3485
3487
3489}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformFlyToRangeFromDestination()

JSBool ShipPerformFlyToRangeFromDestination ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3491 of file OOJSShip.m.

3492{
3494
3495 ShipEntity* thisEnt = nil;
3496 GET_THIS_SHIP(thisEnt);
3497 [thisEnt performFlyToRangeFromDestination];
3498
3500
3502}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformHold()

JSBool ShipPerformHold ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3504 of file OOJSShip.m.

3505{
3507
3508 ShipEntity* thisEnt = nil;
3509 GET_THIS_SHIP(thisEnt);
3510 [thisEnt performHold];
3511
3513
3515}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformIdle()

JSBool ShipPerformIdle ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3517 of file OOJSShip.m.

3518{
3520
3521 ShipEntity* thisEnt = nil;
3522 GET_THIS_SHIP(thisEnt);
3523 [thisEnt performIdle];
3524
3526
3528}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformIntercept()

JSBool ShipPerformIntercept ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3530 of file OOJSShip.m.

3531{
3533
3534 ShipEntity* thisEnt = nil;
3535 GET_THIS_SHIP(thisEnt);
3536 [thisEnt performIntercept];
3537
3539
3541}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformLandOnPlanet()

JSBool ShipPerformLandOnPlanet ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3543 of file OOJSShip.m.

3544{
3546
3547 ShipEntity* thisEnt = nil;
3548 GET_THIS_SHIP(thisEnt);
3549 [thisEnt performLandOnPlanet];
3550
3552
3554}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformMining()

JSBool ShipPerformMining ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3556 of file OOJSShip.m.

3557{
3559
3560 ShipEntity* thisEnt = nil;
3561 GET_THIS_SHIP(thisEnt);
3562 [thisEnt performMining];
3563
3565
3567}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformScriptedAI()

JSBool ShipPerformScriptedAI ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3569 of file OOJSShip.m.

3570{
3572
3573 ShipEntity* thisEnt = nil;
3574 GET_THIS_SHIP(thisEnt);
3575 [thisEnt performScriptedAI];
3576
3578
3580}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformScriptedAttackAI()

JSBool ShipPerformScriptedAttackAI ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3582 of file OOJSShip.m.

3583{
3585
3586 ShipEntity* thisEnt = nil;
3587 GET_THIS_SHIP(thisEnt);
3588 [thisEnt performScriptedAttackAI];
3589
3591
3593}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformStop()

JSBool ShipPerformStop ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3595 of file OOJSShip.m.

3596{
3598
3599 ShipEntity* thisEnt = nil;
3600 GET_THIS_SHIP(thisEnt);
3601 [thisEnt performStop];
3602
3604
3606}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipPerformTumble()

JSBool ShipPerformTumble ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3608 of file OOJSShip.m.

3609{
3611
3612 ShipEntity* thisEnt = nil;
3613 GET_THIS_SHIP(thisEnt);
3614 [thisEnt performTumble];
3615
3617
3619}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipReactToAIMessage()

JSBool ShipReactToAIMessage ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1941 of file OOJSShip.m.

1942{
1943 OOJS_NATIVE_ENTER(context)
1944
1945 ShipEntity* thisEnt = nil;
1946 NSString* message = nil;
1947
1948 GET_THIS_SHIP(thisEnt);
1949 if (argc > 0)
1950 message = OOStringFromJSValue(context, OOJS_ARGV[0]);
1951 if (EXPECT_NOT(message == nil)) {
1952 OOJSReportBadArguments(context, @"Ship", @"reactToAIMessage", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
1953 return NO;
1954 }
1955 if (EXPECT_NOT([thisEnt isPlayer])) {
1956 OOJSReportErrorForCaller(context, @"Ship", @"reactToAIMessage", @"Not valid for player ship.");
1957 return NO;
1958 }
1959
1960 [thisEnt reactToAIMessage:message context:@"JavaScript reactToAIMessage()"];
1962
1964}
void reactToAIMessage:context:(NSString *message,[context] NSString *debugContext)

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOJSReportErrorForCaller(), OOStringFromJSValue(), and ShipEntity::reactToAIMessage:context:.

Here is the call graph for this function:

◆ ShipRecallDockingInstructions()

JSBool ShipRecallDockingInstructions ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3639 of file OOJSShip.m.

3640{
3642
3643 ShipEntity* thisEnt = nil;
3644 GET_THIS_SHIP(thisEnt);
3645 [thisEnt recallDockingInstructions];
3646
3647 NSDictionary* dockingInstructions = [thisEnt dockingInstructions];
3648 if (dockingInstructions != nil) {
3649 OOJS_RETURN_OBJECT(dockingInstructions);
3650 } else {
3652 }
3653
3655}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_NULL, and OOJS_RETURN_OBJECT.

◆ ShipRemove()

JSBool ShipRemove ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2282 of file OOJSShip.m.

2283{
2284 OOJS_NATIVE_ENTER(context)
2285
2286 ShipEntity* thisEnt = nil;
2287 JSBool suppressDeathEvent = NO;
2288
2289 GET_THIS_SHIP(thisEnt);
2290
2291 if ([thisEnt isPlayer]) {
2292 OOJSReportError(context, @"Cannot remove() player's ship.");
2293 return NO;
2294 }
2295
2296 if (argc > 0 && EXPECT_NOT(!JS_ValueToBoolean(context, OOJS_ARGV[0], &suppressDeathEvent))) {
2297 OOJSReportBadArguments(context, @"Ship", @"remove", argc, OOJS_ARGV, nil, @"boolean");
2298 return NO;
2299 }
2300
2301 [thisEnt doScriptEvent:OOJSID("shipRemoved") withArgument:[NSNumber numberWithBool:suppressDeathEvent]];
2302
2303 if (suppressDeathEvent) {
2304 [thisEnt removeScript];
2305 }
2306 return RemoveOrExplodeShip(context, argc, vp, NO);
2307
2309}
void removeScript()

References ShipEntity::doScriptEvent:withArgument:, EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadArguments(), OOJSReportError(), RemoveOrExplodeShip(), and ShipEntity::removeScript.

Here is the call graph for this function:

◆ ShipRemoveCollisionException()

JSBool ShipRemoveCollisionException ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3210 of file OOJSShip.m.

3211{
3213
3214 ShipEntity* thisEnt = nil;
3215 ShipEntity* target = nil;
3216
3217 GET_THIS_SHIP(thisEnt);
3218 if (EXPECT_NOT(argc == 0 || (argc > 0 && (JSVAL_IS_NULL(OOJS_ARGV[0]) || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &target))))) {
3219 OOJSReportBadArguments(context, @"Ship", @"removeCollisionException", 1U, OOJS_ARGV, nil, @"other ship");
3220 return NO;
3221 }
3222
3223 // doesn't need a check to see if it was already gone
3224 [thisEnt removeCollisionException:target];
3225 [target removeCollisionException:thisEnt];
3226
3228
3230}
void removeCollisionException:(ShipEntity *ship)

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), and ShipEntity::removeCollisionException:.

Here is the call graph for this function:

◆ ShipRemoveDefenseTarget()

JSBool ShipRemoveDefenseTarget ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3166 of file OOJSShip.m.

3167{
3169
3170 ShipEntity* thisEnt = nil;
3171 ShipEntity* target = nil;
3172
3173 GET_THIS_SHIP(thisEnt);
3174 if (EXPECT_NOT(argc == 0 || (argc > 0 && (JSVAL_IS_NULL(OOJS_ARGV[0]) || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &target))))) {
3175 OOJSReportBadArguments(context, @"Ship", @"removeDefenseTarget", 1U, OOJS_ARGV, nil, @"target");
3176 return NO;
3177 }
3178
3179 [thisEnt removeDefenseTarget:target];
3180
3182
3184}

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_VOID, and OOJSReportBadArguments().

Here is the call graph for this function:

◆ ShipRemoveEquipment()

JSBool ShipRemoveEquipment ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2523 of file OOJSShip.m.

2524{
2525 OOJS_NATIVE_ENTER(context)
2526
2527 ShipEntity* thisEnt = nil;
2528 NSString* key = nil;
2529 BOOL OK = YES;
2530
2531 GET_THIS_SHIP(thisEnt);
2532
2533 if (argc > 0)
2534 key = JSValueToEquipmentKey(context, OOJS_ARGV[0]);
2535 if (EXPECT_NOT(key == nil)) {
2536 OOJSReportBadArguments(context, @"Ship", @"removeEquipment", MIN(argc, 1U), OOJS_ARGV, nil, @"equipment type");
2537 return NO;
2538 }
2539 // berths are not in hasOneEquipmentItem
2540 OK = [thisEnt hasOneEquipmentItem:key includeMissiles:YES whileLoading:NO] || ([key isEqualToString:@"EQ_PASSENGER_BERTH"] && [thisEnt passengerCapacity] > 0);
2541 if (!OK) {
2542 // Allow removal of damaged equipment.
2543 key = [key stringByAppendingString:@"_DAMAGED"];
2544 OK = [thisEnt hasOneEquipmentItem:key includeMissiles:NO whileLoading:NO];
2545 }
2546 if (OK) {
2547 // exceptions
2548 if ([key isEqualToString:@"EQ_PASSENGER_BERTH"] || [key isEqualToString:@"EQ_CARGO_BAY"]) {
2549 if ([key isEqualToString:@"EQ_PASSENGER_BERTH"]) {
2550 if ([thisEnt passengerCapacity] > [thisEnt passengerCount]) {
2551 // must be the player's ship!
2552 if ([thisEnt isPlayer])
2554 } else
2555 OK = NO;
2556 } else // EQ_CARGO_BAY
2557 {
2558 // player cargo bay removal handled in script
2559 if ([thisEnt isPlayer] || [thisEnt extraCargo] <= [thisEnt availableCargoSpace]) {
2560 [thisEnt removeEquipmentItem:key];
2561 } else
2562 OK = NO;
2563 }
2564 } else
2565 [thisEnt removeEquipmentItem:key];
2566 }
2567
2568 OOJS_RETURN_BOOL(OK);
2569
2571}
void removeEquipmentItem:(NSString *equipmentKey)
NSUInteger passengerCapacity()
BOOL hasOneEquipmentItem:includeMissiles:whileLoading:(NSString *itemKey,[includeMissiles] BOOL includeMissiles,[whileLoading] BOOL loading)

References PlayerEntity::changePassengerBerths:, EXPECT_NOT, GET_THIS_SHIP, ShipEntity::hasOneEquipmentItem:includeMissiles:whileLoading:, JSValueToEquipmentKey(), MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), ShipEntity::passengerCapacity, and ShipEntity::removeEquipmentItem:.

Here is the call graph for this function:

◆ ShipRequestDockingInstructions()

JSBool ShipRequestDockingInstructions ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3621 of file OOJSShip.m.

3622{
3624
3625 ShipEntity* thisEnt = nil;
3626 GET_THIS_SHIP(thisEnt);
3627 [thisEnt requestDockingCoordinates];
3628
3629 NSDictionary* dockingInstructions = [thisEnt dockingInstructions];
3630 if (dockingInstructions != nil) {
3631 OOJS_RETURN_OBJECT(dockingInstructions);
3632 } else {
3634 }
3635
3637}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_NULL, and OOJS_RETURN_OBJECT.

◆ ShipRequestHelpFromGroup()

JSBool ShipRequestHelpFromGroup ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3314 of file OOJSShip.m.

3315{
3317
3318 ShipEntity* thisEnt = nil;
3319
3320 GET_THIS_SHIP(thisEnt);
3321
3322 [thisEnt groupAttackTarget];
3323
3325
3327}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipRestoreSubEntities()

JSBool ShipRestoreSubEntities ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2574 of file OOJSShip.m.

2575{
2576 OOJS_NATIVE_ENTER(context)
2577
2578 ShipEntity* thisEnt = nil;
2579 NSUInteger numSubEntitiesRestored = 0U;
2580
2581 GET_THIS_SHIP(thisEnt);
2582
2583 NSUInteger subCount = [[thisEnt subEntitiesForScript] count];
2584
2585 [thisEnt clearSubEntities];
2586 [thisEnt setUpSubEntities];
2587
2588 if ([[thisEnt subEntitiesForScript] count] - subCount > 0)
2589 numSubEntitiesRestored = [[thisEnt subEntitiesForScript] count] - subCount;
2590
2591 // for each subentity restored, slightly increase the trade-in factor
2592 if ([thisEnt isPlayer]) {
2593 int tradeInFactorChange = (int)MAX(PLAYER_SHIP_SUBENTITY_TRADE_IN_VALUE * numSubEntitiesRestored, 25U);
2594 [(PlayerEntity*)thisEnt adjustTradeInFactorBy:tradeInFactorChange];
2595 }
2596
2597 OOJS_RETURN_BOOL(numSubEntitiesRestored > 0);
2598
2600}
#define MAX(A, B)
Definition OOMaths.h:94
#define PLAYER_SHIP_SUBENTITY_TRADE_IN_VALUE
void adjustTradeInFactorBy:(int value)
void clearSubEntities()
BOOL setUpSubEntities()
Definition ShipEntity.m:790
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

References PlayerEntity::adjustTradeInFactorBy:, ShipEntity::clearSubEntities, count, GET_THIS_SHIP, int(), MAX, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, PLAYER_SHIP_SUBENTITY_TRADE_IN_VALUE, ShipEntity::setUpSubEntities, and ShipEntity::subEntitiesForScript.

Here is the call graph for this function:

◆ ShipRunLegacyScriptActions()

JSBool ShipRunLegacyScriptActions ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2312 of file OOJSShip.m.

2313{
2314 OOJS_NATIVE_ENTER(context)
2315
2316 ShipEntity* thisEnt = nil;
2317 PlayerEntity* player = nil;
2318 ShipEntity* target = nil;
2319 NSArray* actions = nil;
2320
2321 player = OOPlayerForScripting();
2322 GET_THIS_SHIP(thisEnt);
2323
2324 if (argc > 1)
2325 actions = OOJSNativeObjectFromJSValue(context, OOJS_ARGV[1]);
2326 if (EXPECT_NOT(argc != 2 || !JSVAL_IS_OBJECT(OOJS_ARGV[0]) || !JSShipGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &target) || ![actions isKindOfClass:[NSArray class]])) {
2327 OOJSReportBadArguments(context, @"Ship", @"__runLegacyScriptActions", argc, OOJS_ARGV, nil, @"target and array of actions");
2328 return NO;
2329 }
2330
2331 if (target != nil) // Not stale reference
2332 {
2333 [player setScriptTarget:thisEnt];
2334 [player runUnsanitizedScriptActions:actions
2336 withContextName:[NSString stringWithFormat:@"<ship \"%@\" legacy actions>", [thisEnt name]]
2337 forTarget:target];
2338 }
2339
2341
2343}
PlayerEntity * OOPlayerForScripting(void)
Definition OOJSPlayer.m:175
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
void runUnsanitizedScriptActions:allowingAIMethods:withContextName:forTarget:(NSArray *unsanitizedActions,[allowingAIMethods] BOOL allowAIMethods,[withContextName] NSString *contextName,[forTarget] ShipEntity *target)
void setScriptTarget:(ShipEntity *ship)

References EXPECT_NOT, GET_THIS_SHIP, ShipEntity::name, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSNativeObjectFromJSValue(), OOJSReportBadArguments(), OOPlayerForScripting(), PlayerEntity::runUnsanitizedScriptActions:allowingAIMethods:withContextName:forTarget:, and PlayerEntity::setScriptTarget:.

Here is the call graph for this function:

◆ ShipSelectNewMissile()

JSBool ShipSelectNewMissile ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2742 of file OOJSShip.m.

2743{
2744 OOJS_NATIVE_ENTER(context)
2745
2746 ShipEntity* thisEnt = nil;
2747
2748 GET_THIS_SHIP(thisEnt);
2749
2750 NSString* result = [[thisEnt selectMissile] identifier];
2751 // if there's a badly defined missile, selectMissile may return nil
2752 if (result == nil)
2753 result = @"EQ_MISSILE";
2754
2755 OOJS_RETURN_OBJECT(result);
2756
2758}
OOEquipmentType * selectMissile()

References GET_THIS_SHIP, OOEquipmentType::identifier, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, and ShipEntity::selectMissile.

Here is the call graph for this function:

◆ ShipSendAIMessage()

JSBool ShipSendAIMessage ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1967 of file OOJSShip.m.

1968{
1969 OOJS_NATIVE_ENTER(context)
1970
1971 ShipEntity* thisEnt = nil;
1972 NSString* message = nil;
1973
1974 GET_THIS_SHIP(thisEnt);
1975 if (argc > 0)
1976 message = OOStringFromJSValue(context, OOJS_ARGV[0]);
1977 if (EXPECT_NOT(message == nil)) {
1978 OOJSReportBadArguments(context, @"Ship", @"sendAIMessage", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
1979 return NO;
1980 }
1981 if (EXPECT_NOT([thisEnt isPlayer])) {
1982 OOJSReportErrorForCaller(context, @"Ship", @"sendAIMessage", @"Not valid for player ship.");
1983 return NO;
1984 }
1985
1986 [thisEnt sendAIMessage:message];
1988
1990}
void sendAIMessage:(NSString *message)

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOJSReportErrorForCaller(), OOStringFromJSValue(), and ShipEntity::sendAIMessage:.

Here is the call graph for this function:

◆ ShipSetAI()

JSBool ShipSetAI ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1858 of file OOJSShip.m.

1859{
1860 OOJS_NATIVE_ENTER(context)
1861
1862 ShipEntity* thisEnt = nil;
1863 NSString* name = nil;
1864
1865 GET_THIS_SHIP(thisEnt);
1866 if (argc > 0)
1867 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1868 if (EXPECT_NOT(name == nil)) {
1869 OOJSReportBadArguments(context, @"Ship", @"setAI", MIN(argc, 1U), OOJS_ARGV, nil, @"string (AI name)");
1870 return NO;
1871 }
1872 if (EXPECT_NOT([thisEnt isPlayer])) {
1873 OOJSReportErrorForCaller(context, @"Ship", @"setAI", @"Not valid for player ship.");
1874 return NO;
1875 }
1876
1877 [thisEnt setAITo:name];
1879
1881}
void setAITo:(NSString *aiString)

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOJSReportErrorForCaller(), OOStringFromJSValue(), and ShipEntity::setAITo:.

Here is the call graph for this function:

◆ ShipSetBounty()

JSBool ShipSetBounty ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2808 of file OOJSShip.m.

2809{
2810 OOJS_NATIVE_ENTER(context)
2811
2812 ShipEntity* thisEnt = nil;
2813 NSString* reason = nil;
2814 int32 newbounty = 0;
2815 BOOL gotBounty = YES;
2816
2817 GET_THIS_SHIP(thisEnt);
2818
2819 if (argc > 0)
2820 gotBounty = JS_ValueToInt32(context, OOJS_ARGV[0], &newbounty);
2821 if (argc > 1)
2822 reason = OOStringFromJSValue(context, OOJS_ARGV[1]);
2823 if (EXPECT_NOT(reason == nil || !gotBounty || newbounty < 0)) {
2824 OOJSReportBadArguments(context, @"Ship", @"setBounty", argc, OOJS_ARGV, nil, @"new bounty and reason");
2825 return NO;
2826 }
2827
2828 [thisEnt setBounty:(OOCreditsQuantity)newbounty withReasonAsString:reason];
2829
2830 return YES;
2831
2833}
void setBounty:withReasonAsString:(OOCreditsQuantity amount,[withReasonAsString] NSString *reason)

References EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadArguments(), OOStringFromJSValue(), and ShipEntity::setBounty:withReasonAsString:.

Here is the call graph for this function:

◆ ShipSetCargo()

JSBool ShipSetCargo ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2836 of file OOJSShip.m.

2837{
2838 OOJS_NATIVE_ENTER(context)
2839
2840 ShipEntity* thisEnt = nil;
2841 OOCommodityType commodity = nil;
2842 int32 count = 1;
2843 BOOL gotCount = YES;
2844
2845 GET_THIS_SHIP(thisEnt);
2846
2847 if (argc > 0)
2848 commodity = OOStringFromJSValue(context, OOJS_ARGV[0]);
2849 if (argc > 1)
2850 gotCount = JS_ValueToInt32(context, OOJS_ARGV[1], &count);
2851 if (EXPECT_NOT(commodity == nil || !gotCount || count < 1)) {
2852 OOJSReportBadArguments(context, @"Ship", @"setCargo", argc, OOJS_ARGV, nil, @"cargo name and optional positive quantity");
2853 return NO;
2854 }
2855
2856 if ([[UNIVERSE commodities] goodDefined:commodity]) {
2857 [thisEnt setCommodityForPod:commodity andAmount:count];
2858 }
2859
2860 OOJS_RETURN_BOOL([[UNIVERSE commodities] goodDefined:commodity]);
2861
2863}
void setCommodityForPod:andAmount:(OOCommodityType co_type,[andAmount] OOCargoQuantity co_amount)

References count, EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOStringFromJSValue(), ShipEntity::setCommodityForPod:andAmount:, and UNIVERSE.

Here is the call graph for this function:

◆ ShipSetCargoType()

JSBool ShipSetCargoType ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2902 of file OOJSShip.m.

2903{
2904 OOJS_NATIVE_ENTER(context)
2905
2906 ShipEntity* thisEnt = nil;
2907 NSString* cargoType = nil;
2908
2909 GET_THIS_SHIP(thisEnt);
2910
2911 if (argc > 0)
2912 cargoType = OOStringFromJSValue(context, OOJS_ARGV[0]);
2913 if (EXPECT_NOT(cargoType == nil)) {
2914 OOJSReportBadArguments(context, @"Ship", @"setCargoType", argc, OOJS_ARGV, nil, @"cargo type name");
2915 return NO;
2916 }
2917 if ([thisEnt cargoType] != CARGO_NOT_CARGO) {
2918 OOJSReportBadArguments(context, @"Ship", @"setCargoType", argc, OOJS_ARGV, nil, [NSString stringWithFormat:@"Can only be used on cargo pod carriers, not cargo pods (%@)", [thisEnt shipDataKey]]);
2919 return NO;
2920 }
2921 BOOL ok = YES;
2922 if ([cargoType isEqualToString:@"SCARCE_GOODS"]) {
2923 [thisEnt setCargoFlag:CARGO_FLAG_FULL_SCARCE];
2924 } else if ([cargoType isEqualToString:@"PLENTIFUL_GOODS"]) {
2925 [thisEnt setCargoFlag:CARGO_FLAG_FULL_PLENTIFUL];
2926 } else if ([cargoType isEqualToString:@"MEDICAL_GOODS"]) {
2927 [thisEnt setCargoFlag:CARGO_FLAG_FULL_MEDICAL];
2928 } else if ([cargoType isEqualToString:@"ILLEGAL_GOODS"]) {
2929 [thisEnt setCargoFlag:CARGO_FLAG_FULL_CONTRABAND];
2930 } else if ([cargoType isEqualToString:@"PIRATE_GOODS"]) {
2931 [thisEnt setCargoFlag:CARGO_FLAG_PIRATE];
2932 } else {
2933 ok = NO;
2934 }
2935 OOJS_RETURN_BOOL(ok);
2936
2938}
void setCargoFlag:(OOCargoFlag flag)

References CARGO_NOT_CARGO, EXPECT_NOT, GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOStringFromJSValue(), and ShipEntity::setCargoFlag:.

Here is the call graph for this function:

◆ ShipSetCrew()

JSBool ShipSetCrew ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2866 of file OOJSShip.m.

2867{
2868 /* TODO: ships can in theory have multiple crew, so this could
2869 * allow that to be set. Probably not necessary for now. */
2870 OOJS_NATIVE_ENTER(context)
2871
2872 ShipEntity* thisEnt = nil;
2873 NSDictionary* crewDefinition = nil;
2874 JSObject* params = NULL;
2875
2876 GET_THIS_SHIP(thisEnt);
2877
2878 if (argc < 1 || (!JSVAL_IS_NULL(OOJS_ARGV[0]) && !JS_ValueToObject(context, OOJS_ARGV[0], &params))) {
2879 OOJSReportBadArguments(context, @"Ship", @"setCrew", MIN(argc, 1U), OOJS_ARGV, NULL, @"definition");
2880 return NO;
2881 }
2882 BOOL success = YES;
2883
2884 if (![thisEnt isExplicitlyUnpiloted]) {
2885 if (JSVAL_IS_NULL(OOJS_ARGV[0])) {
2886 [thisEnt setCrew:nil];
2887 } else {
2888 crewDefinition = OOJSNativeObjectFromJSObject(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]));
2889 OOCharacter* crew = [OOCharacter characterWithDictionary:crewDefinition];
2890 [thisEnt setCrew:[NSArray arrayWithObject:crew]];
2891 }
2892 } else {
2893 success = NO;
2894 }
2895
2896 OOJS_RETURN_BOOL(success);
2897
2899}
id OOJSNativeObjectFromJSObject(JSContext *context, JSObject *object)
OOCharacter * characterWithDictionary:(NSDictionary *c_dict)
void setCrew:(NSArray *crewArray)

References OOCharacter::characterWithDictionary:, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSNativeObjectFromJSObject(), OOJSReportBadArguments(), and ShipEntity::setCrew:.

Here is the call graph for this function:

◆ ShipSetEquipmentStatus()

JSBool ShipSetEquipmentStatus ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2603 of file OOJSShip.m.

2604{
2605 OOJS_NATIVE_ENTER(context)
2606
2607 // equipment status accepted: @"EQUIPMENT_OK", @"EQUIPMENT_DAMAGED"
2608
2609 ShipEntity* thisEnt = nil;
2610 OOEquipmentType* eqType = nil;
2611 NSString* key = nil;
2612 NSString* damagedKey = nil;
2613 NSString* status = nil;
2614 BOOL hasOK = NO, hasDamaged = NO;
2615
2616 GET_THIS_SHIP(thisEnt);
2617
2618 if (argc < 2) {
2619 OOJSReportBadArguments(context, @"Ship", @"setEquipmentStatus", argc, OOJS_ARGV, nil, @"equipment type and status");
2620 return NO;
2621 }
2622
2623 eqType = JSValueToEquipmentType(context, OOJS_ARGV[0]);
2624 if (EXPECT_NOT(eqType == nil)) {
2625 OOJSReportBadArguments(context, @"Ship", @"setEquipmentStatus", 1, &OOJS_ARGV[0], nil, @"equipment type");
2626 return NO;
2627 }
2628
2629 status = OOStringFromJSValue(context, OOJS_ARGV[1]);
2630 if (EXPECT_NOT(status == nil)) {
2631 OOJSReportBadArguments(context, @"Ship", @"setEquipmentStatus", 1, &OOJS_ARGV[1], nil, @"equipment status");
2632 return NO;
2633 }
2634
2635 // EMMSTRAN: use interned strings.
2636 if (![status isEqualToString:@"EQUIPMENT_OK"] && ![status isEqualToString:@"EQUIPMENT_DAMAGED"]) {
2637 OOJSReportErrorForCaller(context, @"Ship", @"setEquipmentStatus", @"Second parameter for setEquipmentStatus must be either \"EQUIPMENT_OK\" or \"EQUIPMENT_DAMAGED\".");
2638 return NO;
2639 }
2640
2641 key = [eqType identifier];
2642 hasOK = [thisEnt hasEquipmentItem:key];
2643 BOOL setOK = [status isEqualToString:@"EQUIPMENT_OK"];
2644 BOOL setDamaged = [status isEqualToString:@"EQUIPMENT_DAMAGED"];
2645 if ([eqType canBeDamaged]) {
2646 damagedKey = [key stringByAppendingString:@"_DAMAGED"];
2647 hasDamaged = [thisEnt hasEquipmentItem:damagedKey];
2648
2649 if ((setOK && hasDamaged) || (setDamaged && hasOK)) {
2650 // the implementation is identical between player and ship.
2651 [thisEnt removeEquipmentItem:(setDamaged ? key : damagedKey)];
2652 if ([thisEnt isPlayer]) {
2653 // these player methods are different to the ship ones.
2654 [(PlayerEntity*)thisEnt addEquipmentItem:(setDamaged ? damagedKey : key) withValidation:NO inContext:@"scripted"];
2655 if (setDamaged) {
2656 [(PlayerEntity*)thisEnt doScriptEvent:OOJSID("equipmentDamaged") withArgument:key];
2657 } else if (setOK) {
2658 [(PlayerEntity*)thisEnt doScriptEvent:OOJSID("equipmentRepaired") withArgument:key];
2659 }
2660
2661 // if player's Docking Computers are set to EQUIPMENT_DAMAGED while on, stop them
2662 // this is now done in a different method
2663 // if (hasOK && [key isEqualToString:@"EQ_DOCK_COMP"]) [(PlayerEntity*)thisEnt disengageAutopilot];
2664 } else {
2665 [thisEnt addEquipmentItem:(setDamaged ? damagedKey : key) withValidation:NO inContext:@"scripted"];
2666 if (hasOK)
2667 [thisEnt doScriptEvent:OOJSID("equipmentDamaged") withArgument:key];
2668 }
2669 }
2670 } else {
2671 if (hasOK && ![status isEqualToString:@"EQUIPMENT_OK"]) {
2672 OOJSReportWarningForCaller(context, @"Ship", @"setEquipmentStatus", @"Equipment %@ cannot be damaged.", key);
2673 hasOK = NO;
2674 }
2675 }
2676
2677 OOJS_RETURN_BOOL(hasOK || hasDamaged);
2678
2680}

References PlayerEntity::addEquipmentItem:withValidation:inContext:, ShipEntity::addEquipmentItem:withValidation:inContext:, ShipEntity::doScriptEvent:withArgument:, EXPECT_NOT, GET_THIS_SHIP, ShipEntity::hasEquipmentItem:, OOEquipmentType::identifier, JSValueToEquipmentType(), nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportErrorForCaller(), OOJSReportWarningForCaller(), OOStringFromJSValue(), and ShipEntity::removeEquipmentItem:.

Here is the call graph for this function:

◆ ShipSetMaterials()

JSBool ShipSetMaterials ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2941 of file OOJSShip.m.

2942{
2943 OOJS_NATIVE_ENTER(context)
2944
2945 ShipEntity* thisEnt = nil;
2946
2947 if (argc < 1) {
2948 OOJSReportBadArguments(context, @"Ship", @"setMaterials", 0, OOJS_ARGV, nil, @"parameter object");
2949 return NO;
2950 }
2951
2952 GET_THIS_SHIP(thisEnt);
2953
2954 return ShipSetMaterialsInternal(context, argc, vp, thisEnt, NO);
2955
2957}
static JSBool ShipSetMaterialsInternal(JSContext *context, uintN argc, jsval *vp, ShipEntity *thisEnt, BOOL fromShaders)
Definition OOJSShip.m:2985

References GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadArguments(), and ShipSetMaterialsInternal().

Here is the call graph for this function:

◆ ShipSetMaterialsInternal()

JSBool ShipSetMaterialsInternal ( JSContext * context,
uintN argc,
jsval * vp,
ShipEntity * thisEnt,
BOOL fromShaders )
static

Definition at line 2985 of file OOJSShip.m.

2986{
2988
2989 JSObject* params = NULL;
2990 NSDictionary* materials;
2991 NSDictionary* shaders;
2992 BOOL withShaders = NO;
2993 BOOL success = NO;
2994
2995 GET_THIS_SHIP(thisEnt);
2996
2997 if (JSVAL_IS_NULL(OOJS_ARGV[0]) || (!JSVAL_IS_NULL(OOJS_ARGV[0]) && !JSVAL_IS_OBJECT(OOJS_ARGV[0]))) {
2998 OOJSReportWarning(context, @"Ship.%@: expected %@ instead of '%@'.", @"setMaterials", @"object", OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[0]));
2999 OOJS_RETURN_BOOL(NO);
3000 }
3001
3002 if (argc > 1) {
3003 withShaders = YES;
3004 if (JSVAL_IS_NULL(OOJS_ARGV[1]) || (!JSVAL_IS_NULL(OOJS_ARGV[1]) && !JSVAL_IS_OBJECT(OOJS_ARGV[1]))) {
3005 OOJSReportWarning(context, @"Ship.%@: expected %@ instead of '%@'.", @"setMaterials", @"object as second parameter", OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[1]));
3006 withShaders = NO;
3007 }
3008 }
3009
3010 if (fromShaders) {
3011 materials = [[thisEnt mesh] materials];
3012 params = JSVAL_TO_OBJECT(OOJS_ARGV[0]);
3013 shaders = OOJSNativeObjectFromJSObject(context, params);
3014 } else {
3015 params = JSVAL_TO_OBJECT(OOJS_ARGV[0]);
3016 materials = OOJSNativeObjectFromJSObject(context, params);
3017 if (withShaders) {
3018 params = JSVAL_TO_OBJECT(OOJS_ARGV[1]);
3019 shaders = OOJSNativeObjectFromJSObject(context, params);
3020 } else {
3021 shaders = [[thisEnt mesh] shaders];
3022 }
3023 }
3024
3025 OOJS_BEGIN_FULL_NATIVE(context)
3026 NSDictionary* shipDict = [thisEnt shipInfoDictionary];
3027
3028 // First we test to see if we can create the mesh.
3029 OOMesh* mesh = [OOMesh meshWithName:[shipDict oo_stringForKey:@"model"]
3030 cacheKey:nil
3031 materialDictionary:materials
3032 shadersDictionary:shaders
3033 smooth:[shipDict oo_boolForKey:@"smooth" defaultValue:NO]
3034 shaderMacros:[[ResourceManager materialDefaults] oo_dictionaryForKey:@"ship-prefix-macros"]
3035 shaderBindingTarget:thisEnt];
3036
3037 if (mesh != nil) {
3038 [thisEnt setMesh:mesh];
3039 success = YES;
3040 }
3042
3043 OOJS_RETURN_BOOL(success);
3044
3046}
NSString * OOStringFromJSValueEvenIfNull(JSContext *context, jsval value)
NSDictionary * shaders()
Definition OOMesh.m:570
OOMaterial * materials[kOOMeshMaxMaterials]
Definition OOMesh.m:565
instancetype meshWithName:cacheKey:materialDictionary:shadersDictionary:smooth:shaderMacros:shaderBindingTarget:(NSString *name,[cacheKey] NSString *cacheKey,[materialDictionary] NSDictionary *materialDict,[shadersDictionary] NSDictionary *shadersDict,[smooth] BOOL smooth,[shaderMacros] NSDictionary *macros,[shaderBindingTarget] id< OOWeakReferenceSupport > object)
Definition OOMesh.m:223
NSDictionary * materialDefaults()
void setMesh:(OOMesh *mesh)
NSDictionary * shipInfoDictionary()
OOMesh * mesh()

References GET_THIS_SHIP, ResourceManager::materialDefaults, OOMesh::materials, ShipEntity::mesh, OOMesh::meshWithName:cacheKey:materialDictionary:shadersDictionary:smooth:shaderMacros:shaderBindingTarget:, nil, OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_BOOL, OOJSNativeObjectFromJSObject(), OOJSReportWarning(), OOStringFromJSValueEvenIfNull(), ShipEntity::setMesh:, OOMesh::shaders, and ShipEntity::shipInfoDictionary.

Referenced by ShipSetMaterials(), ShipSetMaterials(), ShipSetShaders(), and ShipSetShaders().

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

◆ ShipSetProperty()

JSBool ShipSetProperty ( JSContext * context,
JSObject * this,
jsid propID,
JSBool strict,
jsval * value )
static

Definition at line 1177 of file OOJSShip.m.

1178{
1179 if (!JSID_IS_INT(propID))
1180 return YES;
1181
1182 OOJS_NATIVE_ENTER(context)
1183
1184 ShipEntity* entity = nil;
1185 ShipEntity* target = nil;
1186 NSString* sValue = nil;
1187 jsdouble fValue;
1188 int32 iValue;
1189 JSBool bValue;
1190 Vector vValue;
1191 Quaternion qValue;
1192 HPVector hpvValue;
1193 OOShipGroup* group = nil;
1194 OOColor* colorForScript = nil;
1195 BOOL exists;
1196
1197 if (EXPECT_NOT(!JSShipGetShipEntity(context, this, &entity)))
1198 return NO;
1199 if (OOIsStaleEntity(entity))
1200 return YES;
1201
1202 NSCAssert(![entity isTemplateCargoPod], @"-OOJSShip: a template cargo pod has become accessible to Javascript");
1203
1204 switch (JSID_TO_INT(propID)) {
1205 case kShip_name:
1206 if (EXPECT_NOT([entity isPlayer]))
1207 goto playerReadOnly;
1208
1209 sValue = OOStringFromJSValue(context, *value);
1210 if (sValue != nil) {
1211 [entity setName:sValue];
1212 return YES;
1213 }
1214 break;
1215
1216 case kShip_displayName:
1217 if (EXPECT_NOT([entity isPlayer]))
1218 goto playerReadOnly;
1219
1220 sValue = OOStringFromJSValue(context, *value);
1221 if (sValue != nil) {
1222 [entity setDisplayName:sValue];
1223 return YES;
1224 }
1225 break;
1226
1228 sValue = OOStringFromJSValue(context, *value);
1229 if (sValue != nil) {
1230 [entity setShipUniqueName:sValue];
1231 return YES;
1232 }
1233 break;
1234
1236 sValue = OOStringFromJSValue(context, *value);
1237 if (sValue != nil) {
1238 [entity setShipClassName:sValue];
1239 return YES;
1240 }
1241 break;
1242
1244 sValue = OOStringFromJSValue(context, *value);
1245 // can set to nil
1246 [entity setScanDescription:sValue];
1247 return YES;
1248
1249 case kShip_primaryRole:
1250 if (EXPECT_NOT([entity isPlayer]))
1251 goto playerReadOnly;
1252
1253 sValue = OOStringFromJSValue(context, *value);
1254 if (sValue != nil) {
1255 [entity setPrimaryRole:sValue];
1256 return YES;
1257 }
1258 break;
1259
1260 case kShip_AIState:
1261 if (EXPECT_NOT([entity isPlayer]))
1262 goto playerReadOnly;
1263
1264 sValue = OOStringFromJSValue(context, *value);
1265 if (sValue != nil) {
1266 [[entity getAI] setState:sValue];
1267 return YES;
1268 }
1269 break;
1270
1271 case kShip_beaconCode:
1272 if (EXPECT_NOT([entity isPlayer]))
1273 goto playerReadOnly;
1274
1275 sValue = OOStringFromJSValue(context, *value);
1276 if ([sValue length] == 0) {
1277 if ([entity isBeacon]) {
1278 [UNIVERSE clearBeacon:entity];
1279 if ([PLAYER nextBeacon] == entity) {
1280 [PLAYER setCompassMode:COMPASS_MODE_PLANET];
1281 }
1282 }
1283 } else {
1284 if ([entity isBeacon]) {
1285 [entity setBeaconCode:sValue];
1286 } else // Universe needs to update beacon lists in this case only
1287 {
1288 [entity setBeaconCode:sValue];
1289 [UNIVERSE setNextBeacon:entity];
1290 }
1291 }
1292 return YES;
1293 break;
1294
1295 case kShip_beaconLabel:
1296 if (EXPECT_NOT([entity isPlayer]))
1297 goto playerReadOnly;
1298 sValue = OOStringFromJSValue(context, *value);
1299 if (sValue != nil) {
1300 [entity setBeaconLabel:sValue];
1301 return YES;
1302 }
1303 break;
1304
1305 case kShip_accuracy:
1306 if (EXPECT_NOT([entity isPlayer]))
1307 goto playerReadOnly;
1308
1309 if (JS_ValueToNumber(context, *value, &fValue)) {
1310 [entity setAccuracy:fValue];
1311 return YES;
1312 }
1313 break;
1314
1315 case kShip_fuel:
1316 if (JS_ValueToNumber(context, *value, &fValue)) {
1317 fValue = OOClamp_0_max_d(fValue, MAX_JUMP_RANGE);
1318 [entity setFuel:lround(fValue * 10.0)];
1319 return YES;
1320 }
1321 break;
1322
1324 if (JS_ValueToInt32(context, *value, &iValue)) {
1325 if (iValue < 0 || iValue > (int32)ENTITY_PERSONALITY_MAX) {
1326 OOJSReportError(context, @"ship.%@ must be >= 0 and <= %u.", OOStringFromJSPropertyIDAndSpec(context, propID, sShipProperties), ENTITY_PERSONALITY_MAX);
1327 return NO;
1328 }
1329 [entity setEntityPersonalityInt:iValue];
1330 return YES;
1331 }
1332
1334 if (JS_ValueToNumber(context, *value, &fValue)) {
1335 [entity setHyperspaceSpinTime:fValue];
1336 return YES;
1337 }
1338 break;
1339
1340 case kShip_bounty:
1341 if (JS_ValueToInt32(context, *value, &iValue)) {
1342 if (iValue < 0)
1343 iValue = 0;
1344 [entity setBounty:iValue withReason:kOOLegalStatusReasonByScript];
1345 return YES;
1346 }
1347 break;
1348
1350 if (JS_ValueToInt32(context, *value, &iValue)) {
1351 if (iValue < 0)
1352 iValue = 0;
1353 // OXPs using equipment with weight requirements may make us end up with more allocated
1354 // cargo space than what we have available. Do not let iValue become negative.
1355 if ([entity maxAvailableCargoSpace] < [entity availableCargoSpace]) {
1356 iValue = 0;
1357 } else if ((OOCargoQuantity)iValue < [entity maxAvailableCargoSpace] - [entity availableCargoSpace]) {
1358 iValue = [entity maxAvailableCargoSpace] - [entity availableCargoSpace];
1359 }
1360 [entity setMaxAvailableCargoSpace:iValue];
1361 return YES;
1362 }
1363 break;
1364
1366 if (JS_ValueToInt32(context, *value, &iValue)) {
1367 if (iValue < 0)
1368 iValue = 0;
1369 [entity setDestinationSystem:iValue];
1370 return YES;
1371 }
1372 break;
1373
1374 case kShip_homeSystem:
1375 if (JS_ValueToInt32(context, *value, &iValue)) {
1376 if (iValue < 0)
1377 iValue = 0;
1378 [entity setHomeSystem:iValue];
1379 return YES;
1380 }
1381 break;
1382
1383 case kShip_target:
1384 if (JSVAL_IS_NULL(*value)) {
1385 [entity setTargetForScript:nil];
1386 return YES;
1387 } else if (JSValueToEntity(context, *value, &target) && [target isKindOfClass:[ShipEntity class]]) {
1388 [entity setTargetForScript:target];
1389 return YES;
1390 }
1391 break;
1392
1394 if (EXPECT_NOT([entity isPlayer]))
1395 goto playerReadOnly;
1396
1397 if (JSVAL_IS_NULL(*value)) {
1398 [entity setFoundTarget:nil];
1399 return YES;
1400 } else if (JSValueToEntity(context, *value, &target) && [target isKindOfClass:[ShipEntity class]]) {
1401 [entity setFoundTarget:target];
1402 return YES;
1403 }
1404 break;
1405
1407 if (EXPECT_NOT([entity isPlayer]))
1408 goto playerReadOnly;
1409
1410 if (JSVAL_IS_NULL(*value)) {
1411 [entity setPrimaryAggressor:nil];
1412 return YES;
1413 } else if (JSValueToEntity(context, *value, &target) && [target isKindOfClass:[ShipEntity class]]) {
1414 [entity setPrimaryAggressor:target];
1415 return YES;
1416 }
1417 break;
1418
1419 case kShip_group:
1420 group = OOJSNativeObjectOfClassFromJSValue(context, *value, [OOShipGroup class]);
1421 if (group != nil || JSVAL_IS_NULL(*value)) {
1422 [entity setGroup:group];
1423 return YES;
1424 }
1425 break;
1426
1428 if (JS_ValueToNumber(context, *value, &fValue)) {
1429 [entity setAIScriptWakeTime:fValue];
1430 return YES;
1431 }
1432 break;
1433
1434 case kShip_temperature:
1435 if (JS_ValueToNumber(context, *value, &fValue)) {
1436 fValue = fmax(fValue, 0.0);
1437 [entity setTemperature:fValue * SHIP_MAX_CABIN_TEMP];
1438 return YES;
1439 }
1440 break;
1441
1443 if (JS_ValueToNumber(context, *value, &fValue)) {
1444 fValue = fmax(fValue, 0.125);
1445 [entity setHeatInsulation:fValue];
1446 return YES;
1447 }
1448 break;
1449
1450 case kShip_isCloaked:
1451 if (JS_ValueToBoolean(context, *value, &bValue)) {
1452 [entity setCloaked:bValue];
1453 return YES;
1454 }
1455 break;
1456
1458 if (JS_ValueToBoolean(context, *value, &bValue)) {
1459 [entity setAutoCloak:bValue];
1460 return YES;
1461 }
1462 break;
1463
1465 if (JS_ValueToNumber(context, *value, &fValue)) {
1466 [entity setMissileLoadTime:fmax(0.0, fValue)];
1467 return YES;
1468 }
1469 break;
1470
1471 case kShip_reactionTime:
1472 if (EXPECT_NOT([entity isPlayer]))
1473 goto playerReadOnly;
1474
1475 if (JS_ValueToNumber(context, *value, &fValue)) {
1476 [entity setReactionTime:fValue];
1477 return YES;
1478 }
1479 break;
1480
1482 if (JS_ValueToBoolean(context, *value, &bValue)) {
1483 [entity setReportAIMessages:bValue];
1484 return YES;
1485 }
1486 break;
1487
1489 if (JS_ValueToBoolean(context, *value, &bValue)) {
1490 [entity setTrackCloseContacts:bValue];
1491 return YES;
1492 }
1493 break;
1494
1495 case kShip_isBoulder:
1496 if (EXPECT_NOT([entity isPlayer]))
1497 goto playerReadOnly;
1498
1499 if (JS_ValueToBoolean(context, *value, &bValue)) {
1500 [entity setIsBoulder:bValue];
1501 return YES;
1502 }
1503 break;
1504
1505 case kShip_destination:
1506 if (EXPECT_NOT([entity isPlayer]))
1507 goto playerReadOnly;
1508
1509 if (JSValueToHPVector(context, *value, &hpvValue)) {
1510 // use setEscortDestination rather than setDestination as
1511 // scripted amendments shouldn't necessarily reset frustration
1512 [entity setEscortDestination:hpvValue];
1513 return YES;
1514 }
1515 break;
1516
1517 case kShip_desiredSpeed:
1518 if (EXPECT_NOT([entity isPlayer]))
1519 goto playerReadOnly;
1520
1521 if (JS_ValueToNumber(context, *value, &fValue)) {
1522 [entity setDesiredSpeed:fmax(fValue, 0.0)];
1523 return YES;
1524 }
1525 break;
1526
1527 case kShip_desiredRange:
1528 if (EXPECT_NOT([entity isPlayer]))
1529 goto playerReadOnly;
1530
1531 if (JS_ValueToNumber(context, *value, &fValue)) {
1532 [entity setDesiredRange:fmax(fValue, 0.0)];
1533 return YES;
1534 }
1535 break;
1536
1538 if (JSValueToHPVector(context, *value, &hpvValue)) {
1539 [entity setCoordinate:hpvValue];
1540 return YES;
1541 }
1542 break;
1543
1545 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
1546 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
1547 [entity setScannerDisplayColor1:colorForScript];
1548 return YES;
1549 }
1550 break;
1551
1553 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
1554 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
1555 [entity setScannerDisplayColor2:colorForScript];
1556 return YES;
1557 }
1558 break;
1559
1561 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
1562 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
1563 [entity setScannerDisplayColorHostile1:colorForScript];
1564 return YES;
1565 }
1566 break;
1567
1569 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
1570 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
1571 [entity setScannerDisplayColorHostile2:colorForScript];
1572 return YES;
1573 }
1574 break;
1575
1577 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
1578 if (colorForScript != nil || JSVAL_IS_NULL(*value)) {
1579 [entity setExhaustEmissiveColor:colorForScript];
1580 return YES;
1581 }
1582 break;
1583
1585 if (JS_ValueToBoolean(context, *value, &bValue)) {
1586 [entity setScriptedMisjump:bValue];
1587 return YES;
1588 }
1589 break;
1590
1592 if (JS_ValueToNumber(context, *value, &fValue)) {
1593 if (fValue > 0.0 && fValue < 1.0) {
1594 [entity setScriptedMisjumpRange:fValue];
1595 return YES;
1596 } else {
1597 OOJSReportError(context, @"ship.%@ must be > 0.0 and < 1.0.", OOStringFromJSPropertyIDAndSpec(context, propID, sShipProperties));
1598 return NO;
1599 }
1600 }
1601 break;
1602
1604 if (JSValueToQuaternion(context, *value, &qValue)) {
1605 [entity setSubEntityRotationalVelocity:qValue];
1606 return YES;
1607 }
1608 break;
1609
1611 if (JS_ValueToNumber(context, *value, &fValue)) {
1612 if (fValue >= 0.0f && fValue <= 1.0f) {
1613 [entity setSunGlareFilter:fValue];
1614 return YES;
1615 } else {
1616 OOJSReportError(context, @"ship.%@ must be > 0.0 and < 1.0.", OOStringFromJSPropertyIDAndSpec(context, propID, sShipProperties));
1617 return NO;
1618 }
1619 }
1620 break;
1621
1622 case kShip_thrust:
1623 // if (EXPECT_NOT([entity isPlayer])) goto playerReadOnly;
1624
1625 if (JS_ValueToNumber(context, *value, &fValue)) {
1626 [entity setThrust:OOClamp_0_max_f(fValue, [entity maxThrust])];
1627 return YES;
1628 }
1629 break;
1630
1631 case kShip_maxPitch:
1632 if (JS_ValueToNumber(context, *value, &fValue)) {
1633 if (fValue < 0) {
1634 OOJSReportError(context, @"ship.maxPitch cannot be negative.");
1635 return NO;
1636 }
1637 [entity setMaxFlightPitch:fValue];
1638 return YES;
1639 }
1640 break;
1641
1642 case kShip_maxSpeed:
1643 if (JS_ValueToNumber(context, *value, &fValue)) {
1644 if (fValue < 0) {
1645 OOJSReportError(context, @"ship.maxSpeed cannot be negative.");
1646 return NO;
1647 }
1648 [entity setMaxFlightSpeed:fValue];
1649 return YES;
1650 }
1651 break;
1652
1653 case kShip_maxRoll:
1654 if (JS_ValueToNumber(context, *value, &fValue)) {
1655 if (fValue < 0) {
1656 OOJSReportError(context, @"ship.maxRoll cannot be negative.");
1657 return NO;
1658 }
1659 [entity setMaxFlightRoll:fValue];
1660 return YES;
1661 }
1662 break;
1663
1664 case kShip_maxYaw:
1665 if (JS_ValueToNumber(context, *value, &fValue)) {
1666 if (fValue < 0) {
1667 OOJSReportError(context, @"ship.maxYaw cannot be negative.");
1668 return NO;
1669 }
1670 [entity setMaxFlightYaw:fValue];
1671 return YES;
1672 }
1673 break;
1674
1676 if (JS_ValueToNumber(context, *value, &fValue)) {
1677 if (fValue < 0) {
1678 OOJSReportError(context, @"ship.injectorBurnRate cannot be negative.");
1679 return NO;
1680 }
1681 [entity setAfterburnerRate:fValue];
1682 return YES;
1683 }
1684 break;
1685
1687 if (JS_ValueToNumber(context, *value, &fValue)) {
1688 if (fValue < 1) {
1689 OOJSReportError(context, @"ship.injectorSpeedFactor cannot be less than 1.0.");
1690 return NO;
1691 }
1692#if OO_VARIABLE_TORUS_SPEED
1693 else if (fValue > MIN_HYPERSPEED_FACTOR) {
1694 OOJSReportError(context, @"ship.injectorSpeedFactor cannot be higher than minimum torus speed factor (%f).", MIN_HYPERSPEED_FACTOR);
1695#else
1696 else if (fValue > HYPERSPEED_FACTOR) {
1697 OOJSReportError(context, @"ship.injectorSpeedFactor cannot be higher than torus speed factor (%f).", HYPERSPEED_FACTOR);
1698#endif
1699 return NO;
1700 }
1701 [entity setAfterburnerFactor:fValue];
1702 return YES;
1703 }
1704 break;
1705
1706 case kShip_maxThrust:
1707 if (JS_ValueToNumber(context, *value, &fValue)) {
1708 if (fValue < 0) {
1709 OOJSReportError(context, @"ship.maxThrust cannot be negative.");
1710 return NO;
1711 }
1712 [entity setMaxThrust:fValue];
1713 return YES;
1714 }
1715 break;
1716
1718 if (JS_ValueToNumber(context, *value, &fValue)) {
1719 if (fValue < 0) {
1720 OOJSReportError(context, @"ship.energyRechargeRate cannot be negative.");
1721 return NO;
1722 }
1723 [entity setEnergyRechargeRate:fValue];
1724 return YES;
1725 }
1726 break;
1727
1728 case kShip_lightsActive:
1729 if (JS_ValueToBoolean(context, *value, &bValue)) {
1730 if (bValue)
1731 [entity switchLightsOn];
1732 else
1733 [entity switchLightsOff];
1734 return YES;
1735 }
1736 break;
1737
1738 case kShip_velocity:
1739 if (JSValueToVector(context, *value, &vValue)) {
1740 [entity setTotalVelocity:vValue];
1741 return YES;
1742 }
1743 break;
1744
1745 case kShip_portWeapon:
1747 case kShip_aftWeapon:
1750 sValue = JSValueToEquipmentKeyRelaxed(context, *value, &exists);
1751 if (sValue == nil) {
1752 sValue = @"EQ_WEAPON_NONE";
1753 }
1755 switch (JSID_TO_INT(propID)) {
1756 case kShip_aftWeapon:
1757 facing = WEAPON_FACING_AFT;
1758 break;
1760 facing = WEAPON_FACING_FORWARD;
1761 break;
1762 case kShip_portWeapon:
1763 facing = WEAPON_FACING_PORT;
1764 break;
1766 facing = WEAPON_FACING_STARBOARD;
1767 break;
1769 facing = [entity currentWeaponFacing];
1770 break;
1771 }
1772 if ([entity isPlayer]) {
1773 PlayerEntity* pent = (PlayerEntity*)entity;
1774 [pent setWeaponMount:facing toWeapon:sValue inContext:@"scripted"];
1775 } else {
1776 [entity setWeaponMount:facing toWeapon:sValue];
1777 }
1778 return YES;
1779
1780 case kShip_maxEscorts:
1781 if (EXPECT_NOT([entity isPlayer]))
1782 goto playerReadOnly;
1783
1784 if (JS_ValueToInt32(context, *value, &iValue)) {
1785 if ((NSInteger)iValue < (NSInteger)[[entity escortGroup] count] - 1) {
1786 OOJSReportError(context, @"ship.%@ must be >= current escort numbers.", OOStringFromJSPropertyIDAndSpec(context, propID, sShipProperties));
1787 return NO;
1788 }
1789 if (iValue > MAX_ESCORTS) {
1790 OOJSReportError(context, @"ship.%@ must be <= %d.", OOStringFromJSPropertyIDAndSpec(context, propID, sShipProperties), MAX_ESCORTS);
1791 return NO;
1792 }
1793 [entity setMaxEscortCount:iValue];
1794 return YES;
1795 }
1796
1797 break;
1798
1799 default:
1800 OOJSReportBadPropertySelector(context, this, propID, sShipProperties);
1801 return NO;
1802 }
1803
1804 OOJSReportBadPropertyValue(context, this, propID, sShipProperties, *value);
1805 return NO;
1806
1807playerReadOnly:
1808 OOJSReportError(context, @"player.ship.%@ is read-only.", OOStringFromJSPropertyIDAndSpec(context, propID, sShipProperties));
1809 return NO;
1810
1811 // Not used (yet)
1812 /*
1813 npcReadOnly:
1814 OOJSReportError(context, @"npc.ship.%@ is read-only.", OOStringFromJSPropertyIDAndSpec(context, propID, sShipProperties));
1815 return NO;
1816 */
1817
1819}
OOINLINE double OOClamp_0_max_d(double value, double max) INLINE_CONST_FUNC
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:133
BOOL JSValueToQuaternion(JSContext *context, jsval value, Quaternion *outQuaternion) NONNULL_FUNC
BOOL JSValueToVector(JSContext *context, jsval value, Vector *outVector) NONNULL_FUNC
Definition OOJSVector.m:341
BOOL JSValueToHPVector(JSContext *context, jsval value, HPVector *outVector) NONNULL_FUNC
Definition OOJSVector.m:333
NSString * OOStringFromJSPropertyIDAndSpec(JSContext *context, jsid propID, JSPropertySpec *propertySpec)
id OOJSNativeObjectOfClassFromJSValue(JSContext *context, jsval value, Class requiredClass)
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
OOWeaponFacing
Definition OOTypes.h:195
@ WEAPON_FACING_FORWARD
Definition OOTypes.h:196
@ WEAPON_FACING_AFT
Definition OOTypes.h:197
@ WEAPON_FACING_PORT
Definition OOTypes.h:198
@ WEAPON_FACING_STARBOARD
Definition OOTypes.h:199
#define HYPERSPEED_FACTOR
#define MIN_HYPERSPEED_FACTOR
#define MAX_JUMP_RANGE
Definition ShipEntity.h:109
#define MAX_ESCORTS
Definition ShipEntity.h:76
#define ENTITY_PERSONALITY_MAX
Definition ShipEntity.h:112
void setState:(NSString *stateName)
Definition AI.m:303
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135
BOOL setWeaponMount:toWeapon:inContext:(OOWeaponFacing facing,[toWeapon] NSString *eqKey,[inContext] NSString *context)
void setMaxFlightYaw:(GLfloat new)
void setScannerDisplayColor1:(OOColor *color1)
void setExhaustEmissiveColor:(OOColor *color)
void setAfterburnerFactor:(GLfloat new)
void setBounty:withReason:(OOCreditsQuantity amount,[withReason] OOLegalStatusReason reason)
float maxThrust()
void setPrimaryAggressor:(Entity *targetEntity)
void setDesiredSpeed:(double amount)
void setEnergyRechargeRate:(GLfloat new)
void setFuel:(OOFuelQuantity amount)
void setCoordinate:(HPVector coord)
void setMaxFlightRoll:(GLfloat new)
void setThrust:(double amount)
void setDestinationSystem:(OOSystemID s)
void setMaxAvailableCargoSpace:(OOCargoQuantity new)
void switchLightsOn()
void setScannerDisplayColorHostile1:(OOColor *color1)
void setAIScriptWakeTime:(OOTimeAbsolute t)
void setGroup:(OOShipGroup *group)
void setEscortDestination:(HPVector dest)
void setDisplayName:(NSString *inName)
void setAccuracy:(GLfloat new_accuracy)
void setAutoCloak:(BOOL automatic)
void setAfterburnerRate:(GLfloat new)
void setPrimaryRole:(NSString *role)
void setHeatInsulation:(GLfloat value)
void setScannerDisplayColor2:(OOColor *color2)
BOOL setWeaponMount:toWeapon:(OOWeaponFacing facing,[toWeapon] NSString *eqKey)
void setTargetForScript:(ShipEntity *target)
void setName:(NSString *inName)
void setBeaconCode:(NSString *bcode)
void setScanDescription:(NSString *inName)
void switchLightsOff()
void setMaxFlightPitch:(GLfloat new)
void setReactionTime:(float newReactionTime)
void setScriptedMisjumpRange:(GLfloat newValue)
void setEntityPersonalityInt:(uint16_t value)
void setReportAIMessages:(BOOL yn)
void setTrackCloseContacts:(BOOL value)
void setSubEntityRotationalVelocity:(Quaternion rv)
void setMaxFlightSpeed:(GLfloat new)
OOCargoQuantity maxAvailableCargoSpace()
void setTemperature:(GLfloat value)
void setScriptedMisjump:(BOOL newValue)
void setTotalVelocity:(Vector vel)
void setSunGlareFilter:(GLfloat newValue)
void setCloaked:(BOOL cloak)
void setIsBoulder:(BOOL flag)
void setMaxEscortCount:(uint8_t newCount)
void setBeaconLabel:(NSString *blabel)
void setFoundTarget:(Entity *targetEntity)
void setScannerDisplayColorHostile2:(OOColor *color2)
void setMissileLoadTime:(OOTimeDelta newMissileLoadTime)
void setDesiredRange:(double amount)
void setHomeSystem:(OOSystemID s)
void setHyperspaceSpinTime:(float new)
void setShipUniqueName:(NSString *inName)
void setMaxThrust:(GLfloat new)
void setShipClassName:(NSString *inName)

References ShipEntity::availableCargoSpace, OOColor::colorWithDescription:, count, ShipEntity::currentWeaponFacing, ENTITY_PERSONALITY_MAX, EXPECT_NOT, ShipEntity::getAI, HYPERSPEED_FACTOR, JSValueToEntity(), JSValueToEquipmentKeyRelaxed(), JSValueToHPVector(), JSValueToQuaternion(), JSValueToVector(), kShip_accuracy, kShip_aftWeapon, kShip_AIFoundTarget, kShip_AIPrimaryAggressor, kShip_AIScriptWakeTime, kShip_AIState, kShip_beaconCode, kShip_beaconLabel, kShip_bounty, kShip_cargoSpaceCapacity, kShip_cloakAutomatic, kShip_currentWeapon, kShip_desiredRange, kShip_desiredSpeed, kShip_destination, kShip_destinationSystem, kShip_displayName, kShip_energyRechargeRate, kShip_entityPersonality, kShip_exhaustEmissiveColor, kShip_forwardWeapon, kShip_fuel, kShip_group, kShip_heatInsulation, kShip_homeSystem, kShip_hyperspaceSpinTime, kShip_injectorBurnRate, kShip_injectorSpeedFactor, kShip_isBoulder, kShip_isCloaked, kShip_lightsActive, kShip_maxEscorts, kShip_maxPitch, kShip_maxRoll, kShip_maxSpeed, kShip_maxThrust, kShip_maxYaw, kShip_missileLoadTime, kShip_name, kShip_portWeapon, kShip_primaryRole, kShip_reactionTime, kShip_reportAIMessages, kShip_savedCoordinates, kShip_scanDescription, kShip_scannerDisplayColor1, kShip_scannerDisplayColor2, kShip_scannerHostileDisplayColor1, kShip_scannerHostileDisplayColor2, kShip_scriptedMisjump, kShip_scriptedMisjumpRange, kShip_shipClassName, kShip_shipUniqueName, kShip_starboardWeapon, kShip_subEntityRotation, kShip_sunGlareFilter, kShip_target, kShip_temperature, kShip_thrust, kShip_trackCloseContacts, kShip_velocity, MAX_ESCORTS, MAX_JUMP_RANGE, ShipEntity::maxAvailableCargoSpace, ShipEntity::maxThrust, MIN_HYPERSPEED_FACTOR, nil, OOClamp_0_max_d(), OOIsStaleEntity(), OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSNativeObjectOfClassFromJSValue(), OOJSReportBadPropertySelector(), OOJSReportBadPropertyValue(), OOJSReportError(), OOStringFromJSPropertyIDAndSpec(), OOStringFromJSValue(), PLAYER, ShipEntity::setAccuracy:, ShipEntity::setAfterburnerFactor:, ShipEntity::setAfterburnerRate:, ShipEntity::setAIScriptWakeTime:, ShipEntity::setAutoCloak:, ShipEntity::setBeaconCode:, ShipEntity::setBeaconLabel:, ShipEntity::setBounty:withReason:, ShipEntity::setCloaked:, ShipEntity::setCoordinate:, ShipEntity::setDesiredRange:, ShipEntity::setDesiredSpeed:, ShipEntity::setDestinationSystem:, ShipEntity::setDisplayName:, ShipEntity::setEnergyRechargeRate:, ShipEntity::setEntityPersonalityInt:, ShipEntity::setEscortDestination:, ShipEntity::setExhaustEmissiveColor:, ShipEntity::setFoundTarget:, ShipEntity::setFuel:, ShipEntity::setGroup:, ShipEntity::setHeatInsulation:, ShipEntity::setHomeSystem:, ShipEntity::setHyperspaceSpinTime:, ShipEntity::setIsBoulder:, ShipEntity::setMaxAvailableCargoSpace:, ShipEntity::setMaxEscortCount:, ShipEntity::setMaxFlightPitch:, ShipEntity::setMaxFlightRoll:, ShipEntity::setMaxFlightSpeed:, ShipEntity::setMaxFlightYaw:, ShipEntity::setMaxThrust:, ShipEntity::setMissileLoadTime:, ShipEntity::setName:, ShipEntity::setPrimaryAggressor:, ShipEntity::setPrimaryRole:, ShipEntity::setReactionTime:, ShipEntity::setReportAIMessages:, ShipEntity::setScanDescription:, ShipEntity::setScannerDisplayColor1:, ShipEntity::setScannerDisplayColor2:, ShipEntity::setScannerDisplayColorHostile1:, ShipEntity::setScannerDisplayColorHostile2:, ShipEntity::setScriptedMisjump:, ShipEntity::setScriptedMisjumpRange:, ShipEntity::setShipClassName:, ShipEntity::setShipUniqueName:, AI::setState:, ShipEntity::setSubEntityRotationalVelocity:, ShipEntity::setSunGlareFilter:, ShipEntity::setTargetForScript:, ShipEntity::setTemperature:, ShipEntity::setThrust:, ShipEntity::setTotalVelocity:, ShipEntity::setTrackCloseContacts:, ShipEntity::setWeaponMount:toWeapon:, PlayerEntity::setWeaponMount:toWeapon:inContext:, sShipProperties, ShipEntity::switchLightsOff, ShipEntity::switchLightsOn, WEAPON_FACING_AFT, WEAPON_FACING_FORWARD, WEAPON_FACING_PORT, and WEAPON_FACING_STARBOARD.

Here is the call graph for this function:

◆ ShipSetScript()

JSBool ShipSetScript ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1832 of file OOJSShip.m.

1833{
1834 OOJS_NATIVE_ENTER(context)
1835
1836 ShipEntity* thisEnt = nil;
1837 NSString* name = nil;
1838
1839 GET_THIS_SHIP(thisEnt);
1840 if (argc > 0)
1841 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1842 if (EXPECT_NOT(name == nil)) {
1843 OOJSReportBadArguments(context, @"Ship", @"setScript", MIN(argc, 1U), OOJS_ARGV, nil, @"string (script name)");
1844 return NO;
1845 }
1846 if (EXPECT_NOT([thisEnt isPlayer])) {
1847 OOJSReportErrorForCaller(context, @"Ship", @"setScript", @"Not valid for player ship.");
1848 return NO;
1849 }
1850
1851 [thisEnt setShipScript:name];
1853
1855}
void setShipScript:(NSString *script_name)

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOJSReportErrorForCaller(), OOStringFromJSValue(), and ShipEntity::setShipScript:.

Here is the call graph for this function:

◆ ShipSetShaders()

JSBool ShipSetShaders ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2960 of file OOJSShip.m.

2961{
2962 OOJS_NATIVE_ENTER(context)
2963
2964 ShipEntity* thisEnt = nil;
2965
2966 GET_THIS_SHIP(thisEnt);
2967
2968 if (argc < 1) {
2969 OOJSReportBadArguments(context, @"Ship", @"setShaders", 0, OOJS_ARGV, nil, @"parameter object");
2970 return NO;
2971 }
2972
2973 if (JSVAL_IS_NULL(OOJS_ARGV[0]) || (!JSVAL_IS_NULL(OOJS_ARGV[0]) && !JSVAL_IS_OBJECT(OOJS_ARGV[0]))) {
2974 // EMMSTRAN: JS_ValueToObject() and normal error handling here.
2975 OOJSReportWarning(context, @"Ship.%@: expected %@ instead of '%@'.", @"setShaders", @"object", OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[0]));
2976 OOJS_RETURN_BOOL(NO);
2977 }
2978
2979 OOJS_ARGV[1] = OOJS_ARGV[0];
2980 return ShipSetMaterialsInternal(context, argc, vp, thisEnt, YES);
2981
2983}

References GET_THIS_SHIP, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportWarning(), OOStringFromJSValueEvenIfNull(), and ShipSetMaterialsInternal().

Here is the call graph for this function:

◆ ShipSpawn()

JSBool ShipSpawn ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 2197 of file OOJSShip.m.

2198{
2199 OOJS_NATIVE_ENTER(context)
2200
2201 ShipEntity* thisEnt = nil;
2202 NSString* role = nil;
2203 int32 count = 1;
2204 BOOL gotCount = YES;
2205 NSArray* result = nil;
2206
2207 GET_THIS_SHIP(thisEnt);
2208
2209 if (argc > 0)
2210 role = OOStringFromJSValue(context, OOJS_ARGV[0]);
2211 if (argc > 1)
2212 gotCount = JS_ValueToInt32(context, OOJS_ARGV[1], &count);
2213 if (EXPECT_NOT(role == nil || !gotCount || count < 1 || count > 64)) {
2214 OOJSReportBadArguments(context, @"Ship", @"spawn", MIN(argc, 1U), OOJS_ARGV, nil, @"role and optional quantity (1 to 64)");
2215 return NO;
2216 }
2217
2218 OOJS_BEGIN_FULL_NATIVE(context)
2219 result = [thisEnt spawnShipsWithRole:role count:count];
2221
2222 OOJS_RETURN_OBJECT(result);
2223
2225}
NSArray * spawnShipsWithRole:count:(NSString *role,[count] NSUInteger count)

References count, EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), OOStringFromJSValue(), and ShipEntity::spawnShipsWithRole:count:.

Here is the call graph for this function:

◆ ShipStaticKeys()

JSBool ShipStaticKeys ( JSContext * context,
uintN argc,
jsval * vp )
static

Static methods

Definition at line 3928 of file OOJSShip.m.

3929{
3930 OOJS_NATIVE_ENTER(context);
3932
3933 NSArray* keys = [registry shipKeys];
3934 OOJS_RETURN_OBJECT(keys);
3935
3937}
OOShipRegistry * sharedRegistry()
NSArray * shipKeys()

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOShipRegistry::sharedRegistry, and OOShipRegistry::shipKeys.

Here is the call graph for this function:

◆ ShipStaticKeysForRole()

JSBool ShipStaticKeysForRole ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3939 of file OOJSShip.m.

3940{
3941 OOJS_NATIVE_ENTER(context);
3943
3944 if (argc > 0) {
3945 NSString* role = OOStringFromJSValue(context, OOJS_ARGV[0]);
3946 NSArray* keys = [registry shipKeysWithRole:role];
3947 OOJS_RETURN_OBJECT(keys);
3948 } else {
3949 OOJSReportBadArguments(context, @"Ship", @"shipKeysForRole", MIN(argc, 1U), OOJS_ARGV, nil, @"ship role");
3950 return NO;
3951 }
3952
3954}
NSArray * shipKeysWithRole:(NSString *role)

References MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), OOStringFromJSValue(), OOShipRegistry::sharedRegistry, and OOShipRegistry::shipKeysWithRole:.

Here is the call graph for this function:

◆ ShipStaticRoleIsInCategory()

JSBool ShipStaticRoleIsInCategory ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3956 of file OOJSShip.m.

3957{
3958 OOJS_NATIVE_ENTER(context);
3959
3960 if (argc > 1) {
3961 NSString* role = OOStringFromJSValue(context, OOJS_ARGV[0]);
3962 NSString* category = OOStringFromJSValue(context, OOJS_ARGV[1]);
3963
3964 OOJS_RETURN_BOOL([UNIVERSE role:role isInCategory:category]);
3965 } else {
3966 OOJSReportBadArguments(context, @"Ship", @"roleIsInCategory", MIN(argc, 2U), OOJS_ARGV, nil, @"role, category");
3967 return NO;
3968 }
3969
3971}

References MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOStringFromJSValue(), and UNIVERSE.

Here is the call graph for this function:

◆ ShipStaticRoles()

JSBool ShipStaticRoles ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3973 of file OOJSShip.m.

3974{
3975 OOJS_NATIVE_ENTER(context);
3977
3978 NSArray* keys = [registry shipRoles];
3979 OOJS_RETURN_OBJECT(keys);
3980
3982}
NSArray * shipRoles()

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOShipRegistry::sharedRegistry, and OOShipRegistry::shipRoles.

Here is the call graph for this function:

◆ ShipStaticSetShipDataForKey()

JSBool ShipStaticSetShipDataForKey ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 4000 of file OOJSShip.m.

4001{
4002 OOJS_NATIVE_ENTER(context);
4004
4005 if (argc >= 2) {
4006 NSString* key = OOStringFromJSValue(context, OOJS_ARGV[0]);
4007 NSDictionary* newShipData = OOJSNativeObjectFromJSObject(context, JSVAL_TO_OBJECT(OOJS_ARGV[1]));
4008 [registry setShipInfoForKey:key with:newShipData];
4009 OOJS_RETURN_BOOL(YES);
4010 } else {
4011 OOJSReportBadArguments(context, @"Ship", @"setShipInfoForKey", MIN(argc, 2U), OOJS_ARGV, nil, @"key shipdata");
4012 return NO;
4013 }
4015}
void setShipInfoForKey:with:(NSString *key,[with] NSDictionary *newShipData)

References MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSNativeObjectFromJSObject(), OOJSReportBadArguments(), OOStringFromJSValue(), OOShipRegistry::setShipInfoForKey:with:, and OOShipRegistry::sharedRegistry.

Here is the call graph for this function:

◆ ShipStaticShipDataForKey()

JSBool ShipStaticShipDataForKey ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3984 of file OOJSShip.m.

3985{
3986 OOJS_NATIVE_ENTER(context);
3988
3989 if (argc > 0) {
3990 NSString* key = OOStringFromJSValue(context, OOJS_ARGV[0]);
3991 NSDictionary* keys = [registry shipInfoForKey:key];
3992 OOJS_RETURN_OBJECT(keys);
3993 } else {
3994 OOJSReportBadArguments(context, @"Ship", @"shipDataForKey", MIN(argc, 1U), OOJS_ARGV, nil, @"key");
3995 return NO;
3996 }
3998}
NSDictionary * shipInfoForKey:(NSString *key)

References MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), OOStringFromJSValue(), OOShipRegistry::sharedRegistry, and OOShipRegistry::shipInfoForKey:.

Here is the call graph for this function:

◆ ShipSwitchAI()

JSBool ShipSwitchAI ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 1884 of file OOJSShip.m.

1885{
1886 OOJS_NATIVE_ENTER(context)
1887
1888 ShipEntity* thisEnt = nil;
1889 NSString* name = nil;
1890
1891 GET_THIS_SHIP(thisEnt);
1892 if (argc > 0)
1893 name = OOStringFromJSValue(context, OOJS_ARGV[0]);
1894 if (EXPECT_NOT(name == nil)) {
1895 OOJSReportBadArguments(context, @"Ship", @"switchAI", MIN(argc, 1U), OOJS_ARGV, nil, @"string (AI name)");
1896 return NO;
1897 }
1898 if (EXPECT_NOT([thisEnt isPlayer])) {
1899 OOJSReportErrorForCaller(context, @"Ship", @"switchAI", @"Not valid for player ship.");
1900 return NO;
1901 }
1902
1903 [thisEnt switchAITo:name];
1905
1907}
void switchAITo:(NSString *aiString)

References EXPECT_NOT, GET_THIS_SHIP, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOJSReportBadArguments(), OOJSReportErrorForCaller(), OOStringFromJSValue(), and ShipEntity::switchAITo:.

Here is the call graph for this function:

◆ ShipThreatAssessment()

JSBool ShipThreatAssessment ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3797 of file OOJSShip.m.

3798{
3800
3801 ShipEntity* thisEnt = nil;
3802 JSBool fullCheck = NO;
3803
3804 GET_THIS_SHIP(thisEnt);
3805
3806 if (argc > 0 && EXPECT_NOT(!JS_ValueToBoolean(context, OOJS_ARGV[0], &fullCheck))) {
3807 OOJSReportBadArguments(context, @"Ship", @"threatAssessment", argc, OOJS_ARGV, nil, @"boolean");
3808 return NO;
3809 }
3810 // start with 2.5 per ship
3811 double assessment = 2.5;
3812 // +/- 0.1 for speed, larger subtraction for very slow ships
3813 GLfloat maxspeed = [thisEnt maxFlightSpeed];
3814 assessment += (maxspeed - 300) / 1000;
3815 if (maxspeed < 200) {
3816 assessment += (maxspeed - 200) / 500;
3817 }
3818
3819 /* FIXME: at the moment this means NPCs can detect other NPCs shield
3820 * boosters, since they're implemented as extra energy */
3821 assessment += ([thisEnt maxEnergy] - 200) / 1000;
3822
3823 // add on some for missiles. Mostly ignore 3rd and subsequent
3824 // missiles: either they can be ECMd or the first two are already
3825 // too many.
3826 if ([thisEnt missileCapacity] > 2) {
3827 assessment += 0.5;
3828 } else {
3829 assessment += ((double)[thisEnt missileCapacity]) / 5.0;
3830 }
3831
3832 /* Turret count is public knowledge */
3833 /* TODO: consider making ship combat behaviour try to
3834 * stay at long range from enemies with turrets. Then
3835 * we could perhaps reduce this bonus a bit. */
3836 assessment += [thisEnt turretCount];
3837
3838 if (fullCheck) {
3839 // consider pilot skill
3840 if ([thisEnt isPlayer]) {
3841 double score = (double)[PLAYER score];
3842 if (score > 6400) {
3843 score = 6400;
3844 }
3845 assessment += pow(score, 0.33) / 10;
3846 // 0 - 1.8
3847 } else {
3848 assessment += [thisEnt accuracy] / 5;
3849 }
3850
3851 // check lasers
3852 OOWeaponType wt = [thisEnt weaponTypeIDForFacing:WEAPON_FACING_FORWARD strict:NO];
3853 /* Not affected by multiple mounts here: they're either just a
3854 * split of the power, or only more dangerous until they
3855 * overheat */
3856 assessment += ShipThreatAssessmentWeapon(wt);
3857 if (isWeaponNone(wt)) {
3858 assessment -= 1.5; // further penalty for ships with no forward laser
3859 }
3860
3861 wt = [thisEnt weaponTypeIDForFacing:WEAPON_FACING_AFT strict:NO];
3862 if (!isWeaponNone(wt)) {
3863 assessment += 1 + ShipThreatAssessmentWeapon(wt);
3864 }
3865 // port and starboard weapons less important
3866 wt = [thisEnt weaponTypeIDForFacing:WEAPON_FACING_PORT strict:NO];
3867 if (!isWeaponNone(wt)) {
3868 assessment += 0.2 + ShipThreatAssessmentWeapon(wt) / 5.0;
3869 }
3870 wt = [thisEnt weaponTypeIDForFacing:WEAPON_FACING_STARBOARD strict:NO];
3871 if (!isWeaponNone(wt)) {
3872 assessment += 0.2 + ShipThreatAssessmentWeapon(wt) / 5.0;
3873 }
3874
3875 // combat-related secondary equipment
3876 if ([thisEnt hasECM]) {
3877 assessment += 0.5;
3878 }
3879 if ([thisEnt hasFuelInjection]) {
3880 assessment += 0.5;
3881 }
3882
3883 } else {
3884 // consider thargoids dangerous
3885 if ([thisEnt isThargoid]) {
3886 assessment *= 1.5;
3887 if ([thisEnt hasRole:@"thargoid-mothership"]) {
3888 assessment += 5;
3889 }
3890 } else {
3891 // consider that armed ships might have a trick or two
3892 if ([thisEnt weaponFacings] == 1) {
3893 assessment += 0.25;
3894 } else {
3895 // and more than one trick if they can mount multiple lasers
3896 assessment += 0.5;
3897 }
3898 }
3899 }
3900
3901 // mostly ignore fleeing ships as threats
3902 if ([thisEnt behaviour] == BEHAVIOUR_FLEE_TARGET || [thisEnt behaviour] == BEHAVIOUR_FLEE_EVASIVE_ACTION) {
3903 assessment *= 0.2;
3904 } else if ([thisEnt isPlayer] && [(PlayerEntity*)thisEnt fleeingStatus] >= PLAYER_FLEEING_CARGO) {
3905 assessment *= 0.2;
3906 }
3907
3908 // don't go too low.
3909 if (assessment < 0.1) {
3910 assessment = 0.1;
3911 }
3912
3913 OOJS_RETURN_DOUBLE(assessment);
3914
3916}
static double ShipThreatAssessmentWeapon(OOWeaponType wt)
Definition OOJSShip.m:3918
#define OOJS_RETURN_DOUBLE(value)
OOEquipmentType * OOWeaponType
Definition ShipEntity.h:164
BOOL isWeaponNone(OOWeaponType weapon)

References EXPECT_NOT, GET_THIS_SHIP, isWeaponNone(), nil, OOJS_ARGV, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_DOUBLE, OOJSReportBadArguments(), PLAYER, PLAYER_FLEEING_CARGO, and ShipThreatAssessmentWeapon().

Here is the call graph for this function:

◆ ShipThreatAssessmentWeapon()

double ShipThreatAssessmentWeapon ( OOWeaponType wt)
static

Definition at line 3918 of file OOJSShip.m.

3919{
3920 if (wt == nil) {
3921 return -1.0;
3922 }
3923 return [wt weaponThreatAssessment];
3924}
GLfloat weaponThreatAssessment()

References nil, and OOEquipmentType::weaponThreatAssessment.

Referenced by ShipThreatAssessment(), and ShipThreatAssessment().

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

◆ ShipThrowSpark()

JSBool ShipThrowSpark ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3413 of file OOJSShip.m.

3414{
3416
3417 ShipEntity* thisEnt = nil;
3418 GET_THIS_SHIP(thisEnt);
3419 [thisEnt setThrowSparks:YES];
3420
3422
3424}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

◆ ShipUpdateEscortFormation()

JSBool ShipUpdateEscortFormation ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 3077 of file OOJSShip.m.

3078{
3080
3081 ShipEntity* thisEnt = nil;
3082 GET_THIS_SHIP(thisEnt);
3083 [thisEnt updateEscortFormation];
3084
3086
3088}

References GET_THIS_SHIP, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_VOID.

Variable Documentation

◆ sShipClass

JSClass sShipClass
static
Initial value:
= {
"Ship",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}
static JSBool ShipSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
Definition OOJSShip.m:1177
static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
Definition OOJSShip.m:592
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Definition at line 153 of file OOJSShip.m.

153 {
154 "Ship",
155 JSCLASS_HAS_PRIVATE,
156
157 JS_PropertyStub, // addProperty
158 JS_PropertyStub, // delProperty
159 ShipGetProperty, // getProperty
160 ShipSetProperty, // setProperty
161 JS_EnumerateStub, // enumerate
162 JS_ResolveStub, // resolve
163 JS_ConvertStub, // convert
164 OOJSObjectWrapperFinalize, // finalize
165 JSCLASS_NO_OPTIONAL_MEMBERS
166};

Referenced by InitOOJSShip(), InitOOJSShip(), and JSShipClass().

◆ sShipMethods

JSFunctionSpec sShipMethods[]
static

Definition at line 476 of file OOJSShip.m.

476 {
477 // JS name Function min args
478 { "abandonShip", ShipAbandonShip, 0 },
479 { "addCargoEntity", ShipAddCargoEntity, 1 },
480 { "addCollisionException", ShipAddCollisionException, 1 },
481 { "addDefenseTarget", ShipAddDefenseTarget, 1 },
482 { "adjustCargo", ShipAdjustCargo, 2 },
483 { "awardEquipment", ShipAwardEquipment, 1 },
484 { "becomeCascadeExplosion", ShipBecomeCascadeExplosion, 0 },
485 { "broadcastCascadeImminent", ShipBroadcastCascadeImminent, 0 },
486 { "broadcastDistressMessage", ShipBroadcastDistressMessage, 0 },
487 { "canAwardEquipment", ShipCanAwardEquipment, 1 },
488 { "checkCourseToDestination", ShipCheckCourseToDestination, 0 },
489 { "checkScanner", ShipCheckScanner, 0 },
490 { "clearDefenseTargets", ShipClearDefenseTargets, 0 },
491 { "commsMessage", ShipCommsMessage, 1 },
492 { "damageAssessment", ShipDamageAssessment, 0 },
493 { "dealEnergyDamage", ShipDealEnergyDamage, 2 },
494 { "deployEscorts", ShipDeployEscorts, 0 },
495 { "dockEscorts", ShipDockEscorts, 0 },
496 { "dumpCargo", ShipDumpCargo, 0 },
497 { "ejectItem", ShipEjectItem, 1 },
498 { "ejectSpecificItem", ShipEjectSpecificItem, 1 },
499 { "enterWormhole", ShipEnterWormhole, 0 },
500 { "equipmentStatus", ShipEquipmentStatus, 1 },
501 { "exitAI", ShipExitAI, 0 },
502 { "exitSystem", ShipExitSystem, 0 },
503 { "explode", ShipExplode, 0 },
504 { "fireECM", ShipFireECM, 0 },
505 { "fireMissile", ShipFireMissile, 0 },
506 { "findNearestStation", ShipFindNearestStation, 0 },
507 { "getMaterials", ShipGetMaterials, 0 },
508 { "getSafeCourseToDestination", ShipGetSafeCourseToDestination, 0 },
509 { "getShaders", ShipGetShaders, 0 },
510 { "hasEquipmentProviding", ShipHasEquipmentProviding, 1 },
511 { "hasRole", ShipHasRole, 1 },
512 { "markTargetForFines", ShipMarkTargetForFines, 0 },
513 { "notifyGroupOfWormhole", ShipNotifyGroupOfWormhole, 0 },
514 { "offerToEscort", ShipOfferToEscort, 1 },
515 { "patrolReportIn", ShipPatrolReportIn, 1 },
516 { "performAttack", ShipPerformAttack, 0 },
517 { "performCollect", ShipPerformCollect, 0 },
518 { "performEscort", ShipPerformEscort, 0 },
519 { "performFaceDestination", ShipPerformFaceDestination, 0 },
520 { "performFlee", ShipPerformFlee, 0 },
521 { "performFlyToRangeFromDestination", ShipPerformFlyToRangeFromDestination, 0 },
522 { "performHold", ShipPerformHold, 0 },
523 { "performIdle", ShipPerformIdle, 0 },
524 { "performIntercept", ShipPerformIntercept, 0 },
525 { "performLandOnPlanet", ShipPerformLandOnPlanet, 0 },
526 { "performMining", ShipPerformMining, 0 },
527 { "performScriptedAI", ShipPerformScriptedAI, 0 },
528 { "performScriptedAttackAI", ShipPerformScriptedAttackAI, 0 },
529 { "performStop", ShipPerformStop, 0 },
530 { "performTumble", ShipPerformTumble, 0 },
531
532 { "reactToAIMessage", ShipReactToAIMessage, 1 },
533 { "remove", ShipRemove, 0 },
534 { "removeCollisionException", ShipRemoveCollisionException, 1 },
535 { "removeDefenseTarget", ShipRemoveDefenseTarget, 1 },
536 { "removeEquipment", ShipRemoveEquipment, 1 },
537 { "requestHelpFromGroup", ShipRequestHelpFromGroup, 0 },
538 { "requestDockingInstructions", ShipRequestDockingInstructions, 0 },
539 { "recallDockingInstructions", ShipRecallDockingInstructions, 0 },
540 { "restoreSubEntities", ShipRestoreSubEntities, 0 },
541 { "__runLegacyScriptActions", ShipRunLegacyScriptActions, 2 }, // Deliberately not documented
542 { "selectNewMissile", ShipSelectNewMissile, 0 },
543 { "sendAIMessage", ShipSendAIMessage, 1 },
544 { "setAI", ShipSetAI, 1 },
545 { "setBounty", ShipSetBounty, 2 },
546 { "setCargo", ShipSetCargo, 1 },
547 { "setCargoType", ShipSetCargoType, 1 },
548 { "setCrew", ShipSetCrew, 1 },
549 { "setEquipmentStatus", ShipSetEquipmentStatus, 2 },
550 { "setMaterials", ShipSetMaterials, 1 },
551 { "setScript", ShipSetScript, 1 },
552 { "setShaders", ShipSetShaders, 2 },
553 { "spawn", ShipSpawn, 1 },
554 // spawnOne() is defined in the prefix script.
555 { "switchAI", ShipSwitchAI, 1 },
556 { "threatAssessment", ShipThreatAssessment, 1 },
557 { "throwSpark", ShipThrowSpark, 0 },
558 { "updateEscortFormation", ShipUpdateEscortFormation, 0 },
559 { 0 }
560};
static JSBool ShipPerformCollect(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3439
static JSBool ShipRemoveDefenseTarget(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3166
static JSBool ShipPatrolReportIn(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3329
static JSBool ShipCheckCourseToDestination(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3670
static JSBool ShipExitSystem(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3049
static JSBool ShipPerformFlyToRangeFromDestination(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3491
static JSBool ShipPerformEscort(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3452
static JSBool ShipSwitchAI(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:1884
static JSBool ShipThreatAssessment(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3797
static JSBool ShipHasRole(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2045
static JSBool ShipAbandonShip(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2395
static JSBool ShipRestoreSubEntities(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2574
static JSBool ShipExitAI(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:1910
static JSBool ShipPerformMining(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3556
static JSBool ShipSelectNewMissile(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2742
static JSBool ShipThrowSpark(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3413
static JSBool ShipUpdateEscortFormation(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3077
static JSBool ShipSetCargo(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2836
static JSBool ShipPerformFaceDestination(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3465
static JSBool ShipSetShaders(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2960
static JSBool ShipSetMaterials(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2941
static JSBool ShipSendAIMessage(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:1967
static JSBool ShipBroadcastCascadeImminent(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3268
static JSBool ShipFindNearestStation(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2781
static JSBool ShipSpawn(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2197
static JSBool ShipGetShaders(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3251
static JSBool ShipPerformScriptedAttackAI(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3582
static JSBool ShipHasEquipmentProviding(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2023
static JSBool ShipExplode(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2272
static JSBool ShipCommsMessage(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2346
static JSBool ShipDamageAssessment(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3770
static JSBool ShipRemove(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2282
static JSBool ShipClearDefenseTargets(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3133
static JSBool ShipDealEnergyDamage(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2228
static JSBool ShipEquipmentStatus(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2683
static JSBool ShipPerformHold(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3504
static JSBool ShipFireMissile(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2761
static JSBool ShipAddCargoEntity(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2089
static JSBool ShipRequestHelpFromGroup(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3314
static JSBool ShipBecomeCascadeExplosion(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3281
static JSBool ShipCanAwardEquipment(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2408
static JSBool ShipNotifyGroupOfWormhole(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3399
static JSBool ShipSetCargoType(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2902
static JSBool ShipDockEscorts(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2008
static JSBool ShipPerformFlee(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3478
static JSBool ShipDumpCargo(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2157
static JSBool ShipMarkTargetForFines(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3351
static JSBool ShipReactToAIMessage(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:1941
static JSBool ShipSetEquipmentStatus(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2603
static JSBool ShipSetScript(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:1832
static JSBool ShipPerformLandOnPlanet(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3543
static JSBool ShipPerformIdle(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3517
static JSBool ShipFireECM(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2375
static JSBool ShipCheckScanner(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3698
static JSBool ShipPerformIntercept(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3530
static JSBool ShipEjectSpecificItem(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2135
static JSBool ShipSetCrew(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2866
static JSBool ShipRemoveCollisionException(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3210
static JSBool ShipAddDefenseTarget(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3146
static JSBool ShipAddCollisionException(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3186
static JSBool ShipAwardEquipment(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2454
static JSBool ShipDeployEscorts(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:1993
static JSBool ShipPerformStop(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3595
static JSBool ShipGetMaterials(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3233
static JSBool ShipRequestDockingInstructions(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3621
static JSBool ShipSetBounty(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2808
static JSBool ShipGetSafeCourseToDestination(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3684
static JSBool ShipSetAI(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:1858
static JSBool ShipEnterWormhole(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3370
static JSBool ShipEjectItem(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2067
static JSBool ShipPerformScriptedAI(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3569
static JSBool ShipPerformAttack(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3426
static JSBool ShipRemoveEquipment(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2523
static JSBool ShipBroadcastDistressMessage(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3657
static JSBool ShipRunLegacyScriptActions(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:2312
static JSBool ShipOfferToEscort(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3294
static JSBool ShipRecallDockingInstructions(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3639
static JSBool ShipPerformTumble(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3608
static JSBool ShipAdjustCargo(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3728

Referenced by InitOOJSShip(), and InitOOJSShip().

◆ sShipProperties

JSPropertySpec sShipProperties[]
static

Definition at line 325 of file OOJSShip.m.

325 {
326 // JS name ID flags
327 { "accuracy", kShip_accuracy, OOJS_PROP_READWRITE_CB },
328 { "aftWeapon", kShip_aftWeapon, OOJS_PROP_READWRITE_CB },
330 { "AIScript", kShip_AIScript, OOJS_PROP_READONLY_CB },
331 { "AIScriptWakeTime", kShip_AIScriptWakeTime, OOJS_PROP_READWRITE_CB },
333 { "AIFoundTarget", kShip_AIFoundTarget, OOJS_PROP_READWRITE_CB },
334 { "AIPrimaryAggressor", kShip_AIPrimaryAggressor, OOJS_PROP_READWRITE_CB },
335 { "alertCondition", kShip_alertCondition, OOJS_PROP_READONLY_CB },
336 { "autoAI", kShip_autoAI, OOJS_PROP_READONLY_CB },
337 { "autoWeapons", kShip_autoWeapons, OOJS_PROP_READONLY_CB },
338 { "beaconCode", kShip_beaconCode, OOJS_PROP_READWRITE_CB },
339 { "beaconLabel", kShip_beaconLabel, OOJS_PROP_READWRITE_CB },
340 { "boundingBox", kShip_boundingBox, OOJS_PROP_READONLY_CB },
342 { "cargoList", kShip_cargoList, OOJS_PROP_READONLY_CB },
343 { "cargoSpaceUsed", kShip_cargoSpaceUsed, OOJS_PROP_READONLY_CB },
344 { "cargoSpaceCapacity", kShip_cargoSpaceCapacity, OOJS_PROP_READWRITE_CB },
345 { "cargoSpaceAvailable", kShip_cargoSpaceAvailable, OOJS_PROP_READONLY_CB },
346 { "collisionExceptions", kShip_collisionExceptions, OOJS_PROP_READONLY_CB },
347 { "commodity", kShip_commodity, OOJS_PROP_READONLY_CB },
348 { "commodityAmount", kShip_commodityAmount, OOJS_PROP_READONLY_CB },
349 // contracts instead of cargo to distinguish them from the manifest
350 { "contracts", kShip_contracts, OOJS_PROP_READONLY_CB },
351 { "cloakAutomatic", kShip_cloakAutomatic, OOJS_PROP_READWRITE_CB },
353 { "cruiseSpeed", kShip_cruiseSpeed, OOJS_PROP_READONLY_CB },
354 { "currentWeapon", kShip_currentWeapon, OOJS_PROP_READWRITE_CB },
355 { "dataKey", kShip_dataKey, OOJS_PROP_READONLY_CB },
356 { "defenseTargets", kShip_defenseTargets, OOJS_PROP_READONLY_CB },
357 { "desiredRange", kShip_desiredRange, OOJS_PROP_READWRITE_CB },
358 { "desiredSpeed", kShip_desiredSpeed, OOJS_PROP_READWRITE_CB },
359 { "destination", kShip_destination, OOJS_PROP_READWRITE_CB },
360 { "destinationSystem", kShip_destinationSystem, OOJS_PROP_READWRITE_CB },
361 { "displayName", kShip_displayName, OOJS_PROP_READWRITE_CB },
362 { "dockingInstructions", kShip_dockingInstructions, OOJS_PROP_READONLY_CB },
363 { "energyRechargeRate", kShip_energyRechargeRate, OOJS_PROP_READWRITE_CB },
364 { "entityPersonality", kShip_entityPersonality, OOJS_PROP_READWRITE_CB },
365 { "equipment", kShip_equipment, OOJS_PROP_READONLY_CB },
366 { "escorts", kShip_escorts, OOJS_PROP_READONLY_CB },
367 { "escortGroup", kShip_escortGroup, OOJS_PROP_READONLY_CB },
368 { "exhaustEmissiveColor", kShip_exhaustEmissiveColor, OOJS_PROP_READWRITE_CB },
369 { "exhausts", kShip_exhausts, OOJS_PROP_READONLY_CB },
370 { "extraCargo", kShip_extraCargo, OOJS_PROP_READONLY_CB },
371 { "flashers", kShip_flashers, OOJS_PROP_READONLY_CB },
372 { "forwardWeapon", kShip_forwardWeapon, OOJS_PROP_READWRITE_CB },
374 { "fuelChargeRate", kShip_fuelChargeRate, OOJS_PROP_READONLY_CB },
376 { "hasHostileTarget", kShip_hasHostileTarget, OOJS_PROP_READONLY_CB },
377 { "hasHyperspaceMotor", kShip_hasHyperspaceMotor, OOJS_PROP_READONLY_CB },
378 { "hasSuspendedAI", kShip_hasSuspendedAI, OOJS_PROP_READONLY_CB },
379 { "heatInsulation", kShip_heatInsulation, OOJS_PROP_READWRITE_CB },
380 { "heading", kShip_heading, OOJS_PROP_READONLY_CB },
381 { "homeSystem", kShip_homeSystem, OOJS_PROP_READWRITE_CB },
382 { "hyperspaceSpinTime", kShip_hyperspaceSpinTime, OOJS_PROP_READWRITE_CB },
383 { "injectorBurnRate", kShip_injectorBurnRate, OOJS_PROP_READWRITE_CB },
384 { "injectorSpeedFactor", kShip_injectorSpeedFactor, OOJS_PROP_READWRITE_CB },
385 { "homeSystem", kShip_homeSystem, OOJS_PROP_READWRITE_CB },
386 { "isBeacon", kShip_isBeacon, OOJS_PROP_READONLY_CB },
387 { "isCloaked", kShip_isCloaked, OOJS_PROP_READWRITE_CB },
388 { "isCargo", kShip_isCargo, OOJS_PROP_READONLY_CB },
389 { "isDerelict", kShip_isDerelict, OOJS_PROP_READONLY_CB },
390 { "isFrangible", kShip_isFrangible, OOJS_PROP_READONLY_CB },
391 { "isFleeing", kShip_isFleeing, OOJS_PROP_READONLY_CB },
392 { "isJamming", kShip_isJamming, OOJS_PROP_READONLY_CB },
393 { "isMinable", kShip_isMinable, OOJS_PROP_READONLY_CB },
394 { "isMine", kShip_isMine, OOJS_PROP_READONLY_CB },
395 { "isMissile", kShip_isMissile, OOJS_PROP_READONLY_CB },
396 { "isPiloted", kShip_isPiloted, OOJS_PROP_READONLY_CB },
397 { "isPirate", kShip_isPirate, OOJS_PROP_READONLY_CB },
398 { "isPirateVictim", kShip_isPirateVictim, OOJS_PROP_READONLY_CB },
399 { "isPolice", kShip_isPolice, OOJS_PROP_READONLY_CB },
400 { "isRock", kShip_isRock, OOJS_PROP_READONLY_CB },
401 { "isBoulder", kShip_isBoulder, OOJS_PROP_READWRITE_CB },
402 { "isThargoid", kShip_isThargoid, OOJS_PROP_READONLY_CB },
403 { "isTurret", kShip_isTurret, OOJS_PROP_READONLY_CB },
404 { "isTrader", kShip_isTrader, OOJS_PROP_READONLY_CB },
405 { "isWeapon", kShip_isWeapon, OOJS_PROP_READONLY_CB },
406 { "laserHeatLevel", kShip_laserHeatLevel, OOJS_PROP_READONLY_CB },
407 { "laserHeatLevelAft", kShip_laserHeatLevelAft, OOJS_PROP_READONLY_CB },
408 { "laserHeatLevelForward", kShip_laserHeatLevelForward, OOJS_PROP_READONLY_CB },
409 { "laserHeatLevelPort", kShip_laserHeatLevelPort, OOJS_PROP_READONLY_CB },
410 { "laserHeatLevelStarboard", kShip_laserHeatLevelStarboard, OOJS_PROP_READONLY_CB },
411 { "lightsActive", kShip_lightsActive, OOJS_PROP_READWRITE_CB },
412 { "markedForFines", kShip_markedForFines, OOJS_PROP_READONLY_CB },
413 { "maxEscorts", kShip_maxEscorts, OOJS_PROP_READWRITE_CB },
414 { "maxPitch", kShip_maxPitch, OOJS_PROP_READWRITE_CB },
415 { "maxSpeed", kShip_maxSpeed, OOJS_PROP_READWRITE_CB },
418 { "maxThrust", kShip_maxThrust, OOJS_PROP_READWRITE_CB },
419 { "missileCapacity", kShip_missileCapacity, OOJS_PROP_READONLY_CB },
420 { "missileLoadTime", kShip_missileLoadTime, OOJS_PROP_READWRITE_CB },
421 { "missiles", kShip_missiles, OOJS_PROP_READONLY_CB },
423 { "parcelCount", kShip_parcelCount, OOJS_PROP_READONLY_CB },
424 { "parcels", kShip_parcels, OOJS_PROP_READONLY_CB },
425 { "passengerCount", kShip_passengerCount, OOJS_PROP_READONLY_CB },
426 { "passengerCapacity", kShip_passengerCapacity, OOJS_PROP_READONLY_CB },
427 { "passengers", kShip_passengers, OOJS_PROP_READONLY_CB },
429 { "portWeapon", kShip_portWeapon, OOJS_PROP_READWRITE_CB },
430 { "potentialCollider", kShip_potentialCollider, OOJS_PROP_READONLY_CB },
431 { "primaryRole", kShip_primaryRole, OOJS_PROP_READWRITE_CB },
432 { "reactionTime", kShip_reactionTime, OOJS_PROP_READWRITE_CB },
433 { "reportAIMessages", kShip_reportAIMessages, OOJS_PROP_READWRITE_CB },
434 { "roleWeights", kShip_roleWeights, OOJS_PROP_READONLY_CB },
437 { "savedCoordinates", kShip_savedCoordinates, OOJS_PROP_READWRITE_CB },
438 { "scanDescription", kShip_scanDescription, OOJS_PROP_READWRITE_CB },
439 { "scannerDisplayColor1", kShip_scannerDisplayColor1, OOJS_PROP_READWRITE_CB },
440 { "scannerDisplayColor2", kShip_scannerDisplayColor2, OOJS_PROP_READWRITE_CB },
441 { "scannerHostileDisplayColor1", kShip_scannerHostileDisplayColor1, OOJS_PROP_READWRITE_CB },
442 { "scannerHostileDisplayColor2", kShip_scannerHostileDisplayColor2, OOJS_PROP_READWRITE_CB },
443 { "scannerRange", kShip_scannerRange, OOJS_PROP_READONLY_CB },
444 { "script", kShip_script, OOJS_PROP_READONLY_CB },
445 { "scriptedMisjump", kShip_scriptedMisjump, OOJS_PROP_READWRITE_CB },
446 { "scriptedMisjumpRange", kShip_scriptedMisjumpRange, OOJS_PROP_READWRITE_CB },
447 { "scriptInfo", kShip_scriptInfo, OOJS_PROP_READONLY_CB },
448 { "shipClassName", kShip_shipClassName, OOJS_PROP_READWRITE_CB },
449 { "shipUniqueName", kShip_shipUniqueName, OOJS_PROP_READWRITE_CB },
451 { "starboardWeapon", kShip_starboardWeapon, OOJS_PROP_READWRITE_CB },
452 { "subEntities", kShip_subEntities, OOJS_PROP_READONLY_CB },
453 { "subEntityCapacity", kShip_subEntityCapacity, OOJS_PROP_READONLY_CB },
454 { "subEntityRotation", kShip_subEntityRotation, OOJS_PROP_READWRITE_CB },
455 { "sunGlareFilter", kShip_sunGlareFilter, OOJS_PROP_READWRITE_CB },
457 { "temperature", kShip_temperature, OOJS_PROP_READWRITE_CB },
459 { "thrustVector", kShip_thrustVector, OOJS_PROP_READONLY_CB },
460 { "trackCloseContacts", kShip_trackCloseContacts, OOJS_PROP_READWRITE_CB },
461 { "vectorForward", kShip_vectorForward, OOJS_PROP_READONLY_CB },
462 { "vectorRight", kShip_vectorRight, OOJS_PROP_READONLY_CB },
463 { "vectorUp", kShip_vectorUp, OOJS_PROP_READONLY_CB },
464 { "velocity", kShip_velocity, OOJS_PROP_READWRITE_CB },
465 { "weaponFacings", kShip_weaponFacings, OOJS_PROP_READONLY_CB },
466 { "weaponPositionAft", kShip_weaponPositionAft, OOJS_PROP_READONLY_CB },
467 { "weaponPositionForward", kShip_weaponPositionForward, OOJS_PROP_READONLY_CB },
468 { "weaponPositionPort", kShip_weaponPositionPort, OOJS_PROP_READONLY_CB },
469 { "weaponPositionStarboard", kShip_weaponPositionStarboard, OOJS_PROP_READONLY_CB },
470 { "weaponRange", kShip_weaponRange, OOJS_PROP_READONLY_CB },
471 { "withinStationAegis", kShip_withinStationAegis, OOJS_PROP_READONLY_CB },
473 { 0 }
474};
#define OOJS_PROP_READWRITE_CB
#define OOJS_PROP_READONLY_CB

Referenced by InitOOJSShip(), InitOOJSShip(), ShipGetProperty(), ShipGetProperty(), ShipSetProperty(), and ShipSetProperty().

◆ sShipPrototype

JSObject* sShipPrototype
static

Definition at line 53 of file OOJSShip.m.

Referenced by InitOOJSShip(), and JSShipPrototype().

◆ sShipStaticMethods

JSFunctionSpec sShipStaticMethods[]
static
Initial value:
= {
{ "keys", ShipStaticKeys, 0 },
{ "keysForRole", ShipStaticKeysForRole, 1 },
{ "roleIsInCategory", ShipStaticRoleIsInCategory, 2 },
{ "roles", ShipStaticRoles, 0 },
{ "shipDataForKey", ShipStaticShipDataForKey, 1 },
{ "setShipDataForKey", ShipStaticSetShipDataForKey, 2 },
{ 0 }
}
static JSBool ShipStaticKeysForRole(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3939
static JSBool ShipStaticKeys(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3928
static JSBool ShipStaticShipDataForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3984
static JSBool ShipStaticRoleIsInCategory(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3956
static JSBool ShipStaticRoles(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:3973
static JSBool ShipStaticSetShipDataForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSShip.m:4000

Definition at line 562 of file OOJSShip.m.

562 {
563 // JS name Function min args
564 { "keys", ShipStaticKeys, 0 },
565 { "keysForRole", ShipStaticKeysForRole, 1 },
566 { "roleIsInCategory", ShipStaticRoleIsInCategory, 2 },
567 { "roles", ShipStaticRoles, 0 },
568 { "shipDataForKey", ShipStaticShipDataForKey, 1 },
569 { "setShipDataForKey", ShipStaticSetShipDataForKey, 2 },
570 { 0 }
571};

Referenced by InitOOJSShip(), and InitOOJSShip().