2001-07-23 20:52:47 +00:00
|
|
|
#include "defs.qh"
|
2001-07-17 05:58:10 +00:00
|
|
|
/*============================
|
|
|
|
coop.qc
|
|
|
|
|
|
|
|
This file handles all the
|
|
|
|
cooperative mode functions
|
|
|
|
============================*/
|
|
|
|
|
|
|
|
|
|
|
|
void() DroppedKeyThink =
|
|
|
|
{
|
|
|
|
// let the throwing player pick it up again
|
2001-10-17 07:48:11 +00:00
|
|
|
self.think = NIL;
|
2001-07-17 05:58:10 +00:00
|
|
|
self.touch = key_touch;
|
|
|
|
self.owner = world;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void() DropKey =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if ((self.items & IT_KEY1) || (self.items & IT_KEY2))
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
newmis = spawn();
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.items & IT_KEY1)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-08-10 10:03:36 +00:00
|
|
|
self.items = self.items & ~IT_KEY1;
|
2001-07-23 20:52:47 +00:00
|
|
|
newmis.items = IT_KEY1;
|
2001-07-17 05:58:10 +00:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
else if (self.items & IT_KEY2)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-08-10 10:03:36 +00:00
|
|
|
self.items = self.items & ~IT_KEY2;
|
2001-07-23 20:52:47 +00:00
|
|
|
newmis.items = IT_KEY2;
|
2001-07-17 05:58:10 +00:00
|
|
|
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;
|
2001-10-17 07:48:11 +00:00
|
|
|
newmis.touch = NIL;
|
2001-07-17 05:58:10 +00:00
|
|
|
setorigin(newmis, self.origin + '0 0 16');
|
|
|
|
makevectors(self.v_angle);
|
|
|
|
newmis.velocity = normalize(v_forward) * 300 + '0 0 200';
|
2001-07-23 20:52:47 +00:00
|
|
|
newmis.movetype = MOVETYPE_TOSS;
|
|
|
|
newmis.solid = SOLID_TRIGGER;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
newmis.deadflag = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
setsize (newmis, '-16 -16 -24', '16 16 32');
|
|
|
|
newmis.think = DroppedKeyThink;
|
|
|
|
newmis.nextthink = time + 1.5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, "You don't have a key\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*==================================
|
|
|
|
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;
|
2001-10-19 03:31:30 +00:00
|
|
|
local entity plyr1 = NIL;
|
|
|
|
local entity plyr2 = NIL;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
if (coop != 2)
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
plyrcount = 0;
|
|
|
|
ptr = find(world, classname, "player");
|
|
|
|
while (ptr != world)
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (!(ptr.tf_items & self.items) && ptr.playerclass != PC_UNDEFINED
|
|
|
|
&& ptr.solid != SOLID_NOT
|
2001-09-30 22:38:44 +00:00
|
|
|
&& ptr.model)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
bprint(PRINT_HIGH, plyr1.netname);
|
|
|
|
bprint(PRINT_HIGH, " needs");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (plyrcount == 2)
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
bprint(PRINT_HIGH, plyr1.netname);
|
|
|
|
bprint(PRINT_HIGH, " and ");
|
|
|
|
bprint(PRINT_HIGH, plyr2.netname);
|
|
|
|
bprint(PRINT_HIGH, " need");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
bprint(PRINT_HIGH, "More players need");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
bprint(PRINT_HIGH, " to unlock the ");
|
|
|
|
if (self.items & IT_KEY1)
|
|
|
|
bprint(PRINT_HIGH, "silver");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
2001-07-23 20:52:47 +00:00
|
|
|
bprint(PRINT_HIGH, "gold");
|
|
|
|
bprint(PRINT_HIGH, " door\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
bprint(PRINT_HIGH, "The ");
|
|
|
|
if (self.items & IT_KEY1)
|
|
|
|
bprint(PRINT_HIGH, "silver");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
2001-07-23 20:52:47 +00:00
|
|
|
bprint(PRINT_HIGH, "gold");
|
|
|
|
bprint(PRINT_HIGH, " door has been unlocked\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
|
|
|
};
|