home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / items.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  12.2 KB  |  531 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  MoH: Allied Assault Script File  
  4. //  Global function: For giving items and placing item icons on the HUD
  5. //  Script Written By: Benson 'elmagoo' Russell
  6. //
  7. ////////////////////////////////////////////////////////////////////////////////////////
  8.  
  9. //**************************************************************************
  10. //*** add items to inventory
  11. //*** this will put an item into the players inventory
  12. //*** syntax --------------------------------
  13. //*** add_item <item>
  14. //**************************************************************************
  15. add_item local.passed_item local.nomessage:
  16.  
  17.     //*** check to see if the counter has been initialized
  18.     if (level.item_total == NIL)
  19.     {
  20.         level.item_total = 0
  21.     }
  22.  
  23.     //*** check to see if there are already 6 items in the inventory
  24.     if (level.item_total >= 6)
  25.     {
  26.         println "^~^~^ Can't have more than 6 items in player's inventory!!"
  27.         goto add_item_end
  28.     }
  29.  
  30.     //*** assign the proper graphic for the item
  31.     switch (local.passed_item)
  32.     {
  33.         case "camera":
  34.             local.item_graphic = "textures/hud/item_camera"
  35.             local.item = "camera"
  36.  
  37.             if (local.nomessage == NIL)
  38.             {
  39.                 iprintln "You have acquired the spy camera!"
  40.             }
  41.  
  42.             $player item models/items/camera.tik
  43.             break
  44.  
  45.         case "binoculars":
  46.             local.item_graphic = "textures/hud/item_binoculars"
  47.             local.pickup_sound = "pickup_explosives"
  48.             local.item = "binoculars"
  49.  
  50.             if (local.nomessage == NIL)
  51.             {
  52.                 iprintln "You have acquired the binoculars!"
  53.             }
  54.  
  55.             $player item models/items/binoculars.tik
  56.             break
  57.  
  58.         case "bangalores":
  59.             local.item_graphic = "textures/hud/item_bangalore"
  60.             local.pickup_sound = "pickup_bangalore"
  61.             local.item = "bangalores"
  62.  
  63.             if (local.nomessage == NIL)
  64.             {
  65.                 iprintln "You have acquired the bangalores!"
  66.             }
  67.  
  68.             break
  69.  
  70.         case "battery":
  71.             local.item_graphic = "textures/hud/item_battery"
  72.             local.item = "battery"
  73.  
  74.             if (local.nomessage == NIL)
  75.             {
  76.                 iprintln "You have acquired the battery!"
  77.             }
  78.  
  79.             break
  80.  
  81.         case "clipboard":
  82.             local.item_graphic = "textures/hud/item_clipboard"
  83.             //local.pickup_sound = "pickup_clipboard"
  84.             local.pickup_sound = "pickup_papers"
  85.             local.item = "clipboard"
  86.  
  87.             if (local.nomessage == NIL)
  88.             {
  89.                 iprintln "You have acquired the manifest!"
  90.             }
  91.  
  92.             break
  93.  
  94.         case "radar_blueprints":
  95.             local.item_graphic = "textures/hud/item_radar_blueprints"
  96.             local.pickup_sound = "pickup_papers"
  97.             local.item = "radar_blueprints"
  98.  
  99.             if (local.nomessage == NIL)
  100.             {
  101.                 iprintln "You have acquired the Naxos radar blueprints!"
  102.             }
  103.  
  104.             break
  105.  
  106.         case "radar_notes":
  107.             local.item_graphic = "textures/hud/item_radar_notes"
  108.             local.pickup_sound = "pickup_papers"
  109.             local.item = "radar_notes"
  110.  
  111.             if (local.nomessage == NIL)
  112.             {
  113.                 iprintln "You have acquired the Naxos radar research notes!"
  114.             }
  115.  
  116.             break
  117.  
  118.         case "uboat_blueprints":
  119.             local.item_graphic = "textures/hud/item_uboat_blueprints"
  120.             local.pickup_sound = "pickup_papers"
  121.             local.item = "uboat_blueprints"
  122.  
  123.             if (local.nomessage == NIL)
  124.             {
  125.                 iprintln "You have acquired the Naxos uboat blueprints!"
  126.             }
  127.  
  128.             break
  129.  
  130.         case "uboat_notes":
  131.             local.item_graphic = "textures/hud/item_uboat_notes"
  132.             local.pickup_sound = "pickup_papers"
  133.             local.item = "uboat_notes"
  134.  
  135.             if (local.nomessage == NIL)
  136.             {
  137.                 iprintln "You have acquired the Naxos uboat research notes!"
  138.             }
  139.  
  140.             break
  141.  
  142.         case "explosive":
  143.             local.item = "explosive"
  144.             // no break
  145.  
  146.         case "explosives":
  147.             local.item_graphic = "textures/hud/item_explosive"
  148.             local.pickup_sound = "pickup_explosives"
  149.             if (local.item == NIL)
  150.             {
  151.                 local.item = "explosives"
  152.             }
  153.  
  154.             if (local.nomessage == NIL)
  155.             {
  156.                 iprintln "You have acquired explosives!"
  157.             }
  158.  
  159.             break
  160.  
  161.         case "radio_explosives":
  162.             local.item_graphic = "textures/hud/item_radio_explosive"
  163.             local.pickup_sound = "pickup_explosives"
  164.             if (local.item == NIL)
  165.             {
  166.                 local.item = "radio_explosives"
  167.             }
  168.  
  169.             if (local.nomessage == NIL)
  170.             {
  171.                 iprintln "You have acquired radio detonated explosives!"
  172.             }
  173.  
  174.             break
  175.  
  176.         case "gasmask":
  177.             local.item_graphic = "textures/hud/item_gasmask"
  178.             local.pickup_sound = "pickup_gasmask"
  179.             local.item = "gasmask"
  180.  
  181.             if (local.nomessage == NIL)
  182.             {
  183.                 iprintln "You have acquired the gas mask!"
  184.             }
  185.  
  186.             break
  187.  
  188.         case "papers_level1":
  189.             local.item_graphic = "textures/hud/item_papers1"
  190.             local.pickup_sound = "pickup_papers"
  191.             local.item = "papers_level1"
  192.             $player item models/items/papers.tik
  193.  
  194.             if (local.nomessage == NIL)
  195.             {
  196.                 iprintln "You have acquired level 1 papers!"
  197.             }
  198.  
  199.             level.papers = 1
  200.             break
  201.  
  202.         case "papers_level2":
  203.             local.item_graphic = "textures/hud/item_papers2"
  204.             local.pickup_sound = "pickup_papers"
  205.             local.item = "papers_level2"
  206.             $player item models/items/papers2.tik
  207.  
  208.             if (local.nomessage == NIL)
  209.             {
  210.                 iprintln "You have acquired level 2 papers!"
  211.             }
  212.  
  213.             level.papers = 2
  214.             break
  215.  
  216.         case "wirecutters":
  217.             local.item = "wirecutters"
  218.             // no break
  219.  
  220.         case "wirecutter":
  221.             local.item = "wirecutter"
  222.             // no break
  223.  
  224.         case "cutters":
  225.             local.item = "cutters"
  226.             // no break
  227.  
  228.         case "cutter":
  229.             local.item_graphic = "textures/hud/item_wirecutters"
  230.             if (local.item == NIL)
  231.             {
  232.                 local.item = "cutter"
  233.             }
  234.  
  235.             if (local.nomessage == NIL)
  236.             {
  237.                 iprintln "You have acquired the wirecutters!"
  238.             }
  239.  
  240.             break
  241.  
  242.         case "radio":
  243.             local.item_graphic = "textures/hud/item_radio"
  244.             local.pickup_sound = "radio_click"
  245.             local.item = "radio"
  246.  
  247.             if (local.nomessage == NIL)
  248.             {
  249.                 iprintln "You have acquired the radio!"
  250.             }
  251.  
  252.             break
  253.  
  254.         case "uniform":
  255.             local.item_graphic = "textures/hud/item_uniform"
  256.             local.pickup_sound = "pickup_uniform"
  257.             local.item = "uniform"
  258.  
  259.             if (local.nomessage == NIL)
  260.             {
  261.                 iprintln "You have acquired a German officers uniform!"
  262.             }
  263.  
  264.             $player.has_disguise = 1
  265.             setcvar g_playermodel "german_waffenss_officer"
  266.  
  267.             break
  268.  
  269.         case "stg44_blueprints":
  270.             local.item_graphic = "textures/hud/item_stg44_blueprints"
  271.             local.pickup_sound = "pickup_papers"
  272.             local.item = "stg44_blueprints"
  273.  
  274.             if (local.nomessage == NIL)
  275.             {
  276.                 iprintln "You have acquired the StG44 blueprints!"
  277.             }
  278.  
  279.             break
  280.  
  281.         case "tigerii_manual":
  282.             local.item_graphic = "textures/hud/item_tigerii_manual"
  283.             local.pickup_sound = "pickup_papers"
  284.             local.item = "tigerii_manual"
  285.  
  286.             if (local.nomessage == NIL)
  287.             {
  288.                 iprintln "You have acquired the King Tiger field manual!"
  289.             }
  290.  
  291.             break
  292.  
  293.         case "battleplans":
  294.             local.item_graphic = "textures/hud/item_battleplans"
  295.             local.pickup_sound = "pickup_papers"
  296.             local.item = "battleplans"
  297.  
  298.             if (local.nomessage == NIL)
  299.             {
  300.                 iprintln "You have acquired the German battle plans!"
  301.             }
  302.  
  303.             break
  304.  
  305.         case "stickybomb":
  306.             local.item = "stickybomb"
  307.             local.item_graphic = "textures/hud/item_stickybomb"
  308.             local.pickup_sound = "stickybomb_pickup"
  309.  
  310.             if (local.nomessage == NIL)
  311.             {
  312.                 iprintln "You have acquired sticky bombs!"
  313.             }
  314.  
  315.             break
  316.  
  317.         case "charges0":
  318.             local.item = "charges0"
  319.             local.item_graphic = "textures/hud/democharge0"
  320.             break
  321.  
  322.         case "charges1":
  323.             local.item = "charges1"
  324.             local.item_graphic = "textures/hud/democharge1"
  325.             break
  326.  
  327.         case "charges2":
  328.             local.item = "charges2"
  329.             local.item_graphic = "textures/hud/democharge2"
  330.             break
  331.  
  332.         case "charges3":
  333.             local.item = "charges3"
  334.             local.item_graphic = "textures/hud/democharge3"
  335.             break
  336.  
  337.         case "charges4":
  338.             local.item = "charges4"
  339.             local.item_graphic = "textures/hud/democharge4"
  340.             break
  341.  
  342.         case "charges5":
  343.             local.item = "charges5"
  344.             local.item_graphic = "textures/hud/democharge5"
  345.             break
  346.  
  347.         //*** the default is selected if the scripter enter a non-valid item
  348.         default:
  349.             println "^~^~^ " local.item " is not a valid inventory item!!"
  350.             goto add_item_end
  351.             break
  352.     }
  353.  
  354.     //*** up the item total counter
  355.     level.item_total += 1
  356.  
  357.     //*** shuffle the inventory items down 1 slot each
  358.     for (local.i = level.item_total ; local.i > 1 ; local.i --)
  359.     {
  360.         level.item_graphic[local.i] = level.item_graphic[(local.i - 1)]
  361.         level.item[local.i] = level.item[(local.i - 1)]
  362.         huddraw_shader (local.i + 20) level.item_graphic[local.i]
  363.     }
  364.  
  365.     //*** add the new item
  366.     level.item_graphic[1] = local.item_graphic
  367.     level.item[1] = local.item
  368.     huddraw_shader 21 level.item_graphic[1]
  369.  
  370.     //*** play the proper sound
  371.     if (local.pickup_sound != NIL)
  372.     {
  373.         $player playsound local.pickup_sound
  374.     }
  375.  
  376.     //*** draw the items on the screen
  377.     thread draw_items
  378.  
  379. add_item_end:
  380. end
  381.  
  382.  
  383. //**************************************************************************
  384. //*** remove items from inventory
  385. //*** this will remove an item from the players inventory
  386. //*** syntax --------------------------------
  387. //*** remove_item <item>
  388. //**************************************************************************
  389. remove_item local.item:
  390.  
  391.     //*** check to see if the counter has been initialized
  392.     if (level.item_total == NIL)
  393.     {
  394.         level.item_total = 0
  395.     }
  396.  
  397.     //*** if the inventory is already empty, exit
  398.     if (level.item_total <= 0)
  399.     {
  400.         println "^~^~^ There are no items currently in the players inventory!!"
  401.         goto remove_item_end
  402.     }
  403.  
  404.     for (local.i = 1 ; local.i <= 6 ; local.i ++)
  405.     {
  406.         if (level.item[local.i] == local.item)
  407.         {
  408.             local.index = local.i
  409.             goto remove_item_remove
  410.         }
  411.     }
  412.  
  413.     //*** if the item isn't in the players inventory tell the scripter
  414.     println "^~^~^ " local.item " can not be removed, it is not in the players inventory!!"
  415.     goto remove_item_end
  416.  
  417. //*** remove the item and shuffle the remaining inventory down a slot
  418. remove_item_remove:
  419.  
  420.     //*** check to see if it's a useable item that needs removing
  421.     if (local.item == "camera")
  422.     {
  423.         $player take models/items/camera.tik
  424.     }
  425.     else if (local.item == "binoculars")
  426.     {
  427.         $player take models/items/binoculars.tik
  428.     }
  429.     else if (local.item == "papers_level1")
  430.     {
  431.         $player take models/items/papers.tik
  432.         level.papers = 0
  433.     }
  434.     else if (local.item == "papers_level2")
  435.     {
  436.         $player take models/items/papers2.tik
  437.         level.papers = 0
  438.     }
  439.     else if (local.item == "uniform")
  440.     {
  441.         setcvar g_playermodel "american_army"
  442.         $player.has_disguise = 0
  443.     }
  444.  
  445.     //*** remove the item and shuffle the rest down a slot
  446.     for (local.j = local.index ; local.j < level.item_total ; local.j ++)
  447.     {
  448.         
  449.         level.item_graphic[local.j] = level.item_graphic[(local.j + 1)]
  450.         level.item[local.j] = level.item[(local.j + 1)]
  451.         huddraw_shader (local.j + 20) level.item_graphic[local.j]
  452.  
  453.         level.item_graphic[(local.j + 1)] = ""
  454.         level.item[(local.j + 1)] = ""
  455.     }
  456.  
  457.     level.item_total -= 1
  458.  
  459.     //*** draw the items on the screen
  460.     thread draw_items
  461.  
  462. remove_item_end:
  463. end
  464.  
  465.  
  466.  
  467. //************************************************
  468. // draw the item icons
  469. //************************************************
  470. draw_items:
  471.  
  472.     //*** variables to base the position off of, positions for all the item slots
  473.     local.xpos = -384
  474.     local.ypos = 8
  475.  
  476.     huddraw_align 21 right top
  477.     huddraw_align 22 right top
  478.     huddraw_align 23 right top
  479.     huddraw_align 24 right top
  480.     huddraw_align 25 right top
  481.     huddraw_align 26 right top
  482.  
  483.     //*** draw the items on the hud
  484.     for (local.j = 1 ; local.j <= 6 ; local.j ++)
  485.     {
  486.         local.xpos = -70 * local.j - 8
  487.         huddraw_rect (local.j + 20) local.xpos local.ypos 64 64
  488.  
  489.         if (local.j > level.item_total)
  490.         {
  491.             huddraw_alpha (local.j + 20) 0
  492.             goto draw_item_next
  493.         }
  494.  
  495.         huddraw_alpha (local.j + 20) 0.7
  496. draw_item_next:
  497.     }
  498.  
  499. end
  500.  
  501.  
  502. //************************************************
  503. // reload all the item slots
  504. //************************************************
  505. reload_items:
  506.  
  507.     waitthread blank_items
  508.  
  509.     for (local.i = 1 ; local.i <= 6 ; local.i ++)
  510.     {
  511.         huddraw_shader (local.i + 20) level.item_graphic[local.i]
  512.     }
  513.  
  514.     thread draw_items
  515.  
  516. end
  517.  
  518.  
  519. //************************************************
  520. // blank all the item slots
  521. //************************************************
  522. blank_items:
  523.  
  524.     huddraw_alpha 21 0
  525.     huddraw_alpha 22 0
  526.     huddraw_alpha 23 0
  527.     huddraw_alpha 24 0
  528.     huddraw_alpha 25 0
  529.     huddraw_alpha 26 0
  530.  
  531. end