2020-07-04 19:36:27 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
2020-07-04 19:50:16 +00:00
|
|
|
Copyright 2020 Christoph Oelckers
|
2020-07-04 19:36:27 +00:00
|
|
|
|
|
|
|
This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
|
|
|
|
|
|
|
|
Duke Nukem 3D is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Original Source: 1996 - Todd Replogle
|
|
|
|
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|
|
|
Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h"
|
|
|
|
|
|
|
|
#include "duke3d.h"
|
|
|
|
#include "mapinfo.h"
|
|
|
|
#include "cheathandler.h"
|
2020-07-14 12:00:27 +00:00
|
|
|
#include "c_dispatch.h"
|
2020-08-29 15:49:15 +00:00
|
|
|
#include "gamestate.h"
|
2021-02-16 10:36:08 +00:00
|
|
|
#include "gamefuncs.h"
|
2020-10-21 17:14:41 +00:00
|
|
|
#include "dukeactor.h"
|
2020-07-04 19:36:27 +00:00
|
|
|
|
|
|
|
BEGIN_DUKE_NS
|
|
|
|
|
2020-07-15 10:34:42 +00:00
|
|
|
int getlabelvalue(const char* text);
|
|
|
|
|
2020-07-04 19:36:27 +00:00
|
|
|
static int ccmd_spawn(CCmdFuncPtr parm)
|
|
|
|
{
|
2020-07-20 21:21:27 +00:00
|
|
|
int x = 0, y = 0, z = 0;
|
2021-12-18 19:41:15 +00:00
|
|
|
ESpriteFlags cstat = 0;
|
2021-11-14 11:25:25 +00:00
|
|
|
int picnum = 0;
|
2020-07-20 21:21:27 +00:00
|
|
|
unsigned int pal = 0;
|
|
|
|
int ang = 0;
|
2020-10-23 18:07:26 +00:00
|
|
|
int set = 0;
|
2020-07-20 21:21:27 +00:00
|
|
|
|
2020-09-03 21:10:28 +00:00
|
|
|
#if 0 // fixme - route through the network and this limitation becomes irrelevant
|
|
|
|
if (netgame || numplayers > 1 || !(ps[myconnectindex].gm & MODE_GAME)) {
|
2020-07-20 21:21:27 +00:00
|
|
|
Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
|
|
|
|
return CCMD_OK;
|
|
|
|
}
|
2020-09-03 21:10:28 +00:00
|
|
|
#endif
|
2020-07-20 21:21:27 +00:00
|
|
|
|
|
|
|
switch (parm->numparms) {
|
|
|
|
case 7: // x,y,z
|
|
|
|
x = atol(parm->parms[4]);
|
|
|
|
y = atol(parm->parms[5]);
|
|
|
|
z = atol(parm->parms[6]);
|
|
|
|
set |= 8;
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-07-20 21:21:27 +00:00
|
|
|
case 4: // ang
|
|
|
|
ang = atol(parm->parms[3]) & 2047; set |= 4;
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-07-20 21:21:27 +00:00
|
|
|
case 3: // cstat
|
2021-12-18 11:28:48 +00:00
|
|
|
cstat = ESpriteFlags::FromInt(atol(parm->parms[2])); set |= 2;
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-07-20 21:21:27 +00:00
|
|
|
case 2: // pal
|
2021-11-07 11:43:00 +00:00
|
|
|
pal = (uint8_t)atol(parm->parms[1]); set |= 1;
|
2021-11-14 11:25:25 +00:00
|
|
|
[[fallthrough]];
|
2020-07-20 21:21:27 +00:00
|
|
|
case 1: // tile number
|
|
|
|
if (isdigit(parm->parms[0][0])) {
|
|
|
|
picnum = (unsigned short)atol(parm->parms[0]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
picnum = getlabelvalue(parm->parms[0]);
|
|
|
|
if (picnum < 0) {
|
|
|
|
Printf("spawn: Invalid tile label given\n");
|
|
|
|
return CCMD_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (picnum >= MAXTILES) {
|
|
|
|
Printf("spawn: Invalid tile number\n");
|
|
|
|
return CCMD_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return CCMD_SHOWHELP;
|
|
|
|
}
|
|
|
|
|
2020-10-23 18:07:26 +00:00
|
|
|
auto spawned = spawn(ps[myconnectindex].GetActor(), picnum);
|
2021-11-19 11:32:12 +00:00
|
|
|
if (spawned)
|
|
|
|
{
|
2021-12-21 17:19:45 +00:00
|
|
|
if (set & 1) spawned->spr.pal = (uint8_t)pal;
|
|
|
|
if (set & 2) spawned->spr.cstat = ESpriteFlags::FromInt(cstat);
|
2022-08-16 21:20:35 +00:00
|
|
|
if (set & 4) spawned->set_int_ang(ang);
|
2022-02-05 09:16:50 +00:00
|
|
|
if (set & 8) SetActor(spawned, DVector3( x, y, z ));
|
2021-12-07 22:27:12 +00:00
|
|
|
|
|
|
|
if (spawned->sector() == nullptr)
|
|
|
|
{
|
|
|
|
Printf("spawn: Sprite can't be spawned into null space\n");
|
|
|
|
deletesprite(spawned);
|
|
|
|
}
|
2020-07-20 21:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return CCMD_OK;
|
2020-07-04 19:36:27 +00:00
|
|
|
}
|
|
|
|
|
2020-11-29 11:23:31 +00:00
|
|
|
void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz)
|
2020-08-04 08:03:47 +00:00
|
|
|
{
|
|
|
|
player_struct* p = &ps[myconnectindex];
|
|
|
|
|
2022-02-05 12:40:30 +00:00
|
|
|
p->pos = DVector3(x, y, z);
|
2022-02-05 11:05:29 +00:00
|
|
|
p->backupxyz();
|
2020-08-04 12:33:17 +00:00
|
|
|
|
2021-11-09 23:05:42 +00:00
|
|
|
if (ang != INT_MIN)
|
|
|
|
{
|
2022-08-27 13:09:22 +00:00
|
|
|
p->angle.oang = p->angle.ang = DAngle::fromBuild(ang);
|
2021-11-09 23:05:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (horz != INT_MIN)
|
|
|
|
{
|
|
|
|
p->horizon.ohoriz = p->horizon.horiz = buildhoriz(horz);
|
|
|
|
}
|
2020-08-04 08:03:47 +00:00
|
|
|
}
|
|
|
|
|
2020-11-29 11:23:31 +00:00
|
|
|
void GameInterface::ToggleThirdPerson()
|
2020-08-29 15:49:15 +00:00
|
|
|
{
|
2020-11-29 11:23:31 +00:00
|
|
|
if (gamestate != GS_LEVEL) return;
|
2020-08-29 15:49:15 +00:00
|
|
|
if (!isRRRA() || (!ps[myconnectindex].OnMotorcycle && !ps[myconnectindex].OnBoat))
|
|
|
|
{
|
|
|
|
if (ps[myconnectindex].over_shoulder_on)
|
|
|
|
ps[myconnectindex].over_shoulder_on = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ps[myconnectindex].over_shoulder_on = 1;
|
|
|
|
cameradist = 0;
|
2020-08-31 17:27:22 +00:00
|
|
|
cameraclock = INT_MIN;
|
2020-08-29 15:49:15 +00:00
|
|
|
}
|
|
|
|
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-29 11:23:31 +00:00
|
|
|
void GameInterface::SwitchCoopView()
|
2020-08-29 15:49:15 +00:00
|
|
|
{
|
2020-11-29 11:23:31 +00:00
|
|
|
if (gamestate != GS_LEVEL) return;
|
2020-08-29 15:49:15 +00:00
|
|
|
if (ud.coop || ud.recstat == 2)
|
|
|
|
{
|
|
|
|
screenpeek = connectpoint2[screenpeek];
|
|
|
|
if (screenpeek == -1) screenpeek = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-29 11:23:31 +00:00
|
|
|
void GameInterface::ToggleShowWeapon()
|
2020-08-29 15:49:15 +00:00
|
|
|
{
|
2020-11-29 11:23:31 +00:00
|
|
|
if (gamestate != GS_LEVEL) return;
|
|
|
|
cl_showweapon = cl_showweapon == 0;
|
|
|
|
FTA(QUOTE_WEAPON_MODE_OFF - cl_showweapon, &ps[screenpeek]);
|
2020-08-29 15:49:15 +00:00
|
|
|
}
|
2020-07-04 19:36:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
int registerosdcommands(void)
|
|
|
|
{
|
2020-07-20 21:21:27 +00:00
|
|
|
C_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn);
|
|
|
|
return 0;
|
2020-07-04 19:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_DUKE_NS
|