Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. Using ammo in stock instead of clip

Using ammo in stock instead of clip

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
3 Posts 1 Posters 202 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • bhfffundefined Offline
    bhfffundefined Offline
    bhfff
    wrote on last edited by bhfff
    #1

    Hi I'm relatively new to modding but I know my way around. I can read an understand what the code is doing.

    I'm trying to recreate the Ring of Fire specifically its tier 3 effect, where the player uses its ammo in stock instead of the clip.

    The basic concept is to put the following code into a loop (hopefully it's properly formatted)

    if(self isFiring() && self attackButtonPressed())
    {
    
    	if( self GetWeaponAmmoStock( self getCurrentWeapon() ) > 0 )
    	{
    		self setWeaponAmmoClip(self getCurrentWeapon(), self GetWeaponAmmoClip( self getCurrentWeapon() )+1);
    		self setWeaponAmmoStock(self getCurrentWeapon(), self GetWeaponAmmoStock( self getCurrentWeapon() )-1);
    	}
    }
    					
    

    The problem it's not smooth and the bullets in the clip can still decrease. I thought about using this, but it doesn't help.

    // Use ammo from stock
    if( self GetWeaponAmmoStock( self getCurrentWeapon() ) != 0 )
    {	
       self setClientDvar("sf_use_ignoreammo", "1");
    	
    } else {
    
       self setClientDvar("sf_use_ignoreammo", "0");
    }
    

    I also can't use dvars such as player_sustainAmmo 1 because it's globally applied.

    Here's a function that calculates the time between shots:
    ( I thought about using it as a delay, but it came out it's a bad idea )

    self.timeBetweenShots = gettime() - self.lastShotTime;
    self iprintln(self.timeBetweenShots / 1000);
    
    if(self isFiring() && self attackButtonPressed())
    {
       self.lastShotTime = gettime();
    }
    

    I couldn't find any function related to when a player is shooting or more specifically a function that detects change in ammunition.

    So right now I'm kinda lost, as I really want to make it smooth (aka the ammo in the clip has to stay still) but I also want a code that works for every weapon (considering their rate of fire).

    Also, this one is too slow 😞
    self waittill("weapon_fired");

    Any tips?

    1 Reply Last reply
    0
    • bhfffundefined Offline
      bhfffundefined Offline
      bhfff
      wrote on last edited by
      #2

      I wanted to add that the first part of the code, works if your weapon is automatic.

      Otherwise there's a delay that must be calculated.

      1 Reply Last reply
      0
      • bhfffundefined Offline
        bhfffundefined Offline
        bhfff
        wrote on last edited by bhfff
        #3

        Solved, here's the code! Remember to run this in a loop 🙂

        // We need to make sure the player shot and is holding the shooting button
        if(self isFiring() && self attackButtonPressed()){
        
        	// Use stock instead of clip
        	if( self GetWeaponAmmoStock( self getCurrentWeapon() ) > 0)
        	{
        			
        		ClipSize = WeaponClipSize( self getCurrentWeapon() );
        		CurrentClip = self GetWeaponAmmoClip( self getCurrentWeapon() );
        		CurrentClipDiff = ClipSize - CurrentClip;
        		
        		CurrentStock = self GetWeaponAmmoStock( self getCurrentWeapon() );
        		
        		self setWeaponAmmoClip(self getCurrentWeapon(), ClipSize);
        		self setWeaponAmmoStock(self getCurrentWeapon(), CurrentStock - CurrentClipDiff);
        	
        	}
        }
        

        I'm unsure how this would work for dual wield weapons, the following might work for World at War but unsure about other games

        Add this to any if statement:

        && !maps\_zombiemode_weapons::weapon_is_dual_wield( CurrentWeapon ) 
        
        1 Reply Last reply
        1

        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Donate