]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Don't allow players to swallow anyone larger than them by default. This means you...
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index f389d22d7b0cff77f6a7ba88c1e70f2c2bc6778d..4adbd900e443396e1710e16780f118823e24f78d 100644 (file)
@@ -18,7 +18,7 @@ entity Swallow_player_check()
        swallow_range = cvar("g_balance_vore_swallow_range");\r
        if(self.scale) // we can swallow from further or closer based on our size\r
                swallow_range *= self.scale;\r
-       vore_w_shotorg = self.origin + self.view_ofs;\r
+       vore_w_shotorg = self.origin;\r
        vore_w_shotdir = v_forward;\r
 \r
        WarpZone_traceline_antilag(self, vore_w_shotorg, vore_w_shotorg + vore_w_shotdir * swallow_range, FALSE, self, ANTILAG_LATENCY(self));\r
@@ -38,52 +38,28 @@ float Swallow_condition_check(entity prey)
        if(!self.BUTTON_REGURGITATE && self.swallow_delay < time)\r
        if not(vlen(self.velocity) > cvar("g_balance_vore_regurgitate_speedcap"))\r
        {\r
+               string swallow_complain;\r
                if(teams_matter && prey.team == self.team && !cvar("g_vore_teamvore"))\r
+                       swallow_complain = "You cannot swallow your team mates\n";\r
+               else if(!cvar("g_vore_spawnshield") && prey.spawnshieldtime > time)\r
+                       swallow_complain = "You cannot swallow someone protected by the spawn shield\n";\r
+               else if(self.stomach_load >= cvar("g_balance_vore_swallow_limit"))\r
+                       swallow_complain = strcat("You cannot swallow more than ^2", cvar_string("g_balance_vore_swallow_limit"), "^7 players at a time\n");\r
+               else if(cvar("g_vore_biggergut") && prey.stomach_load > self.stomach_load)\r
+                       swallow_complain = "You cannot swallow someone with a bigger stomach than yours\n";\r
+               else if(cvar("g_vore_biggersize") && prey.scale > self.scale)\r
+                       swallow_complain = "You cannot swallow someone larger than you\n";\r
+\r
+               if(swallow_complain != "")\r
                {\r
                        if(time > self.complain_vore && self.BUTTON_ATCK)\r
                        {\r
                                play2(self, "misc/forbidden.wav");\r
-                               sprint(self, "You cannot swallow your team mates\n");\r
+                               sprint(self, swallow_complain);\r
                                self.complain_vore = time + complain_delay_time;\r
                        }\r
                        return FALSE;\r
                }\r
-\r
-               if(self.stomach_load >= cvar("g_balance_vore_swallow_limit"))\r
-               {\r
-                       if(time > self.complain_vore && self.BUTTON_ATCK)\r
-                       {\r
-                               play2(self, "misc/forbidden.wav");\r
-                               sprint(self, strcat("You cannot swallow more than ^2", cvar_string("g_balance_vore_swallow_limit"), "^7 players at a time\n"));\r
-                               self.complain_vore = time + complain_delay_time;\r
-                       }\r
-                       return FALSE;\r
-               }\r
-\r
-               if(cvar("g_vore_biggergut"))\r
-               if(prey.stomach_load > self.stomach_load)\r
-               {\r
-                       if(time > self.complain_vore && self.BUTTON_ATCK)\r
-                       {\r
-                               play2(self, "misc/forbidden.wav");\r
-                               sprint(self, "You cannot swallow someone with a bigger stomach than yours\n");\r
-                               self.complain_vore = time + complain_delay_time;\r
-                       }\r
-                       return FALSE;\r
-               }\r
-\r
-               if(!cvar("g_vore_spawnshield"))\r
-               if(prey.spawnshieldtime > time)\r
-               {\r
-                       if(time > self.complain_vore && self.BUTTON_ATCK)\r
-                       {\r
-                               play2(self, "misc/forbidden.wav");\r
-                               sprint(self, "You cannot swallow someone protected by the spawn shield\n");\r
-                               self.complain_vore = time + complain_delay_time;\r
-                       }\r
-                       return FALSE;\r
-               }\r
-\r
                return TRUE;\r
        }\r
        return FALSE;\r
@@ -119,34 +95,20 @@ float Vore_CanLeave()
        return FALSE;\r
 }\r
 \r
