-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcoop.qc
114 lines (105 loc) · 3.8 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
//========================================================
// This file handles all the cooperative mode functions
//========================================================
void () DroppedKeyThink = {
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 = DEAD_DYING;
setsize(newmis, VEC_HULL_MIN, VEC_HULL_MAX);
newmis.think = DroppedKeyThink;
newmis.nextthink = time + 1.5;
} else
sprint(self, PRINT_HIGH, "You do not have a key\n");
};
float () DoorShouldOpen = {
local entity ptr;
local float plyrcount;
local entity plyr1;
local entity plyr2;
if (coop != 2)
return (1);
plyr1 = world;
plyr2 = world;
plyrcount = 0;
ptr = find(world, classname, "player");
while (ptr != world) {
if (!(ptr.tf_items & self.items) && (ptr.playerclass != 0.000)
&& (ptr.solid != 0.000) && (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, " needs");
} else if (plyrcount == 2) {
bprint(PRINT_HIGH, plyr1.netname, " and ", plyr2.netname,
" 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 (0);
}
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 (1);
};