2020-04-15 18:39:17 +02:00
|
|
|
// the interface the game uses to access the engine
|
|
|
|
|
|
|
|
extern int curtime; // current frame time
|
|
|
|
extern int lastmillis; // last time
|
|
|
|
extern int elapsedtime; // elapsed frame time
|
|
|
|
extern int totalmillis; // total elapsed time
|
|
|
|
extern int gamespeed, paused;
|
|
|
|
|
|
|
|
extern void lightent(extentity &e, float height = 8.0f);
|
|
|
|
extern void lightreaching(const vec &target, vec &color, vec &dir, bool fast = false, extentity *e = 0, float minambient = 0.4f);
|
|
|
|
|
|
|
|
enum { RAY_BB = 1, RAY_POLY = 3, RAY_ALPHAPOLY = 7, RAY_ENTS = 9, RAY_CLIPMAT = 16, RAY_SKIPFIRST = 32, RAY_EDITMAT = 64, RAY_SHADOW = 128, RAY_PASS = 256, RAY_SKIPSKY = 512 };
|
|
|
|
|
|
|
|
extern float raycube (const vec &o, const vec &ray, float radius = 0, int mode = RAY_CLIPMAT, int size = 0, extentity *t = 0);
|
|
|
|
extern float raycubepos(const vec &o, const vec &ray, vec &hit, float radius = 0, int mode = RAY_CLIPMAT, int size = 0);
|
|
|
|
extern float rayfloor (const vec &o, vec &floor, int mode = 0, float radius = 0);
|
|
|
|
extern bool raycubelos(const vec &o, const vec &dest, vec &hitpos);
|
|
|
|
|
|
|
|
extern int thirdperson;
|
|
|
|
extern bool isthirdperson();
|
|
|
|
|
|
|
|
// octaedit
|
|
|
|
|
|
|
|
enum { EDIT_FACE = 0, EDIT_TEX, EDIT_MAT, EDIT_FLIP, EDIT_COPY, EDIT_PASTE, EDIT_ROTATE, EDIT_REPLACE, EDIT_DELCUBE, EDIT_CALCLIGHT, EDIT_REMIP, EDIT_VSLOT, EDIT_UNDO, EDIT_REDO };
|
|
|
|
|
2020-04-28 04:02:15 +02:00
|
|
|
struct selinfo;
|
2020-04-15 18:39:17 +02:00
|
|
|
struct editinfo;
|
|
|
|
extern editinfo *localedit;
|
|
|
|
|
|
|
|
extern bool editmode;
|
|
|
|
|
|
|
|
extern int shouldpacktex(int index);
|
|
|
|
extern bool packeditinfo(editinfo *e, int &inlen, uchar *&outbuf, int &outlen);
|
|
|
|
extern bool unpackeditinfo(editinfo *&e, const uchar *inbuf, int inlen, int outlen);
|
|
|
|
extern void freeeditinfo(editinfo *&e);
|
|
|
|
extern void pruneundos(int maxremain = 0);
|
|
|
|
extern bool packundo(int op, int &inlen, uchar *&outbuf, int &outlen);
|
|
|
|
extern bool unpackundo(const uchar *inbuf, int inlen, int outlen);
|
|
|
|
extern bool noedit(bool view = false, bool msg = true);
|
|
|
|
extern void toggleedit(bool force = true);
|
|
|
|
extern void mpeditface(int dir, int mode, selinfo &sel, bool local);
|
|
|
|
extern void mpedittex(int tex, int allfaces, selinfo &sel, bool local);
|
|
|
|
extern bool mpedittex(int tex, int allfaces, selinfo &sel, ucharbuf &buf);
|
|
|
|
extern void mpeditmat(int matid, int filter, selinfo &sel, bool local);
|
|
|
|
extern void mpflip(selinfo &sel, bool local);
|
|
|
|
extern void mpcopy(editinfo *&e, selinfo &sel, bool local);
|
|
|
|
extern void mppaste(editinfo *&e, selinfo &sel, bool local);
|
|
|
|
extern void mprotate(int cw, selinfo &sel, bool local);
|
|
|
|
extern void mpreplacetex(int oldtex, int newtex, bool insel, selinfo &sel, bool local);
|
|
|
|
extern bool mpreplacetex(int oldtex, int newtex, bool insel, selinfo &sel, ucharbuf &buf);
|
|
|
|
extern void mpdelcube(selinfo &sel, bool local);
|
|
|
|
extern void mpremip(bool local);
|
|
|
|
extern bool mpeditvslot(int delta, int allfaces, selinfo &sel, ucharbuf &buf);
|
|
|
|
extern void mpcalclight(bool local);
|
|
|
|
|
|
|
|
// command
|
|
|
|
extern int variable(const char *name, int min, int cur, int max, int *storage, identfun fun, int flags);
|
|
|
|
extern float fvariable(const char *name, float min, float cur, float max, float *storage, identfun fun, int flags);
|
|
|
|
extern char *svariable(const char *name, const char *cur, char **storage, identfun fun, int flags);
|
|
|
|
extern void setvar(const char *name, int i, bool dofunc = true, bool doclamp = true);
|
|
|
|
extern void setfvar(const char *name, float f, bool dofunc = true, bool doclamp = true);
|
|
|
|
extern void setsvar(const char *name, const char *str, bool dofunc = true);
|
|
|
|
extern void setvarchecked(ident *id, int val);
|
|
|
|
extern void setfvarchecked(ident *id, float val);
|
|
|
|
extern void setsvarchecked(ident *id, const char *val);
|
|
|
|
extern void touchvar(const char *name);
|
|
|
|
extern int getvar(const char *name);
|
|
|
|
extern int getvarmin(const char *name);
|
|
|
|
extern int getvarmax(const char *name);
|
|
|
|
extern bool identexists(const char *name);
|
|
|
|
extern ident *getident(const char *name);
|
|
|
|
extern ident *newident(const char *name, int flags = 0);
|
|
|
|
extern ident *readident(const char *name);
|
|
|
|
extern ident *writeident(const char *name, int flags = 0);
|
|
|
|
extern bool addcommand(const char *name, identfun fun, const char *narg, int type = ID_COMMAND);
|
|
|
|
extern uint *compilecode(const char *p);
|
|
|
|
extern void keepcode(uint *p);
|
|
|
|
extern void freecode(uint *p);
|
|
|
|
extern void executeret(const uint *code, tagval &result = *commandret);
|
|
|
|
extern void executeret(const char *p, tagval &result = *commandret);
|
|
|
|
extern void executeret(ident *id, tagval *args, int numargs, bool lookup = false, tagval &result = *commandret);
|
|
|
|
extern char *executestr(const uint *code);
|
|
|
|
extern char *executestr(const char *p);
|
|
|
|
extern char *executestr(ident *id, tagval *args, int numargs, bool lookup = false);
|
|
|
|
extern char *execidentstr(const char *name, bool lookup = false);
|
|
|
|
extern int execute(const uint *code);
|
|
|
|
extern int execute(const char *p);
|
|
|
|
extern int execute(ident *id, tagval *args, int numargs, bool lookup = false);
|
|
|
|
extern int execident(const char *name, int noid = 0, bool lookup = false);
|
|
|
|
extern float executefloat(const uint *code);
|
|
|
|
extern float executefloat(const char *p);
|
|
|
|
extern float executefloat(ident *id, tagval *args, int numargs, bool lookup = false);
|
|
|
|
extern float execidentfloat(const char *name, float noid = 0, bool lookup = false);
|
|
|
|
extern bool executebool(const uint *code);
|
|
|
|
extern bool executebool(const char *p);
|
|
|
|
extern bool executebool(ident *id, tagval *args, int numargs, bool lookup = false);
|
|
|
|
extern bool execidentbool(const char *name, bool noid = false, bool lookup = false);
|
|
|
|
extern bool execfile(const char *cfgfile, bool msg = true);
|
|
|
|
extern void alias(const char *name, const char *action);
|
|
|
|
extern void alias(const char *name, tagval &v);
|
|
|
|
extern const char *getalias(const char *name);
|
|
|
|
extern const char *escapestring(const char *s);
|
|
|
|
extern const char *escapeid(const char *s);
|
|
|
|
static inline const char *escapeid(ident &id) { return escapeid(id.name); }
|
|
|
|
extern bool validateblock(const char *s);
|
|
|
|
extern void explodelist(const char *s, vector<char *> &elems, int limit = -1);
|
|
|
|
extern char *indexlist(const char *s, int pos);
|
|
|
|
extern int listlen(const char *s);
|
|
|
|
extern void printvar(ident *id);
|
|
|
|
extern void printvar(ident *id, int i);
|
|
|
|
extern void printfvar(ident *id, float f);
|
|
|
|
extern void printsvar(ident *id, const char *s);
|
|
|
|
extern int clampvar(ident *id, int i, int minval, int maxval);
|
|
|
|
extern float clampfvar(ident *id, float f, float minval, float maxval);
|
|
|
|
extern void loopiter(ident *id, identstack &stack, const tagval &v);
|
|
|
|
extern void loopend(ident *id, identstack &stack);
|
|
|
|
|
|
|
|
#define loopstart(id, stack) if((id)->type != ID_ALIAS) return; identstack stack;
|
|
|
|
static inline void loopiter(ident *id, identstack &stack, int i) { tagval v; v.setint(i); loopiter(id, stack, v); }
|
|
|
|
static inline void loopiter(ident *id, identstack &stack, float f) { tagval v; v.setfloat(f); loopiter(id, stack, v); }
|
|
|
|
static inline void loopiter(ident *id, identstack &stack, const char *s) { tagval v; v.setstr(newstring(s)); loopiter(id, stack, v); }
|
|
|
|
|
|
|
|
// console
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CON_INFO = 1<<0,
|
|
|
|
CON_WARN = 1<<1,
|
|
|
|
CON_ERROR = 1<<2,
|
|
|
|
CON_DEBUG = 1<<3,
|
|
|
|
CON_INIT = 1<<4,
|
|
|
|
CON_ECHO = 1<<5
|
|
|
|
};
|
|
|
|
|
|
|
|
extern void conoutf(const char *s, ...) PRINTFARGS(1, 2);
|
|
|
|
extern void conoutf(int type, const char *s, ...) PRINTFARGS(2, 3);
|
|
|
|
extern void conoutfv(int type, const char *fmt, va_list args);
|
|
|
|
|
|
|
|
// main
|
|
|
|
extern void fatal(const char *s, ...) PRINTFARGS(1, 2);
|
|
|
|
|
|
|
|
// texture
|
|
|
|
|
|
|
|
struct VSlot;
|
|
|
|
|
|
|
|
// dynlight
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
DL_SHRINK = 1<<8,
|
|
|
|
DL_EXPAND = 1<<9,
|
|
|
|
DL_FLASH = 1<<10
|
|
|
|
};
|
|
|
|
|
|
|
|
extern void adddynlight(const vec &o, float radius, const vec &color, int fade = 0, int peak = 0, int flags = 0, float initradius = 0, const vec &initcolor = vec(0, 0, 0), physent *owner = NULL, const vec &dir = vec(0, 0, 0), int spot = 0);
|
|
|
|
extern void dynlightreaching(const vec &target, vec &color, vec &dir, bool hud = false);
|
|
|
|
extern void removetrackeddynlights(physent *owner = NULL);
|
|
|
|
|
|
|
|
// rendergl
|
|
|
|
extern physent *camera1;
|
|
|
|
extern vec worldpos, camdir, camright, camup;
|
|
|
|
extern float curfov, fovy, aspect;
|
|
|
|
|
|
|
|
extern void disablezoom();
|
|
|
|
|
|
|
|
extern vec calcavatarpos(const vec &pos, float dist);
|
|
|
|
extern vec calcmodelpreviewpos(const vec &radius, float &yaw);
|
|
|
|
|
|
|
|
extern void damageblend(int n);
|
|
|
|
extern void damagecompass(int n, const vec &loc);
|
|
|
|
|
|
|
|
extern vec minimapcenter, minimapradius, minimapscale;
|
|
|
|
extern void bindminimap();
|
|
|
|
|
|
|
|
extern matrix4 hudmatrix;
|
|
|
|
extern void resethudmatrix();
|
|
|
|
extern void pushhudmatrix();
|
|
|
|
extern void flushhudmatrix(bool flushparams = true);
|
|
|
|
extern void pophudmatrix(bool flush = true, bool flushparams = true);
|
|
|
|
extern void pushhudscale(float sx, float sy = 0);
|
|
|
|
extern void pushhudtranslate(float tx, float ty, float sx = 0, float sy = 0);
|
|
|
|
extern void resethudshader();
|
|
|
|
|
|
|
|
// stain
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
STAIN_BLOOD = 0,
|
|
|
|
STAIN_PULSE_SCORCH,
|
|
|
|
STAIN_RAIL_HOLE,
|
|
|
|
STAIN_PULSE_GLOW,
|
|
|
|
STAIN_RAIL_GLOW
|
|
|
|
};
|
|
|
|
|
|
|
|
extern void addstain(int type, const vec ¢er, const vec &surface, float radius, const bvec &color = bvec(0xFF, 0xFF, 0xFF), int info = 0);
|
|
|
|
|
|
|
|
static inline void addstain(int type, const vec ¢er, const vec &surface, float radius, int color, int info = 0)
|
|
|
|
{
|
|
|
|
addstain(type, center, surface, radius, bvec::hexcolor(color), info);
|
|
|
|
}
|
|
|
|
|
|
|
|
// physics
|
|
|
|
extern vec collidewall;
|
|
|
|
extern int collideinside;
|
|
|
|
extern physent *collideplayer;
|
|
|
|
|
|
|
|
extern void moveplayer(physent *pl, int moveres, bool local);
|
|
|
|
extern bool moveplayer(physent *pl, int moveres, bool local, int curtime);
|
|
|
|
extern void crouchplayer(physent *pl, int moveres, bool local);
|
|
|
|
extern bool collide(physent *d, const vec &dir = vec(0, 0, 0), float cutoff = 0.0f, bool playercol = true, bool insideplayercol = false);
|
|
|
|
extern bool bounce(physent *d, float secs, float elasticity, float waterfric, float grav);
|
|
|
|
extern bool bounce(physent *d, float elasticity, float waterfric, float grav);
|
|
|
|
extern void avoidcollision(physent *d, const vec &dir, physent *obstacle, float space);
|
|
|
|
extern bool overlapsdynent(const vec &o, float radius);
|
|
|
|
extern bool movecamera(physent *pl, const vec &dir, float dist, float stepdist);
|
|
|
|
extern void physicsframe();
|
|
|
|
extern void dropenttofloor(entity *e);
|
|
|
|
extern bool droptofloor(vec &o, float radius, float height);
|
|
|
|
|
|
|
|
extern void vecfromyawpitch(float yaw, float pitch, int move, int strafe, vec &m);
|
|
|
|
extern void vectoyawpitch(const vec &v, float &yaw, float &pitch);
|
|
|
|
extern void updatephysstate(physent *d);
|
|
|
|
extern void cleardynentcache();
|
|
|
|
extern void updatedynentcache(physent *d);
|
|
|
|
extern bool entinmap(dynent *d, bool avoidplayers = false);
|
|
|
|
extern void findplayerspawn(dynent *d, int forceent = -1, int tag = 0);
|
|
|
|
|
|
|
|
// sound
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SND_MAP = 1<<0,
|
|
|
|
SND_NO_ALT = 1<<1,
|
|
|
|
SND_USE_ALT = 1<<2
|
|
|
|
};
|
|
|
|
|
2020-04-16 20:13:59 +02:00
|
|
|
inline int playsound(
|
|
|
|
int, const vec * = NULL, extentity * = NULL, int = 0, int = 0, int = 0,
|
|
|
|
int = -1, int = 0, int = -1
|
|
|
|
) {
|
|
|
|
return -1;
|
|
|
|
}
|
2020-04-15 18:39:17 +02:00
|
|
|
|
|
|
|
// rendermodel
|
|
|
|
enum { MDL_CULL_VFC = 1<<0, MDL_CULL_DIST = 1<<1, MDL_CULL_OCCLUDED = 1<<2, MDL_CULL_QUERY = 1<<3, MDL_FULLBRIGHT = 1<<4, MDL_NORENDER = 1<<5, MDL_MAPMODEL = 1<<6, MDL_NOBATCH = 1<<7, MDL_ONLYSHADOW = 1<<8, MDL_NOSHADOW = 1<<9, MDL_FORCESHADOW = 1<<10, MDL_FORCETRANSPARENT = 1<<11 };
|
|
|
|
|
|
|
|
struct model;
|
|
|
|
struct modelattach
|
|
|
|
{
|
|
|
|
const char *tag, *name;
|
|
|
|
int anim, basetime;
|
|
|
|
vec *pos;
|
|
|
|
model *m;
|
|
|
|
|
|
|
|
modelattach() : tag(NULL), name(NULL), anim(-1), basetime(0), pos(NULL), m(NULL) {}
|
|
|
|
modelattach(const char *tag, const char *name, int anim = -1, int basetime = 0) : tag(tag), name(name), anim(anim), basetime(basetime), pos(NULL), m(NULL) {}
|
|
|
|
modelattach(const char *tag, vec *pos) : tag(tag), name(NULL), anim(-1), basetime(0), pos(pos), m(NULL) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern void rendermodel(const char *mdl, int anim, const vec &o, float yaw = 0, float pitch = 0, float roll = 0, int cull = MDL_CULL_VFC | MDL_CULL_DIST | MDL_CULL_OCCLUDED, dynent *d = NULL, modelattach *a = NULL, int basetime = 0, int basetime2 = 0, float size = 1, const vec4 &color = vec4(1, 1, 1, 1));
|
|
|
|
extern int intersectmodel(const char *mdl, int anim, const vec &pos, float yaw, float pitch, float roll, const vec &o, const vec &ray, float &dist, int mode = 0, dynent *d = NULL, modelattach *a = NULL, int basetime = 0, int basetime2 = 0, float size = 1);
|
|
|
|
extern void abovemodel(vec &o, const char *mdl);
|
|
|
|
extern void renderclient(dynent *d, const char *mdlname, modelattach *attachments, int hold, int attack, int attackdelay, int lastaction, int lastpain, float scale = 1, bool ragdoll = false, float trans = 1);
|
|
|
|
extern void interpolateorientation(dynent *d, float &interpyaw, float &interppitch);
|
|
|
|
extern void setbbfrommodel(dynent *d, const char *mdl);
|
|
|
|
extern const char *mapmodelname(int i);
|
|
|
|
extern model *loadmodel(const char *name, int i = -1, bool msg = false);
|
|
|
|
extern void preloadmodel(const char *name);
|
|
|
|
extern void flushpreloadedmodels(bool msg = true);
|
|
|
|
extern bool matchanim(const char *name, const char *pattern);
|
|
|
|
|
|
|
|
// ragdoll
|
|
|
|
|
|
|
|
extern void moveragdoll(dynent *d);
|
|
|
|
extern void cleanragdoll(dynent *d);
|
|
|
|
|
|
|
|
// client
|
2020-04-26 00:20:00 +02:00
|
|
|
extern bool haslocalclients();
|
2020-04-15 18:39:17 +02:00
|
|
|
extern bool isconnected(bool attempt = false, bool local = true);
|
|
|
|
extern bool multiplayer(bool msg = true);
|