2019-09-19 22:42:45 +00:00
//-------------------------------------------------------------------------
/*
Copyright ( C ) 2010 - 2019 EDuke32 developers and contributors
Copyright ( C ) 2019 Nuke . YKT
2020-01-28 03:29:47 +00:00
Copyright ( C ) 2020 Raze developers and contributors
2019-09-19 22:42:45 +00:00
2020-01-28 03:29:47 +00:00
This file was part of NBlood .
2019-09-19 22:42:45 +00:00
NBlood is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*/
//-------------------------------------------------------------------------
2019-09-21 18:59:54 +00:00
# include "ns.h" // Must come before everything else!
2019-09-19 22:42:45 +00:00
# include "build.h"
# include "compat.h"
# include "mmulti.h"
# include "common_game.h"
# include "blood.h"
2019-06-27 04:33:22 +00:00
# include "globals.h"
2019-09-19 22:42:45 +00:00
# include "levels.h"
# include "messages.h"
# include "sound.h"
# include "view.h"
2020-01-25 19:21:49 +00:00
# include "mapinfo.h"
2020-07-29 21:18:08 +00:00
# include "gamestate.h"
2019-09-19 22:42:45 +00:00
2019-09-22 06:39:22 +00:00
BEGIN_BLD_NS
2019-09-19 22:42:45 +00:00
2020-07-11 13:05:49 +00:00
static int osdcmd_warptocoords ( CCmdFuncPtr parm )
{
2020-08-04 12:33:17 +00:00
if ( parm - > numparms < 3 | | parm - > numparms > 5 )
2020-07-11 13:05:49 +00:00
return CCMD_SHOWHELP ;
PLAYER * pPlayer = & gPlayer [ myconnectindex ] ;
pPlayer - > pSprite - > x = gView - > pSprite - > x = atoi ( parm - > parms [ 0 ] ) ;
pPlayer - > pSprite - > y = gView - > pSprite - > y = atoi ( parm - > parms [ 1 ] ) ;
pPlayer - > zView = gView - > zView = atoi ( parm - > parms [ 2 ] ) ;
2020-08-04 12:33:17 +00:00
2020-08-04 13:13:22 +00:00
if ( parm - > numparms > = 4 )
2020-08-04 12:33:17 +00:00
{
2020-10-07 20:55:54 +00:00
pPlayer - > angle . oang = gView - > angle . ang = buildang ( atoi ( parm - > parms [ 3 ] ) ) ;
2020-08-04 12:33:17 +00:00
}
if ( parm - > numparms = = 5 )
{
2020-10-07 06:16:58 +00:00
pPlayer - > horizon . horiz = gView - > horizon . horiz = buildhoriz ( atoi ( parm - > parms [ 4 ] ) ) ;
2020-08-04 12:33:17 +00:00
}
2020-07-11 13:05:49 +00:00
viewBackupView ( pPlayer - > nPlayer ) ;
return CCMD_OK ;
}
2020-08-29 15:49:15 +00:00
static int osdcmd_third_person_view ( CCmdFuncPtr parm )
{
if ( gamestate ! = GS_LEVEL | | System_WantGuiCapture ( ) ) return CCMD_OK ;
if ( gViewPos > VIEWPOS_0 )
gViewPos = VIEWPOS_0 ;
else
gViewPos = VIEWPOS_1 ;
return CCMD_OK ;
}
static int osdcmd_coop_view ( CCmdFuncPtr parm )
{
if ( gamestate ! = GS_LEVEL | | System_WantGuiCapture ( ) ) return CCMD_OK ;
if ( gGameOptions . nGameType = = 1 )
{
gViewIndex = connectpoint2 [ gViewIndex ] ;
if ( gViewIndex = = - 1 )
gViewIndex = connecthead ;
gView = & gPlayer [ gViewIndex ] ;
}
else if ( gGameOptions . nGameType = = 3 )
{
int oldViewIndex = gViewIndex ;
do
{
gViewIndex = connectpoint2 [ gViewIndex ] ;
if ( gViewIndex = = - 1 )
gViewIndex = connecthead ;
if ( oldViewIndex = = gViewIndex | | gMe - > teamId = = gPlayer [ gViewIndex ] . teamId )
break ;
} while ( oldViewIndex ! = gViewIndex ) ;
gView = & gPlayer [ gViewIndex ] ;
}
return CCMD_OK ;
}
static int osdcmd_show_weapon ( CCmdFuncPtr parm )
{
if ( gamestate ! = GS_LEVEL | | System_WantGuiCapture ( ) ) return CCMD_OK ;
cl_showweapon = ( cl_showweapon + 1 ) & 3 ;
return CCMD_OK ;
}
2019-09-19 22:42:45 +00:00
int32_t registerosdcommands ( void )
{
2020-08-04 12:33:17 +00:00
C_RegisterFunction ( " warptocoords " , " warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates " , osdcmd_warptocoords ) ;
2020-08-29 15:49:15 +00:00
C_RegisterFunction ( " third_person_view " , " Switch to third person view " , osdcmd_third_person_view ) ;
C_RegisterFunction ( " coop_view " , " Switch player to view from in coop " , osdcmd_coop_view ) ;
C_RegisterFunction ( " show_weapon " , " Show opponents' weapons " , osdcmd_show_weapon ) ;
2020-07-11 13:05:49 +00:00
2019-09-19 22:42:45 +00:00
return 0 ;
}
2019-09-22 06:39:22 +00:00
END_BLD_NS