Added custom animations array and re-enabled target_animation entity in default Lazarus DLL.

Added support for custom client railgun colors in default Lazarus DLL.
Removed sk_rail_color_* cvars from default Lazarus DLL.
This commit is contained in:
Knightmare66 2021-10-28 21:39:19 -04:00
parent b573e7da75
commit b4fe9c809e
17 changed files with 1116 additions and 54 deletions

View file

@ -759,6 +759,7 @@ extern void G_TouchTriggers ( edict_t * ent ) ;
extern void G_FreeEdict ( edict_t * ed ) ;
extern edict_t * G_Spawn ( void ) ;
extern void G_InitEdict ( edict_t * e ) ;
extern mmove_t * G_NewCustomAnim ( void ) ;
extern char * G_CopyString ( char * in ) ;
extern void vectoangles2 ( vec3_t value1 , vec3_t angles ) ;
extern void vectoangles ( vec3_t value1 , vec3_t angles ) ;

View file

@ -759,6 +759,7 @@
{"G_FreeEdict", (byte *)G_FreeEdict},
{"G_Spawn", (byte *)G_Spawn},
{"G_InitEdict", (byte *)G_InitEdict},
{"G_NewCustomAnim", (byte *)G_NewCustomAnim},
{"G_CopyString", (byte *)G_CopyString},
{"vectoangles2", (byte *)vectoangles2},
{"vectoangles", (byte *)vectoangles},

View file

@ -472,6 +472,7 @@ typedef struct
int freezeframes;
int next_skill;
int num_reflectors;
int num_custom_anims; // Knightmare- custom anim counter
qboolean intermission_letterbox; // Knightmare- letterboxing
// Knightmare- for map-specific logic switching
@ -1166,6 +1167,11 @@ void Hud_Off();
void ServerCommand (void);
qboolean SV_FilterPacket (char *from);
//
// g_target.c
//
extern mmove_t g_custom_anims[MAX_CUSTOM_ANIMS];
//
// g_thing.c
//
@ -1202,6 +1208,7 @@ edict_t *findradius (edict_t *from, vec3_t org, float rad);
edict_t *G_PickTarget (char *targetname);
void G_UseTargets (edict_t *ent, edict_t *activator);
void G_SetMovedir (vec3_t angles, vec3_t movedir);
mmove_t *G_NewCustomAnim (void); // Knightmare- util func for custom anims
void G_InitEdict (edict_t *e);
edict_t *G_Spawn (void);
void G_FreeEdict (edict_t *e);
@ -1452,8 +1459,8 @@ typedef struct
gitem_t *newweapon;
// Custom client colors
// color_t color1;
// color_t color2;
color_t color1;
color_t color2;
} client_persistant_t;
// client data that stays across deathmatch respawns
@ -1932,7 +1939,7 @@ struct edict_s
vec3_t movewith_offset;
vec3_t parent_attach_angles;
vec3_t child_attach_angles; // Knightmare added
// vec3_t aim_point; // Knightmare- safe aim vector for gunner grenades
vec3_t aim_point; // Knightmare- safe aim vector for gunner grenades
qboolean do_not_rotate;
// monster AI

View file

