2019-08-31 19:18:15 -07:00
|
|
|
/*
|
2020-04-07 05:46:23 -07:00
|
|
|
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
2019-08-31 19:18:15 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
2019-01-18 20:50:25 -08:00
|
|
|
|
2020-05-02 20:26:06 -07:00
|
|
|
#include "player.h"
|
2020-04-12 06:50:42 -07:00
|
|
|
#include "damage.h"
|
|
|
|
#include "flags.h"
|
|
|
|
#include "hitmesh.h"
|
2020-04-19 21:44:47 -07:00
|
|
|
#include "entities.h"
|
|
|
|
#include "events.h"
|
|
|
|
#include "flags.h"
|
|
|
|
#include "hitmesh.h"
|
|
|
|
#include "materials.h"
|
|
|
|
#include "math.h"
|
2020-05-02 14:57:25 -07:00
|
|
|
#include "sound.h"
|
2020-10-30 04:21:00 -07:00
|
|
|
#include "pmove.h"
|
2020-04-12 06:50:42 -07:00
|
|
|
|
2019-02-20 05:30:16 -08:00
|
|
|
/* Those are constant for HL BSP and CANNOT be changed.
|
|
|
|
* Blame Valve for purchasing a Quake II license but not
|
|
|
|
* scrapping hull sizes for their .bsp format... */
|
|
|
|
const vector VEC_HULL_MIN = [-16,-16,-36];
|
|
|
|
const vector VEC_HULL_MAX = [16,16,36];
|
|
|
|
const vector VEC_CHULL_MIN = [-16,-16,-18];
|
|
|
|
const vector VEC_CHULL_MAX = [16,16,18];
|
2019-01-18 20:50:25 -08:00
|
|
|
|
2019-08-31 19:18:15 -07:00
|
|
|
/* Counter-Strike players are hunched over a little bit */
|
2019-01-28 18:40:14 -08:00
|
|
|
#ifdef CSTRIKE
|
2019-08-31 19:18:15 -07:00
|
|
|
const vector VEC_PLAYER_VIEWPOS = [0,0,20];
|
2019-02-20 05:30:16 -08:00
|
|
|
const vector VEC_PLAYER_CVIEWPOS = [0,0,12];
|
2019-08-31 19:18:15 -07:00
|
|
|
#else
|
2019-02-20 05:30:16 -08:00
|
|
|
const vector VEC_PLAYER_VIEWPOS = [0,0,24];
|
|
|
|
const vector VEC_PLAYER_CVIEWPOS = [0,0,12];
|
2019-01-28 18:40:14 -08:00
|
|
|
#endif
|
2019-01-18 20:50:25 -08:00
|
|
|
|
|
|
|
// Actually used by input_button etc.
|
2019-08-31 19:18:15 -07:00
|
|
|
#define INPUT_BUTTON0 0x00000001
|
|
|
|
#define INPUT_BUTTON2 0x00000002
|
|
|
|
#define INPUT_BUTTON3 0x00000004
|
|
|
|
#define INPUT_BUTTON4 0x00000008
|
|
|
|
#define INPUT_BUTTON5 0x00000010
|
|
|
|
#define INPUT_BUTTON6 0x00000020
|
|
|
|
#define INPUT_BUTTON7 0x00000040
|
|
|
|
#define INPUT_BUTTON8 0x00000080
|
2019-01-18 20:50:25 -08:00
|
|
|
|
2020-04-12 06:50:42 -07:00
|
|
|
/* sendflags */
|
|
|
|
#define UPDATE_ALL 16777215
|
2019-09-28 16:54:29 -07:00
|
|
|
|
2019-01-18 20:50:25 -08:00
|
|
|
#define clamp(d,min,max) bound(min,d,max)
|
2019-03-24 17:49:27 -07:00
|
|
|
|
|
|
|
.float jumptime;
|
|
|
|
.float teleport_time;
|
2020-04-04 17:25:27 -07:00
|
|
|
.vector basevelocity;
|
2020-10-22 07:30:37 -07:00
|
|
|
.float gflags;
|
2019-09-01 02:45:42 -07:00
|
|
|
|
2020-04-19 21:44:47 -07:00
|
|
|
void*
|
|
|
|
memrealloc(__variant *oldptr, int elementsize, int oldelements, int newelements)
|
2019-09-01 02:45:42 -07:00
|
|
|
{
|
2020-04-12 06:50:42 -07:00
|
|
|
void *n = memalloc(elementsize * newelements);
|
|
|
|
memcpy(n, oldptr, elementsize * min(oldelements, newelements));
|
|
|
|
memfree(oldptr);
|
2019-09-01 02:45:42 -07:00
|
|
|
return n;
|
|
|
|
}
|
2019-09-02 19:58:49 -07:00
|
|
|
|
2020-04-19 21:44:47 -07:00
|
|
|
__wrap __variant*
|
|
|
|
memalloc(int size)
|
2020-04-12 10:40:09 -07:00
|
|
|
{
|
|
|
|
return prior(size);
|
|
|
|
}
|
|
|
|
|
2020-04-19 21:44:47 -07:00
|
|
|
void
|
|
|
|
Empty(void)
|
2019-09-02 19:58:49 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2019-11-08 17:09:17 -08:00
|
|
|
|
2020-04-19 21:44:47 -07:00
|
|
|
void
|
|
|
|
Util_Destroy(void)
|
2019-11-08 17:09:17 -08:00
|
|
|
{
|
|
|
|
remove(self);
|
|
|
|
}
|
|
|
|
|
2020-04-19 21:44:47 -07:00
|
|
|
__wrap void
|
|
|
|
dprint(string m)
|
2020-03-31 00:28:40 -07:00
|
|
|
{
|
|
|
|
if (cvar("developer") == 1)
|
|
|
|
return prior(m);
|
|
|
|
}
|
2020-04-19 03:02:05 -07:00
|
|
|
|
2020-05-02 14:57:25 -07:00
|
|
|
__wrap string
|
|
|
|
precache_model(string m)
|
|
|
|
{
|
|
|
|
#ifdef CLIENT
|
|
|
|
dprint(sprintf("^3Client precaching model ^7%s\n", m));
|
|
|
|
#else
|
|
|
|
dprint(sprintf("^3Server precaching model ^7%s\n", m));
|
|
|
|
#endif
|
|
|
|
return prior(m);
|
|
|
|
}
|
|
|
|
|
2020-04-19 03:02:05 -07:00
|
|
|
/* info print */
|
|
|
|
void
|
|
|
|
iprint(string m)
|
|
|
|
{
|
|
|
|
print(sprintf("^Ue080^Ue081^Ue081^Ue081^Ue081^Ue081^Ue081 %s ^Ue081^Ue081^Ue081^Ue081^Ue081^Ue081^Ue082\n", m));
|
|
|
|
}
|