forked from itslunaranyo/copper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subs.qc
133 lines (107 loc) · 2.69 KB
/
subs.qc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
================================================================
MISC SUBSTITUTION FUNCTIONS
================================================================
*/
void() SUB_Null = {}
/*
=============
SUB_Remove/SUB_RemoveSoon
RemoveSoon is to be used during touch functions to avoid touchlinks errors
===============
*/
void() SUB_Remove = { remove(self); }
void() SUB_RemoveSoon =
{
// ensure no shenanigans take place in the next hundredth of a second
// otherwise we get weirdness like items being picked up twice at high framerates
self.model = string_null;
self.solid = SOLID_NOT;
self.touch = SUB_Null;
self.use = SUB_Null;
self.think = SUB_Remove;
self.nextthink = time;
}
/*
=============
RemoveTarget
take an entity out of gameplay (independent of 'killing' it)
===============
*/
void(entity victim) RemoveTarget =
{
// iw -- don't change kill count when removing a dead monster
if (victim.flags & FL_MONSTER && victim.deadflag == DEAD_NO && !(victim.customflags & CFL_SPAWNER))
addmonster(-1); // since the player won't get credit for the kill
// clean up door triggers so they don't get lonely and crash
if (victim.trigger_field != world)
remove(victim.trigger_field);
// silence movers
sound(victim, CHAN_VOICE, "misc/null.wav", 1, 1);
remove (victim);
}
/*
=============
SUB_CallAsSelf
wrap the self/oself shuffle for code cleanliness elsewhere
===============
*/
void(void() fun, entity newself) SUB_CallAsSelf =
{
local entity oself;
oself = self;
self = newself;
fun();
self = oself;
}
/*
=============
SUB_ChangeModel
size changes after a model change, use this to preserve it
===============
*/
void(entity ent, string mdl) SUB_ChangeModel =
{
local vector sz,smin,smax;
sz = ent.size;
smin = ent.mins;
smax = ent.maxs;
setmodel(ent, mdl);
if (sz == VEC_ORIGIN)
setsize(ent, VEC_ORIGIN, VEC_ORIGIN);
else
setsize(ent, smin, smax);
}
/*
void(float frame, void() th, float thtime) SUB_FrameThinkTime
{
self.frame = frame;
self.think = th;
self.nextthink = time + thtime;
}
*/
/*
===============
SUB_ShouldSpawn
===============
*/
float() SUB_ShouldSpawn =
{
// do a minimum-version check so cheeky mappers can place surprise
// trigger_hurts to frag people who don't upgrade
if (self.version && self.version <= version_f)
{
remove(self);
return FALSE;
}
// check coop spawn flags, because we invented them and the exe only
// checks skill/dm flags
if (self.spawnflags & SPAWN_COOPONLY && self.spawnflags & SPAWN_NOTCOOP)
objerror("cooponly and notincoop flags both set on the same entity");
if ( ((self.spawnflags & SPAWN_NOTCOOP) && coop) || ((self.spawnflags & SPAWN_COOPONLY) && !(coop)) )
{
remove(self);
return FALSE;
}
return TRUE;
}