@ -300,4 +300,4 @@ extern mmove_t actor_move_walk_back ;
extern mmove_t actor_move_run ;
extern mmove_t actor_move_walk ;
extern mmove_t actor_move_stand ;
extern mmove_t mmove_reloc ;
extern mmove_t g_custom_anims[1024] ;

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define Function(f) {#f, f}
#ifndef SAVEGAME_USE_FUNCTION_TABLE
mmove_t mmove_reloc;
#endif
field_t fields[] = {
{"classname", FOFS(classname), F_LSTRING},
@ -213,7 +215,8 @@ field_t fields[] = {
{"org_size", FOFS(org_size), F_VECTOR},
{"owner_id", FOFS(owner_id), F_INT},
{"parent_attach_angles", FOFS(parent_attach_angles), F_VECTOR},
{"child_attach_angles", FOFS(child_attach_angles), F_VECTOR}, // Knightmare added
{"child_attach_angles", FOFS(child_attach_angles), F_VECTOR},
{"aim_point", FOFS(aim_point), F_VECTOR},
{"pitch_speed", FOFS(pitch_speed), F_FLOAT},
{"powerarmor", FOFS(powerarmor), F_INT},
{"powerarmortype", FOFS(powerarmortype), F_INT},
@ -1070,8 +1073,8 @@ All pointer variables (except function pointers) must be handled specially.
*/
void WriteLevelLocals (FILE *f)
{
field_t *field;
level_locals_t temp;
field_t *field;
level_locals_t temp;
// all of the ints, floats, and vectors stay as they are
temp = level;
@ -1166,6 +1169,14 @@ void WriteLevel (char *filename)
// write out level_locals_t
WriteLevelLocals (f);
// Knightmare added
// write out custom animations
for (i=0; i<MAX_CUSTOM_ANIMS; i++)
{
fwrite (&g_custom_anims[i], sizeof(g_custom_anims[i]), 1, f);
}
// end Knightmare
// write out all the entities
for (i=0; i<globals.num_edicts; i++)
{
@ -1255,6 +1266,14 @@ void ReadLevel (char *filename)
// load the level locals
ReadLevelLocals (f);
// Knightmare added
// load custom animations
for (i=0; i<MAX_CUSTOM_ANIMS; i++)
{
fread (&g_custom_anims[i], sizeof(g_custom_anims[i]), 1, f);
}
// end Knightmare
// load all the entities
while (1)
{

View file

@ -1189,6 +1189,7 @@ void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
gi.FreeTags (TAG_LEVEL);
memset (&level, 0, sizeof(level));
memset (g_custom_anims, 0, sizeof(g_custom_anims)); // Knightmare- wipe custom animations
memset (g_edicts, 0, game.maxentities * sizeof (g_edicts[0]));
// Lazarus: these are used to track model and sound indices
// in g_main.c:

View file

@ -3572,6 +3572,9 @@ void SP_target_monitor (edict_t *self)
"message" - specifies allowable classname to animate. This prevents
animating entities with inapplicable frame numbers
=====================================================================================*/
mmove_t g_custom_anims[MAX_CUSTOM_ANIMS]; // array of custom anins, saved to level file
void target_animate (edict_t *ent)
{
if ( (ent->s.frame < ent->monsterinfo.currentmove->firstframe) ||
@ -3649,7 +3652,7 @@ void target_animation_use (edict_t *self, edict_t *other, edict_t *activator)
void SP_target_animation (edict_t *self)
{
#if 1
#if 0
gi.dprintf("Target_animation is currently not implemented.\n");
G_FreeEdict(self);
return;
@ -3660,10 +3663,11 @@ void SP_target_animation (edict_t *self)
if (!self->target && !(self->spawnflags & 1))
{
gi.dprintf("target_animation w/o a target at %s\n",vtos(self->s.origin));
gi.dprintf("target_animation w/o a target at %s\n", vtos(self->s.origin));
G_FreeEdict(self);
return; // Knightmare- exit function after this!
}
switch (self->sounds)
{
case 1:
@ -3700,8 +3704,16 @@ void SP_target_animation (edict_t *self)
if (!self->framenumbers)
self->framenumbers = 1;
}
self->use = target_animation_use;
move = gi.TagMalloc(sizeof(mmove_t), TAG_LEVEL);
// move = gi.TagMalloc(sizeof(mmove_t), TAG_LEVEL);
move = G_NewCustomAnim();
if (!move) {
gi.dprintf("target_animation: no more custom anims available!\n");
G_FreeEdict(self);
return;
}
self->monsterinfo.currentmove = move;
#endif
}

View file

@ -487,6 +487,22 @@ char *G_CopyString (char *in)
return out;
}
// Knightmare added
mmove_t *G_NewCustomAnim (void)
{
int idx = 0;
if (level.num_custom_anims < MAX_CUSTOM_ANIMS) {
idx = level.num_custom_anims;
level.num_custom_anims++;
return &g_custom_anims[idx];
}
else {
// gi.dprintf ("G_NewCustomAnimIndex: no more custom anims available!\n");
return NULL;
}
}
// end Knightmare
void G_InitEdict (edict_t *e)
{

View file

@ -1286,8 +1286,6 @@ void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick
#ifdef KMQUAKE2_ENGINE_MOD
if (useColor)
tempevent = TE_RAILTRAIL_COLORED;
// else if ( self->client && (sk_rail_color->value == 2) )
// tempevent = TE_RAILTRAIL2;
else
#endif
tempevent = TE_RAILTRAIL;

View file

@ -90,10 +90,6 @@ cvar_t *sk_hyperblaster_color; //hyperblaster color- 1=yellow, 2=green, 3=blue,
cvar_t *sk_railgun_damage;
cvar_t *sk_railgun_damage_dm;
cvar_t *sk_railgun_skin;
cvar_t *sk_rail_color;
cvar_t *sk_rail_color_red;
cvar_t *sk_rail_color_green;
cvar_t *sk_rail_color_blue;
cvar_t *sk_bfg_damage;
cvar_t *sk_bfg_damage_dm;
@ -275,10 +271,6 @@ void InitLithiumVars (void)
sk_railgun_damage = gi.cvar("sk_railgun_damage", "150", 0);
sk_railgun_damage_dm = gi.cvar("sk_railgun_damage_dm", "100", 0);
sk_railgun_skin = gi.cvar("sk_railgun_skin", "0", 0);
sk_rail_color = gi.cvar("sk_rail_color", "1", 0);
sk_rail_color_red = gi.cvar("sk_rail_color_red", "255", 0);
sk_rail_color_green = gi.cvar("sk_rail_color_green", "20", 0);
sk_rail_color_blue = gi.cvar("sk_rail_color_blue", "20", 0);
sk_bfg_damage = gi.cvar("sk_bfg_damage", "500", 0);
sk_bfg_damage_dm = gi.cvar("sk_bfg_damage_dm", "200", 0);

View file

@ -87,10 +87,6 @@ extern cvar_t *sk_hyperblaster_color;
extern cvar_t *sk_railgun_damage;
extern cvar_t *sk_railgun_damage_dm;
extern cvar_t *sk_railgun_skin;
extern cvar_t *sk_rail_color;
extern cvar_t *sk_rail_color_red;
extern cvar_t *sk_rail_color_green;
extern cvar_t *sk_rail_color_blue;
extern cvar_t *sk_bfg_damage;
extern cvar_t *sk_bfg_damage_dm;

View file

@ -470,7 +470,7 @@ qboolean gunner_grenade_check (edict_t *self)
tr = gi.trace(start, vec3_origin, vec3_origin, target, self, MASK_SHOT);
if (tr.ent == self->enemy || tr.fraction == 1)
{
VectorCopy (target, self->pos0); // save this aim location in case later safety check fails
VectorCopy (target, self->aim_point); // save this aim location in case later safety check fails
// Knightmare- added close-range contact grenade safety checks
if (isContact) {
if ( gunner_ctgrenade_safety_check(self, start, target) )
@ -485,7 +485,7 @@ qboolean gunner_grenade_check (edict_t *self)
tr = gi.trace(start, vec3_origin, vec3_origin, target, self, MASK_SHOT);
if (tr.ent == self->enemy || tr.fraction == 1)
{
VectorCopy (target, self->pos0); // save this aim location in case later safety check fails
VectorCopy (target, self->aim_point); // save this aim location in case later safety check fails
// Knightmare- added close-range contact grenade safety checks
if (isContact) {
if ( gunner_ctgrenade_safety_check(self, start, target) )
@ -655,7 +655,7 @@ void GunnerGrenade (edict_t *self)
if (isContact)
{
if ( gunner_ctgrenade_safety_check(self, start, target) ) {
VectorCopy (target, self->pos0); // save this target point
VectorCopy (target, self->aim_point); // save this target point
targetSafe = true;
}
if ( leadingTarget && gunner_ctgrenade_safety_check(self, start, leadTarget) ) {
@ -663,7 +663,7 @@ void GunnerGrenade (edict_t *self)
leadSafe = true;
}
if ( !targetSafe && !leadSafe ) {
VectorCopy (self->pos0, target); // revert to prev target point
VectorCopy (self->aim_point, target); // revert to prev target point
}
/* if ( (g_showlogic) && (g_showlogic->value) )
{

View file

@ -1189,8 +1189,8 @@ void InitClientPersistant (gclient_t *client, int style)
client->pers.spawn_levelchange = false;
// custom client colors
// Vector4Set (client->pers.color1, 255, 255, 255, 0);
// Vector4Set (client->pers.color2, 255, 255, 255, 0);
Vector4Set (client->pers.color1, 255, 255, 255, 0);
Vector4Set (client->pers.color2, 255, 255, 255, 0);
}
@ -2237,7 +2237,7 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
// set spectator
s = Info_ValueForKey (userinfo, "spectator");
// spectators are only supported in deathmatch
if (deathmatch->value && *s && strcmp(s, "0"))
if ( deathmatch->value && *s && strcmp(s, "0") )
ent->client->pers.spectator = true;
else
ent->client->pers.spectator = false;
@ -2283,12 +2283,12 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
// handedness
s = Info_ValueForKey (userinfo, "hand");
if (strlen(s))
if (strlen(s) > 0)
ent->client->pers.hand = atoi(s);
// custom colors
/* s = Info_ValueForKey (userinfo, "color1");
if ( (strlen(s) > 0) && (strncmp(s, "default", 7) != 0) ) {
s = Info_ValueForKey (userinfo, "color1");
if (strlen(s) >= 6) {
// color_t testColor;
// if ( Com_ParseColorString (s, testColor) )
// gi.dprintf ("ClientUserinfoChanged: color1 is (%d %d %d) for %s.\n", testColor[0], testColor[1], testColor[2], ent->client->pers.netname);
@ -2299,7 +2299,7 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
}
s = Info_ValueForKey (userinfo, "color2");
if ( (strlen(s) > 0) && (strncmp(s, "default", 7) != 0) ) {
if (strlen(s) >= 6) {
// color_t testColor;
// if ( Com_ParseColorString (s, testColor) )
// gi.dprintf ("ClientUserinfoChanged: color2 is (%d %d %d) for %s.\n", testColor[0], testColor[1], testColor[2], ent->client->pers.netname);
@ -2307,7 +2307,7 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
// gi.dprintf ("ClientUserinfoChanged: color2 (%s) is invalid for %s.\n", s, ent->client->pers.netname);
if ( Com_ParseColorString (s, ent->client->pers.color2) )
ent->client->pers.color2[3] = 255; // mark as set
} */
}
// save off the userinfo in case we want to check something later
strncpy (ent->client->pers.userinfo, userinfo, sizeof(ent->client->pers.userinfo)-1);

View file

@ -1735,19 +1735,12 @@ void weapon_railgun_fire (edict_t *ent, qboolean altfire)
}
}
// custom client color
/* else if ( ent->client && (ent->client->pers.color1[3] != 0) )
else if ( ent->client && (ent->client->pers.color1[3] != 0) )
{
useColor = true;
red = ent->client->pers.color1[0];
green = ent->client->pers.color1[1];
blue = ent->client->pers.color1[2];
} */
// changeable color
else if ( (sk_rail_color->value >= 2 ) && ent->client ) {
useColor = true;
red = (int)sk_rail_color_red->value;
green = (int)sk_rail_color_green->value;
blue = (int)sk_rail_color_blue->value;
}
AngleVectors (ent->client->v_angle, forward, right, NULL);

View file

@ -159,10 +159,6 @@ __inline int Q_vsnprintf (char *Dest, size_t Count, const char *Format, va_list
#define MD2_AS_MD3 // whether to load md2s into md3 memory representation
#ifndef MD2_AS_MD3
#define PROJECTION_SHADOWS // whether to use projection shadows from BeefQuake
#endif
#define CLIENT_SPLIT_NETFRAME // whether to use split net and render frames in the client
//#define WARP_LIGHTMAPS // whether to support lightmaps on warp surfaces
@ -170,9 +166,12 @@ __inline int Q_vsnprintf (char *Dest, size_t Count, const char *Format, va_list
#define CLIENT_THIRDPERSON_CVAR "cg_thirdperson"
//#define CLIENT_THIRDPERSON_CVAR "cl_3dcam"
#define MAX_CUSTOM_ANIMS 1024 // This sets the size of an mmove_t array that is saved
// to the level file, so it affects savegame compatibility.
#define SAVEGAME_USE_FUNCTION_TABLE
#define SAVEGAME_DLLNAME "Lazarus Quake II mod with CTF"
#define SAVEGAME_VERSION 4
#define SAVEGAME_VERSION 5
// angle indexes
#define PITCH 0 // up / down
@ -190,20 +189,20 @@ __inline int Q_vsnprintf (char *Dest, size_t Count, const char *Format, va_list
// per-level limits
//
#define MAX_CLIENTS 256 // absolute limit
#ifdef KMQUAKE2_ENGINE_MOD //Knightmare- increase MAX_EDICTS
#ifdef KMQUAKE2_ENGINE_MOD // Knightmare- increase MAX_EDICTS
#define MAX_EDICTS 8192 // must change protocol to increase more
#else
#define MAX_EDICTS 1024 // must change protocol to increase more
#endif
#define MAX_LIGHTSTYLES 256
#ifdef KMQUAKE2_ENGINE_MOD //Knightmare- Ding-Dong, Index: Overflow is dead!
#ifdef KMQUAKE2_ENGINE_MOD // Knightmare- Ding-Dong, Index: Overflow is dead!
#define MAX_MODELS 8192 // these are sent over the net as shorts
#define MAX_SOUNDS 8192 // so they cannot exceed 64K
#define MAX_IMAGES 2048
#else
#define MAX_MODELS 256 // these are sent over the net as bytes
#define MAX_SOUNDS 256 // so they cannot be blindly increased
#define MAX_MODELS 256 // these are sent over the net as bytes
#define MAX_SOUNDS 256 // so they cannot be blindly increased
#define MAX_IMAGES 256
#endif

View file

@ -25,6 +25,10 @@ d*_t structures are on-disk representations
m*_t structures are in-memory
*/
#ifndef MD2_AS_MD3
#define PROJECTION_SHADOWS // whether to use projection shadows from BeefQuake
#endif
/*
==============================================================================