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"
|
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-10-31 06:32:23 -07:00
|
|
|
#include "memory.h"
|
2021-03-23 23:50:30 -07:00
|
|
|
#include "spectator.h"
|
2021-06-18 00:26:24 -07:00
|
|
|
#include "platform.h"
|
2021-09-17 10:31:22 -07:00
|
|
|
#include "propdata.h"
|
2021-10-15 09:06:04 -07:00
|
|
|
#include "surfaceproperties.h"
|
2021-08-19 08:54:08 -07:00
|
|
|
#include "vehicles.h"
|
2020-04-12 06:50:42 -07:00
|
|
|
|
2020-12-07 09:16:45 -08:00
|
|
|
#define BSPVER_PREREL 28
|
|
|
|
#define BSPVER_Q1 29
|
|
|
|
#define BSPVER_HL 30
|
|
|
|
#define BSPVER_Q2 38
|
2020-12-08 03:00:10 -08:00
|
|
|
#define BSPVER_Q2W 69
|
2020-12-07 09:16:45 -08:00
|
|
|
#define BSPVER_Q3 46
|
|
|
|
#define BSPVER_RTCW 47
|
|
|
|
#define BSPVER_RBSP 1
|
|
|
|
|
2020-12-01 03:32:42 -08:00
|
|
|
#define CLASSEXPORT(classname,classa) void classname(void) { spawnfunc_##classa(); }
|
|
|
|
|
2021-06-18 00:26:24 -07:00
|
|
|
#define printf(x, ...) print(sprintf(x, ...))
|
2021-05-16 14:08:08 -07:00
|
|
|
|
2019-02-20 05:30:16 -08:00
|
|
|
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
|
|
|
|
|
|
|
// 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
|
|
|
|
2020-12-28 10:59:37 -08:00
|
|
|
enumflags
|
|
|
|
{
|
|
|
|
SEARCH_INSENSITIVE,
|
|
|
|
SEARCH_FULLPACKAGE,
|
|
|
|
SEARCH_ALLOWDUPES,
|
|
|
|
SEARCH_FORCESEARCH,
|
|
|
|
SEARCH_MULTISEARCH,
|
|
|
|
SEARCH_NAMESORT
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:18:36 -07:00
|
|
|
string
|
|
|
|
Util_TimeToString(float fTime)
|
|
|
|
{
|
|
|
|
fTime = rint(fTime);
|
|
|
|
|
|
|
|
switch (fTime) {
|
|
|
|
case 0: return "less than one";
|
|
|
|
case 1: return "one";
|
|
|
|
case 2: return "two";
|
|
|
|
case 3: return "three";
|
|
|
|
case 4: return "four";
|
|
|
|
case 5: return "five";
|
|
|
|
case 6: return "six";
|
|
|
|
case 7: return "seven";
|
|
|
|
case 8: return "eight";
|
|
|
|
case 9: return "nine";
|
|
|
|
case 10: return "ten";
|
|
|
|
default: return "over ten";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-09-15 13:44:31 -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));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
crossprint(string m)
|
|
|
|
{
|
|
|
|
#ifdef CLIENT
|
|
|
|
print(strcat("CLIENT: ", m));
|
|
|
|
#else
|
|
|
|
print(strcat("SERVER: ", m));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-09-01 06:17:35 -07:00
|
|
|
/* this could probably be a lot better, use this from now on so that it can be improved later */
|
2021-09-15 13:44:31 -07:00
|
|
|
noref float input_sequence;
|
2021-09-01 06:17:35 -07:00
|
|
|
float
|
|
|
|
pseudorandom()
|
|
|
|
{
|
2021-09-02 00:47:48 -07:00
|
|
|
float seed = (float)input_sequence % 5;
|
|
|
|
seed += (float)input_sequence % 8;
|
|
|
|
seed += (float)input_sequence % 4;
|
|
|
|
seed += (float)input_sequence % 13;
|
|
|
|
seed += (float)input_sequence % 70;
|
2021-09-01 06:17:35 -07:00
|
|
|
|
|
|
|
/* like the engine its random(), never return 0, never return 1 */
|
2021-09-02 00:47:48 -07:00
|
|
|
return bound(0.01, (seed) / 100.0f, 0.99f);
|
2021-09-01 06:17:35 -07:00
|
|
|
}
|
|
|
|
|
2021-06-01 03:40:53 -07:00
|
|
|
__wrap void
|
|
|
|
setmodel(entity ent, string mname)
|
|
|
|
{
|
|
|
|
if (mname != "") /* not empty */
|
|
|
|
if (substring(mname, 0, 1) != "*") /* not a brush */
|
|
|
|
if not(whichpack(mname)) /* not present on disk */
|
|
|
|
return prior(ent, "models/error.vvm");
|
|
|
|
|
|
|
|
return prior(ent, mname);
|
|
|
|
}
|
|
|
|
|
2021-09-11 15:12:55 -07:00
|
|
|
void
|
|
|
|
setorigin_safe(entity target, vector testorg)
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
tracebox(testorg, target.mins, target.maxs, testorg, MOVE_NORMAL, target);
|
|
|
|
|
|
|
|
if (!trace_startsolid) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
testorg[2] += 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
setorigin(target, testorg);
|
2021-09-15 13:44:31 -07:00
|
|
|
}
|