Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
ship.c File Reference

Space objects: creation, weapons, movement and damage. More...

#include "game.h"

Go to the source code of this file.

Macros

#define SHIP_C

Functions

short CountShipProjectiles (short ship)
short ShipHasCloakingDevice (short ship)
short CanShipWeaponDamageTarget (short ship, short target)
short IsCapitalShipObject (short obj)
short HasShipCockpitGunDisplay (short ship)
short ShipHasTorpedo (short ship)
short GetAdaptiveTurnRate (void)
void IncreaseAdaptiveDifficulty (void)
void DecreaseAdaptiveDifficulty (void)
short initialize_object (short obj, short type, short owner, short matchLoadedType)
short borrow_dust (void)
short new_object (short type, short owner)
short initialize_ship (short type, short owner, short matchLoadedType)
short any_selected (unsigned char *loadout, short objectClass)
void remove_weapon (short obj, short weapon)
void InitializeShipWeaponTypeIndices (short obj)
void set_objects_data (short obj, short type, short owner, short matchResourceType)
unsigned int match_rotation_goal (short *rotation, short *goal, short totalError, short rate)
void rotate_object_to_goal (short obj)
void check_for_lost_control (short obj)
void celerate (short ship, int delta)
unsigned int approach_speed (short ship, int targetSpeed)
void steady_object (short ship)
short real_velocity (short obj)
unsigned int fix_velocity (short obj)
void SortViableTargetsByDistance (void)
void send_appropriate_message (short attacker, short victim)
short inflict_damage (short attacker, short victim, short damage, const FixedVector *impactDirection)
short pilot_hit (short obj)
short onboard_explosion (short obj)
void call_enemy (short obj)
short RandomBelow (short n)
short internal_damage (short attacker, short owner, short victim, short damage, short quadrant)
void revise_shields (short obj)
void check_computer_damage (void)
short IsOnlyShipGun (short ship, short weapon)
short your_internal_damage (short attacker, short owner, short damage, short quadrant)
short ReportComponentRepaired (short component, short minimumDamage)
void repair_internal_damage (void)
void AddFixedVectors (const FixedVector *left, const FixedVector *right, FixedVector *sum)
void Create_ship_hit_debris (short obj, short count)
void check_next_wave (void)
void ProcessEnemyWaveCompletion (void)
void Create_explosion_debris (short obj)
void affect_mission_score (short pilot, int event, short amount)
void score_for_kill (short pilot, short victim)
void analyze_kill (short attacker, short victim)
void explosion_shock_wave (short obj, short blastDamage)
short ShipExplosion (short obj)
short Explosion (short obj)
short explode (short attacker, short victim)
short ResolveObjectDestruction (short attacker, short victim)
short SpawnFlakBurst (short obj, short range, FixedVector *hardpoint, short burstMode)
void fire_flack (short owner, short explosion, short range, FixedVector *aim, short burstMode)
short hemisphere (FixedVector *target, FixedVector *parent, FixedVector *hardpoint)
int send_at_point (short obj, FixedVector *point, short speed)
short find_child_object (short parent, short objectClass)
short find_child_ship (short parent, short objectClass, short target)
int launch_object (short parent, short child, FixedVector direction, short speed)
void fire (short obj, short target)
short RandomSign (short v)
int RandomFixedAimComponent (short radius, short speed, short maximum)
short HasShipActiveMissile (short obj)
short fire_turrets (short obj)
void ScaleFixedVector (FixedVector *vector, int scale, FixedVector *result)
void copy_frame (short source, short destination)
short fire_weapon (short obj, short weapon)
short find_weapon (short obj, short weaponType)
short fire_missile (short ship)
void fire_fixed_projectile_weapon (short obj)
void fire_afterburner (short obj, short time)
void fire_super_brake (short ship)
short flip_angle (short ship, short angle)
void place_exhaust_on_ships (void)
void reposition_fixed_child_objects (void)
void housekeep_power_plant_and_fuel (short ship)
void replenish_shields (short ship)
void replenish_weapon_energy_bank (short ship)
void accelerate (short amount)
void your_afterburner (void)

