Use entityDefs instead of hard-coded item pickups

This commit is contained in:
Marco Cawthorne 2023-05-08 11:18:29 -07:00
parent a3df1fdcb7
commit e52bea41a3
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
15 changed files with 94 additions and 156 deletions

View File

@ -1,98 +0,0 @@
/*
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void item_pickup::Touch(entity eToucher)
{
bool isDeathmatch = false;
if (eToucher.classname != "player") {
return;
}
/* don't remove if AddItem fails */
if (Weapons_AddItem((player)eToucher, id, m_iClip) == FALSE) {
return;
}
if (cvar("deathmatch") == 1 || cvar("deathmatch") == 2)
isDeathmatch = true;
Logging_Pickup(eToucher, this, __NULL__);
Sound_Play(other, CHAN_ITEM, "dmc_weapon.pickup");
UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
if (real_owner || m_iWasDropped == 1 || isDeathmatch == false) {
Destroy();
} else {
Disappear();
ScheduleThink(PickupRespawn, 30.0f);
}
}
void item_pickup::SetItem(int i)
{
id = i;
m_oldModel = Weapons_GetWorldmodel(id);
SetModel(GetSpawnModel());
SetSize([-16,-16,0], [16,16,16]);
}
void item_pickup::SetFloating(int i)
{
m_bFloating = rint(bound(0, m_bFloating, 1));
}
void
item_pickup::PickupRespawn(void)
{
Respawn();
Sound_Play(this, CHAN_ITEM, "dmc_item.respawn");
}
void item_pickup::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetOrigin(GetSpawnOrigin());
botinfo = BOTINFO_WEAPON;
modelflags = MF_ROTATE;
/* At some points, the item id might not yet be set */
if (GetSpawnModel()) {
SetModel(GetSpawnModel());
}
SetSize([-16,-16,0], [16,16,16]);
ReleaseThink();
if (!m_bFloating) {
DropToFloor();
SetMovetype(MOVETYPE_TOSS);
}
}
void
item_pickup::Spawned(void)
{
super::Spawned();
Sound_Precache("dmc_item.respawn");
Sound_Precache("dmc_weapon.pickup");
}
void item_pickup::item_pickup(void)
{
}

View File

@ -55,7 +55,7 @@ defs.h
../../../valve/src/server/monster_zombie.qc
../../../valve/src/server/player.qc
item_pickup.qc
../../../valve/src/server/items.qc
../../../valve/src/server/item_longjump.qc
../../../valve/src/server/item_suit.qc
../../../valve/src/server/item_healthkit.qc

View File

@ -257,11 +257,3 @@ w_grenadelauncher =
.type = w_grenadelauncher_type,
.hudpic = w_grenadelauncher_hudpic
};
#ifdef SERVER
void
weapon_grenadelauncher(void)
{
Weapons_InitItem(WEAPON_GRENADELAUNCHER);
}
#endif

View File

@ -391,11 +391,3 @@ weapon_t w_lightning =
.hudpic = w_lightning_hudpic,
.predraw = w_lightning_postdraw
};
#ifdef SERVER
void
weapon_lightning(void)
{
Weapons_InitItem(WEAPON_LIGHTNING);
}
#endif

View File

@ -242,12 +242,3 @@ weapon_t w_nailgun =
.type = w_nailgun_type,
.hudpic = w_nailgun_hudpic
};
/* pickups */
#ifdef SERVER
void
weapon_nailgun(void)
{
Weapons_InitItem(WEAPON_NAILGUN);
}
#endif

View File

@ -237,12 +237,4 @@ w_rocketlauncher =
.isempty = w_rocketlauncher_isempty,
.type = w_rocketlauncher_type,
.hudpic = w_rocketlauncher_hudpic
};
#ifdef SERVER
void
weapon_rocketlauncher(void)
{
Weapons_InitItem(WEAPON_ROCKETLAUNCHER);
}
#endif
};

View File

@ -229,7 +229,3 @@ weapon_t w_shotgun =
.type = w_shotgun_type,
.hudpic = w_shotgun_hudpic
};
#ifdef SERVER
#endif

View File

@ -229,12 +229,4 @@ weapon_t w_supernailgun =
.isempty = w_supernailgun_isempty,
.type = w_supernailgun_type,
.hudpic = w_supernailgun_hudpic
};
#ifdef SERVER
void
weapon_supernailgun(void)
{
Weapons_InitItem(WEAPON_SUPERNAILGUN);
}
#endif
};

View File

@ -245,13 +245,4 @@ weapon_t w_supershotgun =
.isempty = w_supershotgun_isempty,
.type = w_supershotgun_type,
.hudpic = w_supershotgun_hudpic
};
/* pickups */
#ifdef SERVER
void
weapon_supershotgun(void)
{
Weapons_InitItem(WEAPON_SUPERSHOTGUN);
}
#endif
};

View File

@ -0,0 +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"
"spawnclass" "NSItem"
"model" "models/g_rock.mdl"
"inv_item" "6"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View File

@ -0,0 +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"
"spawnclass" "NSItem"
"model" "models/g_light.mdl"
"inv_item" "8"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View File

@ -0,0 +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"
"spawnclass" "NSItem"
"model" "models/g_nail.mdl"
"inv_item" "4"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View File

@ -0,0 +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"
"spawnclass" "NSItem"
"model" "models/g_rock2.mdl"
"inv_item" "7"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View File

@ -0,0 +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"
"spawnclass" "NSItem"
"model" "models/g_nail2.mdl"
"inv_item" "5"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}

View File

@ -0,0 +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"
"spawnclass" "NSItem"
"model" "models/g_shot2.mdl"
"inv_item" "3"
"snd_acquire" "dmc_weapon.pickup"
"snd_respawn" "dmc_item.respawn"
"spin" "1"
}