hhdeath/src/server/items.qc

103 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2021-02-11 10:06:14 -08:00
/*
2022-03-13 16:56:13 -07:00
* Copyright (c) 2016-2020 Marco Cawthorne <marco@icculus.org>
2021-02-11 10:06:14 -08:00
*
* 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
2022-04-03 14:07:09 -07:00
item_pickup::Touch(entity eToucher)
2021-02-11 10:06:14 -08:00
{
if (other.classname != "player") {
return;
}
player pl = (player)other;
if (pl.g_items & ITEM_MACHETTE) {
return;
}
/* don't remove if AddItem fails */
if (Weapons_AddItem((player)other, id, m_iClip) == FALSE) {
return;
}
Logging_Pickup(other, this, __NULL__);
Sound_Play(other, CHAN_ITEM, "weapon.pickup");
super::UseTargets(this, TRIG_TOGGLE, 0.0f);
2021-02-11 10:06:14 -08:00
if (real_owner || m_iWasDropped == 1 || cvar("sv_playerslots") == 1) {
2023-01-18 19:45:26 -08:00
Destroy();
2021-02-11 10:06:14 -08:00
} else {
2023-01-18 19:45:26 -08:00
Disappear();
2023-02-12 13:03:49 -08:00
ScheduleThink(PickupRespawn, 30.0f);
2021-02-11 10:06:14 -08:00
}
}
2023-02-12 13:03:49 -08:00
void
item_pickup::PickupRespawn(void)
{
Respawn();
Sound_Play(this, CHAN_ITEM, "item.respawn");
}
void
item_pickup::SetItem(int i)
2021-02-11 10:06:14 -08:00
{
id = i;
GetSpawnModel() = Weapons_GetWorldmodel(id);
SetModel(GetSpawnModel());
2021-02-11 10:06:14 -08:00
}
void
item_pickup::SetFloating(int i)
2021-02-11 10:06:14 -08:00
{
m_bFloating = rint(bound(0, m_bFloating, 1));
}
void
item_pickup::Respawn(void)
2021-02-11 10:06:14 -08:00
{
SetSolid(SOLID_TRIGGER);
SetOrigin(GetSpawnOrigin());
2021-02-11 10:06:14 -08:00
/* At some points, the item id might not yet be set */
if (GetSpawnModel()) {
SetModel(GetSpawnModel());
2021-02-11 10:06:14 -08:00
}
SetSize([-16,-16,0], [16,16,16]);
think = __NULL__;
nextthink = -1;
if (!m_bFloating) {
droptofloor();
SetMovetype(MOVETYPE_TOSS);
}
}
void
item_pickup::Spawned(void)
2021-02-11 10:06:14 -08:00
{
Sound_Precache("item.respawn");
Sound_Precache("weapon.pickup");
}
void
item_pickup::item_pickup(void)
{
super::NSRenderableEntity();
2021-02-11 10:06:14 -08:00
Respawn();
}