From a91122ccbeb30282e41e8e9e7377748840514387 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Fri, 22 Sep 2023 16:21:40 -0700 Subject: [PATCH] item_generic: initial implementation of this Opposing Force entity --- src/gs-entbase/server.src | 1 + src/gs-entbase/server/item_generic.qc | 93 +++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/gs-entbase/server/item_generic.qc diff --git a/src/gs-entbase/server.src b/src/gs-entbase/server.src index 6389471f..3a25e2f6 100644 --- a/src/gs-entbase/server.src +++ b/src/gs-entbase/server.src @@ -54,6 +54,7 @@ server/light.qc server/logic_auto.qc server/stubs.qc server/infodecal.qc +server/item_generic.qc server/player_weaponstrip.qc server/player_loadsaved.qc server/prop_dynamic.qc diff --git a/src/gs-entbase/server/item_generic.qc b/src/gs-entbase/server/item_generic.qc new file mode 100644 index 00000000..2021ef52 --- /dev/null +++ b/src/gs-entbase/server/item_generic.qc @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016-2022 Vera Visions LLC. + * + * 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. +*/ + +/*!QUAKED scripted_sequence (1 0 0) (-8 -8 -8) (8 8 8) +# OVERVIEW +A 'generic' decorative entity which uses an animation sequence. + +# KEYS +- "targetname" : Name +- "target" : Target when triggered. +- "killtarget" : Target to kill when triggered. +- "sequencename" : Animation sequence to play, by name. +- "body" : Which bodygroup to use. +- "skin" : Which skin to use. + +# TRIVIA +This entity was introduced in Half-Life: Opposing Force (1999). +*/ +class +item_generic:NSRenderableEntity +{ +public: + void item_generic(void); + + virtual void Respawn(void); + virtual void SpawnKey(string, string); +private: + string m_strSequenceName; +}; + +void +item_generic::item_generic(void) +{ + m_strSequenceName = ""; +} + +void +item_generic::Save(float handle) +{ + super::Save(handle); + SaveString(handle, "m_strSequenceName", m_strSequenceName); +} + +void +item_generic::Restore(string strKey, string strValue) +{ + switch (strKey) { + case "m_strSequenceName": + m_strSequenceName = ReadString(strValue); + break; + default: + super::Restore(strKey, strValue); + } +} + +void +item_generic::SpawnKey(string strKey, string strValue) +{ + switch (strKey) { + case "sequencename": + m_strSequenceName = strValue; + break; + default: + super::SpawnKey(strKey, strValue); + } +} + +void +item_generic::Respawn(void) +{ + SetOrigin(GetSpawnOrigin()); + SetAngles(GetSpawnAngles()); + SetModel(GetSpawnModel()); + SetSize([0,0,0], [0,0,0]); + SetSolid(SOLID_NOT); + SetMovetype(MOVETYPE_NONE); + + if (m_strSequenceName) + SetFrame(frameforname(GetModelindex(), m_strSequenceName)); +} \ No newline at end of file