Variables

short g_bAiMissileFiringEnabled = 1
short g_bFriendlyFireWarningIssued = 0
short g_nLastAdaptiveDifficultyChangeFrame = 0
short g_nObjectType62Index = -1
short g_nObjectType63Index = -1
short g_nLastFriendlyFireObjectFrame = 0x0ee4
short g_aasPlayerDamageSystemTable [5][10]
static short g_aaeExplosionDebris [4][7]
short g_aeShipHitDebrisTypes [4]
short g_bExplosionTraversalIdle = 1
signed char g_acGunRefireDelay [4] = {5, 9, 3, 4}
int g_6_nPendingAfterburnerSfxFrame
short g_asWingmanDamageCredit [10]
short g_nAdaptiveDifficulty
short g_7_asShipBurstStageCountdown [10]
int g_3_bAfterburnerSfxActive
signed char g_10_abExplosionEntityDoneBytes [SPACE_OBJECT_COUNT]
short g_asPlayerHitsCreditValues [10]
short g_asMissileProximityFuseValues [16]
short g_1_asObjectCreationFrameTable [SPACE_OBJECT_COUNT]

Detailed Description

Space objects: creation, weapons, movement and damage.

Definition in file ship.c.

Macro Definition Documentation

◆ SHIP_C

#define SHIP_C

Definition at line 6 of file ship.c.

Function Documentation

◆ accelerate()

void accelerate ( short amount)

◆ AddFixedVectors()

void AddFixedVectors ( const FixedVector * left,
const FixedVector * right,
FixedVector * sum )

Definition at line 211 of file geom.c.

◆ affect_mission_score()

void affect_mission_score ( short pilot,
int event,
short amount )

◆ analyze_kill()

◆ any_selected()

short any_selected ( unsigned char * loadout,
short objectClass )

Definition at line 264 of file ship.c.

References any_selected(), and g_aObjectTypeData.

Referenced by any_selected(), DrawTextAt(), and remove_weapon().

◆ approach_speed()

◆ borrow_dust()

◆ call_enemy()

◆ CanShipWeaponDamageTarget()

short CanShipWeaponDamageTarget ( short ship,
short target )

◆ celerate()

void celerate ( short ship,
int delta )

◆ check_computer_damage()

void check_computer_damage ( void )

◆ check_for_lost_control()

◆ check_next_wave()

◆ copy_frame()

void copy_frame ( short source,
short destination )

Definition at line 470 of file geom.c.

◆ CountShipProjectiles()

short CountShipProjectiles ( short ship)

◆ Create_explosion_debris()

◆ Create_ship_hit_debris()

◆ DecreaseAdaptiveDifficulty()

◆ explode()

◆ Explosion()

◆ explosion_shock_wave()

◆ find_child_object()

short find_child_object ( short parent,
short objectClass )

Definition at line 2017 of file ship.c.

References find_child_object(), g_acObjectOwner, g_aeObjectClass, and SPACE_OBJECT_COUNT.

Referenced by DrawTextAt(), and find_child_object().

◆ find_child_ship()

short find_child_ship ( short parent,
short objectClass,
short target )

Definition at line 2030 of file ship.c.

References find_child_ship(), g_acObjectOwner, g_acShipTarget, and g_aeObjectClass.

Referenced by DrawTextAt(), find_child_ship(), and fire().

◆ find_weapon()

short find_weapon ( short obj,
short weaponType )

Definition at line 2666 of file ship.c.

References find_weapon(), and g_aShipWeapons.

Referenced by DrawTextAt(), find_weapon(), and perform_maneuver().

◆ fire()

◆ fire_afterburner()

◆ fire_fixed_projectile_weapon()

◆ fire_flack()

