X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=b4a2126eb58548a3760ffc540183119f98da9266;hb=35f5024ed5e377f89840ed171708338efb866f86;hp=4de538145f961220512e8da9be8a173e6c1c8380;hpb=a9f13bd520968a9495b22baa78d0b883092d88c7;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 4de53814..b4a2126e 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -1,7 +1,7 @@ .float regurgitate_prepare; .float system_delay, swallow_delay, digest_button_delay_time, regurgitate_button_delay_time; .float complain_vore; -.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload, vore_oldview_ofs_z; +.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload; const float system_delay_time = 0.1; const float complain_delay_time = 1; @@ -25,18 +25,30 @@ entity Swallow_player_check() float Swallow_condition_check(entity prey) { - // checks the necessary conditions for swallowing another player + // checks the necessary conditions for swallowing a player if(prey != self) if(prey.classname == "player" && prey.predator.classname != "player" && prey.deadflag == DEAD_NO) // we can't swallow someone who's already in someone else's stomach if(self.classname == "player" && self.predator.classname != "player" && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves + if(!self.BUTTON_REGURGITATE && self.swallow_delay < time) if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_speedcap")) { + if(teams_matter && prey.team == self.team && !cvar("g_vore_teamvore")) + { + if(time > self.complain_vore) + { + play2(self, "misc/unavailable.wav"); + sprint(self, "You cannot swallow your team mates\n"); + self.complain_vore = time + complain_delay_time; + } + return FALSE; + } + if(self.stomach_load >= cvar("g_balance_vore_swallow_limit")) { if(time > self.complain_vore) { - play2(self, "weapons/unavailable.wav"); + play2(self, "misc/unavailable.wav"); sprint(self, strcat("You cannot swallow more than ^2", cvar_string("g_balance_vore_swallow_limit"), "^7 players at a time\n")); self.complain_vore = time + complain_delay_time; } @@ -48,7 +60,7 @@ float Swallow_condition_check(entity prey) { if(time > self.complain_vore) { - play2(self, "weapons/unavailable.wav"); + play2(self, "misc/unavailable.wav"); sprint(self, "You cannot swallow someone with a bigger stomach than yours\n"); self.complain_vore = time + complain_delay_time; } @@ -62,8 +74,15 @@ float Swallow_condition_check(entity prey) float Vore_CanLeave() { - if(teams_matter && self.team == self.predator.team) - return TRUE; + if(self.predator.classname == "player") + { + if(!cvar("g_vore_kick")) // you are defenseless in the stomach if you can't kick, so allow leaving + return TRUE; + if(teams_matter && self.team == self.predator.team) + return TRUE; + if(g_rpg && cvar("g_rpg_canleave")) + return TRUE; + } return FALSE; } @@ -94,11 +113,11 @@ void Vore_CameraEffect_Apply() else self.cameraeffect_current = self.cameraeffect_target; - self.view_ofs_z = self.vore_oldview_ofs_z / self.cameraeffect_current; + self.view_ofs_z = PL_VIEW_OFS_z / self.cameraeffect_current; } .float gurgle_oldstomachload; -void Vore_Gurglesound() +void Vore_GurgleSound() { if(time > self.gurglesound_finished || self.gurgle_oldstomachload != self.stomach_load) { @@ -109,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 @@ -121,6 +140,29 @@ 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 not(e.cvar_cl_vore_autodigest) + return; + if not(cvar("g_vore_digestion")) + return; + + entity head; + if(teams_matter) + { + FOR_EACH_PLAYER(head) + { + // never begin automatic digestion if we've swallowed a team mate + if(head.team == e.team) + return; + } + } + + e.digesting = TRUE; +} + .entity pusher; .float pushltime; void Vore_Swallow(entity e) @@ -129,7 +171,6 @@ void Vore_Swallow(entity e) e.vore_oldmovetype = e.movetype; e.vore_oldsolid = e.solid; - e.vore_oldview_ofs_z = e.view_ofs_z; e.predator = self; setorigin(e, e.predator.origin); @@ -157,9 +198,12 @@ void Vore_Swallow(entity e) PlayerSound(e.predator, playersound_swallow, CHAN_PAIN, VOICETYPE_PLAYERSOUND); setanim(e.predator, e.predator.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating + e.predator.punchangle_x -= e.predator.cvar_cl_vore_punchangle; e.predator.stomach_load += 1; e.predator.regurgitate_prepare = 0; - Vore_Weight_apply(e.predator); + e.predator.spawnshieldtime = 0; // lose spawn shield when we vore + 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; @@ -174,7 +218,7 @@ void Vore_Regurgitate(entity e) e.movetype = e.vore_oldmovetype; if(e.health > 0) // leave SOLID_NOT for dead bodies e.solid = e.vore_oldsolid; - e.view_ofs_z = e.vore_oldview_ofs_z; + e.view_ofs_z = PL_VIEW_OFS_z; e.alpha = default_player_alpha; // apply velocities @@ -195,10 +239,11 @@ void Vore_Regurgitate(entity e) PlayerSound(e.predator, playersound_regurgitate, CHAN_PAIN, VOICETYPE_PLAYERSOUND); setanim(e.predator, e.predator.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating pointparticles(particleeffectnum("regurgitate"), e.predator.origin, '0 0 0', 1); + e.predator.punchangle_x += e.predator.cvar_cl_vore_punchangle; 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; @@ -206,13 +251,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) @@ -221,10 +323,12 @@ 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 } .float digestion_step; @@ -273,7 +377,7 @@ void Vore_StomachKick() { float damage; damage = ceil(random() * (cvar("g_balance_vore_kick_damage_max") - cvar("g_balance_vore_kick_damage_min")) + cvar("g_balance_vore_kick_damage_min")); - Damage(self.predator, self, self, damage, DEATH_STOMACHKICK, self.predator.origin, '0 0 0'); + Damage(self.predator, self, self, damage, DEATH_STOMACHKICK, self.predator.origin, v_forward * cvar("g_balance_vore_kick_force")); sound(self.predator, CHAN_PROJECTILE, "weapons/stomachkick.ogg", VOL_BASE, ATTN_NORM); if(random() < cvar("g_balance_vore_kick_escapeprobability")) @@ -291,7 +395,7 @@ void Vore_StomachLeave() Vore_Regurgitate(self); else if(time > self.complain_vore) { - play2(self, "weapons/unavailable.wav"); + play2(self, "misc/unavailable.wav"); sprint(self, strcat("You cannot get out of ", self.predator.netname, "\n")); self.complain_vore = time + complain_delay_time; } @@ -301,6 +405,29 @@ void Vore() { // main vore code, this is where it all happens + if(!cvar("g_vore")) // the vore system is disabled + { + Vore_Disconnect(); + 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") { @@ -316,7 +443,31 @@ void Vore() } self.stat_canleave = Vore_CanLeave(); - // skip the vore system under some circumstances + // don't allow a player inside a player inside another player :) + // prevent this by checking if such has happened, and taking the proper measures + // this code has a high priority and must not be stopped by any delay, so run it here + if(self.predator.predator.classname == "player") + { + entity target_predator, target_predator_predator, oldself; + target_predator = self.predator; + target_predator_predator = self.predator.predator; + + Vore_Regurgitate(self); + + // now steal our prey's prey if this probability applies + if(random() < cvar("g_balance_vore_swallow_stealprey")) + { + oldself = self; + self = target_predator_predator; + if(Swallow_condition_check(oldself)) + if not(teams_matter && self.team == target_predator.team) // don't steal a team mate's prey + if not(teams_matter && self.team == oldself.team) // if the prey we would be stealing is a team mate, don't do it + Vore_Swallow(oldself); + self = oldself; + } + } + + // apply delays and skip the vore system under some circumstances if(time < game_starttime || (time < warmup && !inWarmupStage)) // don't allow vore before a round begins { Vore_Disconnect(); @@ -335,12 +486,12 @@ void Vore() prey = Swallow_player_check(); // attempt to swallow our new prey if we pressed the attack button, and there's any in range - if(self.BUTTON_ATCK && !self.BUTTON_REGURGITATE && self.swallow_delay < time) + if(self.BUTTON_ATCK) if(Swallow_condition_check(prey)) Vore_Swallow(prey); // toggle digestion, if the player has someone in their stomach - if(self.BUTTON_DIGEST) + if(self.BUTTON_DIGEST && cvar("g_vore_digestion")) { if(self.stomach_load) { @@ -352,12 +503,12 @@ void Vore() } else if(time > self.complain_vore) { - play2(self, "weapons/unavailable.wav"); + play2(self, "misc/unavailable.wav"); sprint(self, "There is nothing to digest\n"); self.complain_vore = time + complain_delay_time; } } - if(!self.stomach_load) + if(!self.stomach_load || !cvar("g_vore_digestion")) self.digesting = FALSE; // predator wishes to regurgitate his prey @@ -374,40 +525,35 @@ void Vore() } else if(time > self.complain_vore) { - play2(self, "weapons/unavailable.wav"); + play2(self, "misc/unavailable.wav"); sprint(self, "There is nothing to regurgitate\n"); self.complain_vore = time + complain_delay_time; } } 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.predator.deadflag || self.deadflag) - Vore_Regurgitate(self); - else if(self.predator.predator.classname == "player") // don't allow a player inside a player inside another player :) + if(self.deadflag) { - entity target_predator, oldself; - target_predator = self.predator.predator; + Vore_PreyRelease(self); + return; + } + if(self.predator.deadflag) Vore_Regurgitate(self); - if(random() < cvar("g_vore_stealprey")) // steal our prey's prey if this probability returns true - if not(teams_matter && self.predator.team == target_predator.team) // don't steal a team mate's prey - if(Swallow_condition_check(self)) - { - oldself = self; - self = target_predator; - Vore_Swallow(oldself); - self = oldself; - } - } else if(vlen(self.predator.velocity) > cvar("g_balance_vore_regurgitate_speedcap")) Vore_Regurgitate(self); @@ -423,10 +569,11 @@ void Vore() if(self.predator.digesting == TRUE) Vore_Digest(); if(teams_matter && self.team == self.predator.team) + if(cvar("g_balance_vore_teamheal") && cvar("g_vore_teamvore")) Vore_Teamheal(); // execute prey commands - if(self.BUTTON_ATCK) + if(self.BUTTON_ATCK && cvar("g_vore_kick")) Vore_StomachKick(); if(self.BUTTON_JUMP) Vore_StomachLeave();