UGX-Mods

Call of Duty 5: World at War => Tutorial Desk => Scripting => Topic started by: gympie6 on April 15, 2022, 07:17:35 pm

Title: 3-round burst fix
Post by: gympie6 on April 15, 2022, 07:17:35 pm
I was working on my map and added some three round burst weapons to the game.
When I reload with the last magazine I noticed that the weapon is firing very slow with weird delay.
If there is one bullet reserve this problem won't happen so that gave me an idea.
 
There is a tutorial that should have a fix but for me it didn't work:
https://www.ugx-mods.com/forum/modding/52/user-tutorial-weapon-settings-in-a-weapon-file/5651/ (https://www.ugx-mods.com/forum/modding/52/user-tutorial-weapon-settings-in-a-weapon-file/5651/)
 
This one however seems to fix the issue:
https://www.ugx-mods.com/forum/modding/52/slow-3-round-burst-weapon-fix-verteseas-fix/23898/ (https://www.ugx-mods.com/forum/modding/52/slow-3-round-burst-weapon-fix-verteseas-fix/23898/)
I leave this fix up in case it's still neccesary.
 
Anyway here is the fix, make a new gsc file with name three_round_burst_fix and paste this:
 
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
    level thread fix_on_player_connect();
}

fix_on_player_connect()
{
    for( ;; )
    {
        level waittill( "connecting", player );
        player thread begin_firing_fix();
        player thread end_firing_fix();
        player thread fire_fix();
    }
}

check_is_weapon(weapon)
{
    // I couldn't find a check for 3-round burst weapons...
    // Add your 3-round burst weapons here!
    if(weapon == "zm_m16"
    || weapon == "ray_gun2"
    || weapon == "ray_gun2_upgraded"
    || weapon == "acidgat_zm"
    || weapon == "acidgat_zm_upgraded")
    {
        return true;
    }
   
    return false;
}

begin_firing_fix()
{
    self endon("disconnect");

    while(1)
    {
        self waittill( "begin_firing" );
        current_weapon = self GetCurrentWeapon();
   
        if (check_is_weapon(current_weapon))
        {    
            stock_ammo = self getWeaponAmmoStock( current_weapon );            
            if (stock_ammo == 0)
            {
                self setWeaponAmmoStock( current_weapon, 1 );
            }
        }
    }
}

end_firing_fix()
{
    self endon("disconnect");

    while(1)
    {
        self waittill( "end_firing" );
        current_weapon = self GetCurrentWeapon();
       
        if (check_is_weapon(current_weapon))
        {    
            stock_ammo = self getWeaponAmmoStock( current_weapon );            
            if (stock_ammo <= 1)
            {
                self setWeaponAmmoStock( current_weapon, 0 );
            }
        }
    }
}

fire_fix()
{
    self endon("disconnect");

    while(1)
    {
        self waittill( "weapon_fired" );
        current_weapon = self GetCurrentWeapon();
       
        if (check_is_weapon(current_weapon))
        {    
            clip_ammo = self GetWeaponAmmoClip( current_weapon );
            stock_ammo = self getWeaponAmmoStock( current_weapon );
           
            if (stock_ammo <= 1 && clip_ammo == 0)
            {
                self setWeaponAmmoStock( current_weapon, 0 );
            }
        }
    }
}

add this under maps\_load::main(); in _zombiemode.gsc
 
maps\three_round_burst_fix::init();
 
You're done congrats!