void fire_flack ( short owner,
short explosion,
short range,
FixedVector * aim,
short burstMode )

◆ fire_missile()

◆ fire_super_brake()

void fire_super_brake ( short ship)

◆ fire_turrets()

◆ fire_weapon()

◆ fix_velocity()

unsigned int fix_velocity ( short obj)

◆ flip_angle()

short flip_angle ( short ship,
short angle )

Definition at line 2757 of file ship.c.

References flip_angle(), g_asObjectFlip, and g_asObjectScreenAngle.

Referenced by DrawTextAt(), flip_angle(), and place_exhaust_on_ships().

◆ GetAdaptiveTurnRate()

◆ HasShipActiveMissile()

short HasShipActiveMissile ( short obj)

◆ HasShipCockpitGunDisplay()

◆ hemisphere()

short hemisphere ( FixedVector * target,
FixedVector * parent,
FixedVector * hardpoint )

Definition at line 2222 of file ship.c.

References ComputeVectorDelta(), hemisphere(), and vector_angle().

Referenced by DrawTextAt(), fire_turrets(), and hemisphere().

◆ housekeep_power_plant_and_fuel()

void housekeep_power_plant_and_fuel ( short ship)

◆ IncreaseAdaptiveDifficulty()

◆ inflict_damage()

◆ initialize_object()

short initialize_object ( short obj,
short type,
short owner,
short matchLoadedType )

◆ initialize_ship()

short initialize_ship ( short type,
short owner,
short matchLoadedType )

◆ InitializeShipWeaponTypeIndices()

◆ internal_damage()

◆ IsCapitalShipObject()

short IsCapitalShipObject ( short obj)

◆ IsOnlyShipGun()

short IsOnlyShipGun ( short ship,
short weapon )

◆ launch_object()

int launch_object ( short parent,
short child,
FixedVector direction,
short speed )

◆ match_rotation_goal()

unsigned int match_rotation_goal ( short * rotation,
short * goal,
short totalError,
short rate )

◆ new_object()

◆ onboard_explosion()

◆ pilot_hit()

◆ place_exhaust_on_ships()

◆ ProcessEnemyWaveCompletion()

◆ RandomBelow()

short RandomBelow ( short n)

Definition at line 12 of file eventmgr.c.

◆ RandomFixedAimComponent()

int RandomFixedAimComponent ( short radius,
short speed,
short maximum )

◆ RandomSign()

short RandomSign ( short v)

Definition at line 2257 of file ship.c.

References RandomBelowOrEqual(), and RandomSign().

Referenced by DrawTextAt(), RandomFixedAimComponent(), and RandomSign().

◆ real_velocity()

◆ remove_weapon()

◆ repair_internal_damage()

◆ replenish_shields()

◆ replenish_weapon_energy_bank()

◆ ReportComponentRepaired()

short ReportComponentRepaired ( short component,
short minimumDamage )

◆ reposition_fixed_child_objects()

◆ ResolveObjectDestruction()

◆ revise_shields()

void revise_shields ( short obj)

◆ rotate_object_to_goal()

◆ ScaleFixedVector()

void ScaleFixedVector ( FixedVector * vector,
int scale,
FixedVector * result )

Definition at line 237 of file geom.c.

◆ score_for_kill()

void score_for_kill ( short pilot,
short victim )

◆ send_appropriate_message()

◆ send_at_point()

int send_at_point ( short obj,
FixedVector * point,
short speed )

◆ set_objects_data()

void set_objects_data ( short obj,
short type,
short owner,
short matchResourceType )

Definition at line 347 of file ship.c.

