Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- weapon_machinegun.script
- ***********************************************************************/
- /*
- CATEGORY: AVERAGE WEAPONS
- ZOOM (FOV Value): 85
- ADS TYPES: 1- DEFAULT; 2- SHOULDERED; 3- SCOPED
- ADS MODE: 2
- SPREAD NORMAL: 1.5 - 7 MAX
- SPREAD ADS MODE: 0.3 - 3 MAX
- */
- #define MACHINEGUN_BASE_FIRERATE 0.3 // RATE OF FIRE at which spread will be minimum
- #define MACHINEGUN_LOWAMMO 10
- #define MACHINEGUN_SEMIAUTO_RATE 0.10 //// WHY IT IS DEFINED TWICE ? FIRST
- #define MACHINEGUN_FIRERATE 0.08 // A fast motherfucker
- #define MACHINEGUN_FIRERATE_ADS 0.08
- #define MACHINEGUN_NUMPROJECTILES 1
- #define MACHINEGUN_IDLE_TO_LOWER 4
- #define MACHINEGUN_IDLE_TO_FIRE 0
- #define MACHINEGUN_IDLE_TO_RELOAD 4
- #define MACHINEGUN_RAISE_TO_IDLE 4
- #define MACHINEGUN_FIRE_TO_IDLE 0
- #define MACHINEGUN_RELOAD_TO_IDLE 4
- #define MACHINEGUN_SPREAD_SIGHTS 0.3
- #define MACHINEGUN_MAX_SPREAD_SIGHTS 3
- #define MACHINEGUN_SEMIAUTO_RATE 0.03 //// WHY IT IS DEFINED TWICE ? SECOND
- #define MACHINEGUN_SEMIBURST_ROUNDS 3 //Triple shot burst, like pistol//0x29a
- //Sight Augmentation //0x29a
- #define MACHINEGUN_SPREAD 0.95
- #define MACHINEGUN_MAX_SPREAD 2.5
- #define MACHINEGUN_SPREAD_FLASH 4
- #define MACHINEGUN_MAX_SPREAD_FLASH 8
- #define MACHINEGUN_SPREAD_ZOOMED 0.2
- #define MACHINEGUN_MAX_SPREAD_ZOOMED 0.8
- #define MACHINEGUN_SPREAD_RUNNING 1.5
- #define MACHINEGUN_MAX_SPREAD_RUNNING 4.5
- #define MACHINEGUN_SPREAD_CROSSHAIR 1.5
- #define MACHINEGUN_SPREAD_CROSSHAIR_MAX 7
- #ifndef _GLOBAL_FLASH_INTENSITY_
- float global_flashlight_intensity = 1.0;
- #define _GLOBAL_FLASH_INTENSITY_
- #endif
- object weapon_machinegun : weapon_base {
- float next_attack;
- boolean holdButton;
- float projType;
- float spread;
- float currentRound;
- float spread_max;
- float gradual_spread;
- float buttons;
- float spread_incrementation_factor;
- void init();
- void Lower();
- void Raise();
- void Idle();
- void Fire();
- void Reload();
- //"Iron Sights" setcvar(gunx,y,z,) taken directly from CED ASSETS PACK
- void ADS_IN();
- void ADS_OUT();
- void ExitCinematic();
- float currentRound;
- float mgunlight;
- float mgunlaser;
- boolean laddery;
- boolean inmelee;
- boolean switched;
- boolean f_toggle;
- float next_attack;
- float spread;
- float light;
- boolean aimOnce;
- boolean isZoomed;
- void init();
- void ToggleOnOff();
- float next_semiauto;
- void NoAmmo();
- boolean AlphaLabs2;
- float intensity;
- void Melee();
- float clip1;
- float clip2;
- float clip3;
- float clip4;
- float clip5;
- float current_clip;
- float clip_to_adjust;
- float getAmmo();
- void decrementClip();
- float getSmallestClipNo();
- float getClipNo();
- void adjustAmmo();
- void alignAmmo();
- void alignClip();
- float getCurrentValue();
- void getClips();
- void setClips();
- float canReload();
- float isZero();
- };
- float weapon_machinegun::isZero() {
- return clip1+clip2+clip3+clip4+clip5;
- }
- float weapon_machinegun::canReload(){
- float i = 0;
- float oldAmmo = ammoAvailable() - ammoInClip();
- float oldClip = ammoInClip();
- adjustAmmo();
- float val = ammoInClip();
- if(clip1 <= val && clip2 <= val && clip3 <= val && clip4 <= val && clip5 <= val){
- if(getClipNo() == current_clip && getCurrentValue() != ammoInClip()){
- return 1;
- }else{
- float AMMO_GAME = ammoAvailable();
- for(i;i<AMMO_GAME;i++){
- useBullet();
- }
- addToClip(0,-oldAmmo,1);
- if(ammoInClip() == 0){
- addToClip(oldClip,0,1);
- }
- return 0;
- }
- }else{
- return 1;
- }
- }
- void weapon_machinegun::getClips(){
- clip1 = $player1.getFloatKey("machineclip1");
- clip2 = $player1.getFloatKey("machineclip2");
- clip3 = $player1.getFloatKey("machineclip3");
- clip4 = $player1.getFloatKey("machineclip4");
- clip5 = $player1.getFloatKey("machineclip5");
- current_clip = $player1.getFloatKey("currentmachineclip");
- }
- void weapon_machinegun::setClips(){
- $player1.setKey("machineclip1", clip1);
- $player1.setKey("machineclip2", clip2);
- $player1.setKey("machineclip3", clip3);
- $player1.setKey("machineclip4", clip4);
- $player1.setKey("machineclip5", clip5);
- $player1.setKey("currentmachineclip", current_clip);
- }
- void weapon_machinegun::decrementClip() {
- if(current_clip == 1){
- if(clip1 == 0){
- clip1 = ammoInClip();
- }
- clip1 = clip1 - 1;
- if(clip1 < 0) {
- clip1 = 0;
- }
- }
- if(current_clip == 2){
- if(clip2 == 0){
- clip2 = ammoInClip();
- }
- clip2 = clip2 - 1;
- if(clip2 < 0) {
- clip2 = 0;
- }
- }
- if(current_clip == 3){
- if(clip3 == 0){
- clip3 = ammoInClip();
- }
- clip3 = clip3 - 1;
- if(clip3 < 0) {
- clip3 = 0;
- }
- }
- if(current_clip == 4){
- if(clip4 == 0){
- clip4 = ammoInClip();
- }
- clip4 = clip4 - 1;
- if(clip4 < 0) {
- clip4 = 0;
- }
- }
- if(current_clip == 5){
- if(clip5 == 0){
- clip5 = ammoInClip();
- }
- clip5 = clip5 - 1;
- if(clip5 < 0) {
- clip5 = 0;
- }
- }
- }
- float weapon_machinegun::getCurrentValue() {
- if(current_clip == 1){
- return clip1;
- }
- if(current_clip == 2){
- return clip2;
- }
- if(current_clip == 3){
- return clip3;
- }
- if(current_clip == 4){
- return clip4;
- }
- if(current_clip == 5){
- return clip5;
- }
- }
- void weapon_machinegun::alignClip() {
- float clip = 0;
- float AMMO_GAME;
- float AMMO_MY;
- float x;
- if( current_clip == 1 ){
- clip = clip1;
- }
- if( current_clip == 2 ){
- clip = clip2;
- }
- if( current_clip == 3 ){
- clip = clip3;
- }
- if( current_clip == 4 ){
- clip = clip4;
- }
- if( current_clip == 5 ){
- clip = clip5;
- }
- if(ammoInClip() != clip) {
- clip = ammoInClip();
- }
- AMMO_GAME = ammoAvailable();
- AMMO_MY = clip1 + clip2 + clip3 + clip4 + clip5;
- if( current_clip == 1 ){
- clip1 = clip;
- }
- if( current_clip == 2 ){
- clip2 = clip;
- }
- if( current_clip == 3 ){
- clip3 = clip;
- }
- if( current_clip == 4 ){
- clip4 = clip;
- }
- if( current_clip == 5 ){
- clip5 = clip;
- }
- }
- void weapon_machinegun::alignAmmo() {
- float i = 0;
- float SUM = 0;
- float number = getClipNo();
- if(number == 1){
- SUM = clip2+clip3+clip4+clip5;
- }else
- if(number == 2){
- SUM = clip1+clip3+clip4+clip5;
- }else
- if(number == 3){
- SUM = clip1+clip2+clip4+clip5;
- }
- if(number == 4){
- SUM = clip1+clip2+clip3+clip5;
- }
- if(number == 5){
- SUM = clip1+clip2+clip3+clip4;
- }
- float AMMO_GAME= ammoAvailable();
- for(i;i<AMMO_GAME;i++){
- useBullet();
- }
- addToClip(0,-SUM,1);
- }
- float weapon_machinegun::getSmallestClipNo() {
- float value = clipSize();
- float number = 0;
- if (clip1 <= value && clip1 != 30 ) {
- value = clip1;
- number = 1;
- }
- if (clip2 <= value && clip2 != 30 ) {
- value = clip2;
- number = 2;
- }
- if (clip3 <= value && clip3 != 30 ) {
- value = clip3;
- number = 3;
- }
- if (clip4 <= value && clip4 != 30 ) {
- value = clip4;
- number = 4;
- }
- if (clip5 <= value && clip5 != 30 ) {
- value = clip5;
- number = 5;
- }
- return number;
- }
- float weapon_machinegun::getClipNo() {
- float value = 0;
- float number = 0;
- if (clip1 >= value) {
- value = clip1;
- number = 1;
- }
- if (clip2 >= value) {
- value = clip2;
- number = 2;
- }
- if (clip3 >= value) {
- value = clip3;
- number = 3;
- }
- if (clip4 >= value) {
- value = clip4;
- number = 4;
- }
- if (clip5 >= value) {
- value = clip5;
- number = 5;
- }
- return number;
- }
- float weapon_machinegun::getAmmo() {
- float value = 0;
- if (clip1 > value) {
- value = clip1;
- }
- if (clip2 > value) {
- value = clip2;
- }
- if (clip3 > value) {
- value = clip3;
- }
- if (clip4 > value) {
- value = clip4;
- }
- if (clip5 > value) {
- value = clip5;
- }
- return value;
- }
- void weapon_machinegun::adjustAmmo() {
- float clip = 0;
- float i = 0;
- float dec_amount = 0;
- float number = 0;
- float AMMO_GAME;
- float AMMO_MY;
- for(i; i<5; i++){
- float x = 0;
- number = getSmallestClipNo();
- AMMO_GAME = ammoAvailable();
- AMMO_MY = clip1 + clip2 + clip3 + clip4 + clip5;
- float IN_WEAPON = ammoInClip();
- float EXTRA = AMMO_GAME - AMMO_MY;
- if( number == 1 ){
- clip = clip1;
- }
- if( number == 2 ){
- clip = clip2;
- }
- if( number == 3 ){
- clip = clip3;
- }
- if( number == 4 ){
- clip = clip4;
- }
- if( number == 5 ){
- clip = clip5;
- }
- if(clip < 0) {
- clip = clipSize() + clip;
- }
- dec_amount = clip;
- if(number != 0) {
- if(EXTRA >= clipSize()){
- clip = clipSize();
- for(x; x<dec_amount; x++){
- useBullet();
- }
- }else
- if(EXTRA > 0){
- clip = clip + EXTRA;
- if(clip > clipSize()){
- dec_amount = clipSize() - clip;
- clip = clipSize();
- for(x; x<dec_amount; x++){
- useBullet();
- }
- }
- }
- }
- if( number == 1 ){
- clip1 = clip;
- }
- if( number == 2 ){
- clip2 = clip;
- }
- if( number == 3 ){
- clip3 = clip;
- }
- if( number == 4 ){
- clip4 = clip;
- }
- if( number == 5 ){
- clip5 = clip;
- }
- }
- }
- void weapon_machinegun::Melee() {
- inmelee = true;
- projType = 1;
- changeProjectileDef( projType);
- if(light == 2)
- {
- stopWeaponLight( "laser_normal" );
- stopWeaponLight( "glow_laser_normal" );
- stopWeaponParticle( "view_laser_normal" );
- stopWeaponParticle( "world_laser_normal" );
- startWeaponLight( "laser_melee");
- startWeaponLight( "glow_laser_melee");
- startWeaponParticle( "view_laser_melee" );
- startWeaponParticle( "world_laser_melee" );
- }
- playAnim( ANIMCHANNEL_ALL,"melee" );
- startSound( "snd_whoosh", SND_CHANNEL_ITEM, true );
- launchProjectiles( 1, 0.1, 0, 1.0, 1.0,1);
- waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
- if(light == 2)
- {
- startWeaponLight( "laser_normal" );
- startWeaponLight( "glow_laser_normal" );
- startWeaponParticle( "view_laser_normal" );
- startWeaponParticle( "world_laser_normal" );
- stopWeaponLight( "laser_melee");
- stopWeaponLight( "glow_laser_melee");
- stopWeaponParticle( "view_laser_melee" );
- stopWeaponParticle( "world_laser_melee" );
- }
- projType = 0;
- changeProjectileDef( projType);
- inmelee = false;
- weaponState( "Idle", 0 );
- }
- void weapon_machinegun::ToggleOnOff() {
- if(light==0)
- { //// FLASHLIGHT ON
- startWeaponLight( "light_flash" );
- startWeaponLight( "glow_flash" );
- startWeaponParticle( "flash" );
- startWeaponParticle( "world_flash" );
- light = 1;
- $player1.setKey("mgunlight","1");
- sys.setcvar("g_crosshair","0");
- spread = MACHINEGUN_SPREAD_FLASH;
- spread_max = MACHINEGUN_MAX_SPREAD_FLASH;
- f_toggle = 0;
- startSoundShader( "player_flashlight_on", SND_CHANNEL_ITEM );
- }else if(light==1)
- { //// LASER ON
- startSoundShader( "player_flashlight_on", SND_CHANNEL_ITEM );
- stopWeaponLight( "light_flash" );
- stopWeaponLight( "glow_flash" );
- stopWeaponParticle( "flash" );
- stopWeaponParticle( "world_flash" );
- startWeaponLight( "laser_normal" );
- startWeaponLight( "glow_laser_normal" );
- startWeaponParticle( "view_laser_normal" );
- startWeaponParticle( "world_laser_normal" );
- light = 2; //// I USED THIS ONE AS A DIFFIRENT FIRE SOUND TRIGGER. DOESN'T WORK
- $player1.setKey("mgunlight","0");
- $player1.setKey("mgunlaser","1");
- sys.setcvar("g_crosshair","0");
- spread = MACHINEGUN_SPREAD;
- spread_max = MACHINEGUN_MAX_SPREAD;
- f_toggle = 0; //// I TRIED THIS ONE BEFORE BUT IT HAS ONLY 0/1 STATES
- }else{ //// FLASHLIGHT OFF LASER OFF
- startSoundShader( "player_flashlight_off", SND_CHANNEL_ITEM );
- f_toggle = 1;
- stopWeaponLight( "laser_normal" );
- stopWeaponLight( "glow_laser_normal" );
- stopWeaponParticle( "view_laser_normal" );
- stopWeaponParticle( "world_laser_normal" );
- light = 0;
- $player1.setKey("mgunlaser","0");
- sys.setcvar("g_crosshair","0");
- spread = MACHINEGUN_SPREAD_SIGHTS;
- spread_max = MACHINEGUN_MAX_SPREAD_SIGHTS;
- f_toggle = 1;
- }
- sys.wait(0.2);
- weaponState( "Idle", MACHINEGUN_RELOAD_TO_IDLE );
- }
- void weapon_machinegun::init() {
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1"); //Was -2
- sys.setcvar("g_gunZ", "-1");
- sys.wait(0.008);
- inmelee = false;
- getClips();
- alignClip();
- string ownerName;
- ownerName = ( getOwner() ).getName();
- f_toggle = 0;
- next_attack = 0;
- weaponState( "Raise", 0 );
- intensity = 1.0;
- AlphaLabs2 = false;
- aimOnce = 0;
- global_flashlight_intensity = 1.0;
- light = 0;
- weaponState( "Raise", 0 );
- }
- void weapon_machinegun::Raise() {
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1"); //Was -2
- sys.setcvar("g_gunZ", "-1");
- sys.wait(0.008);
- if($player1.getKey("mgunlight") == "1" && !sys.isMultiplayer() )
- {
- light = 1;
- }else
- if($player1.getKey("mgunlaser") == "1" && !sys.isMultiplayer() )
- {
- light = 2;
- }else{
- light = 0;
- }
- if(light==1)
- {
- startWeaponLight( "light_flash" );
- startWeaponLight( "glow_flash" );
- startWeaponParticle( "flash" );
- startWeaponParticle( "world_flash" );
- sys.setcvar("g_crosshair","0");
- spread = MACHINEGUN_SPREAD_FLASH;
- spread_max = MACHINEGUN_MAX_SPREAD_FLASH;
- f_toggle = 0;
- }else if(light==2)
- {
- startWeaponLight( "laser_normal" );
- startWeaponLight( "glow_laser_normal" );
- startWeaponParticle( "view_laser_normal" );
- startWeaponParticle( "world_laser_normal" );
- sys.setcvar("g_crosshair","0");
- spread = MACHINEGUN_SPREAD;
- spread_max = MACHINEGUN_MAX_SPREAD;
- f_toggle = 0;
- }else{
- sys.setcvar("g_crosshair","0");
- spread = MACHINEGUN_SPREAD_SIGHTS;
- spread_max = MACHINEGUN_MAX_SPREAD_SIGHTS;
- f_toggle = 1;
- }
- weaponRising();
- playAnim( ANIMCHANNEL_ALL, "raise" );
- waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
- weaponState( "Idle", MACHINEGUN_RAISE_TO_IDLE );
- }
- void weapon_machinegun::Lower() {
- sys.setcvar("g_crosshair","0");
- if(aimOnce)
- {
- ADS_OUT();
- aimOnce = !aimOnce;
- }
- weaponLowering();
- playAnim( ANIMCHANNEL_ALL, "putaway" );
- waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
- weaponHolstered();
- waitUntil( WEAPON_RAISEWEAPON );
- weaponState( "Raise", 0 );
- }
- void weapon_machinegun::Idle() {
- float currentTime;
- currentRound = 1;
- float ammoClip;
- float clip_size;
- ammoClip = ammoInClip();
- clip_size = clipSize();
- if ( !ammoInClip() ) {
- weaponOutOfAmmo();
- } else {
- weaponReady();
- }
- currentRound = 1;
- if(inmelee)
- {
- if(light == 2)
- {
- startWeaponLight( "laser_normal" );
- startWeaponLight( "glow_laser_normal" );
- startWeaponParticle( "view_laser_normal" );
- startWeaponParticle( "world_laser_normal" );
- stopWeaponLight( "laser_melee");
- stopWeaponLight( "glow_laser_melee");
- stopWeaponParticle( "view_laser_melee" );
- stopWeaponParticle( "world_laser_melee" );
- }
- projType = 0;
- changeProjectileDef( projType);
- inmelee = false;
- }
- playCycle( ANIMCHANNEL_ALL, "idle" );
- while ( 1 ) {
- if($player1.getKey("mgunlight") == "1" && !AlphaLabs2 && 1.0 != global_flashlight_intensity)
- {
- stopWeaponLight( "light_flash" );
- stopWeaponLight( "glow_flash" );
- stopWeaponParticle( "flash" );
- stopWeaponParticle( "world_flash" );
- sys.wait(0.2);
- startWeaponLight( "light_flash" );
- startWeaponLight( "glow_flash" );
- startWeaponParticle( "flash" );
- startWeaponParticle( "world_flash" );
- sys.wait(0.2);
- stopWeaponLight( "light_flash" );
- stopWeaponLight( "glow_flash" );
- stopWeaponParticle( "flash" );
- stopWeaponParticle( "world_flash" );
- AlphaLabs2 = true;
- }
- if(AlphaLabs2 && $player1.getKey("mgunlight") == "1" && 1.0 == global_flashlight_intensity)
- {
- startWeaponLight( "light_flash" );
- startWeaponLight( "glow_flash" );
- startWeaponParticle( "flash" );
- startWeaponParticle( "world_flash" );
- AlphaLabs2 = false;
- }
- buttons = $player1.getButtons();
- if(!WEAPON_ATTACK)
- {
- holdButton = false;
- }
- buttons = $player1.getButtons();
- if ( buttons == 20 || buttons == 84 || buttons == 148)
- {
- isZoomed = 1;
- }
- if (buttons != 20 && buttons != 84 && buttons != 148)
- {
- isZoomed = 0;
- }
- if ( isZoomed && !WEAPON_ATTACK )
- {
- if(!aimOnce)
- {
- spread = MACHINEGUN_SPREAD_ZOOMED;
- spread_incrementation_factor = 0.08;
- spread_max = MACHINEGUN_MAX_SPREAD_ZOOMED;
- ADS_IN();
- aimOnce = !aimOnce;
- }
- if($player1.getKey("crouched") == "1")
- {
- spread = spread / 2;
- }
- }
- if ( !isZoomed && !WEAPON_ATTACK )
- {
- if (buttons == 18)
- {
- spread = MACHINEGUN_SPREAD_RUNNING;
- spread_max = MACHINEGUN_MAX_SPREAD_RUNNING;
- spread_incrementation_factor = 0.75;
- }else{
- spread = MACHINEGUN_SPREAD ;
- spread_incrementation_factor = 0.45;
- spread_max = MACHINEGUN_MAX_SPREAD;
- }
- if($player1.getKey("crouched") == "1")
- {
- spread = spread / 2;
- }
- if(aimOnce)
- {
- if(light != 2)
- {
- spread = MACHINEGUN_SPREAD_CROSSHAIR;
- spread_max = MACHINEGUN_SPREAD_CROSSHAIR_MAX;
- }
- ADS_OUT();
- spread = MACHINEGUN_SPREAD_CROSSHAIR;
- spread_max = MACHINEGUN_SPREAD_CROSSHAIR_MAX;
- if($player1.getKey("crouched") == "1")
- {
- spread = spread / 2;
- }
- aimOnce = !aimOnce;
- }
- }
- if ( WEAPON_LOWERWEAPON ) {
- weaponState( "Lower", MACHINEGUN_IDLE_TO_LOWER );
- }
- currentTime = sys.getTime();
- ammoClip = ammoInClip();
- if ( ( currentTime >= next_attack ) && WEAPON_ATTACK ) {
- if ( ammoClip > 0 ) {
- if(!f_toggle)
- {
- weaponState( "Fire", MACHINEGUN_IDLE_TO_FIRE );
- }else if(f_toggle && !holdButton)
- {
- holdButton = true;
- weaponState( "Fire", MACHINEGUN_IDLE_TO_FIRE);
- }
- } else {
- weaponState( "NoAmmo", 4 );
- }
- }
- if ( WEAPON_RELOAD ) {
- if(ammoInClip() < 30 && canReload())
- {
- weaponState( "Reload", MACHINEGUN_IDLE_TO_RELOAD );
- }else{
- startSound( "snd_lowammo", SND_CHANNEL_WEAPON,false);
- }
- }
- if ( WEAPON_SPECIAL && !sys.isMultiplayer() && !aimOnce ) {
- weaponState( "ToggleOnOff", MACHINEGUN_IDLE_TO_RELOAD );
- }
- if (WEAPON_MELEE && !aimOnce)
- {
- weaponState( "Melee", MACHINEGUN_IDLE_TO_RELOAD );
- }
- waitFrame();
- }
- }
- void weapon_machinegun::NoAmmo() {
- startSoundShader( "player_machinegun_dryfire" , SND_CHANNEL_WEAPON );
- sys.wait(0.2);
- weaponState( "Idle", 3 );
- }
- void weapon_machinegun::Fire() {
- entity owner;
- owner = getOwner();
- holdButton = true;
- float ammoClip;
- float currentTime;
- float attackDiff, currentSpread, maxAttackDiff;
- currentTime = sys.getTime();
- maxAttackDiff = MACHINEGUN_BASE_FIRERATE - MACHINEGUN_FIRERATE;
- attackDiff = sys.getTime() - next_attack;
- if( attackDiff >= maxAttackDiff ) {
- currentSpread = spread;
- gradual_spread = 0;
- }
- else {
- gradual_spread = gradual_spread + spread_incrementation_factor * (1 - (attackDiff /maxAttackDiff));
- if(gradual_spread > spread_max) {
- gradual_spread = spread_max;
- }
- currentSpread = spread + gradual_spread;
- }
- next_attack = currentTime + MACHINEGUN_FIRERATE;
- if(light == 1)
- {
- next_attack = next_attack + MACHINEGUN_FIRERATE;
- }
- next_semiauto = sys.getTime() + MACHINEGUN_SEMIAUTO_RATE;
- ammoClip = ammoInClip();
- if ( ammoClip == MACHINEGUN_LOWAMMO ) {
- startSound( "snd_lowammo", SND_CHANNEL_ITEM, true );
- }
- startWeaponParticle("flashfx_right");
- startWeaponParticle("flashfx_left");
- startWeaponParticle("flashfx_left_world");
- startWeaponParticle("flashfx_right_world");
- launchProjectiles( MACHINEGUN_NUMPROJECTILES, currentSpread, 0, 1.0, 1.0,0);
- alignClip();
- if(light == 2) //// WHAT IS THE DIFFIRENCE BETWEEN "=" AND "==" ?
- {
- startSoundShader( "player_machinegun_burst" , SND_CHANNEL_WEAPON );
- }else{
- startSoundShader( "player_machinegun_fire" , SND_CHANNEL_WEAPON );
- }
- playAnim( ANIMCHANNEL_ALL, "fire" );
- while( !animDone( ANIMCHANNEL_ALL, MACHINEGUN_FIRE_TO_IDLE ) ) {
- currentTime = sys.getTime();
- ammoClip = ammoInClip();
- if(f_toggle)
- {
- if (f_toggle && ( ammoClip > 0 ) && ( currentRound < 3 ) ) { //// WHAT "&&" MEANS ?
- currentRound++;
- stopWeaponParticle("flashfx_right");
- stopWeaponParticle("flashfx_left");
- stopWeaponParticle("flashfx_left_world");
- stopWeaponParticle("flashfx_right_world");
- sys.wait( MACHINEGUN_SEMIAUTO_RATE );
- weaponState( "Fire", 0 );
- }
- if ( f_toggle && ( ammoClip > 0 ) && ( currentRound >= 3 ) ) {
- stopWeaponParticle("flashfx_right");
- stopWeaponParticle("flashfx_left");
- stopWeaponParticle("flashfx_left_world");
- stopWeaponParticle("flashfx_right_world");
- sys.wait( MACHINEGUN_SEMIAUTO_RATE );
- weaponState( "Idle", MACHINEGUN_FIRE_TO_IDLE );
- }
- if ( !WEAPON_ATTACK && holdButton ) {
- sys.wait( MACHINEGUN_SEMIAUTO_RATE );
- holdButton = false;
- }
- if ( WEAPON_ATTACK && ( ammoClip > 0 ) && !holdButton ) {
- weaponState( "Fire", 0 );
- }
- }
- else if ( ( currentTime >= next_attack ) && ( WEAPON_NETFIRING || ( WEAPON_ATTACK && ( ammoClip > 0 ) ) ) ) {
- stopWeaponParticle("flashfx_right");
- stopWeaponParticle("flashfx_left");
- stopWeaponParticle("flashfx_left_world");
- stopWeaponParticle("flashfx_right_world");
- weaponState( "Fire", 0 );
- }
- waitFrame();
- }
- stopWeaponParticle("flashfx_right");
- stopWeaponParticle("flashfx_left");
- stopWeaponParticle("flashfx_left_world");
- stopWeaponParticle("flashfx_right_world");
- weaponState( "Idle", MACHINEGUN_FIRE_TO_IDLE );
- }
- void weapon_machinegun::Reload() {
- //startSoundShader( "player_machinegun_reload_script" , SND_CHANNEL_ANY );
- weaponReloading();
- float ammoClip;
- ammoClip = getCurrentValue();
- adjustAmmo();
- alignAmmo();
- playAnim( ANIMCHANNEL_ALL, "reload" );
- while( !animDone( ANIMCHANNEL_ALL, MACHINEGUN_RELOAD_TO_IDLE ) ) {
- if ( WEAPON_LOWERWEAPON ) {
- stopSound( SND_CHANNEL_ANY, false );
- weaponState( "Idle", MACHINEGUN_RELOAD_TO_IDLE );
- }
- waitFrame();
- }
- waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
- float clip = getAmmo();
- current_clip = getClipNo();
- $player1.setKey("currentmachineclip", current_clip);
- addToClip(clip,0,1);
- setClips();
- weaponState( "Idle", MACHINEGUN_RELOAD_TO_IDLE );
- }
- void weapon_machinegun::ExitCinematic() {
- next_attack = 0;
- weaponState( "Idle", 0 );
- }
- void weapon_machinegun::ADS_IN() {
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1");
- sys.setcvar("g_gunZ", "-1");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.2");
- sys.setcvar("g_gunZ", "-0.5");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.4");
- sys.setcvar("g_gunZ", "-0.2");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.6");
- sys.setcvar("g_gunZ", "0.2");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.8");
- sys.setcvar("g_gunZ", "0.6");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.05");
- sys.setcvar("g_gunZ", "0.85");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.2");
- sys.setcvar("g_gunZ", "1");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.3");
- sys.setcvar("g_gunZ", "1.1");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.3");
- sys.setcvar("g_gunZ", "1.2");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.5");
- sys.setcvar("g_gunZ", "1.3");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.7");
- sys.setcvar("g_gunZ", "1.3");
- }
- void weapon_machinegun::ADS_OUT() {
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.2");
- sys.setcvar("g_gunZ", "1.05");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.15");
- sys.setcvar("g_gunZ", "1");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "2.05");
- sys.setcvar("g_gunZ", "0.85");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.95");
- sys.setcvar("g_gunZ", "0.75");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.8");
- sys.setcvar("g_gunZ", "0.6");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.6");
- sys.setcvar("g_gunZ", "0.4");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.3");
- sys.setcvar("g_gunZ", "0.2");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.4");
- sys.setcvar("g_gunZ", "-0.2");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1.2");
- sys.setcvar("g_gunZ", "-0.5");
- sys.wait(0.011);
- sys.setcvar("g_gunX", "0");
- sys.setcvar("g_gunY", "1");
- sys.setcvar("g_gunZ", "-1");
- sys.wait(0.011);
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ATM
- LASER ON - RAPID AUTOMATIC FIRE "player_machinegun_fire" SOUND
- FLASHLIGHT ON - CYCLIC AUTOMATIC FIRE"player_machinegun_fire" SOUND
- FLASHLIGHT OFF LASER OFF - 3rnd BURST "player_machinegun_fire" SOUND
- I WANNA ACHIEVE SITUATION, WHERE
- LASER ON - EXTREMLY FAST 3rnd burst FIRE "player_machinegun_burst" CUSTOM SOUND I HAVE MADE
- FLASHLIGHT ON/OFF - CYCLIC AUTOMATIC FIRE"player_machinegun_fire" SOUND
- "player_machinegun_burst"
- I PLACED .WAV FILE INTO zSound.pk4 MOD DIRECTORY
- sound/weapons/machinegun/machinegun_burst.wav
- HAS BEEN DESCRIBED IN weapons.sndhd file
- "player_machinegun_burst {
- minDistance 5
- maxDistance 130
- volume 10
- sound/weapons/machinegun/machinegun_burst.wav
- }"
- ONLY WEAPON, THAT USES TWO FIRING SOUNDS IS PLASMAGUN BALL/RAILBEAM. PROPER SOUNDS ARE TRIGGERED VIA
- "launchProjectiles( PLASMAGUN_NUMPROJECTILES, spread, 0, 1.0, 1.0 ,0);
- if( projType == PROJECTILE_TYPE_PLASMARAIL_BEAM)
- {
- startSoundShader( "plasma_rail_fire", SND_CHANNEL_WEAPON );
- }else{
- startSoundShader( "plasma_fire" , SND_CHANNEL_WEAPON );
- }"
- SHOULD I JUST CREATE CUSTOM PROJECTILE FOR 3rnd burst EXCLUSIVELY, DESCRIBED IN weapon_.def ?
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement