Swarm ThirdPersonView: Difference between revisions
 (Created page with "== How to Create a Third Person View in a Alien Swarm Modification. ==  See Swarm SDK Create a Mod first.   == Code: ==  ;Changing asw_controls  Open this file: ::src\game\sh...")  | 
				Thunder4ik (talk | contribs)  m (→top: Unicodifying, replaced: [[Image: → [[File:)  | 
				||
| (4 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[File:thirdpersonalienswarm001.gif|right|250px|thumb|Third Person View from this Tutorial]]  | |||
== How to Create a Third Person View in a Alien Swarm Modification. ==  | == How to Create a Third Person View in a Alien Swarm Modification. ==  | ||
| Line 56: | Line 57: | ||
</source>  | </source>  | ||
now the yaw movement (side)  | |||
search for :    | search for :    | ||
<source lang=cpp>  | <source lang=cpp>  | ||
| Line 94: | Line 95: | ||
(NOTICE:You just have to fix the Shootpositions in some weapons!)  | (NOTICE:You just have to fix the Shootpositions in some weapons!)  | ||
== Updated Code: ==  | |||
- First change asw_controls back to 1  | |||
- Now open up asw_in_mouse.cpp (clientside)  | |||
::asw_in_mouse.cpp  | |||
search for  | |||
<source lang=cpp>void CASWInput::ResetMouse( void )  | |||
{</source>  | |||
replace the whole function with this  | |||
<source lang=cpp>  | |||
		int x, y;  | |||
	if (MarineDidPrice() || !asw_controls.GetBool())  | |||
	{		  | |||
		GetMousePos( x, y );	// asw instead of GetWindowCenter, so mouse doesn't move   | |||
		SetMousePos( x, y );   //asw by price  | |||
	}  | |||
	else  | |||
	{  | |||
	GetWindowCenter( x,  y );  | |||
	SetMousePos( x, y );  | |||
	}  | |||
</source>  | |||
go on and search for  | |||
<source lang=cpp>ApplyMouse( void )  | |||
{</source>  | |||
replace the whole function with this  | |||
<source lang=cpp>  | |||
		int current_posx, current_posy;	  | |||
		GetMousePos(current_posx, current_posy);  | |||
	if ( ASWInput()->ControllerModeActive() )  | |||
		return;  | |||
//by price  | |||
	if (MarineDidPrice() || !asw_controls.GetBool())  | |||
	{		  | |||
				TurnTowardMouse( viewangles, cmd );  | |||
		// force the mouse to the center, so there's room to move  | |||
		ResetMouse();  | |||
		SetMousePos( current_posx, current_posy );	// asw - swarm wants it unmoved (have to reset to stop buttons locking)  | |||
	}  | |||
	CInput::ApplyMouse( nSlot, viewangles, cmd, mouse_x, mouse_y );  | |||
		// force the mouse to the center, so there's room to move  | |||
		ResetMouse();  | |||
</source>  | |||
Save and now search for asw_input.cpp (clientside)  | |||
::asw_input.cpp  | |||
Search for   | |||
<source lang=cpp>bool MarineControllingTurret()</source>  | |||
below that function add this:  | |||
<source lang=cpp>  | |||
//price IsHacking  | |||
bool MarineDidPrice()  | |||
//by price  | |||
{  | |||
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();  | |||
	return (pPlayer && pPlayer->GetMarine() && pPlayer->GetMarine()->IsHacking());  | |||
}  | |||
</source>  | |||
now open the header and add this :  | |||
<source lang=cpp>bool MarineDidPrice();//by price</source>  | |||
The last part is to comment out every command of the walking in  | |||
::src\game\shared\swarm\asw_marine_gamemovement.cpp  | |||
Example (9 functions have to comment out):  | |||
<source lang=cpp>  | |||
	if ( asw_controls.GetInt() == 1 )  | |||
		AngleVectors( ASWGameRules()->GetTopDownMovementAxis(), &forward );   | |||
	else  | |||
</source>  | |||
== More information ==  | == More information ==  | ||
[[Category:Alien Swarm]]  | [[Category:Alien Swarm]]  | ||
[[Category:Programming]]  | [[Category:Programming]]  | ||
Latest revision as of 12:44, 8 January 2024
How to Create a Third Person View in a Alien Swarm Modification.
See Swarm SDK Create a Mod first.
Code:
- Changing asw_controls
 
Open this file:
- src\game\shared\swarm\asw_player_shared.cpp
 
First we change the value "1" to "0" in asw_controls otherwise the angle of the mouse will be wrong. (NOTICE: the panels and stuff will NOT work anymore, you have to fix that in asw_in_mouse reset and apply functions)
ConVar asw_controls("asw_controls", "1", FCVAR_REPLICATED | FCVAR_CHEAT, "Disable to get normal FPS controls (affects all players on the server)");
- Changing the Crosshair to look like a Shooter one.
 
Open this file:
- src\game\client\swarm\vgui\asw_hud_crosshair.cpp
 
and change the number in this entry to 0
ConVar asw_crosshair_use_perspective("asw_crosshair_use_perspective", "1", FCVAR_CHEAT, "Show the crosshair that has perspective or the old version?");
- Fixing the Shootposition
 - 
- src\game\shared\swarm\asw_marine_shared.cpp
 
 
search for
Vector CASW_Marine::Weapon_ShootPosition( )
and replace the whole function with this:
	return EyePosition();
- Now we adjust the yaw and pitch code (copy and paste) [big thanks to Rehbock]
 
Open:
- src\game\client\swarm\asw_in_camera.cpp
 
search for :
	return m_fCurrentCameraPitch;
(its in the float CASWInput::ASW_GetCameraPitch function) replace with this:
	bool bIsThirdPerson = ( ::input->CAM_IsThirdPerson() != 0 );
	if ( bIsThirdPerson )
	{
//function:
		float fPitchMovement;
C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
	{
	fPitchMovement = pPlayer->EyeAngles()[PITCH];
			float fRotate = fPitchMovement;
		float fFullRotations = static_cast< int >( fRotate / 360.0f );
		fRotate -= fFullRotations * 360.0f;
				fRotate = AngleNormalize( fRotate );
				return  fRotate ;}
	}
	return m_fCurrentCameraPitch;
now the yaw movement (side) search for :
	return asw_cam_marine_yaw.GetFloat();
(its in the float CASWInput::ASW_GetCamera function) replace with this:
	bool bIsThirdPerson = ( ::input->CAM_IsThirdPerson() != 0 );
	if ( bIsThirdPerson )
	{
	float fYawMovement;
C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if (pPlayer && pPlayer->GetMarine())
				{
	fYawMovement = pPlayer->EyeAngles()[YAW];
			float fRotate = fYawMovement;
		float fFullRotations = static_cast< int >( fRotate / 360.0f );
		fRotate -= fFullRotations * 360.0f;
				fRotate = AngleNormalize( fRotate );
				return  fRotate ;
				}
	}
	return asw_cam_marine_yaw.GetFloat();
- To change the distance you can change the value from
 
ConVar asw_cam_marine_dist( "asw_cam_marine_dist", "412", FCVAR_CHEAT, "Marine Camera: Distance from marine." );
I set it to the value "90" its also important to remove the shift function, just change the value "1" to "0"
ConVar asw_cam_marine_shift_enable( "asw_cam_marine_shift_enable", "0", FCVAR_CHEAT, "Camera shifting enable/disable." ); //default was 1
Thats it :-)
(NOTICE:You just have to fix the Shootpositions in some weapons!)
Updated Code:
- First change asw_controls back to 1 - Now open up asw_in_mouse.cpp (clientside)
- asw_in_mouse.cpp
 
search for
void CASWInput::ResetMouse( void )
{
replace the whole function with this
		int x, y;
	if (MarineDidPrice() || !asw_controls.GetBool())
	{		
		GetMousePos( x, y );	// asw instead of GetWindowCenter, so mouse doesn't move 
		SetMousePos( x, y );   //asw by price
	}
	else
	{
	GetWindowCenter( x,  y );
	SetMousePos( x, y );
	}
go on and search for
ApplyMouse( void )
{
replace the whole function with this
		int current_posx, current_posy;	
		GetMousePos(current_posx, current_posy);
	if ( ASWInput()->ControllerModeActive() )
		return;
//by price
	if (MarineDidPrice() || !asw_controls.GetBool())
	{		
				TurnTowardMouse( viewangles, cmd );
		// force the mouse to the center, so there's room to move
		ResetMouse();
		SetMousePos( current_posx, current_posy );	// asw - swarm wants it unmoved (have to reset to stop buttons locking)
	}
	CInput::ApplyMouse( nSlot, viewangles, cmd, mouse_x, mouse_y );
		// force the mouse to the center, so there's room to move
		ResetMouse();
Save and now search for asw_input.cpp (clientside)
- asw_input.cpp
 
Search for
bool MarineControllingTurret()
below that function add this:
//price IsHacking
bool MarineDidPrice()
//by price
{
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	return (pPlayer && pPlayer->GetMarine() && pPlayer->GetMarine()->IsHacking());
}
now open the header and add this :
bool MarineDidPrice();//by price
The last part is to comment out every command of the walking in
- src\game\shared\swarm\asw_marine_gamemovement.cpp
 
Example (9 functions have to comment out):
	if ( asw_controls.GetInt() == 1 )
		AngleVectors( ASWGameRules()->GetTopDownMovementAxis(), &forward ); 
	else