Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] how to enable Spectador mode

Junior Spellweaver
Joined
Mar 29, 2013
Messages
123
Reaction score
39
WarZ.sln

in HUD_Spectator.cpp

Search:

void CameraHUD :: SetFPSCamera(r3dCamera &Cam )

Put this:
Code:
void CameraHUD :: SetFPSCamera(r3dCamera &Cam )
{
    if(g_usePlayerEditorCamera)
        return editor_GetHudByIndex(1)->SetCamera(Cam);


    r3dPoint3D CamPos = FPS_Position;
    CamPos += GetCamOffset();


    r3dPoint3D ViewPos = CamPos + FPS_vVision*10.0f;


[COLOR=#ff0000]//#ifndef FINAL_BUILD //UndeadBrasil Spectator[/COLOR]
    if(d_spectator_fov->GetFloat() > 0.0f)
        GameFOV = d_spectator_fov->GetFloat();
    else
[COLOR=#ff0000]//#endif[/COLOR]
        GameFOV = VIEW_FOV;


    Cam.FOV = GameFOV;
    Cam.SetPosition( CamPos );
    Cam.PointTo(ViewPos);
}

Search:

void CameraHUD :: ProcessFPSCamera()

Put this:

Code:
void CameraHUD :: ProcessFPSCamera()
{
[COLOR=#ff0000]//#ifndef FINAL_BUILD //UndeadBrasil Spectator[/COLOR]
    FPS_Acceleration.Assign(0, 0, 0);


    float    glb_MouseSens    = 0.5f;    // in range (0.1 - 1.0)
    float  glb_MouseSensAdj = 1.0f;    // in range (0.1 - 1.0)




    enablemouselook = (Mouse->IsPressed(r3dMouse::mRightButton)) && !g_imgui_LockRbr;




    if (!enablemouselook) return;




    //
    //  Mouse controls are here
    //
    int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;


    FPS_vViewOrig.x += float(-mMX) * glb_MouseSensAdj;
    FPS_vViewOrig.y += float(-mMY) * glb_MouseSensAdj;


    // Player can't look too high!
    if(FPS_vViewOrig.y > 85)  FPS_vViewOrig.y = 85;
    if(FPS_vViewOrig.y < -85) FPS_vViewOrig.y = -85;


    FPS_ViewAngle = FPS_vViewOrig; // + FPS_vViewDistortion;


    if(FPS_ViewAngle.y > 360 ) FPS_ViewAngle.y = FPS_ViewAngle.y - 360;
    if(FPS_ViewAngle.y < 0 )   FPS_ViewAngle.y = FPS_ViewAngle.y + 360;




    D3DXMATRIX mr;


    D3DXMatrixIdentity(&mr);
    D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-FPS_ViewAngle.x), R3D_DEG2RAD(-FPS_ViewAngle.y), 0);


    FPS_vVision  = r3dVector(mr._31, mr._32, mr._33);


    D3DXMatrixIdentity(&mr);
    D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-FPS_ViewAngle.x), 0, 0);
    FPS_vRight = r3dVector(mr._11, mr._12, mr._13);
    FPS_vUp    = r3dVector(0, 1, 0);
    FPS_vForw  = r3dVector(mr._31, mr._32, mr._33);


    FPS_vForw.Normalize();
    FPS_vRight.Normalize();
    FPS_vVision.Normalize();


    // walk
