View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-28-2015 , 10:34   Re: [HELP] Launching Grenades From Weapon
Reply With Quote #29

I told you that there may be more things to handle, and if I remember well you said you could take care of them. Well, nvm. Also, my code only handle the smoke grenade case, you need to check for other grenades too.

Edit: Or, wait, maybe not. The only thing that is different on grenades is the animation in my code, but looking at the weapons code animations index are the same, and it should work ok.

To find a way, you must understand what CS do. Look at what I highlighted(will talk about sg, it should be mostly the same for all of them): https://github.com/Arkshine/CSSDK/bl...enade.cpp#L116

When you execute PrimaryAttack on the grenade, it sets m_flStartThrow offset to current game time. Then, in WeaponIdle this offset is checked, if bigger than 0 a grenade throw will be initialized(https://github.com/Arkshine/CSSDK/bl...enade.cpp#L151). My answer will be mostly the same as before, redo this:
PHP Code:
 if( angleThrow.)
            
angleThrow.= -10 angleThrow.* ( ( 90 10 ) / 90.0 );
        else
            
angleThrow.= -10 angleThrow.* ( ( 90 10 ) / 90.0 );

        
float flVel = ( 90 angleThrow.) * 6;

        if( 
flVel 750 )
            
flVel 750;

        
UTIL_MakeVectorsangleThrow );

        
Vector vecSrc   m_pPlayer->pev->origin m_pPlayer->pev->view_ofs gpGlobals->v_forward 16;
        
Vector vecThrow gpGlobals->v_forward flVel m_pPlayer->pev->velocity
Then, find and call CGrenade::ShootSmokeGrenade with orpheu. You may need to also alter the offsets like game do:
PHP Code:
  m_flStartThrow        0;
        
m_flNextPrimaryAttack GetNextAttackDelay0.5 );
        
m_flTimeWeaponIdle    UTIL_WeaponTimeBase() + 0.75;

        
m_pPlayer->m_rgAmmom_iPrimaryAmmoType ]--;

        if( !
m_pPlayer->m_rgAmmom_iPrimaryAmmoType ] )
        {
            
m_flTimeWeaponIdle m_flNextSecondaryAttack m_flNextPrimaryAttack GetNextAttackDelay0.5 );
        } 
Edit2: Hold on a minute, I'll try to get the signature for the needed functions.
__________________

Last edited by HamletEagle; 08-28-2015 at 10:44.
HamletEagle is offline