Advertisement
BarTwoOne

my questions "////" d3_mgun

Feb 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 33.72 KB | None | 0 0
  1. /***********************************************************************
  2.  
  3.   weapon_machinegun.script
  4.  
  5.  ***********************************************************************/
  6. /*
  7. CATEGORY: AVERAGE WEAPONS
  8. ZOOM (FOV Value): 85
  9. ADS TYPES: 1- DEFAULT; 2- SHOULDERED; 3- SCOPED
  10. ADS MODE: 2
  11. SPREAD NORMAL: 1.5 - 7 MAX
  12. SPREAD ADS MODE: 0.3 - 3 MAX
  13.  */
  14.  
  15.  
  16. #define MACHINEGUN_BASE_FIRERATE    0.3     // RATE OF FIRE at which       spread will be minimum
  17. #define MACHINEGUN_LOWAMMO          10
  18. #define MACHINEGUN_SEMIAUTO_RATE        0.10                                                //// WHY IT IS DEFINED TWICE ? FIRST
  19.  
  20.  
  21.  
  22. #define MACHINEGUN_FIRERATE         0.08    // A fast motherfucker
  23. #define MACHINEGUN_FIRERATE_ADS     0.08
  24. #define MACHINEGUN_NUMPROJECTILES       1
  25.  
  26. #define MACHINEGUN_IDLE_TO_LOWER        4
  27. #define MACHINEGUN_IDLE_TO_FIRE     0
  28. #define MACHINEGUN_IDLE_TO_RELOAD       4
  29. #define MACHINEGUN_RAISE_TO_IDLE        4
  30. #define MACHINEGUN_FIRE_TO_IDLE     0
  31. #define MACHINEGUN_RELOAD_TO_IDLE       4
  32.  
  33. #define MACHINEGUN_SPREAD_SIGHTS        0.3
  34. #define MACHINEGUN_MAX_SPREAD_SIGHTS    3
  35.  
  36.  
  37. #define MACHINEGUN_SEMIAUTO_RATE        0.03                                                //// WHY IT IS DEFINED TWICE ? SECOND
  38. #define MACHINEGUN_SEMIBURST_ROUNDS     3 //Triple shot burst, like pistol//0x29a
  39.  
  40.  
  41. //Sight Augmentation //0x29a
  42. #define MACHINEGUN_SPREAD               0.95
  43. #define MACHINEGUN_MAX_SPREAD           2.5
  44. #define MACHINEGUN_SPREAD_FLASH         4
  45. #define MACHINEGUN_MAX_SPREAD_FLASH     8
  46. #define MACHINEGUN_SPREAD_ZOOMED        0.2
  47. #define MACHINEGUN_MAX_SPREAD_ZOOMED    0.8
  48. #define MACHINEGUN_SPREAD_RUNNING       1.5
  49. #define MACHINEGUN_MAX_SPREAD_RUNNING   4.5
  50. #define MACHINEGUN_SPREAD_CROSSHAIR     1.5
  51. #define MACHINEGUN_SPREAD_CROSSHAIR_MAX 7
  52.  
  53.  
  54.  
  55.  
  56.  
  57. #ifndef _GLOBAL_FLASH_INTENSITY_
  58. float global_flashlight_intensity = 1.0;
  59. #define _GLOBAL_FLASH_INTENSITY_
  60. #endif
  61.  
  62. object weapon_machinegun : weapon_base {
  63.     float       next_attack;
  64.         boolean holdButton;
  65.         float projType;
  66.     float       spread;
  67.     float currentRound;
  68.         float       spread_max;
  69.         float       gradual_spread;
  70.         float       buttons;
  71.         float       spread_incrementation_factor;
  72.         void        init();
  73.         void        Lower();
  74.         void        Raise();
  75.         void        Idle();
  76.         void        Fire();
  77.         void        Reload();
  78.         //"Iron Sights" setcvar(gunx,y,z,) taken directly from CED ASSETS PACK
  79.         void        ADS_IN();
  80.         void        ADS_OUT();
  81.         void        ExitCinematic();
  82.         float       currentRound;
  83.     float     mgunlight;
  84.         float     mgunlaser;
  85.         boolean     laddery;
  86.         boolean     inmelee;
  87.        
  88.        
  89.        
  90.         boolean     switched;
  91.     boolean     f_toggle;
  92.        
  93.         float       next_attack;
  94.         float       spread;
  95.         float       light;
  96.         boolean     aimOnce;
  97.         boolean     isZoomed;
  98.         void        init();
  99.         void        ToggleOnOff();
  100.  
  101.        
  102.         float next_semiauto;
  103.         void        NoAmmo();
  104.  
  105.         boolean     AlphaLabs2;
  106.     float   intensity;
  107.         void Melee();
  108.    
  109.        
  110.     float       clip1;
  111.     float       clip2;
  112.     float       clip3;
  113.     float       clip4;
  114.     float       clip5;
  115.     float       current_clip;
  116.     float       clip_to_adjust;
  117.     float       getAmmo();
  118.     void        decrementClip();
  119.     float       getSmallestClipNo();
  120.     float       getClipNo();
  121.     void        adjustAmmo();
  122.     void        alignAmmo();
  123.     void        alignClip();
  124.     float       getCurrentValue();
  125.     void        getClips();
  126.     void        setClips();
  127.     float       canReload();
  128.     float       isZero();
  129. };
  130.  
  131. float weapon_machinegun::isZero() {
  132.     return clip1+clip2+clip3+clip4+clip5;
  133. }
  134.  
  135. float weapon_machinegun::canReload(){
  136.         float i = 0;
  137.         float oldAmmo = ammoAvailable() - ammoInClip();
  138.         float oldClip = ammoInClip();
  139.         adjustAmmo();
  140.         float val = ammoInClip();
  141.         if(clip1 <= val && clip2 <= val && clip3 <= val && clip4 <= val && clip5 <= val){
  142.             if(getClipNo() == current_clip && getCurrentValue() != ammoInClip()){
  143.                 return 1;
  144.             }else{
  145.                 float AMMO_GAME = ammoAvailable();
  146.                 for(i;i<AMMO_GAME;i++){
  147.                     useBullet();
  148.                 }
  149.                 addToClip(0,-oldAmmo,1);
  150.                 if(ammoInClip() == 0){
  151.                     addToClip(oldClip,0,1);
  152.                 }
  153.                 return 0;
  154.             }
  155.         }else{
  156.             return 1;
  157.         }
  158. }
  159.  
  160.  
  161. void weapon_machinegun::getClips(){
  162.     clip1 = $player1.getFloatKey("machineclip1");
  163.     clip2 = $player1.getFloatKey("machineclip2");
  164.     clip3 = $player1.getFloatKey("machineclip3");
  165.     clip4 = $player1.getFloatKey("machineclip4");
  166.     clip5 = $player1.getFloatKey("machineclip5");
  167.     current_clip = $player1.getFloatKey("currentmachineclip");
  168. }
  169. void weapon_machinegun::setClips(){
  170.     $player1.setKey("machineclip1", clip1);
  171.     $player1.setKey("machineclip2", clip2);
  172.     $player1.setKey("machineclip3", clip3);
  173.     $player1.setKey("machineclip4", clip4);
  174.     $player1.setKey("machineclip5", clip5);
  175.     $player1.setKey("currentmachineclip", current_clip);
  176. }
  177.  
  178. void weapon_machinegun::decrementClip() {
  179.     if(current_clip == 1){
  180.         if(clip1 == 0){
  181.             clip1 = ammoInClip();
  182.         }
  183.         clip1 = clip1 - 1;
  184.         if(clip1 < 0) {
  185.             clip1 = 0;
  186.         }
  187.     }
  188.     if(current_clip == 2){
  189.         if(clip2 == 0){
  190.             clip2 = ammoInClip();
  191.         }
  192.         clip2 = clip2 - 1;
  193.         if(clip2 < 0) {
  194.             clip2 = 0;
  195.         }
  196.     }
  197.     if(current_clip == 3){
  198.         if(clip3 == 0){
  199.             clip3 = ammoInClip();
  200.         }
  201.         clip3 = clip3 - 1;
  202.         if(clip3 < 0) {
  203.             clip3 = 0;
  204.         }
  205.     }
  206.     if(current_clip == 4){
  207.         if(clip4 == 0){
  208.             clip4 = ammoInClip();
  209.         }
  210.         clip4 = clip4 - 1;
  211.         if(clip4 < 0) {
  212.             clip4 = 0;
  213.         }
  214.     }
  215.     if(current_clip == 5){
  216.         if(clip5 == 0){
  217.             clip5 = ammoInClip();
  218.         }
  219.         clip5 = clip5 - 1;
  220.         if(clip5 < 0) {
  221.             clip5 = 0;
  222.         }
  223.     }
  224. }
  225.  
  226. float weapon_machinegun::getCurrentValue() {
  227.     if(current_clip == 1){
  228.         return clip1;
  229.     }
  230.     if(current_clip == 2){
  231.         return clip2;
  232.     }
  233.     if(current_clip == 3){
  234.         return clip3;
  235.     }
  236.     if(current_clip == 4){
  237.         return clip4;
  238.     }
  239.     if(current_clip == 5){
  240.         return clip5;
  241.     }
  242. }
  243.  
  244. void weapon_machinegun::alignClip() {
  245.     float clip = 0;
  246.     float AMMO_GAME;
  247.     float AMMO_MY;
  248.     float x;
  249.     if( current_clip == 1 ){
  250.         clip = clip1;
  251.     }
  252.     if( current_clip == 2 ){
  253.         clip = clip2;
  254.     }
  255.     if( current_clip == 3 ){
  256.         clip = clip3;
  257.     }
  258.     if( current_clip == 4 ){
  259.         clip = clip4;
  260.     }
  261.     if( current_clip == 5 ){
  262.         clip = clip5;
  263.     }
  264.     if(ammoInClip() != clip) {
  265.         clip = ammoInClip();
  266.     }
  267.     AMMO_GAME = ammoAvailable();
  268.     AMMO_MY = clip1 + clip2 + clip3 + clip4 + clip5;
  269.     if( current_clip == 1 ){
  270.         clip1 = clip;
  271.     }
  272.     if( current_clip == 2 ){
  273.         clip2 = clip;
  274.     }
  275.     if( current_clip == 3 ){
  276.         clip3 = clip;
  277.     }
  278.     if( current_clip == 4 ){
  279.         clip4 = clip;
  280.     }
  281.     if( current_clip == 5 ){
  282.         clip5 = clip;
  283.     }
  284. }
  285.  
  286. void weapon_machinegun::alignAmmo() {
  287.     float i = 0;
  288.     float SUM = 0;
  289.     float number = getClipNo();
  290.     if(number == 1){
  291.         SUM = clip2+clip3+clip4+clip5;
  292.     }else
  293.     if(number == 2){
  294.         SUM = clip1+clip3+clip4+clip5;
  295.     }else
  296.     if(number == 3){
  297.         SUM = clip1+clip2+clip4+clip5;
  298.     }
  299.     if(number == 4){
  300.         SUM = clip1+clip2+clip3+clip5;
  301.     }
  302.     if(number == 5){
  303.         SUM = clip1+clip2+clip3+clip4;
  304.     }
  305.     float AMMO_GAME= ammoAvailable();
  306.     for(i;i<AMMO_GAME;i++){
  307.         useBullet();
  308.     }
  309.     addToClip(0,-SUM,1);
  310. }
  311.  
  312.  
  313. float weapon_machinegun::getSmallestClipNo() {
  314.     float value = clipSize();
  315.     float number = 0;
  316.     if (clip1 <= value && clip1 != 30 ) {
  317.         value = clip1;
  318.         number = 1;
  319.     }
  320.     if (clip2 <= value && clip2 != 30 ) {
  321.         value = clip2;
  322.         number = 2;
  323.     }
  324.     if (clip3 <= value && clip3 != 30 ) {
  325.         value = clip3;
  326.         number = 3;
  327.     }
  328.     if (clip4 <= value && clip4 != 30 ) {
  329.         value = clip4;
  330.         number = 4;
  331.     }
  332.     if (clip5 <= value && clip5 != 30 ) {
  333.         value = clip5;
  334.         number = 5;
  335.     }
  336.     return number;
  337. }
  338.  
  339.  
  340.  
  341. float weapon_machinegun::getClipNo() {
  342.     float value = 0;
  343.     float number = 0;
  344.     if (clip1 >= value) {
  345.         value = clip1;
  346.         number = 1;
  347.     }
  348.     if (clip2 >= value) {
  349.         value = clip2;
  350.         number = 2;
  351.     }
  352.     if (clip3 >= value) {
  353.         value = clip3;
  354.         number = 3;
  355.     }
  356.     if (clip4 >= value) {
  357.         value = clip4;
  358.         number = 4;
  359.     }
  360.     if (clip5 >= value) {
  361.         value = clip5;
  362.         number = 5;
  363.     }
  364.     return number;
  365. }
  366.  
  367. float weapon_machinegun::getAmmo() {
  368.     float value = 0;
  369.     if (clip1 > value) {
  370.         value = clip1;
  371.     }
  372.     if (clip2 > value) {
  373.         value = clip2;
  374.     }
  375.     if (clip3 > value) {
  376.         value = clip3;
  377.     }
  378.     if (clip4 > value) {
  379.         value = clip4;
  380.     }
  381.     if (clip5 > value) {
  382.         value = clip5;
  383.     }
  384.     return value;
  385. }
  386.  
  387. void weapon_machinegun::adjustAmmo() {
  388.     float clip = 0;
  389.     float i = 0;
  390.     float dec_amount = 0;
  391.     float number = 0;
  392.     float AMMO_GAME;
  393.     float AMMO_MY;
  394.     for(i; i<5; i++){
  395.         float x = 0;
  396.         number = getSmallestClipNo();
  397.         AMMO_GAME = ammoAvailable();
  398.         AMMO_MY = clip1 + clip2 + clip3 + clip4 + clip5;
  399.         float IN_WEAPON = ammoInClip();
  400.         float EXTRA = AMMO_GAME - AMMO_MY;
  401.  
  402.         if( number == 1 ){
  403.             clip = clip1;
  404.         }
  405.         if( number == 2 ){
  406.             clip = clip2;
  407.         }
  408.         if( number == 3 ){
  409.             clip = clip3;
  410.         }
  411.         if( number == 4 ){
  412.             clip = clip4;
  413.         }
  414.         if( number == 5 ){
  415.             clip = clip5;
  416.         }
  417.         if(clip < 0) {
  418.             clip = clipSize() + clip;
  419.         }
  420.  
  421.         dec_amount = clip;
  422.         if(number != 0) {
  423.             if(EXTRA >= clipSize()){
  424.                 clip = clipSize();
  425.                 for(x; x<dec_amount; x++){
  426.                     useBullet();
  427.                 }
  428.             }else
  429.             if(EXTRA > 0){
  430.                clip = clip + EXTRA;
  431.                if(clip > clipSize()){
  432.                     dec_amount = clipSize() - clip;
  433.                     clip = clipSize();
  434.                     for(x; x<dec_amount; x++){
  435.                         useBullet();
  436.                     }
  437.                }
  438.             }
  439.         }
  440.         if( number == 1 ){
  441.             clip1 = clip;
  442.         }
  443.         if( number == 2 ){
  444.             clip2 = clip;
  445.         }
  446.         if( number == 3 ){
  447.             clip3 = clip;
  448.         }
  449.         if( number == 4 ){
  450.             clip4 = clip;
  451.         }
  452.         if( number == 5 ){
  453.             clip5 = clip;
  454.         }
  455.     }
  456. }
  457.  
  458. void weapon_machinegun::Melee() {
  459.     inmelee = true;
  460.     projType = 1;
  461.     changeProjectileDef( projType);
  462.     if(light == 2)
  463.     {
  464.         stopWeaponLight( "laser_normal" );
  465.         stopWeaponLight( "glow_laser_normal" );
  466.         stopWeaponParticle( "view_laser_normal" );
  467.         stopWeaponParticle( "world_laser_normal" );
  468.         startWeaponLight( "laser_melee");
  469.         startWeaponLight( "glow_laser_melee");
  470.         startWeaponParticle( "view_laser_melee" );
  471.         startWeaponParticle( "world_laser_melee" );
  472.     }
  473.     playAnim( ANIMCHANNEL_ALL,"melee" );
  474.     startSound( "snd_whoosh", SND_CHANNEL_ITEM, true );
  475.     launchProjectiles( 1, 0.1, 0, 1.0, 1.0,1);
  476.     waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
  477.     if(light == 2)
  478.     {
  479.         startWeaponLight( "laser_normal" );
  480.         startWeaponLight( "glow_laser_normal" );
  481.         startWeaponParticle( "view_laser_normal" );
  482.         startWeaponParticle( "world_laser_normal" );
  483.         stopWeaponLight( "laser_melee");
  484.         stopWeaponLight( "glow_laser_melee");
  485.         stopWeaponParticle( "view_laser_melee" );
  486.         stopWeaponParticle( "world_laser_melee" );
  487.  
  488.     }
  489.     projType = 0;
  490.     changeProjectileDef( projType);
  491.     inmelee = false;
  492.     weaponState( "Idle", 0 );
  493. }
  494.  
  495.  
  496.  
  497.  
  498. void weapon_machinegun::ToggleOnOff() {
  499.  
  500.     if(light==0)
  501.     {                                                                       //// FLASHLIGHT ON
  502.         startWeaponLight( "light_flash" );
  503.         startWeaponLight( "glow_flash" );
  504.         startWeaponParticle( "flash" );
  505.         startWeaponParticle( "world_flash" );
  506.         light = 1;
  507.         $player1.setKey("mgunlight","1");
  508.         sys.setcvar("g_crosshair","0");
  509.  
  510.         spread = MACHINEGUN_SPREAD_FLASH;
  511.         spread_max = MACHINEGUN_MAX_SPREAD_FLASH;
  512.         f_toggle = 0;
  513.         startSoundShader( "player_flashlight_on", SND_CHANNEL_ITEM );
  514.     }else if(light==1)
  515.     {                                                                       //// LASER ON
  516.         startSoundShader( "player_flashlight_on", SND_CHANNEL_ITEM );
  517.         stopWeaponLight( "light_flash" );
  518.         stopWeaponLight( "glow_flash" );
  519.         stopWeaponParticle( "flash" );
  520.         stopWeaponParticle( "world_flash" );
  521.         startWeaponLight( "laser_normal" );
  522.         startWeaponLight( "glow_laser_normal" );
  523.         startWeaponParticle( "view_laser_normal" );
  524.         startWeaponParticle( "world_laser_normal" );
  525.         light = 2;                                                          //// I USED THIS ONE AS A DIFFIRENT FIRE SOUND TRIGGER. DOESN'T WORK
  526.  
  527.         $player1.setKey("mgunlight","0");
  528.         $player1.setKey("mgunlaser","1");
  529.         sys.setcvar("g_crosshair","0");
  530.         spread = MACHINEGUN_SPREAD;
  531.         spread_max = MACHINEGUN_MAX_SPREAD;
  532.         f_toggle = 0;                                                       //// I TRIED THIS ONE BEFORE BUT IT HAS ONLY 0/1 STATES
  533.  
  534.  
  535.     }else{                                                                  //// FLASHLIGHT OFF LASER OFF
  536.         startSoundShader( "player_flashlight_off", SND_CHANNEL_ITEM );
  537.         f_toggle = 1;
  538.  
  539.         stopWeaponLight( "laser_normal" );
  540.         stopWeaponLight( "glow_laser_normal" );
  541.         stopWeaponParticle( "view_laser_normal" );
  542.         stopWeaponParticle( "world_laser_normal" );
  543.         light = 0;
  544.         $player1.setKey("mgunlaser","0");
  545.         sys.setcvar("g_crosshair","0");
  546.         spread = MACHINEGUN_SPREAD_SIGHTS;
  547.         spread_max = MACHINEGUN_MAX_SPREAD_SIGHTS;
  548.         f_toggle = 1;
  549.  
  550.     }
  551.  
  552.  
  553.     sys.wait(0.2);
  554.  
  555.     weaponState( "Idle", MACHINEGUN_RELOAD_TO_IDLE );
  556. }
  557.  
  558.  
  559. void weapon_machinegun::init() {
  560.     sys.setcvar("g_gunX", "0");
  561.     sys.setcvar("g_gunY", "1"); //Was -2
  562.     sys.setcvar("g_gunZ", "-1");
  563.     sys.wait(0.008);
  564.     inmelee = false;
  565.     getClips();
  566.     alignClip();
  567.  
  568.     string ownerName;
  569.         ownerName = ( getOwner() ).getName();
  570.        
  571.         f_toggle = 0;
  572.        
  573.         next_attack = 0;
  574.         weaponState( "Raise", 0 );
  575.        
  576.         intensity = 1.0;
  577.         AlphaLabs2 = false;
  578.  
  579.     aimOnce = 0;
  580.         global_flashlight_intensity = 1.0;
  581.     light = 0;
  582.    
  583.        
  584.         weaponState( "Raise", 0 );
  585. }
  586.  
  587.  
  588.  
  589. void weapon_machinegun::Raise() {
  590.     sys.setcvar("g_gunX", "0");
  591.     sys.setcvar("g_gunY", "1"); //Was -2
  592.     sys.setcvar("g_gunZ", "-1");
  593.     sys.wait(0.008);
  594.     if($player1.getKey("mgunlight") == "1"  && !sys.isMultiplayer() )
  595.     {
  596.         light = 1;
  597.     }else
  598.         if($player1.getKey("mgunlaser") == "1"  && !sys.isMultiplayer() )
  599.         {
  600.             light = 2;
  601.         }else{
  602.             light = 0;
  603.         }
  604.     if(light==1)
  605.     {
  606.         startWeaponLight( "light_flash" );
  607.         startWeaponLight( "glow_flash" );
  608.         startWeaponParticle( "flash" );
  609.         startWeaponParticle( "world_flash" );
  610.         sys.setcvar("g_crosshair","0");
  611.         spread = MACHINEGUN_SPREAD_FLASH;
  612.         spread_max = MACHINEGUN_MAX_SPREAD_FLASH;
  613.  
  614.         f_toggle = 0;
  615.  
  616.     }else if(light==2)
  617.     {
  618.         startWeaponLight( "laser_normal" );
  619.         startWeaponLight( "glow_laser_normal" );
  620.         startWeaponParticle( "view_laser_normal" );
  621.         startWeaponParticle( "world_laser_normal" );
  622.         sys.setcvar("g_crosshair","0");
  623.         spread = MACHINEGUN_SPREAD;
  624.         spread_max = MACHINEGUN_MAX_SPREAD;
  625.         f_toggle = 0;
  626.     }else{
  627.         sys.setcvar("g_crosshair","0");
  628.         spread = MACHINEGUN_SPREAD_SIGHTS;
  629.         spread_max = MACHINEGUN_MAX_SPREAD_SIGHTS;
  630.         f_toggle = 1;
  631.     }
  632.  
  633.  
  634.    
  635.     weaponRising();
  636.     playAnim( ANIMCHANNEL_ALL, "raise" );
  637.     waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
  638.     weaponState( "Idle", MACHINEGUN_RAISE_TO_IDLE );
  639. }
  640.  
  641. void weapon_machinegun::Lower() {
  642.     sys.setcvar("g_crosshair","0");
  643.        
  644.         if(aimOnce)
  645.         {
  646.             ADS_OUT();
  647.                 aimOnce = !aimOnce;
  648.         }
  649.    
  650.         weaponLowering();
  651.         playAnim( ANIMCHANNEL_ALL, "putaway" );
  652.         waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
  653.         weaponHolstered();
  654.         waitUntil( WEAPON_RAISEWEAPON );
  655.         weaponState( "Raise", 0 );
  656. }
  657.  
  658.  
  659.  
  660. void weapon_machinegun::Idle() {
  661.     float currentTime;
  662.     currentRound = 1;
  663.         float ammoClip;
  664.         float clip_size;
  665.        
  666.         ammoClip = ammoInClip();
  667.         clip_size = clipSize();
  668.        
  669.         if ( !ammoInClip() ) {
  670.             weaponOutOfAmmo();
  671.         } else {
  672.             weaponReady();
  673.         }
  674.     currentRound = 1;
  675.     if(inmelee)
  676.     {
  677.         if(light == 2)
  678.         {
  679.             startWeaponLight( "laser_normal" );
  680.             startWeaponLight( "glow_laser_normal" );
  681.             startWeaponParticle( "view_laser_normal" );
  682.             startWeaponParticle( "world_laser_normal" );
  683.             stopWeaponLight( "laser_melee");
  684.             stopWeaponLight( "glow_laser_melee");
  685.             stopWeaponParticle( "view_laser_melee" );
  686.             stopWeaponParticle( "world_laser_melee" );
  687.  
  688.         }
  689.         projType = 0;
  690.         changeProjectileDef( projType);
  691.         inmelee = false;
  692.        
  693.     }
  694.  
  695.    
  696.        
  697.         playCycle( ANIMCHANNEL_ALL, "idle" );
  698.        
  699.         while ( 1 ) {
  700.  
  701.             if($player1.getKey("mgunlight") == "1"  && !AlphaLabs2 && 1.0 != global_flashlight_intensity)
  702.             {
  703.                 stopWeaponLight( "light_flash" );
  704.                     stopWeaponLight( "glow_flash" );
  705.                     stopWeaponParticle( "flash" );
  706.                     stopWeaponParticle( "world_flash" );
  707.                     sys.wait(0.2);
  708.                 startWeaponLight( "light_flash" );
  709.                     startWeaponLight( "glow_flash" );
  710.                     startWeaponParticle( "flash" );
  711.                     startWeaponParticle( "world_flash" );
  712.                     sys.wait(0.2);
  713.                 stopWeaponLight( "light_flash" );
  714.                     stopWeaponLight( "glow_flash" );
  715.                     stopWeaponParticle( "flash" );
  716.                     stopWeaponParticle( "world_flash" );
  717.                     AlphaLabs2 = true;
  718.             }
  719.             if(AlphaLabs2 && $player1.getKey("mgunlight") == "1"  && 1.0 == global_flashlight_intensity)
  720.             {
  721.                 startWeaponLight( "light_flash" );
  722.                     startWeaponLight( "glow_flash" );
  723.                     startWeaponParticle( "flash" );
  724.                     startWeaponParticle( "world_flash" );
  725.                     AlphaLabs2 = false;
  726.             }
  727.  
  728.  
  729.            
  730.                 buttons = $player1.getButtons();
  731.                 if(!WEAPON_ATTACK)
  732.                 {
  733.                     holdButton = false;
  734.                 }
  735.            
  736.                 buttons = $player1.getButtons();
  737.                 if ( buttons == 20 || buttons == 84 || buttons == 148)
  738.                 {
  739.                     isZoomed = 1;
  740.                 }
  741.             if (buttons != 20 && buttons != 84 && buttons != 148)
  742.             {
  743.                 isZoomed = 0;
  744.             }
  745.  
  746.  
  747.            
  748.                 if ( isZoomed && !WEAPON_ATTACK )
  749.                 {
  750.                    
  751.                         if(!aimOnce)
  752.                         {
  753.  
  754.                             spread = MACHINEGUN_SPREAD_ZOOMED;
  755.                                 spread_incrementation_factor = 0.08;
  756.                                 spread_max = MACHINEGUN_MAX_SPREAD_ZOOMED;
  757.                                
  758.                                
  759.                                 ADS_IN();
  760.                                 aimOnce = !aimOnce;
  761.                         }
  762.                     if($player1.getKey("crouched") == "1")
  763.                     {
  764.                         spread = spread / 2;
  765.                     }
  766.                 }
  767.             if ( !isZoomed && !WEAPON_ATTACK )
  768.             {
  769.                
  770.                     if (buttons == 18)
  771.                     {
  772.                         spread = MACHINEGUN_SPREAD_RUNNING;
  773.                             spread_max = MACHINEGUN_MAX_SPREAD_RUNNING;
  774.                             spread_incrementation_factor = 0.75;
  775.                     }else{
  776.                         spread = MACHINEGUN_SPREAD ;
  777.                             spread_incrementation_factor = 0.45;
  778.                             spread_max = MACHINEGUN_MAX_SPREAD;
  779.                     }
  780.                 if($player1.getKey("crouched") == "1")
  781.                 {
  782.                     spread = spread / 2;
  783.                 }
  784.                
  785.                     if(aimOnce)
  786.                     {
  787.                             if(light != 2)
  788.                             {
  789.  
  790.                                 spread = MACHINEGUN_SPREAD_CROSSHAIR;
  791.                                 spread_max = MACHINEGUN_SPREAD_CROSSHAIR_MAX;
  792.                             }
  793.  
  794.                         ADS_OUT();
  795.                             spread = MACHINEGUN_SPREAD_CROSSHAIR;
  796.                             spread_max = MACHINEGUN_SPREAD_CROSSHAIR_MAX;
  797.                             if($player1.getKey("crouched") == "1")
  798.                             {
  799.                                 spread = spread / 2;
  800.                             }
  801.                         aimOnce = !aimOnce;
  802.                     }
  803.             }
  804.            
  805.                 if ( WEAPON_LOWERWEAPON ) {
  806.                     weaponState( "Lower", MACHINEGUN_IDLE_TO_LOWER );
  807.                 }
  808.             currentTime = sys.getTime();
  809.                 ammoClip = ammoInClip();
  810.                 if ( ( currentTime >= next_attack ) && WEAPON_ATTACK ) {
  811.                     if ( ammoClip > 0 ) {
  812.                         if(!f_toggle)
  813.                         {
  814.                             weaponState( "Fire", MACHINEGUN_IDLE_TO_FIRE );
  815.                         }else if(f_toggle && !holdButton)
  816.                         {
  817.                             holdButton = true;
  818.                                 weaponState( "Fire", MACHINEGUN_IDLE_TO_FIRE);
  819.                         }
  820.                     } else {
  821.                         weaponState( "NoAmmo", 4 );
  822.                            
  823.                     }
  824.                 }
  825.            
  826.     if ( WEAPON_RELOAD ) {
  827.             if(ammoInClip() < 30 && canReload())
  828.             {
  829.                 weaponState( "Reload", MACHINEGUN_IDLE_TO_RELOAD );
  830.             }else{
  831.                 startSound( "snd_lowammo", SND_CHANNEL_WEAPON,false);
  832.             }
  833.         }
  834.  
  835.             if ( WEAPON_SPECIAL && !sys.isMultiplayer() && !aimOnce ) {
  836.                 weaponState( "ToggleOnOff", MACHINEGUN_IDLE_TO_RELOAD );
  837.             }
  838.             if (WEAPON_MELEE && !aimOnce)
  839.             {
  840.                 weaponState( "Melee", MACHINEGUN_IDLE_TO_RELOAD );
  841.             }
  842.            
  843.                
  844.                
  845.                
  846.                 waitFrame();
  847.                
  848.                
  849.         }
  850. }
  851.  
  852. void weapon_machinegun::NoAmmo() {
  853.     startSoundShader( "player_machinegun_dryfire" , SND_CHANNEL_WEAPON );
  854.         sys.wait(0.2);
  855.         weaponState( "Idle", 3 );
  856. }
  857.  
  858. void weapon_machinegun::Fire() {
  859.    
  860.         entity owner;
  861.         owner = getOwner();
  862.         holdButton = true;
  863.        
  864.        
  865.         float ammoClip;
  866.         float currentTime;
  867.         float attackDiff, currentSpread, maxAttackDiff;
  868.        
  869.         currentTime = sys.getTime();
  870.        
  871.         maxAttackDiff   = MACHINEGUN_BASE_FIRERATE - MACHINEGUN_FIRERATE;
  872.         attackDiff      = sys.getTime() - next_attack;
  873.        
  874.         if( attackDiff >= maxAttackDiff ) {
  875.             currentSpread = spread;
  876.                 gradual_spread = 0;
  877.         }
  878.    
  879.         else {
  880.             gradual_spread = gradual_spread + spread_incrementation_factor * (1 -       (attackDiff /maxAttackDiff));
  881.                
  882.                 if(gradual_spread > spread_max) {
  883.                     gradual_spread = spread_max;
  884.                 }
  885.            
  886.                 currentSpread = spread + gradual_spread;
  887.         }
  888.    
  889.         next_attack = currentTime + MACHINEGUN_FIRERATE;
  890.         if(light == 1)
  891.         {
  892.             next_attack = next_attack + MACHINEGUN_FIRERATE;
  893.         }
  894.         next_semiauto = sys.getTime() + MACHINEGUN_SEMIAUTO_RATE;
  895.        
  896.        
  897.         ammoClip = ammoInClip();
  898.         if ( ammoClip == MACHINEGUN_LOWAMMO ) {
  899.             startSound( "snd_lowammo", SND_CHANNEL_ITEM, true );
  900.         }
  901.    
  902.         startWeaponParticle("flashfx_right");
  903.         startWeaponParticle("flashfx_left");
  904.         startWeaponParticle("flashfx_left_world");
  905.         startWeaponParticle("flashfx_right_world");
  906.        
  907.        
  908.         launchProjectiles( MACHINEGUN_NUMPROJECTILES, currentSpread, 0, 1.0, 1.0,0);
  909.         alignClip();
  910.        
  911.         if(light == 2)                                                                  //// WHAT IS THE DIFFIRENCE BETWEEN "=" AND "==" ?
  912.         {
  913.             startSoundShader( "player_machinegun_burst" , SND_CHANNEL_WEAPON );
  914.         }else{
  915.             startSoundShader( "player_machinegun_fire" , SND_CHANNEL_WEAPON );
  916.         }
  917.        
  918.         playAnim( ANIMCHANNEL_ALL, "fire" );
  919.         while( !animDone( ANIMCHANNEL_ALL, MACHINEGUN_FIRE_TO_IDLE ) ) {
  920.             currentTime = sys.getTime();
  921.                 ammoClip = ammoInClip();
  922.  
  923.                
  924.                
  925.                 if(f_toggle)
  926.                 {
  927.                         if (f_toggle && ( ammoClip > 0 ) && ( currentRound < 3 ) ) {                                        //// WHAT "&&" MEANS ?
  928.                             currentRound++;
  929.                         stopWeaponParticle("flashfx_right");
  930.                             stopWeaponParticle("flashfx_left");
  931.                             stopWeaponParticle("flashfx_left_world");
  932.                             stopWeaponParticle("flashfx_right_world");
  933.                                 sys.wait( MACHINEGUN_SEMIAUTO_RATE );
  934.                             weaponState( "Fire", 0 );
  935.                         }
  936.                         if ( f_toggle &&  ( ammoClip > 0 ) && ( currentRound >= 3 ) ) {
  937.                         stopWeaponParticle("flashfx_right");
  938.                             stopWeaponParticle("flashfx_left");
  939.                             stopWeaponParticle("flashfx_left_world");
  940.                             stopWeaponParticle("flashfx_right_world");
  941.                                 sys.wait( MACHINEGUN_SEMIAUTO_RATE );
  942.                             weaponState( "Idle", MACHINEGUN_FIRE_TO_IDLE );
  943.                         }
  944.                         if ( !WEAPON_ATTACK && holdButton ) {
  945.                                 sys.wait( MACHINEGUN_SEMIAUTO_RATE );
  946.                             holdButton = false;
  947.                         }
  948.                         if ( WEAPON_ATTACK && ( ammoClip > 0 ) && !holdButton ) {
  949.                             weaponState( "Fire", 0 );
  950.                         }
  951.  
  952.                     }  
  953.                  else if ( ( currentTime >= next_attack ) && ( WEAPON_NETFIRING || (     WEAPON_ATTACK && ( ammoClip > 0 ) ) ) ) {
  954.                     stopWeaponParticle("flashfx_right");
  955.                         stopWeaponParticle("flashfx_left");
  956.                         stopWeaponParticle("flashfx_left_world");
  957.                         stopWeaponParticle("flashfx_right_world");
  958.                         weaponState( "Fire", 0 );
  959.                 }
  960.             waitFrame();
  961.         }
  962.     stopWeaponParticle("flashfx_right");
  963.         stopWeaponParticle("flashfx_left");
  964.         stopWeaponParticle("flashfx_left_world");
  965.         stopWeaponParticle("flashfx_right_world");
  966.        
  967.         weaponState( "Idle", MACHINEGUN_FIRE_TO_IDLE );
  968.        
  969.        
  970. }
  971.  
  972.  
  973.  
  974. void weapon_machinegun::Reload() {
  975.     //startSoundShader( "player_machinegun_reload_script" , SND_CHANNEL_ANY );
  976.     weaponReloading();
  977.     float ammoClip;
  978.     ammoClip = getCurrentValue();
  979.     adjustAmmo();
  980.     alignAmmo();
  981.         playAnim( ANIMCHANNEL_ALL, "reload" );
  982.  
  983.         while( !animDone( ANIMCHANNEL_ALL, MACHINEGUN_RELOAD_TO_IDLE ) ) {
  984.             if ( WEAPON_LOWERWEAPON ) {
  985.                 stopSound( SND_CHANNEL_ANY, false );
  986.                 weaponState( "Idle", MACHINEGUN_RELOAD_TO_IDLE );
  987.             }
  988.             waitFrame();
  989.         }
  990.     waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
  991.     float clip = getAmmo();
  992.     current_clip = getClipNo();
  993.     $player1.setKey("currentmachineclip", current_clip);
  994.     addToClip(clip,0,1);
  995.     setClips();
  996.     weaponState( "Idle", MACHINEGUN_RELOAD_TO_IDLE );
  997.  
  998. }
  999.  
  1000. void weapon_machinegun::ExitCinematic() {
  1001.    
  1002.         next_attack = 0;
  1003.         weaponState( "Idle", 0 );
  1004. }
  1005.  
  1006.  
  1007.  
  1008.  
  1009. void weapon_machinegun::ADS_IN() {
  1010.    
  1011.         sys.setcvar("g_gunX", "0");
  1012.         sys.setcvar("g_gunY", "1");
  1013.         sys.setcvar("g_gunZ", "-1");
  1014.         sys.wait(0.011);
  1015.         sys.setcvar("g_gunX", "0");
  1016.         sys.setcvar("g_gunY", "1.2");      
  1017.         sys.setcvar("g_gunZ", "-0.5");
  1018.         sys.wait(0.011);
  1019.         sys.setcvar("g_gunX", "0");    
  1020.         sys.setcvar("g_gunY", "1.4");
  1021.         sys.setcvar("g_gunZ", "-0.2");
  1022.         sys.wait(0.011);
  1023.         sys.setcvar("g_gunX", "0");
  1024.         sys.setcvar("g_gunY", "1.6");
  1025.         sys.setcvar("g_gunZ", "0.2");
  1026.         sys.wait(0.011);
  1027.         sys.setcvar("g_gunX", "0");    
  1028.         sys.setcvar("g_gunY", "1.8");
  1029.         sys.setcvar("g_gunZ", "0.6");
  1030.         sys.wait(0.011);
  1031.         sys.setcvar("g_gunX", "0");    
  1032.         sys.setcvar("g_gunY", "2.05");
  1033.         sys.setcvar("g_gunZ", "0.85");
  1034.         sys.wait(0.011);
  1035.         sys.setcvar("g_gunX", "0");    
  1036.         sys.setcvar("g_gunY", "2.2");
  1037.         sys.setcvar("g_gunZ", "1");
  1038.         sys.wait(0.011);
  1039.         sys.setcvar("g_gunX", "0");    
  1040.         sys.setcvar("g_gunY", "2.3");
  1041.         sys.setcvar("g_gunZ", "1.1");
  1042.         sys.wait(0.011);
  1043.         sys.setcvar("g_gunX", "0");    
  1044.         sys.setcvar("g_gunY", "2.3");
  1045.         sys.setcvar("g_gunZ", "1.2");
  1046.         sys.wait(0.011);
  1047.         sys.setcvar("g_gunX", "0");    
  1048.         sys.setcvar("g_gunY", "2.5");
  1049.         sys.setcvar("g_gunZ", "1.3");
  1050.         sys.wait(0.011);
  1051.         sys.setcvar("g_gunX", "0");
  1052.         sys.setcvar("g_gunY", "2.7");
  1053.         sys.setcvar("g_gunZ", "1.3");
  1054. }
  1055. void weapon_machinegun::ADS_OUT() {
  1056.    
  1057.        
  1058.         sys.setcvar("g_gunX", "0");
  1059.         sys.setcvar("g_gunY", "2.2");
  1060.         sys.setcvar("g_gunZ", "1.05");
  1061.         sys.wait(0.011);
  1062.         sys.setcvar("g_gunX", "0");
  1063.         sys.setcvar("g_gunY", "2.15");
  1064.         sys.setcvar("g_gunZ", "1");
  1065.         sys.wait(0.011);
  1066.         sys.setcvar("g_gunX", "0");
  1067.         sys.setcvar("g_gunY", "2.05");
  1068.         sys.setcvar("g_gunZ", "0.85");
  1069.         sys.wait(0.011);
  1070.         sys.setcvar("g_gunX", "0");
  1071.         sys.setcvar("g_gunY", "1.95");
  1072.         sys.setcvar("g_gunZ", "0.75");
  1073.         sys.wait(0.011);
  1074.         sys.setcvar("g_gunX", "0");
  1075.         sys.setcvar("g_gunY", "1.8");
  1076.         sys.setcvar("g_gunZ", "0.6");
  1077.         sys.wait(0.011);
  1078.         sys.setcvar("g_gunX", "0");
  1079.         sys.setcvar("g_gunY", "1.6");
  1080.         sys.setcvar("g_gunZ", "0.4");
  1081.         sys.wait(0.011);
  1082.         sys.setcvar("g_gunX", "0");
  1083.         sys.setcvar("g_gunY", "1.3");
  1084.         sys.setcvar("g_gunZ", "0.2");
  1085.         sys.wait(0.011);
  1086.         sys.setcvar("g_gunX", "0");    
  1087.         sys.setcvar("g_gunY", "1.4");
  1088.         sys.setcvar("g_gunZ", "-0.2");
  1089.         sys.wait(0.011);
  1090.         sys.setcvar("g_gunX", "0");
  1091.         sys.setcvar("g_gunY", "1.2");      
  1092.         sys.setcvar("g_gunZ", "-0.5");
  1093.         sys.wait(0.011);
  1094.         sys.setcvar("g_gunX", "0");
  1095.         sys.setcvar("g_gunY", "1");
  1096.         sys.setcvar("g_gunZ", "-1");
  1097.         sys.wait(0.011);
  1098. }
  1099.  
  1100.  
  1101.  
  1102. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1103. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1104. ATM
  1105. LASER ON  - RAPID AUTOMATIC FIRE "player_machinegun_fire" SOUND
  1106. FLASHLIGHT ON - CYCLIC AUTOMATIC FIRE"player_machinegun_fire" SOUND
  1107. FLASHLIGHT OFF LASER OFF - 3rnd BURST "player_machinegun_fire" SOUND
  1108.  
  1109. I WANNA ACHIEVE SITUATION, WHERE
  1110. LASER ON  - EXTREMLY FAST 3rnd burst FIRE "player_machinegun_burst" CUSTOM SOUND I HAVE MADE
  1111. FLASHLIGHT ON/OFF - CYCLIC AUTOMATIC FIRE"player_machinegun_fire" SOUND
  1112.  
  1113.  
  1114.  
  1115. "player_machinegun_burst"
  1116.  
  1117. I PLACED .WAV FILE INTO zSound.pk4 MOD DIRECTORY
  1118. sound/weapons/machinegun/machinegun_burst.wav
  1119.  
  1120. HAS BEEN DESCRIBED IN weapons.sndhd file
  1121.  
  1122. "player_machinegun_burst {
  1123.    minDistance 5
  1124.    maxDistance 130
  1125.    volume  10
  1126.  
  1127.    sound/weapons/machinegun/machinegun_burst.wav
  1128. }"
  1129.  
  1130.  
  1131.  ONLY WEAPON, THAT USES TWO FIRING SOUNDS IS PLASMAGUN BALL/RAILBEAM. PROPER SOUNDS ARE TRIGGERED VIA
  1132.  
  1133. "launchProjectiles( PLASMAGUN_NUMPROJECTILES, spread, 0, 1.0, 1.0 ,0);
  1134.  
  1135. if( projType == PROJECTILE_TYPE_PLASMARAIL_BEAM)
  1136. {
  1137. startSoundShader( "plasma_rail_fire", SND_CHANNEL_WEAPON );
  1138. }else{
  1139. startSoundShader( "plasma_fire" , SND_CHANNEL_WEAPON );
  1140. }"
  1141.  
  1142.  
  1143.  SHOULD I JUST CREATE CUSTOM PROJECTILE FOR 3rnd burst EXCLUSIVELY, DESCRIBED IN weapon_.def ?
  1144. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1145. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement