-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCOOP.QC
165 lines (145 loc) · 3.48 KB
/
COOP.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
/*============================
coop.qc
This file handles all the
cooperative mode functions
============================*/
void() DroppedKeyThink =
{
// let the throwing player pick it up again
self.think = SUB_Null;
self.touch = key_touch;
self.owner = world;
};
void() DropKey =
{
if ((self.items & #IT_KEY1) || (self.items & #IT_KEY2))
{
newmis = spawn();
if (self.items & #IT_KEY1)
{
self.items = self.items - (self.items & #IT_KEY1);
newmis.items = #IT_KEY1;
if (world.worldtype == 0)
{
setmodel (newmis, "progs/w_s_key.mdl");
newmis.netname = "silver key";
newmis.noise = "misc/medkey.wav";
}
else if (world.worldtype == 1)
{
setmodel (newmis, "progs/m_s_key.mdl");
newmis.netname = "silver runekey";
newmis.noise = "misc/runekey.wav";
}
else if (world.worldtype == 2)
{
setmodel (newmis, "progs/b_s_key.mdl");
newmis.netname = "silver keycard";
newmis.noise = "misc/basekey.wav";
}
}
else if (self.items & #IT_KEY2)
{
self.items = self.items - (self.items & #IT_KEY2);
newmis.items = #IT_KEY2;
if (world.worldtype == 0)
{
setmodel (newmis, "progs/w_g_key.mdl");
newmis.netname = "gold key";
newmis.noise = "misc/medkey.wav";
}
else if (world.worldtype == 1)
{
setmodel (newmis, "progs/m_g_key.mdl");
newmis.netname = "gold runekey";
newmis.noise = "misc/runekey.wav";
}
else if (world.worldtype == 2)
{
setmodel (newmis, "progs/b_g_key.mdl");
newmis.netname = "gold keycard";
newmis.noise = "misc/basekey.wav";
}
}
newmis.owner = self;
newmis.touch = SUB_Null;
setorigin(newmis, self.origin + '0 0 16');
makevectors(self.v_angle);
newmis.velocity = normalize(v_forward) * 300 + '0 0 200';
newmis.movetype = #MOVETYPE_TOSS;
newmis.solid = #SOLID_TRIGGER;
newmis.deadflag = #TRUE;
setsize (newmis, '-16 -16 -24', '16 16 32');
newmis.think = DroppedKeyThink;
newmis.nextthink = time + 1.5;
}
else
{
sprint (self, #PRINT_HIGH, "You don't have a key\n");
}
};
/*==================================
DoorShouldOpen
This function is only for key doors in
coop mode 2.
It returns true if all players have keyed
the door.
==================================*/
float() DoorShouldOpen =
{
local entity ptr;
local float plyrcount;
local entity plyr1;
local entity plyr2;
if (coop != 2)
return #TRUE;
plyrcount = 0;
ptr = find(world, classname, "player");
while (ptr != world)
{
if (!(ptr.tf_items & self.items) && ptr.playerclass != #PC_UNDEFINED
&& ptr.solid != #SOLID_NOT
&& ptr.model != string_null)
{
plyrcount = plyrcount + 1;
if (plyrcount == 1)
plyr1 = ptr;
else if(plyrcount == 2)
plyr2 = ptr;
}
ptr = find(ptr, classname, "player");
}
if (plyrcount != 0)
{
if (plyrcount == 1)
{
bprint(#PRINT_HIGH, plyr1.netname);
bprint(#PRINT_HIGH, " needs");
}
else if (plyrcount == 2)
{
bprint(#PRINT_HIGH, plyr1.netname);
bprint(#PRINT_HIGH, " and ");
bprint(#PRINT_HIGH, plyr2.netname);
bprint(#PRINT_HIGH, " need");
}
else
{
bprint(#PRINT_HIGH, "More players need");
}
bprint(#PRINT_HIGH, " to unlock the ");
if (self.items & #IT_KEY1)
bprint(#PRINT_HIGH, "silver");
else
bprint(#PRINT_HIGH, "gold");
bprint(#PRINT_HIGH, " door\n");
return #FALSE;
}
bprint(#PRINT_HIGH, "The ");
if (self.items & #IT_KEY1)
bprint(#PRINT_HIGH, "silver");
else
bprint(#PRINT_HIGH, "gold");
bprint(#PRINT_HIGH, " door has been unlocked\n");
return #TRUE;
};