Compare commits

..

2 Commits

Author SHA1 Message Date
9edc786311 make backpacks drop keys 2019-09-16 14:24:18 -04:00
43311591cd remove debug cvar (wow, good job id) 2019-09-16 14:23:37 -04:00
2 changed files with 102 additions and 67 deletions

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

View File

@ -558,10 +558,7 @@ void() PlayerDie = {
return; return;
} }
i = cvar("temp1"); i = 1 + floor(random() * 6);
if(!i) {
i = 1 + floor(random() * 6);
}
if(i == 1) { if(i == 1) {
player_diea1(); player_diea1();