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

  1. //----------------------------------------------------------------------------
  2.  
  3. //----------------------------------------------------------------------------
  4.  
  5. $ItemPopTime = 30;
  6.  
  7. $ToolSlot=0;
  8. $WeaponSlot=0;
  9. $BackpackSlot=1;
  10. $FlagSlot=2;
  11. $DefaultSlot=3;
  12.  
  13. $AutoUse[Blaster] = True;
  14. $AutoUse[Chaingun] = True;
  15. $AutoUse[PlasmaGun] = True;
  16. $AutoUse[Mortar] = True;
  17. $AutoUse[GrenadeLauncher] = True;
  18. $AutoUse[LaserRifle] = True;
  19. $AutoUse[EnergyRifle] = True;
  20. $AutoUse[TargetingLaser] = False;
  21. $AutoUse[ChargeGun] = True;
  22.  
  23. $Use[Blaster] = True;
  24.  
  25. $ArmorType[Male, LightArmor] = larmor;
  26. $ArmorType[Male, MediumArmor] = marmor;
  27. $ArmorType[Male, HeavyArmor] = harmor;
  28. $ArmorType[Female, LightArmor] = lfemale;
  29. $ArmorType[Female, MediumArmor] = mfemale;       
  30. $ArmorType[Female, HeavyArmor] = harmor;
  31.  
  32. $ArmorName[larmor] = LightArmor;
  33. $ArmorName[marmor] = MediumArmor;
  34. $ArmorName[harmor] = HeavyArmor;
  35. $ArmorName[lfemale] = LightArmor;
  36. $ArmorName[mfemale] = MediumArmor;
  37.  
  38. // Amount to remove when selling or dropping ammo
  39. $SellAmmo[BulletAmmo] = 25;
  40. $SellAmmo[PlasmaAmmo] = 5;
  41. $SellAmmo[DiscAmmo] = 5;
  42. $SellAmmo[GrenadeAmmo] = 5;
  43. $SellAmmo[MortarAmmo] = 5;
  44. $SellAmmo[Beacon] = 5;
  45. $SellAmmo[MineAmmo] = 5;
  46. $SellAmmo[Grenade] = 5;
  47.  
  48. // Max Amount of ammo the Ammo Pack can carry
  49. $AmmoPackMax[BulletAmmo] = 150;
  50. $AmmoPackMax[PlasmaAmmo] = 30;
  51. $AmmoPackMax[DiscAmmo] = 15;
  52. $AmmoPackMax[GrenadeAmmo] = 15;
  53. $AmmoPackMax[MortarAmmo] = 10;
  54. $AmmoPackMax[MineAmmo] = 5;
  55. $AmmoPackMax[Grenade] = 10;
  56. $AmmoPackMax[Beacon] = 10;
  57.  
  58. // Items in the AmmoPack
  59. $AmmoPackItems[0] = BulletAmmo;
  60. $AmmoPackItems[1] = PlasmaAmmo;
  61. $AmmoPackItems[2] = DiscAmmo;
  62. $AmmoPackItems[3] = GrenadeAmmo;
  63. $AmmoPackItems[4] = Grenade;
  64. $AmmoPackItems[5] = MineAmmo;
  65. $AmmoPackItems[6] = MortarAmmo;
  66. $AmmoPackItems[7] = Beacon;
  67.  
  68. // Limit on number of special Items you can buy
  69. $TeamItemMax[DeployableAmmoPack] = 7;
  70. $TeamItemMax[DeployableInvPack] = 5;
  71. $TeamItemMax[TurretPack] = 10;
  72. $TeamItemMax[CameraPack] = 15;
  73. $TeamItemMax[DeployableSensorJammerPack] = 8;
  74. $TeamItemMax[PulseSensorPack] = 15;
  75. $TeamItemMax[MotionSensorPack] = 15;
  76. $TeamItemMax[ScoutVehicle] = 3;
  77. $TeamItemMax[HAPCVehicle] = 1;
  78. $TeamItemMax[LAPCVehicle] = 2;
  79. $TeamItemMax[Beacon] = 40;
  80. $TeamItemMax[mineammo] = 35;
  81.  
  82. // Global object damage skins (staticShapes Turrets Stations Sensors)
  83. DamageSkinData objectDamageSkins
  84. {
  85.    bmpName[0] = "dobj1_object";
  86.    bmpName[1] = "dobj2_object";
  87.    bmpName[2] = "dobj3_object";
  88.    bmpName[3] = "dobj4_object";
  89.    bmpName[4] = "dobj5_object";
  90.    bmpName[5] = "dobj6_object";
  91.    bmpName[6] = "dobj7_object";
  92.    bmpName[7] = "dobj8_object";
  93.    bmpName[8] = "dobj9_object";
  94.    bmpName[9] = "dobj10_object";
  95. };
  96.  
  97. // Weapon to ammo table
  98. $WeaponAmmo[Blaster] = "";
  99. $WeaponAmmo[PlasmaGun] = PlasmaAmmo;
  100. $WeaponAmmo[Chaingun] = BulletAmmo;
  101. $WeaponAmmo[DiscLauncher] = DiscAmmo;
  102. $WeaponAmmo[GrenadeLauncher] = GrenadeAmmo;
  103. $WeaponAmmo[Mortar] = Mortar;
  104. $WeaponAmmo[LaserRifle] = "";
  105. $WeaponAmmo[EnergyRifle] = "";
  106.  
  107.  
  108. //----------------------------------------------------------------------------
  109. // Server side methods
  110. // The client side inventory dialogs call buyItem, sellItem,
  111. // useItem and dropItem through remoteEvals.
  112.  
  113. function teamEnergyBuySell(%player,%cost)
  114. {
  115.     %client = Player::getClient(%player);
  116.     %team = Client::getTeam(%client);
  117.     // IF - Cost positive selling    IF - Cost Negitive buying 
  118.     %station = %player.Station;
  119.     %stationName = GameBase::getDataName(%station); 
  120.     if(%stationName == DeployableInvStation || %stationName == DeployableAmmoStation) {
  121.         %station.Energy += %cost;            //Remote StationEnergy
  122.         if(%station.Energy < 1)
  123.             %station.Energy = 0;
  124.     }
  125.     else if($TeamEnergy[%team] != "Infinite") { 
  126.         $TeamEnergy[%team] += %cost;    //Total TeamEnergy
  127.          %client.teamEnergy += %cost;   //Personal TeamEnergy
  128.     }
  129. }
  130.  
  131.  
  132. function remoteBuyFavorites(%client,%favItem0,%favItem1,%favItem2,%favItem3,%favItem4,%favItem5,%favItem6,%favItem7,%favItem8,%favItem9,%favItem10,%favItem11,%favItem12,%favItem13,%favItem14,%favItem15,%favItem16,%favItem17,%favItem18,%favItem19)
  133. {
  134.     %station = (Client::getOwnedObject(%client)).Station;
  135.     %stationName = GameBase::getDataName(%station); 
  136.     if(%stationName == DeployableInvStation || %stationName == DeployableAmmoStation) 
  137.         %energy = %station.Energy;
  138.     else 
  139.         %energy = $TeamEnergy[Client::getTeam(%client)];
  140.     if(%energy == "Infinite" || %energy > 0) {
  141.         %error = 0;
  142.         %bought = 0;
  143.         %max = getNumItems();
  144.         for (%i = 0; %i < %max; %i = %i + 1) { 
  145.             %item = getItemData(%i);
  146.             if ($ServerCheats || Client::isItemShoppingOn(%client,%item)|| $TestCheats) {
  147.                 %count = Player::getItemCount(%client,%item);
  148.                 if(%count) {
  149.                     if(%item.className != Armor) 
  150.                         teamEnergyBuySell(Client::getOwnedObject(%client),(%item.price * %count));
  151.                     Player::setItemCount(%client, %item, 0);  
  152.                 }
  153.             }
  154.         }
  155.         for (%i = 0; %i < 20; %i++) { 
  156.             if(%favItem[%i] != "") {
  157.                 %item = getItemData(%favItem[%i]);
  158.                 if ((Client::isItemShoppingOn(%client,%item)) && ($ItemMax[Player::getArmor(%client),  %item] > Player::getItemCount(%client,%item) || %item.className == Armor)) {
  159.                     if(!buyItem(%client,%item))  
  160.                         %error = 1;
  161.                     else
  162.                         %bought++;
  163.                 }
  164.             }
  165.           }
  166.         if(%bought) {
  167.             if(%error) 
  168.                 Client::sendMessage(%client,0,"~wC_BuySell.wav");
  169.             else 
  170.                 Client::SendMessage(%client,0,"~wbuysellsound.wav");
  171.         }
  172.         updateBuyingList(%client);
  173.     }
  174. }
  175.  
  176.  
  177. function replenishTeamEnergy(%team)
  178. {
  179.     $TeamEnergy[%team] += $incTeamEnergy;
  180.     schedule("replenishTeamEnergy(" @ %team @ ");", $secTeamEnergy);
  181. }
  182.  
  183.  
  184. function checkResources(%player,%item,%delta,%noMessage)
  185. {
  186.     %client = Player::getClient(%player);
  187.     %team = Client::getTeam(%client);
  188.     %extraAmmo = 0 ;
  189.     if (Player::getMountedItem(%client,$BackpackSlot) == ammopack && $AmmoPackMax[%item] != "") {
  190.         %extraAmmo = $AmmoPackMax[%item];
  191.         if(%delta == $ItemMax[Player::getArmor(%client), %item]) 
  192.             %delta = %delta + %extraAmmo;
  193.     }
  194.     if($TestCheats == 0 && %client.spawn == "") {
  195.         %energy = $TeamEnergy[%team];
  196.         %station = %player.Station;
  197.         %sName = GameBase::getDataName(%station);
  198.         if(%sName == DeployableInvStation || %sName == DeployableAmmoStation){
  199.             %energy = %station.Energy;
  200.         }
  201.         if(%energy != "Infinite") {
  202.             if (%item.price * %delta > %energy)    
  203.                 %delta = %energy / %item.price; 
  204.             if(%delta < 1 ) {
  205.                 if(%noMessage == "")
  206.                     Client::sendMessage(%client,0,"Couldn't buy " @ %item.description @ " - "@ %energy @ " Energy points left");
  207.                 return 0;
  208.             }
  209.         }
  210.     }
  211.     if(%item.className == Weapon) {
  212.         %armor = Player::getArmor(%client);
  213.         %wcount = Player::getItemClassCount(%client,"Weapon");
  214.         if (Player::getItemClassCount(%client,"Weapon") >= $MaxWeapons[%armor]) {
  215.             Client::sendMessage(%client,0,"To many weapons for " @ $ArmorName[%armor].description @ " to carry");
  216.             return 0;
  217.         }
  218.       }
  219.     else if(%item == RepairPatch) {
  220.         %pDamage = GameBase::getDamageLevel(%player);
  221.         if(GameBase::getDamageLevel(%player) > 0) 
  222.             return 1;
  223.         return 0;
  224.    }
  225.    else if($TeamItemMax[%item] != "" && !$TestCheats) {
  226.         if($TeamItemMax[%item] <= $TeamItemCount[%team, %item]) {
  227.             Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %item.description @ "s");
  228.             return 0;
  229.         }
  230.     }
  231.     if(%item.className != Armor && %item.className != Vehicle) {
  232.        %count = Player::getItemCount(%client,%item);
  233.           %max = $ItemMax[(Player::getArmor(%client)), %item] + %extraAmmo ;
  234.        if(%delta + %count >= %max) 
  235.             %delta = %max - %count;
  236.     }
  237.     return %delta;
  238. }
  239.  
  240. function buyItem(%client,%item)
  241. {
  242.     %player = Client::getOwnedObject(%client);
  243.     %armor = Player::getArmor(%client);
  244.     if (($ServerCheats || Client::isItemShoppingOn(%client,%item) || $TestCheats || %client.spawn) && 
  245.             ($ItemMax[%armor, %item] || %item.className == Armor || %item.className == Vehicle || $TestCheats)) {
  246.         if (%item.className == Armor) {
  247.             // Assign armor by requested type & gender 
  248.             %buyarmor = $ArmorType[Client::getGender(%client), %item];
  249.             if(%armor != %buyarmor || Player::getItemCount(%client,%item) == 0)    {
  250.                 teamEnergyBuySell(%player,$ArmorName[%armor].price);
  251.                 if(checkResources(%player,%item,1)) {
  252.                     teamEnergyBuySell(%player,$ArmorName[%buyarmor].price * -1);
  253.                     Player::setArmor(%client,%buyarmor);
  254.                     checkMax(%client,%buyarmor);
  255.                     armorChange(%client);
  256.                      Player::setItemCount(%client, $ArmorName[%armor], 0);  
  257.                      Player::setItemCount(%client, %item, 1);  
  258.                     if (Player::getMountedItem(%client,$BackpackSlot) == ammopack) 
  259.                         fillAmmoPack(%client);    
  260.                     return 1;
  261.                 }
  262.  
  263.                 teamEnergyBuySell(%player,$ArmorName[%armor].price * -1);
  264.             }
  265.         }
  266.         else if (%item.className == Backpack) {
  267.             // Only one backpack per armor.
  268.             %pack = Player::getMountedItem(%client,$BackpackSlot);
  269.             if (%pack != -1) {
  270.                 if(%pack == ammopack) 
  271.                     checkMax(%client,%armor);
  272.                 else if(%pack == EnergyPack) {
  273.                     if(Player::getItemCount(%client,"LaserRifle") > 0) {
  274.                         Client::sendMessage(%client,0,"Sold Energy Pack - Auto Selling Laser Rifle");
  275.                         remoteSellItem(%client,22);                        
  276.                     }
  277.                 }    
  278.                 teamEnergyBuySell(%player,%pack.price);
  279.                 Player::decItemCount(%client,%pack);
  280.             }               
  281.             if (checkResources(%player,%item,1) || $testCheats) {
  282.                 teamEnergyBuySell(%player,%item.price * -1);
  283.                 Player::incItemCount(%client,%item);
  284.                 Player::useItem(%client,%item);                                     
  285.                 if(%item == ammopack) 
  286.                     fillAmmoPack(%client);
  287.                 return 1;
  288.             }
  289.             else if(%pack != -1) {
  290.                 teamEnergyBuySell(%player,%pack.price * -1);
  291.                 Player::incItemCount(%client,%pack);
  292.                 Player::useItem(%client,%pack);                                     
  293.                 if(%pack == ammopack) 
  294.                     fillAmmoPack(%client);
  295.             }                 
  296.         }
  297.         else if(%item.className == Weapon) {
  298.             if(checkResources(%player,%item,1)) {
  299.                 if(%item == LaserRifle && Player::getItemCount(%client,"EnergyPack") == 0) {
  300.                     buyItem(%client,"EnergyPack");
  301.                     Client::sendMessage(%client,0,"Bought Laser Rifle - Auto buying Energy Pack");
  302.                 }
  303.                 Player::incItemCount(%client,%item);
  304.                 teamEnergyBuySell(%player,(%item.price * -1));
  305.                 %ammoItem =  %item.imageType.ammoType; 
  306.                 if(%ammoItem != "") {
  307.                     %delta = checkResources(%player,%ammoItem,$ItemMax[%armor, %ammoItem]);
  308.                     if(%delta || $testCheats) {
  309.                         teamEnergyBuySell(%player,(%ammoItem.price * -1 * %delta));
  310.                         Player::incItemCount(%client,%ammoitem,%delta);
  311.                     }
  312.                 }
  313.                 return 1;
  314.             }
  315.         }
  316.          else if(%item.className == Vehicle) {
  317.             %shouldBuy = VehicleStation::checkBuying(%client,%item);
  318.             if(%shouldBuy == 1) {
  319.                 teamEnergyBuySell(%player,(%item.price * -1));
  320.                 return 1;
  321.             }            
  322.              else if(%shouldBuy == 2)
  323.                 return 1;
  324.         }
  325.         else {
  326.             %delta = checkResources(%player,%item,$ItemMax[%armor, %item]);
  327.             if(%delta || $testCheats) {
  328.                 teamEnergyBuySell(%player,(%item.price * -1 * %delta));
  329.                 Player::incItemCount(%client,%item,%delta);
  330.                 return 1;
  331.             }
  332.         }
  333.         
  334.      }
  335.     return 0;
  336. }
  337.  
  338. function armorChange(%client)
  339. {
  340.     %player = Client::getOwnedObject(%client);
  341.     if(%client.respawn == "" && %player.Station != "") {
  342.         %sPos = GameBase::getPosition(%player.Station);
  343.         %pPos    = GameBase::getPosition(%client);
  344.         %posX = getWord(%sPos,0);
  345.         %posY = getWord(%sPos,1);
  346.         %posZ = getWord(%pPos,2);
  347.         %vec = Vector::getFromRot(GameBase::getRotation(%player.Station),-1);    
  348.           %newPosX = (getWord(%vec,0) * 1) + %posX;         
  349.         %newPosY = (getWord(%vec,1) * 1) + %posY;
  350.         GameBase::setPosition(%client, %newPosX @ " " @ %newPosY @ " " @ %posZ);
  351.     }
  352. }
  353.  
  354. function remoteBuyItem(%client,%type)
  355. {
  356.     %item = getItemData(%type);
  357.     if(buyItem(%client,%item)) {
  358.          Client::sendMessage(%client,0,"~wbuysellsound.wav");
  359.         updateBuyingList(%client);
  360.     }
  361.     else 
  362.           Client::sendMessage(%client,0,"You couldn't buy "@ %item.description @"~wC_BuySell.wav");
  363. }
  364.  
  365. function remoteSellItem(%client,%type)
  366. {
  367.     %item = getItemData(%type);
  368.     %player = Client::getOwnedObject(%client);
  369.     if ($ServerCheats || Client::isItemShoppingOn(%client,%item) || $TestCheats) {
  370.         if(Player::getItemCount(%client,%item) && %item.className != Armor) {
  371.             %numsell = 1;
  372.             if(%item.className == Ammo || %item.className == HandAmmo) {
  373.                 %count = Player::getItemCount(%client, %item);
  374.                 if(%count < $SellAmmo[%item]) 
  375.                     %numsell = %count; 
  376.                 else 
  377.                     %numsell = $SellAmmo[%item];
  378.             }
  379.             else if (%item == ammopack) 
  380.                 checkMax(%client,Player::getArmor(%client));
  381.             else if($TeamItemMax[%item] != "") {
  382.                 if(%item.className == Vehicle) 
  383.                     $TeamItemCount[(Client::getTeam(%client)) @ %item]--;
  384.             }
  385.             else if(%item == EnergyPack) { 
  386.                 if(Player::getItemCount(%client,"LaserRifle") > 0) {
  387.                     Client::sendMessage(%client,0,"Sold Energy Pack - Auto Selling Laser Rifle");
  388.                     remoteSellItem(%client,22);                        
  389.                 }
  390.             }
  391.             teamEnergyBuySell(%player,%item.price * %numsell);
  392.             Player::setItemCount(%player,%item,(%count-%numsell));
  393.             updateBuyingList(%client);
  394.             Client::SendMessage(%client,0,"~wbuysellsound.wav");
  395.             return 1;
  396.         }
  397.     }
  398.     Client::sendMessage(%client,0,"Cannot sell item ~wC_BuySell.wav");
  399. }
  400.  
  401. function remoteUseItem(%client,%type)
  402. {
  403.     //echo("Use item: " @ %type @ " " @ %item);
  404.     %client.throwStrength = 1;
  405.  
  406.     %item = getItemData(%type);
  407.     if (%item == Backpack) 
  408.         %item = Player::getMountedItem(%client,$BackpackSlot);
  409.     else {
  410.         if (%item == Weapon) 
  411.             %item = Player::getMountedItem(%client,$WeaponSlot);
  412.     }
  413.     Player::useItem(%client,%item);
  414. }
  415.  
  416. function remoteThrowItem(%client,%type,%strength)
  417. {
  418.     //echo("Throw item: " @ %type @ " " @ %strength);
  419.     %item = getItemData(%type);
  420.     if (%item == Grenade || %item == MineAmmo) {
  421.         if (%strength < 0)
  422.             %strength = 0;
  423.         else
  424.             if (%strength > 100)
  425.                 %strength = 100;
  426.         %client.throwStrength = 0.3 + 0.7 * (%strength / 100);
  427.         Player::useItem(%client,%item);
  428.     }
  429. }
  430.  
  431. function remoteDropItem(%client,%type)
  432. {
  433.     if((Client::getOwnedObject(%client)).driver != 1) {
  434.         //echo("Drop item: ",%type);
  435.         %client.throwStrength = 1;
  436.  
  437.         %item = getItemData(%type);
  438.         if (%item == Backpack) {
  439.             %item = Player::getMountedItem(%client,$BackpackSlot);
  440.             Player::dropItem(%client,%item);
  441.         }
  442.         else if (%item == Weapon) {
  443.             %item = Player::getMountedItem(%client,$WeaponSlot);
  444.             Player::dropItem(%client,%item);
  445.         }
  446.         else if (%item == Ammo) {
  447.             %item = Player::getMountedItem(%client,$WeaponSlot);
  448.             if(%item.className == Weapon) {
  449.                 %item = %item.imageType.ammoType;
  450.                 Player::dropItem(%client,%item);
  451.             }
  452.         }
  453.         else 
  454.             Player::dropItem(%client,%item);
  455.     }
  456. }
  457.  
  458. function remoteDeployItem(%client,%type)
  459. {
  460.     //echo("Deploy item: ",%type);
  461.     %item = getItemData(%type);
  462.     Player::deployItem(%client,%item);
  463. }
  464.  
  465. //
  466. $NextWeapon[EnergyRifle] = Blaster;
  467. $NextWeapon[Blaster] = PlasmaGun;
  468. $NextWeapon[PlasmaGun] = Chaingun;
  469. $NextWeapon[Chaingun] = DiscLauncher;
  470. $NextWeapon[DiscLauncher] = GrenadeLauncher;
  471. $NextWeapon[GrenadeLauncher] = Mortar;
  472. $NextWeapon[Mortar] = LaserRifle;
  473. $NextWeapon[LaserRifle] = EnergyRifle;
  474.  
  475. $PrevWeapon[Blaster] = EnergyRifle;
  476. $PrevWeapon[PlasmaGun] = Blaster;
  477. $PrevWeapon[Chaingun] = PlasmaGun;
  478. $PrevWeapon[DiscLauncher] = Chaingun;
  479. $PrevWeapon[GrenadeLauncher] = DiscLauncher;
  480. $PrevWeapon[Mortar] = GrenadeLauncher;
  481. $PrevWeapon[LaserRifle] = Mortar;
  482. $PrevWeapon[EnergyRifle] = LaserRifle;
  483.  
  484. function remoteNextWeapon(%client)
  485. {
  486.     %item = Player::getMountedItem(%client,$WeaponSlot);
  487.     if (%item == -1 || $NextWeapon[%item] == "")
  488.         selectValidWeapon(%client);
  489.     else {
  490.         for (%weapon = $NextWeapon[%item]; %weapon != %item;
  491.                 %weapon = $NextWeapon[%weapon]) {
  492.             if (isSelectableWeapon(%client,%weapon)) {
  493.                 Player::useItem(%client,%weapon);
  494.                 // Make sure it mounted (laser may not)
  495.                 if (Player::getMountedItem(%client,$WeaponSlot) == %weapon)
  496.                     break;
  497.             }
  498.         }
  499.     }
  500. }
  501.  
  502. function remotePrevWeapon(%client)
  503. {
  504.     %item = Player::getMountedItem(%client,$WeaponSlot);
  505.     if (%item == -1 || $PrevWeapon[%item] == "")
  506.         selectValidWeapon(%client);
  507.     else {
  508.         for (%weapon = $PrevWeapon[%item]; %weapon != %item;
  509.                 %weapon = $PrevWeapon[%weapon]) {
  510.             if (isSelectableWeapon(%client,%weapon)) {
  511.                 Player::useItem(%client,%weapon);
  512.                 // Make sure it mounted (laser may not)
  513.                 if (Player::getMountedItem(%client,$WeaponSlot) == %weapon)
  514.                     break;
  515.             }
  516.         }
  517.     }
  518. }
  519.  
  520. function selectValidWeapon(%client)
  521. {
  522.     %item = EnergyRifle;
  523.     for (%weapon = $NextWeapon[%item]; %weapon != %item;
  524.             %weapon = $NextWeapon[%weapon]) {
  525.         if (isSelectableWeapon(%client,%weapon)) {
  526.             Player::useItem(%client,%weapon);
  527.             break;
  528.         }
  529.     }
  530. }
  531.  
  532. function isSelectableWeapon(%client,%weapon)
  533. {
  534.     if (Player::getItemCount(%client,%weapon)) {
  535.         %ammo = $WeaponAmmo[%weapon];
  536.         if (!%ammo || Player::getItemCount(%client,%ammo) > 0)
  537.             return true;
  538.     }
  539.     return false;
  540. }
  541.  
  542.  
  543. //----------------------------------------------------------------------------
  544. // Default item scripts
  545. //----------------------------------------------------------------------------
  546.  
  547. function Item::giveItem(%player,%item,%delta)
  548. {
  549.     %armor = Player::getArmor(%player);
  550.     if($ItemMax[%armor, %item]) {          
  551.         %client = Player::getClient(%player);
  552.         if (%item.className == Backpack) {
  553.             // Only one backpack per armor, and it's always mounted
  554.             if (Player::getMountedItem(%player,$BackpackSlot) == -1) {
  555.                  Player::incItemCount(%player,%item);
  556.                  Player::useItem(%player,%item);
  557.                 Client::sendMessage(%client,0,"You received a " @ %item @ " backpack");
  558.                  return 1;
  559.             }
  560.         }
  561.           else {
  562.             // Check num weapons carried by player can't have more then max
  563.             if (%item.className == Weapon) {
  564.                 if (Player::getItemClassCount(%player,"Weapon") >= $MaxWeapons[%armor]) 
  565.                     return 0;
  566.             }  
  567.             %extraAmmo = 0 ;
  568.             if (Player::getMountedItem(%client,$BackpackSlot) == ammopack && $AmmoPackMax[%item] != "") 
  569.                 %extraAmmo = $AmmoPackMax[%item];
  570.             // Make sure it doesn't exceed carrying capacity
  571.             %count = Player::getItemCount(%player,%item);
  572.             if (%count + %delta > $ItemMax[%armor, %item] + %extraAmmo) 
  573.                 %delta = ($ItemMax[%armor, %item] + %extraAmmo) - %count;
  574.             if (%delta > 0) {
  575.                 Player::incItemCount(%player,%item,%delta);
  576.                 if (%count == 0 && $AutoUse[%item]) 
  577.                     Player::useItem(%player,%item);
  578.                 Client::sendMessage(%client,0,"You received " @ %delta @ " " @ %item);
  579.                 return %delta;
  580.             }
  581.         }
  582.    }
  583.     return 0;
  584. }
  585.  
  586.  
  587. //----------------------------------------------------------------------------
  588. // Default Item object methods
  589.  
  590. $PickupSound[Ammo] = "SoundPickupAmmo";
  591. $PickupSound[Weapon] = "SoundPickupWeapon";
  592. $PickupSound[Backpack] = "SoundPickupBackpack";
  593. $PickupSound[Repair] = "SoundPickupHealth";
  594.  
  595. function Item::playPickupSound(%this)
  596. {
  597.     %item = Item::getItemData(%this);
  598.     %sound = $PickupSound[%item.className];
  599.     if (%sound != "")  
  600.         playSound(%sound,GameBase::getPosition(%this));
  601.     else {
  602.         // Generic item sound
  603.         playSound(SoundPickupItem,GameBase::getPosition(%this));
  604.     }
  605. }    
  606.  
  607. function Item::respawn(%this)
  608. {
  609.     // If the item is rotating we respawn it,
  610.     if (Item::isRotating(%this)) {
  611.         Item::hide(%this,True);
  612.         schedule("Item::hide(" @ %this @ ",false); GameBase::startFadeIn(" @ %this @ ");",$ItemRespawnTime,%this);
  613.     }
  614.     else { 
  615.         deleteObject(%this);
  616.     }
  617. }    
  618.  
  619. function Item::onAdd(%this)
  620. {
  621. }
  622.  
  623. function Item::onCollision(%this,%object)
  624. {
  625.     if (getObjectType(%object) == "Player") {
  626.         %item = Item::getItemData(%this);
  627.         %count = Player::getItemCount(%object,%item);
  628.         if (Item::giveItem(%object,%item,Item::getCount(%this))) {
  629.             Item::playPickupSound(%this);
  630.             Item::respawn(%this);
  631.         }
  632.     }
  633. }
  634.  
  635.  
  636. //----------------------------------------------------------------------------
  637. // Default Inventory methods
  638.  
  639. function Item::onMount(%player,%item)
  640. {
  641. }
  642.  
  643. function Item::onUnmount(%player,%item)
  644. {
  645. }
  646.  
  647. function Item::onUse(%player,%item)
  648. {
  649.     //echo("Item used: ",%player," ",%item);
  650.     Player::mountItem(%player,%item,$DefaultSlot);
  651. }
  652.  
  653. function Item::pop(%item)
  654. {
  655.      GameBase::startFadeOut(%item);
  656.    schedule("deleteObject(" @ %item @ ");",2.5, %item);
  657. }
  658.  
  659. function Item::onDrop(%player,%item)
  660. {
  661.     if($matchStarted) {
  662.         if(%item.className != Armor) {
  663.             //echo("Item dropped: ",%player," ",%item);
  664.             %obj = newObject("","Item",%item,1,false);
  665.                 schedule("Item::Pop(" @ %obj @ ");", $ItemPopTime, %obj);
  666.                addToSet("MissionCleanup", %obj);
  667.             if (Player::isDead(%player)) 
  668.                 GameBase::throw(%obj,%player,10,true);
  669.             else {
  670.                 GameBase::throw(%obj,%player,15,false);
  671.                 Item::playPickupSound(%obj);
  672.             }
  673.             Player::decItemCount(%player,%item,1);
  674.             return %obj;
  675.         }
  676.     }
  677. }
  678.  
  679. function Item::onDeploy(%player,%item,%pos)
  680. {
  681. }
  682.  
  683.  
  684. //----------------------------------------------------------------------------
  685. // Flags
  686. //----------------------------------------------------------------------------
  687.  
  688. function Flag::onUse(%player,%item)
  689. {
  690.     Player::mountItem(%player,%item,$FlagSlot);
  691. }
  692.  
  693.  
  694. //----------------------------------------------------------------------------
  695.  
  696. ItemImageData FlagImage
  697. {
  698.     shapeFile = "flag";
  699.     mountPoint = 2;
  700.     mountOffset = { 0, 0, -0.35 };
  701.     mountRotation = { 0, 0, 0 };
  702.  
  703.     lightType = 2;   // Pulsing
  704.     lightRadius = 4;
  705.     lightTime = 1.5;
  706.     lightColor = { 1, 1, 1};
  707. };
  708.  
  709. ItemData Flag
  710. {
  711.     description = "Flag";
  712.     shapeFile = "flag";
  713.     imageType = FlagImage;
  714.     showInventory = false;
  715.     shadowDetailMask = 4;
  716.  
  717.     lightType = 2;   // Pulsing
  718.     lightRadius = 4;
  719.     lightTime = 1.5;
  720.     lightColor = { 1, 1, 1 };
  721. };
  722.  
  723. ItemData RaceFlag
  724. {
  725.     description = "Race Flag";
  726.     shapeFile = "flag";
  727.     imageType = FlagImage;
  728.     showInventory = false;
  729.     shadowDetailMask = 4;
  730.  
  731.     lightType = 2;   // Pulsing
  732.     lightRadius = 4;
  733.     lightTime = 1.5;
  734.     lightColor = { 1, 1, 1 };
  735. };
  736.  
  737. //----------------------------------------------------------------------------
  738. // Armors
  739. //----------------------------------------------------------------------------
  740.  
  741. ItemData LightArmor
  742. {
  743.    heading = "aArmor";
  744.     description = "Light Armor";
  745.     className = "Armor";
  746.     price = 175;
  747. };
  748.  
  749. ItemData MediumArmor
  750. {
  751.    heading = "aArmor";
  752.     description = "Medium Armor";
  753.     className = "Armor";
  754.     price = 250;
  755. };
  756.  
  757. ItemData HeavyArmor
  758. {
  759.    heading = "aArmor";
  760.     description = "Heavy Armor";
  761.     className = "Armor";
  762.     price = 400;
  763. };
  764.  
  765. //----------------------------------------------------------------------------
  766. // Vehicles
  767. //----------------------------------------------------------------------------
  768.  
  769. ItemData ScoutVehicle
  770. {
  771.     description = "Scout";
  772.     className = "Vehicle";
  773.    heading = "aVehicle";
  774.     price = 600;
  775. };
  776.  
  777. ItemData LAPCVehicle
  778. {
  779.     description = "LPC";
  780.     className = "Vehicle";
  781.    heading = "aVehicle";
  782.     price = 675;
  783. };
  784.  
  785. ItemData HAPCVehicle
  786. {
  787.     description = "HPC";
  788.     className = "Vehicle";
  789.    heading = "aVehicle";
  790.     price = 875;
  791. };
  792.  
  793.  
  794. //----------------------------------------------------------------------------
  795. // Tools, Weapons & ammo
  796. //----------------------------------------------------------------------------
  797.  
  798. ItemData Weapon
  799. {
  800.     description = "Weapon";
  801.     showInventory = false;
  802. };
  803.  
  804. function Weapon::onUse(%player,%item)
  805. {
  806.     %ammo = %item.imageType.ammoType;
  807.     if (%ammo == "") {
  808.         // Energy weapons dont have ammo types
  809.         Player::mountItem(%player,%item,$WeaponSlot);
  810.     }
  811.     else {
  812.         if (Player::getItemCount(%player,%ammo) > 0) 
  813.             Player::mountItem(%player,%item,$WeaponSlot);
  814.         else {
  815.             Client::sendMessage(Player::getClient(%player),0,
  816.             strcat(%item.description," has no ammo"));
  817.         }
  818.     }
  819. }
  820.  
  821.  
  822. //----------------------------------------------------------------------------
  823.  
  824. ItemData Tool
  825. {
  826.     description = "Tool";
  827.     showInventory = false;
  828. };
  829.  
  830. function Tool::onUse(%player,%item)
  831. {
  832.     Player::mountItem(%player,%item,$ToolSlot);
  833. }
  834.  
  835.  
  836.  
  837. //----------------------------------------------------------------------------
  838.  
  839. ItemData Ammo
  840. {
  841.     description = "Ammo";
  842.     showInventory = false;
  843. };
  844.  
  845. function Ammo::onDrop(%player,%item)
  846. {
  847.     if($matchStarted) {
  848.         %count = Player::getItemCount(%player,%item);
  849.         %delta = $SellAmmo[%item];
  850.         if(%count <= %delta) { 
  851.             if( %item == BulletAmmo || (Player::getMountedItem(%player,$WeaponSlot)).imageType.ammoType != %item)
  852.                 %delta = %count;
  853.             else 
  854.                 %delta = %count - 1;
  855.  
  856.         }
  857.         if(%delta > 0) {
  858.             %obj = newObject("","Item",%item,%delta,false);
  859.           schedule("Item::Pop(" @ %obj @ ");", $ItemPopTime, %obj);
  860.  
  861.           addToSet("MissionCleanup", %obj);
  862.             GameBase::throw(%obj,%player,20,false);
  863.             Item::playPickupSound(%obj);
  864.             Player::decItemCount(%player,%item,%delta);
  865.         }
  866.     }
  867. }    
  868.  
  869. //----------------------------------------------------------------------------
  870.  
  871. ItemImageData BlasterImage
  872. {
  873.    shapeFile  = "energygun";
  874.     mountPoint = 0;
  875.  
  876.     weaponType = 0; // Single Shot
  877.     reloadTime = 0;
  878.     fireTime = 0.3;
  879.     minEnergy = 5;
  880.     maxEnergy = 6;
  881.  
  882.     projectileType = BlasterBolt;
  883.     accuFire = true;
  884.  
  885.     sfxFire = SoundFireBlaster;
  886.     sfxActivate = SoundPickUpWeapon;
  887. };
  888.  
  889. ItemData Blaster
  890. {
  891.    heading = "bWeapons";
  892.     description = "Blaster";
  893.     className = "Weapon";
  894.    shapeFile  = "energygun";
  895.     hudIcon = "blaster";
  896.     shadowDetailMask = 4;
  897.     imageType = BlasterImage;
  898.     price = 85;
  899.     showWeaponBar = true;
  900. };
  901.  
  902.  
  903. //----------------------------------------------------------------------------
  904.  
  905. ItemData BulletAmmo
  906. {
  907.     description = "Bullet";
  908.     className = "Ammo";
  909.     shapeFile = "ammo1";
  910.    heading = "xAmmunition";
  911.     shadowDetailMask = 4;
  912.     price = 1;
  913. };
  914.  
  915. ItemImageData ChaingunImage
  916. {
  917.     shapeFile = "chaingun";
  918.     mountPoint = 0;
  919.  
  920.     weaponType = 1; // Spinning
  921.     reloadTime = 0;
  922.     spinUpTime = 0.5;
  923.     spinDownTime = 3;
  924.     fireTime = 0.2;
  925.  
  926.     ammoType = BulletAmmo;
  927.     projectileType = ChaingunBullet;
  928.     accuFire = false;
  929.  
  930.     lightType = 3;  // Weapon Fire
  931.     lightRadius = 3;
  932.     lightTime = 1;
  933.     lightColor = { 0.6, 1, 1 };
  934.  
  935.     sfxFire = SoundFireChaingun;
  936.     sfxActivate = SoundPickUpWeapon;
  937.     sfxSpinUp = SoundSpinUp;
  938.     sfxSpinDown = SoundSpinDown;
  939. };
  940.  
  941. ItemData Chaingun
  942. {
  943.     description = "Chaingun";
  944.     className = "Weapon";
  945.     shapeFile = "chaingun";
  946.     hudIcon = "chain";
  947.    heading = "bWeapons";
  948.     shadowDetailMask = 4;
  949.     imageType = ChaingunImage;
  950.     price = 125;
  951.     showWeaponBar = true;
  952. };
  953.  
  954.  
  955. //----------------------------------------------------------------------------
  956.  
  957. ItemData PlasmaAmmo
  958. {
  959.     description = "Plasma Bolt";
  960.    heading = "xAmmunition";
  961.     className = "Ammo";
  962.     shapeFile = "plasammo";
  963.     shadowDetailMask = 4;
  964.     price = 2;
  965. };
  966.  
  967. ItemImageData PlasmaGunImage
  968. {
  969.     shapeFile = "plasma";
  970.     mountPoint = 0;
  971.  
  972.     weaponType = 0; // Single Shot
  973.     ammoType = PlasmaAmmo;
  974.     projectileType = PlasmaBolt;
  975.     accuFire = true;
  976.     reloadTime = 0.1;
  977.     fireTime = 0.5;
  978.  
  979.     lightType = 3;  // Weapon Fire
  980.     lightRadius = 3;
  981.     lightTime = 1;
  982.     lightColor = { 1, 1, 0.2 };
  983.  
  984.     sfxFire = SoundFirePlasma;
  985.     sfxActivate = SoundPickUpWeapon;
  986.     sfxReload = SoundDryFire;
  987. };
  988.  
  989. ItemData PlasmaGun
  990. {
  991.     description = "Plasma Gun";
  992.     className = "Weapon";
  993.     shapeFile = "plasma";
  994.     hudIcon = "plasma";
  995.    heading = "bWeapons";
  996.     shadowDetailMask = 4;
  997.     imageType = PlasmaGunImage;
  998.     price = 175;
  999.     showWeaponBar = true;
  1000. };
  1001.  
  1002.  
  1003. //----------------------------------------------------------------------------
  1004.  
  1005. ItemData GrenadeAmmo
  1006. {
  1007.     description = "GrenadeAmmo";
  1008.     className = "Ammo";
  1009.     shapeFile = "grenammo";
  1010.    heading = "xAmmunition";
  1011.     shadowDetailMask = 4;
  1012.     price = 2;
  1013. };
  1014.  
  1015. ItemImageData GrenadeLauncherImage
  1016. {
  1017.     shapeFile = "grenadeL";
  1018.     mountPoint = 0;
  1019.  
  1020.     weaponType = 0; // Single Shot
  1021.     ammoType = GrenadeAmmo;
  1022.     projectileType = GrenadeShell;
  1023.     accuFire = false;
  1024.     reloadTime = 0.5;
  1025.     fireTime = 0.5;
  1026.  
  1027.     lightType = 3;  // Weapon Fire
  1028.     lightRadius = 3;
  1029.     lightTime = 1;
  1030.     lightColor = { 0.6, 1, 1.0 };
  1031.  
  1032.     sfxFire = SoundFireGrenade;
  1033.     sfxActivate = SoundPickUpWeapon;
  1034.     sfxReload = SoundDryFire;
  1035. };
  1036.  
  1037. ItemData GrenadeLauncher
  1038. {
  1039.     description = "Grenade Launcher";
  1040.     className = "Weapon";
  1041.     shapeFile = "grenadeL";
  1042.     hudIcon = "grenade";
  1043.    heading = "bWeapons";
  1044.     shadowDetailMask = 4;
  1045.     imageType = GrenadeLauncherImage;
  1046.     price = 150;
  1047.     showWeaponBar = true;
  1048. };
  1049.  
  1050.  
  1051. //----------------------------------------------------------------------------
  1052.  
  1053. ItemData MortarAmmo
  1054. {
  1055.     description = "MortarAmmo";
  1056.     className = "Ammo";
  1057.    heading = "xAmmunition";
  1058.     shapeFile = "mortarammo";
  1059.     shadowDetailMask = 4;
  1060.     price = 5;
  1061. };
  1062.  
  1063. ItemImageData MortarImage
  1064. {
  1065.     shapeFile = "mortargun";
  1066.     mountPoint = 0;
  1067.  
  1068.     weaponType = 0; // Single Shot
  1069.     ammoType = MortarAmmo;
  1070.     projectileType = MortarShell;
  1071.     accuFire = false;
  1072.     reloadTime = 0.5;
  1073.     fireTime = 2.0;
  1074.  
  1075.     lightType = 3;  // Weapon Fire
  1076.     lightRadius = 3;
  1077.     lightTime = 1;
  1078.     lightColor = { 0.6, 1, 1.0 };
  1079.  
  1080.     sfxFire = SoundFireMortar;
  1081.     sfxActivate = SoundPickUpWeapon;
  1082.     sfxReload = SoundMortarReload;
  1083.     sfxReady = SoundMortarIdle;
  1084. };
  1085.  
  1086. ItemData Mortar
  1087. {
  1088.     description = "Mortar";
  1089.     className = "Weapon";
  1090.     shapeFile = "mortargun";
  1091.     hudIcon = "mortar";
  1092.    heading = "bWeapons";
  1093.     shadowDetailMask = 4;
  1094.     imageType = MortarImage;
  1095.     price = 375;
  1096.     showWeaponBar = true;
  1097. };
  1098.  
  1099.  
  1100. //----------------------------------------------------------------------------
  1101.  
  1102. ItemData DiscAmmo
  1103. {
  1104.     description = "Disc";
  1105.     className = "Ammo";
  1106.     shapeFile = "discammo";
  1107.    heading = "xAmmunition";
  1108.     shadowDetailMask = 4;
  1109.     price = 2;
  1110. };
  1111.  
  1112. ItemImageData DiscLauncherImage
  1113. {
  1114.     shapeFile = "disc";
  1115.     mountPoint = 0;
  1116.  
  1117.     weaponType = 3; // DiscLauncher
  1118.     ammoType = DiscAmmo;
  1119.     projectileType = DiscShell;
  1120.     accuFire = true;
  1121.     reloadTime = 0.25;
  1122.     fireTime = 1.25;
  1123.     spinUpTime = 0.25;
  1124.  
  1125.     sfxFire = SoundFireDisc;
  1126.     sfxActivate = SoundPickUpWeapon;
  1127.     sfxReload = SoundDiscReload;
  1128.     sfxReady = SoundDiscSpin;
  1129. };
  1130.  
  1131. ItemData DiscLauncher
  1132. {
  1133.     description = "Disc Launcher";
  1134.     className = "Weapon";
  1135.     shapeFile = "disc";
  1136.     hudIcon = "disk";
  1137.    heading = "bWeapons";
  1138.     shadowDetailMask = 4;
  1139.     imageType = DiscLauncherImage;
  1140.     price = 150;
  1141.     showWeaponBar = true;
  1142. };
  1143.  
  1144.  
  1145. //----------------------------------------------------------------------------
  1146.  
  1147. ItemImageData LaserRifleImage
  1148. {
  1149.     shapeFile = "sniper";
  1150.     mountPoint = 0;
  1151.  
  1152.     weaponType = 0; // Single Shot
  1153.     projectileType = SniperLaser;
  1154.     accuFire = true;
  1155.     reloadTime = 0.1;
  1156.     fireTime = 0.5;
  1157.     minEnergy = 10;
  1158.     maxEnergy = 60;
  1159.  
  1160.     lightType = 3;  // Weapon Fire
  1161.     lightRadius = 2;
  1162.     lightTime = 1;
  1163.     lightColor = { 1, 0, 0 };
  1164.  
  1165.     sfxFire = SoundFireLaser;
  1166.     sfxActivate = SoundPickUpWeapon;
  1167. };
  1168.  
  1169. ItemData LaserRifle
  1170. {
  1171.     description = "Laser Rifle";
  1172.     className = "Weapon";
  1173.     shapeFile = "sniper";
  1174.     hudIcon = "sniper";
  1175.    heading = "bWeapons";
  1176.     shadowDetailMask = 4;
  1177.     imageType = LaserRifleImage;
  1178.     price = 200;
  1179.     showWeaponBar = true;
  1180. };
  1181.  
  1182. function LaserRifle::onUse(%player,%item)
  1183. {
  1184.     if(Player::getMountedItem(%player,$BackpackSlot) == EnergyPack)
  1185.         Weapon::onUse(%player,%item);
  1186.     else
  1187.         Client::sendMessage(Player::getClient(%player),0,
  1188.             "Must have an Energy Pack to use Laser Rifle."); 
  1189. }
  1190.  
  1191. //----------------------------------------------------------------------------
  1192.  
  1193. ItemImageData TargetingLaserImage
  1194. {
  1195.     shapeFile = "paintgun";
  1196.     mountPoint = 0;
  1197.  
  1198.     weaponType = 2; // Sustained
  1199.     projectileType = targetLaser;
  1200.     accuFire = true;
  1201.     minEnergy = 5;
  1202.     maxEnergy = 15;
  1203.     reloadTime = 1.0;
  1204.  
  1205.     lightType   = 3;  // Weapon Fire
  1206.     lightRadius = 1;
  1207.     lightTime   = 1;
  1208.     lightColor  = { 0.25, 1, 0.25 };
  1209.  
  1210.     sfxFire     = SoundFireTargetingLaser;
  1211.     sfxActivate = SoundPickUpWeapon;
  1212. };
  1213.  
  1214. ItemData TargetingLaser
  1215. {
  1216.     description   = "Targeting Laser";
  1217.     className     = "Tool";
  1218.     shapeFile     = "paintgun";
  1219.     hudIcon       = "targetlaser";
  1220.    heading = "bWeapons";
  1221.     shadowDetailMask = 4;
  1222.     imageType     = TargetingLaserImage;
  1223.     price         = 50;
  1224.     showWeaponBar = false;
  1225. };
  1226.  
  1227. //------------------------------------------------------------------------------
  1228.  
  1229. ItemImageData EnergyRifleImage
  1230. {
  1231.     shapeFile = "shotgun";
  1232.    mountPoint = 0;
  1233.  
  1234.    weaponType = 2;  // Sustained
  1235.     projectileType = lightningCharge;
  1236.    minEnergy = 3;
  1237.    maxEnergy = 11;  // Energy used/sec for sustained weapons
  1238.     reloadTime = 0.2;
  1239.                         
  1240.    lightType = 3;  // Weapon Fire
  1241.    lightRadius = 2;
  1242.    lightTime = 1;
  1243.    lightColor = { 0.25, 0.25, 0.85 };
  1244.  
  1245.    sfxActivate = SoundPickUpWeapon;
  1246.    sfxFire     = SoundELFIdle;
  1247. };
  1248.  
  1249. ItemData EnergyRifle
  1250. {
  1251.    description = "ELF Gun";
  1252.     shapeFile = "shotgun";
  1253.     hudIcon = "energyRifle";
  1254.    className = "Weapon";
  1255.    heading = "bWeapons";
  1256.    shadowDetailMask = 4;
  1257.    imageType = EnergyRifleImage;
  1258.     showWeaponBar = true;
  1259.    price = 500;
  1260. };
  1261.  
  1262. //----------------------------------------------------------------------------
  1263.  
  1264. ItemImageData RepairGunImage
  1265. {
  1266.     shapeFile = "repairgun";
  1267.     mountPoint = 0;
  1268.  
  1269.     weaponType = 2;  // Sustained
  1270.     projectileType = RepairBolt;
  1271.     minEnergy  = 3;
  1272.     maxEnergy = 10;  // Energy used/sec for sustained weapons
  1273.  
  1274.     lightType   = 3;  // Weapon Fire
  1275.     lightRadius = 1;
  1276.     lightTime   = 1;
  1277.     lightColor  = { 0.25, 1, 0.25 };
  1278.  
  1279.     sfxActivate = SoundPickUpWeapon;
  1280.     sfxFire = SoundRepairItem;
  1281. };
  1282.  
  1283. ItemData RepairGun
  1284. {
  1285.     description = "Repair Gun";
  1286.     shapeFile = "repairgun";
  1287.     className = "Weapon";
  1288.     shadowDetailMask = 4;
  1289.     imageType = RepairGunImage;
  1290.     showInventory = false;
  1291.     price = 125;
  1292. };
  1293.  
  1294. function RepairGun::onMount(%player,%imageSlot)
  1295. {
  1296.     Player::trigger(%player,$BackpackSlot,true);
  1297. }
  1298.  
  1299. function RepairGun::onUnmount(%player,%imageSlot)
  1300. {
  1301.     Player::trigger(%player,$BackpackSlot,false);
  1302. }
  1303.  
  1304.  
  1305. //----------------------------------------------------------------------------
  1306. // Backpacks
  1307. //----------------------------------------------------------------------------
  1308.  
  1309. //----------------------------------------------------------------------------
  1310.  
  1311. ItemData Backpack
  1312. {                
  1313.     description = "Backpack";
  1314.     showInventory = false;
  1315. };
  1316.  
  1317. function Backpack::onUse(%player,%item)
  1318. {
  1319.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  1320.         Player::mountItem(%player,%item,$BackpackSlot);
  1321.     }
  1322.     else {
  1323.         Player::trigger(%player,$BackpackSlot);
  1324.     }
  1325. }
  1326.  
  1327.  
  1328. //----------------------------------------------------------------------------
  1329.  
  1330. ItemImageData DeployableInvPackImage
  1331. {
  1332.     shapeFile = "invent_remote";
  1333.     mountPoint = 2;
  1334.     mountOffset = { 0, -0.12, -0.3 };
  1335.     mountRotation = { 0, 0, 0 };
  1336.     mass = 2.5;
  1337.     firstPerson = false;
  1338. };
  1339.  
  1340. ItemData DeployableInvPack
  1341. {
  1342.     description = "Inventory Station";
  1343.     shapeFile = "invent_remote";
  1344.     className = "Backpack";
  1345.    heading = "dDeployables";
  1346.     shadowDetailMask = 4    ;
  1347.     imageType = DeployableInvPackImage;
  1348.     mass = 2.0;
  1349.     elasticity = 0.2;
  1350.     price = $RemoteInvEnergy + 200;
  1351.     hudIcon = "deployable";
  1352.     showWeaponBar = true;
  1353.     hiliteOnActive = true;
  1354. };
  1355.  
  1356.  
  1357. function DeployableInvPack::onUse(%player,%item)
  1358. {
  1359.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  1360.         Player::mountItem(%player,%item,$BackpackSlot);
  1361.     }
  1362.     else {
  1363.         Player::deployItem(%player,%item);
  1364.     }
  1365. }
  1366.  
  1367. function DeployableInvPack::onDeploy(%player,%item,%pos)
  1368. {
  1369.     if (DeployableInvPack::deployShape(%player,%item)) {
  1370.         Player::decItemCount(%player,%item);
  1371.     }
  1372. }    
  1373.  
  1374. function DeployableInvPack::deployShape(%player,%item)
  1375. {
  1376.     %client = Player::getClient(%player);
  1377.     if($TeamItemCount[GameBase::getTeam(%player) @ %item] < $TeamItemMax[%item]) {
  1378.         if (GameBase::getLOSInfo(%player,3)) {
  1379.             %obj = getObjectType($los::object);
  1380.             if (%obj == "SimTerrain" || %obj == "InteriorShape") {
  1381.                 if (Vector::dot($los::normal,"0 0 1") > 0.7) {
  1382.                     if(checkDeployArea(%client,$los::position)) {
  1383.                         %inv = newObject("ammounit_remote","StaticShape","DeployableInvStation",true);
  1384.                        addToSet("MissionCleanup", %inv);
  1385.                         %rot = GameBase::getRotation(%player); 
  1386.                         GameBase::setTeam(%inv,GameBase::getTeam(%player));
  1387.                         GameBase::setPosition(%inv,$los::position);
  1388.                         GameBase::setRotation(%inv,%rot);
  1389.                         Gamebase::setMapName(%inv,%name);
  1390.                         Client::sendMessage(%client,0,"Inventory Station deployed");
  1391.                         playSound(SoundPickupBackpack,$los::position);
  1392.                         $TeamItemCount[GameBase::getTeam(%inv) @ "DeployableInvPack"]++;
  1393.                         return true;
  1394.                     }
  1395.                 }
  1396.                 else {
  1397.                     Client::sendMessage(%client,0,"Can only deploy on flat surfaces");
  1398.                 }
  1399.             }
  1400.             else {
  1401.                 Client::sendMessage(%client,0,"Can only deploy on terrain or buildings");
  1402.             }
  1403.         }
  1404.         else {
  1405.             Client::sendMessage(%client,0,"Deploy position out of range");
  1406.         }
  1407.     }
  1408.     else                                                                                          
  1409.          Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %item.description @ "s");
  1410.     return false;
  1411. }
  1412.  
  1413.  
  1414. //----------------------------------------------------------------------------
  1415.  
  1416. ItemImageData DeployableAmmoPackImage
  1417. {
  1418.     shapeFile = "ammounit_remote";
  1419.     mountPoint = 2;
  1420.     mountOffset = { 0, -0.1, -0.3 };
  1421.     mountRotation = { 0, 0, 0 };
  1422.     mass = 1.0;
  1423.     firstPerson = false;
  1424. };
  1425.  
  1426. ItemData DeployableAmmoPack
  1427. {
  1428.     description = "Ammo Station";
  1429.     shapeFile = "ammounit_remote";
  1430.     className = "Backpack";
  1431.    heading = "dDeployables";
  1432.     shadowDetailMask = 4;
  1433.     imageType = DeployableAmmoPackImage;
  1434.     mass = 2.0;
  1435.     elasticity = 0.2;
  1436.     price = $RemoteAmmoEnergy;
  1437.     hudIcon = "deployable";
  1438.     showWeaponBar = true;
  1439.     hiliteOnActive = true;
  1440. };
  1441.  
  1442.  
  1443. function DeployableAmmoPack::onUse(%player,%item)
  1444. {
  1445.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  1446.         Player::mountItem(%player,%item,$BackpackSlot);
  1447.     }
  1448.     else {
  1449.         Player::deployItem(%player,%item);
  1450.     }
  1451. }
  1452.  
  1453. function DeployableAmmoPack::onDeploy(%player,%item,%pos)
  1454. {
  1455.     if (DeployableAmmoPack::deployShape(%player,%item)) {
  1456.         Player::decItemCount(%player,%item);
  1457.     }
  1458. }    
  1459.  
  1460. function DeployableAmmoPack::deployShape(%player,%item)
  1461. {
  1462.     %client = Player::getClient(%player);
  1463.     if($TeamItemCount[GameBase::getTeam(%player) @ %item] < $TeamItemMax[%item]) {
  1464.         if (GameBase::getLOSInfo(%player,3)) {
  1465.             %obj = getObjectType($los::object);
  1466.             if (%obj == "SimTerrain" || %obj == "InteriorShape") {
  1467.                 if (Vector::dot($los::normal,"0 0 1") > 0.7) {
  1468.                     if(checkDeployArea(%client,$los::position)) {
  1469.                         %inv = newObject("ammounit_remote","StaticShape","DeployableAmmoStation",true);
  1470.                     addToSet("MissionCleanup", %inv);
  1471.                         %rot = GameBase::getRotation(%player); 
  1472.                         GameBase::setTeam(%inv,GameBase::getTeam(%player));
  1473.                         GameBase::setPosition(%inv,$los::position);
  1474.                         GameBase::setRotation(%inv,%rot);
  1475.                         Gamebase::setMapName(%inv,%name);
  1476.                         Client::sendMessage(%client,0,"Ammo Station deployed");
  1477.                         playSound(SoundPickupBackpack,$los::position);
  1478.                         $TeamItemCount[GameBase::getTeam(%inv) @ "DeployableAmmoPack"]++;
  1479.                         return true;
  1480.                     }
  1481.                 }
  1482.                 else 
  1483.                     Client::sendMessage(%client,0,"Can only deploy on flat surfaces");
  1484.             }
  1485.             else 
  1486.                 Client::sendMessage(%client,0,"Can only deploy on terrain or buildings");
  1487.         }
  1488.         else 
  1489.             Client::sendMessage(%client,0,"Deploy position out of range");
  1490.     }
  1491.     else                                                                                          
  1492.          Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %item.description @ "s");
  1493.     return false;
  1494. }
  1495.  
  1496.  
  1497. //----------------------------------------------------------------------------
  1498.  
  1499. ItemImageData EnergyPackImage
  1500. {
  1501.     shapeFile = "jetPack";
  1502.     weaponType = 2;  // Sustained
  1503.  
  1504.     mountPoint = 2;
  1505.     mountOffset = { 0, -0.1, 0 };
  1506.  
  1507.     minEnergy = -1;
  1508.      maxEnergy = -3;
  1509.     firstPerson = false;
  1510. };
  1511.  
  1512. ItemData EnergyPack
  1513. {
  1514.     description = "Energy Pack";
  1515.     shapeFile = "jetPack";
  1516.     className = "Backpack";
  1517.    heading = "cBackpacks";
  1518.     shadowDetailMask = 4;
  1519.     imageType = EnergyPackImage;
  1520.     price = 150;
  1521.     hudIcon = "energypack";
  1522.     showWeaponBar = true;
  1523.     hiliteOnActive = true;
  1524. };
  1525.  
  1526. function EnergyPack::onMount(%player,%item)
  1527. {
  1528.     Player::trigger(%player,$BackpackSlot,true);
  1529. }
  1530.  
  1531. function EnergyPack::onUnmount(%player,%item)
  1532. {
  1533.     if (Player::getMountedItem(%player,$WeaponSlot) == LaserRifle) 
  1534.         Player::unmountItem(%player,$WeaponSlot);
  1535. }
  1536.  
  1537. //----------------------------------------------------------------------------
  1538.  
  1539. ItemImageData RepairPackImage
  1540. {
  1541.     shapeFile = "armorPack";
  1542.     mountPoint = 2;
  1543.     weaponType = 2;  // Sustained
  1544.    minEnergy = 0;
  1545.     maxEnergy = 0;   // Energy used/sec for sustained weapons
  1546.       mountOffset = { 0, -0.05, 0 };
  1547.       mountRotation = { 0, 0, 0 };
  1548.     firstPerson = false;
  1549. };
  1550.  
  1551. ItemData RepairPack
  1552. {
  1553.     description = "Repair Pack";
  1554.     shapeFile = "armorPack";
  1555.     className = "Backpack";
  1556.    heading = "cBackpacks";
  1557.     shadowDetailMask = 4;
  1558.     imageType = RepairPackImage;
  1559.     price = 125;
  1560.     hudIcon = "repairpack";
  1561.     showWeaponBar = true;
  1562.     hiliteOnActive = true;
  1563. };
  1564.  
  1565. function RepairPack::onUnmount(%player,%item)
  1566. {
  1567.     if (Player::getMountedItem(%player,$WeaponSlot) == RepairGun) {
  1568.         Player::unmountItem(%player,$WeaponSlot);
  1569.     }
  1570. }
  1571.  
  1572. function RepairPack::onUse(%player,%item)
  1573. {
  1574.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  1575.         Player::mountItem(%player,%item,$BackpackSlot);
  1576.     }
  1577.     else {
  1578.         Player::mountItem(%player,RepairGun,$WeaponSlot);
  1579.     }
  1580. }
  1581.  
  1582. function RepairPack::onDrop(%player,%item)
  1583. {
  1584.     if($matchStarted) {
  1585.         %mounted = Player::getMountedItem(%player,$WeaponSlot);
  1586.         if (%mounted == RepairGun) {
  1587.             Player::unmountItem(%player,$WeaponSlot);
  1588.         }
  1589.         else {
  1590.             // Remount the existing weapon to make sure the RepairGun
  1591.             // is not on the delayed mount "stack".
  1592.             Player::mountItem(%player,%mounted,$WeaponSlot);
  1593.         }
  1594.         Item::onDrop(%player,%item);
  1595.     }
  1596. }    
  1597.  
  1598.  
  1599. //----------------------------------------------------------------------------
  1600.  
  1601. ItemImageData ShieldPackImage
  1602. {
  1603.     shapeFile = "shieldPack";
  1604.     mountPoint = 2;
  1605.     weaponType = 2;  // Sustained
  1606.     minEnergy = 4;
  1607.     maxEnergy = 9;   // Energy/sec for sustained weapons
  1608.     sfxFire = SoundShieldOn;
  1609.     firstPerson = false;
  1610. };
  1611.  
  1612. ItemData ShieldPack
  1613. {
  1614.     description = "Shield Pack";
  1615.     shapeFile = "shieldPack";
  1616.     className = "Backpack";
  1617.    heading = "cBackpacks";
  1618.     shadowDetailMask = 4;
  1619.     imageType = ShieldPackImage;
  1620.     price = 175;
  1621.     hudIcon = "shieldpack";
  1622.     showWeaponBar = true;
  1623.     hiliteOnActive = true;
  1624. };
  1625.  
  1626. function ShieldPackImage::onActivate(%player,%imageSlot)
  1627. {
  1628.     Client::sendMessage(Player::getClient(%player),0,"Shield On");
  1629.     %player.shieldStrength = 0.012;
  1630. }
  1631.  
  1632. function ShieldPackImage::onDeactivate(%player,%imageSlot)
  1633. {
  1634.     Client::sendMessage(Player::getClient(%player),0,"Shield Off");
  1635.     Player::trigger(%player,$BackpackSlot,false);
  1636.     %player.shieldStrength = 0;
  1637. }
  1638.  
  1639.  
  1640. //----------------------------------------------------------------------------
  1641.  
  1642. ItemImageData SensorJammerPackImage
  1643. {
  1644.     shapeFile = "sensorjampack";
  1645.     mountPoint = 2;
  1646.     weaponType = 2;  // Sustained
  1647.     maxEnergy = 10;  // Energy used/sec for sustained weapons
  1648.     sfxFire = SoundJammerOn;
  1649.       mountOffset = { 0, -0.05, 0 };
  1650.       mountRotation = { 0, 0, 0 };
  1651.     firstPerson = false;
  1652. };
  1653.  
  1654. ItemData SensorJammerPack
  1655. {
  1656.     description = "Sensor Jammer Pack";
  1657.     shapeFile = "sensorjampack";
  1658.     className = "Backpack";
  1659.    heading = "cBackpacks";
  1660.     shadowDetailMask = 4;
  1661.     imageType = SensorJammerPackImage;
  1662.     price = 200;
  1663.     hudIcon = "sensorjamerpack";
  1664.     showWeaponBar = true;
  1665.     hiliteOnActive = true;
  1666. };
  1667.  
  1668. function SensorJammerPackImage::onActivate(%player,%imageSlot)
  1669. {
  1670.     Client::sendMessage(Player::getClient(%player),0,"Sensor Jammer On");
  1671.     %rate = Player::getSensorSupression(%player) + 20;
  1672.     Player::setSensorSupression(%player,%rate);
  1673. }
  1674.  
  1675. function SensorJammerPackImage::onDeactivate(%player,%imageSlot)
  1676. {
  1677.     Client::sendMessage(Player::getClient(%player),0,"Sensor Jammer Off");
  1678.     %rate = Player::getSensorSupression(%player) - 20;
  1679.     Player::setSensorSupression(%player,%rate);
  1680.     Player::trigger(%player,$BackpackSlot,false);
  1681. }
  1682.  
  1683.  
  1684. //----------------------------------------------------------------------------
  1685.  
  1686. ItemImageData MotionSensorPackImage
  1687. {
  1688.     shapeFile = "sensor_small";
  1689.     mountPoint = 2;
  1690.     mountOffset = { 0, 0, 0.1 };
  1691.     mountRotation = { 1.57, 0, 0 };
  1692.     firstPerson = false;
  1693. };
  1694.  
  1695. ItemData MotionSensorPack
  1696. {
  1697.     description = "Motion Sensor";
  1698.     shapeFile = "sensor_small";
  1699.     className = "Backpack";
  1700.    heading = "dDeployables";
  1701.     imageType = MotionSensorPackImage;
  1702.     shadowDetailMask = 4;
  1703.     mass = 2.0;
  1704.     elasticity = 0.2;
  1705.     price = 125;
  1706.     hudIcon = "deployable";
  1707.     showWeaponBar = true;
  1708.     hiliteOnActive = true;
  1709. };
  1710.  
  1711. function MotionSensorPack::onUse(%player,%item)
  1712. {
  1713.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  1714.         Player::mountItem(%player,%item,$BackpackSlot);
  1715.     }
  1716.     else {
  1717.         Player::deployItem(%player,%item);
  1718.     }
  1719. }
  1720.  
  1721. function MotionSensorPack::onDeploy(%player,%item,%pos)
  1722. {
  1723.     if (MotionSensorPack::deployShape(%player,%item)) {
  1724.         Player::decItemCount(%player,%item);
  1725.         $TeamItemCount[GameBase::getTeam(%player) @ "MotionSensorPack"]++;
  1726.     }
  1727. }
  1728.  
  1729. //    if (Item::deployShape(%player,"Motion Sensor",MotionSensor,%item)) {
  1730. function MotionSensorPack::deployShape(%player,%item)
  1731. {
  1732.      %client = Player::getClient(%player);
  1733.     if($TeamItemCount[GameBase::getTeam(%player) @ %item] < $TeamItemMax[%item]) {
  1734.         if (GameBase::getLOSInfo(%player,3)) {
  1735.             // GetLOSInfo sets the following globals:
  1736.             //     los::position
  1737.             //     los::normal
  1738.             //     los::object
  1739.             %obj = getObjectType($los::object);
  1740.             if (%obj == "SimTerrain" || %obj == "InteriorShape") {
  1741.                 // Try to stick it straight up or down, otherwise
  1742.                 // just use the surface normal
  1743.                 %prot = GameBase::getRotation(%player);
  1744.                 %zRot = getWord(%prot,2);
  1745.                 if (Vector::dot($los::normal,"0 0 1") > 0.6) {
  1746.                     %rot = "0 0 " @ %zRot;
  1747.                 }
  1748.                 else {
  1749.                     if (Vector::dot($los::normal,"0 0 -1") > 0.6) {
  1750.                         %rot = "3.14159 0 " @ %zRot;
  1751.                     }
  1752.                     else {
  1753.                         %rot = Vector::getRotation($los::normal);
  1754.                     }
  1755.                 }
  1756.                 if(checkDeployArea(%client,$los::position)) {
  1757.                     %mSensor = newObject("","Sensor",DeployableMotionSensor,true);
  1758.                  addToSet("MissionCleanup", %mSensor);
  1759.                     GameBase::setTeam(%mSensor,GameBase::getTeam(%player));
  1760.                     GameBase::setRotation(%mSensor,%rot);
  1761.                     GameBase::setPosition(%mSensor,$los::position);
  1762.                     Gamebase::setMapName(%mSensor,"Motion Sensor");
  1763.                     Client::sendMessage(%client,0,"Motion Sensor deployed");
  1764.                     playSound(SoundPickupBackpack,$los::position);
  1765.                     return true;
  1766.                 }
  1767.             }
  1768.             else {
  1769.                 Client::sendMessage(%client,0,"Can only deploy on terrain or buildings");
  1770.             }
  1771.         }
  1772.         else {
  1773.             Client::sendMessage(%client,0,"Deploy position out of range");        
  1774.         }
  1775.     }
  1776.     else                                                                                          
  1777.          Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %item.description @ "s");
  1778.     
  1779.     return false;
  1780. }
  1781.  
  1782. //----------------------------------------------------------------------------
  1783.  
  1784. ItemImageData AmmoPackImage
  1785. {
  1786.     shapeFile = "AmmoPack";
  1787.     mountPoint = 2;
  1788.    mountOffset = { 0, -0.03, 0 };
  1789. //   mountRotation = { 1.57, 0, 0 };
  1790.     firstPerson = false;
  1791. };
  1792.  
  1793. ItemData AmmoPack
  1794. {
  1795.     description = "Ammo Pack";
  1796.     shapeFile = "AmmoPack";
  1797.     className = "Backpack";
  1798.    heading = "cBackpacks";
  1799.     imageType = AmmoPackImage;
  1800.     shadowDetailMask = 4;
  1801.     mass = 2.0;
  1802.     elasticity = 0.2;
  1803.     price = 325;
  1804.     hudIcon = "ammopack";
  1805.     showWeaponBar = true;
  1806.     hiliteOnActive = true;
  1807. };
  1808.  
  1809. function AmmoPack::onDrop(%player, %item)
  1810. {
  1811.     if($matchStarted) {
  1812.         %item = Item::onDrop(%player,%item);
  1813.         for(%i = 0; %i < 7 ; %i = %i +1) {
  1814.             %numPack = 0;
  1815.             %ammoItem = $AmmoPackItems[%i];
  1816.             %maxnum = $ItemMax[Player::getArmor(%player), %ammoItem];
  1817.             %pCount = Player::getItemCount(%player, %ammoItem);
  1818.             if(%pCount > %maxnum) {
  1819.                 %numPack = %pCount - %maxnum;
  1820.                 Player::decItemCount(%player,%ammoItem,%numPack);
  1821.             }    
  1822.             if(%i == 0) {
  1823.                  %item.BulletAmmo = %numPack;
  1824.             }
  1825.             else if(%i == 1) {
  1826.                  %item.PlasmaAmmo = %numPack;
  1827.             }
  1828.             else if(%i == 2) {
  1829.                  %item.DiscAmmo = %numPack;
  1830.             }
  1831.             else if(%i == 3) {
  1832.                  %item.GrenadeAmmo = %numPack;
  1833.             }
  1834.             else if(%i == 4) {
  1835.                  %item.Grenade = %numPack;
  1836.             }
  1837.             else if(%i == 5) {
  1838.                  %item.MortarAmmo = %numPack;
  1839.             }
  1840.             else {
  1841.                  %item.MineAmmo = %numPack;
  1842.             }
  1843.         }
  1844.     }
  1845. }
  1846.  
  1847. function AmmoPack::onCollision(%this,%object)
  1848. {
  1849.     if (getObjectType(%object) == "Player") {
  1850.         %item = Item::getItemData(%this);
  1851.         %count = Player::getItemCount(%object,%item);
  1852.         if (Item::giveItem(%object,%item,Item::getCount(%this))) {
  1853.             Item::playPickupSound(%this);
  1854.             checkPacksAmmo(%object, %this);
  1855.             Item::respawn(%this);
  1856.         }
  1857.     }
  1858. }
  1859.  
  1860. function checkPacksAmmo(%player, %item)
  1861. {
  1862.     for(%i = 0; %i < 7 ; %i = %i +1) {
  1863.         %ammoItem = $AmmoPackItems[%i];
  1864.         if(%i == 0) {
  1865.             %numAdd = %item.BulletAmmo;
  1866.         }
  1867.         else if(%i == 1) {
  1868.             %numAdd = %item.PlasmaAmmo;
  1869.         }
  1870.         else if(%i == 2) {
  1871.             %numAdd = %item.DiscAmmo;
  1872.         }
  1873.         else if(%i == 3) {
  1874.             %numAdd = %item.GrenadeAmmo;
  1875.         }
  1876.         else if(%i == 4) {
  1877.             %numAdd = %item.Grenade;
  1878.         }
  1879.         else if(%i == 5) {
  1880.              %numAdd = %item.MortarAmmo;
  1881.         }
  1882.         else {
  1883.             %numAdd = %item.MineAmmo;
  1884.         }
  1885.         Player::incItemCount(%player,%ammoItem,%numAdd);
  1886.     }                         
  1887. }
  1888.  
  1889. function fillAmmoPack(%client)
  1890. {
  1891.     %player = Client::getOwnedObject(%client);
  1892.     for(%i = 0; %i < 7 ; %i = %i +1) {
  1893.         %item = $AmmoPackItems[%i];
  1894.         %maxnum = $AmmoPackMax[%item];
  1895.         %maxnum = checkResources(%player,%item,%maxnum); 
  1896.         if(%maxnum) {
  1897.             Player::incItemCount(%client,%item,%maxnum);
  1898.             teamEnergyBuySell(%player,%item.price * %maxnum * -1);
  1899.         }    
  1900.     }
  1901. }
  1902.  
  1903. //----------------------------------------------------------------------------
  1904.  
  1905. ItemImageData PulseSensorPackImage
  1906. {
  1907.     shapeFile = "radar_small";
  1908.     mountPoint = 2;
  1909.     mountOffset = { 0, 0, 0.1 };
  1910.     mountRotation = { 1.57, 0, 0 };
  1911.     firstPerson = false;
  1912. };
  1913.  
  1914. ItemData PulseSensorPack
  1915. {
  1916.     description = "Pulse Sensor";
  1917.     shapeFile = "radar_small";
  1918.     className = "Backpack";
  1919.    heading = "dDeployables";
  1920.     imageType = PulseSensorPackImage;
  1921.     shadowDetailMask = 4;
  1922.     mass = 2.0;
  1923.     elasticity = 0.2;
  1924.     price = 125;
  1925.     hudIcon = "deployable";
  1926.     showWeaponBar = true;
  1927.     hiliteOnActive = true;
  1928. };
  1929.  
  1930. function PulseSensorPack::onUse(%player,%item)
  1931. {
  1932.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  1933.         Player::mountItem(%player,%item,$BackpackSlot);
  1934.     }
  1935.     else {
  1936.         Player::deployItem(%player,%item);
  1937.     }
  1938. }
  1939.  
  1940. function PulseSensorPack::onDeploy(%player,%item,%pos)
  1941. {
  1942.     if (Item::deployShape(%player,"Pulse Sensor",DeployablePulseSensor,%item)) {
  1943.         Player::decItemCount(%player,%item);
  1944.         $TeamItemCount[GameBase::getTeam(%player) @ "PulseSensorPack"]++;
  1945.     }
  1946. }
  1947.  
  1948.  
  1949. //----------------------------------------------------------------------------
  1950.  
  1951. ItemImageData DeployableSensorJamPackImage
  1952. {
  1953.     shapeFile = "sensor_jammer";
  1954.      mountPoint = 2;
  1955.       mountOffset = { 0, 0.03, 0.1 };
  1956.       mountRotation = { 1.57, 0, 0 };
  1957.     firstPerson = false;
  1958. };
  1959.  
  1960. ItemData DeployableSensorJammerPack
  1961. {
  1962.     description = "Sensor Jammer";
  1963.       shapeFile = "sensor_jammer";
  1964.       className = "Backpack";
  1965.    heading = "dDeployables";
  1966.     imageType = DeployableSensorJamPackImage;
  1967.       shadowDetailMask = 4;
  1968.     mass = 2.0;
  1969.     elasticity = 0.2;
  1970.       price = 225;
  1971.     hudIcon = "deployable";
  1972.     showWeaponBar = true;
  1973.     hiliteOnActive = true;
  1974. };
  1975.  
  1976. function DeployableSensorJammerPack::onUse(%player,%item)
  1977. {
  1978.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  1979.         Player::mountItem(%player,%item,$BackpackSlot);
  1980.     }
  1981.     else {
  1982.         Player::deployItem(%player,%item);
  1983.     }
  1984. }
  1985.  
  1986. function DeployableSensorJammerPack::onDeploy(%player,%item,%pos)
  1987. {
  1988.     if (Item::deployShape(%player,"Sensor Jammer",DeployableSensorJammer,%item)) {
  1989.         Player::decItemCount(%player,%item);
  1990.         $TeamItemCount[GameBase::getTeam(%player) @ "DeployableSensorJammerPack"]++;
  1991.     }
  1992. }
  1993.  
  1994.  
  1995. //----------------------------------------------------------------------------
  1996.  
  1997.  
  1998. ItemImageData CameraPackImage
  1999. {
  2000.     shapeFile = "camera";
  2001.     mountPoint = 2;
  2002.     mountOffset = { 0, -0.1, -0.06 };
  2003.     mountRotation = { 0, 0, 0 };
  2004.     firstPerson = false;
  2005. };
  2006.  
  2007. ItemData CameraPack
  2008. {
  2009.     description = "Camera";
  2010.     shapeFile = "camera";
  2011.     className = "Backpack";
  2012.    heading = "dDeployables";
  2013.     imageType = CameraPackImage;
  2014.     shadowDetailMask = 4;
  2015.     mass = 2.0;
  2016.     elasticity = 0.2;
  2017.     price = 100;
  2018.     hudIcon = "deployable";
  2019.     showWeaponBar = true;
  2020.     hiliteOnActive = true;
  2021. };
  2022.  
  2023. function CameraPack::onUse(%player,%item)
  2024. {
  2025.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  2026.         Player::mountItem(%player,%item,$BackpackSlot);
  2027.     }
  2028.     else {
  2029.         Player::deployItem(%player,%item);
  2030.     }
  2031. }
  2032.  
  2033. function CameraPack::onDeploy(%player,%item,%pos)
  2034. {
  2035.     if (CameraPack::deployShape(%player,%item)) {
  2036.         Player::decItemCount(%player,%item);
  2037.     }
  2038. }
  2039.  
  2040. function CameraPack::deployShape(%player,%item)
  2041. {
  2042.      %client = Player::getClient(%player);
  2043.     if($TeamItemCount[GameBase::getTeam(%player) @ %item] < $TeamItemMax[%item]) {
  2044.         if (GameBase::getLOSInfo(%player,3)) {
  2045.             // GetLOSInfo sets the following globals:
  2046.             //     los::position
  2047.             //     los::normal
  2048.             //     los::object
  2049.             %obj = getObjectType($los::object);
  2050.             if (%obj == "SimTerrain" || %obj == "InteriorShape") {
  2051.                 // Try to stick it straight up or down, otherwise
  2052.                 // just use the surface normal
  2053.                 %prot = GameBase::getRotation(%player);
  2054.                 %zRot = getWord(%prot,2);
  2055.                 if (Vector::dot($los::normal,"0 0 1") > 0.6) {
  2056.                     %rot = "0 0 " @ %zRot;
  2057.                 }
  2058.                 else {
  2059.                     if (Vector::dot($los::normal,"0 0 -1") > 0.6) {
  2060.                         %rot = "3.14159 0 " @ %zRot;
  2061.                     }
  2062.                     else {
  2063.                         %rot = Vector::getRotation($los::normal);
  2064.                     }
  2065.                 }
  2066.                 if(checkDeployArea(%client,$los::position)) {
  2067.                     %camera = newObject("Camera","Turret",CameraTurret,true);
  2068.                  addToSet("MissionCleanup", %camera);
  2069.                     GameBase::setTeam(%camera,GameBase::getTeam(%player));
  2070.                     GameBase::setRotation(%camera,%rot);
  2071.                     GameBase::setPosition(%camera,$los::position);
  2072.                     Gamebase::setMapName(%camera,"Camera#"@ $totalNumCameras++ @ " " @ Client::getName(%client));
  2073.                     Client::sendMessage(%client,0,"Camera deployed");
  2074.                     playSound(SoundPickupBackpack,$los::position);
  2075.                     $TeamItemCount[GameBase::getTeam(%camera) @ "CameraPack"]++;
  2076.                     return true;
  2077.                 }
  2078.             }
  2079.             else {
  2080.                 Client::sendMessage(%client,0,"Can only deploy on terrain or buildings");
  2081.             }
  2082.         }
  2083.         else {
  2084.             Client::sendMessage(%client,0,"Deploy position out of range");        
  2085.         }
  2086.     }
  2087.     else                                                                                          
  2088.          Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %item.description @ "s");
  2089.     
  2090.     return false;
  2091. }
  2092. //----------------------------------------------------------------------------
  2093.                                                                             
  2094. ItemImageData TurretPackImage
  2095. {
  2096.     shapeFile = "remoteturret";
  2097.     mountPoint = 2;
  2098.     mountOffset = { 0, -0.12, -0.1 };
  2099.     mountRotation = { 0, 0, 0 };
  2100.     mass = 2.5;
  2101.     firstPerson = false;
  2102. };
  2103.  
  2104. ItemData TurretPack
  2105. {
  2106.     description = "Turret";
  2107.     shapeFile = "remoteturret";
  2108.     className = "Backpack";
  2109.    heading = "dDeployables";
  2110.     imageType = TurretPackImage;
  2111.     shadowDetailMask = 4;
  2112.     mass = 2.0;
  2113.     elasticity = 0.2;
  2114.     price = 350;
  2115.     hudIcon = "deployable";
  2116.     showWeaponBar = true;
  2117.     hiliteOnActive = true;
  2118. };
  2119.  
  2120. function TurretPack::onUse(%player,%item)
  2121. {
  2122.     if (Player::getMountedItem(%player,$BackpackSlot) != %item) {
  2123.         Player::mountItem(%player,%item,$BackpackSlot);
  2124.     }
  2125.     else {
  2126.         Player::deployItem(%player,%item);
  2127.     }
  2128. }
  2129.  
  2130. function TurretPack::onDeploy(%player,%item,%pos)
  2131. {
  2132.     if (TurretPack::deployShape(%player,%item)) {
  2133.         Player::decItemCount(%player,%item);
  2134.     }
  2135. }
  2136.  
  2137. function CountObjects(%set,%name,%num) 
  2138. {
  2139.     %count = 0;
  2140.     for(%i=0;%i<%num;%i++) {
  2141.         %obj=Group::getObject(%set,%i);
  2142.         if(GameBase::getDataName(Group::getObject(%set,%i)) == %name) 
  2143.             %count++;
  2144.     }
  2145.     return %count;
  2146. }
  2147.  
  2148. function TurretPack::deployShape(%player,%item)
  2149. {
  2150.     %client = Player::getClient(%player);
  2151.     if($TeamItemCount[GameBase::getTeam(%player) @ %item] < $TeamItemMax[%item]) {
  2152.         if (GameBase::getLOSInfo(%player,3)) {
  2153.             %obj = getObjectType($los::object);
  2154.             if (%obj == "SimTerrain" || %obj == "InteriorShape") {
  2155.                 %set = newObject("set",SimSet);
  2156.                 %num = containerBoxFillSet(%set,$StaticObjectType,$los::position,$TurretBoxMaxLength,$TurretBoxMaxWidth,$TurretBoxMaxHeight,0);
  2157.                 %num = CountObjects(%set,"DeployableTurret",%num);
  2158.                 deleteObject(%set);
  2159.                 if($MaxNumTurretsInBox > %num) {
  2160.                     %set = newObject("set",SimSet);
  2161.                     %num = containerBoxFillSet(%set,$StaticObjectType,$los::position,$TurretBoxMinLength,$TurretBoxMinWidth,$TurretBoxMinHeight,0);
  2162.                     %num = CountObjects(%set,"DeployableTurret",%num);
  2163.                     deleteObject(%set);
  2164.                     if(0 == %num) {
  2165.                         if (Vector::dot($los::normal,"0 0 1") > 0.7) {
  2166.                             if(checkDeployArea(%client,$los::position)) {
  2167.                                 %rot = GameBase::getRotation(%player); 
  2168.                                 %turret = newObject("remoteTurret","Turret",DeployableTurret,true);
  2169.                          addToSet("MissionCleanup", %turret);
  2170.                                 GameBase::setTeam(%turret,GameBase::getTeam(%player));
  2171.                                 GameBase::setPosition(%turret,$los::position);
  2172.                                 GameBase::setRotation(%turret,%rot);
  2173.                                 Gamebase::setMapName(%turret,"RMT Turret#" @ $totalNumTurrets++ @ " " @ Client::getName(%client));
  2174.                                 Client::sendMessage(%client,0,"Remote Turret deployed");
  2175.                                 playSound(SoundPickupBackpack,$los::position);
  2176.                                 $TeamItemCount[GameBase::getTeam(%player) @ "TurretPack"]++;
  2177.                                 return true;
  2178.                             }
  2179.                         }
  2180.                         else 
  2181.                             Client::sendMessage(%client,0,"Can only deploy on flat surfaces");
  2182.                     } 
  2183.                     else
  2184.                         Client::sendMessage(%client,0,"Frequency Overload - Too close to other remote turrets");
  2185.                 }
  2186.                else 
  2187.                     Client::sendMessage(%client,0,"Interference from other remote turrets in the area");
  2188.             }
  2189.             else 
  2190.                 Client::sendMessage(%client,0,"Can only deploy on terrain or buildings");
  2191.         }
  2192.         else 
  2193.             Client::sendMessage(%client,0,"Deploy position out of range");
  2194.     }
  2195.     else                                                                                          
  2196.          Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %item.description @ "s");
  2197.  
  2198.     return false;
  2199. }
  2200.  
  2201. function checkDeployArea(%client,%pos)
  2202. {
  2203.       %set=newObject("set",SimSet);
  2204.     %num=containerBoxFillSet(%set,$StaticObjectType | $ItemObjectType | $SimPlayerObjectType,%pos,1,1,1,1);
  2205.     if(!%num) {
  2206.         deleteObject(%set);
  2207.         return 1;
  2208.     }
  2209.     else if(%num == 1 && getObjectType(Group::getObject(%set,0)) == "Player") { 
  2210.         %obj = Group::getObject(%set,0);    
  2211.         if(Player::getClient(%obj) == %client)    
  2212.             Client::sendMessage(%client,0,"Unable to deploy - You're in the way");
  2213.         else
  2214.             Client::sendMessage(%client,0,"Unable to deploy - Player in the way");
  2215.     }
  2216.     else
  2217.         Client::sendMessage(%client,0,"Unable to deploy - Item in the way");
  2218.  
  2219.     deleteObject(%set);
  2220.     return 0;    
  2221.         
  2222.  
  2223. }
  2224. //----------------------------------------------------------------------------
  2225. // Remote deploy for items
  2226.  
  2227. function Item::deployShape(%player,%name,%shape,%item)
  2228. {
  2229.     %client = Player::getClient(%player);
  2230.     if($TeamItemCount[GameBase::getTeam(%player) @ %item] < $TeamItemMax[%item]) {
  2231.         if (GameBase::getLOSInfo(%player,3)) {
  2232.             // GetLOSInfo sets the following globals:
  2233.             //     los::position
  2234.             //     los::normal
  2235.             //     los::object
  2236.             %obj = getObjectType($los::object);
  2237.             if (%obj == "SimTerrain" || %obj == "InteriorShape") {
  2238.                 if (Vector::dot($los::normal,"0 0 1") > 0.7) {
  2239.                     if(checkDeployArea(%client,$los::position)) {
  2240.                         %sensor = newObject("","Sensor",%shape,true);
  2241.                         addToSet("MissionCleanup", %sensor);
  2242.                         GameBase::setTeam(%sensor,GameBase::getTeam(%player));
  2243.                         GameBase::setPosition(%sensor,$los::position);
  2244.                         Gamebase::setMapName(%sensor,%name);
  2245.                         Client::sendMessage(%client,0,%item.description @ " deployed");
  2246.                         playSound(SoundPickupBackpack,$los::position);
  2247.                         return true;
  2248.                     }
  2249.                 }
  2250.                 else 
  2251.                     Client::sendMessage(%client,0,"Can only deploy on flat surfaces");
  2252.             }
  2253.             else 
  2254.                 Client::sendMessage(%client,0,"Can only deploy on terrain or buildings");
  2255.         }
  2256.         else 
  2257.             Client::sendMessage(%client,0,"Deploy position out of range");
  2258.     }
  2259.     else
  2260.          Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %name @ "s");
  2261.     return false;
  2262. }
  2263.  
  2264. //----------------------------------------------------------------------------
  2265. //----------------------------------------------------------------------------
  2266.  
  2267. //----------------------------------------------------------------------------
  2268.  
  2269. $AutoUse[RepairKit] = false;
  2270.  
  2271. ItemData RepairKit
  2272. {
  2273.    description = "Repair Kit";
  2274.    shapeFile = "armorKit";
  2275.    heading = "eMiscellany";
  2276.    shadowDetailMask = 4;
  2277.    price = 35;
  2278. };
  2279.  
  2280. function RepairKit::onUse(%player,%item)
  2281. {
  2282.     Player::decItemCount(%player,%item);
  2283.     GameBase::repairDamage(%player,0.2);
  2284. }
  2285.  
  2286.  
  2287. //----------------------------------------------------------------------------
  2288.  
  2289. ItemData MineAmmo
  2290. {
  2291.    description = "Mine";
  2292.    shapeFile = "mineammo";
  2293.    heading = "eMiscellany";
  2294.    shadowDetailMask = 4;
  2295.    price = 10;
  2296.     className = "HandAmmo";
  2297. };
  2298.  
  2299. function MineAmmo::onUse(%player,%item)
  2300. {
  2301.     if($matchStarted) {
  2302.         if(%player.throwTime < getSimTime() ) {
  2303.             Player::decItemCount(%player,%item);
  2304.             %obj = newObject("","Mine","antipersonelMine");
  2305.              addToSet("MissionCleanup", %obj);
  2306.             %client = Player::getClient(%player);
  2307.             GameBase::throw(%obj,%player,15 * %client.throwStrength,false);
  2308.             %player.throwTime = getSimTime() + 0.5;
  2309.         }
  2310.     }
  2311. }
  2312.  
  2313.  
  2314. //----------------------------------------------------------------------------
  2315.  
  2316. ItemData Grenade
  2317. {
  2318.    description = "Grenade";
  2319.    shapeFile = "grenade";
  2320.    heading = "eMiscellany";
  2321.    shadowDetailMask = 4;
  2322.    price = 5;
  2323.     className = "HandAmmo";
  2324. };
  2325.  
  2326. function Grenade::onUse(%player,%item)
  2327. {
  2328.     if($matchStarted) {
  2329.         if(%player.throwTime < getSimTime() ) {
  2330.             Player::decItemCount(%player,%item);
  2331.             %obj = newObject("","Mine","Handgrenade");
  2332.                addToSet("MissionCleanup", %obj);
  2333.             %client = Player::getClient(%player);
  2334.             GameBase::throw(%obj,%player,9 * %client.throwStrength,false);
  2335.             %player.throwTime = getSimTime() + 0.5;
  2336.         }
  2337.     }
  2338. }
  2339.  
  2340.  
  2341. //----------------------------------------------------------------------------
  2342.  
  2343. ItemData Beacon
  2344. {
  2345.    description = "Beacon";
  2346.    shapeFile = "sensor_small";
  2347.    heading = "eMiscellany";
  2348.    shadowDetailMask = 4;
  2349.    price = 5;
  2350.     className = "HandAmmo";
  2351. };
  2352.  
  2353. function Beacon::onUse(%player,%item)
  2354. {
  2355.     if (Beacon::deployShape(%player,%item)) {
  2356.         Player::decItemCount(%player,%item);
  2357.     }
  2358. }
  2359.  
  2360. function Beacon::deployShape(%player,%item)
  2361. {
  2362.      %client = Player::getClient(%player);
  2363.     if (GameBase::getLOSInfo(%player,3)) {
  2364.         // GetLOSInfo sets the following globals:
  2365.         //     los::position
  2366.         //     los::normal
  2367.         //     los::object
  2368.         %obj = getObjectType($los::object);
  2369.         if (%obj == "SimTerrain" || %obj == "InteriorShape") {
  2370.             // Try to stick it straight up or down, otherwise
  2371.             // just use the surface normal
  2372.             if (Vector::dot($los::normal,"0 0 1") > 0.6) {
  2373.                 %rot = "0 0 0";
  2374.             }
  2375.             else {
  2376.                 if (Vector::dot($los::normal,"0 0 -1") > 0.6) {
  2377.                     %rot = "3.14159 0 0";
  2378.                 }
  2379.                 else {
  2380.                     %rot = Vector::getRotation($los::normal);
  2381.                 }
  2382.             }
  2383.               %set=newObject("set",SimSet);
  2384.             %num=containerBoxFillSet(%set,$StaticObjectType | $ItemObjectType | $SimPlayerObjectType,$los::position,0.3,0.3,0.3,1);
  2385.             deleteObject(%set);
  2386.             if(!%num) {
  2387.                 %team = GameBase::getTeam(%player);
  2388.                 if($TeamItemMax[%item] > $TeamItemCount[%team @ %item] || $TestCheats) {
  2389.                     %beacon = newObject("Target Beacon", "StaticShape", "DefaultBeacon", true);
  2390.                    addToSet("MissionCleanup", %beacon);
  2391.                     //, CameraTurret, true);
  2392.                     GameBase::setTeam(%beacon,GameBase::getTeam(%player));
  2393.                     GameBase::setRotation(%beacon,%rot);
  2394.                     GameBase::setPosition(%beacon,$los::position);
  2395.                     Gamebase::setMapName(%beacon,"Target Beacon");
  2396.                   Beacon::onEnabled(%beacon);
  2397.                     Client::sendMessage(%client,0,"Beacon deployed");
  2398.                     //playSound(SoundPickupBackpack,$los::position);
  2399.                     $TeamItemCount[GameBase::getTeam(%beacon) @ "Beacon"]++;
  2400.                     return true;
  2401.                 }
  2402.                 else
  2403.                     Client::sendMessage(%client,0,"Deployable Item limit reached");
  2404.             }
  2405.             else
  2406.                 Client::sendMessage(%client,0,"Unable to deploy - Item in the way");
  2407.         }
  2408.         else {
  2409.             Client::sendMessage(%client,0,"Can only deploy on terrain or buildings");
  2410.         }
  2411.     }
  2412.     else {
  2413.         Client::sendMessage(%client,0,"Deploy position out of range");
  2414.     }
  2415.     return false;
  2416. }
  2417.  
  2418.  
  2419. //----------------------------------------------------------------------------
  2420. //----------------------------------------------------------------------------
  2421.  
  2422. ItemData RepairPatch
  2423. {
  2424.     description = "Repair Patch";
  2425.     className = "Repair";
  2426.     shapeFile = "armorPatch";
  2427.    heading = "eMiscellany";
  2428.     shadowDetailMask = 4;
  2429.       price = 2;
  2430. };
  2431.  
  2432. function RepairPatch::onCollision(%this,%object)
  2433. {
  2434.     if (getObjectType(%object) == "Player") {
  2435.         if(GameBase::getDamageLevel(%object)) {
  2436.             GameBase::repairDamage(%object,0.125);
  2437.             %item = Item::getItemData(%this);
  2438.             Item::playPickupSound(%this);
  2439.             Item::respawn(%this);
  2440.         }
  2441.     }
  2442. }
  2443.  
  2444. function RepairPatch::onUse(%player,%item)
  2445. {
  2446.     Player::decItemCount(%player,%item);
  2447.     GameBase::repairDamage(%player,0.1);
  2448. }
  2449.  
  2450.  
  2451. //----------------------------------------------------------------------------
  2452.  
  2453. function remoteGiveAll(%clientId)
  2454. {
  2455.     if ($TestCheats) {
  2456.         Player::setItemCount(%clientId,Blaster,1);
  2457.         Player::setItemCount(%clientId,Chaingun,1);
  2458.         Player::setItemCount(%clientId,PlasmaGun,1);
  2459.         Player::setItemCount(%clientId,GrenadeLauncher,1);
  2460.         Player::setItemCount(%clientId,DiscLauncher,1);
  2461.         Player::setItemCount(%clientId,LaserRifle,1);
  2462.         Player::setItemCount(%clientId,EnergyRifle,1);
  2463.         Player::setItemCount(%clientId,TargetingLaser,1);
  2464.         Player::setItemCount(%clientId,Mortar,1);
  2465.  
  2466.         Player::setItemCount(%clientId,BulletAmmo,200);
  2467.         Player::setItemCount(%clientId,PlasmaAmmo,200);
  2468.         Player::setItemCount(%clientId,GrenadeAmmo,200);
  2469.         Player::setItemCount(%clientId,DiscAmmo,200);
  2470.         Player::setItemCount(%clientId,MortarAmmo,200);
  2471.  
  2472.       Player::setItemCount(%clientId,Grenade, 200);
  2473.       Player::setItemCount(%clientId,MineAmmo, 200);
  2474.         Player::setItemCount(%clientId,Beacon,  200);
  2475.  
  2476.         Player::setItemCount(%clientId,RepairKit,200);
  2477.     }
  2478.     else if($ServerCheats) {
  2479.         %armor = Player::getArmor(%clientId);
  2480.         Player::setItemCount(%clientId,BulletAmmo,$ItemMax[%armor, BulletAmmo]);
  2481.         Player::setItemCount(%clientId,PlasmaAmmo,$ItemMax[%armor, PlasmaAmmo]);
  2482.         Player::setItemCount(%clientId,GrenadeAmmo,$ItemMax[%armor, GrenadeAmmo]);
  2483.         Player::setItemCount(%clientId,DiscAmmo,$ItemMax[%armor, DiscAmmo]);
  2484.         Player::setItemCount(%clientId,MortarAmmo,$ItemMax[%armor, MortarAmmo]);
  2485.  
  2486.       Player::setItemCount(%clientId,Grenade, $ItemMax[%armor, Grenade]);
  2487.       Player::setItemCount(%clientId,MineAmmo,$ItemMax[%armor, MineAmmo]);
  2488.         Player::setItemCount(%clientId,Beacon,$ItemMax[%armor, Beacon]);
  2489.  
  2490.         Player::setItemCount(%clientId,RepairKit,1);
  2491.     }
  2492. }
  2493.  
  2494.  
  2495. //----------------------------------------------------------------------------
  2496.  
  2497.  
  2498. function checkMax(%client,%armor)
  2499. {
  2500.      %weaponflag = 0;
  2501.     %numweapon = Player::getItemClassCount(%client,"Weapon");
  2502.     if (%numweapon > $MaxWeapons[%armor]) {
  2503.        %weaponflag = %numweapon - $MaxWeapons[%armor];
  2504.     }
  2505.     %max = getNumItems();
  2506.     for (%i = 0; %i < %max; %i = %i + 1) {
  2507.         %item = getItemData(%i);
  2508.         %maxnum = $ItemMax[%armor, %item];
  2509.         if(%maxnum != "") {
  2510.             %numsell = 0;
  2511.             %count = Player::getItemCount(%client,%item);
  2512.             if(%count > %maxnum) {
  2513.                 %numsell =  %count - %maxnum;
  2514.             }
  2515.             if (%count > 0 && %weaponflag && %item.className == Weapon) {
  2516.                 %numsell = 1;
  2517.                 %weaponflag = %weaponflag - 1;
  2518.             }
  2519.             if(%numsell > 0) {
  2520.                 Client::sendMessage(%client,0,"SOLD " @ %numsell @ " " @ %item);
  2521.                 teamEnergyBuySell(Client::getOwnedObject(%client),(%item.price * %numsell));
  2522.                 Player::setItemCount(%client, %item, %count - %numsell);  
  2523.                 updateBuyingList(%client);
  2524.             } 
  2525.         }
  2526.     }
  2527. }
  2528.  
  2529. function checkPlayerCash(%client)
  2530. {
  2531.     %team = Client::getTeam(%client);    
  2532.     if($TeamEnergy[%team] != "Infinite") {
  2533.         if(%client.teamEnergy > ($InitialPlayerEnergy * -1) ) {
  2534.             if(%client.teamEnergy >= 0)
  2535.                 %diff = $InitialPlayerEnergy;
  2536.             else 
  2537.                 %diff = $InitialPlayerEnergy + %client.teamEnergy;
  2538.             $TeamEnergy[%team] -= %diff;
  2539.         }
  2540.     }
  2541. }    
  2542.  
  2543. function Mission::reinitData()
  2544. {
  2545.     $TeamItemCount[0 @ DeployableAmmoPack] = 0;
  2546.     $TeamItemCount[0 @ DeployableInvPack] = 0;
  2547.     $TeamItemCount[0 @ TurretPack] = 0;
  2548.     $TeamItemCount[0 @ CameraPack] = 0;
  2549.     $TeamItemCount[0 @ DeployableSensorJammerPack] = 0;
  2550.     $TeamItemCount[0 @ PulseSensorPack] = 0;
  2551.     $TeamItemCount[0 @ MotionSensorPack] = 0;
  2552.     $TeamItemCount[0 @ ScoutVehicle] = 0;
  2553.     $TeamItemCount[0 @ LAPCVehicle] = 0;
  2554.     $TeamItemCount[0 @ HAPCVehicle] = 0;
  2555.     $TeamItemCount[0 @ Beacon] = 0;
  2556.     $TeamItemCount[0 @ mineammo] = 0;
  2557.  
  2558.     $TeamItemCount[1 @ DeployableAmmoPack] = 0;
  2559.     $TeamItemCount[1 @ DeployableInvPack] = 0;
  2560.     $TeamItemCount[1 @ TurretPack] = 0;
  2561.     $TeamItemCount[1 @ CameraPack] = 0;
  2562.     $TeamItemCount[1 @ DeployableSensorJammerPack] = 0;
  2563.     $TeamItemCount[1 @ PulseSensorPack] = 0;
  2564.     $TeamItemCount[1 @ MotionSensorPack] = 0;
  2565.     $TeamItemCount[1 @ ScoutVehicle] = 0;
  2566.     $TeamItemCount[1 @ LAPCVehicle] = 0;
  2567.     $TeamItemCount[1 @ HAPCVehicle] = 0;
  2568.     $TeamItemCount[1 @ Beacon] = 0;
  2569.     $TeamItemCount[1 @ mineammo] = 0;
  2570.  
  2571.     $TeamItemCount[2 @ DeployableAmmoPack] = 0;
  2572.     $TeamItemCount[2 @ DeployableInvPack] = 0;
  2573.     $TeamItemCount[2 @ TurretPack] = 0;
  2574.     $TeamItemCount[2 @ CameraPack] = 0;
  2575.     $TeamItemCount[2 @ DeployableSensorJammerPack] = 0;
  2576.     $TeamItemCount[2 @ PulseSensorPack] = 0;
  2577.     $TeamItemCount[2 @ MotionSensorPack] = 0;
  2578.     $TeamItemCount[2 @ ScoutVehicle] = 0;
  2579.     $TeamItemCount[2 @ LAPCVehicle] = 0;
  2580.     $TeamItemCount[2 @ HAPCVehicle] = 0;
  2581.     $TeamItemCount[2 @ Beacon] = 0;
  2582.     $TeamItemCount[2 @ mineammo] = 0;
  2583.  
  2584.     $TeamItemCount[3 @ DeployableAmmoPack] = 0;
  2585.     $TeamItemCount[3 @ DeployableInvPack] = 0;
  2586.     $TeamItemCount[3 @ TurretPack] = 0;
  2587.     $TeamItemCount[3 @ CameraPack] = 0;
  2588.     $TeamItemCount[3 @ DeployableSensorJammerPack]= 0;
  2589.     $TeamItemCount[3 @ PulseSensorPack] = 0;
  2590.     $TeamItemCount[3 @ MotionSensorPack] = 0;
  2591.     $TeamItemCount[3 @ ScoutVehicle] = 0;
  2592.     $TeamItemCount[3 @ LAPCVehicle] = 0;
  2593.     $TeamItemCount[3 @ HAPCVehicle] = 0;
  2594.     $TeamItemCount[3 @ Beacon] = 0;
  2595.     $TeamItemCount[3 @ mineammo] = 0;
  2596.  
  2597.     $TeamItemCount[4 @ DeployableAmmoPack] = 0;
  2598.     $TeamItemCount[4 @ DeployableInvPack] = 0;
  2599.     $TeamItemCount[4 @ TurretPack] = 0;
  2600.     $TeamItemCount[4 @ CameraPack] = 0;
  2601.     $TeamItemCount[4 @ DeployableSensorJammerPack]= 0;
  2602.     $TeamItemCount[4 @ PulseSensorPack] = 0;
  2603.     $TeamItemCount[4 @ MotionSensorPack] = 0;
  2604.     $TeamItemCount[4 @ ScoutVehicle] = 0;
  2605.     $TeamItemCount[4 @ LAPCVehicle] = 0;
  2606.     $TeamItemCount[4 @ HAPCVehicle] = 0;
  2607.     $TeamItemCount[4 @ Beacon] = 0;
  2608.     $TeamItemCount[4 @ mineammo] = 0;
  2609.  
  2610.     $TeamItemCount[5 @ DeployableAmmoPack] = 0;
  2611.     $TeamItemCount[5 @ DeployableInvPack] = 0;
  2612.     $TeamItemCount[5 @ TurretPack] = 0;
  2613.     $TeamItemCount[5 @ CameraPack] = 0;
  2614.     $TeamItemCount[5 @ DeployableSensorJammerPack]= 0;
  2615.     $TeamItemCount[5 @ PulseSensorPack] = 0;
  2616.     $TeamItemCount[5 @ MotionSensorPack] = 0;
  2617.     $TeamItemCount[5 @ ScoutVehicle] = 0;
  2618.     $TeamItemCount[5 @ LAPCVehicle] = 0;
  2619.     $TeamItemCount[5 @ HAPCVehicle] = 0;
  2620.     $TeamItemCount[5 @ Beacon] = 0;
  2621.     $TeamItemCount[5 @ mineammo] = 0;
  2622.  
  2623.     $TeamItemCount[6 @ DeployableAmmoPack] = 0;
  2624.     $TeamItemCount[6 @ DeployableInvPack] = 0;
  2625.     $TeamItemCount[6 @ TurretPack] = 0;
  2626.     $TeamItemCount[6 @ CameraPack] = 0;
  2627.     $TeamItemCount[6 @ DeployableSensorJammerPack]= 0;
  2628.     $TeamItemCount[6 @ PulseSensorPack] = 0;
  2629.     $TeamItemCount[6 @ MotionSensorPack] = 0;
  2630.     $TeamItemCount[6 @ ScoutVehicle] = 0;
  2631.     $TeamItemCount[6 @ LAPCVehicle] = 0;
  2632.     $TeamItemCount[6 @ HAPCVehicle] = 0;
  2633.     $TeamItemCount[6 @ Beacon] = 0;
  2634.     $TeamItemCount[6 @ mineammo] = 0;
  2635.  
  2636.     $TeamItemCount[7 @ DeployableAmmoPack] = 0;
  2637.     $TeamItemCount[7 @ DeployableInvPack] = 0;
  2638.     $TeamItemCount[7 @ TurretPack] = 0;
  2639.     $TeamItemCount[7 @ CameraPack] = 0;
  2640.     $TeamItemCount[7 @ DeployableSensorJammerPack]= 0;
  2641.     $TeamItemCount[7 @ PulseSensorPack] = 0;
  2642.     $TeamItemCount[7 @ MotionSensorPack] = 0;
  2643.     $TeamItemCount[7 @ ScoutVehicle] = 0;
  2644.     $TeamItemCount[7 @ LAPCVehicle] = 0;
  2645.     $TeamItemCount[7 @ HAPCVehicle] = 0;
  2646.     $TeamItemCount[7 @ Beacon] = 0;
  2647.     $TeamItemCount[7 @ mineammo] = 0;
  2648.  
  2649.     $totalNumCameras = 0;
  2650.     $totalNumTurrets = 0;
  2651.  
  2652.     for(%i = -1; %i < 8 ; %i++)
  2653.         $TeamEnergy[%i] = $DefaultTeamEnergy; 
  2654. }
  2655.