home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / movement / Parachute.lua < prev    next >
Encoding:
Text File  |  2009-09-27  |  1.8 KB  |  60 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Parachute
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, August 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.parachute={}
  10.  
  11. -- Load & Prepare Ressources
  12. cc.parachute.gfx_wpn=loadgfx("weapons/parachute.bmp")                        -- Weapon Image
  13. setmidhandle(cc.parachute.gfx_wpn)
  14. --cc.parachute.sfx_wpn=loadsfx("parachute.wav")                                -- parachute Sound
  15.  
  16. --------------------------------------------------------------------------------
  17. -- Weapon: Parachute
  18. --------------------------------------------------------------------------------
  19.  
  20. cc.parachute.id=addweapon("cc.parachute","Parachute",cc.parachute.gfx_wpn,1)    -- Add Weapon (1 use)
  21.  
  22. function cc.parachute.draw()                                                    -- Draw
  23.     if weapon_mode==1 then
  24.         setblend(blend_alpha)
  25.         setalpha(0.9)
  26.         setcolor(255,255,255)
  27.         setscale(getplayerdirection(0),1)
  28.         setrotation(0)
  29.         drawimage(cc.parachute.gfx_wpn,getplayerx(0),getplayery(0)-8)
  30.         -- HUD Info
  31.         hudinfo("Press [Space] to deactivate the parachute!")
  32.     elseif weapon_shots==0 then
  33.         -- HUD Info
  34.         hudinfo("Parachute will be activated automatically when falling!")
  35.     end
  36. end
  37.  
  38. function cc.parachute.attack(attack)                                        -- Attack
  39.     if (weapon_mode==0) and (weapon_shots==0) then
  40.         if getplayeryspeed(0)>7.0 then
  41.             -- Use weapon and allow to use another one afterwards (1)
  42.             useweapon(1)
  43.             -- Activate
  44.             weapon_mode=1
  45.             weapon_shots=1
  46.         end
  47.     end
  48.     -- Control fallspeed if parachute is active
  49.     if (weapon_mode==1) then
  50.         -- Disable parachute
  51.         if attack==1 or getplayeryspeed(0)<1.0 then
  52.             weapon_mode=0
  53.         end
  54.         if getframesleft()<=1 then
  55.             weapon_mode=0
  56.         end
  57.         -- Control fallspeed
  58.         playerpush(0,getwind()*10.0,1.0,1)
  59.     end
  60. end