From 3bb88216c88040d24bc66a95d4c7eeffc50b5db5 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 6 Nov 2021 07:15:13 +0100 Subject: [PATCH] Add DAMAGE_MATERIAL as a possible .takedamage value, this may just be a temp way for model based entities to communicate whether or not they use that in-model surfaceflags. --- src/gs-entbase/client.src | 1 - src/gs-entbase/server.src | 2 + src/gs-entbase/server/prop_dynamic.qc | 63 +++++++++++++++ .../prop_dynamic.qc => server/prop_static.qc} | 81 +++++-------------- src/shared/damage.h | 6 ++ src/shared/surfaceproperties.qc | 2 +- 6 files changed, 94 insertions(+), 61 deletions(-) create mode 100644 src/gs-entbase/server/prop_dynamic.qc rename src/gs-entbase/{client/prop_dynamic.qc => server/prop_static.qc} (59%) diff --git a/src/gs-entbase/client.src b/src/gs-entbase/client.src index 21e3d55f..4b2b6d0c 100644 --- a/src/gs-entbase/client.src +++ b/src/gs-entbase/client.src @@ -22,6 +22,5 @@ client/infodecal.qc client/sky_camera.qc client/info_notnull.qc client/point_message.qc -client/prop_dynamic.qc client/prop_rope.qc #endlist diff --git a/src/gs-entbase/server.src b/src/gs-entbase/server.src index ad54005b..bcb1b14c 100644 --- a/src/gs-entbase/server.src +++ b/src/gs-entbase/server.src @@ -59,6 +59,8 @@ server/infodecal.qc server/player_weaponstrip.qc server/player_loadsaved.qc server/prop_physics.qc +server/prop_dynamic.qc +server/prop_static.qc server/point_camera.qc server/targ_speaker.qc server/target_cdaudio.qc diff --git a/src/gs-entbase/server/prop_dynamic.qc b/src/gs-entbase/server/prop_dynamic.qc new file mode 100644 index 00000000..859afccd --- /dev/null +++ b/src/gs-entbase/server/prop_dynamic.qc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016-2020 Marco Hladik + * + * 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 prop_dynamic (0 0.2 1) (-8 -8 -8) (8 8 8) SF_BASIC_COL +Client-side decorative model entity. + +-------- KEYS -------- +"model" : Model file that will be displayed by the entity. +"modelscale" : Scale modifier of the model. Default is "1". +"angles" : Sets the pitch, yaw and roll angles of the model. +"_cs" : Toggles if the prop casts a shadow or not. + +-------- TRIVIA -------- +This entity was introduced in Half-Life 2 (2004). +*/ + +class prop_dynamic:NSRenderableEntity +{ + void(void) prop_dynamic; + + virtual void(void) Respawn; + virtual void(string, string) SpawnKey; +}; + +void +prop_dynamic::Respawn(void) +{ + super::Respawn(); + SetModel(GetSpawnModel()); + SetSolid(SOLID_CORPSE); + takedamage = DAMAGE_MATERIAL; +} + +void +prop_dynamic::SpawnKey(string strKey, string strValue) +{ + switch (strKey) { + case "modelscale": + scale = stof(strValue); + break; + default: + super::SpawnKey(strKey, strValue); + } +} + +void +prop_dynamic::prop_dynamic(void) +{ + super::NSRenderableEntity(); +} \ No newline at end of file diff --git a/src/gs-entbase/client/prop_dynamic.qc b/src/gs-entbase/server/prop_static.qc similarity index 59% rename from src/gs-entbase/client/prop_dynamic.qc rename to src/gs-entbase/server/prop_static.qc index 4316921d..9928fa59 100644 --- a/src/gs-entbase/client/prop_dynamic.qc +++ b/src/gs-entbase/server/prop_static.qc @@ -14,19 +14,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/*QUAKED prop_dynamic (0 0.2 1) (-8 -8 -8) (8 8 8) SF_BASIC_COL -Client-side decorative model entity. - --------- KEYS -------- -"model" : Model file that will be displayed by the entity. -"modelscale" : Scale modifier of the model. Default is "1". -"angles" : Sets the pitch, yaw and roll angles of the model. -"_cs" : Toggles if the prop casts a shadow or not. - --------- TRIVIA -------- -This entity was introduced in Half-Life 2 (2004). -*/ - /*QUAKED prop_static (0 0.2 1) (-8 -8 -8) (8 8 8) SF_BASIC_COL Decorative model entity that gets baked into the level file. @@ -51,61 +38,37 @@ waste disk space and memory. Use wisely. This entity was introduced in Half-Life 2 (2004). */ -class prop_dynamic:NSRenderableEntity +class prop_static:NSRenderableEntity { - void(void) prop_dynamic; + void(void) prop_static; - virtual void(void) Init; + virtual void(void) Respawn; virtual void(string, string) SpawnKey; - virtual float(void) predraw; }; void -prop_dynamic::SpawnKey(string strField, string strKey) +prop_static::Respawn(void) { - switch (strField) { - case "modelscale": - scale = stof(strKey); - break; - case "angle": - angles[1] = stof(strKey); - break; - case "avelocity": - avelocity = stov(strKey); - break; - default: - super::SpawnKey(strField, strKey); + super::Respawn(); + SetModel(GetSpawnModel()); + SetSolid(SOLID_CORPSE); + takedamage = DAMAGE_MATERIAL; +} + +void +prop_static::SpawnKey(string strKey, string strValue) +{ + switch (strKey) { + case "modelscale": + scale = stof(strValue); + break; + default: + super::SpawnKey(strKey, strValue); } } -float -prop_dynamic::predraw(void) -{ - angles += avelocity * frametime; - return super::predraw(); -} void -prop_dynamic::Init(void) +prop_static::prop_static(void) { - super::Init(); - - precache_model(model); - setmodel(this, model); - setorigin(this, origin); - solid = SOLID_NOT; - movetype = MOVETYPE_NONE; - setsize(this, mins * scale, maxs * scale); - drawmask = MASK_ENGINE; - - if (vlen(avelocity) == 0) - MakeStatic(); -} - -void -prop_dynamic::prop_dynamic(void) -{ - scale = 1.0f; - Init(); -} - -CLASSEXPORT(prop_static, prop_dynamic) + super::NSRenderableEntity(); +} \ No newline at end of file diff --git a/src/shared/damage.h b/src/shared/damage.h index ad7e2a0e..baa35725 100644 --- a/src/shared/damage.h +++ b/src/shared/damage.h @@ -42,3 +42,9 @@ typedef enumflags DMG_SKIP_ARMOR, DMG_SKIP_RAGDOLL } damageType_t; + +/* takedamage types */ +const float DAMAGE_NO = 0; +const float DAMAGE_YES = 1; +const float DAMAGE_AIM = 2; +const float DAMAGE_MATERIAL = 3; \ No newline at end of file diff --git a/src/shared/surfaceproperties.qc b/src/shared/surfaceproperties.qc index fd2a598c..75816e8c 100644 --- a/src/shared/surfaceproperties.qc +++ b/src/shared/surfaceproperties.qc @@ -415,7 +415,7 @@ SurfData_Finish(void) void SurfData_Impact(entity e, int fl, vector org, vector ang) { - if (e == world || e.health == 0) { /* the static world */ + if (e == world || e.health == 0 || e.takedamage == 3) { /* the static world */ switch (serverkeyfloat("*bspversion")) { case BSPVER_HL: float surf;