X-Git-Url: https://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=blobdiff_plain;f=data%2Fqcsrc%2Fserver%2Fvore.qc;h=1296b01595e5af5ed57d0f3194cf31a59f37af32;hp=5c81ee2a6aa8053ff748f78d11e3b4c43176bf3d;hb=cc23a7f7de9e6e058039ed39b4bffd44fffa3238;hpb=cc148bf19700d380a18d7f51a706f9bbe959811b diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index 5c81ee2a..1296b015 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -1,10 +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() { @@ -24,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")) { @@ -54,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 @@ -70,15 +102,17 @@ 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; + + Vore_CameraEffect_Set(e); // drop keys (KH) and flags (CTF) when we get swallowed kh_Key_DropAll(e, FALSE); @@ -88,11 +122,19 @@ void Vore_Swallow(entity 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) @@ -101,19 +143,34 @@ 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; + oldforward = v_forward; + oldright = v_right; + oldup = v_up; + makevectors(e.eater.v_angle); + e.velocity = v_forward * cvar("g_balance_vore_regurgitate_force"); + e.eater.velocity += -v_forward * cvar("g_balance_vore_regurgitate_eaterforce"); + v_forward = oldforward; + v_right = oldright; + v_up = oldup; 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 @@ -121,8 +178,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; @@ -137,6 +193,7 @@ void Vore_Disconnect() if(head.eater == self) Vore_Regurgitate(head); } + Vore_Gurglesound(); // stop the gurgling sound } } @@ -144,7 +201,7 @@ void Vore_Disconnect() void Vore_Digest() { // apply digestion to prey - if(time > self.eater.digestion_step + 0.1) + if(time > self.eater.digestion_step + steptime) { Damage(self, self.eater, self.eater, cvar("g_balance_vore_digestion_damage"), DEATH_DIGESTION, self.origin, '0 0 0'); if(cvar("g_balance_vore_digestion_vampire") && self.eater.health < cvar("g_balance_vore_digestion_vampire_stable")) @@ -153,7 +210,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; } @@ -163,35 +220,66 @@ void Vore_Digest() self.colormod = stov(cvar_string("g_vore_regurgitatecolor_digested")); } +.float teamheal_step; +void Vore_Teamheal() +{ + if(cvar("g_balance_vore_teamheal") && self.health < cvar("g_balance_vore_teamheal_stable")) + if(time > self.teamheal_step + steptime) + { + self.health += cvar("g_balance_vore_teamheal"); + self.teamheal_step = time; + } +} + .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) { @@ -200,6 +288,8 @@ void Vore() } if(self.spectatee_status) return; + if(time < self.system_delay) + return; // -------------------------------- // Code that addresses predators: @@ -211,17 +301,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) @@ -264,6 +344,9 @@ void Vore() } } + if(cvar("g_vore_gurglesound")) + Vore_Gurglesound(); + // -------------------------------- // Code that addresses the prey: // -------------------------------- @@ -274,7 +357,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); @@ -288,6 +384,11 @@ void Vore() if(self.eater.digesting == TRUE) Vore_Digest(); + if(teams_matter && self.team == self.eater.team) + Vore_Teamheal(); + + if(self.BUTTON_ATCK) + Vore_StomachKick(); - Vore_StomachKick(); + Vore_CameraEffect_Apply(); } \ No newline at end of file