[COLOR=#ff0000]    //extern float __EditorWalkSpeed;[/COLOR]
[COLOR=#ff0000]    float __EditorWalkSpeed = 5.0f; //UndeadBrasil Spectator[/COLOR]
    float fSpeed = __EditorWalkSpeed;


    float mult = 1;
    if(Keyboard->IsPressed(kbsLeftShift)) mult = 30.0f; //64.0f;


    if(Keyboard->IsPressed(kbsW)) FPS_Acceleration.Z = fSpeed;
    if(Keyboard->IsPressed(kbsS)) FPS_Acceleration.Z = -fSpeed * 0.7f;
    if(Keyboard->IsPressed(kbsA)) FPS_Acceleration.X = -fSpeed * 0.7f;
    if(Keyboard->IsPressed(kbsD)) FPS_Acceleration.X = fSpeed * 0.7f;
    if(Keyboard->IsPressed(kbsQ)) FPS_Position.Y    += SRV_WORLD_SCALE(1.0f)* r3dGetFrameTime() * mult;
    if(Keyboard->IsPressed(kbsE)) FPS_Position.Y    -= SRV_WORLD_SCALE(1.0f)* r3dGetFrameTime() * mult;


    FPS_Position += FPS_vVision * FPS_Acceleration.Z * r3dGetFrameTime() * mult;
    FPS_Position += FPS_vRight * FPS_Acceleration.X * r3dGetFrameTime() *mult;


    //if (FPS_Position.Y < terra_GetH(FPS_Position)) FPS_Position.Y = terra_GetH(FPS_Position);


    if(Keyboard->WasPressed(kbsF6))
    {
        r3dPoint3D PP = FPS_Position + FPS_vVision*60.0f;


        r3dOutToLog("POINT at %f %f %f\n", PP.X, PP.Y, PP.Z);


        GameObject *Car = srv_CreateGameObject("obj_Phys", "Data\\Models\\Objects\\Box01.sco", PP);
    }


[COLOR=#ff0000]//#endif[/COLOR]
}

in Hud_TpsGame.cpp

Search:

void TPSGameHUD :: SetCameraPure ( r3dCamera &Cam)

Put this:
Code:
void TPSGameHUD :: SetCameraPure ( r3dCamera &Cam)
{
[COLOR=#ff0000]//#ifndef FINAL_BUILD  //UndeadBrasil Spectator[/COLOR]
    if(d_video_spectator_mode->GetBool() || d_observer_mode->GetBool())
    {
        r3dPoint3D CamPos = FPS_Position;
        CamPos.Y += 1.8f;
        r3dPoint3D ViewPos = CamPos + FPS_vVision*10.0f;


[COLOR=#ff0000]        //Cam.FOV = r_video_fov->GetFloat();[/COLOR]
        Cam.SetPosition( CamPos );
        Cam.PointTo(ViewPos);


[COLOR=#ff0000]        //LevelDOF = r_video_DOF_enable->GetBool();[/COLOR]
        _NEAR_DOF = 1;
        _FAR_DOF = 1;
[COLOR=#ff0000]        //DepthOfField_NearStart = r_video_nearDOF_start->GetFloat();[/COLOR]
[COLOR=#ff0000]        //DepthOfField_NearEnd = r_video_nearDOF_end->GetFloat();[/COLOR]
[COLOR=#ff0000]        //DepthOfField_FarStart = r_video_farDOF_start->GetFloat();[/COLOR]
[COLOR=#ff0000]        //DepthOfField_FarEnd = r_video_farDOF_end->GetFloat();[/COLOR]
        
        return;
    }
//#endif

Search:

void TPSGameHUD :: Process()

Put this:
Code:
//----------------------------------------------------------------
void TPSGameHUD :: Process()
//----------------------------------------------------------------
{
    if( g_cursor_mode->GetInt() )
    {
        imgui_Update();
        imgui2_Update();
    }


    {
        r3dSetAsyncLoading( 1 ) ;
    }


    obj_Player* pl = gClientLogic().localPlayer_;
    if(!pl) return;


[COLOR=#ff0000]//#ifndef FINAL_BUILD //UndeadBrasil Spectator[/COLOR]
[COLOR=#ff0000]    if (gUserProfile.ProfileData.isDevAccount){ // UndeadBrasil Para nenhum player poder usar o Specator somente Devs[/COLOR]


    bool allow_specator_mode = true;
    if(Keyboard->WasPressed(kbsF8) && allow_specator_mode)
    {
        d_video_spectator_mode->SetBool(!d_video_spectator_mode->GetBool());
        static float DOF_NS=0, DOF_NE=0, DOF_FS=0, DOF_FE=0;
        static int DOF_N=0, DOF_F=0, DOF_ENABLE=0;
        if(d_video_spectator_mode->GetBool())
        {
            FPS_vViewOrig.Assign(pl->ViewAngle);
            // save
            DOF_NS=DepthOfField_NearStart;
            DOF_NE=DepthOfField_NearEnd;
            DOF_FS=DepthOfField_FarStart;
            DOF_FE=DepthOfField_FarEnd;
            DOF_N=_NEAR_DOF;
            DOF_F=_FAR_DOF;
            DOF_ENABLE=LevelDOF;
        }
        else
        {
            // restore
            DepthOfField_NearStart=DOF_NS;
            DepthOfField_NearEnd=DOF_NE;
            DepthOfField_FarStart=DOF_FS;
            DepthOfField_FarEnd=DOF_FE;
            _NEAR_DOF=DOF_N;
            _FAR_DOF=DOF_F;
            LevelDOF=DOF_ENABLE;
        }
    }


    bool allow_observer_mode = true;
    allow_observer_mode = true;


    if(Keyboard->WasPressed(kbsF9) && allow_observer_mode)
    {
        d_observer_mode->SetBool(!d_observer_mode->GetBool());
        if(d_observer_mode->GetBool())
        {
            FPS_vViewOrig.Assign(pl->ViewAngle);
        }
    }


    if(d_video_spectator_mode->GetBool() || d_observer_mode->GetBool())
    {
        FPS_Acceleration.Assign(0, 0, 0);


        float  glb_MouseSensAdj = g_mouse_sensitivity->GetFloat();    
        // camera view
        if(Gamepad->IsConnected())
        {
            float X, Y;
            Gamepad->GetRightThumb(X, Y);
            FPS_vViewOrig.x += float(-X) * r_gamepad_view_sens->GetFloat();
            FPS_vViewOrig.y += float(Y) * r_gamepad_view_sens->GetFloat() * (g_vertical_look->GetBool()?-1.0f:1.0f);
        }
        else // mouse fallback
        {
            int mMX=Mouse->m_MouseMoveX, mMY=Mouse->m_MouseMoveY;


            FPS_vViewOrig.x += float(-mMX) * glb_MouseSensAdj;
            FPS_vViewOrig.y += float(-mMY) * glb_MouseSensAdj * (g_vertical_look->GetBool()?-1.0f:1.0f);
        }


        if(FPS_vViewOrig.y > 85)  FPS_vViewOrig.y = 85;
        if(FPS_vViewOrig.y < -85) FPS_vViewOrig.y = -85;


        FPS_ViewAngle = FPS_vViewOrig;


        if(FPS_ViewAngle.y > 360 ) FPS_ViewAngle.y = FPS_ViewAngle.y - 360;
        if(FPS_ViewAngle.y < 0 )   FPS_ViewAngle.y = FPS_ViewAngle.y + 360;




        D3DXMATRIX mr;


        D3DXMatrixIdentity(&mr);
        D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-FPS_ViewAngle.x), R3D_DEG2RAD(-FPS_ViewAngle.y), 0);


        FPS_vVision  = r3dVector(mr._31, mr._32, mr._33);


        D3DXMatrixIdentity(&mr);
        D3DXMatrixRotationYawPitchRoll(&mr, R3D_DEG2RAD(-FPS_ViewAngle.x), 0, 0);
        FPS_vRight = r3dVector(mr._11, mr._12, mr._13);
        FPS_vUp    = r3dVector(0, 1, 0);
        FPS_vForw  = r3dVector(mr._31, mr._32, mr._33);


        FPS_vForw.Normalize();
        FPS_vRight.Normalize();
        FPS_vVision.Normalize();


       // walk
[COLOR=#ff0000]      //extern float __EditorWalkSpeed;[/COLOR]
[COLOR=#ff0000]        float __EditorWalkSpeed = 5.0f; //UndeadBrasil Spectator[/COLOR]
        float fSpeed = __EditorWalkSpeed;


        float mult = 1;
        if(Keyboard->IsPressed(kbsLeftShift)) mult = d_spectator_fast_move_mul->GetFloat();
        if(Keyboard->IsPressed(kbsLeftControl)) mult = d_spectator_slow_move_mul->GetFloat();


        if(Keyboard->IsPressed(kbsW)) FPS_Acceleration.Z = fSpeed;
        if(Keyboard->IsPressed(kbsS)) FPS_Acceleration.Z = -fSpeed * 0.7f;
        if(Keyboard->IsPressed(kbsA)) FPS_Acceleration.X = -fSpeed * 0.7f;
        if(Keyboard->IsPressed(kbsD)) FPS_Acceleration.X = fSpeed * 0.7f;
        if(Keyboard->IsPressed(kbsQ)) FPS_Position.Y    += SRV_WORLD_SCALE(1.0f)* r3dGetFrameTime() * mult;
        if(Keyboard->IsPressed(kbsE)) FPS_Position.Y    -= SRV_WORLD_SCALE(1.0f)* r3dGetFrameTime() * mult;


        if(Gamepad->IsConnected())
        {
            float RX, RY, TL, TR;
            Gamepad->GetLeftThumb(RX, RY);
            Gamepad->GetTrigger(TL, TR);


            FPS_Acceleration.Z = -RY*r_gamepad_move_speed->GetFloat();
            FPS_Acceleration.Z = RY*r_gamepad_move_speed->GetFloat();
            FPS_Acceleration.X = -RX*r_gamepad_move_speed->GetFloat();
            FPS_Acceleration.X = RX*r_gamepad_move_speed->GetFloat();
            FPS_Position.Y    += r3dGetFrameTime() * TR * r_gamepad_move_speed->GetFloat();
            FPS_Position.Y    -= r3dGetFrameTime() * TL * r_gamepad_move_speed->GetFloat();
        }


        FPS_Position += FPS_vVision * FPS_Acceleration.Z * r3dGetFrameTime() * mult;
        FPS_Position += FPS_vRight * FPS_Acceleration.X * r3dGetFrameTime() *mult;


        return;
    }
    [COLOR=#ff0000]}[/COLOR]
[COLOR=#ff0000]//#endif[/COLOR]
    ProcessPlayerMovement(pl, false);
}

need edit this

Original:

Code:
REG_VAR( d_mouse_window_lock,        false,            0 );        // should I restrict mouse at window client area?
#ifndef FINAL_BUILD
REG_VAR( d_show_muzzle,                0,                0 );

modified:

Code:
REG_VAR( d_mouse_window_lock,        false,            0 );        // should I restrict mouse at window client area?
//#ifndef FINAL_BUILD
REG_VAR( d_show_muzzle,                0,                0 );

and this

Original:
Code:
REG_VAR( d_allow_musictriggerarea,    0,            0);

#endif // FINAL BUILD

modified:

Code:
REG_VAR( d_allow_musictriggerarea,    0,            0);

//#endif // FINAL BUILD
put the // on this lines and fixed

Do not forget to thank me =)


Credits: Mateuus (Undead Brasil)
 
Last edited:
Master Summoner
Joined
Mar 30, 2013
Messages
543
Reaction score
72
Now if you're not a dev you can go in spectator mode :p
 
Newbie Spellweaver
Joined
May 2, 2013
Messages
96
Reaction score
141
Why not just use Studio?

Do people not know that you can enter server with Studio? It gives you access to some developer tools, and the console ..:ehh:
 
Newbie Spellweaver
Joined
May 17, 2013
Messages
39
Reaction score
3
Why not just use Studio?

Do people not know that you can enter server with Studio? It gives you access to some developer tools, and the console ..:ehh:

Many can not play with Studio .. It would be interesting to the customer have.! :)
PS: Only DEV. (gUserProfile.ProfileData.isDevAccount)
 
Newbie Spellweaver
Joined
Apr 15, 2013
Messages
51
Reaction score
1

Some errors happened to me ...

Can anyone help me?
Mateuus - [Tutorial]  how to enable Spectador mode - RaGEZONE Forums
 
Master Summoner
Joined
Mar 30, 2013
Messages
543
Reaction score
72
Why not just use Studio?

Do people not know that you can enter server with Studio? It gives you access to some developer tools, and the console ..:ehh:
How could I use the console?
 
Newbie Spellweaver
Joined
Sep 19, 2013
Messages
29
Reaction score
3
Spectate doesnt work for me I changed everything without errors I joined into my Server pressed F8 and F9 and nothing happens.
 
Master Summoner
Joined
May 8, 2013
Messages
574
Reaction score
571
need edit this

Original:

Code:
REG_VAR( d_mouse_window_lock,        false,            0 );        // should I restrict mouse at window client area?
#ifndef FINAL_BUILD
REG_VAR( d_show_muzzle,                0,                0 );

modified:

Code:
REG_VAR( d_mouse_window_lock,        false,            0 );        // should I restrict mouse at window client area?
//#ifndef FINAL_BUILD
REG_VAR( d_show_muzzle,                0,                0 );

and this

Original:
Code:
REG_VAR( d_allow_musictriggerarea,    0,            0);

#endif // FINAL BUILD

modified:

Code:
REG_VAR( d_allow_musictriggerarea,    0,            0);

//#endif // FINAL BUILD
put the // on this lines and fixed
 
Last edited:
Initiate Mage
Joined
Sep 14, 2013
Messages
2
Reaction score
0
Good evening, saddened for my bad English. It is in what file that it is necessary to modify these last one lines please? Thank you
 
Newbie Spellweaver
Joined
Apr 15, 2013
Messages
21
Reaction score
0
need edit this

Original:

Code:
REG_VAR( d_mouse_window_lock,        false,            0 );        // should I restrict mouse at window client area?
#ifndef FINAL_BUILD
REG_VAR( d_show_muzzle,                0,                0 );

modified:

Code:
REG_VAR( d_mouse_window_lock,        false,            0 );        // should I restrict mouse at window client area?
//#ifndef FINAL_BUILD
REG_VAR( d_show_muzzle,                0,                0 );

and this

Original:
Code:
REG_VAR( d_allow_musictriggerarea,    0,            0);

#endif // FINAL BUILD

modified:

Code:
REG_VAR( d_allow_musictriggerarea,    0,            0);

//#endif // FINAL BUILD
put the // on this lines and fixed

would be helpfull if you told us what file to edit this in to get spectator mode working,do you expect us to magically know which file?
 
Back
Top