References animate_shape(), ObjectTypeData::animation, ObjectTypeData::armorFront, ObjectTypeData::armorLeft, ObjectTypeData::armorRear, ObjectTypeData::armorRight, ObjectTypeData::collisionRadius, ObjectTypeData::field_18, g_1_asObjectCreationFrameTable, g_aasShipArmor, g_aasShipMaximumShield, g_aasShipShield, g_abProjectileCollisionBonus, g_acLastCollisionObject, g_acObjectAnimationDelay, g_acObjectOwner, g_acObjectType, g_acPilotHitPoints, g_acShipDamage, g_acShipIonDriveDamage, g_acShipLastAttacker, g_acShipTarget, g_aeObjectClass, g_anShipFuel, g_aObjectTypeData, g_apObjectExhaustShape, g_apObjectShape, g_aShipWeapons, g_asObjectAnimationIndex, g_asObjectCollisionRadius, g_asObjectDamage, g_asObjectFlip, g_asObjectScale, g_asObjectScreenAngle, g_asObjectType, g_asObjectViewFrame, g_asShipSide, g_asShipTurretFireEnabled, g_asShipWeaponEnergy, g_nObjectType62Index, g_nObjectType63Index, g_nSelectedGunType, g_nSelectedReleaseWeaponIndex, g_nSpaceFrame, g_pGenericMissileExhaustShape, g_pGenericMissileShape, HasShipCockpitGunDisplay(), init_ijk(), InitializeShipWeaponTypeIndices(), ObjectTypeData::lifetime, OBJECT_CLASS_DUST, OBJECT_CLASS_MISSILE, OBJECT_CLASS_PROJECTILE, OBJECT_CLASS_SHIP, OBJECT_DATA_ASTEROID1, OBJECT_DATA_ASTEROID2, OBJECT_DATA_ASTEROID3, OBJECT_DATA_ASTEROID4, OBJECT_DATA_ASTEROID5, OBJECT_DATA_ASTEROID6, OBJECT_DATA_CHAFF_POD, OBJECT_DATA_EXPLOSION_LARGE, OBJECT_DATA_EXPLOSION_MEDIUM, OBJECT_DATA_EXPLOSION_SMALL, OBJECT_DATA_GIRDER_CHUNK, OBJECT_DATA_METAL_SHEET, OBJECT_DATA_PIPE, OBJECT_DATA_ROCK_CHUNK, OBJECT_DATA_SHIP_WING, OBJECT_DATA_SPACE_DUST, ObjectTypeData::objectClass, recalc_max_velocity(), ObjectTypeData::scale, set_objects_data(), ObjectTypeData::shapeSet, ObjectTypeData::shieldAft, ObjectTypeData::shieldFore, SIDE_KILRATHI, ObjectTypeData::weaponLoadout, and ObjectTypeData::yawRate.

Referenced by animate_object(), ApplyCannedSceneObjectEventRecord(), Create_explosion_debris(), Create_ship_hit_debris(), DrawTextAt(), Explosion(), fire_flack(), house_keep_objects(), init_hazard(), initialize_object(), make_shard(), object_collision(), onboard_explosion(), place_exhaust_on_ships(), prepare_mission(), set_objects_data(), ShipExplosion(), SpawnMissionEjectionPod(), start_dust(), ToggleTargetCameraTracking(), unwarp(), update_star_field(), and warp().

◆ ShipExplosion()

◆ ShipHasCloakingDevice()

short ShipHasCloakingDevice ( short ship)

Definition at line 72 of file ship.c.

References g_aShipWeapons, and ShipHasCloakingDevice().

Referenced by DrawTextAt(), Set_up_ship_info(), and ShipHasCloakingDevice().

◆ ShipHasTorpedo()

short ShipHasTorpedo ( short ship)

Definition at line 122 of file ship.c.

References g_aShipWeapons, and ShipHasTorpedo().

Referenced by DrawTextAt(), request(), ShipHasTorpedo(), and target_valid().

◆ SortViableTargetsByDistance()

◆ SpawnFlakBurst()

◆ steady_object()

◆ your_afterburner()

◆ your_internal_damage()

Variable Documentation

◆ g_10_abExplosionEntityDoneBytes

signed char g_10_abExplosionEntityDoneBytes[ SPACE_OBJECT_COUNT]

