Results 1 to 6 of 6
  1. #1
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    North of Hell, South of Heaven
    Posts
    6,067
    Reputation
    323
    Thanks
    3,323
    My Mood
    Doh

    Some stuff with ammo...

    this is only to help the section and to help you guys better understand how this game engine works. This has lots of explanations in it about all sorts of info on ammo and what it does

    Code:
    void CClientWeapon::ChangeAmmoWithReload( uint8 nNewAmmoId, bool bForce /*=false*/ )
    {
    	// Update the player's stats...
    	if ( ( W_RELOADING == GetState() ) && !bForce )
    	{
    		return;
    	}
    
    	if ( CanChangeToAmmo( nNewAmmoId ) && ( nNewAmmoId != m_nAmmoId ) )
    	{
    		ASSERT( 0 != g_pWeaponMgr );
    		m_nAmmoId   = nNewAmmoId;
    		m_pAmmo     = g_pWeaponMgr->GetAmmo( m_nAmmoId );
    
    		// Make sure we reset the anis (the ammo may override the 
    		// weapon animations)...
    		InitAnimations( true );
    
    		if ( m_pAmmo->pAniOverrides )
    		{
    			// If we're not using the defaults play the new select ani...
    			Select();
    		}
    		else
    		{
    			// Do normal reload...
    			ReloadClip( true, -1, true, true );
    
    			// Add a message so the user knows he switched ammo (sometimes it
    			// isn't that obvious)...
    
    			if (strlen(m_pAmmo->szShortName))
    			{
    				char szMsg[128];
    				FormatString(IDS_CHANGING_AMMO, szMsg, sizeof(szMsg), m_pAmmo->szShortName);
    				std::string icon = m_pAmmo->GetNormalIcon();
    				g_pPickupMsgs->AddMessage(szMsg, icon.c_str());
    			}
    		}
    	}
    }
    
    
    // ----------------------------------------------------------------------- //
    //
    //	ROUTINE:	CClientWeapon::ChangeAmmoImmediate()
    //
    //	PURPOSE:	Change to the specified ammo type
    //
    // ----------------------------------------------------------------------- //
    
    void CClientWeapon::ChangeAmmoImmediate( uint8 nNewAmmoId, int nAmmoAmount /*=-1*/, bool bForce /*=false*/ )
    {
    	// Update the player's stats...
    	if ( ( W_RELOADING == GetState() ) && !bForce )
    	{
    		return;
    	}
    
    	if ( CanChangeToAmmo( nNewAmmoId ) && ( nNewAmmoId != m_nAmmoId ) )
    	{
    		ASSERT( 0 != g_pWeaponMgr );
    		m_nAmmoId   = nNewAmmoId;
    		m_pAmmo     = g_pWeaponMgr->GetAmmo( m_nAmmoId );
    
    		// Make sure we reset the anis (the ammo may override the 
    		// weapon animations)...
    		InitAnimations( true );
    
    		if ( m_pAmmo->pAniOverrides )
    		{
    			// If we're not using the defaults play the new select ani...
    			Select();
    		}
    		else
    		{
    			// Do normal reload...
    			ReloadClip( false, nAmmoAmount /*-1*/, true, true );
    		}
    		}
    	else
    	{
    		// Update the hud to reflect the new ammo amount...
    		g_pPlayerStats->UpdateAmmo( m_nWeaponId, m_nAmmoId, nAmmoAmount );
    		g_pPlayerStats->UpdatePlayerWeapon( m_nWeaponId, m_nAmmoId );
    	}
    }
    
    
    // ----------------------------------------------------------------------- //
    //
    //	ROUTINE:	CWeapon::ReloadClip
    //
    //	PURPOSE:	Fill the clip
    //
    // ----------------------------------------------------------------------- //
    
    void CClientWeapon::ReloadClip( bool bPlayReload /*=true*/,
                                    int nNewAmmo /*=-1*/,
                                    bool bForce /*=false*/,
    								bool bNotifyServer /*=false*/)
    {
    	// Can't reload clip while deselecting the weapon...
    
    	if ( W_DESELECT == GetState() ) return;
    
    	// get all the ammo the player possesses
    	int nAmmoCount = g_pPlayerStats->GetAmmoCount( m_nAmmoId );
    
    	// Get an intermediate amount of ammo.  If the nNewAmmo has
    	// been specified, use that value.  Otherwise use the total
    	// amount of ammo on the player.
    	int nAmmo = nNewAmmo >= 0 ? nNewAmmo : nAmmoCount;
    
    	// Get how many shots are in a clip.
    	int nShotsPerClip = m_pWeapon->nShotsPerClip;
    
    	// Update the player's stats...
    	// note: the ammo amount we pass may be too much but
    	// these functions figure out what the max really is,
    	// and then we do the same thing later
    
    	// UpdateAmmo does a lot of stuff, one of those is passing in
    	// how much ammo you have.  If you specify an amount that is
    	// more or less, it will consider this the new amount of
    	// ammo that you have on you and adjust things accordingly.
    	g_pPlayerStats->UpdateAmmo( m_nWeaponId, m_nAmmoId, nAmmo );
    
    
    	// This will set the player stats to the specified weapon and 
    	// ammo id.  In this case, use the current ones.
    	g_pPlayerStats->UpdatePlayerWeapon( m_nWeaponId, m_nAmmoId );
    
    	// Make sure we can reload the clip...
    	if ( !bForce )
    	{
    		// Already reloading...
    		if ( m_hObject && ( W_RELOADING == GetState() ) )
    		{
    			return;
    		}
    
    		// Clip is full...
    		if ( ( m_nAmmoInClip == nShotsPerClip ) || ( m_nAmmoInClip == nAmmoCount ) )
    		{
    			return;
    		}
    	}
    
    	if ( ( nAmmo > 0 ) && ( nShotsPerClip > 0 ) )
    	{
    		// The amount of ammo we give the player due
    		// of the reload is tracked with m_nNewAmmoInClip.
    		// Set the new ammo to the lesser vaule of
    		// either the max clip size of the amount of ammo
    		// on the player.
    		if ( nAmmo < nShotsPerClip )
    		{
    			m_nNewAmmoInClip = nAmmo;
    		}
    		else
    		{
    			m_nNewAmmoInClip = nShotsPerClip;
    		}
    		
    		if( bNotifyServer )
    		{
    			// Let the server know we are reloading the clip...
    
    			CAutoMessage cMsg;
    			cMsg.Writeuint8( MID_WEAPON_RELOAD );
    			cMsg.Writeuint8( m_nAmmoId ); // We maybe switching ammo
    			g_pLTClient->SendToServer( cMsg.Read(), MESSAGE_GUARANTEED );
    		}
    		
    
    		// check for a valid reload animation
    		if ( bPlayReload && ( INVALID_ANI != GetReloadAni() ) )
    		{
    			// setting the state will "queue" the animation to
    			// start playing on the next update
    			SetState( W_RELOADING );
    			return;
    		}
    		else
    		{
    			// there is no reload animation, so just put
    			// the right amount in the clip directly
    			m_nAmmoInClip = m_nNewAmmoInClip;
    		}
    	}
    }
    
    
    // ----------------------------------------------------------------------- //
    //
    //	ROUTINE:	CClientWeapon::DecrementAmmo
    //
    //	PURPOSE:	Decrement the weapon's ammo count
    //
    // ----------------------------------------------------------------------- //
    
    void CClientWeapon::DecrementAmmo()
    {
    	// Hide the necessary pieces...
    	SpecialShowPieces(false);
    
    	int nAmmo;
    	bool bInfiniteAmmo = ( g_bInfiniteAmmo || ( !!( m_pWeapon->bInfiniteAmmo ) ) );
    	if ( bInfiniteAmmo )
    	{
    		nAmmo = INFINITE_AMMO_AMOUNT;
    	}
    	else
    	{
    		nAmmo = g_pPlayerStats->GetAmmoCount( m_nAmmoId );
    	}
    
    	int nShotsPerClip = m_pWeapon->nShotsPerClip;
    
    	if ( 0 < m_nAmmoInClip )
    	{
    		if ( 0 < nShotsPerClip )
    		{
    			// decrease the ammo in the clip only if the clip
    			// is non-zero
    			--m_nAmmoInClip;
    		}
    
    		if ( !bInfiniteAmmo )
    		{
    			// we are not using infinite ammo, update the current amount
    			--nAmmo;
    
    			// Update our stats.  This will ensure that our stats are always
    			// accurate (even in multiplayer)...
    			g_pPlayerStats->UpdateAmmo( m_nWeaponId, m_nAmmoId, nAmmo, LTFALSE, LTFALSE );
    		}
    	}
    
    	// Check to see if we need to reload...
    	if ( 0 < nShotsPerClip )
    	{
    		if ( 0 >= m_nAmmoInClip )
    		{
    			ReloadClip( true, nAmmo );
    		}
    	}
    }

    This is from the NOLF2 source, yes i know you can't just throw it in CA and it works... but maybe it will help some one here out. I've found lots of weird features this way before just by taking bits n pieces and throwing em in a CA hack

    commando: You're probably the best non-coder coder I know LOL


  2. The Following 2 Users Say Thank You to supercarz1991 For This Useful Post:

    p2ssword (01-04-2013),pDevice (01-04-2013)

  3. #2
    Skaterforeva1's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Up your ass
    Posts
    917
    Reputation
    32
    Thanks
    476
    My Mood
    Psychedelic
    Well do you think if we reset the total amount of ammo every time we go to reload that we could get unlimited?

    ^Suck it!


  4. #3
    -Bl00d-'s Avatar
    Join Date
    Sep 2011
    Gender
    female
    Location
    Imma girl what about it?
    Posts
    481
    Reputation
    10
    Thanks
    53
    My Mood
    Twisted
    Quote Originally Posted by Skaterforeva1 View Post
    Well do you think if we reset the total amount of ammo every time we go to reload that we could get unlimited?
    try resetting the total ammo after every shot...
    result = no reload + infinite ammo
    Successful buys: 20
    Successful sells: 4
    Successful trades: 9
    Scammed: 4

     
    http://www.mpgh.net/forum/490-vouches/560562-vouches.html

    ^^^^^^^^^^^
    vouche for me?

  5. #4
    Flengo's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    Ontario, Canada
    Posts
    15,696
    Reputation
    3319
    Thanks
    11,111
    My Mood
    Happy
    Quote Originally Posted by -Bl00d- View Post

    try resetting the total ammo after every shot...
    result = no reload + infinite ammo
    You have to find these functions inside Engine to use them first
    I Read All Of My PM's & VM's
    If you need help with anything, just let me know.
     
     
    VM | PM

    Publicist Since 04.04.2015
    Middleman Since Unknown - Unknown
    Global Moderator Since 08.01.2013
    Donator Since 05.29.2013

    Minion+ Since 04.18.2013

    District 187 Minion Since 04.04.2013
    Steam Minion Since 02.26.2013
    WarRock Minion Since 02.19.2013
    A.V.A Minion Since 02.13.2013
    DayZ Minion Since 01.21.2013
    Combat Arms Minion Since 12.26.2012
    Contributor Since 11.16.2012
    Member Since 05.11.2010


  6. #5
    Skaterforeva1's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Up your ass
    Posts
    917
    Reputation
    32
    Thanks
    476
    My Mood
    Psychedelic
    Quote Originally Posted by -Bl00d- View Post
    Quote Originally Posted by Skaterforeva1 View Post
    Well do you think if we reset the total amount of ammo every time we go to reload that we could get unlimited?
    try resetting the total ammo after every shot...
    result = no reload + infinite ammo
    Even better lol

    ^Suck it!


  7. #6
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    North of Hell, South of Heaven
    Posts
    6,067
    Reputation
    323
    Thanks
    3,323
    My Mood
    Doh
    Quote Originally Posted by Flengo View Post


    You have to find these functions inside Engine to use them first
    these are from CShell, not engine

    commando: You're probably the best non-coder coder I know LOL


Similar Threads

  1. me messing around with some stuff
    By -ParallaX in forum Showroom
    Replies: 2
    Last Post: 08-04-2009, 06:29 PM
  2. need some help with domains.
    By fastbullet in forum WarRock - International Hacks
    Replies: 1
    Last Post: 04-26-2007, 09:44 AM
  3. this is how i solve stuff with my teachers
    By EleMentX in forum Spammers Corner
    Replies: 3
    Last Post: 12-09-2006, 05:20 PM
  4. need some help with client exe.
    By barney in forum Hack Requests
    Replies: 2
    Last Post: 11-03-2006, 11:05 PM
  5. Need help with ammo hack
    By AthlaS in forum WarRock - International Hacks
    Replies: 4
    Last Post: 01-19-2006, 02:50 PM