- fixed game Makefile

- added basic cinematic camera mode (needs much more work until it is finished)
This commit is contained in:
UberGames 2011-06-09 00:16:25 +02:00
parent a1b782613a
commit eb2bd43add
22 changed files with 258 additions and 33 deletions

View file

@ -73,7 +73,7 @@ SOOBJ = \
cg_syscalls.o
# do cc for shared library
DO_SOCC = $(CC) $(SOCFLAGS) -o $@ -c $<
DO_SOCC = $(CC) $(SOCFLAGS) -Wall -o $@ -c $<
build_so: DO_CC=$(DO_SOCC)

View file

@ -1061,5 +1061,9 @@ void CG_InitConsoleCommands( void ) {
#ifdef CG_LUA
trap_AddCommand("lua_status");
#endif
// CCAM
trap_AddCommand("camtest");
trap_AddCommand("camtestend");
}

View file

@ -4827,6 +4827,10 @@ static void CG_Draw2D( void ) {
return;
}
if ( cg.snap->ps.pm_type == PM_CCAM ) {
return;
}
if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
#ifndef FINAL_BUILD
CG_DrawUpperRight();

View file

@ -1347,7 +1347,7 @@ static int CG_CalcViewValues( void ) {
}
}
if ( cg.renderingThirdPerson ) {
if ( cg.renderingThirdPerson && ps->pm_type != PM_CCAM ) {
// back away from character
CG_OffsetThirdPersonView();
} else {

BIN
game/-Wall Normal file

Binary file not shown.

View file

@ -56,6 +56,7 @@ OBJ = \
g_bot.o \
g_arenas.o \
g_active.o \
g_cinematic.o \
bg_slidemove.o \
bg_pmove.o \
bg_oums.o \
@ -70,7 +71,8 @@ OBJ = \
lua_entity.o \
lua_vector.o \
lua_mover.o \
lua_qmath.o
lua_qmath.o \
lua_cinematic.o
# game object for syscalls to the engine
SOOBJ = \
@ -114,9 +116,9 @@ LUAOBJ = \
lzio.o
# do cc for shared library
DO_SOCC = $(CC) $(SOCFLAGS) -o $@ -c $<
DO_SOCC = $(CC) $(SOCFLAGS) -Wall -o $@ -c $<
# do cc for lua
DO_LUACC = $(CC) -O2 -Wall -fPIC -DLUA_COMPAT_ALL -o $@ -c $<
DO_LUACC = $(CC) -O2 -Wall $(SOCFLAGS) -DLUA_COMPAT_ALL -o $@ -c $<
build_so: DO_CC=$(DO_SOCC)
@ -160,12 +162,14 @@ q_shared.o : q_shared.c; $(DO_CC)
g_lua.o: g_lua.c; $(DO_CC)
g_ui.o: g_ui.c; $(DO_CC)
g_sql.o: g_sql.c; $(DO_CC)
g_cinematic.o: g_cinematic.c; $(DO_CC)
bg_oums.o : bg_oums.c; $(DO_CC)
lua_game.o: lua_game.c; $(DO_CC)
lua_entity.o: lua_entity.c; $(DO_CC)
lua_mover.o: lua_mover.c; $(DO_CC)
lua_qmath.o: lua_qmath.c; $(DO_CC)
lua_vector.o: lua_vector.c; $(DO_CC)
lua_cinematic.o: lua_cinematic.c; $(DO_CC)
# game syscalls
g_syscalls.o : g_syscalls.c; $(DO_CC)

View file

@ -3478,6 +3478,10 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) {
return; // no view changes at all
}
if ( ps->pm_type == PM_CCAM) {
return;
}
if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 1 ) { //RPG-X: RedTechie - This use to be 0 but in rpg-x with or without medics revive 1 health means you die!
return; // no view changes at all
}
@ -3554,6 +3558,7 @@ void PmoveSingle (pmove_t *pmove) {
// set the firing flag for continuous beam weapons
if ( !(ps->pm_flags & PMF_RESPAWNED) &&
ps->pm_type != PM_INTERMISSION &&
ps->pm_type != PM_CCAM &&
( (pm->cmd.buttons & BUTTON_ATTACK) || (pm->cmd.buttons & BUTTON_ALT_ATTACK) ) &&
(ps->ammo[ ps->weapon ] || ps->weapon == WP_PHASER))
{
@ -3712,26 +3717,10 @@ void PmoveSingle (pmove_t *pmove) {
if ( ps->pm_type == PM_SPECTATOR )
{
//spectator or an eliminated player
//RPG-X J2J - NoClip Spectation:
//Change to allow noclip in spectator if enabled on server
//And if the client wants to noclip
/*if(rpg_noclipspectating.integer == 1 && ClientNCSpec == qtrue)
{
PM_NoclipMove();
PM_DropTimers ();
return;
}*/
//Else allow flight.
//else
{
PM_CheckDuck ();
PM_FlyMove();
PM_DropTimers ();
return;
}
////////////////////////////////
PM_CheckDuck ();
PM_FlyMove();
PM_DropTimers ();
return;
}
if ( ps->pm_type == PM_NOCLIP ) {
@ -3740,6 +3729,10 @@ void PmoveSingle (pmove_t *pmove) {
return;
}
if ( ps->pm_type == PM_CCAM) {
return;
}
if ( ps->pm_type == PM_INTERMISSION ) {
return; // no movement at all
}

View file

@ -258,7 +258,8 @@ typedef enum {
PM_SPECTATOR, //!< still run into walls
PM_DEAD, //!< no acceleration or turning, but free falling
PM_FREEZE, //!< stuck in place with no control
PM_INTERMISSION //!< no movement or status bar
PM_INTERMISSION,//!< no movement or status bar
PM_CCAM //!< cinematic cam mode
} pmtype_t;
/** \enum weaponstate_t

View file

@ -2661,6 +2661,13 @@ void SendPendingPredictableEvents( playerState_t *ps ) {
}
}
void ClientCamThink(gentity_t *client) {
if(!client->client->cam) return;
G_SetOrigin(client, client->client->cam->s.origin);
SetClientViewAngle(client, client->client->cam->s.angles);
trap_LinkEntity(client);
}
/*
==============
ClientThink
@ -2720,6 +2727,11 @@ void ClientThink_real( gentity_t *ent ) {
return;
}
if (ent->flags & FL_CCAM) {
ClientCamThink( ent );
return;
}
// Don't move while under intro sequence.
/*if (ps->introTime > level.time)
{ // Don't be visible either.

62
game/g_cinematic.c Normal file
View file

@ -0,0 +1,62 @@
#include "g_local.h"
#include "g_cinematic.h"
extern void InitMover( gentity_t *ent );
/*QUAKED cinematic_camera (0 0.5 0) (-4 -4 -4) (4 4 4)
Camera for cinematic. Normally spawn by Lua script.
*/
void SP_cinematic_camera(gentity_t *ent) {
trap_LinkEntity(ent);
InitMover(ent);
}
void Cinematic_ActivateCameraMode(gentity_t *ent, gentity_t *target) {
gclient_t *client;
if(!ent || !ent->client || (ent->flags & FL_CCAM)) return;
client = ent->client;
ent->flags ^= FL_CCAM;
client->ps.pm_type = PM_CCAM;
client->cam = target;
VectorCopy(client->ps.viewangles, client->origViewAngles);
VectorCopy(ent->r.currentOrigin, client->origOrigin);
SetClientViewAngle(ent, target->s.angles);
G_SetOrigin(ent, target->r.currentOrigin);
trap_LinkEntity(ent);
}
void Cinematic_DeactivateCameraMode(gentity_t *ent) {
gclient_t *client;
if(!ent || !ent->client || !(ent->flags & FL_CCAM)) return;
client = ent->client;
ent->flags ^= FL_CCAM;
G_SetOrigin(ent, client->origOrigin);
SetClientViewAngle(ent, client->origViewAngles);
trap_LinkEntity(ent);
}
void Cinematic_ActivateGlobalCameraMode(gentity_t *target) {
int i;
gentity_t *ent;
for(i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if(!ent || !ent->client) continue;
Cinematic_ActivateCameraMode(ent, target);
}
}
void Cinematic_DeactivateGlobalCameraMode(void) {
int i;
gentity_t *ent;
for(i = 0; i < g_maxclients.integer; i++) {
ent = g_entities + i;
if(!ent || !ent->client) continue;
Cinematic_DeactivateCameraMode(ent);
}
}

2
game/g_cinematic.cpp Normal file
View file

@ -0,0 +1,2 @@
#include "g_cinematic.h"

10
game/g_cinematic.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef _G_CIN_H_
#define _G_CIN_H_
#include "g_local.h"
void Cinematic_ActivateCameraMode(gentity_t *ent, gentity_t *target);
void Cinematic_DeactivateCameraMode(gentity_t *ent);
void Cinematic_ActivateGlobalCameraMode(gentity_t *target);
void Cinematic_DeactivateGlobalCameraMode(void);
#endif //_G_CIN_H_

View file

@ -9914,6 +9914,32 @@ static void Cmd_findEntitiesInRadius(gentity_t *ent) {
}
}
// CCAM
extern void Cinematic_ActivateCameraMode(gentity_t *ent, gentity_t *target);
extern void Cinematic_DeactivateCameraMode(gentity_t *ent);
void Cmd_Camtest_f(gentity_t *ent) {
gentity_t *targ;
char tname[256];
if(trap_Argc() < 1) return;
G_Printf("activate cam\n");
if(ent->flags & FL_CCAM) return;
trap_Argv(1, tname, sizeof(tname));
targ = G_Find(NULL, FOFS(targetname), tname);
if(!targ) return;
Cinematic_ActivateCameraMode(ent, targ);
}
void Cmd_CamtestEnd_f(gentity_t *ent) {
Cinematic_DeactivateCameraMode(ent);
}
// END CCAM
/*
=================
ClientCommand
@ -10168,6 +10194,12 @@ void ClientCommand( int clientNum )
else if (Q_stricmp(cmd, "userDel") == 0)
Cmd_SqlUserDel_f(ent);
#endif
// CCAM
else if (Q_stricmp(cmd, "camtest") == 0)
Cmd_Camtest_f(ent);
else if (Q_stricmp(cmd, "camtestend") == 0)
Cmd_CamtestEnd_f(ent);
// END CCAM
else if (Q_strncmp (cmd, "\n", 1) == 0 || Q_strncmp (cmd, " ", 1) == 0 || Q_strncmp (cmd, "\0", 1) == 0) // sorry
(void)(0);
else

View file

@ -1,6 +1,8 @@
// Copyright (C) 1999-2000 Id Software, Inc.
//
// g_local.h -- local definitions for game module
#ifndef _G_LOCAL_H_
#define _G_LOCAL_H_
#include "q_shared.h"
#include "bg_public.h"
@ -41,6 +43,8 @@
#define FL_CLAMPED 0x01000000 //RPG-X | TiM | 25/6/2006
#define FL_THROWN_ITEM 0x02000000 //RPG-X | Marcin | 03/12/2008
#define FL_LOCKED 0x04000000 //RPG-X | GSIO01 | 08/05/2009
// CCAM
#define FL_CCAM 0x08000000
//RPG-X Defines ==============================
@ -602,6 +606,11 @@ struct gclient_s {
int uid; //!< uiser id of the player in the sql database
byte sqlkey; //!< random key used to make transmission of the username and password from the ui at least a bit safer
#endif
// CCAM
vec3_t origViewAngles;
vec3_t origOrigin;
gentity_t *cam;
};
@ -2047,3 +2056,4 @@ struct luaAlertState_s {
luaAlertState_t *luaAlertState;
#endif //_G_LOCAL_H_

View file

@ -271,6 +271,7 @@ qboolean G_LuaStartVM(lvm_t * vm)
Luaopen_Mover(vm->L);
Luaopen_Vector(vm->L);
Luaopen_Entity(vm->L);
Luaopen_Cinematic(vm->L);
res = luaL_loadbuffer(vm->L, vm->code, vm->code_size, vm->filename);
if(res == LUA_ERRSYNTAX)

View file

@ -49,7 +49,7 @@ void G_LuaShutdown(void);
void G_LuaStatus(gentity_t *ent);
lvm_t *G_LuaGetVM(lua_State *L);
// lua/entity.c
// lua_entity.c
typedef struct {
gentity_t *e;
} lent_t;
@ -58,19 +58,23 @@ int Luaopen_Entity(lua_State *L);
void Lua_PushEntity(lua_State *L, gentity_t *ent);
lent_t *Lua_GetEntity(lua_State *L, int argNum);
// lua/game.c
// lua_game.c
int Luaopen_Game(lua_State *L);
// lua/qmath.c
// lua_qmath.c
int Luaopen_Qmath(lua_State *L);
// lua/vector.c
// lua_vector.c
int Luaopen_Vector(lua_State *L);
void Lua_PushVector(lua_State *L, vec3_t v);
vec_t *Lua_GetVector(lua_State *L, int argNum);
int Lua_IsVector(lua_State *L, int index);
vec3_t *Lua_GetVectorMisc(lua_State *L, int *index);
// lua/mover.c
// lua_mover.c
int Luaopen_Mover(lua_State *L);
// lua_cinematic.c
int Luaopen_Cinematic(lua_State *L);
#endif

View file

@ -238,6 +238,9 @@ void SP_path_point(gentity_t *ent);
void SP_ui_transporter(gentity_t *ent);
void SP_ui_holodeck(gentity_t *ent);
// cinematic entities
void SP_cinematic_camera(gentity_t *ent);
spawn_t spawns[] = {
// info entities don't do anything at all, but provide positional
@ -415,6 +418,9 @@ spawn_t spawns[] = {
{"ref_tag", SP_info_notnull},
// cinematic entities
{"cinematic_camera", SP_cinematic_camera},
{0, 0}
};

View file

@ -227,6 +227,7 @@
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">WIN32;NDEBUG;_WINDOWS</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="g_cinematic.c" />
<ClCompile Include="lapi.c" />
<ClCompile Include="lauxlib.c" />
<ClCompile Include="lbaselib.c" />
@ -258,6 +259,7 @@
<ClCompile Include="ltm.c" />
<ClCompile Include="lua.c" />
<ClCompile Include="luac.c" />
<ClCompile Include="lua_cinematic.c" />
<ClCompile Include="lua_game.c" />
<ClCompile Include="lua_entity.c" />
<ClCompile Include="g_active.c">
@ -487,6 +489,7 @@
<ClInclude Include="botlib.h" />
<ClInclude Include="chars.h" />
<ClInclude Include="g_breakable.h" />
<ClInclude Include="g_cinematic.h" />
<ClInclude Include="g_groups.h" />
<ClInclude Include="g_local.h" />
<ClInclude Include="g_lua.h" />
@ -543,6 +546,13 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</CustomBuildStep>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View file

@ -258,6 +258,12 @@
<ClCompile Include="luac.c">
<Filter>Source Files\lua</Filter>
</ClCompile>
<ClCompile Include="g_cinematic.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lua_cinematic.c">
<Filter>Source Files\lua</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ai_chat.h">
@ -431,6 +437,9 @@
<ClInclude Include="lzio.h">
<Filter>Source Files\lua</Filter>
</ClInclude>
<ClInclude Include="g_cinematic.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="game.def">

62
game/lua_cinematic.c Normal file
View file

@ -0,0 +1,62 @@
// cinematic lib for lua
#include "g_lua.h"
#include "g_cinematic.h"
#ifdef G_LUA
static int Cinematic_Activate(lua_State *L) {
lent_t *ent;
lent_t *target;
ent = Lua_GetEntity(L, 1);
if(!ent) return 0;
target = Lua_GetEntity(L, 2);
if(!target) return 0;
Cinematic_ActivateCameraMode(ent->e, target->e);
return 0;
}
static int Cinematic_Deactivate(lua_State *L) {
lent_t *ent;
ent = Lua_GetEntity(L, 1);
if(!ent) return 0;
Cinematic_DeactivateCameraMode(ent->e);
return 0;
}
static int Cinematic_ActivateGlobal(lua_State *L) {
lent_t *target;
target = Lua_GetEntity(L, 2);
if(!target) return 0;
Cinematic_ActivateGlobalCameraMode(target->e);
return 0;
}
static int Cinematic_DeactivateGlobal(lua_State *L) {
Cinematic_DeactivateGlobalCameraMode();
return 0;
}
static const luaL_Reg lib_cinematic[] = {
{"Activate", Cinematic_Activate},
{"Deactivate", Cinematic_Deactivate},
{"ActivateGlobal", Cinematic_ActivateGlobal},
{"DeactivateGlobal", Cinematic_DeactivateGlobal},
{NULL, NULL}
};
int Luaopen_Cinematic(lua_State *L) {
luaL_register(L, "cinematic", lib_cinematic);
return 1;
}
#endif //G_LUA

View file

@ -16,8 +16,7 @@
//#define MISSION_PACK //TiM: was commented out
#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(disable : 4018) // signed/unsigned mismatch
#pragma warning(disable : 4032)
#pragma warning(disable : 4051)

Binary file not shown.