Migrate vec to OFVector3D
FossilOrigin-Name: 2e931ae3e1bb8a3ac23d368cfacc7394d07f295bd0bc56a40e0c70190d019d8b
This commit is contained in:
parent
4ce99636d3
commit
6f64252d65
15 changed files with 141 additions and 136 deletions
|
@ -201,7 +201,7 @@ localservertoclient(
|
||||||
|
|
||||||
case SV_SHOT: {
|
case SV_SHOT: {
|
||||||
int gun = getint(p);
|
int gun = getint(p);
|
||||||
vec s, e;
|
OFVector3D s, e;
|
||||||
s.x = getint(p) / DMF;
|
s.x = getint(p) / DMF;
|
||||||
s.y = getint(p) / DMF;
|
s.y = getint(p) / DMF;
|
||||||
s.z = getint(p) / DMF;
|
s.z = getint(p) / DMF;
|
||||||
|
@ -274,8 +274,8 @@ localservertoclient(
|
||||||
setspawn(i, true);
|
setspawn(i, true);
|
||||||
if (i >= (uint)ents.length())
|
if (i >= (uint)ents.length())
|
||||||
break;
|
break;
|
||||||
vec v = {(float)ents[i].x, (float)ents[i].y,
|
OFVector3D v =
|
||||||
(float)ents[i].z};
|
OFMakeVector3D(ents[i].x, ents[i].y, ents[i].z);
|
||||||
playsound(S_ITEMSPAWN, &v);
|
playsound(S_ITEMSPAWN, &v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,8 @@ alias(OFString *name, OFString *action)
|
||||||
if (b.type == ID_ALIAS)
|
if (b.type == ID_ALIAS)
|
||||||
b.action = action;
|
b.action = action;
|
||||||
else
|
else
|
||||||
conoutf(
|
conoutf(@"cannot redefine builtin %s with an alias",
|
||||||
@"cannot redefine builtin %s with an alias", name.UTF8String);
|
name.UTF8String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
COMMAND(alias, ARG_2STR)
|
COMMAND(alias, ARG_2STR)
|
||||||
|
|
15
src/cube.h
15
src/cube.h
|
@ -102,9 +102,6 @@ struct header // map file format header
|
||||||
((x) < MINBORD || (y) < MINBORD || (x) >= ssize - MINBORD || \
|
((x) < MINBORD || (y) < MINBORD || (x) >= ssize - MINBORD || \
|
||||||
(y) >= ssize - MINBORD)
|
(y) >= ssize - MINBORD)
|
||||||
|
|
||||||
struct vec {
|
|
||||||
float x, y, z;
|
|
||||||
};
|
|
||||||
struct block {
|
struct block {
|
||||||
int x, y, xs, ys;
|
int x, y, xs, ys;
|
||||||
};
|
};
|
||||||
|
@ -128,8 +125,8 @@ enum {
|
||||||
|
|
||||||
struct dynent // players & monsters
|
struct dynent // players & monsters
|
||||||
{
|
{
|
||||||
vec o, vel; // origin, velocity
|
OFVector3D o, vel; // origin, velocity
|
||||||
float yaw, pitch, roll; // used as vec in one place
|
float yaw, pitch, roll; // used as OFVector3D in one place
|
||||||
float maxspeed; // cubes per second, 24 for player
|
float maxspeed; // cubes per second, 24 for player
|
||||||
bool outsidemap; // from his eyes
|
bool outsidemap; // from his eyes
|
||||||
bool inwater;
|
bool inwater;
|
||||||
|
@ -154,8 +151,8 @@ struct dynent // players & monsters
|
||||||
bool blocked, moving; // used by physics to signal ai
|
bool blocked, moving; // used by physics to signal ai
|
||||||
int trigger; // millis at which transition to another monsterstate takes
|
int trigger; // millis at which transition to another monsterstate takes
|
||||||
// place
|
// place
|
||||||
vec attacktarget; // delayed attacks
|
OFVector3D attacktarget; // delayed attacks
|
||||||
int anger; // how many times already hit by fellow monster
|
int anger; // how many times already hit by fellow monster
|
||||||
string name, team;
|
string name, team;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -295,7 +292,7 @@ extern dynent
|
||||||
extern dvector players; // all the other clients (in multiplayer)
|
extern dvector players; // all the other clients (in multiplayer)
|
||||||
extern bool editmode;
|
extern bool editmode;
|
||||||
extern vector<entity> ents; // map entities
|
extern vector<entity> ents; // map entities
|
||||||
extern vec worldpos; // current target of the crosshair in the world
|
extern OFVector3D worldpos; // current target of the crosshair in the world
|
||||||
extern int lastmillis; // last time
|
extern int lastmillis; // last time
|
||||||
extern int curtime; // current frame time
|
extern int curtime; // current frame time
|
||||||
extern int gamemode, nextmode;
|
extern int gamemode, nextmode;
|
||||||
|
@ -341,7 +338,7 @@ extern bool demoplayback;
|
||||||
(u).z -= (v).z; \
|
(u).z -= (v).z; \
|
||||||
};
|
};
|
||||||
#define vdist(d, v, e, s) \
|
#define vdist(d, v, e, s) \
|
||||||
vec v = s; \
|
OFVector3D v = s; \
|
||||||
vsub(v, e); \
|
vsub(v, e); \
|
||||||
float d = (float)sqrt(dotprod(v, v));
|
float d = (float)sqrt(dotprod(v, v));
|
||||||
#define vreject(v, u, max) \
|
#define vreject(v, u, max) \
|
||||||
|
|
|
@ -298,15 +298,15 @@ pickup(int n, dynent *d)
|
||||||
if (lastmillis - lastjumppad < 300)
|
if (lastmillis - lastjumppad < 300)
|
||||||
break;
|
break;
|
||||||
lastjumppad = lastmillis;
|
lastjumppad = lastmillis;
|
||||||
vec v = {(int)(char)ents[n].attr3 / 10.0f,
|
OFVector3D v = OFMakeVector3D((int)(char)ents[n].attr3 / 10.0f,
|
||||||
(int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f};
|
(int)(char)ents[n].attr2 / 10.0f, ents[n].attr1 / 10.0f);
|
||||||
player1->vel.z = 0;
|
player1->vel.z = 0;
|
||||||
vadd(player1->vel, v);
|
vadd(player1->vel, v);
|
||||||
playsoundc(S_JUMPPAD);
|
playsoundc(S_JUMPPAD);
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
checkitems()
|
checkitems()
|
||||||
|
@ -322,13 +322,13 @@ checkitems()
|
||||||
continue;
|
continue;
|
||||||
if (OUTBORD(e.x, e.y))
|
if (OUTBORD(e.x, e.y))
|
||||||
continue;
|
continue;
|
||||||
vec v = {(float)e.x, (float)e.y,
|
OFVector3D v = OFMakeVector3D(
|
||||||
(float)S(e.x, e.y)->floor + player1->eyeheight};
|
e.x, e.y, (float)S(e.x, e.y)->floor + player1->eyeheight);
|
||||||
vdist(dist, t, player1->o, v);
|
vdist(dist, t, player1->o, v);
|
||||||
if (dist < (e.type == TELEPORT ? 4 : 2.5))
|
if (dist < (e.type == TELEPORT ? 4 : 2.5))
|
||||||
pickup(i, player1);
|
pickup(i, player1);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
checkquad(int time)
|
checkquad(int time)
|
||||||
|
|
|
@ -126,7 +126,7 @@ monsterclear() // called after map start of when toggling edit mode to
|
||||||
|
|
||||||
bool
|
bool
|
||||||
los(float lx, float ly, float lz, float bx, float by, float bz,
|
los(float lx, float ly, float lz, float bx, float by, float bz,
|
||||||
vec &v) // height-correct line of sight for monster shooting/seeing
|
OFVector3D &v) // height-correct line of sight for monster shooting/seeing
|
||||||
{
|
{
|
||||||
if (OUTBORD((int)lx, (int)ly) || OUTBORD((int)bx, (int)by))
|
if (OUTBORD((int)lx, (int)ly) || OUTBORD((int)bx, (int)by))
|
||||||
return false;
|
return false;
|
||||||
|
@ -162,7 +162,7 @@ los(float lx, float ly, float lz, float bx, float by, float bz,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
enemylos(dynent *m, vec &v)
|
enemylos(dynent *m, OFVector3D &v)
|
||||||
{
|
{
|
||||||
v = m->o;
|
v = m->o;
|
||||||
return los(m->o.x, m->o.y, m->o.z, m->enemy->o.x, m->enemy->o.y,
|
return los(m->o.x, m->o.y, m->o.z, m->enemy->o.x, m->enemy->o.y,
|
||||||
|
@ -253,7 +253,7 @@ monsteraction(
|
||||||
case M_SLEEP: // state classic sp monster start in, wait for visual
|
case M_SLEEP: // state classic sp monster start in, wait for visual
|
||||||
// contact
|
// contact
|
||||||
{
|
{
|
||||||
vec target;
|
OFVector3D target;
|
||||||
if (editmode || !enemylos(m, target))
|
if (editmode || !enemylos(m, target))
|
||||||
return; // skip running physics
|
return; // skip running physics
|
||||||
normalise(m, enemyyaw);
|
normalise(m, enemyyaw);
|
||||||
|
@ -283,7 +283,7 @@ monsteraction(
|
||||||
// and may want to shoot at any time
|
// and may want to shoot at any time
|
||||||
m->targetyaw = enemyyaw;
|
m->targetyaw = enemyyaw;
|
||||||
if (m->trigger < lastmillis) {
|
if (m->trigger < lastmillis) {
|
||||||
vec target;
|
OFVector3D target;
|
||||||
if (!enemylos(
|
if (!enemylos(
|
||||||
m, target)) // no visual contact anymore, let
|
m, target)) // no visual contact anymore, let
|
||||||
// monster get as close as possible
|
// monster get as close as possible
|
||||||
|
@ -380,7 +380,8 @@ monsterthink()
|
||||||
continue;
|
continue;
|
||||||
if (OUTBORD(e.x, e.y))
|
if (OUTBORD(e.x, e.y))
|
||||||
continue;
|
continue;
|
||||||
vec v = {(float)e.x, (float)e.y, (float)S(e.x, e.y)->floor};
|
OFVector3D v =
|
||||||
|
OFMakeVector3D(e.x, e.y, (float)S(e.x, e.y)->floor);
|
||||||
loopv(monsters) if (monsters[i]->state == CS_DEAD)
|
loopv(monsters) if (monsters[i]->state == CS_DEAD)
|
||||||
{
|
{
|
||||||
if (lastmillis - monsters[i]->lastaction < 2000) {
|
if (lastmillis - monsters[i]->lastaction < 2000) {
|
||||||
|
|
|
@ -240,7 +240,7 @@ moveplayer(dynent *pl, int moveres, bool local, int curtime)
|
||||||
const bool water = hdr.waterlevel > pl->o.z - 0.5f;
|
const bool water = hdr.waterlevel > pl->o.z - 0.5f;
|
||||||
const bool floating = (editmode && local) || pl->state == CS_EDITING;
|
const bool floating = (editmode && local) || pl->state == CS_EDITING;
|
||||||
|
|
||||||
vec d; // vector of direction we ideally want to move in
|
OFVector3D d; // vector of direction we ideally want to move in
|
||||||
|
|
||||||
d.x = (float)(pl->move * cos(rad(pl->yaw - 90)));
|
d.x = (float)(pl->move * cos(rad(pl->yaw - 90)));
|
||||||
d.y = (float)(pl->move * sin(rad(pl->yaw - 90)));
|
d.y = (float)(pl->move * sin(rad(pl->yaw - 90)));
|
||||||
|
|
23
src/protos.h
23
src/protos.h
|
@ -126,7 +126,7 @@ extern entity *newentity(
|
||||||
// worldlight
|
// worldlight
|
||||||
extern void calclight();
|
extern void calclight();
|
||||||
extern void dodynlight(
|
extern void dodynlight(
|
||||||
vec &vold, vec &v, int reach, int strength, dynent *owner);
|
OFVector3D &vold, OFVector3D &v, int reach, int strength, dynent *owner);
|
||||||
extern void cleardlights();
|
extern void cleardlights();
|
||||||
extern block *blockcopy(block &b);
|
extern block *blockcopy(block &b);
|
||||||
extern void blockpaste(block &b);
|
extern void blockpaste(block &b);
|
||||||
|
@ -167,7 +167,7 @@ extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
|
||||||
extern void box(block &b, float z1, float z2, float z3, float z4);
|
extern void box(block &b, float z1, float z2, float z3, float z4);
|
||||||
extern void dot(int x, int y, float z);
|
extern void dot(int x, int y, float z);
|
||||||
extern void linestyle(float width, int r, int g, int b);
|
extern void linestyle(float width, int r, int g, int b);
|
||||||
extern void newsphere(vec &o, float max, int type);
|
extern void newsphere(OFVector3D &o, float max, int type);
|
||||||
extern void renderspheres(int time);
|
extern void renderspheres(int time);
|
||||||
extern void gl_drawhud(
|
extern void gl_drawhud(
|
||||||
int w, int h, int curfps, int nquads, int curvert, bool underwater);
|
int w, int h, int curfps, int nquads, int curvert, bool underwater);
|
||||||
|
@ -176,9 +176,10 @@ extern void blendbox(int x1, int y1, int x2, int y2, bool border);
|
||||||
extern void damageblend(int n);
|
extern void damageblend(int n);
|
||||||
|
|
||||||
// renderparticles
|
// renderparticles
|
||||||
extern void setorient(vec &r, vec &u);
|
extern void setorient(OFVector3D &r, OFVector3D &u);
|
||||||
extern void particle_splash(int type, int num, int fade, vec &p);
|
extern void particle_splash(int type, int num, int fade, OFVector3D &p);
|
||||||
extern void particle_trail(int type, int fade, vec &from, vec &to);
|
extern void particle_trail(
|
||||||
|
int type, int fade, OFVector3D &from, OFVector3D &to);
|
||||||
extern void render_particles(int time);
|
extern void render_particles(int time);
|
||||||
|
|
||||||
// worldio
|
// worldio
|
||||||
|
@ -191,7 +192,7 @@ extern void incomingdemodata(uchar *buf, int len, bool extras = false);
|
||||||
extern void demoplaybackstep();
|
extern void demoplaybackstep();
|
||||||
extern void stop();
|
extern void stop();
|
||||||
extern void stopifrecording();
|
extern void stopifrecording();
|
||||||
extern void demodamage(int damage, vec &o);
|
extern void demodamage(int damage, OFVector3D &o);
|
||||||
extern void demoblend(int damage);
|
extern void demoblend(int damage);
|
||||||
|
|
||||||
// physics
|
// physics
|
||||||
|
@ -202,7 +203,7 @@ extern void setentphysics(int mml, int mmr);
|
||||||
extern void physicsframe();
|
extern void physicsframe();
|
||||||
|
|
||||||
// sound
|
// sound
|
||||||
extern void playsound(int n, vec *loc = 0);
|
extern void playsound(int n, OFVector3D *loc = 0);
|
||||||
extern void playsoundc(int n);
|
extern void playsoundc(int n);
|
||||||
extern void initsound();
|
extern void initsound();
|
||||||
extern void cleansound();
|
extern void cleansound();
|
||||||
|
@ -236,10 +237,10 @@ extern ENetPacket *recvmap(int n);
|
||||||
|
|
||||||
// weapon
|
// weapon
|
||||||
extern void selectgun(int a = -1, int b = -1, int c = -1);
|
extern void selectgun(int a = -1, int b = -1, int c = -1);
|
||||||
extern void shoot(dynent *d, vec &to);
|
extern void shoot(dynent *d, OFVector3D &to);
|
||||||
extern void shootv(
|
extern void shootv(int gun, OFVector3D &from, OFVector3D &to, dynent *d = 0,
|
||||||
int gun, vec &from, vec &to, dynent *d = 0, bool local = false);
|
bool local = false);
|
||||||
extern void createrays(vec &from, vec &to);
|
extern void createrays(OFVector3D &from, OFVector3D &to);
|
||||||
extern void moveprojectiles(float time);
|
extern void moveprojectiles(float time);
|
||||||
extern void projreset();
|
extern void projreset();
|
||||||
extern char *playerincrosshair();
|
extern char *playerincrosshair();
|
||||||
|
|
|
@ -80,7 +80,7 @@ blendbox(int x1, int y1, int x2, int y2, bool border)
|
||||||
|
|
||||||
const int MAXSPHERES = 50;
|
const int MAXSPHERES = 50;
|
||||||
struct sphere {
|
struct sphere {
|
||||||
vec o;
|
OFVector3D o;
|
||||||
float size, max;
|
float size, max;
|
||||||
int type;
|
int type;
|
||||||
sphere *next;
|
sphere *next;
|
||||||
|
@ -89,7 +89,7 @@ sphere spheres[MAXSPHERES], *slist = NULL, *sempty = NULL;
|
||||||
bool sinit = false;
|
bool sinit = false;
|
||||||
|
|
||||||
void
|
void
|
||||||
newsphere(vec &o, float max, int type)
|
newsphere(OFVector3D &o, float max, int type)
|
||||||
{
|
{
|
||||||
if (!sinit) {
|
if (!sinit) {
|
||||||
loopi(MAXSPHERES)
|
loopi(MAXSPHERES)
|
||||||
|
@ -184,9 +184,9 @@ renderents() // show sparkly thingies for map entities in edit mode
|
||||||
entity &e = ents[i];
|
entity &e = ents[i];
|
||||||
if (e.type == NOTUSED)
|
if (e.type == NOTUSED)
|
||||||
continue;
|
continue;
|
||||||
vec v = {(float)e.x, (float)e.y, (float)e.z};
|
OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
|
||||||
particle_splash(2, 2, 40, v);
|
particle_splash(2, 2, 40, v);
|
||||||
};
|
}
|
||||||
int e = closestent();
|
int e = closestent();
|
||||||
if (e >= 0) {
|
if (e >= 0) {
|
||||||
entity &c = ents[e];
|
entity &c = ents[e];
|
||||||
|
@ -226,7 +226,7 @@ COMMAND(loadsky, ARG_1STR)
|
||||||
float cursordepth = 0.9f;
|
float cursordepth = 0.9f;
|
||||||
GLint viewport[4];
|
GLint viewport[4];
|
||||||
GLdouble mm[16], pm[16];
|
GLdouble mm[16], pm[16];
|
||||||
vec worldpos;
|
OFVector3D worldpos;
|
||||||
|
|
||||||
void
|
void
|
||||||
readmatrices()
|
readmatrices()
|
||||||
|
@ -262,8 +262,8 @@ readdepth(int w, int h)
|
||||||
worldpos.x = (float)worldx;
|
worldpos.x = (float)worldx;
|
||||||
worldpos.y = (float)worldy;
|
worldpos.y = (float)worldy;
|
||||||
worldpos.z = (float)worldz;
|
worldpos.z = (float)worldz;
|
||||||
vec r = {(float)mm[0], (float)mm[4], (float)mm[8]};
|
OFVector3D r = OFMakeVector3D(mm[0], mm[4], mm[8]);
|
||||||
vec u = {(float)mm[1], (float)mm[5], (float)mm[9]};
|
OFVector3D u = OFMakeVector3D(mm[1], mm[5], mm[9]);
|
||||||
setorient(r, u);
|
setorient(r, u);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct md2 {
|
||||||
int numFrames;
|
int numFrames;
|
||||||
int numVerts;
|
int numVerts;
|
||||||
char *frames;
|
char *frames;
|
||||||
vec **mverts;
|
OFVector3D **mverts;
|
||||||
int displaylist;
|
int displaylist;
|
||||||
int displaylistverts;
|
int displaylistverts;
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ struct md2 {
|
||||||
bool loaded;
|
bool loaded;
|
||||||
|
|
||||||
bool load(char *filename);
|
bool load(char *filename);
|
||||||
void render(vec &light, int numFrame, int range, float x, float y,
|
void render(OFVector3D &light, int numFrame, int range, float x,
|
||||||
float z, float yaw, float pitch, float scale, float speed, int snap,
|
float y, float z, float yaw, float pitch, float scale, float speed,
|
||||||
int basetime);
|
int snap, int basetime);
|
||||||
void scale(int frame, float scale, int sn);
|
void scale(int frame, float scale, int sn);
|
||||||
|
|
||||||
md2()
|
md2()
|
||||||
|
@ -103,7 +103,7 @@ md2::load(char *filename)
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
mverts = new vec *[numFrames];
|
mverts = new OFVector3D *[numFrames];
|
||||||
loopj(numFrames) mverts[j] = NULL;
|
loopj(numFrames) mverts[j] = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -118,13 +118,13 @@ snap(int sn, float f)
|
||||||
void
|
void
|
||||||
md2::scale(int frame, float scale, int sn)
|
md2::scale(int frame, float scale, int sn)
|
||||||
{
|
{
|
||||||
mverts[frame] = new vec[numVerts];
|
mverts[frame] = new OFVector3D[numVerts];
|
||||||
md2_frame *cf = (md2_frame *)((char *)frames + frameSize * frame);
|
md2_frame *cf = (md2_frame *)((char *)frames + frameSize * frame);
|
||||||
float sc = 16.0f / scale;
|
float sc = 16.0f / scale;
|
||||||
loop(vi, numVerts)
|
loop(vi, numVerts)
|
||||||
{
|
{
|
||||||
uchar *cv = (uchar *)&cf->vertices[vi].vertex;
|
uchar *cv = (uchar *)&cf->vertices[vi].vertex;
|
||||||
vec *v = &(mverts[frame])[vi];
|
OFVector3D *v = &(mverts[frame])[vi];
|
||||||
v->x = (snap(sn, cv[0] * cf->scale[0]) + cf->translate[0]) / sc;
|
v->x = (snap(sn, cv[0] * cf->scale[0]) + cf->translate[0]) / sc;
|
||||||
v->y =
|
v->y =
|
||||||
-(snap(sn, cv[1] * cf->scale[1]) + cf->translate[1]) / sc;
|
-(snap(sn, cv[1] * cf->scale[1]) + cf->translate[1]) / sc;
|
||||||
|
@ -133,7 +133,7 @@ md2::scale(int frame, float scale, int sn)
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
md2::render(vec &light, int frame, int range, float x, float y, float z,
|
md2::render(OFVector3D &light, int frame, int range, float x, float y, float z,
|
||||||
float yaw, float pitch, float sc, float speed, int snap, int basetime)
|
float yaw, float pitch, float sc, float speed, int snap, int basetime)
|
||||||
{
|
{
|
||||||
loopi(range) if (!mverts[frame + i]) scale(frame + i, sc, snap);
|
loopi(range) if (!mverts[frame + i]) scale(frame + i, sc, snap);
|
||||||
|
@ -163,8 +163,8 @@ md2::render(vec &light, int frame, int range, float x, float y, float z,
|
||||||
int fr2 = fr1 + 1;
|
int fr2 = fr1 + 1;
|
||||||
if (fr2 >= frame + range)
|
if (fr2 >= frame + range)
|
||||||
fr2 = frame;
|
fr2 = frame;
|
||||||
vec *verts1 = mverts[fr1];
|
OFVector3D *verts1 = mverts[fr1];
|
||||||
vec *verts2 = mverts[fr2];
|
OFVector3D *verts2 = mverts[fr2];
|
||||||
|
|
||||||
for (int *command = glCommands; (*command) != 0;) {
|
for (int *command = glCommands; (*command) != 0;) {
|
||||||
int numVertex = *command++;
|
int numVertex = *command++;
|
||||||
|
@ -181,8 +181,8 @@ md2::render(vec &light, int frame, int range, float x, float y, float z,
|
||||||
float tv = *((float *)command++);
|
float tv = *((float *)command++);
|
||||||
glTexCoord2f(tu, tv);
|
glTexCoord2f(tu, tv);
|
||||||
int vn = *command++;
|
int vn = *command++;
|
||||||
vec &v1 = verts1[vn];
|
OFVector3D &v1 = verts1[vn];
|
||||||
vec &v2 = verts2[vn];
|
OFVector3D &v2 = verts2[vn];
|
||||||
#define ip(c) v1.c *frac2 + v2.c *frac1
|
#define ip(c) v1.c *frac2 + v2.c *frac1
|
||||||
glVertex3f(ip(x), ip(z), ip(y));
|
glVertex3f(ip(x), ip(z), ip(y));
|
||||||
};
|
};
|
||||||
|
@ -283,7 +283,7 @@ rendermodel(OFString *mdl, int frame, int range, int tex, float rad, float x,
|
||||||
|
|
||||||
int ix = (int)x;
|
int ix = (int)x;
|
||||||
int iy = (int)z;
|
int iy = (int)z;
|
||||||
vec light = {1.0f, 1.0f, 1.0f};
|
OFVector3D light = OFMakeVector3D(1, 1, 1);
|
||||||
|
|
||||||
if (!OUTBORD(ix, iy)) {
|
if (!OUTBORD(ix, iy)) {
|
||||||
sqr *s = S(ix, iy);
|
sqr *s = S(ix, iy);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
const int MAXPARTICLES = 10500;
|
const int MAXPARTICLES = 10500;
|
||||||
const int NUMPARTCUTOFF = 20;
|
const int NUMPARTCUTOFF = 20;
|
||||||
struct particle {
|
struct particle {
|
||||||
vec o, d;
|
OFVector3D o, d;
|
||||||
int fade, type;
|
int fade, type;
|
||||||
int millis;
|
int millis;
|
||||||
particle *next;
|
particle *next;
|
||||||
|
@ -16,7 +16,7 @@ bool parinit = false;
|
||||||
VARP(maxparticles, 100, 2000, MAXPARTICLES - 500);
|
VARP(maxparticles, 100, 2000, MAXPARTICLES - 500);
|
||||||
|
|
||||||
void
|
void
|
||||||
newparticle(vec &o, vec &d, int fade, int type)
|
newparticle(OFVector3D &o, OFVector3D &d, int fade, int type)
|
||||||
{
|
{
|
||||||
if (!parinit) {
|
if (!parinit) {
|
||||||
loopi(MAXPARTICLES)
|
loopi(MAXPARTICLES)
|
||||||
|
@ -42,22 +42,22 @@ newparticle(vec &o, vec &d, int fade, int type)
|
||||||
VAR(demotracking, 0, 0, 1);
|
VAR(demotracking, 0, 0, 1);
|
||||||
VARP(particlesize, 20, 100, 500);
|
VARP(particlesize, 20, 100, 500);
|
||||||
|
|
||||||
vec right, up;
|
OFVector3D right, up;
|
||||||
|
|
||||||
void
|
void
|
||||||
setorient(vec &r, vec &u)
|
setorient(OFVector3D &r, OFVector3D &u)
|
||||||
{
|
{
|
||||||
right = r;
|
right = r;
|
||||||
up = u;
|
up = u;
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
render_particles(int time)
|
render_particles(int time)
|
||||||
{
|
{
|
||||||
if (demoplayback && demotracking) {
|
if (demoplayback && demotracking) {
|
||||||
vec nom = {0, 0, 0};
|
OFVector3D nom = OFMakeVector3D(0, 0, 0);
|
||||||
newparticle(player1->o, nom, 100000000, 8);
|
newparticle(player1->o, nom, 100000000, 8);
|
||||||
};
|
}
|
||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -118,13 +118,13 @@ render_particles(int time)
|
||||||
if (pt->gr)
|
if (pt->gr)
|
||||||
p->o.z -= ((lastmillis - p->millis) / 3.0f) *
|
p->o.z -= ((lastmillis - p->millis) / 3.0f) *
|
||||||
curtime / (pt->gr * 10000);
|
curtime / (pt->gr * 10000);
|
||||||
vec a = p->d;
|
OFVector3D a = p->d;
|
||||||
vmul(a, time);
|
vmul(a, time);
|
||||||
vdiv(a, 20000.0f);
|
vdiv(a, 20000.0f);
|
||||||
vadd(p->o, a);
|
vadd(p->o, a);
|
||||||
pp = &p->next;
|
pp = &p->next;
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
glEnable(GL_FOG);
|
glEnable(GL_FOG);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
@ -132,7 +132,7 @@ render_particles(int time)
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
particle_splash(int type, int num, int fade, vec &p)
|
particle_splash(int type, int num, int fade, OFVector3D &p)
|
||||||
{
|
{
|
||||||
loopi(num)
|
loopi(num)
|
||||||
{
|
{
|
||||||
|
@ -143,22 +143,22 @@ particle_splash(int type, int num, int fade, vec &p)
|
||||||
y = rnd(radius * 2) - radius;
|
y = rnd(radius * 2) - radius;
|
||||||
z = rnd(radius * 2) - radius;
|
z = rnd(radius * 2) - radius;
|
||||||
} while (x * x + y * y + z * z > radius * radius);
|
} while (x * x + y * y + z * z > radius * radius);
|
||||||
vec d = {(float)x, (float)y, (float)z};
|
OFVector3D d = OFMakeVector3D(x, y, z);
|
||||||
newparticle(p, d, rnd(fade * 3), type);
|
newparticle(p, d, rnd(fade * 3), type);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
particle_trail(int type, int fade, vec &s, vec &e)
|
particle_trail(int type, int fade, OFVector3D &s, OFVector3D &e)
|
||||||
{
|
{
|
||||||
vdist(d, v, s, e);
|
vdist(d, v, s, e);
|
||||||
vdiv(v, d * 2 + 0.1f);
|
vdiv(v, d * 2 + 0.1f);
|
||||||
vec p = s;
|
OFVector3D p = s;
|
||||||
loopi((int)d * 2)
|
loopi((int)d * 2)
|
||||||
{
|
{
|
||||||
vadd(p, v);
|
vadd(p, v);
|
||||||
vec d = {
|
OFVector3D d =
|
||||||
float(rnd(11) - 5), float(rnd(11) - 5), float(rnd(11) - 5)};
|
OFMakeVector3D(rnd(11) - 5, rnd(11) - 5, rnd(11) - 5);
|
||||||
newparticle(p, d, rnd(fade) + fade, type);
|
newparticle(p, d, rnd(fade) + fade, type);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ gzputi(int i)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gzputv(vec &v)
|
gzputv(OFVector3D &v)
|
||||||
{
|
{
|
||||||
gzwrite(f, &v, sizeof(vec));
|
gzwrite(f, &v, sizeof(OFVector3D));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -59,9 +59,9 @@ gzgeti()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gzgetv(vec &v)
|
gzgetv(OFVector3D &v)
|
||||||
{
|
{
|
||||||
gzcheck(gzread(f, &v, sizeof(vec)), sizeof(vec));
|
gzcheck(gzread(f, &v, sizeof(OFVector3D)), sizeof(OFVector3D));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -244,7 +244,7 @@ loadgamerest()
|
||||||
int starttime = 0;
|
int starttime = 0;
|
||||||
int playbacktime = 0;
|
int playbacktime = 0;
|
||||||
int ddamage, bdamage;
|
int ddamage, bdamage;
|
||||||
vec dorig;
|
OFVector3D dorig;
|
||||||
|
|
||||||
void
|
void
|
||||||
record(OFString *name)
|
record(OFString *name)
|
||||||
|
@ -269,7 +269,7 @@ record(OFString *name)
|
||||||
COMMAND(record, ARG_1STR)
|
COMMAND(record, ARG_1STR)
|
||||||
|
|
||||||
void
|
void
|
||||||
demodamage(int damage, vec &o)
|
demodamage(int damage, OFVector3D &o)
|
||||||
{
|
{
|
||||||
ddamage = damage;
|
ddamage = damage;
|
||||||
dorig = o;
|
dorig = o;
|
||||||
|
@ -363,11 +363,12 @@ startdemo()
|
||||||
|
|
||||||
VAR(demodelaymsec, 0, 120, 500);
|
VAR(demodelaymsec, 0, 120, 500);
|
||||||
|
|
||||||
|
// spline interpolation
|
||||||
void
|
void
|
||||||
catmulrom(
|
catmulrom(OFVector3D &z, OFVector3D &a, OFVector3D &b, OFVector3D &c, float s,
|
||||||
vec &z, vec &a, vec &b, vec &c, float s, vec &dest) // spline interpolation
|
OFVector3D &dest)
|
||||||
{
|
{
|
||||||
vec t1 = b, t2 = c;
|
OFVector3D t1 = b, t2 = c;
|
||||||
|
|
||||||
vsub(t1, z);
|
vsub(t1, z);
|
||||||
vmul(t1, 0.5f) vsub(t2, a);
|
vmul(t1, 0.5f) vsub(t2, a);
|
||||||
|
@ -377,7 +378,7 @@ catmulrom(
|
||||||
float s3 = s * s2;
|
float s3 = s * s2;
|
||||||
|
|
||||||
dest = a;
|
dest = a;
|
||||||
vec t = b;
|
OFVector3D t = b;
|
||||||
|
|
||||||
vmul(dest, 2 * s3 - 3 * s2 + 1);
|
vmul(dest, 2 * s3 - 3 * s2 + 1);
|
||||||
vmul(t, -2 * s3 + 3 * s2);
|
vmul(t, -2 * s3 + 3 * s2);
|
||||||
|
@ -407,7 +408,7 @@ demoplaybackstep()
|
||||||
@"error: huge packet during demo play (%d)", len);
|
@"error: huge packet during demo play (%d)", len);
|
||||||
stopreset();
|
stopreset();
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
uchar buf[MAXTRANS];
|
uchar buf[MAXTRANS];
|
||||||
gzread(f, buf, len);
|
gzread(f, buf, len);
|
||||||
localservertoclient(buf, len); // update game state
|
localservertoclient(buf, len); // update game state
|
||||||
|
@ -434,9 +435,9 @@ demoplaybackstep()
|
||||||
if (ddamage = gzgeti()) {
|
if (ddamage = gzgeti()) {
|
||||||
gzgetv(dorig);
|
gzgetv(dorig);
|
||||||
particle_splash(3, ddamage, 1000, dorig);
|
particle_splash(3, ddamage, 1000, dorig);
|
||||||
};
|
}
|
||||||
// FIXME: set more client state here
|
// FIXME: set more client state here
|
||||||
};
|
}
|
||||||
|
|
||||||
// insert latest copy of player into history
|
// insert latest copy of player into history
|
||||||
if (extras &&
|
if (extras &&
|
||||||
|
@ -449,11 +450,11 @@ demoplaybackstep()
|
||||||
if (playerhistory.length() > 20) {
|
if (playerhistory.length() > 20) {
|
||||||
zapdynent(playerhistory[0]);
|
zapdynent(playerhistory[0]);
|
||||||
playerhistory.remove(0);
|
playerhistory.remove(0);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
readdemotime();
|
readdemotime();
|
||||||
};
|
}
|
||||||
|
|
||||||
if (demoplayback) {
|
if (demoplayback) {
|
||||||
int itime = lastmillis - demodelaymsec;
|
int itime = lastmillis - demodelaymsec;
|
||||||
|
@ -489,18 +490,19 @@ demoplaybackstep()
|
||||||
{
|
{
|
||||||
catmulrom(z->o, a->o, b->o, c->o, bf,
|
catmulrom(z->o, a->o, b->o, c->o, bf,
|
||||||
player1->o);
|
player1->o);
|
||||||
catmulrom(*(vec *)&z->yaw,
|
catmulrom(*(OFVector3D *)&z->yaw,
|
||||||
*(vec *)&a->yaw, *(vec *)&b->yaw,
|
*(OFVector3D *)&a->yaw,
|
||||||
*(vec *)&c->yaw, bf,
|
*(OFVector3D *)&b->yaw,
|
||||||
*(vec *)&player1->yaw);
|
*(OFVector3D *)&c->yaw, bf,
|
||||||
};
|
*(OFVector3D *)&player1->yaw);
|
||||||
|
}
|
||||||
fixplayer1range();
|
fixplayer1range();
|
||||||
};
|
}
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
// if(player1->state!=CS_DEAD) showscores(false);
|
// if(player1->state!=CS_DEAD) showscores(false);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
stopn()
|
stopn()
|
||||||
|
|
|
@ -16,7 +16,7 @@ bool nosound = false;
|
||||||
#define SOUNDFREQ 22050
|
#define SOUNDFREQ 22050
|
||||||
|
|
||||||
struct soundloc {
|
struct soundloc {
|
||||||
vec loc;
|
OFVector3D loc;
|
||||||
bool inuse;
|
bool inuse;
|
||||||
} soundlocs[MAXCHAN];
|
} soundlocs[MAXCHAN];
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ cleansound()
|
||||||
VAR(stereo, 0, 1, 1);
|
VAR(stereo, 0, 1, 1);
|
||||||
|
|
||||||
void
|
void
|
||||||
updatechanvol(int chan, vec *loc)
|
updatechanvol(int chan, OFVector3D *loc)
|
||||||
{
|
{
|
||||||
int vol = soundvol, pan = 255 / 2;
|
int vol = soundvol, pan = 255 / 2;
|
||||||
if (loc) {
|
if (loc) {
|
||||||
|
@ -178,7 +178,7 @@ updatechanvol(int chan, vec *loc)
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
newsoundloc(int chan, vec *loc)
|
newsoundloc(int chan, OFVector3D *loc)
|
||||||
{
|
{
|
||||||
assert(chan >= 0 && chan < MAXCHAN);
|
assert(chan >= 0 && chan < MAXCHAN);
|
||||||
soundlocs[chan].loc = *loc;
|
soundlocs[chan].loc = *loc;
|
||||||
|
@ -213,7 +213,7 @@ playsoundc(int n)
|
||||||
int soundsatonce = 0, lastsoundmillis = 0;
|
int soundsatonce = 0, lastsoundmillis = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
playsound(int n, vec *loc)
|
playsound(int n, OFVector3D *loc)
|
||||||
{
|
{
|
||||||
if (nosound)
|
if (nosound)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct guninfo {
|
||||||
const int MONSTERDAMAGEFACTOR = 4;
|
const int MONSTERDAMAGEFACTOR = 4;
|
||||||
const int SGRAYS = 20;
|
const int SGRAYS = 20;
|
||||||
const float SGSPREAD = 2;
|
const float SGSPREAD = 2;
|
||||||
vec sg[SGRAYS];
|
OFVector3D sg[SGRAYS];
|
||||||
|
|
||||||
guninfo guns[NUMGUNS] = {
|
guninfo guns[NUMGUNS] = {
|
||||||
{S_PUNCH1, 250, 50, 0, 0, 1, "fist"},
|
{S_PUNCH1, 250, 50, 0, 0, 1, "fist"},
|
||||||
|
@ -71,23 +71,25 @@ weapon(OFString *a1, OFString *a2, OFString *a3)
|
||||||
COMMAND(weapon, ARG_3STR)
|
COMMAND(weapon, ARG_3STR)
|
||||||
|
|
||||||
void
|
void
|
||||||
createrays(vec &from, vec &to) // create random spread of rays for the shotgun
|
createrays(OFVector3D &from,
|
||||||
|
OFVector3D &to) // create random spread of rays for the shotgun
|
||||||
{
|
{
|
||||||
vdist(dist, dvec, from, to);
|
vdist(dist, dvec, from, to);
|
||||||
float f = dist * SGSPREAD / 1000;
|
float f = dist * SGSPREAD / 1000;
|
||||||
loopi(SGRAYS)
|
loopi(SGRAYS)
|
||||||
{
|
{
|
||||||
#define RNDD (rnd(101) - 50) * f
|
#define RNDD (rnd(101) - 50) * f
|
||||||
vec r = {RNDD, RNDD, RNDD};
|
OFVector3D r = OFMakeVector3D(RNDD, RNDD, RNDD);
|
||||||
sg[i] = to;
|
sg[i] = to;
|
||||||
vadd(sg[i], r);
|
vadd(sg[i], r);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
intersect(dynent *d, vec &from, vec &to) // if lineseg hits entity bounding box
|
intersect(dynent *d, OFVector3D &from,
|
||||||
|
OFVector3D &to) // if lineseg hits entity bounding box
|
||||||
{
|
{
|
||||||
vec v = to, w = d->o, *p;
|
OFVector3D v = to, w = d->o, *p;
|
||||||
vsub(v, from);
|
vsub(v, from);
|
||||||
vsub(w, from);
|
vsub(w, from);
|
||||||
float c1 = dotprod(w, v);
|
float c1 = dotprod(w, v);
|
||||||
|
@ -129,7 +131,7 @@ playerincrosshair()
|
||||||
|
|
||||||
const int MAXPROJ = 100;
|
const int MAXPROJ = 100;
|
||||||
struct projectile {
|
struct projectile {
|
||||||
vec o, to;
|
OFVector3D o, to;
|
||||||
float speed;
|
float speed;
|
||||||
dynent *owner;
|
dynent *owner;
|
||||||
int gun;
|
int gun;
|
||||||
|
@ -144,8 +146,8 @@ projreset()
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
newprojectile(
|
newprojectile(OFVector3D &from, OFVector3D &to, float speed, bool local,
|
||||||
vec &from, vec &to, float speed, bool local, dynent *owner, int gun)
|
dynent *owner, int gun)
|
||||||
{
|
{
|
||||||
loopi(MAXPROJ)
|
loopi(MAXPROJ)
|
||||||
{
|
{
|
||||||
|
@ -182,7 +184,7 @@ const float RL_RADIUS = 5;
|
||||||
const float RL_DAMRAD = 7; // hack
|
const float RL_DAMRAD = 7; // hack
|
||||||
|
|
||||||
void
|
void
|
||||||
radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at)
|
radialeffect(dynent *o, OFVector3D &v, int cn, int qdam, dynent *at)
|
||||||
{
|
{
|
||||||
if (o->state != CS_ALIVE)
|
if (o->state != CS_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
@ -199,8 +201,8 @@ radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at)
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster,
|
splash(projectile *p, OFVector3D &v, OFVector3D &vold, int notthisplayer,
|
||||||
int qdam)
|
int notthismonster, int qdam)
|
||||||
{
|
{
|
||||||
particle_splash(0, 50, 300, v);
|
particle_splash(0, 50, 300, v);
|
||||||
p->inuse = false;
|
p->inuse = false;
|
||||||
|
@ -230,7 +232,7 @@ splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
projdamage(dynent *o, projectile *p, vec &v, int i, int im, int qdam)
|
projdamage(dynent *o, projectile *p, OFVector3D &v, int i, int im, int qdam)
|
||||||
{
|
{
|
||||||
if (o->state != CS_ALIVE)
|
if (o->state != CS_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
@ -264,14 +266,14 @@ moveprojectiles(float time)
|
||||||
if (!o)
|
if (!o)
|
||||||
continue;
|
continue;
|
||||||
projdamage(o, p, v, i, -1, qdam);
|
projdamage(o, p, v, i, -1, qdam);
|
||||||
};
|
}
|
||||||
if (p->owner != player1)
|
if (p->owner != player1)
|
||||||
projdamage(player1, p, v, -1, -1, qdam);
|
projdamage(player1, p, v, -1, -1, qdam);
|
||||||
dvector &mv = getmonsters();
|
dvector &mv = getmonsters();
|
||||||
loopv(mv) if (!vreject(mv[i]->o, v, 10.0f) &&
|
loopv(mv) if (!vreject(mv[i]->o, v, 10.0f) &&
|
||||||
mv[i] != p->owner)
|
mv[i] != p->owner)
|
||||||
projdamage(mv[i], p, v, -1, i, qdam);
|
projdamage(mv[i], p, v, -1, i, qdam);
|
||||||
};
|
}
|
||||||
if (p->inuse) {
|
if (p->inuse) {
|
||||||
if (time == dtime)
|
if (time == dtime)
|
||||||
splash(p, v, p->o, -1, -1, qdam);
|
splash(p, v, p->o, -1, -1, qdam);
|
||||||
|
@ -283,15 +285,15 @@ moveprojectiles(float time)
|
||||||
particle_splash(1, 1, 200, v);
|
particle_splash(1, 1, 200, v);
|
||||||
particle_splash(
|
particle_splash(
|
||||||
guns[p->gun].part, 1, 1, v);
|
guns[p->gun].part, 1, 1, v);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
p->o = v;
|
p->o = v;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
shootv(int gun, vec &from, vec &to, dynent *d,
|
shootv(int gun, OFVector3D &from, OFVector3D &to, dynent *d,
|
||||||
bool local) // create visual effect from a shot
|
bool local) // create visual effect from a shot
|
||||||
{
|
{
|
||||||
playsound(guns[gun].sound, d == player1 ? NULL : &d->o);
|
playsound(guns[gun].sound, d == player1 ? NULL : &d->o);
|
||||||
|
@ -328,16 +330,17 @@ shootv(int gun, vec &from, vec &to, dynent *d,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
hitpush(int target, int damage, dynent *d, dynent *at, vec &from, vec &to)
|
hitpush(int target, int damage, dynent *d, dynent *at, OFVector3D &from,
|
||||||
|
OFVector3D &to)
|
||||||
{
|
{
|
||||||
hit(target, damage, d, at);
|
hit(target, damage, d, at);
|
||||||
vdist(dist, v, from, to);
|
vdist(dist, v, from, to);
|
||||||
vmul(v, damage / dist / 50);
|
vmul(v, damage / dist / 50);
|
||||||
vadd(d->vel, v);
|
vadd(d->vel, v);
|
||||||
};
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
raydamage(dynent *o, vec &from, vec &to, dynent *d, int i)
|
raydamage(dynent *o, OFVector3D &from, OFVector3D &to, dynent *d, int i)
|
||||||
{
|
{
|
||||||
if (o->state != CS_ALIVE)
|
if (o->state != CS_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
@ -356,7 +359,7 @@ raydamage(dynent *o, vec &from, vec &to, dynent *d, int i)
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
shoot(dynent *d, vec &targ)
|
shoot(dynent *d, OFVector3D &targ)
|
||||||
{
|
{
|
||||||
int attacktime = lastmillis - d->lastaction;
|
int attacktime = lastmillis - d->lastaction;
|
||||||
if (attacktime < d->gunwait)
|
if (attacktime < d->gunwait)
|
||||||
|
@ -374,13 +377,13 @@ shoot(dynent *d, vec &targ)
|
||||||
};
|
};
|
||||||
if (d->gunselect)
|
if (d->gunselect)
|
||||||
d->ammo[d->gunselect]--;
|
d->ammo[d->gunselect]--;
|
||||||
vec from = d->o;
|
OFVector3D from = d->o;
|
||||||
vec to = targ;
|
OFVector3D to = targ;
|
||||||
from.z -= 0.2f; // below eye
|
from.z -= 0.2f; // below eye
|
||||||
|
|
||||||
vdist(dist, unitv, from, to);
|
vdist(dist, unitv, from, to);
|
||||||
vdiv(unitv, dist);
|
vdiv(unitv, dist);
|
||||||
vec kickback = unitv;
|
OFVector3D kickback = unitv;
|
||||||
vmul(kickback, guns[d->gunselect].kickamount * -0.01f);
|
vmul(kickback, guns[d->gunselect].kickamount * -0.01f);
|
||||||
vadd(d->vel, kickback);
|
vadd(d->vel, kickback);
|
||||||
if (d->pitch < 80.0f)
|
if (d->pitch < 80.0f)
|
||||||
|
|
|
@ -267,7 +267,7 @@ closestent() // used for delent and edit mode ent display
|
||||||
entity &e = ents[i];
|
entity &e = ents[i];
|
||||||
if (e.type == NOTUSED)
|
if (e.type == NOTUSED)
|
||||||
continue;
|
continue;
|
||||||
vec v = {(float)e.x, (float)e.y, (float)e.z};
|
OFVector3D v = OFMakeVector3D(e.x, e.y, e.z);
|
||||||
vdist(dist, t, player1->o, v);
|
vdist(dist, t, player1->o, v);
|
||||||
if (dist < bdist) {
|
if (dist < bdist) {
|
||||||
best = i;
|
best = i;
|
||||||
|
|
|
@ -200,7 +200,8 @@ cleardlights()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dodynlight(vec &vold, vec &v, int reach, int strength, dynent *owner)
|
dodynlight(
|
||||||
|
OFVector3D &vold, OFVector3D &v, int reach, int strength, dynent *owner)
|
||||||
{
|
{
|
||||||
if (!reach)
|
if (!reach)
|
||||||
reach = dynlight;
|
reach = dynlight;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue