X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=102ce98b43a16b77a921b44533804d5c8b1f8ad8;hb=14364ac9058be0fc1520288c1660e099c775b7f9;hp=4c81370489bba58f0f6c793953912a0ae73606fd;hpb=8e12f789d44c8d6bcb6a15c755a4be62e7ed11ce;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 4c813704..102ce98b 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -1,11 +1,12 @@ .float regurgitate_prepare; -.float swallow_delay, digest_button_delay, regurgitate_button_delay; +.float system_delay, swallow_delay, digest_button_delay, regurgitate_button_delay; .float complain_swallow; const float complain_delay = 1; const float button_delay = 0.5; const float steptime = 0.1; +const float system_delay_time = 0.1; -.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload; +.float vore_oldmovetype, vore_oldsolid, vore_oldstomachload, vore_oldview_ofs_z; entity Swallow_distance_check() { @@ -25,8 +26,8 @@ float Swallow_condition_check(entity prey) { // checks the necessary conditions for swallowing another player if(prey.classname == "player" && prey.eater.classname != "player" && prey.deadflag == DEAD_NO) // we can't swallow someone who's already in someone else's stomach + if(self.classname == "player" && self.eater.classname != "player" && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_velocitylimit")) - if(self.eater.classname != "player") // we can't swallow players while inside someone's stomach ourselves { if(self.stomach_load >= cvar("g_balance_vore_swallow_limit")) { @@ -55,6 +56,43 @@ float Swallow_condition_check(entity prey) return FALSE; } +float Vore_PreyCanLeave() +{ + if(teams_matter && self.team == self.eater.team) + return TRUE; + return FALSE; +} + +// make the camera smoothly lower itself when we get swallowed +// the target we are going for is from normal view offset to half of the view offset (because half is the best positioning of the view 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() +{ + if(self.eater.classname != "player") + 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_z = self.vore_oldview_ofs_z / self.cameraeffect_current; +} + void Vore_Weight_apply(entity e) { // apply stomach weight that makes you heavier the more you eat @@ -66,34 +104,49 @@ void Vore_Weight_apply(entity e) e.vore_oldstomachload = e.stomach_load; } +.entity pusher; +.float pushltime; void Vore_Swallow(entity e) { // this player is beening swallowed by another player, apply the proper changes e.vore_oldmovetype = e.movetype; e.vore_oldsolid = e.solid; + e.vore_oldview_ofs_z = e.view_ofs_z; + e.eater = self; setorigin(e, e.eater.origin); e.velocity = '0 0 0'; e.movetype = MOVETYPE_FOLLOW; e.solid = SOLID_NOT; e.alpha = -1; // best way of hiding / showing the eaten player e.aiment = e.eater; // follow the predator. Is automatically unset - e.view_ofs_z /= 2; // best positioning for the stomach model - e.stat_eaten = TRUE; // drop keys (KH) and flags (CTF) when we get swallowed kh_Key_DropAll(e, FALSE); if(e.flagcarried) DropFlag(e.flagcarried, world, e.eater); + Vore_CameraEffect_Set(e); + if(stov(cvar_string("g_vore_regurgitatecolor_released"))) e.colormod = stov(cvar_string("g_vore_regurgitatecolor_released")); + if(e.team == e.eater.team && teamplay) + { + centerprint(e, "^3You have been swallowed by a team mate, don't kick!"); + centerprint(e.eater, "^3You have swallowed a team mate, use caution!"); + } + PlayerSound(e.eater, playersound_swallow, CHAN_PAIN, VOICETYPE_PLAYERSOUND); - setanim(e.eater, e.eater.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing \ regurgitating + setanim(e.eater, e.eater.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating e.eater.stomach_load += 1; e.eater.regurgitate_prepare = 0; Vore_Weight_apply(e.eater); + + // block firing for a small amount of time when voring, or we'll be firing the next frame after we swallow + e.eater.weapon_delay = time + button_delay; + e.eater.swallow_delay = time + cvar("g_balance_vore_swallow_delay"); + e.system_delay = e.eater.system_delay = time + system_delay_time; } void Vore_Regurgitate(entity e) @@ -102,9 +155,8 @@ 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.alpha = 0; // best way of hiding / showing the eaten player - e.view_ofs_z *= 2; // best positioning for the stomach model - e.stat_eaten = FALSE; + e.view_ofs_z = e.vore_oldview_ofs_z; + e.alpha = default_player_alpha; // best way of hiding / showing the eaten player // velocities local vector oldforward, oldright, oldup; @@ -118,16 +170,24 @@ void Vore_Regurgitate(entity e) v_right = oldright; v_up = oldup; + e.pusher = e.eater; // so we can frag players by regurgitating them in deadly pits + e.pushltime = time + cvar("g_maxpushtime"); + PlayerSound(e.eater, playersound_regurgitate, CHAN_PAIN, VOICETYPE_PLAYERSOUND); - setanim(e.eater, e.eater.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing \ regurgitating + setanim(e.eater, e.eater.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating pointparticles(particleeffectnum("regurgitate"), e.eater.origin, '0 0 0', 1); e.eater.stomach_load -= 1; e.eater.regurgitate_prepare = 0; e.eater.swallow_delay = time + cvar("g_balance_vore_swallow_delay"); Vore_Weight_apply(e.eater); + + // block firing for a small amount of time when getting regurgitated, or we'll be firing the next frame + e.weapon_delay = time + button_delay; + e.system_delay = e.eater.system_delay = time + system_delay_time; e.eater = world; } +void Vore_Gurglesound(); void Vore_Disconnect() { // frees prey from their predators when someone disconnects or goes spectating @@ -135,8 +195,7 @@ void Vore_Disconnect() // prey disconnects or goes spectating while inside someone's belly: if(self.eater.classname == "player") { - self.view_ofs_z += 25; - self.stat_eaten = FALSE; + self.view_ofs_z = self.vore_oldview_ofs_z; self.eater.stomach_load -= 1; Vore_Weight_apply(self.eater); self.eater = world; @@ -151,6 +210,7 @@ void Vore_Disconnect() if(head.eater == self) Vore_Regurgitate(head); } + Vore_Gurglesound(); // stop the gurgling sound } } @@ -191,12 +251,10 @@ void Vore_Teamheal() .float stomachkick_delay; void Vore_StomachKick() { - // allows prey to kick the predator's stomach and do some damage / attempt to escape, or bring the predator's digestion upon their self when there's no other option + // allows prey to kick the predator's stomach and do some damage or attempt to escape if(self.eater.classname != "player") return; - // kick the predator's stomach and do damage, or escape if we are lucky - if(self.BUTTON_ATCK) if(time > self.stomachkick_delay) { float damage; @@ -209,12 +267,19 @@ void Vore_StomachKick() self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay"); } +} + +void Vore_StomachLeave() +{ + // allows players to get out of their predator at will in some circumstances, such as team mates - // start the predator's digestion - if(self.BUTTON_ATCK2) + if(Vore_PreyCanLeave()) + Vore_Regurgitate(self); + else if(time > self.complain_swallow) { - centerprint(self.eater, strcat(self.netname, " has triggered your digestion")); - self.eater.digesting = TRUE; + play2(self, "weapons/unavailable.wav"); + sprint(self, strcat("You can't willingly get out of ", self.eater.netname, "\n")); + self.complain_swallow = time + complain_delay; } } @@ -232,6 +297,20 @@ void Vore_Gurglesound() void Vore() { + // if we are free, show our stomach load on the HUD. Otherwise, show the predator's + if(self.eater.classname == "player") + { + self.stat_stomachload = self.eater.stomach_load; + self.stat_digesting = self.eater.digesting; + self.stat_eaten = num_for_edict(self.eater); + } + else + { + self.stat_stomachload = self.stomach_load; + self.stat_digesting = self.digesting; + self.stat_eaten = 0; + } + // skip the vore system under some circumstances if(time < game_starttime) { @@ -240,6 +319,8 @@ void Vore() } if(self.spectatee_status) return; + if(time < self.system_delay) + return; // -------------------------------- // Code that addresses predators: @@ -251,17 +332,7 @@ void Vore() // attempt to swallow our new prey if there's any in range if(self.BUTTON_ATCK && !self.BUTTON_REGURGITATE && self.swallow_delay < time) if(Swallow_condition_check(prey)) - { - prey.eater = self; Vore_Swallow(prey); - self.swallow_delay = time + cvar("g_balance_vore_swallow_delay"); - - if(self.team == prey.team && teamplay) - centerprint(self, "You have swallowed a team mate, use caution!"); - - // block firing for a small amount of time when voring, or we'll be firing the next frame after we swallow - self.weapon_delay = time + 0.25; - } // start / stop digestion on command, if the player has someone in their stomach if(self.BUTTON_DIGEST) @@ -292,7 +363,7 @@ void Vore() if(time > self.regurgitate_button_delay) { self.regurgitate_prepare = time + cvar("g_balance_vore_regurgitate_delay"); - PlayerSound(self, playersound_regurgitate_prepare, CHAN_PAIN, VOICETYPE_PLAYERSOUND); + PlayerSound(self, playersound_regurgitate_prepare, CHAN_VOICE, VOICETYPE_PLAYERSOUND); self.regurgitate_button_delay = time + button_delay; } } @@ -317,7 +388,20 @@ void Vore() if(self.eater.deadflag || self.deadflag) Vore_Regurgitate(self); else if(self.eater.eater.classname == "player") // don't allow a player inside a player inside another player :) + { + entity targeteater, oldself; + targeteater = self.eater.eater; + Vore_Regurgitate(self); + if(random() < cvar("g_vore_stealprey")) + if(Swallow_condition_check(self)) + { + oldself = self; + self = targeteater; + Vore_Swallow(oldself); + self = oldself; + } + } else if(vlen(self.eater.velocity) > cvar("g_balance_vore_regurgitate_velocitylimit")) Vore_Regurgitate(self); @@ -334,5 +418,12 @@ void Vore() if(teams_matter && self.team == self.eater.team) Vore_Teamheal(); - Vore_StomachKick(); + if(self.BUTTON_ATCK) + Vore_StomachKick(); + else if(self.BUTTON_JUMP) + Vore_StomachLeave(); + + self.stat_canleave = Vore_PreyCanLeave(); + + Vore_CameraEffect_Apply(); } \ No newline at end of file