Definition at line 3065 of file ship.c.

Referenced by explode().

◆ g_1_asObjectCreationFrameTable

short g_1_asObjectCreationFrameTable[SPACE_OBJECT_COUNT]

Definition at line 3069 of file ship.c.

Referenced by inflict_damage(), and set_objects_data().

◆ g_3_bAfterburnerSfxActive

int g_3_bAfterburnerSfxActive

Definition at line 3064 of file ship.c.

Referenced by ResetSoundState().

◆ g_6_nPendingAfterburnerSfxFrame

int g_6_nPendingAfterburnerSfxFrame

Definition at line 3060 of file ship.c.

Referenced by init_3Space_objects(), and your_afterburner().

◆ g_7_asShipBurstStageCountdown

short g_7_asShipBurstStageCountdown[10]

Definition at line 3063 of file ship.c.

Referenced by BeginShipDestructionSequence(), Explosion(), house_keep_objects(), and vid_transmit().

◆ g_aaeExplosionDebris

◆ g_aasPlayerDamageSystemTable

short g_aasPlayerDamageSystemTable[5][10]
Initial value:
= {
{ 0, 8, 6, 5, 0, 3, 5, 5, 7, 6 },
{ 0, 8, 6, 5, 4, 3, 4, 0, 4, 4 },
{ 1, 2, 5, 2, 7, 3, 4, 7, 5, 1 },
{ 1, 4, 1, 5, 2, 3, 4, 7, 2, 1 },
{ 4, 4, 4, 4, 0, 8, 6, 5, 4, 0 }
}

Definition at line 15 of file ship.c.

Referenced by your_internal_damage().

◆ g_acGunRefireDelay

signed char g_acGunRefireDelay[4] = {5, 9, 3, 4}

Definition at line 54 of file ship.c.

Referenced by fire_weapon(), and FireTargetCameraGuns().

◆ g_aeShipHitDebrisTypes

short g_aeShipHitDebrisTypes[4]
Initial value:

Definition at line 48 of file ship.c.

Referenced by Create_ship_hit_debris().

◆ g_asMissileProximityFuseValues

short g_asMissileProximityFuseValues[16]

Definition at line 3068 of file ship.c.

Referenced by explosion_shock_wave(), fire_turrets(), fire_weapon(), and house_keep_objects().

◆ g_asPlayerHitsCreditValues

short g_asPlayerHitsCreditValues[10]

◆ g_asWingmanDamageCredit

short g_asWingmanDamageCredit[10]

Definition at line 3061 of file ship.c.

Referenced by inflict_damage(), send_appropriate_message(), and Set_up_ship_info().

◆ g_bAiMissileFiringEnabled

short g_bAiMissileFiringEnabled = 1

Definition at line 9 of file ship.c.

Referenced by fire(), and perform_maneuver().

◆ g_bExplosionTraversalIdle

short g_bExplosionTraversalIdle = 1

Definition at line 53 of file ship.c.

Referenced by explode().

◆ g_bFriendlyFireWarningIssued

short g_bFriendlyFireWarningIssued = 0

Definition at line 10 of file ship.c.

Referenced by inflict_damage(), init_mission(), and RunCampaignGameLoop().

◆ g_nAdaptiveDifficulty

short g_nAdaptiveDifficulty

◆ g_nLastAdaptiveDifficultyChangeFrame

short g_nLastAdaptiveDifficultyChangeFrame = 0

Definition at line 11 of file ship.c.

Referenced by DecreaseAdaptiveDifficulty(), IncreaseAdaptiveDifficulty(), and init_mission().

◆ g_nLastFriendlyFireObjectFrame

short g_nLastFriendlyFireObjectFrame = 0x0ee4

Definition at line 14 of file ship.c.

Referenced by inflict_damage().

◆ g_nObjectType62Index

short g_nObjectType62Index = -1

◆ g_nObjectType63Index

short g_nObjectType63Index = -1