This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
hiptrig.qc
238 lines (194 loc) · 6.2 KB
/
hiptrig.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//Selections from hiptrig.qc NOT the entire file
/* Trigger QuickC program
By Jim Dose' 12/2/96
Copyright (c)1996 Hipnotic Interactive, Inc.
All rights reserved.
Do not distribute.
*/
float USE_SILV_KEY = 8;
float USE_GOLD_KEY = 16;
/*
================
keytrigger_unlock
Perform the actions which should be performed when self is successfully
unlocked with a key.
This function exists so that it can be passed as an argument to the new
keylock_try_to_unlock function. This code was previously part of the
keytrigger_use function. -- iw
================
*/
void() keytrigger_unlock =
{
// we can't just remove (self) here, because this is a touch function
// called while C code is looping through area links...
self.touch = SUB_Null;
self.use = SUB_Null;
self.nextthink = time + 0.1;
self.think = SUB_Remove;
self.message = "";
SUB_UseTargets();
};
void() keytrigger_use =
{
// from Copper -- dumptruck_ds
if (!CheckValidTouch()) return;
if (self.attack_finished > time)
return;
self.attack_finished = time + 2;
keylock_try_to_unlock (activator, self.message, keytrigger_unlock);
};
void() keytrigger_touch =
{
activator = other;
keytrigger_use();
};
/*QUAKED trigger_usekey (0 .5 0) ? X X X USE_SILV_KEY USE_GOLD_KEY X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Variable sized single use trigger that requires a key to trigger targets. Must be targeted at one or more entities.
"cnt" if 1, leave a used key in the player's inventory (0 default).
"keyname" if set, this is the keyname of the item_key_custom which unlocks this entity.
"message" is printed when the trigger is touched without having the right key.
"noise1" sound file for the "key required" sound (default is per worldtype).
"noise2" sound file for the "key used" sound (default is per worldtype).
*/
void() trigger_usekey =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
// the keylock_* functions use self.noise3 and self.noise4 internally,
// but trigger_usekey doesn't use the self.noise1 or self.noise2 fields
// for anything, so we allow the mapper to specify custom sound files by
// setting self.noise1 and self.noise2, but we move those values into
// self.noise3 and self.noise4 -- iw
self.noise3 = self.noise1;
self.noise4 = self.noise2;
self.noise1 = "";
self.noise2 = "";
keylock_init ();
if (self.spawnflags & USE_SILV_KEY) {//dumptruck_ds
keylock_set_silver_key ();
if (self.keyname != "") {
self.netname = self.keyname;
self.keyname = "";
}
}
if (self.spawnflags & USE_GOLD_KEY) {//dumptruck_ds
keylock_set_gold_key ();
if (self.keyname != "") {
self.netname = self.keyname;
self.keyname = "";
}
}
// support for item_key_custom -- iw
if (self.keyname != "")
{
keylock_set_custom_key (self.keyname);
self.keyname = ""; // this should not be referenced again
}
if (!keylock_has_key_set ())
{
objerror ("no key specified!");
return;
}
self.use = keytrigger_use;
self.touch = keytrigger_touch;
InitTrigger ();
SUB_CheckWaiting();
};
// void() remove_touch =
// {
// if (other.flags & self.cnt)
// return;
// other.touch = SUB_Null;
// other.model = "";
// remove(self);
// };
//
// /*QUAKED trigger_remove (.5 .5 .5) ? ignoremonsters ignoreplayers
// Variable sized trigger that removes the thing
// that touches it. Does not affect monsters or
// players.
// */
// void() trigger_remove =
// {
// if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
// return;
//
// self.cnt = FL_CLIENT|FL_MONSTER;
// if (self.spawnflags & 1)
// self.cnt = self.cnt - FL_MONSTER;
// if (self.spawnflags & 2)
// self.cnt = self.cnt - FL_CLIENT;
// InitTrigger ();
// self.touch = remove_touch;
// };
/*
==============================================================================
trigger_setgravity
==============================================================================
*/
float DT_GRAVTOFF = 8; // trigger will start off
void() grav_toggle = //dumptruck_ds based on hipnotic blocker_use
{
if (self.estate != STATE_ACTIVE)
self.estate = STATE_ACTIVE;
else
self.estate = STATE_INACTIVE;
};
void() trigger_gravity_touch =
{
// from Copper -- dumptruck_ds
// if (!CheckValidTouch()) return;
if (self.estate != STATE_ACTIVE) return;
local float grav;
// This is commented out so that the changing gravity will
// affect everything, if you don't want to use all affecting
// gravity changes, then uncomment these two lines.
// if (other.classname != "player")
// return;
if (self.gravity == -1)
grav = 1;
else
grav = self.gravity;
// the player's gravity is now managed in PlayerPreThink(), however
// other entities don't have special gravity management, so their
// gravity is still set directly -- iw
if (other.classname == "player")
other.wantedgravity = grav;
else
other.gravity = grav;
};
/*QUAKED trigger_setgravity (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
set the gravity of a player
"gravity" what to set the players gravity to
- 0 (default) normal gravity
- 1 no gravity
- 2 almost no gravity
- 10 is a good setting
- ...
- 101 normal gravity
- 102 slightly higher gravity
- ...
- 1000 very high gravity
NOTE: the amount of gravity can only be changed by touching another
trigger_setgravity with a different setting. The gravity key defaults to 0
which is normal gravity. Lower numbers (e.g. 25) equal lower gravity. Setting
100 is normal gravity. Numbers above 100 will make the player “heavier”, i.e.
harder to jump. If you want multiple trigger setgravity triggers in one room or
area, make sure the brushes are not touching each other. This can cause the
triggers not to work properly.
*/
void() trigger_setgravity =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
InitTrigger ();
self.use = grav_toggle; // dumptruck_ds
self.touch = trigger_gravity_touch;
if ( self.spawnflags & DT_GRAVTOFF ) //dumptruck_ds
self.estate = STATE_INACTIVE;
if (!self.gravity)
self.gravity = -1;
else
self.gravity = ((self.gravity - 1) / 100);
SUB_CheckWaiting();
};