X-Git-Url: http://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=0c45de6a96991c8dca127a3e9dc117b45aa10ed0;hp=bb35b189cef495b052952417ac3ffc6ce76d2012;hb=8e9068cc5e283363d6221618cad92b1eaff9bce3;hpb=829dd8207468230c9ce035a8c5622af026e932bb diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index bb35b189..0c45de6a 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -6,7 +6,7 @@ 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() { @@ -26,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")) { @@ -56,6 +56,36 @@ float Swallow_condition_check(entity prey) 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 @@ -67,34 +97,45 @@ 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 // 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.eater.team == e.team && teamplay) + centerprint(e.eater, "^4You 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; } @@ -104,8 +145,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.view_ofs_z = e.vore_oldview_ofs_z; e.alpha = default_player_alpha; // best way of hiding / showing the eaten player - e.view_ofs_z *= 2; // best positioning for the stomach model // velocities local vector oldforward, oldright, oldup; @@ -119,8 +160,11 @@ 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; @@ -131,6 +175,7 @@ void Vore_Regurgitate(entity e) e.eater = world; } +void Vore_Gurglesound(); void Vore_Disconnect() { // frees prey from their predators when someone disconnects or goes spectating @@ -138,7 +183,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.view_ofs_z = self.vore_oldview_ofs_z; self.eater.stomach_load -= 1; Vore_Weight_apply(self.eater); self.eater = world; @@ -153,6 +198,7 @@ void Vore_Disconnect() if(head.eater == self) Vore_Regurgitate(head); } + Vore_Gurglesound(); // stop the gurgling sound } } @@ -193,12 +239,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; @@ -211,13 +255,6 @@ void Vore_StomachKick() self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay"); } - - // start the predator's digestion - if(self.BUTTON_ATCK2) - { - centerprint(self.eater, strcat(self.netname, " has triggered your digestion")); - self.eater.digesting = TRUE; - } } .float gurglesound_finished, gurglesound_oldstomachload; @@ -235,14 +272,16 @@ void Vore_Gurglesound() void Vore() { // if we are free, show our stomach load on the HUD. Otherwise, show the predator's - if(self.eater != self && self.eater.classname == "player") + 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; } @@ -267,17 +306,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) @@ -308,7 +337,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; } } @@ -333,7 +362,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); @@ -350,5 +392,8 @@ void Vore() if(teams_matter && self.team == self.eater.team) Vore_Teamheal(); - Vore_StomachKick(); + if(self.BUTTON_ATCK) + Vore_StomachKick(); + + Vore_CameraEffect_Apply(); } \ No newline at end of file