summaryrefslogtreecommitdiffhomepage
path: root/Stars45/QuantumDrive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Stars45/QuantumDrive.cpp')
-rw-r--r--Stars45/QuantumDrive.cpp292
1 files changed, 146 insertions, 146 deletions
diff --git a/Stars45/QuantumDrive.cpp b/Stars45/QuantumDrive.cpp
index 57e2c94..8e24ee2 100644
--- a/Stars45/QuantumDrive.cpp
+++ b/Stars45/QuantumDrive.cpp
@@ -1,15 +1,15 @@
/* Project Starshatter 5.0
- Destroyer Studios LLC
- Copyright © 1997-2007. All Rights Reserved.
+ Destroyer Studios LLC
+ Copyright © 1997-2007. All Rights Reserved.
- SUBSYSTEM: Stars.exe
- FILE: QuantumDrive.cpp
- AUTHOR: John DiCamillo
+ SUBSYSTEM: Stars.exe
+ FILE: QuantumDrive.cpp
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Quantum Drive class
+ OVERVIEW
+ ========
+ Quantum Drive class
*/
#include "MemDebug.h"
@@ -31,28 +31,28 @@ static int drive_value = 3;
// +----------------------------------------------------------------------+
QuantumDrive::QuantumDrive(SUBTYPE s, double cap, double rate)
- : System(DRIVE, s, "Quantum", drive_value, (float) cap, (float) cap, (float) rate),
- dst_rgn(0), active_state(ACTIVE_READY), warp_fov(1), jump_time(0), countdown(5)
+: System(DRIVE, s, "Quantum", drive_value, (float) cap, (float) cap, (float) rate),
+dst_rgn(0), active_state(ACTIVE_READY), warp_fov(1), jump_time(0), countdown(5)
{
- name = Game::GetText("sys.quantum");
- abrv = Game::GetText("sys.quantum.abrv");
+ name = Game::GetText("sys.quantum");
+ abrv = Game::GetText("sys.quantum.abrv");
- emcon_power[0] = 0;
- emcon_power[1] = 0;
- emcon_power[2] = 100;
+ emcon_power[0] = 0;
+ emcon_power[1] = 0;
+ emcon_power[2] = 100;
}
// +----------------------------------------------------------------------+
QuantumDrive::QuantumDrive(const QuantumDrive& d)
- : System(d),
- dst_rgn(0), active_state(ACTIVE_READY), warp_fov(1), jump_time(0),
- countdown(d.countdown)
+: System(d),
+dst_rgn(0), active_state(ACTIVE_READY), warp_fov(1), jump_time(0),
+countdown(d.countdown)
{
- Mount(d);
- SetAbbreviation(d.Abbreviation());
+ Mount(d);
+ SetAbbreviation(d.Abbreviation());
- energy = capacity;
+ energy = capacity;
}
// +--------------------------------------------------------------------+
@@ -65,8 +65,8 @@ QuantumDrive::~QuantumDrive()
void
QuantumDrive::SetDestination(SimRegion* rgn, const Point& loc)
{
- dst_rgn = rgn;
- dst_loc = loc;
+ dst_rgn = rgn;
+ dst_loc = loc;
}
// +--------------------------------------------------------------------+
@@ -74,75 +74,75 @@ QuantumDrive::SetDestination(SimRegion* rgn, const Point& loc)
bool
QuantumDrive::Engage(bool immediate)
{
- if (active_state == ACTIVE_READY && ship != 0 &&
- IsPowerOn() && Status() == NOMINAL && energy == capacity) {
+ if (active_state == ACTIVE_READY && ship != 0 &&
+ IsPowerOn() && Status() == NOMINAL && energy == capacity) {
- active_state = ACTIVE_COUNTDOWN;
- if (immediate) {
- jump_time = 1;
- return true;
- }
+ active_state = ACTIVE_COUNTDOWN;
+ if (immediate) {
+ jump_time = 1;
+ return true;
+ }
- jump_time = countdown;
+ jump_time = countdown;
- SimRegion* rgn = ship->GetRegion();
+ SimRegion* rgn = ship->GetRegion();
- ListIter<Ship> s_iter = rgn->Ships();
- while (++s_iter) {
- Ship* s = s_iter.value();
+ ListIter<Ship> s_iter = rgn->Ships();
+ while (++s_iter) {
+ Ship* s = s_iter.value();
- if (s != ship) {
- double dist = Point(s->Location() - ship->Location()).length();
+ if (s != ship) {
+ double dist = Point(s->Location() - ship->Location()).length();
- if (dist < 25e3)
- jump_time += 5;
+ if (dist < 25e3)
+ jump_time += 5;
- else if (dist < 50e3)
- jump_time += 2;
+ else if (dist < 50e3)
+ jump_time += 2;
- else if (dist < 100e3)
- jump_time += 1;
+ else if (dist < 100e3)
+ jump_time += 1;
- else if (dist < 200e3)
- jump_time += 0.5;
- }
- }
+ else if (dist < 200e3)
+ jump_time += 0.5;
+ }
+ }
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
void
QuantumDrive::PowerOff()
{
- System::PowerOff();
- AbortJump();
+ System::PowerOff();
+ AbortJump();
}
void
QuantumDrive::AbortJump()
{
- active_state = ACTIVE_READY;
- jump_time = 0;
- energy = 0;
- warp_fov = 1;
+ active_state = ACTIVE_READY;
+ jump_time = 0;
+ energy = 0;
+ warp_fov = 1;
- ship->SetWarp(warp_fov);
+ ship->SetWarp(warp_fov);
- SimRegion* r = ship->GetRegion();
- ListIter<Ship> neighbor = r->Ships();
+ SimRegion* r = ship->GetRegion();
+ ListIter<Ship> neighbor = r->Ships();
- while (++neighbor) {
- if (neighbor->IsDropship()) {
- Ship* s = neighbor.value();
- Point delta = s->Location() - ship->Location();
+ while (++neighbor) {
+ if (neighbor->IsDropship()) {
+ Ship* s = neighbor.value();
+ Point delta = s->Location() - ship->Location();
- if (delta.length() < 5e3)
- s->SetWarp(warp_fov);
- }
- }
+ if (delta.length() < 5e3)
+ s->SetWarp(warp_fov);
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -150,66 +150,66 @@ QuantumDrive::AbortJump()
void
QuantumDrive::ExecFrame(double seconds)
{
- System::ExecFrame(seconds);
-
- if (active_state == ACTIVE_READY)
- return;
-
- if (ship) {
- bool warping = false;
-
- if (active_state == ACTIVE_COUNTDOWN) {
- if (jump_time > 0) {
- jump_time -= seconds;
- }
-
- else {
- jump_time = 0;
- active_state = ACTIVE_PREWARP;
- }
- }
-
- else if (active_state == ACTIVE_PREWARP) {
- if (warp_fov < 5000) {
- warp_fov *= 1.5;
- }
- else {
- Jump();
- energy = 0.0f;
- }
-
- warping = true;
- }
-
- else if (active_state == ACTIVE_POSTWARP) {
- if (warp_fov > 1) {
- warp_fov *= 0.75;
- }
- else {
- warp_fov = 1;
- active_state = ACTIVE_READY;
- }
-
- warping = true;
- }
-
- if (warping) {
- ship->SetWarp(warp_fov);
-
- SimRegion* r = ship->GetRegion();
- ListIter<Ship> neighbor = r->Ships();
-
- while (++neighbor) {
- if (neighbor->IsDropship()) {
- Ship* s = neighbor.value();
- Point delta = s->Location() - ship->Location();
-
- if (delta.length() < 5e3)
- s->SetWarp(warp_fov);
- }
- }
- }
- }
+ System::ExecFrame(seconds);
+
+ if (active_state == ACTIVE_READY)
+ return;
+
+ if (ship) {
+ bool warping = false;
+
+ if (active_state == ACTIVE_COUNTDOWN) {
+ if (jump_time > 0) {
+ jump_time -= seconds;
+ }
+
+ else {
+ jump_time = 0;
+ active_state = ACTIVE_PREWARP;
+ }
+ }
+
+ else if (active_state == ACTIVE_PREWARP) {
+ if (warp_fov < 5000) {
+ warp_fov *= 1.5;
+ }
+ else {
+ Jump();
+ energy = 0.0f;
+ }
+
+ warping = true;
+ }
+
+ else if (active_state == ACTIVE_POSTWARP) {
+ if (warp_fov > 1) {
+ warp_fov *= 0.75;
+ }
+ else {
+ warp_fov = 1;
+ active_state = ACTIVE_READY;
+ }
+
+ warping = true;
+ }
+
+ if (warping) {
+ ship->SetWarp(warp_fov);
+
+ SimRegion* r = ship->GetRegion();
+ ListIter<Ship> neighbor = r->Ships();
+
+ while (++neighbor) {
+ if (neighbor->IsDropship()) {
+ Ship* s = neighbor.value();
+ Point delta = s->Location() - ship->Location();
+
+ if (delta.length() < 5e3)
+ s->SetWarp(warp_fov);
+ }
+ }
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -217,30 +217,30 @@ QuantumDrive::ExecFrame(double seconds)
void
QuantumDrive::Jump()
{
- Sim* sim = Sim::GetSim();
+ Sim* sim = Sim::GetSim();
- if (ship && sim) {
- double dist = 150e3 + Random(0, 60e3);
- Point esc_vec = dst_rgn->GetOrbitalRegion()->Location() -
- dst_rgn->GetOrbitalRegion()->Primary()->Location();
+ if (ship && sim) {
+ double dist = 150e3 + Random(0, 60e3);
+ Point esc_vec = dst_rgn->GetOrbitalRegion()->Location() -
+ dst_rgn->GetOrbitalRegion()->Primary()->Location();
- esc_vec.Normalize();
- esc_vec *= dist;
- esc_vec += RandomDirection() * Random(15e3, 22e3);
+ esc_vec.Normalize();
+ esc_vec *= dist;
+ esc_vec += RandomDirection() * Random(15e3, 22e3);
- if (subtype == HYPER)
- sim->CreateExplosion(ship->Location(), Point(0,0,0), Explosion::HYPER_FLASH, 1, 1, ship->GetRegion());
- else
- sim->CreateExplosion(ship->Location(), Point(0,0,0), Explosion::QUANTUM_FLASH, 1, 0, ship->GetRegion());
+ if (subtype == HYPER)
+ sim->CreateExplosion(ship->Location(), Point(0,0,0), Explosion::HYPER_FLASH, 1, 1, ship->GetRegion());
+ else
+ sim->CreateExplosion(ship->Location(), Point(0,0,0), Explosion::QUANTUM_FLASH, 1, 0, ship->GetRegion());
- sim->RequestHyperJump(ship, dst_rgn, esc_vec);
+ sim->RequestHyperJump(ship, dst_rgn, esc_vec);
- ShipStats* stats = ShipStats::Find(ship->Name());
- stats->AddEvent(SimEvent::QUANTUM_JUMP, dst_rgn->Name());
- }
+ ShipStats* stats = ShipStats::Find(ship->Name());
+ stats->AddEvent(SimEvent::QUANTUM_JUMP, dst_rgn->Name());
+ }
- dst_rgn = 0;
- dst_loc = Point();
+ dst_rgn = 0;
+ dst_loc = Point();
- active_state = ACTIVE_POSTWARP;
+ active_state = ACTIVE_POSTWARP;
}