From 69209c38968c6f4066a772e0a51a2928749217de Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Fri, 9 Dec 2011 19:00:23 +0000 Subject: Re-indenting the code to use standard tabs. Yes, I know this is pretty pointless, but who cares? --- Stars45/GroundAI.cpp | 202 +++++++++++++++++++++++++-------------------------- 1 file changed, 101 insertions(+), 101 deletions(-) (limited to 'Stars45/GroundAI.cpp') diff --git a/Stars45/GroundAI.cpp b/Stars45/GroundAI.cpp index c7b7c6b..3cb2f28 100644 --- a/Stars45/GroundAI.cpp +++ b/Stars45/GroundAI.cpp @@ -1,15 +1,15 @@ /* Project Starshatter 4.5 - Destroyer Studios LLC - Copyright © 1997-2004. All Rights Reserved. + Destroyer Studios LLC + Copyright © 1997-2004. All Rights Reserved. - SUBSYSTEM: Stars.exe - FILE: GroundAI.cpp - AUTHOR: John DiCamillo + SUBSYSTEM: Stars.exe + FILE: GroundAI.cpp + AUTHOR: John DiCamillo - OVERVIEW - ======== - Low-Level Artificial Intelligence class for Ground Units + OVERVIEW + ======== + Low-Level Artificial Intelligence class for Ground Units */ #include "MemDebug.h" @@ -32,33 +32,33 @@ // +----------------------------------------------------------------------+ GroundAI::GroundAI(SimObject* s) - : ship((Ship*) s), target(0), subtarget(0), exec_time(0), carrier_ai(0) +: ship((Ship*) s), target(0), subtarget(0), exec_time(0), carrier_ai(0) { - Sim* sim = Sim::GetSim(); - Ship* pship = sim->GetPlayerShip(); - int player_team = 1; - int ai_level = 1; - - if (pship) - player_team = pship->GetIFF(); - - Player* player = Player::GetCurrentPlayer(); - if (player) { - if (ship && ship->GetIFF() && ship->GetIFF() != player_team) { - ai_level = player->AILevel(); - } - else if (player->AILevel() == 0) { - ai_level = 1; - } - } - - // evil alien ships are *always* smart: - if (ship && ship->GetIFF() > 1 && ship->Design()->auto_roll > 1) { - ai_level = 2; - } - - if (ship && ship->GetHangar() && ship->GetCommandAILevel() > 0) - carrier_ai = new(__FILE__,__LINE__) CarrierAI(ship, ai_level); + Sim* sim = Sim::GetSim(); + Ship* pship = sim->GetPlayerShip(); + int player_team = 1; + int ai_level = 1; + + if (pship) + player_team = pship->GetIFF(); + + Player* player = Player::GetCurrentPlayer(); + if (player) { + if (ship && ship->GetIFF() && ship->GetIFF() != player_team) { + ai_level = player->AILevel(); + } + else if (player->AILevel() == 0) { + ai_level = 1; + } + } + + // evil alien ships are *always* smart: + if (ship && ship->GetIFF() > 1 && ship->Design()->auto_roll > 1) { + ai_level = 2; + } + + if (ship && ship->GetHangar() && ship->GetCommandAILevel() > 0) + carrier_ai = new(__FILE__,__LINE__) CarrierAI(ship, ai_level); } @@ -66,7 +66,7 @@ GroundAI::GroundAI(SimObject* s) GroundAI::~GroundAI() { - delete carrier_ai; + delete carrier_ai; } // +--------------------------------------------------------------------+ @@ -74,14 +74,14 @@ GroundAI::~GroundAI() void GroundAI::SetTarget(SimObject* targ, System* sub) { - if (target != targ) { - target = targ; - - if (target) - Observe(target); - } - - subtarget = sub; + if (target != targ) { + target = targ; + + if (target) + Observe(target); + } + + subtarget = sub; } // +--------------------------------------------------------------------+ @@ -89,20 +89,20 @@ GroundAI::SetTarget(SimObject* targ, System* sub) bool GroundAI::Update(SimObject* obj) { - if (obj == target) { - target = 0; - subtarget = 0; - } - - return SimObserver::Update(obj); + if (obj == target) { + target = 0; + subtarget = 0; + } + + return SimObserver::Update(obj); } const char* GroundAI::GetObserverName() const { - static char name[64]; - sprintf(name, "GroundAI(%s)", ship->Name()); - return name; + static char name[64]; + sprintf(name, "GroundAI(%s)", ship->Name()); + return name; } // +--------------------------------------------------------------------+ @@ -110,41 +110,41 @@ GroundAI::GetObserverName() const void GroundAI::SelectTarget() { - SimObject* potential_target = 0; + SimObject* potential_target = 0; - // pick the closest combatant ship with a different IFF code: - double target_dist = 1.0e15; + // pick the closest combatant ship with a different IFF code: + double target_dist = 1.0e15; - Ship* current_ship_target = 0; + Ship* current_ship_target = 0; - ListIter c_iter = ship->ContactList(); - while (++c_iter) { - Contact* contact = c_iter.value(); - int c_iff = contact->GetIFF(ship); - Ship* c_ship = contact->GetShip(); - Shot* c_shot = contact->GetShot(); - bool rogue = false; + ListIter c_iter = ship->ContactList(); + while (++c_iter) { + Contact* contact = c_iter.value(); + int c_iff = contact->GetIFF(ship); + Ship* c_ship = contact->GetShip(); + Shot* c_shot = contact->GetShot(); + bool rogue = false; - if (c_ship) - rogue = c_ship->IsRogue(); + if (c_ship) + rogue = c_ship->IsRogue(); - if (rogue || c_iff > 0 && c_iff != ship->GetIFF() && c_iff < 1000) { - if (c_ship && !c_ship->InTransition()) { - // found an enemy, check distance: - double dist = (ship->Location() - c_ship->Location()).length(); + if (rogue || c_iff > 0 && c_iff != ship->GetIFF() && c_iff < 1000) { + if (c_ship && !c_ship->InTransition()) { + // found an enemy, check distance: + double dist = (ship->Location() - c_ship->Location()).length(); - if (!current_ship_target || (c_ship->Class() <= current_ship_target->Class() && - dist < target_dist)) { - current_ship_target = c_ship; - target_dist = dist; - } - } - } + if (!current_ship_target || (c_ship->Class() <= current_ship_target->Class() && + dist < target_dist)) { + current_ship_target = c_ship; + target_dist = dist; + } + } + } - potential_target = current_ship_target; - } + potential_target = current_ship_target; + } - SetTarget(potential_target); + SetTarget(potential_target); } // +--------------------------------------------------------------------+ @@ -152,7 +152,7 @@ GroundAI::SelectTarget() int GroundAI::Type() const { - return SteerAI::GROUND; + return SteerAI::GROUND; } // +--------------------------------------------------------------------+ @@ -160,32 +160,32 @@ GroundAI::Type() const void GroundAI::ExecFrame(double secs) { - const int exec_period = 1000; + const int exec_period = 1000; - if ((int) Game::GameTime() - exec_time > exec_period) { - exec_time = (int) Game::GameTime(); - SelectTarget(); - } + if ((int) Game::GameTime() - exec_time > exec_period) { + exec_time = (int) Game::GameTime(); + SelectTarget(); + } - if (ship) { - Shield* shield = ship->GetShield(); + if (ship) { + Shield* shield = ship->GetShield(); - if (shield) - shield->SetPowerLevel(100); + if (shield) + shield->SetPowerLevel(100); - ListIter iter = ship->Weapons(); - while (++iter) { - WeaponGroup* group = (WeaponGroup*) iter.value(); + ListIter iter = ship->Weapons(); + while (++iter) { + WeaponGroup* group = (WeaponGroup*) iter.value(); - if (group->NumWeapons() > 1 && group->CanTarget(Ship::DROPSHIPS)) - group->SetFiringOrders(Weapon::POINT_DEFENSE); - else - group->SetFiringOrders(Weapon::AUTO); + if (group->NumWeapons() > 1 && group->CanTarget(Ship::DROPSHIPS)) + group->SetFiringOrders(Weapon::POINT_DEFENSE); + else + group->SetFiringOrders(Weapon::AUTO); - group->SetTarget((Ship*) target, 0); - } + group->SetTarget((Ship*) target, 0); + } - if (carrier_ai) - carrier_ai->ExecFrame(secs); - } + if (carrier_ai) + carrier_ai->ExecFrame(secs); + } } -- cgit v1.1