make backpacks drop keys

This commit is contained in:
alison wright 2019-09-16 14:24:18 -04:00
parent 43311591cd
commit 9edc786311

View File

@ -1,4 +1,32 @@
const string WEPNAME_AXE = "Axe";
const string WEPNAME_SHOTGUN = "Shotgun";
const string WEPNAME_SUPER_SHOTGUN = "Double-barrelled Shotgun";
const string WEPNAME_NAILGUN = "Nailgun";
const string WEPNAME_SUPER_NAILGUN = "Super Nailgun";
const string WEPNAME_GRENADE_LAUNCHER = "Grenade Launcher";
const string WEPNAME_ROCKET_LAUNCHER = "Rocket Launcher";
const string WEPNAME_LIGHTNING = "Thunderbolt";
void() W_SetCurrentAmmo;
string() Key1Name = {
switch(world.worldtype) {
case 0: return "silver key";
case 1: return "silver runekey";
case 2: return "silver keycard";
default: return string_null;
}
};
string() Key2Name = {
switch(world.worldtype) {
case 0: return "gold key";
case 1: return "gold runekey";
case 2: return "gold keycard";
default: return string_null;
}
};
/* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
BE .8 .3 .4 IN COLOR */
@ -497,7 +525,7 @@ 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.netname = WEPNAME_SUPER_SHOTGUN;
self.touch = weapon_touch;
setsize(self, '-16 -16 0', '16 16 56');
StartItem();
@ -510,7 +538,7 @@ void() weapon_nailgun = {
precache_model("progs/g_nail.mdl");
setmodel(self, "progs/g_nail.mdl");
self.weapon = IT_NAILGUN;
self.netname = "nailgun";
self.netname = WEPNAME_NAILGUN;
self.touch = weapon_touch;
setsize(self, '-16 -16 0', '16 16 56');
StartItem();
@ -523,7 +551,7 @@ 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.netname = WEPNAME_SUPER_NAILGUN;
self.touch = weapon_touch;
setsize(self, '-16 -16 0', '16 16 56');
StartItem();
@ -536,7 +564,7 @@ void() weapon_grenadelauncher = {
precache_model("progs/g_rock.mdl");
setmodel(self, "progs/g_rock.mdl");
self.weapon = 3;
self.netname = "Grenade Launcher";
self.netname = WEPNAME_GRENADE_LAUNCHER;
self.touch = weapon_touch;
setsize(self, '-16 -16 0', '16 16 56');
StartItem();
@ -549,7 +577,7 @@ void() weapon_rocketlauncher = {
precache_model("progs/g_rock2.mdl");
setmodel(self, "progs/g_rock2.mdl");
self.weapon = 3;
self.netname = "Rocket Launcher";
self.netname = WEPNAME_ROCKET_LAUNCHER;
self.touch = weapon_touch;
setsize(self, '-16 -16 0', '16 16 56');
StartItem();
@ -563,7 +591,7 @@ void() weapon_lightning = {
precache_model("progs/g_light.mdl");
setmodel(self, "progs/g_light.mdl");
self.weapon = 3;
self.netname = "Thunderbolt";
self.netname = WEPNAME_LIGHTNING;
self.touch = weapon_touch;
setsize(self, '-16 -16 0', '16 16 56');
StartItem();
@ -885,18 +913,20 @@ following:
*/
void() item_key1 = {
if(world.worldtype == 0) {
self.netname = Key1Name();
switch(world.worldtype) {
case 0:
precache_model("progs/w_s_key.mdl");
setmodel(self, "progs/w_s_key.mdl");
self.netname = "silver key";
} else if(world.worldtype == 1) {
break;
case 1:
precache_model("progs/m_s_key.mdl");
setmodel(self, "progs/m_s_key.mdl");
self.netname = "silver runekey";
} else if(world.worldtype == 2) {
break;
case 2:
precache_model2("progs/b_s_key.mdl");
setmodel(self, "progs/b_s_key.mdl");
self.netname = "silver keycard";
break;
}
key_setsounds();
self.touch = key_touch;
@ -917,20 +947,20 @@ following:
*/
void() item_key2 = {
if(world.worldtype == 0) {
self.netname = Key2Name();
switch(world.worldtype) {
case 0:
precache_model("progs/w_g_key.mdl");
setmodel(self, "progs/w_g_key.mdl");
self.netname = "gold key";
}
if(world.worldtype == 1) {
break;
case 1:
precache_model("progs/m_g_key.mdl");
setmodel(self, "progs/m_g_key.mdl");
self.netname = "gold runekey";
}
if(world.worldtype == 2) {
break;
case 2:
precache_model2("progs/b_g_key.mdl");
setmodel(self, "progs/b_g_key.mdl");
self.netname = "gold keycard";
break;
}
key_setsounds();
self.touch = key_touch;
@ -1167,24 +1197,20 @@ void() BackpackTouch = {
local entity stemp;
local float acount;
if(other.classname != "player") {
return;
}
if(other.health <= 0) {
if(other.classname != "player" || other.health <= 0) {
return;
}
acount = 0;
sprint(other, "You get ");
if(self.items)
if((other.items & self.items) == 0) {
if(self.items && (other.items & self.items) == 0) {
acount = 1;
sprint(other, "the ");
sprint(other, self.netname);
}
// if the player was using his best weapon, change up to the new one if better
// if the player was using their best weapon, change up to the new one if better
stemp = self;
self = other;
best = W_BestWeapon();
@ -1241,6 +1267,20 @@ void() BackpackTouch = {
sprint(other, s);
sprint(other, " cells");
}
if(self.items & IT_KEY1) {
if(acount) {
sprint(other, ", ");
}
acount = 1;
sprint(other, Key1Name());
}
if(self.items & IT_KEY2) {
if(acount) {
sprint(other, ", ");
}
acount = 1;
sprint(other, Key2Name());
}
sprint(other, "\n");
// backpack touch sound
@ -1266,33 +1306,29 @@ void() BackpackTouch = {
DropBackpack
===============
*/
void() DropBackpack = {
entity() DropBackpack = {
local entity item;
if(!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells)) {
return; // nothing in it
}
item = spawn();
item.origin = self.origin - '0 0 24';
item.items = self.weapon | (self.items & (IT_KEY1 | IT_KEY2));
item.items = self.weapon;
if(item.items == IT_AXE) {
item.netname = "Axe";
item.netname = WEPNAME_AXE;
} else if(item.items == IT_SHOTGUN) {
item.netname = "Shotgun";
item.netname = WEPNAME_SHOTGUN;
} else if(item.items == IT_SUPER_SHOTGUN) {
item.netname = "Double-barrelled Shotgun";
item.netname = WEPNAME_SUPER_SHOTGUN;
} else if(item.items == IT_NAILGUN) {
item.netname = "Nailgun";
item.netname = WEPNAME_NAILGUN;
} else if(item.items == IT_SUPER_NAILGUN) {
item.netname = "Super Nailgun";
item.netname = WEPNAME_SUPER_NAILGUN;
} else if(item.items == IT_GRENADE_LAUNCHER) {
item.netname = "Grenade Launcher";
item.netname = WEPNAME_GRENADE_LAUNCHER;
} else if(item.items == IT_ROCKET_LAUNCHER) {
item.netname = "Rocket Launcher";
item.netname = WEPNAME_ROCKET_LAUNCHER;
} else if(item.items == IT_LIGHTNING) {
item.netname = "Thunderbolt";
item.netname = WEPNAME_LIGHTNING;
} else {
item.netname = "";
}
@ -1315,4 +1351,6 @@ void() DropBackpack = {
item.nextthink = time + 120; // remove after 2 minutes
item.think = SUB_Remove;
return item;
};