-// make the camera smoothly lower itself when we get swallowed\r
-// our aim is going from the normal view offset to half of the view offset (because half is the best positioning for the stomach model)\r
-.float cameraeffect_current, cameraeffect_target;\r
-void Vore_CameraEffect_Set(entity e)\r
-{\r
-       e.cameraeffect_current = 1;\r
-       e.cameraeffect_target = 2;\r
-}\r
-void Vore_CameraEffect_Apply()\r
+// position the camera properly for prey\r
+void Vore_SetCamera()\r
 {\r
-       if(self.predator.classname != "player")\r
+       if not(self.predator.classname == "player" || self.fakeprey > 1)\r
                return;\r
 \r
-       if(self.cvar_cl_vore_cameraspeed)\r
-       {\r
-               local float step;\r
-               step = self.cvar_cl_vore_cameraspeed * frametime;\r
-\r
-               // not sure if these maths are good, as the effect should be smoother\r
-               if(self.cameraeffect_current >= self.cameraeffect_target + step)\r
-                       self.cameraeffect_current -= step;\r
-               else if(self.cameraeffect_current <= self.cameraeffect_target - step)\r
-                       self.cameraeffect_current += step;\r
-       }\r
-       else\r
-               self.cameraeffect_current = self.cameraeffect_target;\r
+       self.view_ofs = PL_PREY_VIEW_OFS;\r
 \r
-       self.view_ofs_z = PL_VIEW_OFS_z / self.cameraeffect_current;\r
+       float prey_height;\r
+       if(self.fakeprey > 1)\r
+               prey_height = (self.scale - self.fakepredator.scale) * cvar("g_healthsize_vore_pos");\r
+       else\r
+               prey_height = (self.scale - self.predator.scale) * cvar("g_healthsize_vore_pos");\r
+       self.view_ofs_z += prey_height;\r
 }\r
 \r
 .float gurgle_oldstomachload;\r
@@ -203,7 +165,6 @@ void Vore_Swallow(entity e)
        e.velocity = '0 0 0';\r
        e.movetype = MOVETYPE_FOLLOW;\r
        e.solid = SOLID_NOT;\r
-       e.alpha = -1; // best way of hiding the eaten player\r
        e.aiment = e.predator; // follow the predator, automatically unset when regurgitated\r
 \r
        // drop keys (KH) and flags (CTF) when we get swallowed\r
@@ -211,8 +172,6 @@ void Vore_Swallow(entity e)
        if(e.flagcarried)\r
                DropFlag(e.flagcarried, world, e.predator);\r
 \r
-       Vore_CameraEffect_Set(e);\r
-\r
        if(stov(cvar_string("g_vore_regurgitatecolor_release")))\r
                e.colormod = stov(cvar_string("g_vore_regurgitatecolor_release"));\r
 \r
@@ -247,7 +206,6 @@ void Vore_Regurgitate(entity e)
        if(e.health > 0) // leave SOLID_NOT for dead bodies\r
                e.solid = e.vore_oldsolid;\r
        e.view_ofs_z = PL_VIEW_OFS_z;\r
-       e.alpha = default_player_alpha;\r
 \r
        // apply velocities\r
        local vector oldforward, oldright, oldup;\r
@@ -288,7 +246,7 @@ void Vore_DeadPrey_Configure(entity e)
 \r
        // this entity is like e.predator but for dead prey, to avoid conflicts\r
        e.fakepredator = e.predator;\r
-       e.fakeprey = TRUE;\r
+       e.fakeprey = 2; // is fakeprey in a stomach\r
 \r
        // first release the prey from the predator, as dead prey needs to be attached differently\r
        // the predator's stomach load is also decreased, as dead prey doesn't count any more\r
@@ -301,9 +259,6 @@ void Vore_DeadPrey_Configure(entity e)
        e.takedamage = DAMAGE_NO;\r
        e.solid = SOLID_NOT;\r
        e.aiment = e.fakepredator;\r
-\r
-       // completely remove the dead body\r
-       e.modelindex = 0;\r
 }\r
 \r
 void Vore_DeadPrey_Detach(entity e)\r
@@ -315,7 +270,7 @@ void Vore_DeadPrey_Detach(entity e)
                return;\r
 \r
        e.fakepredator = world;\r
-       e.fakeprey = FALSE;\r
+       e.fakeprey = 1; // was fakeprey but is now detached\r
        e.aiment = world;\r
        e.movetype = MOVETYPE_TOSS;\r
 }\r
@@ -324,7 +279,7 @@ void Vore_PreyRelease(entity e, float pred_disconnect)
 {\r
        if(pred_disconnect)\r
        {\r
-               if(e.fakeprey)\r
+               if(e.fakeprey > 1)\r
                        Vore_DeadPrey_Detach(e);\r
                else\r
                        Vore_Regurgitate(e);\r
@@ -506,7 +461,7 @@ void Vore()
        }\r
 \r
        // set all vore stats\r
-       if(self.fakeprey)\r
+       if(self.fakeprey > 1)\r
                self.stat_eaten = num_for_edict(self.fakepredator);\r
        else if(self.predator.classname == "player")\r
        {\r
@@ -628,6 +583,8 @@ void Vore()
 // Code that addresses the prey:\r
 // --------------------------------\r
 \r
+       Vore_SetCamera();\r
+\r
        // keepdeadprey - detach dead prey if their predator died or got swallowed\r
        if(self.fakepredator.classname == "player")\r
        if(self.fakepredator.deadflag != DEAD_NO || self.fakepredator.predator.classname == "player")\r
@@ -668,8 +625,6 @@ void Vore()
        if(self.BUTTON_JUMP)\r
                Vore_StomachLeave();\r
 \r
-       Vore_CameraEffect_Apply();\r
-\r
        // Ugly workaround for a Keyhunt issue. Your team's key can still be given to you while in the stomach\r
        // (at round start), which is pretty ugly and wrong. So attempt to drop keys each frame for prey\r
        kh_Key_DropAll(self, FALSE);\r