bool damagedbycontents_prev = this.damagedbycontents;
if(this.alpha >= 0)
{
- if(autocvar_g_respawn_ghosts && !(this.effects & EF_NODRAW))
+ if(autocvar_g_respawn_ghosts
+ && !(this.effects & EF_NODRAW)) // only spawn one ghost
{
- this.solid = SOLID_NOT;
- this.takedamage = DAMAGE_NO;
- 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);
- 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);
+ SpawnGhost(this);
}
else
SUB_SetFade (this, time, 1); // fade out the corpse immediately
IL_REMOVE(g_damagedbycontents, this);
this.damagedbycontents = false;
- if (autocvar_g_respawn_ghosts)
+ if(autocvar_g_respawn_ghosts
+ && autocvar_g_respawn_ghosts_gib
+ && !(this.effects & EF_NODRAW)) // only spawn one ghost
{
- //this.solid = SOLID_NOT; // already set above
- //this.takedamage = DAMAGE_NO;
- //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);
- 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);
+ SpawnGhost(this);
CopyBody(this, 1);
this.effects |= EF_NODRAW; // prevent another CopyBody and 2nd ghost spawns
return true;
}
+void SpawnGhost(entity this)
+{
+ // effects are disabled or one ghost was already spawned
+ if (this.effects & EF_NODRAW)
+ return;
+
+ this.solid = SOLID_NOT;
+ this.takedamage = DAMAGE_NO;
+ 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);
+ 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);
+}
+
void precache_playermodel(string m)
{
int globhandle, i, n;
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"