From 14218576016a1017ee4020a909bbdae73e50ee2a Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sat, 15 Apr 2023 16:56:46 -0700 Subject: [PATCH] Set rotating flag on select pickups, make item_pickup sound DMC specific --- src/server/item_armor.qc | 1 + src/server/item_artifact.qc | 1 + src/server/item_pickup.qc | 98 +++++++++++++++++++++++++++ src/server/progs.src | 2 +- zpak001.pk3dir/sound/items_dmc.sndshd | 5 ++ 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 src/server/item_pickup.qc diff --git a/src/server/item_armor.qc b/src/server/item_armor.qc index 56d2fa6..cbb9ad0 100644 --- a/src/server/item_armor.qc +++ b/src/server/item_armor.qc @@ -51,6 +51,7 @@ item_armor::Respawn(void) SetOrigin(GetSpawnOrigin()); SetModel(GetSpawnModel()); SetSize([-16,-16,0],[16,16,16]); + modelflags = MF_ROTATE; ReleaseThink(); diff --git a/src/server/item_artifact.qc b/src/server/item_artifact.qc index 520cab1..6d6a7f4 100644 --- a/src/server/item_artifact.qc +++ b/src/server/item_artifact.qc @@ -53,6 +53,7 @@ item_artifact::Respawn(void) SetOrigin(GetSpawnOrigin()); SetModel(GetSpawnModel()); SetSize([-16,-16,0],[16,16,16]); + modelflags = MF_ROTATE; ReleaseThink(); diff --git a/src/server/item_pickup.qc b/src/server/item_pickup.qc new file mode 100644 index 0000000..03f8000 --- /dev/null +++ b/src/server/item_pickup.qc @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016-2020 Marco Cawthorne + * + * 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) +{ +} diff --git a/src/server/progs.src b/src/server/progs.src index 91b3c21..98c7e7e 100644 --- a/src/server/progs.src +++ b/src/server/progs.src @@ -55,7 +55,7 @@ ../../../valve/src/server/monster_zombie.qc ../../../valve/src/server/player.qc -../../../valve/src/server/items.qc +item_pickup.qc ../../../valve/src/server/item_longjump.qc ../../../valve/src/server/item_suit.qc ../../../valve/src/server/item_healthkit.qc diff --git a/zpak001.pk3dir/sound/items_dmc.sndshd b/zpak001.pk3dir/sound/items_dmc.sndshd index b92793a..ee7024e 100644 --- a/zpak001.pk3dir/sound/items_dmc.sndshd +++ b/zpak001.pk3dir/sound/items_dmc.sndshd @@ -57,4 +57,9 @@ item_artifact_super_damage.pickup dmc_item.respawn { sample items/itembk2.wav +} + +dmc_weapon.pickup +{ + sample weapons/pkup.wav } \ No newline at end of file