RepairRearmAction.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. ** Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: RepairRearmAction.cpp
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Implementation of the training library "RepairRearmAction" interface.
  10. **
  11. ** History:
  12. */
  13. #include "pch.h"
  14. #include "RepairRearmAction.h"
  15. #include "TrainingMission.h"
  16. namespace Training
  17. {
  18. //------------------------------------------------------------------------------
  19. // global variabes
  20. //------------------------------------------------------------------------------
  21. extern TrainingMission* g_pMission;
  22. //------------------------------------------------------------------------------
  23. // class methods
  24. //------------------------------------------------------------------------------
  25. /* void */ RepairRearmAction::~RepairRearmAction (void)
  26. {
  27. }
  28. //------------------------------------------------------------------------------
  29. void RepairRearmAction::Execute (void)
  30. {
  31. IshipIGC* pShip = trekClient.GetShip ();
  32. // heal the ship entirely
  33. IshieldIGC* pShield = static_cast<IshieldIGC*> (pShip->GetMountedPart (ET_Shield, 0));
  34. if (pShield)
  35. pShield->SetFraction (1.0f);
  36. pShip->SetFraction (1.0f);
  37. // reload the ammunition, energy, and fuel
  38. pShip->SetEnergy (pShip->GetHullType ()->GetMaxEnergy ());
  39. pShip->SetAmmo (pShip->GetHullType ()->GetMaxAmmo ());
  40. pShip->SetFuel (pShip->GetHullType ()->GetMaxFuel ());
  41. // fill the first empty cargo slot with missiles
  42. for (int i = -1; i > -c_maxCargo; i--)
  43. if (pShip->GetMountedPart (NA, i) == 0)
  44. {
  45. g_pMission->AddPartToShip (150, i, 0x7fff);
  46. break;
  47. }
  48. // fill the second empty cargo slot with ammo
  49. for (; i > -c_maxCargo; i--)
  50. if (pShip->GetMountedPart (NA, i) == 0)
  51. g_pMission->AddPartToShip (24, i, 0x7fff);
  52. // fill all subsequent slots with missiles
  53. for (; i > -c_maxCargo; i--)
  54. if (pShip->GetMountedPart (NA, i) == 0)
  55. g_pMission->AddPartToShip (150, i, 0x7fff);
  56. }
  57. //------------------------------------------------------------------------------
  58. }