]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Second part; Show the stomach board of the eater as well
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index b7e3b6ddf1563f5956f04813b4f6dbe6fc4b55dc..268798a0c11fad9af8803a7360e0394876df267f 100644 (file)
@@ -1,8 +1,10 @@
 .float regurgitate_prepare;\r
-.float swallow_delay, digest_button_delay, regurgitate_button_delay;\r
+.float system_delay, swallow_delay, digest_button_delay, regurgitate_button_delay;\r
 .float complain_swallow;\r
 const float complain_delay = 1;\r
 const float button_delay = 0.5;\r
+const float steptime = 0.1;\r
+const float system_delay_time = 0.1;\r
 \r
 .float vore_oldmovetype, vore_oldsolid, vore_oldstomachload;\r
 \r
@@ -78,7 +80,7 @@ void Vore_Swallow(entity e)
        e.alpha = -1; // best way of hiding / showing the eaten player\r
        e.aiment = e.eater; // follow the predator. Is automatically unset\r
        e.view_ofs_z /= 2; // best positioning for the stomach model\r
-       e.stat_eaten = TRUE;\r
+       e.stat_eaten = num_for_edict(e.eater);\r
 \r
        // drop keys (KH) and flags (CTF) when we get swallowed\r
        kh_Key_DropAll(e, FALSE);\r
@@ -93,6 +95,8 @@ void Vore_Swallow(entity e)
        e.eater.stomach_load += 1;\r
        e.eater.regurgitate_prepare = 0;\r
        Vore_Weight_apply(e.eater);\r
+\r
+       e.system_delay = e.eater.system_delay = time + system_delay_time;\r
 }\r
 \r
 void Vore_Regurgitate(entity e)\r
@@ -101,16 +105,31 @@ void Vore_Regurgitate(entity e)
        e.movetype = e.vore_oldmovetype;\r
        if(e.health > 0) // leave SOLID_NOT for dead bodies\r
                e.solid = e.vore_oldsolid;\r
-       e.alpha = 0; // best way of hiding / showing the eaten player\r
+       e.alpha = default_player_alpha; // best way of hiding / showing the eaten player\r
        e.view_ofs_z *= 2; // best positioning for the stomach model\r
-       e.stat_eaten = FALSE;\r
+       e.stat_eaten = 0;\r
+\r
+       // velocities\r
+       local vector oldforward, oldright, oldup;\r
+       oldforward = v_forward;\r
+       oldright = v_right;\r
+       oldup = v_up;\r
+       makevectors(e.eater.v_angle);\r
+       e.velocity = v_forward * cvar("g_balance_vore_regurgitate_force");\r
+       e.eater.velocity += -v_forward * cvar("g_balance_vore_regurgitate_eaterforce");\r
+       v_forward = oldforward;\r
+       v_right = oldright;\r
+       v_up = oldup;\r
 \r
        PlayerSound(e.eater, playersound_regurgitate, CHAN_PAIN, VOICETYPE_PLAYERSOUND);\r
        setanim(e.eater, e.eater.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing \ regurgitating\r
        pointparticles(particleeffectnum("regurgitate"), e.eater.origin, '0 0 0', 1);\r
        e.eater.stomach_load -= 1;\r
        e.eater.regurgitate_prepare = 0;\r
+       e.eater.swallow_delay = time + cvar("g_balance_vore_swallow_delay");\r
        Vore_Weight_apply(e.eater);\r
+\r
+       e.system_delay = e.eater.system_delay = time + system_delay_time;\r
        e.eater = world;\r
 }\r
 \r
