game: sync ctf moster move code

This commit is contained in:
Denis Pauk 2023-10-23 01:25:43 +03:00
parent d8b8a78d37
commit 59e3207bed
15 changed files with 206 additions and 682 deletions

View file

@ -1465,6 +1465,7 @@ CTF_OBJS_ = \
src/common/shared/flash.o \ src/common/shared/flash.o \
src/common/shared/rand.o \ src/common/shared/rand.o \
src/common/shared/shared.o \ src/common/shared/shared.o \
src/game/g_newai.o \
src/ctf/g_ai.o \ src/ctf/g_ai.o \
src/ctf/g_chase.o \ src/ctf/g_chase.o \
src/ctf/g_cmds.o \ src/ctf/g_cmds.o \
@ -1484,7 +1485,7 @@ CTF_OBJS_ = \
src/ctf/g_utils.o \ src/ctf/g_utils.o \
src/ctf/g_weapon.o \ src/ctf/g_weapon.o \
src/ctf/menu/menu.o \ src/ctf/menu/menu.o \
src/ctf/monster/move.o \ src/game/monster/misc/move.o \
src/ctf/player/client.o \ src/ctf/player/client.o \
src/ctf/player/hud.o \ src/ctf/player/hud.o \
src/ctf/player/trail.o \ src/ctf/player/trail.o \

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) ZeniMax Media Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,7 +26,7 @@
*/ */
#include "header/local.h" #include "header/local.h"
#include "monster/player.h" #include "monster/misc/player.h"
gitem_t *CTFWhat_Tech(edict_t *ent); gitem_t *CTFWhat_Tech(edict_t *ent);
@ -36,6 +37,11 @@ ClientTeam(edict_t *ent, char* value)
value[0] = 0; value[0] = 0;
if (!ent)
{
return value;
}
if (!ent->client) if (!ent->client)
{ {
return value; return value;
@ -64,6 +70,11 @@ OnSameTeam(edict_t *ent1, edict_t *ent2)
char ent1Team[512]; char ent1Team[512];
char ent2Team[512]; char ent2Team[512];
if (!ent1 || !ent2)
{
return false;
}
if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS))) if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
{ {
return false; return false;
@ -87,6 +98,11 @@ SelectNextItem(edict_t *ent, int itflags)
int i, index; int i, index;
gitem_t *it; gitem_t *it;
if (!ent)
{
return;
}
cl = ent->client; cl = ent->client;
if (cl->menu) if (cl->menu)
@ -136,6 +152,11 @@ SelectPrevItem(edict_t *ent, int itflags)
int i, index; int i, index;
gitem_t *it; gitem_t *it;
if (!ent)
{
return;
}
cl = ent->client; cl = ent->client;
if (cl->menu) if (cl->menu)
@ -149,7 +170,7 @@ SelectPrevItem(edict_t *ent, int itflags)
return; return;
} }
/* scan for the next valid one */ /* scan for the next valid one */
for (i = 1; i <= MAX_ITEMS; i++) for (i = 1; i <= MAX_ITEMS; i++)
{ {
index = (cl->pers.selected_item + MAX_ITEMS - i) % MAX_ITEMS; index = (cl->pers.selected_item + MAX_ITEMS - i) % MAX_ITEMS;
@ -183,6 +204,11 @@ ValidateSelectedItem(edict_t *ent)
{ {
gclient_t *cl; gclient_t *cl;
if (!ent)
{
return;
}
cl = ent->client; cl = ent->client;
if (cl->pers.inventory[cl->pers.selected_item]) if (cl->pers.inventory[cl->pers.selected_item])
@ -208,9 +234,14 @@ Cmd_Give_f(edict_t *ent)
qboolean give_all; qboolean give_all;
edict_t *it_ent; edict_t *it_ent;
if (deathmatch->value && !sv_cheats->value) if (!ent)
{ {
gi.cprintf( ent, PRINT_HIGH, return;
}
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf(ent, PRINT_HIGH,
"You must run the server with '+set cheats 1' to enable this command.\n"); "You must run the server with '+set cheats 1' to enable this command.\n");
return; return;
} }
@ -230,8 +261,8 @@ Cmd_Give_f(edict_t *ent)
{ {
if (gi.argc() == 3) if (gi.argc() == 3)
{ {
ent->health = atoi(gi.argv(2)); ent->health = (int)strtol(gi.argv(2), (char **)NULL, 10);
ent->health = ent->health < 1 ? 1 : ent->health; ent->health = ent->health < 1 ? 1 : ent->health;
} }
else else
{ {
@ -344,6 +375,11 @@ Cmd_Give_f(edict_t *ent)
continue; continue;
} }
if (it->flags & IT_NOT_GIVEABLE)
{
continue;
}
if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO)) if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO))
{ {
continue; continue;
@ -375,13 +411,19 @@ Cmd_Give_f(edict_t *ent)
return; return;
} }
if (it->flags & IT_NOT_GIVEABLE)
{
gi.dprintf("item cannot be given\n");
return;
}
index = ITEM_INDEX(it); index = ITEM_INDEX(it);
if (it->flags & IT_AMMO) if (it->flags & IT_AMMO)
{ {
if (gi.argc() == 3) if (gi.argc() == 3)
{ {
ent->client->pers.inventory[index] = atoi(gi.argv(2)); ent->client->pers.inventory[index] = (int)strtol(gi.argv(2), (char **)NULL, 10);
} }
else else
{ {
@ -393,6 +435,13 @@ Cmd_Give_f(edict_t *ent)
it_ent = G_Spawn(); it_ent = G_Spawn();
it_ent->classname = it->classname; it_ent->classname = it->classname;
SpawnItem(it_ent, it); SpawnItem(it_ent, it);
/* since some items don't actually spawn when you say to .. */
if (!it_ent->inuse)
{
return;
}
Touch_Item(it_ent, ent, NULL, NULL); Touch_Item(it_ent, ent, NULL, NULL);
if (it_ent->inuse) if (it_ent->inuse)
@ -410,9 +459,14 @@ Cmd_God_f(edict_t *ent)
{ {
char *msg; char *msg;
if (deathmatch->value && !sv_cheats->value) if (!ent)
{ {
gi.cprintf( ent, PRINT_HIGH, return;
}
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf(ent, PRINT_HIGH,
"You must run the server with '+set cheats 1' to enable this command.\n"); "You must run the server with '+set cheats 1' to enable this command.\n");
return; return;
} }
@ -439,6 +493,11 @@ Cmd_Notarget_f(edict_t *ent)
{ {
char *msg; char *msg;
if (!ent)
{
return;
}
if (deathmatch->value && !sv_cheats->value) if (deathmatch->value && !sv_cheats->value)
{ {
gi.cprintf( ent, PRINT_HIGH, gi.cprintf( ent, PRINT_HIGH,
@ -460,6 +519,9 @@ Cmd_Notarget_f(edict_t *ent)
gi.cprintf(ent, PRINT_HIGH, msg); gi.cprintf(ent, PRINT_HIGH, msg);
} }
/*
* argv(0) noclip
*/
void void
Cmd_Noclip_f(edict_t *ent) Cmd_Noclip_f(edict_t *ent)
{ {
@ -1282,4 +1344,3 @@ ClientCommand(edict_t *ent)
Cmd_Say_f(ent, false, true); Cmd_Say_f(ent, false, true);
} }
} }

View file

@ -27,6 +27,25 @@
#include "header/local.h" #include "header/local.h"
void M_SetEffects(edict_t *self);
/*
* clean up heal targets for medic
*/
void
cleanupHealTarget(edict_t *ent)
{
if (!ent)
{
return;
}
ent->monsterinfo.healer = NULL;
ent->takedamage = DAMAGE_YES;
ent->monsterinfo.aiflags &= ~AI_RESURRECTING;
M_SetEffects(ent);
}
/* /*
* Returns true if the inflictor can * Returns true if the inflictor can
* directly damage the target. Used for * directly damage the target. Used for

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) ZeniMax Media Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,7 +26,7 @@
*/ */
#include "header/local.h" #include "header/local.h"
#include "monster/player.h" #include "monster/misc/player.h"
typedef enum match_s typedef enum match_s
{ {

View file

@ -889,3 +889,14 @@ swimmonster_start(edict_t *self)
monster_start(self); monster_start(self);
} }
void
monster_done_dodge(edict_t *self)
{
if (!self)
{
return;
}
self->monsterinfo.aiflags &= ~AI_DODGING;
}

View file

@ -188,6 +188,8 @@ InitGame(void)
capturelimit = gi.cvar("capturelimit", "0", CVAR_SERVERINFO); capturelimit = gi.cvar("capturelimit", "0", CVAR_SERVERINFO);
instantweap = gi.cvar("instantweap", "0", CVAR_SERVERINFO); instantweap = gi.cvar("instantweap", "0", CVAR_SERVERINFO);
password = gi.cvar("password", "", CVAR_USERINFO); password = gi.cvar("password", "", CVAR_USERINFO);
spectator_password = gi.cvar("spectator_password", "", CVAR_USERINFO);
needpass = gi.cvar("needpass", "0", CVAR_SERVERINFO);
filterban = gi.cvar("filterban", "1", 0); filterban = gi.cvar("filterban", "1", 0);
g_select_empty = gi.cvar("g_select_empty", "0", CVAR_ARCHIVE); g_select_empty = gi.cvar("g_select_empty", "0", CVAR_ARCHIVE);
run_pitch = gi.cvar("run_pitch", "0.002", 0); run_pitch = gi.cvar("run_pitch", "0.002", 0);
@ -807,4 +809,3 @@ ReadLevel(const char *filename)
} }
} }
} }

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) ZeniMax Media Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,7 +23,7 @@
* Misc. utility functions for the game logic. * Misc. utility functions for the game logic.
* *
* ======================================================================= * =======================================================================
*/ */
#include "header/local.h" #include "header/local.h"
@ -441,11 +442,69 @@ vectoangles(vec3_t value1, vec3_t angles)
angles[ROLL] = 0; angles[ROLL] = 0;
} }
void
vectoangles2(vec3_t value1, vec3_t angles)
{
float forward;
float yaw, pitch;
if ((value1[1] == 0) && (value1[0] == 0))
{
yaw = 0;
if (value1[2] > 0)
{
pitch = 90;
}
else
{
pitch = 270;
}
}
else
{
if (value1[0])
{
yaw = (atan2(value1[1], value1[0]) * 180 / M_PI);
}
else if (value1[1] > 0)
{
yaw = 90;
}
else
{
yaw = 270;
}
if (yaw < 0)
{
yaw += 360;
}
forward = sqrt(value1[0] * value1[0] + value1[1] * value1[1]);
pitch = (atan2(value1[2], forward) * 180 / M_PI);
if (pitch < 0)
{
pitch += 360;
}
}
angles[PITCH] = -pitch;
angles[YAW] = yaw;
angles[ROLL] = 0;
}
char * char *
G_CopyString(char *in) G_CopyString(char *in)
{ {
char *out; char *out;
if (!in)
{
return NULL;
}
out = gi.TagMalloc(strlen(in) + 1, TAG_LEVEL); out = gi.TagMalloc(strlen(in) + 1, TAG_LEVEL);
strcpy(out, in); strcpy(out, in);
return out; return out;
@ -454,10 +513,24 @@ G_CopyString(char *in)
void void
G_InitEdict(edict_t *e) G_InitEdict(edict_t *e)
{ {
if (!e)
{
return;
}
if (e->nextthink)
{
e->nextthink = 0;
}
e->inuse = true; e->inuse = true;
e->classname = "noclass"; e->classname = "noclass";
e->gravity = 1.0; e->gravity = 1.0;
e->s.number = e - g_edicts; e->s.number = e - g_edicts;
e->gravityVector[0] = 0.0;
e->gravityVector[1] = 0.0;
e->gravityVector[2] = -1.0;
} }
/* /*

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) ZeniMax Media Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -224,4 +225,3 @@
#define FRAME_death308 197 #define FRAME_death308 197
#define MODEL_SCALE 1.000000 #define MODEL_SCALE 1.000000

View file

@ -1,659 +0,0 @@
/*
* Copyright (C) 1997-2001 Id Software, Inc.
*
* This program 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.
*
* =======================================================================
*
* Monster movement support functions. While unused by the CTF code
* these functions must be here since they're referenced at several
* points inside the game.so.
*
* =======================================================================
*/
#include "../header/local.h"
#define STEPSIZE 18
/*
* Returns false if any part of the bottom of
* the entity is off an edge that is not a staircase.
*/
int c_yes, c_no;
qboolean
M_CheckBottom(edict_t *ent)
{
vec3_t mins, maxs, start, stop;
trace_t trace;
int x, y;
float mid, bottom;
VectorAdd(ent->s.origin, ent->mins, mins);
VectorAdd(ent->s.origin, ent->maxs, maxs);
/* if all of the points under the corners are
solid world, don't bother with the tougher
checks the corners must be within 16 of the
midpoint */
start[2] = mins[2] - 1;
for (x = 0; x <= 1; x++)
{
for (y = 0; y <= 1; y++)
{
start[0] = x ? maxs[0] : mins[0];
start[1] = y ? maxs[1] : mins[1];
if (gi.pointcontents(start) != CONTENTS_SOLID)
{
goto realcheck;
}
}
}
c_yes++;
return true; /* we got out easy */
realcheck:
c_no++;
/* check it for real... */
start[2] = mins[2];
/* the midpoint must be within 16 of the bottom */
start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5;
start[1] = stop[1] = (mins[1] + maxs[1]) * 0.5;
stop[2] = start[2] - 2 * STEPSIZE;
trace = gi.trace(start, vec3_origin, vec3_origin,
stop, ent, MASK_MONSTERSOLID);
if (trace.fraction == 1.0)
{
return false;
}
mid = bottom = trace.endpos[2];
/* the corners must be within 16 of the midpoint */
for (x = 0; x <= 1; x++)
{
for (y = 0; y <= 1; y++)
{
start[0] = stop[0] = x ? maxs[0] : mins[0];
start[1] = stop[1] = y ? maxs[1] : mins[1];
trace = gi.trace(start, vec3_origin, vec3_origin,
stop, ent, MASK_MONSTERSOLID);
if ((trace.fraction != 1.0) && (trace.endpos[2] > bottom))
{
bottom = trace.endpos[2];
}
if ((trace.fraction == 1.0) || (mid - trace.endpos[2] > STEPSIZE))
{
return false;
}
}
}
c_yes++;
return true;
}
/*
* Called by monster program code.
* The move will be adjusted for
* slopes and stairs, but if the move
* isn't possible, no move is done,
* false is returned, and
* pr_global_struct->trace_normal
* is set to the normal of the
* blocking wall
*/
qboolean
SV_movestep(edict_t *ent, vec3_t move, qboolean relink)
{
float dz;
vec3_t oldorg, neworg, end;
trace_t trace;
int i;
float stepsize;
vec3_t test;
int contents;
/* try the move */
VectorCopy(ent->s.origin, oldorg);
VectorAdd(ent->s.origin, move, neworg);
/* flying monsters don't step up */
if (ent->flags & (FL_SWIM | FL_FLY))
{
/* try one move with vertical motion, then one without */
for (i = 0; i < 2; i++)
{
VectorAdd(ent->s.origin, move, neworg);
if ((i == 0) && ent->enemy)
{
if (!ent->goalentity)
{
ent->goalentity = ent->enemy;
}
dz = ent->s.origin[2] - ent->goalentity->s.origin[2];
if (ent->goalentity->client)
{
if (dz > 40)
{
neworg[2] -= 8;
}
if (!((ent->flags & FL_SWIM) && (ent->waterlevel < 2)))
{
if (dz < 30)
{
neworg[2] += 8;
}
}
}
else
{
if (dz > 8)
{
neworg[2] -= 8;
}
else if (dz > 0)
{
neworg[2] -= dz;
}
else if (dz < -8)
{
neworg[2] += 8;
}
else
{
neworg[2] += dz;
}
}
}
trace = gi.trace(ent->s.origin, ent->mins, ent->maxs,
neworg, ent, MASK_MONSTERSOLID);
/* fly monsters don't enter water voluntarily */
if (ent->flags & FL_FLY)
{
if (!ent->waterlevel)
{
test[0] = trace.endpos[0];
test[1] = trace.endpos[1];
test[2] = trace.endpos[2] + ent->mins[2] + 1;
contents = gi.pointcontents(test);
if (contents & MASK_WATER)
{
return false;
}
}
}
/* swim monsters don't exit water voluntarily */
if (ent->flags & FL_SWIM)
{
if (ent->waterlevel < 2)
{
test[0] = trace.endpos[0];
test[1] = trace.endpos[1];
test[2] = trace.endpos[2] + ent->mins[2] + 1;
contents = gi.pointcontents(test);
if (!(contents & MASK_WATER))
{
return false;
}
}
}
if (trace.fraction == 1)
{
VectorCopy(trace.endpos, ent->s.origin);
if (relink)
{
gi.linkentity(ent);
G_TouchTriggers(ent);
}
return true;
}
if (!ent->enemy)
{
break;
}
}
return false;
}
/* push down from a step height above the wished position */
if (!(ent->monsterinfo.aiflags & AI_NOSTEP))
{
stepsize = STEPSIZE;
}
else
{
stepsize = 1;
}
neworg[2] += stepsize;
VectorCopy(neworg, end);
end[2] -= stepsize * 2;
trace = gi.trace(neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);
if (trace.allsolid)
{
return false;
}
if (trace.startsolid)
{
neworg[2] -= stepsize;
trace = gi.trace(neworg, ent->mins, ent->maxs, end,
ent, MASK_MONSTERSOLID);
if (trace.allsolid || trace.startsolid)
{
return false;
}
}
/* don't go in to water */
if (ent->waterlevel == 0)
{
test[0] = trace.endpos[0];
test[1] = trace.endpos[1];
test[2] = trace.endpos[2] + ent->mins[2] + 1;
contents = gi.pointcontents(test);
if (contents & MASK_WATER)
{
return false;
}
}
if (trace.fraction == 1)
{
/* if monster had the ground pulled out, go ahead and fall */
if (ent->flags & FL_PARTIALGROUND)
{
VectorAdd(ent->s.origin, move, ent->s.origin);
if (relink)
{
gi.linkentity(ent);
G_TouchTriggers(ent);
}
ent->groundentity = NULL;
return true;
}
return false; /* walked off an edge */
}
/* check point traces down for dangling corners */
VectorCopy(trace.endpos, ent->s.origin);
if (!M_CheckBottom(ent))
{
if (ent->flags & FL_PARTIALGROUND)
{
/* entity had floor mostly pulled out
from underneath it and is trying to
correct */
if (relink)
{
gi.linkentity(ent);
G_TouchTriggers(ent);
}
return true;
}
VectorCopy(oldorg, ent->s.origin);
return false;
}
if (ent->flags & FL_PARTIALGROUND)
{
ent->flags &= ~FL_PARTIALGROUND;
}
ent->groundentity = trace.ent;
ent->groundentity_linkcount = trace.ent->linkcount;
/* the move is ok */
if (relink)
{
gi.linkentity(ent);
G_TouchTriggers(ent);
}
return true;
}
/* ============================================================================ */
void
M_ChangeYaw(edict_t *ent)
{
float ideal;
float current;
float move;
float speed;
current = anglemod(ent->s.angles[YAW]);
ideal = ent->ideal_yaw;
if (current == ideal)
{
return;
}
move = ideal - current;
speed = ent->yaw_speed;
if (ideal > current)
{
if (move >= 180)
{
move = move - 360;
}
}
else
{
if (move <= -180)
{
move = move + 360;
}
}
if (move > 0)
{
if (move > speed)
{
move = speed;
}
}
else
{
if (move < -speed)
{
move = -speed;
}
}
ent->s.angles[YAW] = anglemod(current + move);
}
/*
* Turns to the movement direction, and
* walks the current distance if facing it.
*/
qboolean
SV_StepDirection(edict_t *ent, float yaw, float dist)
{
vec3_t move, oldorigin;
float delta;
ent->ideal_yaw = yaw;
M_ChangeYaw(ent);
yaw = yaw * M_PI * 2 / 360;
move[0] = cos(yaw) * dist;
move[1] = sin(yaw) * dist;
move[2] = 0;
VectorCopy(ent->s.origin, oldorigin);
if (SV_movestep(ent, move, false))
{
delta = ent->s.angles[YAW] - ent->ideal_yaw;
if ((delta > 45) && (delta < 315))
{
/* not turned far enough, so don't take the step */
VectorCopy(oldorigin, ent->s.origin);
}
gi.linkentity(ent);
G_TouchTriggers(ent);
return true;
}
gi.linkentity(ent);
G_TouchTriggers(ent);
return false;
}
void
SV_FixCheckBottom(edict_t *ent)
{
ent->flags |= FL_PARTIALGROUND;
}
#define DI_NODIR -1
void
SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist)
{
float deltax, deltay;
float d[3];
float tdir, olddir, turnaround;
if (!enemy)
{
return;
}
olddir = anglemod((int)(actor->ideal_yaw / 45) * 45);
turnaround = anglemod(olddir - 180);
deltax = enemy->s.origin[0] - actor->s.origin[0];
deltay = enemy->s.origin[1] - actor->s.origin[1];
if (deltax > 10)
{
d[1] = 0;
}
else if (deltax < -10)
{
d[1] = 180;
}
else
{
d[1] = DI_NODIR;
}
if (deltay < -10)
{
d[2] = 270;
}
else if (deltay > 10)
{
d[2] = 90;
}
else
{
d[2] = DI_NODIR;
}
/* try direct route */
if ((d[1] != DI_NODIR) && (d[2] != DI_NODIR))
{
if (d[1] == 0)
{
tdir = d[2] == 90 ? 45 : 315;
}
else
{
tdir = d[2] == 90 ? 135 : 215;
}
if ((tdir != turnaround) && SV_StepDirection(actor, tdir, dist))
{
return;
}
}
/* try other directions */
if (((rand() & 3) & 1) || (fabsf(deltay) > fabsf(deltax)))
{
tdir = d[1];
d[1] = d[2];
d[2] = tdir;
}
if ((d[1] != DI_NODIR) && (d[1] != turnaround) &&
SV_StepDirection(actor, d[1], dist))
{
return;
}
if ((d[2] != DI_NODIR) && (d[2] != turnaround) &&
SV_StepDirection(actor, d[2], dist))
{
return;
}
/* there is no direct path to the player, so pick another direction */
if ((olddir != DI_NODIR) && SV_StepDirection(actor, olddir, dist))
{
return;
}
if (rand() & 1) /*randomly determine direction of search*/
{
for (tdir = 0; tdir <= 315; tdir += 45)
{
if ((tdir != turnaround) && SV_StepDirection(actor, tdir, dist))
{
return;
}
}
}
else
{
for (tdir = 315; tdir >= 0; tdir -= 45)
{
if ((tdir != turnaround) && SV_StepDirection(actor, tdir, dist))
{
return;
}
}
}
if ((turnaround != DI_NODIR) && SV_StepDirection(actor, turnaround, dist))
{
return;
}
actor->ideal_yaw = olddir; /* can't move */
/* if a bridge was pulled out from underneath a
monster, it may not have a valid standing
position at all */
if (!M_CheckBottom(actor))
{
SV_FixCheckBottom(actor);
}
}
qboolean
SV_CloseEnough(edict_t *ent, edict_t *goal, float dist)
{
int i;
for (i = 0; i < 3; i++)
{
if (goal->absmin[i] > ent->absmax[i] + dist)
{
return false;
}
if (goal->absmax[i] < ent->absmin[i] - dist)
{
return false;
}
}
return true;
}
void
M_MoveToGoal(edict_t *ent, float dist)
{
edict_t *goal;
goal = ent->goalentity;
if (!ent->groundentity && !(ent->flags & (FL_FLY | FL_SWIM)))
{
return;
}
/* if the next step hits the enemy, return immediately */
if (ent->enemy && SV_CloseEnough(ent, ent->enemy, dist))
{
return;
}
/* bump around... */
if (((rand() & 3) == 1) || !SV_StepDirection(ent, ent->ideal_yaw, dist))
{
if (ent->inuse)
{
SV_NewChaseDir(ent, goal, dist);
}
}
}
qboolean
M_walkmove(edict_t *ent, float yaw, float dist)
{
vec3_t move;
if (!ent->groundentity && !(ent->flags & (FL_FLY | FL_SWIM)))
{
return false;
}
yaw = yaw * M_PI * 2 / 360;
move[0] = cos(yaw) * dist;
move[1] = sin(yaw) * dist;
move[2] = 0;
return SV_movestep(ent, move, true);
}

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) ZeniMax Media Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,7 +26,7 @@
*/ */
#include "../header/local.h" #include "../header/local.h"
#include "../monster/player.h" #include "../monster/misc/player.h"
void SP_misc_teleporter_dest(edict_t *ent); void SP_misc_teleporter_dest(edict_t *ent);

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) ZeniMax Media Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,10 +23,10 @@
* The "camera" through which the player looks into the game. * The "camera" through which the player looks into the game.
* *
* ======================================================================= * =======================================================================
*/ */
#include "../header/local.h" #include "../header/local.h"
#include "../monster/player.h" #include "../monster/misc/player.h"
static edict_t *current_player; static edict_t *current_player;
static gclient_t *current_client; static gclient_t *current_client;

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) ZeniMax Media Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,10 +23,12 @@
* Player weapons. * Player weapons.
* *
* ======================================================================= * =======================================================================
*/ */
#include "../header/local.h" #include "../header/local.h"
#include "../monster/player.h" #include "../monster/misc/player.h"
#include <limits.h>
static qboolean is_quad; static qboolean is_quad;
static byte is_silenced; static byte is_silenced;
@ -40,6 +43,11 @@ P_ProjectSource(edict_t *ent, vec3_t distance,
float *point = ent->s.origin; float *point = ent->s.origin;
vec3_t _distance; vec3_t _distance;
if (!client)
{
return;
}
VectorCopy(distance, _distance); VectorCopy(distance, _distance);
if (client->pers.hand == LEFT_HANDED) if (client->pers.hand == LEFT_HANDED)

View file

@ -48,7 +48,7 @@ cleanupHealTarget(edict_t *ent)
/* /*
* Returns true if the inflictor can * Returns true if the inflictor can
* directly damage the target. Used for * directly damage the target. Used for
* explosions and melee attacks. * explosions and melee attacks.
*/ */
qboolean qboolean

View file

@ -20,7 +20,9 @@
* *
* ======================================================================= * =======================================================================
* *
* Monster movement support functions. * Monster movement support functions. While unused by the CTF code
* these functions must be here since they're referenced at several
* points inside the game.so.
* *
* ======================================================================= * =======================================================================
*/ */

View file

@ -22,7 +22,9 @@
* *
* ======================================================================= * =======================================================================
* *
* The savegame system. * The savegame system. Unused by the CTF game but nevertheless called
* during game initialization. Therefor no new savegame code ist
* imported.
* *
* ======================================================================= * =======================================================================
*/ */
@ -232,6 +234,8 @@ InitGame(void)
dmflags = gi.cvar("dmflags", "0", CVAR_SERVERINFO); dmflags = gi.cvar("dmflags", "0", CVAR_SERVERINFO);
fraglimit = gi.cvar("fraglimit", "0", CVAR_SERVERINFO); fraglimit = gi.cvar("fraglimit", "0", CVAR_SERVERINFO);
timelimit = gi.cvar("timelimit", "0", CVAR_SERVERINFO); timelimit = gi.cvar("timelimit", "0", CVAR_SERVERINFO);
capturelimit = gi.cvar("capturelimit", "0", CVAR_SERVERINFO);
instantweap = gi.cvar("instantweap", "0", CVAR_SERVERINFO);
password = gi.cvar("password", "", CVAR_USERINFO); password = gi.cvar("password", "", CVAR_USERINFO);
spectator_password = gi.cvar("spectator_password", "", CVAR_USERINFO); spectator_password = gi.cvar("spectator_password", "", CVAR_USERINFO);
needpass = gi.cvar("needpass", "0", CVAR_SERVERINFO); needpass = gi.cvar("needpass", "0", CVAR_SERVERINFO);