X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=0c45de6a96991c8dca127a3e9dc117b45aa10ed0;hb=8e9068cc5e283363d6221618cad92b1eaff9bce3;hp=037aca006a15102948c5f1d1500f5bdf81403c87;hpb=e9fe6e60fe3f74c6a8fe359510e6c19fc5d09027;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 037aca00..0c45de6a 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,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 @@ -66,34 +97,46 @@ 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.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; } void Vore_Regurgitate(entity e) @@ -102,9 +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.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,15 +160,22 @@ 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); + + 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 @@ -134,8 +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.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; @@ -150,6 +198,7 @@ void Vore_Disconnect() if(head.eater == self) Vore_Regurgitate(head); } + Vore_Gurglesound(); // stop the gurgling sound } } @@ -166,7 +215,7 @@ void Vore_Digest() if (self.eater.digestsound_finished < time) { self.eater.digestsound_finished = time + 0.5; - sound (self.eater, CHAN_PLAYER, "player/digest.wav", VOL_BASE, ATTN_NORM); + PlayerSound (self.eater, playersound_digest, CHAN_PLAYER, VOICETYPE_PLAYERSOUND); } self.eater.digestion_step = time; } @@ -190,32 +239,52 @@ void Vore_Teamheal() .float stomachkick_delay; void Vore_StomachKick() { - // allows prey to kick the predator's stomach and do some damage, 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 - if(self.BUTTON_ATCK) if(time > self.stomachkick_delay) { 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.eater, self, self, damage, DEATH_STOMACHKICK, self.eater.origin, '0 0 0'); sound(self.eater, CHAN_PROJECTILE, "weapons/stomachkick.ogg", VOL_BASE, ATTN_NORM); + + if(cvar("g_balance_vore_kick_escapeprobability") >= random()) + Vore_Regurgitate(self); + self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay"); } +} - // start the predator's digestion - if(self.BUTTON_ATCK2) +.float gurglesound_finished, gurglesound_oldstomachload; +void Vore_Gurglesound() +{ + if(time > self.gurglesound_finished || self.gurglesound_oldstomachload != self.stomach_load) { - centerprint(self.eater, strcat(self.netname, " triggered your digestion")); - self.eater.digesting = TRUE; + GlobalSound(self.playersound_gurgle, CHAN_TRIGGER, VOICETYPE_GURGLE); + + self.gurglesound_finished = time + 11; // yes, hard coded sound length. I know it's bad but what can I do? + self.gurglesound_oldstomachload = self.stomach_load; } } 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) { @@ -224,6 +293,8 @@ void Vore() } if(self.spectatee_status) return; + if(time < self.system_delay) + return; // -------------------------------- // Code that addresses predators: @@ -235,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) @@ -276,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; } } @@ -288,6 +349,9 @@ void Vore() } } + if(cvar("g_vore_gurglesound")) + Vore_Gurglesound(); + // -------------------------------- // Code that addresses the prey: // -------------------------------- @@ -298,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); @@ -315,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