From 8760402b1c725c443a28d751b8699f18cfea3c98 Mon Sep 17 00:00:00 2001 From: drjaska Date: Tue, 19 Nov 2024 17:39:25 +0200 Subject: [PATCH] Refactor respawn ghosts to death ghosts The name "respawn ghost" will remain as obsolete legacy as it's impossible to rename it fully without breaking changes as clients have a particle effect with that name. --- .gitlab-ci.yml | 2 +- qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc | 2 ++ qcsrc/server/client.qc | 10 +------ qcsrc/server/client.qh | 1 - qcsrc/server/player.qc | 26 +++++++++---------- xonotic-client.cfg | 2 +- xonotic-server.cfg | 11 ++++---- 7 files changed, 23 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55eb8a1bb..48573bc3d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,7 +36,7 @@ test_compilation_units: test_sv_game: stage: test script: - - export EXPECT=e67187c8446f97a8b062a431dccb89e0 + - export EXPECT=1b80629ffd60bdd46befff04559d1fb9 - qcsrc/tools/sv_game-hashtest.sh - exit $? diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 39f45666d..1c30a3a48 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -1360,6 +1360,8 @@ void ctf_FlagSetup(int teamnum, entity flag) // called when spawning a flag enti flag.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP; flag.damagedbytriggers = autocvar_g_ctf_flag_return_when_unreachable; flag.damagedbycontents = false; // can be damaged by contents only when dropped + if(IL_CONTAINS(g_damagedbycontents, flag)) + IL_REMOVE(g_damagedbycontents, flag); flag.velocity = '0 0 0'; flag.mangle = flag.angles; diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index ad6433000..70d62dc3f 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1469,15 +1469,7 @@ void respawn(entity this) { bool damagedbycontents_prev = this.damagedbycontents; if(this.alpha >= 0) - { - if(autocvar_g_respawn_ghosts - && !(this.effects & EF_NODRAW)) // only spawn one ghost - { - TransmuteToGhost(this); - } - else - SUB_SetFade (this, time, 1); // fade out the corpse immediately - } + SUB_SetFade (this, time, 1); // fade out the corpse immediately CopyBody(this, 1); this.damagedbycontents = damagedbycontents_prev; diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index d7240d952..d7fb94837 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -26,7 +26,6 @@ int autocvar_g_respawn_delay_large_count; float autocvar_g_respawn_delay_max; bool autocvar_g_respawn_delay_forced; bool autocvar_g_respawn_ghosts; -bool autocvar_g_respawn_ghosts_gib; float autocvar_g_respawn_ghosts_alpha = 1; float autocvar_g_respawn_ghosts_fadetime = 1.5; float autocvar_g_respawn_ghosts_time = 4.5; diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index a529fabfb..2a823b61c 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -220,23 +220,12 @@ void PlayerCorpseDamage(entity this, entity inflictor, entity attacker, float da this.view_ofs = '0 0 4'; Violence_GibSplash(this, 1, 1, attacker); - //this.alpha = -1; //postpone after potential ghost spawn to avoid temp storing + this.alpha = -1; this.solid = SOLID_NOT; // restore later this.takedamage = DAMAGE_NO; // restore later if(this.damagedbycontents) IL_REMOVE(g_damagedbycontents, this); this.damagedbycontents = false; - - if(autocvar_g_respawn_ghosts - && autocvar_g_respawn_ghosts_gib - && !(this.effects & EF_NODRAW)) // only spawn one ghost - { - TransmuteToGhost(this); - - CopyBody(this, 1); - this.effects |= EF_NODRAW; // prevent another CopyBody and 2nd ghost spawns - } - this.alpha = -1; } } @@ -616,6 +605,15 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, } }); } + + if (autocvar_g_respawn_ghosts) + { + // spawn a ghost as the player died + //entity oldbody = CopyBody(this, 1); + CopyBody(this, 1); + TransmuteToGhost(this); + } + MUTATOR_CALLHOOK(PlayerDied, this); } } @@ -638,12 +636,14 @@ void TransmuteToGhost(entity this) this.solid = SOLID_NOT; this.takedamage = DAMAGE_NO; + if(this.damagedbycontents) + IL_REMOVE(g_damagedbycontents, this); this.damagedbycontents = false; set_movetype(this, MOVETYPE_FLY); this.velocity = '0 0 1' * autocvar_g_respawn_ghosts_speed; this.avelocity = randomvec() * autocvar_g_respawn_ghosts_speed * 3 - randomvec() * autocvar_g_respawn_ghosts_speed * 3; this.effects |= CSQCMODEL_EF_RESPAWNGHOST; - this.alpha = min(this.alpha, autocvar_g_respawn_ghosts_alpha); + this.alpha = autocvar_g_respawn_ghosts_alpha; Send_Effect(EFFECT_RESPAWN_GHOST, this.origin, '0 0 0', 1); if(autocvar_g_respawn_ghosts_time > 0) SUB_SetFade(this, time + autocvar_g_respawn_ghosts_time, autocvar_g_respawn_ghosts_fadetime); diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 4f36583a7..19d7e56d1 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -238,7 +238,7 @@ seta cl_damageeffect_lifetime_max 6 "maximum lifetime a damage effect may have" set cl_deathglow 2 "number of seconds during which dead bodies glow out" set cl_deathglow_min 0.5 "glow out up to this glow factor" -set cl_respawn_ghosts_keepcolors 1 "if enabled respawn ghosts keep body colors" +set cl_respawn_ghosts_keepcolors 1 "if enabled player ghosts keep body colors" set _teams_available 0 "internal cvar, value is synced from the server to reflect currently available teams to join" diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 7d62a345a..39080d1f5 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -59,12 +59,11 @@ set g_telefrags_avoid 1 "when teleporters have a random destination, avoid telep set g_teleport_maxspeed 0 "maximum speed that a player can keep when going through a teleporter (if a misc_teleporter_dest also has a cap the smallest one of these will be used), 0 = don't limit, -1 = keep no speed" set g_teleport_minspeed 0 "minimum speed that a player can keep when going through a teleporter which affects speed" -set g_respawn_ghosts 1 "if 1 dead bodies become ghosts and float away when the player respawns" -set g_respawn_ghosts_gib 0 "spawn a ghost for gibbed players instantly" -set g_respawn_ghosts_speed 5 "the speed with which respawn ghosts float and rotate" -set g_respawn_ghosts_time 4.5 "amount of time a respawn ghost lasts before it starts fading out. 0 disables and ghosts fade when the body would" -set g_respawn_ghosts_fadetime 1.5 "amount of time a respawn ghost takes to fade out" -set g_respawn_ghosts_alpha 1 "respawn ghost alpha" +set g_respawn_ghosts 1 "if 1 dead players leave behind ghosts which float away" +set g_respawn_ghosts_speed 5 "the speed with which ghosts float and rotate" +set g_respawn_ghosts_time 4.5 "amount of time a ghost lasts before it starts fading out. 0 disables and ghosts fade when the body would" +set g_respawn_ghosts_fadetime 1.5 "amount of time a ghost takes to fade out" +set g_respawn_ghosts_alpha 1 "ghost alpha" set sv_gibhealth 100 "Minus health a dead body must have in order to get gibbed" -- 2.39.2