game-source/ctf/qwsrc/items.qc

1530 lines
33 KiB
C++
Raw Normal View History

/*
2003-03-03 19:17:04 +00:00
items.qc
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
2003-03-03 19:17:04 +00:00
void () W_SetCurrentAmmo;
/* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
BE .8 .3 .4 IN COLOR */
2003-03-03 19:17:04 +00:00
void ()
SUB_regen =
{
self.model = self.mdl; // restore original model
self.solid = SOLID_TRIGGER; // allow it to be touched again
2003-03-03 19:17:04 +00:00
// play respawn sound
sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);
setorigin (self, self.origin);
};
/*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
prints a warning message when spawned
*/
2003-03-03 19:17:04 +00:00
void ()
noclass =
{
dprint ("noclass spawned at");
dprint (vtos(self.origin));
dprint ("\n");
remove (self);
};
/*
============
PlaceItem
plants the object on the floor
============
*/
2003-03-03 19:17:04 +00:00
void ()
PlaceItem =
{
2003-03-03 19:17:04 +00:00
local float oldz;
self.mdl = self.model; // so it can be restored on respawn
self.flags = FL_ITEM; // make extra wide
self.solid = SOLID_TRIGGER;
self.movetype = MOVETYPE_TOSS;
self.velocity = '0 0 0';
2003-03-03 19:17:04 +00:00
self.origin_z += 6;
oldz = self.origin_z;
2003-03-03 19:17:04 +00:00
if (!droptofloor ()) {
dprint ("Bonus item fell out of level at ");
2003-03-03 19:17:04 +00:00
dprint (vtos (self.origin));
dprint ("\n");
2003-03-03 19:17:04 +00:00
remove (self);
return;
}
};
/*
============
StartItem
Sets the clipping size and plants the object on the floor
============
*/
2003-03-03 19:17:04 +00:00
void ()
StartItem =
{
self.nextthink = time + 0.2; // items start after other solids
self.think = PlaceItem;
};
2003-03-03 19:17:04 +00:00
// HEALTH BOX =================================================================
// T_Heal: add health to an entity, limiting health to max_health
// "ignore" will ignore max_health limit
2003-03-03 19:17:04 +00:00
float (entity e, float healamount, float ignore)
T_Heal =
{
if (e.health <= 0)
return 0;
if ((!ignore) && (e.health >= other.max_health))
return 0;
2003-03-03 19:17:04 +00:00
healamount = ceil (healamount);
e.health = e.health + healamount;
if ((!ignore) && (e.health >= other.max_health))
e.health = other.max_health;
if (e.health > 250)
e.health = 250;
return 1;
};
float H_ROTTEN = 1;
float H_MEGA = 2;
.float healamount, healtype;
2003-03-03 19:17:04 +00:00
void ()
item_megahealth_rot =
{
other = self.owner;
2003-03-03 19:17:04 +00:00
// ZOID: player doesn't rot if they have Elder Magic rune
if (other.health > other.max_health
&& !(other.player_flag & ITEM_RUNE4_FLAG)) {
other.health = other.health - 1;
self.nextthink = time + 1;
return;
}
2003-03-03 19:17:04 +00:00
// it is possible for a player to die and respawn between rots, so don't
// just blindly subtract the flag off
other.items &= ~IT_SUPERHEALTH;
if (deathmatch == 1 || deathmatch == 3) { // deathmatch 2 = silly old rules
self.nextthink = time + 20;
self.think = SUB_regen;
}
};
2003-03-03 19:17:04 +00:00
void ()
health_touch =
{
2003-03-03 19:17:04 +00:00
local string s;
if (other.classname != "player")
return;
2003-03-03 19:17:04 +00:00
if (self.healtype == 2) { // Megahealth? Ignore max_health...
if (other.health >= 250)
return;
2003-03-03 19:17:04 +00:00
if (!T_Heal (other, self.healamount, 1))
return;
2003-03-03 19:17:04 +00:00
} else {
if (!T_Heal (other, self.healamount, 0))
return;
}
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, "You receive ");
s = ftos (self.healamount);
sprint (other, PRINT_LOW, s);
sprint (other, PRINT_LOW, " health\n");
// health touch sound
sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
stuffcmd (other, "bf\n");
2003-03-03 19:17:04 +00:00
self.model = string_null;
self.solid = SOLID_NOT;
// Megahealth = rot down the player's super health
2003-03-03 19:17:04 +00:00
if (self.healtype == 2) {
2004-02-08 05:38:36 +00:00
other.items |= IT_SUPERHEALTH;
self.nextthink = time + 5;
self.think = item_megahealth_rot;
self.owner = other;
2003-03-03 19:17:04 +00:00
} else {
if (deathmatch != 2) { // deathmatch 2 is the silly old rules
self.nextthink = time + 20;
self.think = SUB_regen;
}
}
activator = other;
2003-03-03 19:17:04 +00:00
SUB_UseTargets (); // fire all targets / killtargets
};
2003-03-03 19:17:04 +00:00
/*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
Health box. Normally gives 25 points.
Rotten box heals 5-10 points,
megahealth will add 100 health, then
rot you down to your maximum health limit,
one point per second.
*/
void ()
item_health =
{
2003-03-03 19:17:04 +00:00
self.touch = health_touch;
2003-03-03 19:17:04 +00:00
if (self.spawnflags & H_ROTTEN) {
precache_model("maps/b_bh10.bsp");
precache_sound("items/r_item1.wav");
setmodel(self, "maps/b_bh10.bsp");
self.noise = "items/r_item1.wav";
self.healamount = 15;
self.healtype = 0;
} else if (self.spawnflags & H_MEGA) {
precache_model("maps/b_bh100.bsp");
precache_sound("items/r_item2.wav");
setmodel(self, "maps/b_bh100.bsp");
self.noise = "items/r_item2.wav";
self.healamount = 100;
self.healtype = 2;
} else {
precache_model("maps/b_bh25.bsp");
precache_sound("items/health1.wav");
setmodel(self, "maps/b_bh25.bsp");
self.noise = "items/health1.wav";
self.healamount = 25;
self.healtype = 1;
}
2003-03-03 19:17:04 +00:00
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};
2003-03-03 19:17:04 +00:00
// ARMOR ======================================================================
2003-03-03 19:17:04 +00:00
void ()
armor_touch =
{
2003-03-03 19:17:04 +00:00
local float type = 0, value = 0, bit = 0;
if (other.health <= 0)
return;
if (other.classname != "player")
return;
2003-03-03 19:17:04 +00:00
switch (self.classname) {
case "item_armor1":
type = 0.3;
value = 100;
bit = IT_ARMOR1;
2003-03-03 19:17:04 +00:00
break;
case "item_armor2":
type = 0.6;
value = 150;
bit = IT_ARMOR2;
2003-03-03 19:17:04 +00:00
break;
case "item_armorInv":
type = 0.8;
value = 200;
bit = IT_ARMOR3;
2003-03-03 19:17:04 +00:00
default:
break;
}
2003-03-03 19:17:04 +00:00
if (other.armortype * other.armorvalue >= type * value)
return;
other.armortype = type;
other.armorvalue = value;
2003-03-03 19:17:04 +00:00
other.items &= ~(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3);
other.items |= bit;
self.solid = SOLID_NOT;
self.model = string_null;
if (deathmatch == 1 || deathmatch == 3)
self.nextthink = time + 20;
self.think = SUB_regen;
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, "You got armor\n");
// armor touch sound
sound (other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
activator = other;
2003-03-03 19:17:04 +00:00
SUB_UseTargets (); // fire all targets / killtargets
};
/*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
item_armor1 =
{
self.touch = armor_touch;
precache_model ("progs/armor.mdl");
setmodel (self, "progs/armor.mdl");
self.skin = 0;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
item_armor2 =
{
self.touch = armor_touch;
precache_model ("progs/armor.mdl");
setmodel (self, "progs/armor.mdl");
self.skin = 1;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
/*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
item_armorInv =
{
self.touch = armor_touch;
precache_model ("progs/armor.mdl");
setmodel (self, "progs/armor.mdl");
self.skin = 2;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
2003-03-03 19:17:04 +00:00
// WEAPONS ====================================================================
2003-03-03 19:17:04 +00:00
void ()
bound_other_ammo =
{
if (other.ammo_shells > 100)
other.ammo_shells = 100;
if (other.ammo_nails > 200)
other.ammo_nails = 200;
if (other.ammo_rockets > 100)
other.ammo_rockets = 100;
if (other.ammo_cells > 100)
other.ammo_cells = 100;
};
2003-03-03 19:17:04 +00:00
float (float w)
RankForWeapon =
{
2003-03-03 19:17:04 +00:00
switch (w) {
case IT_LIGHTNING:
return 1;
2003-03-03 19:17:04 +00:00
case IT_ROCKET_LAUNCHER:
return 2;
2003-03-03 19:17:04 +00:00
case IT_SUPER_NAILGUN:
return 3;
2003-03-03 19:17:04 +00:00
case IT_GRENADE_LAUNCHER:
return 4;
2003-03-03 19:17:04 +00:00
case IT_SUPER_SHOTGUN:
return 5;
2003-03-03 19:17:04 +00:00
case IT_NAILGUN:
return 6;
2003-03-03 19:17:04 +00:00
default:
return 7;
}
};
2003-03-03 19:17:04 +00:00
float (float w)
WeaponCode =
{
2003-03-03 19:17:04 +00:00
switch (w) {
case IT_SUPER_SHOTGUN:
return 3;
2003-03-03 19:17:04 +00:00
case IT_NAILGUN:
return 4;
2003-03-03 19:17:04 +00:00
case IT_SUPER_NAILGUN:
return 5;
2003-03-03 19:17:04 +00:00
case IT_GRENADE_LAUNCHER:
return 6;
2003-03-03 19:17:04 +00:00
case IT_ROCKET_LAUNCHER:
return 7;
2003-03-03 19:17:04 +00:00
case IT_LIGHTNING:
return 8;
2003-03-03 19:17:04 +00:00
default:
return 1;
}
};
/*
=============
Deathmatch_Weapon
Deathmatch weapon change rules for picking up a weapon
.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
=============
*/
2003-03-03 19:17:04 +00:00
void (float old, float new)
Deathmatch_Weapon =
{
local float or, nr;
if (self.weapon == IT_GRAPPLE && self.button0)
return; // never change if we pulled ourselves to it
2003-03-03 19:17:04 +00:00
// change self.weapon if desired
or = RankForWeapon (self.weapon);
nr = RankForWeapon (new);
2003-03-03 19:17:04 +00:00
if (nr < or)
self.weapon = new;
};
2003-03-03 19:17:04 +00:00
float () W_BestWeapon;
2003-03-03 19:17:04 +00:00
void ()
weapon_touch =
{
2003-03-03 19:17:04 +00:00
local float best, hadammo, leave, w_switch, new = 0, old;
// McBain: added prevweapon local variable
local float prevweapon;
local entity stemp;
if (!(other.flags & FL_CLIENT))
return;
2003-03-03 19:17:04 +00:00
if ((stof (infokey (other, "w_switch"))) == 0)
w_switch = 8;
else
2003-03-03 19:17:04 +00:00
w_switch = stof (infokey (other, "w_switch"));
2003-03-03 19:17:04 +00:00
// if the player was using his best weapon, change to new one if better
stemp = self;
self = other;
2003-03-03 19:17:04 +00:00
best = W_BestWeapon ();
self = stemp;
if (deathmatch == 2 || deathmatch == 3)
leave = 1;
else
leave = 0;
2003-03-03 19:17:04 +00:00
switch (self.classname) {
case "weapon_nailgun":
if (leave && (other.items & IT_NAILGUN) )
return;
hadammo = other.ammo_nails;
new = IT_NAILGUN;
other.ammo_nails = other.ammo_nails + 30;
2003-03-03 19:17:04 +00:00
break;
case "weapon_supernailgun":
if (leave && (other.items & IT_SUPER_NAILGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_NAILGUN;
other.ammo_nails = other.ammo_nails + 30;
2003-03-03 19:17:04 +00:00
break;
case "weapon_supershotgun":
if (leave && (other.items & IT_SUPER_SHOTGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_SHOTGUN;
other.ammo_shells = other.ammo_shells + 5;
2003-03-03 19:17:04 +00:00
break;
case "weapon_rocketlauncher":
if (leave && (other.items & IT_ROCKET_LAUNCHER) )
return;
hadammo = other.ammo_rockets;
new = IT_ROCKET_LAUNCHER;
other.ammo_rockets = other.ammo_rockets + 5;
2003-03-03 19:17:04 +00:00
break;
case "weapon_grenadelauncher":
if (leave && (other.items & IT_GRENADE_LAUNCHER) )
return;
hadammo = other.ammo_rockets;
new = IT_GRENADE_LAUNCHER;
other.ammo_rockets = other.ammo_rockets + 5;
2003-03-03 19:17:04 +00:00
break;
case "weapon_lightning":
if (leave && (other.items & IT_LIGHTNING) )
return;
hadammo = other.ammo_rockets;
new = IT_LIGHTNING;
other.ammo_cells = other.ammo_cells + 15;
2003-03-03 19:17:04 +00:00
break;
default:
objerror ("weapon_touch: unknown classname");
2003-03-03 19:17:04 +00:00
break;
}
sprint (other, PRINT_LOW, "You got the ");
sprint (other, PRINT_LOW, self.netname);
sprint (other, PRINT_LOW, "\n");
2003-03-03 19:17:04 +00:00
// weapon touch sound
sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
bound_other_ammo ();
2003-03-03 19:17:04 +00:00
// change to the weapon
old = other.items;
2003-03-03 19:17:04 +00:00
other.items |= new;
stemp = self;
self = other;
prevweapon = self.weapon;
2003-03-03 19:17:04 +00:00
if (WeaponCode (new) <= w_switch ) {
if (self.flags & FL_INWATER) {
if (new != IT_LIGHTNING)
Deathmatch_Weapon (old, new);
2003-03-03 19:17:04 +00:00
} else
Deathmatch_Weapon (old, new);
}
if (self.weapon != prevweapon)
self.previous_weapon = prevweapon;
2003-03-03 19:17:04 +00:00
W_SetCurrentAmmo ();
self = stemp;
if (leave)
return;
2003-03-03 19:17:04 +00:00
// remove it in single player, or setup for respawning in deathmatch
self.model = string_null;
self.solid = SOLID_NOT;
if (deathmatch == 1 || deathmatch == 3)
self.nextthink = time + 30;
self.think = SUB_regen;
activator = other;
2003-03-03 19:17:04 +00:00
SUB_UseTargets (); // fire all targets / killtargets
};
/*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
weapon_supershotgun =
{
precache_model ("progs/g_shot.mdl");
setmodel (self, "progs/g_shot.mdl");
self.weapon = IT_SUPER_SHOTGUN;
self.netname = "Double-barrelled Shotgun";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
/*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
weapon_nailgun =
{
precache_model ("progs/g_nail.mdl");
setmodel (self, "progs/g_nail.mdl");
self.weapon = IT_NAILGUN;
self.netname = "nailgun";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
/*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
weapon_supernailgun =
{
precache_model ("progs/g_nail2.mdl");
setmodel (self, "progs/g_nail2.mdl");
self.weapon = IT_SUPER_NAILGUN;
self.netname = "Super Nailgun";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
/*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
weapon_grenadelauncher =
{
precache_model ("progs/g_rock.mdl");
setmodel (self, "progs/g_rock.mdl");
self.weapon = 3;
self.netname = "Grenade Launcher";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
/*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
weapon_rocketlauncher =
{
precache_model ("progs/g_rock2.mdl");
setmodel (self, "progs/g_rock2.mdl");
self.weapon = 3;
self.netname = "Rocket Launcher";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
/*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
*/
2003-03-03 19:17:04 +00:00
void ()
weapon_lightning =
{
precache_model ("progs/g_light.mdl");
setmodel (self, "progs/g_light.mdl");
self.weapon = 3;
self.netname = "Thunderbolt";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
StartItem ();
};
2003-03-03 19:17:04 +00:00
// AMMO =======================================================================
2003-03-03 19:17:04 +00:00
void ()
ammo_touch =
{
2003-03-03 19:17:04 +00:00
local entity stemp;
local float best;
if (other.classname != "player")
return;
if (other.health <= 0)
return;
2003-03-03 19:17:04 +00:00
// if the player was using his best weapon, change to new one if better
stemp = self;
self = other;
2003-03-03 19:17:04 +00:00
best = W_BestWeapon ();
self = stemp;
2003-03-03 19:17:04 +00:00
switch (self.weapon) {
case 1: // shotgun
if (other.ammo_shells >= 100)
return;
other.ammo_shells = other.ammo_shells + self.aflag;
2003-03-03 19:17:04 +00:00
break;
case 2: // spikes
if (other.ammo_nails >= 200)
return;
other.ammo_nails = other.ammo_nails + self.aflag;
2003-03-03 19:17:04 +00:00
break;
case 3: // rockets
if (other.ammo_rockets >= 100)
return;
other.ammo_rockets = other.ammo_rockets + self.aflag;
2003-03-03 19:17:04 +00:00
break;
case 4: // cells
if (other.ammo_cells >= 100)
return;
other.ammo_cells = other.ammo_cells + self.aflag;
2003-03-03 19:17:04 +00:00
default:
break;
}
bound_other_ammo ();
sprint (other, PRINT_LOW, "You got the ");
sprint (other, PRINT_LOW, self.netname);
sprint (other, PRINT_LOW, "\n");
2003-03-03 19:17:04 +00:00
// ammo touch sound
sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
2003-03-03 19:17:04 +00:00
// change to a better weapon if appropriate
if (other.weapon == best) {
stemp = self;
self = other;
self.weapon = W_BestWeapon();
W_SetCurrentAmmo ();
self = stemp;
}
2003-03-03 19:17:04 +00:00
// if changed current ammo, update it
stemp = self;
self = other;
2003-03-03 19:17:04 +00:00
W_SetCurrentAmmo ();
self = stemp;
2003-03-03 19:17:04 +00:00
// remove it in single player, or setup for respawning in deathmatch
self.model = string_null;
self.solid = SOLID_NOT;
if (deathmatch == 1 || deathmatch == 3)
self.nextthink = time + 30;
self.think = SUB_regen;
activator = other;
SUB_UseTargets(); // fire all targets / killtargets
};
float WEAPON_BIG2 = 1;
/*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
*/
2003-03-03 19:17:04 +00:00
void ()
item_shells =
{
self.touch = ammo_touch;
2003-03-03 19:17:04 +00:00
if (self.spawnflags & WEAPON_BIG2) {
precache_model ("maps/b_shell1.bsp");
setmodel (self, "maps/b_shell1.bsp");
self.aflag = 40;
2003-03-03 19:17:04 +00:00
} else {
precache_model ("maps/b_shell0.bsp");
setmodel (self, "maps/b_shell0.bsp");
self.aflag = 20;
}
self.weapon = 1;
self.netname = "shells";
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};
/*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
*/
2003-03-03 19:17:04 +00:00
void ()
item_spikes =
{
self.touch = ammo_touch;
2003-03-03 19:17:04 +00:00
if (self.spawnflags & WEAPON_BIG2) {
precache_model ("maps/b_nail1.bsp");
setmodel (self, "maps/b_nail1.bsp");
self.aflag = 50;
2003-03-03 19:17:04 +00:00
} else {
precache_model ("maps/b_nail0.bsp");
setmodel (self, "maps/b_nail0.bsp");
self.aflag = 25;
}
self.weapon = 2;
self.netname = "nails";
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};
/*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
*/
2003-03-03 19:17:04 +00:00
void ()
item_rockets =
{
self.touch = ammo_touch;
2003-03-03 19:17:04 +00:00
if (self.spawnflags & WEAPON_BIG2) {
precache_model ("maps/b_rock1.bsp");
setmodel (self, "maps/b_rock1.bsp");
self.aflag = 10;
2003-03-03 19:17:04 +00:00
} else {
precache_model ("maps/b_rock0.bsp");
setmodel (self, "maps/b_rock0.bsp");
self.aflag = 5;
}
self.weapon = 3;
self.netname = "rockets";
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};
/*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
*/
2003-03-03 19:17:04 +00:00
void ()
item_cells =
{
self.touch = ammo_touch;
2003-03-03 19:17:04 +00:00
if (self.spawnflags & WEAPON_BIG2) {
precache_model ("maps/b_batt1.bsp");
setmodel (self, "maps/b_batt1.bsp");
self.aflag = 12;
2003-03-03 19:17:04 +00:00
} else {
precache_model ("maps/b_batt0.bsp");
setmodel (self, "maps/b_batt0.bsp");
self.aflag = 6;
}
self.weapon = 4;
self.netname = "cells";
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};
/*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
DO NOT USE THIS!!!! IT WILL BE REMOVED!
*/
float WEAPON_SHOTGUN = 1;
float WEAPON_ROCKET = 2;
float WEAPON_SPIKES = 4;
float WEAPON_BIG = 8;
2003-03-03 19:17:04 +00:00
void ()
item_weapon =
{
self.touch = ammo_touch;
2003-03-03 19:17:04 +00:00
if (self.spawnflags & WEAPON_SHOTGUN) {
if (self.spawnflags & WEAPON_BIG) {
precache_model ("maps/b_shell1.bsp");
setmodel (self, "maps/b_shell1.bsp");
self.aflag = 40;
2003-03-03 19:17:04 +00:00
} else {
precache_model ("maps/b_shell0.bsp");
setmodel (self, "maps/b_shell0.bsp");
self.aflag = 20;
}
self.weapon = 1;
self.netname = "shells";
}
2003-03-03 19:17:04 +00:00
if (self.spawnflags & WEAPON_SPIKES) {
if (self.spawnflags & WEAPON_BIG) {
precache_model ("maps/b_nail1.bsp");
setmodel (self, "maps/b_nail1.bsp");
self.aflag = 40;
2003-03-03 19:17:04 +00:00
} else {
precache_model ("maps/b_nail0.bsp");
setmodel (self, "maps/b_nail0.bsp");
self.aflag = 20;
}
self.weapon = 2;
self.netname = "spikes";
}
2003-03-03 19:17:04 +00:00
if (self.spawnflags & WEAPON_ROCKET) {
if (self.spawnflags & WEAPON_BIG) {
precache_model ("maps/b_rock1.bsp");
setmodel (self, "maps/b_rock1.bsp");
self.aflag = 10;
2003-03-03 19:17:04 +00:00
} else {
precache_model ("maps/b_rock0.bsp");
setmodel (self, "maps/b_rock0.bsp");
self.aflag = 5;
}
self.weapon = 3;
self.netname = "rockets";
}
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};
2003-03-03 19:17:04 +00:00
// KEYS =======================================================================
2003-03-03 19:17:04 +00:00
void ()
key_touch =
{
if (other.classname != "player")
return;
if (other.health <= 0)
return;
if (other.items & self.items)
return;
sprint (other, PRINT_LOW, "You got the ");
sprint (other, PRINT_LOW, self.netname);
sprint (other,PRINT_LOW, "\n");
sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
stuffcmd (other, "bf\n");
2004-02-08 05:38:36 +00:00
other.items |= self.items;
self.solid = SOLID_NOT;
self.model = string_null;
activator = other;
2003-03-03 19:17:04 +00:00
SUB_UseTargets (); // fire all targets / killtargets
};
2003-03-03 19:17:04 +00:00
void ()
key_setsounds =
{
2003-03-03 19:17:04 +00:00
switch (world.worldtype) {
case 0:
precache_sound ("misc/medkey.wav");
self.noise = "misc/medkey.wav";
2003-03-03 19:17:04 +00:00
break;
case 1:
precache_sound ("misc/runekey.wav");
self.noise = "misc/runekey.wav";
2003-03-03 19:17:04 +00:00
break;
case 2:
precache_sound2 ("misc/basekey.wav");
self.noise = "misc/basekey.wav";
2003-03-03 19:17:04 +00:00
default:
break;
}
};
/*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
SILVER key
In order for keys to work
you MUST set your maps
worldtype to one of the
following:
0: medieval
1: metal
2: base
*/
2003-03-03 19:17:04 +00:00
void ()
item_key1 =
{
2003-03-03 19:17:04 +00:00
switch (world.worldtype) {
case 0:
precache_model ("progs/w_s_key.mdl");
setmodel (self, "progs/w_s_key.mdl");
self.netname = "silver key";
2003-03-03 19:17:04 +00:00
break;
case 1:
precache_model ("progs/m_s_key.mdl");
setmodel (self, "progs/m_s_key.mdl");
self.netname = "silver runekey";
2003-03-03 19:17:04 +00:00
break;
case 2:
precache_model2 ("progs/b_s_key.mdl");
setmodel (self, "progs/b_s_key.mdl");
self.netname = "silver keycard";
2003-03-03 19:17:04 +00:00
default:
break;
}
2003-03-03 19:17:04 +00:00
key_setsounds ();
self.touch = key_touch;
self.items = IT_KEY1;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
/*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
GOLD key
In order for keys to work
you MUST set your maps
worldtype to one of the
following:
0: medieval
1: metal
2: base
*/
2003-03-03 19:17:04 +00:00
void ()
item_key2 =
{
2003-03-03 19:17:04 +00:00
switch (world.worldtype) {
case 0:
precache_model ("progs/w_g_key.mdl");
setmodel (self, "progs/w_g_key.mdl");
self.netname = "gold key";
2003-03-03 19:17:04 +00:00
break;
case 1:
precache_model ("progs/m_g_key.mdl");
setmodel (self, "progs/m_g_key.mdl");
self.netname = "gold runekey";
2003-03-03 19:17:04 +00:00
break;
case 2:
precache_model2 ("progs/b_g_key.mdl");
setmodel (self, "progs/b_g_key.mdl");
self.netname = "gold keycard";
2003-03-03 19:17:04 +00:00
default:
break;
}
2003-03-03 19:17:04 +00:00
key_setsounds ();
self.touch = key_touch;
self.items = IT_KEY2;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
2003-03-03 19:17:04 +00:00
// END OF LEVEL RUNES =========================================================
2003-03-03 19:17:04 +00:00
void ()
sigil_touch =
{
if (other.classname != "player")
return;
if (other.health <= 0)
return;
centerprint (other, "You got the rune!");
sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
stuffcmd (other, "bf\n");
self.solid = SOLID_NOT;
self.model = string_null;
2003-03-03 19:17:04 +00:00
serverflags |= (self.spawnflags & 15);
self.classname = ""; // so rune doors won't find it
activator = other;
SUB_UseTargets(); // fire all targets / killtargets
};
/*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
End of level sigil, pick up to end episode and return to jrstart.
*/
2003-03-03 19:17:04 +00:00
void ()
item_sigil =
{
if (!self.spawnflags)
objerror ("no spawnflags");
precache_sound ("misc/runekey.wav");
self.noise = "misc/runekey.wav";
2003-03-03 19:17:04 +00:00
if (self.spawnflags & 1) {
precache_model ("progs/end1.mdl");
setmodel (self, "progs/end1.mdl");
}
2003-03-03 19:17:04 +00:00
if (self.spawnflags & 2) {
precache_model2 ("progs/end2.mdl");
setmodel (self, "progs/end2.mdl");
}
2003-03-03 19:17:04 +00:00
if (self.spawnflags & 4) {
precache_model2 ("progs/end3.mdl");
setmodel (self, "progs/end3.mdl");
}
2003-03-03 19:17:04 +00:00
if (self.spawnflags & 8) {
precache_model2 ("progs/end4.mdl");
setmodel (self, "progs/end4.mdl");
}
self.touch = sigil_touch;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
2003-03-03 19:17:04 +00:00
// POWERUPS
2003-03-03 19:17:04 +00:00
void ()
powerup_touch =
{
if (other.classname != "player")
return;
if (other.health <= 0)
return;
sprint (other, PRINT_LOW, "You got the ");
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, self.netname);
sprint (other, PRINT_LOW, "\n");
self.mdl = self.model;
2003-03-03 19:17:04 +00:00
self.think = SUB_regen;
sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
stuffcmd (other, "bf\n");
self.solid = SOLID_NOT;
2003-03-03 19:17:04 +00:00
other.items |= self.items;
self.model = string_null;
2003-03-03 19:17:04 +00:00
// do the apropriate action
switch (self.classname) {
case "item_artifact_envirosuit":
other.rad_time = 1;
other.radsuit_finished = time + 30;
2003-03-03 19:17:04 +00:00
self.nextthink = time + 60;
break;
case "item_artifact_invulnerability":
other.invincible_time = 1;
other.invincible_finished = time + 30;
2003-03-03 19:17:04 +00:00
self.nextthink = time + 300;
break;
case "item_artifact_invisibility":
other.invisible_time = 1;
other.invisible_finished = time + 30;
2003-03-03 19:17:04 +00:00
self.nextthink = time + 300;
break;
case "item_artifact_super_damage":
other.super_time = 1;
other.super_damage_finished = time + 30;
2003-03-03 19:17:04 +00:00
default:
self.nextthink = time + 60;
break;
}
activator = other;
2003-03-03 19:17:04 +00:00
SUB_UseTargets (); // fire all targets / killtargets
};
/*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
Player is invulnerable for 30 seconds
*/
2003-03-03 19:17:04 +00:00
void ()
item_artifact_invulnerability =
{
self.touch = powerup_touch;
precache_model ("progs/invulner.mdl");
precache_sound ("items/protect.wav");
precache_sound ("items/protect2.wav");
precache_sound ("items/protect3.wav");
self.noise = "items/protect.wav";
setmodel (self, "progs/invulner.mdl");
self.netname = "Pentagram of Protection";
self.items = IT_INVULNERABILITY;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
/*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
Player takes no damage from water or slime for 30 seconds
*/
2003-03-03 19:17:04 +00:00
void ()
item_artifact_envirosuit =
{
self.touch = powerup_touch;
precache_model ("progs/suit.mdl");
precache_sound ("items/suit.wav");
precache_sound ("items/suit2.wav");
self.noise = "items/suit.wav";
setmodel (self, "progs/suit.mdl");
self.netname = "Biosuit";
self.items = IT_SUIT;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
/*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
Player is invisible for 30 seconds
*/
2003-03-03 19:17:04 +00:00
void ()
item_artifact_invisibility =
{
self.touch = powerup_touch;
precache_model ("progs/invisibl.mdl");
precache_sound ("items/inv1.wav");
precache_sound ("items/inv2.wav");
precache_sound ("items/inv3.wav");
self.noise = "items/inv1.wav";
setmodel (self, "progs/invisibl.mdl");
self.netname = "Ring of Shadows";
self.items = IT_INVISIBILITY;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
/*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
The next attack from the player will do 4x damage
*/
2003-03-03 19:17:04 +00:00
void ()
item_artifact_super_damage =
{
self.touch = powerup_touch;
precache_model ("progs/quaddama.mdl");
precache_sound ("items/damage.wav");
precache_sound ("items/damage2.wav");
precache_sound ("items/damage3.wav");
self.noise = "items/damage.wav";
setmodel (self, "progs/quaddama.mdl");
self.netname = "Quad Damage";
self.items = IT_QUAD;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
2003-03-03 19:17:04 +00:00
// PLAYER BACKPACKS ===========================================================
2003-03-03 19:17:04 +00:00
void ()
BackpackTouch =
{
2003-03-03 19:17:04 +00:00
local entity stemp;
local float acount, best, old, new, b_switch = 0; // XXX eh?
local string s;
if (other.classname != "player")
return;
if (other.health <= 0)
return;
//don't let self pick it up for a sec
2003-03-03 19:17:04 +00:00
if ((other == self.owner) && ((self.nextthink - time) > 118))
return;
acount = 0;
sprint (other, PRINT_LOW, "You get ");
if (self.items)
2003-03-03 19:17:04 +00:00
if ((other.items & self.items) == 0) {
acount = 1;
sprint (other, PRINT_LOW, "the ");
sprint (other, PRINT_LOW, self.netname);
}
2003-03-03 19:17:04 +00:00
// if the player was using his best weapon, change to new one if better
stemp = self;
self = other;
2003-03-03 19:17:04 +00:00
best = W_BestWeapon ();
self = stemp;
2003-03-03 19:17:04 +00:00
// change weapons
other.ammo_shells += self.ammo_shells;
other.ammo_nails += self.ammo_nails;
other.ammo_rockets += self.ammo_rockets;
other.ammo_cells += self.ammo_cells;
new = self.items;
if (!new)
new = other.weapon;
old = other.items;
2003-03-03 19:17:04 +00:00
other.items |= new;
bound_other_ammo ();
2003-03-03 19:17:04 +00:00
if (self.ammo_shells) {
if (acount)
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, ", ");
acount = 1;
s = ftos(self.ammo_shells);
sprint (other, PRINT_LOW, s);
sprint (other, PRINT_LOW, " shells");
}
2003-03-03 19:17:04 +00:00
if (self.ammo_nails) {
if (acount)
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, ", ");
acount = 1;
s = ftos(self.ammo_nails);
sprint (other, PRINT_LOW, s);
sprint (other, PRINT_LOW, " nails");
}
2003-03-03 19:17:04 +00:00
if (self.ammo_rockets) {
if (acount)
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, ", ");
acount = 1;
s = ftos(self.ammo_rockets);
sprint (other, PRINT_LOW, s);
sprint (other, PRINT_LOW, " rockets");
}
2003-03-03 19:17:04 +00:00
if (self.ammo_cells) {
if (acount)
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, ", ");
acount = 1;
s = ftos(self.ammo_cells);
sprint (other, PRINT_LOW, s);
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, " cells");
}
2003-03-03 19:17:04 +00:00
sprint (other, PRINT_LOW, "\n");
2003-03-03 19:17:04 +00:00
// backpack touch sound
sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
2003-03-03 19:17:04 +00:00
// remove the backpack, change self to the player
remove (self);
self = other;
2003-03-03 19:17:04 +00:00
// change to the weapon
if (WeaponCode(new) <= b_switch) {
if (self.flags & FL_INWATER) {
if (new != IT_LIGHTNING)
Deathmatch_Weapon (old, new);
} else
Deathmatch_Weapon (old, new);
}
W_SetCurrentAmmo ();
};
2003-03-03 19:17:04 +00:00
void ()
DropBackpack =
{
local entity item;
2003-03-03 19:17:04 +00:00
if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets
+ self.ammo_cells))
return; // nothing in it
2003-03-03 19:17:04 +00:00
item = spawn ();
item.origin = self.origin - '0 0 24';
item.items = 0; // none by default
2003-03-03 19:17:04 +00:00
// ZOID -- axe doesn't go into backpack
if (self.weapon != IT_AXE)
item.items = self.weapon;
2003-03-03 19:17:04 +00:00
switch (item.items) {
case IT_SHOTGUN:
item.netname = "Shotgun";
2003-03-03 19:17:04 +00:00
break;
case IT_SUPER_SHOTGUN:
item.netname = "Double-barrelled Shotgun";
2003-03-03 19:17:04 +00:00
break;
case IT_NAILGUN:
item.netname = "Nailgun";
2003-03-03 19:17:04 +00:00
break;
case IT_SUPER_NAILGUN:
item.netname = "Super Nailgun";
2003-03-03 19:17:04 +00:00
break;
case IT_GRENADE_LAUNCHER:
item.netname = "Grenade Launcher";
2003-03-03 19:17:04 +00:00
break;
case IT_ROCKET_LAUNCHER:
item.netname = "Rocket Launcher";
2003-03-03 19:17:04 +00:00
break;
case IT_LIGHTNING:
item.netname = "Thunderbolt";
2003-03-03 19:17:04 +00:00
break;
default:
item.netname = "";
2003-03-03 19:17:04 +00:00
break;
}
item.ammo_shells = self.ammo_shells;
item.ammo_nails = self.ammo_nails;
item.ammo_rockets = self.ammo_rockets;
item.ammo_cells = self.ammo_cells;
2003-03-03 19:17:04 +00:00
item.velocity_x = (200 * random ()) - 100;
item.velocity_y = (200 * random ()) - 100;
item.velocity_z = 300;
item.flags = FL_ITEM;
item.solid = SOLID_TRIGGER;
item.movetype = MOVETYPE_TOSS;
setmodel (item, "progs/backpack.mdl");
setsize (item, '-16 -16 0', '16 16 56');
item.touch = BackpackTouch;
item.nextthink = time + 120; // remove after 2 minutes
item.think = SUB_Remove;
};
/*----------------------------------------------------------------------
The Rune Game modes
Rune 1 - Earth Magic
resistance
Rune 2 - Black Magic
strength
Rune 3 - Hell Magic
haste
Rune 4 - Elder Magic
regeneration
----------------------------------------------------------------------*/
2003-03-03 19:17:04 +00:00
entity ()
SelectRuneSpawnPoint =
{
2003-03-03 19:17:04 +00:00
runespawn = find (runespawn, classname, "info_player_deathmatch");
if (runespawn == world)
runespawn = find (runespawn, classname, "info_player_deathmatch");
if (runespawn == world)
2003-03-03 19:17:04 +00:00
error ("no info_player_deathmatch to spawn rune");
return runespawn;
};
2003-03-03 19:17:04 +00:00
void ()
RuneTouch =
{
if (other.classname != "player")
return;
if (other.health <= 0)
return;
if (other.player_flag & ITEM_RUNE_MASK) {
if (other.rune_notice_time < time) {
2003-03-03 19:17:04 +00:00
TeamPlayerUpdate (other, "You already have a rune.");
other.rune_notice_time = time + 5;
}
return; // one per customer
}
2003-03-03 19:17:04 +00:00
other.player_flag |= self.player_flag;
// notification of rune, no nofity in team mode
if (self.player_flag & ITEM_RUNE1_FLAG) {
2003-03-03 19:17:04 +00:00
self.items |= IT_SIGIL1;
if (teamplay == 0) {
2003-03-03 19:17:04 +00:00
bprint (PRINT_LOW, other.netname);
bprint (PRINT_LOW, " got the rune of <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>!\n");
}
TeamPlayerUpdate(other, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
if (self.player_flag & ITEM_RUNE2_FLAG) {
2003-03-03 19:17:04 +00:00
self.items |= IT_SIGIL2;
if (teamplay == 0) {
2003-03-03 19:17:04 +00:00
bprint (PRINT_LOW, other.netname);
bprint (PRINT_LOW, " got the rune of <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>!\n");
}
TeamPlayerUpdate(other, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
if (self.player_flag & ITEM_RUNE3_FLAG) {
2003-03-03 19:17:04 +00:00
self.items |= IT_SIGIL3;
if (teamplay == 0) {
2003-03-03 19:17:04 +00:00
bprint (PRINT_LOW, other.netname);
bprint (PRINT_LOW, " got the rune of <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>!\n");
}
2003-03-03 19:17:04 +00:00
TeamPlayerUpdate (other, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD>");
other.maxspeed = other.maxspeed * 1.25;
}
if (self.player_flag & ITEM_RUNE4_FLAG) {
2003-03-03 19:17:04 +00:00
self.items |= IT_SIGIL4;
if (teamplay == 0) {
2003-03-03 19:17:04 +00:00
bprint (PRINT_LOW, other.netname);
bprint (PRINT_LOW, " got the rune of <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>!\n");
}
2003-03-03 19:17:04 +00:00
TeamPlayerUpdate (other, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
// backpack touch sound
sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
2003-03-03 19:17:04 +00:00
remove (self);
};
void (float flag) Do_DropRune;
2003-03-03 19:17:04 +00:00
void ()
RuneRespawn =
{
2003-03-03 19:17:04 +00:00
local entity oself;
oself = self;
// choose random starting points
2003-03-03 19:17:04 +00:00
self = SelectRuneSpawnPoint ();
Do_DropRune (oself.player_flag);
2003-03-03 19:17:04 +00:00
remove (oself);
};
2003-03-03 19:17:04 +00:00
void (float flag)
Do_DropRune =
{
local entity item;
2003-03-03 19:17:04 +00:00
item = spawn ();
item.origin = self.origin - '0 0 24';
item.player_flag = flag;
2003-03-03 19:17:04 +00:00
item.velocity_x = -500 + (1000 * random ());
item.velocity_y = -500 + (1000 * random ());
item.velocity_z = 400;
item.flags = FL_ITEM;
item.solid = SOLID_TRIGGER;
item.movetype = MOVETYPE_TOSS;
if (flag & ITEM_RUNE1_FLAG)
setmodel (item, "progs/end1.mdl");
else if (flag & ITEM_RUNE2_FLAG)
setmodel (item, "progs/end2.mdl");
else if (flag & ITEM_RUNE3_FLAG)
setmodel (item, "progs/end3.mdl");
else if (flag & ITEM_RUNE4_FLAG)
setmodel (item, "progs/end4.mdl");
setsize (item, '-16 -16 0', '16 16 56');
item.touch = RuneTouch;
item.nextthink = time + 120; /* if no one touches it in two minutes,
respawn it somewhere else, so inaccessible ones will come 'back' */
item.think = RuneRespawn;
};
/*
===============
Droprune
self is player
===============
*/
2003-03-03 19:17:04 +00:00
void ()
DropRune =
{
if (self.player_flag & ITEM_RUNE1_FLAG)
2003-03-03 19:17:04 +00:00
Do_DropRune (ITEM_RUNE1_FLAG);
if (self.player_flag & ITEM_RUNE2_FLAG)
2003-03-03 19:17:04 +00:00
Do_DropRune (ITEM_RUNE2_FLAG);
if (self.player_flag & ITEM_RUNE3_FLAG)
2003-03-03 19:17:04 +00:00
Do_DropRune (ITEM_RUNE3_FLAG);
if (self.player_flag & ITEM_RUNE4_FLAG)
2003-03-03 19:17:04 +00:00
Do_DropRune (ITEM_RUNE4_FLAG);
self.player_flag &= ~ITEM_RUNE_MASK;
};
/*
================
SpawnRunes
spawn all the runes
self is the entity that was created for us, we remove it
================
*/
2003-03-03 19:17:04 +00:00
void ()
SpawnRunes =
{
2003-03-03 19:17:04 +00:00
local entity oself;
local float i;
oself = self;
// choose random starting points
2003-03-03 19:17:04 +00:00
i = 10 * random ();
while (i > 0) {
2003-03-03 19:17:04 +00:00
self = SelectRuneSpawnPoint ();
i--;
}
2003-03-03 19:17:04 +00:00
self = SelectRuneSpawnPoint ();
Do_DropRune (ITEM_RUNE1_FLAG);
self = SelectRuneSpawnPoint ();
Do_DropRune (ITEM_RUNE2_FLAG);
self = SelectRuneSpawnPoint ();
Do_DropRune (ITEM_RUNE3_FLAG);
self = SelectRuneSpawnPoint ();
Do_DropRune (ITEM_RUNE4_FLAG);
2003-03-03 19:17:04 +00:00
remove (oself);
};
2003-03-03 19:17:04 +00:00
void ()
StartRuneSpawn =
{
2003-03-03 19:17:04 +00:00
local entity rspawn;
if (runespawned || gamestart)
return;
runespawned = 1;
precache_model ("progs/end1.mdl");
precache_model ("progs/end2.mdl");
precache_model ("progs/end3.mdl");
precache_model ("progs/end4.mdl");
precache_model ("progs/m_s_key.mdl");
precache_model ("progs/m_g_key.mdl");
precache_sound("rune/rune1.wav");
precache_sound("rune/rune2.wav");
precache_sound("rune/rune22.wav"); // special rune and quad combo
precache_sound("rune/rune3.wav");
precache_sound("rune/rune4.wav");
// spawn the runes
2003-03-03 19:17:04 +00:00
rspawn = spawn ();
rspawn.nextthink = time + 0.1;
rspawn.think = SpawnRunes;
};