AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How is weapon punchangle calculated? (https://forums.alliedmods.net/showthread.php?t=339795)

AnimalMonster 10-01-2022 17:33

How is weapon punchangle calculated?
 
The title already expresses what i'm looking for.

deprale 10-01-2022 19:50

Re: How is weapon punchangle calculated?
 
https://github.com/alliedmodders/hls...layer.cpp#L633

also weapons have their separate modifiers

AnimalMonster 10-02-2022 07:46

Re: How is weapon punchangle calculated?
 
Still can't seem to find what i look for...

I'll try to be more descriptive. So, i'm looking to calculate the punchangle the player should get when they fire a weapon.

I think i found my answer but i don't know how i should convert it:
Code:

void CBasePlayerWeapon::KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change)
{
        real_t flKickUp;
        float flKickLateral;

        if (m_iShotsFired == 1)
        {
                flKickUp = up_base;
                flKickLateral = lateral_base;
        }
        else
        {
                flKickUp = m_iShotsFired * up_modifier + up_base;
                flKickLateral = m_iShotsFired * lateral_modifier + lateral_base;
        }

        m_pPlayer->pev->punchangle.x -= flKickUp;

        if (m_pPlayer->pev->punchangle.x < -up_max)
        {
                m_pPlayer->pev->punchangle.x = -up_max;
        }

        if (m_iDirection == 1)
        {
                m_pPlayer->pev->punchangle.y += flKickLateral;

                if (m_pPlayer->pev->punchangle.y > lateral_max)
                        m_pPlayer->pev->punchangle.y = lateral_max;
        }
        else
        {
                m_pPlayer->pev->punchangle.y -= flKickLateral;

                if (m_pPlayer->pev->punchangle.y < -lateral_max)
                        m_pPlayer->pev->punchangle.y = -lateral_max;
        }

        if (!RANDOM_LONG(0, direction_change))
        {
                m_iDirection = !m_iDirection;
        }
}


fysiks 10-02-2022 22:14

Re: How is weapon punchangle calculated?
 
Doesn't the game already do this? Why do you need this value?


All times are GMT -4. The time now is 15:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.