@@ -122,7 +141,7 @@ void Vore_Disconnect()
        if(self.eater.classname == "player")\r
        {\r
                self.view_ofs_z += 25;\r
-               self.stat_eaten = FALSE;\r
+               self.stat_eaten = 0;\r
                self.eater.stomach_load -= 1;\r
                Vore_Weight_apply(self.eater);\r
                self.eater = world;\r
@@ -144,7 +163,7 @@ void Vore_Disconnect()
 void Vore_Digest()\r
 {\r
        // apply digestion to prey\r
-       if(time > self.eater.digestion_step + 0.1)\r
+       if(time > self.eater.digestion_step + steptime)\r
        {\r
                Damage(self, self.eater, self.eater, cvar("g_balance_vore_digestion_damage"), DEATH_DIGESTION, self.origin, '0 0 0');\r
                if(cvar("g_balance_vore_digestion_vampire") && self.eater.health < cvar("g_balance_vore_digestion_vampire_stable"))\r
@@ -153,7 +172,7 @@ void Vore_Digest()
                if (self.eater.digestsound_finished < time)\r
                {\r
                        self.eater.digestsound_finished = time + 0.5;\r
-                       sound (self.eater, CHAN_PLAYER, "player/digest.wav", VOL_BASE, ATTN_NORM);\r
+                       PlayerSound (self.eater, playersound_digest, CHAN_PLAYER, VOICETYPE_PLAYERSOUND);\r
                }\r
                self.eater.digestion_step = time;\r
        }\r
@@ -167,7 +186,7 @@ void Vore_Digest()
 void Vore_Teamheal()\r
 {\r
        if(cvar("g_balance_vore_teamheal") && self.health < cvar("g_balance_vore_teamheal_stable"))\r
-       if(time > self.teamheal_step + 0.1)\r
+       if(time > self.teamheal_step + steptime)\r
        {\r
                self.health += cvar("g_balance_vore_teamheal");\r
                self.teamheal_step = time;\r
@@ -177,32 +196,53 @@ void Vore_Teamheal()
 .float stomachkick_delay;\r
 void Vore_StomachKick()\r
 {\r
-       // 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\r
+       // 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\r
        if(self.eater.classname != "player")\r
                return;\r
 \r
-       // kick the predator's stomach and do damage\r
+       // kick the predator's stomach and do damage, or escape if we are lucky\r
        if(self.BUTTON_ATCK)\r
        if(time > self.stomachkick_delay)\r
        {\r
                float damage;\r
                damage = ceil(random() * (cvar("g_balance_vore_kick_damage_max") - cvar("g_balance_vore_kick_damage_min")) + cvar("g_balance_vore_kick_damage_min"));\r
-\r
                Damage(self.eater, self, self, damage, DEATH_STOMACHKICK, self.eater.origin, '0 0 0');\r
                sound(self.eater, CHAN_PROJECTILE, "weapons/stomachkick.ogg", VOL_BASE, ATTN_NORM);\r
+\r
+               if(cvar("g_balance_vore_kick_escapeprobability") >= random())\r
+                       Vore_Regurgitate(self);\r
+\r
                self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay");\r
        }\r
 \r
        // start the predator's digestion\r
        if(self.BUTTON_ATCK2)\r
        {\r
-               centerprint(self.eater, strcat(self.netname, " triggered your digestion"));\r
+               centerprint(self.eater, strcat(self.netname, " has triggered your digestion"));\r
                self.eater.digesting = TRUE;\r
        }\r
 }\r
 \r
+.float gurglesound_finished, gurglesound_oldstomachload;\r
+void Vore_Gurglesound()\r
+{\r
+       if(time > self.gurglesound_finished || self.gurglesound_oldstomachload != self.stomach_load)\r
+       {\r
+               GlobalSound(self.playersound_gurgle, CHAN_TRIGGER, VOICETYPE_GURGLE);\r
+\r
+               self.gurglesound_finished = time + 11; // yes, hard coded sound length. I know it's bad but what can I do?\r
+               self.gurglesound_oldstomachload = self.stomach_load;\r
+       }\r
+}\r
+\r
 void Vore()\r
 {\r
+       // if we are free, show our stomach load on the HUD. Otherwise, show the predator's\r
+       if(self.eater.classname == "player")\r
+               self.stat_stomachload = self.eater.stomach_load;\r
+       else\r
+               self.stat_stomachload = self.stomach_load;\r
+\r
        // skip the vore system under some circumstances\r
        if(time < game_starttime)\r
        {\r
@@ -211,6 +251,8 @@ void Vore()
        }\r
        if(self.spectatee_status)\r
                return;\r
+       if(time < self.system_delay)\r
+               return;\r
 \r
 // --------------------------------\r
 // Code that addresses predators:\r
@@ -275,6 +317,9 @@ void Vore()
                }\r
        }\r
 \r
+       if(cvar("g_vore_gurglesound"))\r
+               Vore_Gurglesound();\r
+\r
 // --------------------------------\r
 // Code that addresses the prey:\r
 // --------------------------------\r