Swarm FirstPersonView
Contents
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
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() )
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
Enabling Viewmodels
If you want to enable viewmodels, comment this line out from
- src\game\server\asw_player.h
virtual void CreateViewModel( int viewmodelindex = 0 ) { return; } // ASW players don't have viewmodels