home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58b_TRIBES.iso / Tribes / base / scripts.vol / station.cs < prev    next >
Encoding:
Text File  |  1998-12-16  |  27.4 KB  |  913 lines

  1. //----------------------------------------------------------------------------
  2.  
  3. //----------------------------------------------------------------------------
  4.  
  5. //----------------------------------------------------------------------------
  6.  
  7. // List of all items available to buy from inventory station
  8. $InvList[Blaster] = 1;
  9. $InvList[Chaingun] = 1;
  10. $InvList[Disclauncher] = 1;
  11. $InvList[GrenadeLauncher] = 1;
  12. $InvList[Mortar] = 1;
  13. $InvList[PlasmaGun] = 1;
  14. $InvList[LaserRifle] = 1;
  15. $InvList[EnergyRifle] = 1;
  16. $InvList[TargetingLaser] = 1;
  17. $InvList[MineAmmo] = 1;
  18. $InvList[Grenade] = 1;
  19. $InvList[Beacon] = 1;
  20.  
  21. $InvList[BulletAmmo] = 1;
  22. $InvList[PlasmaAmmo] = 1;
  23. $InvList[DiscAmmo] = 1;
  24. $InvList[GrenadeAmmo] = 1;
  25. $InvList[MortarAmmo] = 1;
  26.   
  27. $InvList[EnergyPack] = 1;
  28. $InvList[RepairPack] = 1;
  29. $InvList[ShieldPack] = 1;
  30. $InvList[SensorJammerPack] = 1;
  31. $InvList[MotionSensorPack] = 1;
  32. $InvList[PulseSensorPack] = 1;
  33. $InvList[DeployableSensorJammerPack] = 1;
  34. $InvList[CameraPack] = 1;
  35. $InvList[TurretPack] = 1;
  36. $InvList[AmmoPack] = 1;
  37. $InvList[RepairKit] = 1;
  38. $InvList[DeployableInvPack] = 1;
  39. $InvList[DeployableAmmoPack] = 1;
  40.  
  41. //----------------------------------------------------------------------------
  42.  
  43. // List of all items available to buy from Remote Station
  44. $RemoteInvList[Blaster] = 1;
  45. $RemoteInvList[Chaingun] = 1;
  46. $RemoteInvList[Disclauncher] = 1;
  47. $RemoteInvList[GrenadeLauncher] = 1;
  48. $RemoteInvList[Mortar] = 1;
  49. $RemoteInvList[PlasmaGun] = 1;
  50. $RemoteInvList[LaserRifle] = 1;
  51. $RemoteInvList[EnergyRifle] = 1;
  52. $RemoteInvList[TargetingLaser] = 1;
  53. $RemoteInvList[MineAmmo] = 1;
  54. $RemoteInvList[Grenade] = 1;
  55. $RemoteInvList[Beacon] = 1;
  56.  
  57. $RemoteInvList[BulletAmmo] = 1;
  58. $RemoteInvList[PlasmaAmmo] = 1;
  59. $RemoteInvList[DiscAmmo] = 1;
  60. $RemoteInvList[GrenadeAmmo] = 1;
  61. $RemoteInvList[MortarAmmo] = 1;
  62.   
  63. $RemoteInvList[EnergyPack] = 1;
  64. $RemoteInvList[RepairPack] = 1;
  65. $RemoteInvList[ShieldPack] = 1;
  66. $RemoteInvList[SensorJammerPack] = 1;
  67. $RemoteInvList[MotionSensorPack] = 1;
  68. $RemoteInvList[PulseSensorPack] = 1;
  69. $RemoteInvList[DeployableSensorJammerPack] = 1;
  70. $RemoteInvList[CameraPack] = 1;
  71. $RemoteInvList[TurretPack] = 1;
  72. $RemoteInvList[AmmoPack] = 1;
  73. $RemoteInvList[RepairKit] = 1;
  74.  
  75. //----------------------------------------------------------------------------
  76.  
  77. // List of all items available to buy from Vehicle station
  78. $VehicleInvList[ScoutVehicle] = 1;
  79. $VehicleInvList[LAPCVehicle] = 1;
  80. $VehicleInvList[HAPCVehicle] = 1;
  81.  
  82. //----------------------------------------------------------------------------
  83.  
  84. $DataBlockName[ScoutVehicle] = Scout;
  85. $DataBlockName[LAPCVehicle] = LAPC;
  86. $DataBlockName[HAPCVehicle] = HAPC;
  87.  
  88. $VehicleToItem[Scout] = ScoutVehicle;
  89. $VehicleToItem[LAPC] = LAPCVehicle;
  90. $VehicleToItem[HAPC] = HAPCVehicle;
  91.  
  92.  
  93. //----------------------------------------------------------------------------
  94. // Default station animations
  95.  
  96. function Station::onActivate(%this)
  97. {
  98.     //echo("Activate " @ %this);
  99.     %obj = Station::getTarget(%this);
  100.     if (%obj != -1) {
  101.         GameBase::playSequence(%this,1,"activate");
  102.         GameBase::setSequenceDirection(%this,1,1);
  103.     }
  104.     else 
  105.         GameBase::setActive(%this,false);
  106. }
  107.  
  108. function Station::onDeactivate(%this)
  109. {
  110.     //echo("Dectivate " @ %this);
  111.     GameBase::stopSequence(%this,2);
  112.     GameBase::setSequenceDirection(%this,1,0);
  113. }
  114.  
  115. function Station::onEndSequence(%this,%thread)
  116. {
  117.     //echo("End sequence " @ %this);
  118.      if (%thread == 1 && GameBase::isActive(%this)) {
  119.         GameBase::playSequence(%this,2,"use");
  120.         return true;
  121.     }
  122.     %client = %this.target;
  123.     if(%client == "") {
  124.         %player = Station::getTarget(%this);
  125.         %client = Player::getClient(%player);
  126.     }
  127.     if(Client::getGuiMode(%client) != 1)
  128.         Client::setGuiMode(%client,1);
  129.     
  130.     %team = Client::getTeam(%client);
  131.     if($TeamEnergy[%team] != "Infinite") {
  132.         if(%this.clTeamEnergy != %client.TeamEnergy) {
  133.             if(%client.teamEnergy < 0)
  134.                 Client::sendMessage(%client,0,"Your total mission purchases have come to " @ (%client.teamEnergy * -1) @ ".");
  135.             else
  136.                 Client::sendMessage(%client,0,"You have increased the Team Energy by " @ %client.teamEnergy @ ".");
  137.         }
  138.         if((%client.teamEnergy -%client.EnergyWarning < $TeammateSpending) && ($TeammateSpending != 0) && !$TeamEnergyCheat) {
  139.             TeamMessages(0, %team, "Teammate " @ Client::getName(%client) @ " has spent " @ (%client.teamEnergy *-1) @ " of the TeamEnergy"); 
  140.             %client.EnergyWarning = %client.teamEnergy;
  141.         }
  142.         if($TeamEnergy[%team] < $WarnEnergyLow)  
  143.             TeamMessages(0, %team, "TeamEnergy Low: " @ $TeamEnergy[%team]); 
  144.     }
  145.     (Client::getOwnedObject(%this.target)).Station = "";
  146.     %this.target = "";
  147.     if(GameBase::getDataName(%this) == VehicleStation && %this.vehiclePad.busy < getSimTime())
  148.         VehiclePad::checkSeq(%this.vehiclePad, %this);
  149.     %this.clTeamEnergy = "";
  150.     return false;
  151. }
  152.  
  153. function Station::onPower(%this,%power,%generator)
  154. {
  155.     if (%power) {
  156.         GameBase::playSequence(%this,0,"power");
  157.         GameBase::playSequence(%this,1);
  158.     }
  159.     else {
  160.         GameBase::stopSequence(%this,0);
  161.         GameBase::pauseSequence(%this,1);
  162.         GameBase::pauseSequence(%this,2);
  163.         Station::checkTarget(%this);
  164.     }
  165. }
  166.  
  167. function Station::onEnabled(%this)
  168. {
  169.     if (GameBase::isPowered(%this)) {        
  170.         GameBase::playSequence(%this,0,"power");
  171.         GameBase::playSequence(%this,1);
  172.     }
  173. }
  174.  
  175. function Station::checkTarget(%this)
  176. {
  177.     if(%this.target) {
  178.         Client::setGuiMode(%this.target,1);
  179.         GameBase::setActive(%this,false);
  180.     }
  181. }
  182.  
  183. function Station::onDisabled(%this)
  184. {
  185.     GameBase::stopSequence(%this,0);
  186.     GameBase::setSequenceDirection(%this,1,0);
  187.     GameBase::pauseSequence(%this,1);
  188.     GameBase::stopSequence(%this,2);
  189.     Station::checkTarget(%this);
  190. }
  191.  
  192. function Station::onDestroyed(%this)
  193. {
  194.     StaticShape::objectiveDestroyed(%this);
  195.     GameBase::stopSequence(%this,0);
  196.     GameBase::stopSequence(%this,1);
  197.     GameBase::stopSequence(%this,2);
  198.     Station::checkTarget(%this);
  199.     calcRadiusDamage(%this, $DebrisDamageType, 2.5, 0.05, 25, 13, 2, 0.40, 
  200.         0.1, 250, 100); 
  201. }
  202.  
  203. function Station::getTarget(%this)
  204. {
  205.     if(GameBase::getLOSInfo(%this,1.5,"0 0 3.14")) {
  206.           // GetLOSInfo sets the following globals:
  207.           //     los::position
  208.           //     los::normal
  209.           //     los::object
  210.           %obj = getObjectType($los::object);
  211.         dbecho(3, "STATION: LOS got " @ %obj);
  212.           if (%obj == "Player") {
  213.          if( Player::isAiControlled( $los::object ) != "True" ) {
  214.                return $los::object;
  215.          }
  216.         }
  217.     }
  218.     dbecho(3, "STATION: LOS Got None");
  219.     return -1;
  220. }    
  221.  
  222.  
  223. function Station::onCollision(%this, %object)
  224. {
  225.     dbecho(3, "STATION: Collision (" @ %this @ "," @ %object @ ")");
  226.     %obj = getObjectType(%object);
  227.     if (%obj == "Player") {
  228.            %client = Player::getClient(%object);
  229.          if(GameBase::getTeam(%object) == GameBase::getTeam(%this) || GameBase::getTeam(%this) == -1) {
  230.             if (GameBase::getDamageState(%this) == "Enabled") {
  231.                 if (GameBase::isPowered(%this)) 
  232.                     GameBase::setActive(%this,true);
  233.                 else 
  234.                     Client::sendMessage(%client,0,"Unit is not powered");
  235.             }
  236.             else 
  237.                 Client::sendMessage(%client,0,"Unit is disabled");
  238.         }
  239.         else if(Station::getTarget(%this) == %object)
  240.       {
  241.             %curTime = getSimTime();
  242.             if(%curTime - %object.stationDeniedStamp > 3.5 && GameBase::getDamageState(%this) == "Enabled") {
  243.                 %object.stationDeniedStamp = %curTime;
  244.                 Client::sendMessage(%client,0,"--ACCESS DENIED-- Wrong Team ~waccess_denied.wav");
  245.             }
  246.         }
  247.     }
  248. }
  249.  
  250.  
  251. //----------------------------------------------------------------------------
  252. // Deployable stations
  253.  
  254. function DeployableStation::onActivate(%this)
  255. {
  256.     //echo("Activate " @ %this);
  257.     %obj = Station::getTarget(%this);
  258.     if (%obj != -1) {
  259.         GameBase::playSequence(%this,1,"activate");
  260.         GameBase::setSequenceDirection(%this,1,1);
  261.     }
  262.     else 
  263.         GameBase::setActive(%this,false);
  264. }
  265.  
  266.  
  267. function DeployableStation::onEndSequence(%this,%thread)
  268. {
  269.    if(!%thread) {
  270.         %this.deployed = 1;
  271.         GameBase::playSequence(%this,2,"power");
  272.     }
  273. }
  274.  
  275. function DeployableStation::deploy(%this)
  276. {
  277.     GameBase::playSequence(%this,0,"deploy");
  278. }
  279.  
  280. function DeployableStation::onDeactivate(%this)
  281. {
  282.     //echo("Dectivate " @ %this);
  283.     GameBase::stopSequence(%this,1);
  284. }
  285.  
  286. function DeployableStation::onEnabled(%this)
  287. {
  288.     GameBase::playSequence(%this,2,"power");
  289. }
  290.  
  291. function DeployableStation::onDisabled(%this)
  292. {
  293.     GameBase::stopSequence(%this,2);
  294.     GameBase::stopSequence(%this,1);
  295.     Station::checkTarget(%this);
  296. }
  297.  
  298. function DeployableStation::onDestroyed(%this)
  299. {
  300.     DeployableStation::onDisabled(%this);
  301.     %stationName = GameBase::getDataName(%this);
  302.  
  303.     if(%stationName == DeployableInvStation) 
  304.         $TeamItemCount[GameBase::getTeam(%this) @ "DeployableInvPack"]--;
  305.     else if( %stationName == DeployableAmmoStation) 
  306.           $TeamItemCount[GameBase::getTeam(%this) @ "DeployableAmmoPack"]--;
  307.     calcRadiusDamage(%this, $DebrisDamageType, 2.5, 0.05, 25, 13, 2, 0.30, 
  308.         0.1, 200, 100); 
  309. }
  310.  
  311. function DeployableStation::onCollision(%this, %object)
  312. {
  313.     //echo("Collision (" @ %this @ "," @ %object @ ")");
  314.     %obj = getObjectType(%object);
  315.     if (%obj == "Player") {
  316.            %client = Player::getClient(%object);
  317.         if(GameBase::getTeam(%object) == GameBase::getTeam(%this) || GameBase::getTeam(%this) == -1) {
  318.             if (GameBase::getDamageState(%this) == "Enabled") 
  319.                 GameBase::setActive(%this,true);
  320.             else 
  321.                 Client::sendMessage(%client,0,"Unit is disabled");
  322.         }
  323.       else if(Station::getTarget(%this) == %object) {
  324.             %curTime = getSimTime();
  325.             if(%curTime - %object.stationDeniedStamp > 3.5 && GameBase::getDamageState(%this) == "Enabled") {
  326.                 %object.stationDeniedStamp = %curTime;
  327.                 Client::sendMessage(%client,0,"--ACCESS DENIED-- Wrong Team ~waccess_denied.wav");
  328.             }
  329.         }
  330.     }
  331. }
  332.  
  333. //----------------------------------------------------------------------------
  334.  
  335. //----------------------------------------------------------------------------
  336.  
  337. StaticShapeData AmmoStation
  338. {
  339.    description = "Ammo Supply Unit";
  340.     shapeFile = "ammounit";
  341.     className = "Station";
  342.     visibleToSensor = true;
  343.     sequenceSound[0] = { "activate", SoundActivateAmmoStation };
  344.     sequenceSound[1] = { "power", SoundAmmoStationPower };
  345.     sequenceSound[2] = { "use", SoundUseAmmoStation };
  346.     maxDamage = 1.0;
  347.     debrisId = flashDebrisLarge;
  348.     mapFilter = 4;
  349.     mapIcon = "M_station";
  350.     damageSkinData = "objectDamageSkins";
  351.     shadowDetailMask = 16;
  352.    explosionId = flashExpLarge;
  353. };
  354.  
  355. function AmmoStation::onEndSequence(%this,%thread)
  356. {
  357.     //echo("End Seq ",%thread);
  358.     if(%this.clTeamEnergy == "")
  359.         %this.clTeamEnergy = (Player::getClient(Station::getTarget(%this))).TeamEnergy;
  360.     if (Station::onEndSequence(%this,%thread)) 
  361.         AmmoStation::onResupply(%this);
  362. }                                    
  363.                                             
  364. function AmmoStation::onResupply(%this)
  365. {
  366.     if (GameBase::isActive(%this)) {
  367.         %player = Station::getTarget(%this);
  368.         if (%player != -1) {
  369.             // Hardcoded here for the ammo types
  370.             %cnt = 0;
  371.             %cnt = %cnt + AmmoStation::resupply(%player,ChainGun,BulletAmmo,20);
  372.             %cnt = %cnt + AmmoStation::resupply(%player,PlasmaGun,PlasmaAmmo,5);
  373.             %cnt = %cnt + AmmoStation::resupply(%player,GrenadeLauncher,GrenadeAmmo,2);
  374.             %cnt = %cnt + AmmoStation::resupply(%player,DiscLauncher,DiscAmmo,2);
  375.             %cnt = %cnt + AmmoStation::resupply(%player,Mortar,MortarAmmo,2);
  376.             if (%cnt != 0) {
  377.                 schedule("AmmoStation::onResupply(" @ %this @ ");",0.5,%this);
  378.                 return;
  379.             }
  380.             %client = Player::getClient(%player);
  381.             Client::sendMessage(%client,0,"Resupply Complete");
  382.             Client::setInventoryText(%client, "<f1><jc>TEAM ENERGY: " @ $TeamEnergy[Client::getTeam(%client)]);
  383.         }
  384.         GameBase::setActive(%this,false);
  385.     }
  386. }
  387.                                                      
  388. function AmmoStation::resupply(%player,%weapon,%item,%delta)
  389. {
  390.     %delta =checkResources(%player,%item,%delta,1);        
  391.     if(%item == RepairPatch) {
  392.         if(%delta > 0) {                        
  393.             teamEnergyBuySell(%player,%item.price * %delta * -1);
  394.             GameBase::repairDamage(%player,0.06);
  395.              return %delta;
  396.         }
  397.     }
  398.     else if (Player::getItemCount(%player,%weapon)) {
  399.         if(%delta > 0) {
  400.             teamEnergyBuySell(%player,%item.price * %delta * -1);
  401.             Player::incItemCount(%player,%item,%delta);
  402.              return %delta;
  403.         }
  404.     }
  405.     return 0;
  406. }
  407.  
  408. //----------------------------------------------------------------------------
  409. StaticShapeData DeployableAmmoStation
  410. {
  411.    description = "Remote Ammo Unit";
  412.     shapeFile = "ammounit_remote";
  413.     className = "DeployableStation";
  414.     maxDamage = 0.25;
  415.     sequenceSound[0] = { "deploy", SoundActivateMotionSensor };
  416.     sequenceSound[1] = { "use", SoundUseAmmoStation };
  417.     sequenceSound[2] = { "power", SoundAmmoStationPower };
  418.  
  419.     visibleToSensor = true;
  420.     shadowDetailMask = 4;
  421.     castLOS = true;
  422.     supression = false;
  423.     supressable = false;
  424.     mapFilter = 4;
  425.     mapIcon = "M_station";
  426.     debrisId = flashDebrisSmall;
  427.     damageSkinData = "objectDamageSkins";
  428.    explosionId = flashExpMedium;
  429. };
  430.  
  431.  
  432. function DeployableAmmoStation::onAdd(%this)
  433. {
  434.     schedule("DeployableStation::deploy(" @ %this @ ");",1,%this);
  435.     if (GameBase::getMapName(%this) == "") 
  436.         GameBase::setMapName (%this, "R-Ammo Station");
  437.     %this.Energy = $RemoteAmmoEnergy;
  438. }
  439.  
  440. function DeployableAmmoStation::onActivate(%this)
  441. {
  442.     if(%this.deployed == 1) {
  443.         GameBase::playSequence(%this,1,"use");
  444.         //echo("Activate " @ %this);
  445.         schedule("AmmoStation::onResupply(" @ %this @ ");",0.5,%this);
  446.     }
  447.     else 
  448.         GameBase::setActive(%this,false);    
  449. }
  450.  
  451.  
  452. //----------------------------------------------------------------------------
  453.  
  454. StaticShapeData DeployableInvStation
  455. {
  456.     description = "Remote Inv Unit";
  457.     shapeFile = "invent_remote";
  458.     className = "DeployableStation";
  459.     maxDamage = 0.25;
  460.     sequenceSound[0] = { "deploy", SoundActivateMotionSensor };
  461.     sequenceSound[1] = { "use", SoundUseAmmoStation };
  462.     sequenceSound[2] = { "power", SoundInventoryStationPower };            
  463.     visibleToSensor = true;
  464.     shadowDetailMask = 4;
  465.     castLOS = true;
  466.     supression = false;
  467.     supressable = false;
  468.     mapFilter = 4;
  469.     mapIcon = "M_station";
  470.     debrisId = flashDebrisMedium;
  471.     damageSkinData = "objectDamageSkins";
  472.    explosionId = flashExpSmall;
  473. //    triggerRadius = 1.5;
  474. };
  475.  
  476.  
  477. function DeployableInvStation::onAdd(%this)
  478. {
  479.     schedule("DeployableStation::deploy(" @ %this @ ");",1,%this);
  480.     if (GameBase::getMapName(%this) == "") 
  481.         GameBase::setMapName (%this, "R-Inv Station");
  482.     %this.Energy = $RemoteInvEnergy;
  483. }
  484.  
  485. function DeployableInvStation::onActivate(%this)
  486. {
  487.     if(%this.deployed == 1) {
  488.         GameBase::playSequence(%this,1,"use");
  489.         //echo("Activate " @ %this);
  490.          InventoryStation::onResupply(%this,"RemoteInvList");
  491.     }
  492.     else
  493.         GameBase::setActive(%this,false);
  494. }
  495.  
  496.  
  497. //----------------------------------------------------------------------------
  498.  
  499. StaticShapeData InventoryStation
  500. {
  501.    description = "Station Supply Unit";
  502.     shapeFile = "inventory_sta";
  503.     className = "Station";
  504.     visibleToSensor = true;
  505.     sequenceSound[0] = { "activate", SoundActivateInventoryStation };
  506.     sequenceSound[1] = { "power", SoundInventoryStationPower };
  507.     sequenceSound[2] = { "use", SoundUseInventoryStation };
  508.     maxDamage = 1.0;
  509.     debrisId = flashDebrisLarge;
  510.     mapFilter = 4;
  511.     mapIcon = "M_station";
  512.     damageSkinData = "objectDamageSkins";
  513.     shadowDetailMask = 16;
  514.     triggerRadius = 1.5;
  515.    explosionId = flashExpLarge;
  516. };
  517.  
  518. function InventoryStation::onEndSequence(%this,%thread)
  519. {
  520.     //echo("End Seq ",%thread);
  521.     if (Station::onEndSequence(%this,%thread)) 
  522.         InventoryStation::onResupply(%this,"InvList");
  523. }
  524.  
  525. function InventoryStation::onResupply(%this,%InvShopList)
  526. {
  527.     dbecho(3, "STATION::Resupply");
  528.     if (GameBase::isActive(%this)) {
  529.         %player = Station::getTarget(%this);
  530.         if (%player != -1) {
  531.             %client = Player::getClient(%player);
  532.             if (%this.target != %client) {
  533.                 %player.Station = %this;
  534.                 setupShoppingList(%client,%this,%InvShopList);
  535.                 updateBuyingList(%client);
  536.                 %this.target = %client;
  537.                 %this.clTeamEnergy = %client.TeamEnergy;
  538.                 Client::setGuiMode(%client,4);
  539.                 Client::sendMessage(%client,0,"Station Access On");
  540.                 %client.ResupplyFlag = 1;
  541.             }
  542.             schedule("InventoryStation::onResupply(" @ %this @ ");",0.5,%this);
  543.             if(%client.ResupplyFlag) 
  544.                %client.ResupplyFlag = resupply(%this);
  545.             return;
  546.         }
  547.         GameBase::setActive(%this,false);
  548.     }
  549.     if (%this.target) {       
  550.         %player = Client::getOwnedObject(%this.target);
  551.         Client::clearItemShopping(%this.target);
  552.         Client::sendMessage(%this.target,0,"Station Access Off");
  553.         if(GameBase::getDataName(%player.Station) == DeployableInvStation) {
  554.             Client::setInventoryText(%this.target, "<f1><jc>TEAM ENERGY: " @ $TeamEnergy[Client::getTeam(%this.target)]);
  555.             if(Client::getGuiMode(%this.target) != 1)
  556.                 Client::setGuiMode(%this.target,1);
  557.             %player.Station = "";
  558.             %this.target = "";
  559.         }
  560.     }
  561. }
  562.  
  563.  
  564. function resupply(%this)
  565. {
  566.     if (GameBase::isActive(%this)) {
  567.         %player = Station::getTarget(%this);
  568.         if (%player != -1) {
  569.             // Hardcoded here for the ammo types
  570.             %cnt = 0;
  571.             %cnt = %cnt + AmmoStation::resupply(%player,"",RepairPatch,1);
  572.             %cnt = %cnt + AmmoStation::resupply(%player,ChainGun,BulletAmmo,20);
  573.             %cnt = %cnt + AmmoStation::resupply(%player,PlasmaGun,PlasmaAmmo,5);
  574.             %cnt = %cnt + AmmoStation::resupply(%player,GrenadeLauncher,GrenadeAmmo,2);
  575.             %cnt = %cnt + AmmoStation::resupply(%player,DiscLauncher,DiscAmmo,2);
  576.             %cnt = %cnt + AmmoStation::resupply(%player,Mortar,MortarAmmo,2);
  577.             %client = Player::getClient(%player);
  578.             if (%cnt != 0) {
  579.                 updateBuyingList(%client);
  580.                 return 1;
  581.             }
  582.             Client::sendMessage(%client,0,"Resupply Complete");
  583.             return 0;
  584.         }
  585.     }
  586. }
  587.  
  588.  
  589. //----------------------------------------------------------------------------
  590. function setupShoppingList(%client,%station,%ListType)
  591. {
  592.     %max = getNumItems();
  593.     if(%ListType == "InvList") {
  594.         for (%i = 0; %i < %max; %i = %i + 1) {
  595.             %item = getItemData(%i);
  596.             if($InvList[%item] != "" && $InvList[%item] && !%station.dontSell[%item]) 
  597.                 Client::setItemShopping(%client, %item);
  598.             else if(%item.className == Armor && !%station.dontSell[%item])  
  599.                 Client::setItemShopping(%client, %item);
  600.         }
  601.     }
  602.     else if(%ListType == "RemoteInvList") {
  603.         for (%i = 0; %i < %max; %i = %i + 1) {
  604.             %item = getItemData(%i);
  605.             if($RemoteInvList[%item] != "" && $RemoteInvList[%item] && !%station.dontSell[%item]) 
  606.                 Client::setItemShopping(%client, %item);
  607.        }
  608.     }
  609.     else {
  610.         for (%i = 0; %i < %max; %i = %i + 1) {                        
  611.             %item = getItemData(%i);
  612.             if($VehicleInvList[%item] != "" && $VehicleInvList[%item] && !%station.dontSell[%item]) 
  613.                 Client::setItemShopping(%client, %item);
  614.         }
  615.     }
  616. }
  617.  
  618. function updateBuyingList(%client)
  619. {
  620.    Client::clearItemBuying(%client);
  621.     %station = (Client::getOwnedObject(%client)).Station;
  622.     %stationName = GameBase::getDataName(%station); 
  623.     if(%stationName == DeployableInvStation || %stationName == DeployableAmmoStation) {
  624.         %energy = %station.Energy;
  625.        Client::setInventoryText(%client, "<f1><jc>STATION ENERGY: " @ %energy );
  626.     }
  627.    else {
  628.         %energy = $TeamEnergy[Client::getTeam(%client)];
  629.         Client::setInventoryText(%client, "<f1><jc>TEAM ENERGY: " @ %energy);
  630.     }
  631.     %armor = Player::getArmor(%client);
  632.     %max = getNumItems();
  633.     for (%i = 0; %i < %max; %i = %i + 1) {
  634.         %item = getItemData(%i);
  635.         if($ItemMax[%armor, %item] != "" && Client::isItemShoppingOn(%client,%i)) {
  636.             %extraAmmo = 0;
  637.             if(Player::getMountedItem(%client,$BackpackSlot) == ammopack)
  638.                 %extraAmmo = $AmmoPackMax[%item];
  639.             if($ItemMax[%armor, %item] + %extraAmmo > Player::getItemCount(%client,%item))    {
  640.                 if(%energy >= %item.price ) {
  641.                     if(%item.className == Weapon) {
  642.                         if(Player::getItemClassCount(%client,"Weapon") < $MaxWeapons[%armor])                    
  643.                             Client::setItemBuying(%client, %item);
  644.                     }
  645.                     else { 
  646.                         if($TeamItemMax[%item] != "") {                        
  647.                             if($TeamItemCount[GameBase::getTeam(%client) @ %item] < $TeamItemMax[%item])
  648.                                 Client::setItemBuying(%client, %item);
  649.                         }
  650.                         else
  651.                             Client::setItemBuying(%client, %item);
  652.                     }
  653.                 }
  654.            }
  655.         }
  656.         else if(%item.className == Armor && %item != $ArmorName[%armor] && Client::isItemShoppingOn(%client,%i)) 
  657.             Client::setItemBuying(%client, %item);
  658.         else if(%item.className == Vehicle && $TeamItemCount[client::getTeam(%client) @ %item] < $TeamItemMax[%item] && Client::isItemShoppingOn(%client,%i))
  659.             Client::setItemBuying(%client, %item);
  660.     }
  661. }
  662.  
  663. //----------------------------------------------------------------------------
  664. StaticShapeData CommandStation
  665. {
  666.    description = "Command Station";
  667.     shapeFile = "cmdpnl";
  668.     className = "Station";
  669.     visibleToSensor = true;
  670.     sequenceSound[0] = { "activate", SoundActivateCommandStation };
  671.     sequenceSound[1] = { "power", SoundCommandStationPower };
  672.     sequenceSound[2] = { "use", SoundUseCommandStation };
  673.     maxDamage = 1.0;
  674.     debrisId = flashDebrisMedium;
  675.     mapFilter = 4;
  676.     mapIcon = "M_station";
  677.     damageSkinData = "objectDamageSkins";
  678.     shadowDetailMask = 16;
  679.     triggerRadius = 1.5;
  680.    explosionId = flashExpLarge;
  681. };
  682.  
  683. function CommandStation::onEndSequence(%this,%thread)
  684. {
  685.     //echo("End Seq ",%thread);
  686.     (Client::getOwnedObject(%this.target)).Station = "";
  687.     %this.target = "";
  688.     if (Station::onEndSequence(%this,%thread)) 
  689.         CommandStation::onResupply(%this);
  690. }
  691.  
  692. function CommandStation::onResupply(%this)
  693. {
  694.     if (GameBase::isActive(%this)) {
  695.         %player = Station::getTarget(%this);
  696.         if (%player != -1) {
  697.             %client = Player::getClient(%player);
  698.             if (%this.target != %client) {
  699.                 %this.target = %client;
  700.                 %client.CommandTag = 1;
  701.                 Client::setGuiMode(%client,2);
  702.                 Client::sendMessage(%client,0,"Command Access On");
  703.             }
  704.             schedule("CommandStation::onResupply(" @ %this @ ");",0.5,%this);
  705.             return;
  706.         }
  707.         GameBase::setActive(%this,false);
  708.     }
  709.     if (%this.target) {
  710.         Client::sendMessage(%this.target,0,"Command Access Off");
  711.         %this.target.CommandTag = 0;
  712.     }
  713.     (Client::getOwnedObject(%this.target)).Station = "";
  714.     %this.target = "";
  715. }
  716.  
  717.  
  718. //----------------------------------------------------------------------------
  719. StaticShapeData VehicleStation
  720. {
  721.    description = "Station Vehicle Unit";
  722.     shapeFile = "vehi_pur_pnl";
  723.     className = "Station";
  724.     visibleToSensor = true;
  725.     sequenceSound[0] = { "activate", SoundActivateInventoryStation };
  726.     sequenceSound[1] = { "power", SoundInventoryStationPower };
  727.     sequenceSound[2] = { "use", SoundUseInventoryStation };
  728. //   explosionId = DebrisExp;
  729.     maxDamage = 1.0;
  730.     debrisId = flashDebrisLarge;
  731.     mapFilter = 4;
  732.     mapIcon = "M_station";
  733.     damageSkinData = "objectDamageSkins";
  734.     shadowDetailMask = 16;
  735.     triggerRadius = 1.5;
  736.    explosionId = flashExpLarge;
  737. };
  738.  
  739. function VehicleStation::onEndSequence(%this,%thread)
  740. {
  741.     //echo("End Seq ",%thread);
  742.     if (Station::onEndSequence(%this,%thread)) 
  743.         VehicleStation::onBuyingVechicle(%this);
  744. }
  745.  
  746. function VehicleStation::onBuyingVechicle(%this)
  747. {
  748.     if (GameBase::isActive(%this)) {
  749.         %player = Station::getTarget(%this);
  750.         if (%player != -1) {
  751.             %client = Player::getClient(%player);
  752.             if (%this.target != %client) {
  753.                 setupShoppingList(%client,%this,"VehicleInvList");
  754.                 updateBuyingList(%client);
  755.                 %this.target = %client;
  756.                 %this.clTeamEnergy = %client.TeamEnergy;
  757.                 Client::setGuiMode(%client,4);
  758.                 Client::sendMessage(%client,0,"Station Access On");
  759.                 %player.Station = %this;
  760.                  %numItems = Group::objectCount(GetGroup(%this));
  761.                 for(%i = 0 ; %i<%numItems ; %i++) { 
  762.                     %obj = Group::getObject(GetGroup(%this), %i);
  763.                     %name = GameBase::getDataName(%obj); 
  764.                     if(%name == VehiclePad) { 
  765.                         %this.vehiclePad = %obj;
  766.                         GameBase::setActive(%this.vehiclePad,true);
  767.                         %i = %numItems;
  768.                     }
  769.                 }
  770.             }
  771.             schedule("VehicleStation::onBuyingVechicle(" @ %this @ ");",0.5,%this);
  772.             return;
  773.         }
  774.         GameBase::setActive(%this,false);
  775.     }
  776.     if (%this.target) {       
  777.         Client::clearItemShopping(%this.target);
  778.         Client::sendMessage(%this.target,0,"Station Access Off");
  779.     }
  780. }
  781.  
  782.  
  783. function VehicleStation::checkBuying(%client,%item)
  784. {
  785.     %player = Client::getOwnedObject(%client);
  786.     %obj = %player.Station.vehiclePad;
  787.     if(GameBase::isPowered(%obj) && GameBase::getDamageState(%obj) == "Enabled") {
  788.         %markerPos = GameBase::getPosition(%obj);
  789.           %set = newObject("set",SimSet);
  790.         %mask = $VehicleObjectType | $SimPlayerObjectType | $ItemObjectType;
  791.         %objInWay = containerBoxFillSet(%set,%mask,%markerPos,6,5,14,1);
  792.         %station = %player.Station;
  793.         if(%objInWay == 1) {
  794.             %object = Group::getObject(%set, 0);    
  795.             %sName = GameBase::getDataName(%object);
  796.             if(%sName.className == Vehicle) {
  797.                 if(GameBase::getControlClient(%object) == -1) {
  798.                     if(%station.fadeOut == "") {
  799.                         if(%item != $VehicleToItem[%sname]) {
  800.                             %object.fading = 1;
  801.                             %station.fadeOut=1;
  802.                             teamEnergyBuySell(%player,$VehicleToItem[%sName].price);
  803.                             $TeamItemCount[Client::getTeam(%client) @ ($VehicleToItem[%sName])]--;
  804.                             GameBase::startFadeOut(%object);
  805.                             schedule("deleteObject(" @ %object @ ");",2.5,%object);
  806.                             schedule(%object @ ".fading = \"\";",2.5,%object);
  807.                             schedule(%station @ ".fadeOut = \"\";",2.5,%station);
  808.                             %objInWay--;
  809.                         }
  810.                         else
  811.                             return 2;
  812.                     }
  813.                     else {
  814.                         Client::SendMessage(%client,0,"ERROR - Vehicle creation pad busy"); 
  815.                         return 0;
  816.                     }
  817.                 }
  818.                 else { 
  819.                     Client::SendMessage(%client,0,"ERROR - Vehicle in creation area is mounted");
  820.                     return 0;
  821.                 }
  822.             } 
  823.         }
  824.         if(!%objInWay) {
  825.             if (checkResources(%player,%item,1)) {
  826.                 %vehicle = newObject("",flier,$DataBlockName[%item],true);
  827.             %vehicle.clLastMount = %client;
  828.                 addToSet("MissionCleanup", %vehicle);
  829.                   %vehicle.fading = 1;
  830.                 GameBase::setTeam(%vehicle,Client::getTeam(%client));
  831.                 if(%object.fading) { 
  832.                     schedule("GameBase::startFadeIn(" @ %vehicle @ ");",2.5,%vehicle);
  833.                     schedule("GameBase::setPosition(" @ %vehicle @ ",\"" @ %markerPos @ "\");",2.5,%vehicle);
  834.                     schedule("GameBase::setRotation(" @ %vehicle @ ",\"" @ GameBase::getRotation(%obj) @ "\");",2.5,%vehicle);
  835.                     schedule(%vehicle @ ".fading = \"\"; VehiclePad::checkSeq(" @ %obj @ "," @ %player.Station @ ");",5,%vehicle);
  836.                     %obj.busy = getSimTime() + 5;
  837.                 }
  838.                 else {
  839.                     GameBase::startFadeIn(%vehicle);
  840.                     GameBase::setPosition(%vehicle,%markerPos);
  841.                     GameBase::setRotation(%vehicle,GameBase::getRotation(%obj));
  842.                      schedule(%vehicle @ ".fading = \"\"; VehiclePad::checkSeq(" @ %obj @ "," @ %player.Station @ ");",3,%vehicle);
  843.                     %obj.busy = getSimTime() + 3;
  844.                 }
  845.                 deleteObject(%set);
  846.                 $TeamItemCount[Client::getTeam(%client) @ %item]++;
  847.                 return 1;
  848.             }
  849.         }
  850.         else
  851.             Client::SendMessage(%client,0,"ERROR - Object in vehicle creation area");
  852.         deleteObject(%set);
  853.     }    
  854.     else
  855.         Client::SendMessage(%client,0,"ERROR - Vehicle Pad Disabled");
  856.  
  857.     return 0;
  858. }
  859.  
  860.  
  861. StaticShapeData VehiclePad
  862. {
  863.    description = "Vehicle Pad";
  864.     shapeFile = "vehi_pur_poles";
  865.     className = "Station";
  866.     visibleToSensor = true;
  867.     sequenceSound[0] = { "activate", SoundActivateInventoryStation };
  868.     sequenceSound[1] = { "power", SoundInventoryStationPower };
  869.     sequenceSound[2] = { "use", SoundUseInventoryStation };
  870.     maxDamage = 1.0;
  871.     debrisId = flashDebrisLarge;
  872.     mapFilter = 4;
  873.     mapIcon = "M_station";
  874.    explosionId = flashExpLarge;
  875.     damageSkinData = "objectDamageSkins";
  876. };
  877.  
  878.  
  879.  
  880. function VehiclePad::onActivate(%this)
  881. {
  882.     GameBase::playSequence(%this,1,"use");
  883. }
  884.  
  885. function VehiclePad::onDeactivate(%this)
  886. {
  887.     GameBase::stopSequence(%this,1);
  888. }
  889.  
  890. function VehiclePad::onEnabled(%this)
  891. {
  892. }
  893.  
  894. function VehiclePad::onAdd(%this)
  895. {
  896. }
  897.  
  898. function VehiclePad::onCollision(%this, %object)
  899. {
  900. }
  901.  
  902. function VehiclePad::onPower(%this,%power,%generator)
  903. {
  904.     if(!%power)
  905.         GameBase::setActive(%this,false);
  906. }
  907.  
  908. function VehiclePad::checkSeq(%this, %station)
  909. {
  910.     if(%station.target == "")
  911.         GameBase::setActive(%this,false);
  912. }
  913.