Advertisement
Qent

a_classes.acs (r2732)

Jun 14th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.86 KB | None | 0 0
  1. // All Out War 2 Class purchase scripts
  2. // Credit to VoltlocK for originally creating AOW2
  3. // With modifications by Eruanna, Dusk and the Omega Team
  4.  
  5. // You may use portions of this script in your project as long as you give credit where credit is
  6. // due. Please don't be lame and just copy-paste any of this and call it your own. Thanks!
  7.  
  8. /*============================================================================
  9.  *
  10.  *                       C L A S S E S
  11.  *
  12.  * ============================================================================
  13.  *
  14.  * List of classes and their definitions. Pass an
  15.  * identifier to PurchaseClass() / SetClass() to
  16.  * set a class to the player.
  17.  *
  18.  * Identifier constant chain MUST be in the same
  19.  * order as the actual class array.
  20.  *
  21.  * The class array is where the classes are actually
  22.  * defined in. Changes in here result in changes to class
  23.  * specs. New classes must use existing format and template.
  24.  *
  25.  * Array keys:
  26.  *  row 1:
  27.  *  - display name
  28.  *  - price (0 for free)
  29.  *  - speed (fixed point)
  30.  *  - dependency (constant)
  31.  *
  32.  *  row 2:
  33.  *  - armor grade (-1 - 5)
  34.  *  - armor modifier
  35.  *
  36.  *  row 3:
  37.  *  - frag grenades
  38.  *  - timed C4 count
  39.  *  - enhanced timed C4 (true/false)
  40.  *  - flags
  41.  *      - CF_NOPISTOL (no handgun)
  42.  *      - CF_HARVESTER (is a harvester)
  43.  *      - CF_SNIPER (has powered-up sniper)
  44.  *      - CF_STEALTH (is a stealth class)
  45.  *      - CF_WARNING (warning printed on purchase)
  46.  *      - CF_NOMECHS (cannot use mechs)
  47.  *      - CF_MEDIC (gets medic regeneration)
  48.  *      - CF_TIMECOP (counts as a timecop for limit)
  49.  *      - CF_SUPPORT (counts as a support class)
  50.  *
  51.  *  row 4:
  52.  *  - item 1 | primary weapon
  53.  *  - item 2 |
  54.  *  - item 3 | See a_items.acs for
  55.  *  - item 4 | item definitons
  56.  *  - item 5 |
  57.  *  - item 6 |
  58.  */
  59.  
  60. int Classes[MAX_CLASSES][MAX_CLASSKEYS] = {
  61.     /* {
  62.         "Name of class", cost, speed, dependency,
  63.         armor, armor_mod,
  64.         frags, c4, enhanced, flags,
  65.         item0, item1, item2, item3, item4, item5
  66.     } */
  67.    
  68.     {
  69.         "Gunman", 0, 1.0, DEP_NONE,
  70.         0, ARMOD_NOCHANGE,
  71.         1, 1, false, 0,
  72.         ITEM_SMG, 0, 0, 0, 0, 0
  73.     }, {
  74.         "Engineer", 0, 0.8, DEP_NONE,
  75.         0, ARMOD_NOCHANGE,
  76.         1, 1, true, 0,
  77.         ITEM_REPAIR, 0, 0, 0, 0, 0
  78.     }, {
  79.         "Minigunner", 400, 0.7, DEP_NONE,
  80.         1, ARMOD_NOCHANGE,
  81.         2, 1, false, 0,
  82.         ITEM_GATLING, 0, 0, 0, 0, 0
  83.     }, {
  84.         "Technician", 200, 0.8, DEP_NONE,
  85.         1, ARMOD_NOCHANGE,
  86.         2, 2, true, CF_SUPPORT,
  87.         ITEM_ADVREPAIR, ITEM_SMG, ITEM_MINE_X4, 0, 0, 0
  88.     }, {
  89.         "Flamer", 450, 0.7, DEP_BARRACKS,
  90.         1, ARMOD_FIRE,
  91.         2, 1, false, 0,
  92.         ITEM_FLAMER, 0, 0, 0, 0, 0
  93.     }, {
  94.         "Rifleman", 200, 0.9, DEP_NONE,
  95.         1, ARMOD_NOCHANGE,
  96.         2, 1, false, 0,
  97.         ITEM_RIFLE, 0, 0, 0, 0, 0
  98.     }, {
  99.         "Machine Gunner", 300, 0.9, DEP_NONE,
  100.         1, ARMOD_NOCHANGE,
  101.         2, 1, false, 0,
  102.         ITEM_MACHINEGUN, 0, 0, 0, 0, 0
  103.     }, {
  104.         "Grenadier", 550, 0.8, DEP_BARRACKS,
  105.         2, ARMOD_EXPLO,
  106.         4, 2, true, 0,
  107.         ITEM_GRENADE, ITEM_RIFLE, 0, 0, 0, 0
  108.     }, {
  109.         "Rocket Soldier", 500, 0.7, DEP_BARRACKS,
  110.         2, ARMOD_EXPLO,
  111.         2, 2, false, 0,
  112.         ITEM_MISSILE, ITEM_RIFLE, 0, 0, 0, 0
  113.     }, {
  114.         "Stealth Trooper", 600, 0.95, DEP_NONE,
  115.         -1, ARMOD_NOCHANGE,
  116.         2, 2, false, CF_STEALTH,
  117.         ITEM_STEALTH, ITEM_KNIFE, 0, 0, 0, 0
  118.     }, {
  119.         "Gauss Gunner", 600, 0.8, DEP_BARRACKS,
  120.         2, ARMOD_LASER,
  121.         2, 1, false, 0,
  122.         ITEM_GAUSS, ITEM_RIFLE, 0, 0, 0, 0
  123.     }, {
  124.         "Chem Warrior", 550, 0.7, DEP_BARRACKS,
  125.         2, ARMOD_CHEM,
  126.         2, 1, false, 0,
  127.         ITEM_CHEMSPRAY, 0, 0, 0, 0, 0
  128.     }, {
  129.         "Shock Trooper", 600, 0.7, DEP_CENTRE,
  130.         2, ARMOD_LASER,
  131.         2, 1, false, 0,
  132.         ITEM_SHOCKRIFLE, 0, 0, 0, 0, 0
  133.     }, {
  134.         "Commando", 1000, 0.85, DEP_CENTRE,
  135.         2, ARMOD_BULLET,
  136.         4, 2, true, CF_WARNING|CF_NOMECHS,
  137.         ITEM_GAUSS, ITEM_MISSILE, ITEM_GATLING, ITEM_RIFLE, 0, 0
  138.     }, {
  139.         "Shotgunner", 0, 0.8, DEP_NONE,
  140.         0, ARMOD_NOCHANGE,
  141.         1, 1, false, 0,
  142.         ITEM_SHOTGUN, 0, 0, 0, 0, 0
  143.     }, {
  144.         "Suicide Bomber", 1750, 1.0, DEP_NONE,
  145.         0, ARMOD_NOCHANGE,
  146.         0, 0, false, CF_NOPISTOL|CF_NOMECHS|CF_WARNING|CF_SUPPORT,
  147.         ITEM_BOMBPACK, 0, 0, 0, 0, 0
  148.     }, {
  149.         "Sniper", 750, 0.675, DEP_CENTRE,
  150.         1, ARMOD_NOCHANGE,
  151.         2, 1, false, CF_SNIPER,
  152.         ITEM_SNIPER, 0, 0, 0, 0, 0
  153.     }, {
  154.         "Utility Guy", 650, 0.75, DEP_NONE,
  155.         2, ARMOD_NOCHANGE,
  156.         1, 1, true, CF_NOMECHS|CF_SUPPORT,
  157.         ITEM_UTILITY, ITEM_REPAIR, 0, 0, 0, 0
  158.     }, {
  159.         "Demolitions Expert", 550, 0.75, DEP_NONE,
  160.         2, ARMOD_EXPLO,
  161.         4, 4, true, CF_NOMECHS|CF_SUPPORT,
  162.         ITEM_BOMBSQUAD, ITEM_SHOTGUN, ITEM_REMOTEC4, ITEM_MINE_X6, 0, 0
  163.     }, {
  164.         "Field Medic", 300, 0.85, DEP_NONE,
  165.         2, ARMOD_CHEM,
  166.         2, 1, false, CF_MEDIC|CF_SUPPORT,
  167.         ITEM_HEALGUN, ITEM_TIBRIFLEWEAK, ITEM_MEDFIELD, 0, 0, 0
  168.     }, {
  169.         "Laser Chaingunner", 650, 0.75, DEP_CENTRE,
  170.         2, ARMOD_LASER,
  171.         2, 1, false, 0,
  172.         ITEM_LASERCHAIN, 0, 0, 0, 0, 0
  173.     }, {
  174.         "Jet Trooper", 600, 0.65, DEP_BARRACKS,
  175.         2, ARMOD_NOCHANGE,
  176.         2, 1, false, 0,
  177.         ITEM_JETGUN, 0, 0, 0, 0, 0
  178.     }, {
  179.         "Tiberium Autorifleman", 400, 0.8, DEP_BARRACKS,
  180.         1, ARMOD_CHEM,
  181.         2, 1, false, 0,
  182.         ITEM_TIBRIFLE, 0, 0, 0, 0, 0
  183.     }, {
  184.         "Double Shotgunner", 200, 0.8, DEP_NONE,
  185.         1, ARMOD_NOCHANGE,
  186.         1, 1, false, 0,
  187.         ITEM_SSG, 0, 0, 0, 0, 0
  188.     }, {
  189.         "Plasma Gunner", 800, 0.7, DEP_CENTRE,
  190.         2, ARMOD_LASER,
  191.         2, 1, true, 0,
  192.         ITEM_PLASMA, 0, 0, 0, 0, 0
  193.     }, {
  194.         "Artillery Soldier", 600, 0.7, DEP_BARRACKS,
  195.         2, ARMOD_EXPLO,
  196.         2, 1, true, 0,
  197.         ITEM_ARTILLERY, ITEM_RIFLE, 0, 0, 0, 0
  198.     }, {
  199.         "Time Cop", 2000, 0.9, DEP_CENTRE,
  200.         2, ARMOD_NOCHANGE,
  201.         4, 2, true, CF_WARNING|CF_NOMECHS|CF_SUPPORT,
  202.         ITEM_TIMEGUN, ITEM_MACHINEGUN, 0, 0, 0, 0
  203.     }, {
  204.         "Advanced Harvester", 750, 0.8, DEP_REFINERY,
  205.         1, ARMOD_CHEM,
  206.         2, 1, false, CF_HARVESTER|CF_NOMECHS|CF_SUPPORT,
  207.         ITEM_MACHINEGUN, 0, 0, 0, 0, 0
  208.     }, {
  209.         "Tiberium Harvester", 0, 0.65, DEP_REFINERY,
  210.         0, ARMOD_CHEM,
  211.         1, 1, false, CF_HARVESTER|CF_SUPPORT,
  212.         ITEM_SMG, 0, 0, 0, 0, 0
  213.     }
  214. };
  215.  
  216. // Add-on definitions
  217. #define ADDON_BEACON 5
  218.  
  219. #define MAX_ADDONS 6
  220. #define MAX_ADDON_KEYS 3
  221.  
  222. #define ADK_NAME 0
  223. #define ADK_COST 1
  224. #define ADK_ITEM 2
  225. int AddOns[MAX_ADDONS][MAX_ADDON_KEYS] = {
  226.     {"+1 Armor", 250, ITEM_ARMORUP},
  227.     {"Tiberium Autorifle", 300, ITEM_TIBRIFLEWEAK},
  228.     {"Artillery Cannon", 550, ITEM_ARTILLERY},
  229.     {"Chainsaw", 250, ITEM_CHAINSAW},
  230.     {"Plasma Cannon", 1500, ITEM_BFG},
  231.     {"Superweapon Beacon", 1750, ITEM_BEACON}
  232. };
  233.  
  234. // Tries to purchase a class for the player. If purchase wasn't possible,
  235. // this returns the appropriate error message. Otherwise, returns 0.
  236. function str PurchaseClass (int id) {
  237.     int cost = Classes[id][CK_COST];
  238.    
  239.     // Check barracks
  240.     if (Classes[id][CK_DEPENDENCY] == DEP_BARRACKS)
  241.         if (!CheckBarracks (1-PlayerTeam ()))
  242.             return "Your barracks have been destroyed!";
  243.    
  244.     // Check research centre
  245.     if (Classes[id][CK_DEPENDENCY] == DEP_CENTRE)
  246.         if (!CheckPlant (1-PlayerTeam ()))
  247.             return "Your research centre has been destroyed!";
  248.    
  249.     // Check refinery
  250.     if (Classes[id][CK_DEPENDENCY] == DEP_REFINERY)
  251.         if (!CheckRefinery (1-PlayerTeam ()))
  252.             return "Your refinery has been destroyed!";
  253.    
  254.     // If the class is a time cop, we need to check the limit
  255.     int max = GetCVar ("aow_maxtimecopsperteam");
  256.     if (Classes[id][CK_FLAGS] & CF_TIMECOP && max > 0 && NumTimeCops[1-PlayerTeam ()] >= max)
  257.         return "Timecops at limit!";
  258.    
  259.     // Must not have a class already
  260.     if (!IsResigned())
  261.         return "You must resign first!";
  262.    
  263.     // Must afford it!
  264.     if (!CanAfford (cost))
  265.         return "You need more credits!";
  266.    
  267.     TakeInventory ("PurchaseToken", 1);
  268.     SpendCredits (cost);
  269.    
  270.     if (!SetClass (id, 0))
  271.         return "Couldn't set the class! Something's going nuts here!";
  272.    
  273.     return 0;
  274. }
  275.  
  276. // Sets the player class
  277. #define SCF_NOTELEPORT      1   // don't teleport the player to his base
  278. #define SCF_NOBEEP      2   // no beep sound
  279. function bool SetClass (int id, int scflags) {
  280.     if (id < 0 || id > MAX_CLASSES) {
  281.         Log (s:"SetClass: Tried to set an unknown class ", d:id, s:"!");
  282.         return false;
  283.     }
  284.    
  285.     int cflags = Classes[id][CK_FLAGS];
  286.     str name = Classes[id][CK_NAME];
  287.    
  288.     // Display message to purchaser
  289.     if (!(scflags & SCF_NOBEEP))
  290.         DisplayTick ();
  291.    
  292.     SetFont ("BIGFONT");
  293.     HudMessage (s:"You are a \cf", s:name, s:"!";
  294.         HUDMSG_FADEOUT, 1800+PlayerNumber(), CR_GREEN, 0.5, 0.45, 2.0, 1.0);
  295.    
  296.     // If the class is flagged as dangerous, also print a warning to others
  297.     if (cflags & CF_WARNING) {
  298.         SetFont ("SMALLFONT");
  299.         if (PlayerTeam () == TEAM_RED)
  300.             HudMessageBold (s:"\cGWarning: \cARed\cJ ", s:name, s:" in-field!";
  301.                 HUDMSG_FADEOUT, 15000, CR_WHITE,
  302.                 INTEL_XPOS, INTEL_YPOS, 2.0, 1.0);
  303.         else
  304.             HudMessageBold (s:"\cGWarning: \cNBlue\cJ ", s:name, s:" in-field!";
  305.                 HUDMSG_FADEOUT, 15000, CR_WHITE,
  306.                 INTEL_XPOS, INTEL_YPOS, 2.0, 1.0);
  307.     }
  308.    
  309.     // The essentials
  310.     GiveInventory ("HasClass", 1);
  311.     GiveInventory ("Refunds", Classes[id][CK_COST] / 2);
  312.     GiveInventory ("ClassID", id);
  313.    
  314.     // Speed and armor
  315.     SetSpeed (Classes[id][CK_SPEED]);
  316.     SetArmorGrade (Classes[id][CK_ARMOR], Classes[id][CK_ARMOD]);
  317.    
  318.     // Give a handgun unless undesired
  319.     if (!(cflags & CF_NOPISTOL))
  320.         GiveItem (ITEM_HANDGUN, false);
  321.    
  322.     // C4
  323.     int c4 = Classes[id][CK_C4];
  324.     if (c4 > 0) {
  325.         SetInventory ("TimedC4", c4);
  326.         SetInventory ("TimedC4Count", c4);
  327.     }
  328.    
  329.     // Frag grenades
  330.     SetFragGrenades (Classes[id][CK_FRAGS]);
  331.    
  332.     // If the class is a sniper, flag as such
  333.     if (cflags & CF_SNIPER)
  334.         GiveInventory ("IsSniper", 1);
  335.    
  336.     // If the class shouldn't use mechs, flag as such
  337.     if (cflags & CF_NOMECHS)
  338.         GiveInventory ("HighUpgrade", 1);
  339.    
  340.     // If the class is flagged as a medic, they should get the regeneration
  341.     if (cflags & CF_MEDIC) {
  342.         GiveInventory ("IsMedic", 1);
  343.         ACS_ExecuteAlways (352, 0);
  344.     }
  345.    
  346.     // If the class is counts as a time cop, the limit has to be
  347.     // recounted now.
  348.     if (cflags & CF_TIMECOP)
  349.         RecountTimeCops ();
  350.    
  351.     // If the class is flagged as a harvester, they should be able
  352.     // to collect Tiberium
  353.     if (cflags & CF_HARVESTER) {
  354.         GiveInventory ("IsHarvester", 1);
  355.         GiveInventory ("TiberiumProof", 1);
  356.        
  357.         // They do less damage than others
  358.         GiveInventory ("Grade0Damage", 1);
  359.        
  360.         // Info message
  361.         SetFont ("BIGFONT");
  362.         HudMessage (s:"Pick-up \cDtiberium crystals \c-and";
  363.             HUDMSG_FADEOUT, 1840+PlayerNumber(), CR_GRAY, 0.5, 0.6, 2.0, 1.0);
  364.         HudMessage (s:"return them to your \cDrefinery \c-for \cQcash!";
  365.             HUDMSG_FADEOUT, 1880+PlayerNumber(), CR_GRAY, 0.5, 0.65, 2.0, 1.0);
  366.     }
  367.    
  368.     // Stealth troopers have a specific death sound
  369.     if (cflags & CF_STEALTH)
  370.         SetActorProperty (0, APROP_DeathSound, "stealth/death");
  371.    
  372.     // Give the player the weapons and items. The weapon
  373.     // in the first slot is considered primary, and
  374.     // the player will select it.
  375.     for (int i = 0; i <= 5; i++)
  376.         GiveItem (Classes[id][CK_ITEM0 + i], !i);
  377.    
  378.     // Check for rank for possible upgrades
  379.     ACS_ExecuteAlways (91, 0);
  380.    
  381.     // Send the player to field unless undesired
  382.     if (!(scflags & SCF_NOTELEPORT)) {
  383.         ACS_ExecuteAlways (961, 0, 1-PlayerTeam ());
  384.         GiveInventory ("SpawnInvulnerability", 1);
  385.     }
  386.    
  387.     // Save the player speed for morph handling
  388.     PlayerSpeeds[PlayerNumber()] = Classes[id][CK_SPEED];
  389.    
  390.     Log(n:0, s:" becomes ", s:Classes[id][CK_NAME]);
  391.     return true;
  392. }
  393.  
  394. /* Class scripts. This (and a_weapons) is what
  395.  * remains of that old copy/paste nightmare ;)
  396.  *
  397.  * These now just call the menu
  398.  */
  399. script 20 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  400. script 21 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  401. script 22 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  402. script 23 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  403. script 24 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  404. script 25 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  405. script 26 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  406. script 27 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  407. script 28 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  408. script 29 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  409. script 33 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  410. script 35 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  411. script 38 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  412. script 62 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  413. script 40 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  414. script 41 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  415. script 42 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  416. script 43 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  417. script 44 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  418. script 52 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  419. script 53 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  420. script 54 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  421. script 60 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  422. script 61 (void) ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  423.  
  424. // Classes with post-purchase sounds
  425. script 39 (void) {
  426.     /*if (PurchaseClass (CLASS_TIMECOP)) {
  427.         Delay(35*6);
  428.         ActivatorSound ("misc/commando", 127);
  429.     }*/
  430.     ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  431. }
  432.  
  433. script 34 (void) {
  434.     /*if (PurchaseClass (CLASS_CHEMWARRIOR)) {
  435.         delay (35*6);
  436.         ActivatorSound ("misc/chem", 127);
  437.     }*/
  438.     ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  439. }
  440.  
  441. script 36 (void) {
  442.     /*if (PurchaseClass (CLASS_COMMANDO)) {
  443.         Delay(35*6);
  444.         ActivatorSound ("misc/commando", 127);
  445.     }*/
  446.     ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  447. }
  448.  
  449. script 63 (void) {
  450.     /*if (PurchaseClass (CLASS_HARVESTER)) {
  451.         delay (35*6);
  452.         ActivatorSound ("misc/chem", 127);
  453.     }*/
  454.     ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  455. }
  456.  
  457. script 64 (int Team) {
  458.     /*if (PurchaseClass (CLASS_ADVHARVESTER)) {
  459.         delay (35*6);
  460.         ActivatorSound ("misc/chem", 127);
  461.     }*/
  462.     ACS_ExecuteAlways (970, 0, MENU_PURCHASE);
  463. }
  464.  
  465. // A player tries to buy an addon from the menu
  466. function void MenuAddonPurchase (int sel1) {
  467.     if (sel1 < 0 || sel1 > MAX_ITEMS) {
  468.         MenuResponse (MSGTYPE_ERROR, "Bad item!");
  469.         return;
  470.     }
  471.    
  472.     str name = AddOns[sel1][ADK_NAME];
  473.     int cost = AddOns[sel1][ADK_COST];
  474.     int item = AddOns[sel1][ADK_ITEM];
  475.    
  476.     // Check if the player already has this
  477.     if (Items[item][IK_WEAPONNAME] != 0) {
  478.         if (CheckInventory (Items[item][IK_WEAPONNAME])) {
  479.             MenuResponse (MSGTYPE_ERROR, "You already have this!");
  480.             return;
  481.         }
  482.     } else if (Items[item][IK_AMMONAME] != 0) {
  483.         if (CheckInventory (Items[item][IK_AMMONAME])) {
  484.             MenuResponse (MSGTYPE_ERROR, "You already have this!");
  485.             return;
  486.         }
  487.     } else {
  488.         MenuResponse (MSGTYPE_ERROR, "Bad item!");
  489.         return;
  490.     }
  491.    
  492.     // Item-specific checks
  493.     switch (item) {
  494.     case ITEM_BFG:
  495.         // === Plasma cannon
  496.         // Gamemasters go past all this
  497.         if (IsAdmin[PlayerNumber()])
  498.             break;
  499.        
  500.         // Check cooldown
  501.         if (PlasmaCooldown[PlayerNumber()] > Timer()) {
  502.             int wait = (PlasmaCooldown[PlayerNumber()] - Timer()) / 35;
  503.             LocalAmbientSound ("misc/nope", 127);
  504.             HudMessage(s:"You must wait \cF", d:wait, s:" seconds\c- before\n",
  505.                 s:"purchasing another \cNplasma cannon!";
  506.                 HUDMSG_FADEOUT, MENU_HID + 100, CR_RED, UMENU_X5, UMENU_Y5, 2.0, 1.0);
  507.             return;
  508.         }
  509.        
  510.         int max = GetCVAR("aow_maxcannonsperteam");
  511.         if (NumPlasmaCannons[PlayerTeam()] >= max && max != -1) {
  512.             MenuResponse (MSGTYPE_ERROR, "Your team already has too many of those!");
  513.             return;
  514.         }
  515.        
  516.         if (Timer() < CannonPurchaseDelay) {
  517.             LocalAmbientSound ("misc/nope", 127);
  518.             HudMessage(s:"You must wait \cF", d:(CannonPurchaseDelay - Timer()) / 60,
  519.                 s:" seconds\nbefore you can get one of these!";
  520.                 HUDMSG_FADEOUT, MENU_HID + 100, CR_RED, UMENU_X5, UMENU_Y5, 2.0, 1.0);
  521.             return;
  522.         }
  523.        
  524.         // Warning
  525.         SetFont ("SMALLFONT");
  526.         if (PlayerTeam () == TEAM_RED)
  527.             HudMessageBold (s:"\cGWarning: \cARed\cJ player has \cNPlasma Cannon!";
  528.                 HUDMSG_FADEOUT, 15000, CR_WHITE,
  529.                 INTEL_XPOS, INTEL_YPOS, 2.0, 1.0);
  530.         else
  531.             HudMessageBold (s:"\cGWarning: \cNBlue\cJ player has \cNPlasma Cannon!";
  532.                 HUDMSG_FADEOUT, 15000, CR_WHITE,
  533.                 INTEL_XPOS, INTEL_YPOS, 2.0, 1.0);
  534.        
  535.         // Limits
  536.         RecountPlasma ();
  537.         break;
  538.     case ITEM_BEACON:
  539.         if (IsAdmin[PlayerNumber()])
  540.             break;
  541.        
  542.         // Check if we already have the beacon
  543.         if (CheckInventory("IonCannonBeacon") || CheckInventory("NuclearStrikeBeacon")) {
  544.             MenuResponse (MSGTYPE_ERROR, "You already have that!");
  545.             return;
  546.         }
  547.        
  548.         // Check cooldown
  549.         int time = (BeaconPurchaseDelay - (Timer() - LastPurchasedBeacon[PlayerTeam()]) / 35);
  550.         if (time > 0) {
  551.             int mins = BlueBeaconTime/60 - Timer()/(35*60);
  552.             int secs = 59 - (Timer()/35)%60;
  553.            
  554.             LocalAmbientSound ("misc/nope", 127);
  555.             HudMessage (s:"You must wait \cF", d:time, s:" seconds\nbefore you can get one of these!";
  556.                 HUDMSG_FADEOUT, MENU_HID + 100, CR_RED, UMENU_X5, UMENU_Y5, 2.0, 1.0);
  557.             return;
  558.         }
  559.         LastPurchasedBeacon[PlayerTeam()] = Timer();
  560.        
  561.         // Warning announcement
  562.         if (PlayerTeam () == TEAM_BLUE)
  563.             HudMessageBold (s:"\cGWarning: \cNBlue\cJ team has \cNIon Cannon Beacon!";
  564.                 HUDMSG_FADEOUT, 15000, CR_WHITE,
  565.                 INTEL_XPOS, INTEL_YPOS, 2.0, 1.0);
  566.         else
  567.             HudMessageBold (s:"\cGWarning: \cARed\cJ team has \cANuclear Strike Beacon!";
  568.                 HUDMSG_FADEOUT, 15000, CR_WHITE,
  569.                 INTEL_XPOS, INTEL_YPOS, 2.0, 1.0);
  570.         break;
  571.     }
  572.    
  573.     // Check cost
  574.     Log (s:AddOns[sel1][ADK_NAME], s:" costs ", d:AddOns[sel1][ADK_COST]);
  575.     if (CheckCredits () < cost) {
  576.         MenuResponse (MSGTYPE_ERROR, "You need more credits!");
  577.         return;
  578.     }
  579.    
  580.     // Item is good, give it to the player
  581.     SpendCredits (cost);
  582.     GiveItem (item, false);
  583.    
  584.     str dname = GetAddOnName (sel1);
  585.    
  586.     Log(n:0, s:" purchases ", s:dname, s:".");
  587.    
  588.     // Tell the player he got the item
  589.     SetFont ("SMALLFONT");
  590.     LocalAmbientSound ("c4/use", 127);
  591.     HudMessage (s:"You got the \cf", s:dname, s:"\c-!";
  592.         HUDMSG_FADEOUT, MENU_HID + 100, CR_GREEN, UMENU_X4, UMENU_Y4 - 0.2, 3.0, 1.0);
  593.    
  594.     // Special messages
  595.     switch (item) {
  596.     case ITEM_CHAINSAW:
  597.         HudMessage(s:"Use Alt-Fire to throw the chainsaw!";
  598.             HUDMSG_FADEOUT, MENU_HID + 101, CR_GREEN, UMENU_X4, UMENU_Y4 - 0.225, 4.0, 1.0);
  599.         break;
  600.     case ITEM_BEACON:
  601.         HudMessage(s:"Place this in front of an \cAenemy MCT\cJ and guard\n",
  602.             s:"it for \cU60 seconds\cJ for \cKcertain destruction!";
  603.             HUDMSG_FADEOUT, MENU_HID + 101, CR_GREEN, UMENU_X4, UMENU_Y4 - 0.225, 8.0, 1.0);
  604.         break;
  605.     }
  606. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement