Swarm FirstPersonView

From Valve Developer Community
Jump to: navigation, search

How to Create First Person View in a Alien Swarm Modification.

See Swarm SDK Create a Mod first.


Changing asw_controls

Open this file:


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)");
Set the Camera in the First Person View

Open this file:


search for:


replace with:

		::input->CAM_ToFirstPerson();//	::input->CAM_ToThirdPerson();
Changing the Crosshair to look like a Shooter one.

Open this file:


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 Shootposition

search for

Vector CASW_Marine::Weapon_ShootPosition( )

and replace the whole function with this:

	return EyePosition();

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)


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
	GetWindowCenter( x,  y );
	SetMousePos( x, y );

go on and search for

void CASWInput::ApplyMouse( int nSlot, QAngle& viewangles, CUserCmd *cmd, float mouse_x, float mouse_y )

replace the whole function with this

		int current_posx, current_posy;	
		GetMousePos(current_posx, current_posy);

	if ( ASWInput()->ControllerModeActive() )
//by price
	if (MarineDidPrice() || !asw_controls.GetBool())
				TurnTowardMouse( viewangles, cmd );
		// force the mouse to the center, so there's room to move
		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

Save and now search for asw_input.cpp (clientside)


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


Example (9 functions have to comment out):

	if ( asw_controls.GetInt() == 1 )
		AngleVectors( ASWGameRules()->GetTopDownMovementAxis(), &forward ); 

Enabling Viewmodels

If you want to enable viewmodels, comment this line out from

virtual void			CreateViewModel( int viewmodelindex = 0 ) { return; }	// ASW players don't have viewmodels

More information