Fix the backpack/weaponbox from not dropping

This commit is contained in:
Marco Cawthorne 2023-05-10 14:34:49 -07:00
parent e52bea41a3
commit f86934b685
Signed by: eukara
GPG key ID: CE2032F0A2882A22
14 changed files with 111 additions and 96 deletions

View file

@ -47,6 +47,11 @@ HLGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type
return;
}
if (t.health > 100)
t.max_health = 200;
else
t.max_health = 100;
super::DamageApply(t, c, dmg, w, type);
}

View file

@ -43,6 +43,8 @@ HLMultiplayerRules::IsTeamplay(void)
void
HLMultiplayerRules::InitPostEnts(void)
{
precache_model("models/backpack.mdl");
MOTD_LoadDefault();
if (IsTeamplay() == true) {
@ -125,6 +127,8 @@ HLMultiplayerRules::PlayerDeath(NSClientPlayer pl)
FX_Corpse_Spawn((player)pl, ANIM_DIESIMPLE);
}
dmc_backpack_spawn((player)pl);
/* now let's make the real client invisible */
pl.Death();
pl.SetTakedamage(DAMAGE_NO);

View file

@ -14,12 +14,12 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class item_weaponbox:NSRenderableEntity
class item_backpack:NSRenderableEntity
{
int weapon_items;
int weapon_item;
void(void) item_weaponbox;
void(void) item_backpack;
virtual void(void) Spawned;
virtual void(entity) Touch;
@ -27,7 +27,7 @@ class item_weaponbox:NSRenderableEntity
};
void
item_weaponbox::Touch(entity eToucher)
item_backpack::Touch(entity eToucher)
{
if (eToucher.classname != "player") {
return;
@ -48,45 +48,49 @@ item_weaponbox::Touch(entity eToucher)
pl.ammo_rockets = min(pl.ammo_rockets, MAX_A_ROCKETS);
pl.ammo_cells = min(pl.ammo_cells, MAX_A_CELLS);
pl.g_items |= weapon_items;
pl.g_items |= g_weapons[weapon_item].id;
Weapons_RefreshAmmo(pl);
sprint(pl, PRINT_HIGH, sprintf("You get the %s, %d shells, %d nails, %d rockets, %d cells\n", g_weapons[weapon_item].name, ammo_shells, ammo_nails, ammo_rockets, ammo_cells));
Destroy();
}
void
item_weaponbox::setup(player pl)
item_backpack::setup(player pl)
{
/* TODO: Should the magazine bits be transferred too? */
ammo_shells = pl. ammo_shells;
ammo_nails = pl. ammo_nails;
ammo_rockets = pl.ammo_rockets;
ammo_cells = pl.ammo_cells;
weapon_items = pl.g_items;
}
void
item_weaponbox::Spawned(void)
item_backpack::Spawned(void)
{
super::Spawned();
SetModel("models/w_weaponbox.mdl");
SetModel("models/backpack.mdl");
SetSize([-16,-16,0], [16,16,16]);
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_TOSS);
modelflags = MF_ROTATE;
}
void
item_weaponbox::item_weaponbox(void)
item_backpack::item_backpack(void)
{
botinfo = BOTINFO_AMMO;
}
void
weaponbox_spawn(player spawner)
dmc_backpack_spawn(player spawner)
{
item_weaponbox weaponbox = spawn(item_weaponbox);
item_backpack weaponbox = spawn(item_backpack);
weaponbox.Spawned();
weaponbox.SetOrigin(spawner.origin);
weaponbox.setup(spawner);
weaponbox.ammo_shells = spawner.ammo_shells;
weaponbox.ammo_nails = spawner.ammo_nails;
weaponbox.ammo_rockets = spawner.ammo_rockets;
weaponbox.ammo_cells = spawner.ammo_cells;
weaponbox.weapon_item = spawner.activeweapon;
//bprint(PRINT_HIGH, sprintf("Dropped the %s, %d shells, %d nails, %d rockets, %d cells.\n", g_weapons[weapon_item].name, ammo_shells, ammo_nails, ammo_rockets, ammo_cells));
}

View file

@ -121,6 +121,7 @@ w_nailgun_primary(player pl)
entity nail = spawn();
setmodel(nail, "models/spike.mdl");
vector velOffset = pl.velocity * input_timelength;
setsize(nail, g_vec_null, g_vec_null);
nail.movetype = MOVETYPE_FLYMISSILE;
nail.solid = SOLID_BBOX;
@ -129,10 +130,10 @@ w_nailgun_primary(player pl)
Weapons_MakeVectors(pl);
if (pl.ammo_nails & 1) {
setorigin(nail, Weapons_GetCameraPos(pl) + (v_right * -2) + (v_up * -5));
setorigin(nail, velOffset + Weapons_GetCameraPos(pl) + (v_right * -2) + (v_up * -5));
nail.velocity = v_forward * 1000 + (v_right * -2) + (v_up * -5);
} else {
setorigin(nail, Weapons_GetCameraPos(pl) + (v_right * 2) + (v_up * -5));
setorigin(nail, velOffset + Weapons_GetCameraPos(pl) + (v_right * 2) + (v_up * -5));
nail.velocity = v_forward * 1000 + (v_right * 2) + (v_up * -5);
}
nail.angles = vectoangles(nail.velocity);

View file

@ -128,7 +128,8 @@ w_supernailgun_primary(player pl)
entity nail = spawn();
setmodel(nail, "models/spike.mdl");
setorigin(nail, Weapons_GetCameraPos(pl) + (v_up * -5));
vector velOffset = pl.velocity * input_timelength;
setorigin(nail, velOffset + Weapons_GetCameraPos(pl) + (v_up * -5));
setsize(nail, g_vec_null, g_vec_null);
nail.movetype = MOVETYPE_FLYMISSILE;
nail.solid = SOLID_BBOX;

View file

@ -1,13 +1,13 @@
entityDef q3_item_health_large {
spawnclass item_health
"spawnclass" "item_health"
}
entityDef q3_item_health_mega {
spawnclass item_health
spawnflags 2
"spawnclass" "item_health"
"spawnflags" "2"
}
entityDef q3_item_health_small {
spawnclass item_health
spawnflags 1
"spawnclass" "item_health"
"spawnflags" "1"
}

View file

@ -1,5 +1,5 @@
// Quake 1's buttons are triggered by touch most of the time
entityDef q1_func_button {
spawnclass func_button
spawnflags 256
"spawnclass" "func_button"
"spawnflags" "256"
}

View file

@ -1,4 +1,4 @@
entityDef dmc_trigger_teleport {
spawnclass trigger_teleport
snd_teleport "dmc_teleporter.teleported"
"spawnclass" "trigger_teleport"
"snd_teleport" "dmc_teleporter.teleported"
}

View file

@ -1,15 +1,15 @@
entityDef weapon_grenadelauncher
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Grenade Launcher"
"editor_rotatable" "1"
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Grenade Launcher"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/g_rock.mdl"
"inv_item" "6"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
"spawnclass" "NSItem"
"model" "models/g_rock.mdl"
"inv_item" "6"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View file

@ -1,15 +1,15 @@
entityDef weapon_lightning
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Lightning Gun"
"editor_rotatable" "1"
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Lightning Gun"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/g_light.mdl"
"inv_item" "8"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
"spawnclass" "NSItem"
"model" "models/g_light.mdl"
"inv_item" "8"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View file

@ -1,15 +1,15 @@
entityDef weapon_nailgun
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Nailgun"
"editor_rotatable" "1"
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Nailgun"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/g_nail.mdl"
"inv_item" "4"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
"spawnclass" "NSItem"
"model" "models/g_nail.mdl"
"inv_item" "4"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View file

@ -1,15 +1,15 @@
entityDef weapon_rocketlauncher
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Rocket Launcher"
"editor_rotatable" "1"
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Rocket Launcher"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/g_rock2.mdl"
"inv_item" "7"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
"spawnclass" "NSItem"
"model" "models/g_rock2.mdl"
"inv_item" "7"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View file

@ -1,15 +1,15 @@
entityDef weapon_supernailgun
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Super Nailgun"
"editor_rotatable" "1"
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Super Nailgun"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/g_nail2.mdl"
"inv_item" "5"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
"spawnclass" "NSItem"
"model" "models/g_nail2.mdl"
"inv_item" "5"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View file

@ -1,15 +1,15 @@
entityDef weapon_supershotgun
{
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Super Shotgun"
"editor_rotatable" "1"
"editor_color" ".3 .3 1"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 32"
"editor_usage" "Super Shotgun"
"editor_rotatable" "1"
"spawnclass" "NSItem"
"model" "models/g_shot2.mdl"
"inv_item" "3"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
"spawnclass" "NSItem"
"model" "models/g_shot2.mdl"
"inv_item" "3"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}