X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=863f8b61c1f9d1775b5ad76d8e5626c2ee4f24df;hb=645c441d589f9672bffb8fef9cc34a5c747cc9a8;hp=592284562cca0be1cbba34e8c0f3d063263b7a2b;hpb=10596d2f983e1a570da941d64e3462ee3fe4980a;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 59228456..863f8b61 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -117,7 +117,7 @@ void Vore_CameraEffect_Apply() } .float gurgle_oldstomachload; -void Vore_Gurglesound() +void Vore_GurgleSound() { if(time > self.gurglesound_finished || self.gurgle_oldstomachload != self.stomach_load) { @@ -128,7 +128,7 @@ void Vore_Gurglesound() } } -void Vore_Weight_apply(entity e) +void Vore_WeightApply(entity e) { // apply stomach weight that makes you heavier the more you eat // slowing the player is done in cl_physics.qc @@ -140,6 +140,31 @@ void Vore_Weight_apply(entity e) e.vore_oldstomachload = e.stomach_load; } +void Vore_AutoDigest(entity e) +{ + // if the predator has the autodigest preference enabled, begin digesting new prey automatically + + if(!cvar("g_vore_digestion") || e.digesting) + return; + if(!e.cvar_cl_vore_autodigest || clienttype(e) != CLIENTTYPE_REAL) + return; // this feature is only for players, not bots + if(e.stomach_load > 1) + return; // don't start digestion if we already ate someone, as that means we manually disabled it after the first prey and want it off + + entity head; + if(teams_matter) + { + FOR_EACH_PLAYER(head) + { + // never begin automatic digestion if we've swallowed a team mate + if(head.predator == e && head.team == e.team) + return; + } + } + + e.digesting = TRUE; +} + .entity pusher; .float pushltime; void Vore_Swallow(entity e) @@ -179,7 +204,8 @@ void Vore_Swallow(entity e) e.predator.stomach_load += 1; e.predator.regurgitate_prepare = 0; e.predator.spawnshieldtime = 0; // lose spawn shield when we vore - Vore_Weight_apply(e.predator); + Vore_WeightApply(e.predator); + Vore_AutoDigest(e.predator); // block firing for a small amount of time, or we'll be firing the next frame after we swallow e.predator.weapon_delay = time + button_delay_time; @@ -219,7 +245,7 @@ void Vore_Regurgitate(entity e) e.predator.stomach_load -= 1; e.predator.regurgitate_prepare = 0; e.predator.swallow_delay = time + cvar("g_balance_vore_swallow_delay"); - Vore_Weight_apply(e.predator); + Vore_WeightApply(e.predator); // block firing for a small amount of time, or we'll be firing the next frame e.weapon_delay = time + button_delay_time; @@ -227,13 +253,70 @@ void Vore_Regurgitate(entity e) e.predator = world; } +void Vore_DeadPrey_Configure(entity e) +{ + // ran when the keepdeadprey feature is enabled and prey stays inside the stomach after dying + + if(e.fakeprey || e.predator.classname != "player") // already configured + return; + + // this entity is like e.predator but for dead prey, to avoid conflicts + e.fakepredator = e.predator; + e.fakeprey = TRUE; + + // first release the prey from the predator, as dead prey needs to be attached differently + // the predator's stomach load is also decreased, as dead prey doesn't count any more + e.predator.stomach_load -= 1; + Vore_WeightApply(e.predator); + e.predator = world; + + // now put our dead prey inside the predator's stomach, but only as an effect + e.movetype = MOVETYPE_FOLLOW; + e.takedamage = DAMAGE_NO; + e.solid = SOLID_NOT; + e.aiment = e.fakepredator; + + // completely remove the dead body + e.alpha = -1; +} + +void Vore_DeadPrey_Detach(entity e) +{ + // ran when dead prey must be detached from the stomach (eg: they are respawning) + // should only execute after Vore_DeadPrey_Configure has ran first + + if not(cvar("g_vore_keepdeadprey")) + return; + + e.fakepredator = world; + e.aiment = world; + + if(!e.deadflag) + e.fakeprey = FALSE; +} + +void Vore_PreyRelease(entity e) +{ + // if the keepdeadprey feature is on, don't spit a dead prey's carcass out + if(e.health <= 0 && cvar("g_vore_keepdeadprey")) + { + Vore_DeadPrey_Configure(e); + + // if keepdeadprey is enabled and the predator disconnected, detach the dead prey + if(e.fakepredator.classname != "player") + Vore_DeadPrey_Detach(e); + } + else + Vore_Regurgitate(e); +} + void Vore_Disconnect() { // frees prey from their predators when someone disconnects or goes spectating, or in other circumstances // prey disconnects or goes spectating while inside someone's belly if(self.predator.classname == "player") - Vore_Regurgitate(self); + Vore_PreyRelease(self); // pred disconnects or goes spectating with players in their belly else if(self.stomach_load > 0) @@ -242,9 +325,9 @@ void Vore_Disconnect() FOR_EACH_PLAYER(head) { if(head.predator == self) - Vore_Regurgitate(head); + Vore_PreyRelease(head); } - Vore_Gurglesound(); // stop the gurgling sound + Vore_GurgleSound(); // stop the gurgling sound } self.stomach_load = self.gravity = 0; // prevents a bug @@ -330,6 +413,23 @@ void Vore() return; } + // wash the goo away from players once they leave the stomach + if(self.predator.classname != "player") + if(stov(cvar_string("g_vore_regurgitatecolor_release"))) + if(self.colormod) + if(cvar("g_vore_regurgitatecolor_release_fade")) + { + self.colormod_x += cvar("g_vore_regurgitatecolor_release_fade") * frametime; + if(self.colormod_x > 1) + self.colormod_x = 1; + self.colormod_y += cvar("g_vore_regurgitatecolor_release_fade") * frametime; + if(self.colormod_y > 1) + self.colormod_y = 1; + self.colormod_z += cvar("g_vore_regurgitatecolor_release_fade") * frametime; + if(self.colormod_z > 1) + self.colormod_z = 1; + } + // set all vore related stats if(self.predator.classname == "player") { @@ -434,16 +534,27 @@ void Vore() } if(cvar("g_vore_gurglesound")) - Vore_Gurglesound(); + Vore_GurgleSound(); // -------------------------------- // Code that addresses the prey: // -------------------------------- + // keepdeadprey - detach dead prey if their predator died or got swallowed + if(self.fakepredator.classname == "player") + if(self.fakepredator.deadflag != DEAD_NO || self.fakepredator.predator.classname == "player") + Vore_DeadPrey_Detach(self); + if(self.predator.classname != "player") return; - if(self.deadflag || self.predator.deadflag) + if(self.deadflag) + { + Vore_PreyRelease(self); + return; + } + + if(self.predator.deadflag) Vore_Regurgitate(self); else if(vlen(self.predator.velocity) > cvar("g_balance_vore_regurgitate_speedcap")) Vore_Regurgitate(self);