Swarm FirstPersonView: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 43: Line 43:


(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>
Thats it, now you have to change every command of the walking and stuff in e.g.
::src\game\shared\swarm\asw_player_shared.cpp


== More information ==
== More information ==

Revision as of 09:18, 2 January 2012

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

Open this file:

src\game\client\swarm\clientmode_asw.cpp

search for:

		::input->CAM_ToThirdPerson();

replace with:

		::input->CAM_ToFirstPerson();//	::input->CAM_ToThirdPerson();
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 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();


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

Thats it, now you have to change every command of the walking and stuff in e.g.

src\game\shared\swarm\asw_player_shared.cpp


More information