X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=4adbd900e443396e1710e16780f118823e24f78d;hb=65d6ed8678d022983d75f31db0d957e521425c05;hp=8566f1508c0b7934a5925cb5471052753a10345c;hpb=b7712e8491994a0663833345fa4a5c46ef6a0ecc;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 8566f150..4adbd900 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -12,11 +12,16 @@ entity Swallow_player_check() { // check if we can swallow a player instead of firing our weapon + float swallow_range; vector vore_w_shotorg, vore_w_shotdir; - vore_w_shotorg = self.origin + self.view_ofs; + + swallow_range = cvar("g_balance_vore_swallow_range"); + if(self.scale) // we can swallow from further or closer based on our size + swallow_range *= self.scale; + vore_w_shotorg = self.origin; vore_w_shotdir = v_forward; - WarpZone_traceline_antilag(self, vore_w_shotorg, vore_w_shotorg + vore_w_shotdir * cvar("g_balance_vore_swallow_range"), FALSE, self, ANTILAG_LATENCY(self)); + WarpZone_traceline_antilag(self, vore_w_shotorg, vore_w_shotorg + vore_w_shotdir * swallow_range, FALSE, self, ANTILAG_LATENCY(self)); if(trace_fraction < 1) if(trace_ent.classname == "player") return trace_ent; @@ -33,52 +38,28 @@ float Swallow_condition_check(entity prey) if(!self.BUTTON_REGURGITATE && self.swallow_delay < time) if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_speedcap")) { + string swallow_complain; if(teams_matter && prey.team == self.team && !cvar("g_vore_teamvore")) + swallow_complain = "You cannot swallow your team mates\n"; + else if(!cvar("g_vore_spawnshield") && prey.spawnshieldtime > time) + swallow_complain = "You cannot swallow someone protected by the spawn shield\n"; + else if(self.stomach_load >= cvar("g_balance_vore_swallow_limit")) + swallow_complain = strcat("You cannot swallow more than ^2", cvar_string("g_balance_vore_swallow_limit"), "^7 players at a time\n"); + else if(cvar("g_vore_biggergut") && prey.stomach_load > self.stomach_load) + swallow_complain = "You cannot swallow someone with a bigger stomach than yours\n"; + else if(cvar("g_vore_biggersize") && prey.scale > self.scale) + swallow_complain = "You cannot swallow someone larger than you\n"; + + if(swallow_complain != "") { if(time > self.complain_vore && self.BUTTON_ATCK) { play2(self, "misc/forbidden.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 && self.BUTTON_ATCK) - { - play2(self, "misc/forbidden.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; - } - return FALSE; - } - - if(cvar("g_vore_biggergut")) - if(prey.stomach_load > self.stomach_load) - { - if(time > self.complain_vore && self.BUTTON_ATCK) - { - play2(self, "misc/forbidden.wav"); - sprint(self, "You cannot swallow someone with a bigger stomach than yours\n"); - self.complain_vore = time + complain_delay_time; - } - return FALSE; - } - - if(!cvar("g_vore_spawnshield")) - if(prey.spawnshieldtime > time) - { - if(time > self.complain_vore && self.BUTTON_ATCK) - { - play2(self, "misc/forbidden.wav"); - sprint(self, "You cannot swallow someone protected by the spawn shield\n"); + sprint(self, swallow_complain); self.complain_vore = time + complain_delay_time; } return FALSE; } - return TRUE; } return FALSE; @@ -114,34 +95,20 @@ float Vore_CanLeave() return FALSE; } -// make the camera smoothly lower itself when we get swallowed -// our aim is going from the normal view offset to half of the view offset (because half is the best positioning for the stomach model) -.float cameraeffect_current, cameraeffect_target; -void Vore_CameraEffect_Set(entity e) -{ - e.cameraeffect_current = 1; - e.cameraeffect_target = 2; -} -void Vore_CameraEffect_Apply() +// position the camera properly for prey +void Vore_SetCamera() { - if(self.predator.classname != "player") + if not(self.predator.classname == "player" || self.fakeprey > 1) return; - if(self.cvar_cl_vore_cameraspeed) - { - local float step; - step = self.cvar_cl_vore_cameraspeed * frametime; - - // not sure if these maths are good, as the effect should be smoother - if(self.cameraeffect_current >= self.cameraeffect_target + step) - self.cameraeffect_current -= step; - else if(self.cameraeffect_current <= self.cameraeffect_target - step) - self.cameraeffect_current += step; - } - else - self.cameraeffect_current = self.cameraeffect_target; + self.view_ofs = PL_PREY_VIEW_OFS; - self.view_ofs_z = PL_VIEW_OFS_z / self.cameraeffect_current; + float prey_height; + if(self.fakeprey > 1) + prey_height = (self.scale - self.fakepredator.scale) * cvar("g_healthsize_vore_pos"); + else + prey_height = (self.scale - self.predator.scale) * cvar("g_healthsize_vore_pos"); + self.view_ofs_z += prey_height; } .float gurgle_oldstomachload; @@ -198,7 +165,6 @@ void Vore_Swallow(entity e) e.velocity = '0 0 0'; e.movetype = MOVETYPE_FOLLOW; e.solid = SOLID_NOT; - e.alpha = -1; // best way of hiding the eaten player e.aiment = e.predator; // follow the predator, automatically unset when regurgitated // drop keys (KH) and flags (CTF) when we get swallowed @@ -206,8 +172,6 @@ void Vore_Swallow(entity e) if(e.flagcarried) DropFlag(e.flagcarried, world, e.predator); - Vore_CameraEffect_Set(e); - if(stov(cvar_string("g_vore_regurgitatecolor_release"))) e.colormod = stov(cvar_string("g_vore_regurgitatecolor_release")); @@ -242,7 +206,6 @@ void Vore_Regurgitate(entity e) if(e.health > 0) // leave SOLID_NOT for dead bodies e.solid = e.vore_oldsolid; e.view_ofs_z = PL_VIEW_OFS_z; - e.alpha = default_player_alpha; // apply velocities local vector oldforward, oldright, oldup; @@ -283,7 +246,7 @@ void Vore_DeadPrey_Configure(entity e) // this entity is like e.predator but for dead prey, to avoid conflicts e.fakepredator = e.predator; - e.fakeprey = TRUE; + e.fakeprey = 2; // is fakeprey in a stomach // 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 @@ -296,9 +259,6 @@ void Vore_DeadPrey_Configure(entity e) e.takedamage = DAMAGE_NO; e.solid = SOLID_NOT; e.aiment = e.fakepredator; - - // completely remove the dead body - e.modelindex = 0; } void Vore_DeadPrey_Detach(entity e) @@ -310,27 +270,28 @@ void Vore_DeadPrey_Detach(entity e) return; e.fakepredator = world; - e.fakeprey = FALSE; + e.fakeprey = 1; // was fakeprey but is now detached e.aiment = world; e.movetype = MOVETYPE_TOSS; } void Vore_PreyRelease(entity e, float pred_disconnect) { - // if the keepdeadprey feature is on, don't spit a dead prey's carcass out - if(e.deadflag != DEAD_NO && random() < cvar("g_vore_keepdeadprey")) + if(pred_disconnect) { - // if keepdeadprey is enabled and the predator disconnected, detach the dead prey - if(pred_disconnect) - { - if(e.fakeprey) - Vore_DeadPrey_Detach(e); - } + if(e.fakeprey > 1) + Vore_DeadPrey_Detach(e); else - Vore_DeadPrey_Configure(e); + Vore_Regurgitate(e); } else - Vore_Regurgitate(e); + { + // if the keepdeadprey feature is on, don't spit a dead prey's carcass out + if(e.deadflag != DEAD_NO && random() < cvar("g_vore_keepdeadprey")) + Vore_DeadPrey_Configure(e); + else + Vore_Regurgitate(e); + } } void Vore_Disconnect() @@ -499,8 +460,10 @@ void Vore() self.colormod_z = 1; } - // set all vore related stats - if(self.predator.classname == "player") + // set all vore stats + if(self.fakeprey > 1) + self.stat_eaten = num_for_edict(self.fakepredator); + else if(self.predator.classname == "player") { self.stat_stomachload = self.predator.stomach_load; // necessary for the stomach board self.stat_digesting = self.predator.digesting; // necessary for the stomach board @@ -620,6 +583,8 @@ void Vore() // Code that addresses the prey: // -------------------------------- + Vore_SetCamera(); + // 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") @@ -660,8 +625,6 @@ void Vore() if(self.BUTTON_JUMP) Vore_StomachLeave(); - Vore_CameraEffect_Apply(); - // Ugly workaround for a Keyhunt issue. Your team's key can still be given to you while in the stomach // (at round start), which is pretty ugly and wrong. So attempt to drop keys each frame for prey kh_Key_DropAll(self, FALSE);