Raised This Month: $32 Target: $400
 8% 

How is weapon punchangle calculated?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnimalMonster
Senior Member
Join Date: May 2020
Old 10-01-2022 , 17:33   How is weapon punchangle calculated?
Reply With Quote #1

The title already expresses what i'm looking for.
AnimalMonster is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 10-01-2022 , 19:50   Re: How is weapon punchangle calculated?
Reply With Quote #2

https://github.com/alliedmodders/hls...layer.cpp#L633

also weapons have their separate modifiers
__________________

Last edited by deprale; 10-01-2022 at 19:51.
deprale is offline
AnimalMonster
Senior Member
Join Date: May 2020
Old 10-02-2022 , 07:46   Re: How is weapon punchangle calculated?
Reply With Quote #3

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;
	}
}

Last edited by AnimalMonster; 10-02-2022 at 08:03.
AnimalMonster is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-02-2022 , 22:14   Re: How is weapon punchangle calculated?
Reply With Quote #4

Doesn't the game already do this? Why do you need this value?
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:50.


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