]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/server/vore.qc
Base stomach kick sounds on player scale difference, and tweak the system a bit
[voretournament/voretournament.git] / data / qcsrc / server / vore.qc
index 53202c6e6d9570c834a3d00c45b0e7eba5117636..736e7bda8aa089196f2db4506b6442c72591c93a 100644 (file)
@@ -199,59 +199,62 @@ void Vore_AutoDigest(entity e)
        e.digesting = TRUE;\r
 }\r
 \r
+.entity swallow_model;\r
 void Vore_SwallowModel_Think()\r
 {\r
-       //update the necessary angles to match our view\r
-       //self.angles_x = self.owner.angles_x;\r
-       //self.view_ofs = self.owner.view_ofs;\r
-\r
-       self.view_ofs = '1 0 0' * 500;\r
-\r
-       // if our swallow progress is gone, the swallow model must also go\r
-       if(!self.owner.swallow_progress_prey)\r
-       {\r
-               self.nextthink = 0;\r
-               remove(self);\r
-               self = world;\r
+       //update the position of the swallow model to match our swallow progress\r
+       float dist;\r
+       dist = (-0.5 + self.owner.swallow_progress_prey) * cvar("g_vore_swallowmodel_range"); // the model is centered at 0.5 progress\r
+       if(cvar("g_healthsize"))\r
+               dist *= self.scale;\r
+       self.view_ofs = '1 0 0' * dist;\r
+\r
+       // if our swallow progress is gone or we are dead, the swallow model also goes away\r
+       if(!self.owner.swallow_progress_prey || self.owner.deadflag != DEAD_NO || self.owner.classname != "player")\r
+       {\r
+               remove(self.owner.swallow_model);\r
+               self.owner.swallow_model = world;\r
                return;\r
        }\r
 \r
+       // properties that should update whenever possible, but when the predator is not available\r
+       self.alpha = self.owner.cvar_cl_vore_swallowmodel;\r
        self.nextthink = time;\r
 }\r
 \r
-.entity swallow_model;\r
-void Vore_SwallowModel_Update(entity prey)\r
+void Vore_SwallowModel_Update(entity prey, entity pred)\r
 {\r
        // if we don't have a swallow model already, spawn one\r
        if(!prey.swallow_model)\r
        {\r
                prey.swallow_model = spawn();\r
-               \r
+\r
                prey.swallow_model.movetype = MOVETYPE_FOLLOW;\r
                prey.swallow_model.solid = SOLID_NOT;\r
 \r
-               prey.swallow_model.skin = self.skin;\r
-               prey.swallow_model.scale = self.scale;\r
-\r
                // apply the properties of the prey\r
-               prey.swallow_model.viewmodelforclient = prey;\r
-               prey.swallow_model.effects |= EF_NOGUNBOB;\r
-               prey.swallow_model.alpha = prey.cvar_cl_vore_stomachmodel;\r
-               prey.swallow_model.colormap = prey.colormap;\r
-               prey.swallow_model.glowmod = prey.glowmod;\r
+               prey.swallow_model.viewmodelforclient = prey; // use the same system as the weapon model\r
+               //prey.swallow_model.effects |= EF_NOGUNBOB; // let it bob\r
+               prey.swallow_model.effects |= EF_NODEPTHTEST; // don't hide behind walls\r
+               prey.swallow_model.colormap = prey.colormap; // pants and shirt color\r
+               prey.swallow_model.glowmod = prey.glowmod; // glow color\r
 \r
                prey.swallow_model.owner = prey; // owned by the prey\r
                prey.swallow_model.think = Vore_SwallowModel_Think;\r
                prey.swallow_model.nextthink = time;\r
        }\r
 \r
-       // if predator has changed, update the swallow model\r
-       if(prey.swallow_model.enemy != self)\r
-       {\r
-               setmodel(prey.swallow_model, strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_swallow.md3")); // 4 is the extension length\r
-               prey.swallow_model.skin = self.skin;\r
-               prey.swallow_model.enemy = self; // enemy is the predator\r
-       }\r
+       // properties that should update whenever possible, but when the predator is available\r
+       string player_swallowmodel;\r
+       player_swallowmodel = strcat(substring(pred.playermodel, 0, strlen(pred.playermodel) - 4), "_swallow.md3"); // 4 is the extension length\r
+       if(prey.swallow_model.model != player_swallowmodel) // player model can be changed while the predator is active\r
+               setmodel(prey.swallow_model, player_swallowmodel);\r
+       if(prey.swallow_model.skin != pred.skin) // player skin can be changed while the predator is active\r
+               prey.swallow_model.skin = pred.skin;\r
+       if(cvar("g_healthsize"))\r
+               prey.swallow_model.scale = pred.scale / prey.scale; // player size difference\r
+       if(prey.swallow_model.enemy != pred)\r
+               prey.swallow_model.enemy = pred; // enemy is the predator\r
 }\r
 \r
 .entity pusher;\r
@@ -292,6 +295,7 @@ void Vore_Swallow(entity e)
        e.predator.stomach_load += 1;\r
        e.predator.regurgitate_prepare = 0;\r
        e.predator.spawnshieldtime = 0; // lose spawn shield when we vore\r
+       e.predator.hitsound += 1; // play this for team mates too, as we could be swallowing them to heal them\r
        Vore_WeightApply(e.predator);\r
        Vore_AutoDigest(e.predator);\r
 \r
@@ -310,7 +314,7 @@ void Vore_SwallowStep(entity e)
                return;\r
        }\r
 \r
-       Vore_SwallowModel_Update(e);\r
+       Vore_SwallowModel_Update(e, self);\r
 \r
        // increase the progress value until it reaches 1, then swallow the player\r
        if(e.swallow_progress_prey < 1)\r
@@ -359,12 +363,25 @@ void Vore_Regurgitate(entity e)
        e.pushltime = time + cvar("g_maxpushtime");\r
 \r
        // regurgitated prey is given this amount of swallow progress, to simulate being more vulnerable\r
-       if(cvar("g_balance_vore_swallow_speed_fill"))\r
+       if(cvar("g_balance_vore_swallow_speed_fill") && cvar("g_balance_vore_regurgitate_swallowprogress"))\r
+       {\r
                e.swallow_progress_prey = cvar("g_balance_vore_regurgitate_swallowprogress");\r
+               Vore_SwallowModel_Update(e, e.predator);\r
+       }\r
+\r
+       // apply regurgitation damage to the predator\r
+       if(cvar("g_balance_vore_regurgitate_damage"))\r
+       {\r
+               float regurgitate_dmg;\r
+               regurgitate_dmg = cvar("g_balance_vore_regurgitate_damage");\r
+               if(cvar("g_healthsize"))\r
+                       regurgitate_dmg *= e.scale / e.predator.scale;\r
+               Damage(e.predator, e.predator, e.predator, regurgitate_dmg, DEATH_REGURGITATION, e.predator.origin, '0 0 0');\r
+       }\r
 \r
        PlayerSound(e.predator, playersound_regurgitate, CHAN_VOICE, VOICETYPE_PLAYERSOUND);\r
        setanim(e.predator, e.predator.anim_pain1, FALSE, TRUE, TRUE); // looks good for swallowing / regurgitating\r
-       pointparticles(particleeffectnum("regurgitate"), e.predator.origin, '0 0 0', 1);\r
+       pointparticles(particleeffectnum("vore_regurgitate"), e.predator.origin, '0 0 0', 1);\r
        e.predator.punchangle_x += cvar("g_balance_vore_regurgitate_punchangle");\r
        e.predator.stomach_load -= 1;\r
        e.predator.regurgitate_prepare = 0;\r
@@ -513,26 +530,30 @@ void Vore_Teamheal()
        }\r
 }\r
 \r
+.float kick_pressed;\r
 void Vore_StomachKick()\r
 {\r
        // allows prey to kick the predator's stomach and do some damage or attempt to escape\r
 \r
-       if(time > self.stomachkick_delay)\r
+       if(time > self.stomachkick_delay && !self.kick_pressed)\r
        {\r
-               float damage;\r
+               float damage, vol;\r
                vector force;\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
                force = v_forward * cvar("g_balance_vore_kick_force");\r
+               vol = VOL_BASE;\r
 \r
                // apply player scale to the damage / force of the kick\r
-               if(cvar("g_balance_vore_kick_scalediff"))\r
+               if(cvar("g_healthsize") && cvar("g_balance_vore_kick_scalediff"))\r
                {\r
                        damage *= (self.scale / self.predator.scale);\r
                        force *= (self.scale / self.predator.scale);\r
+                       vol *= (self.scale / self.predator.scale); // kick sound volume based on the same scale\r
                }\r
+               vol = bound(0, vol, 1);\r
 \r
                Damage(self.predator, self, self, damage, DEATH_STOMACHKICK, self.predator.origin, force);\r
-               sound(self.predator, CHAN_PROJECTILE, strcat("weapons/hit", ftos(floor(random() * 8)), ".wav"), VOL_BASE, ATTN_NORM);\r
+               sound(self.predator, CHAN_PROJECTILE, strcat("weapons/hit", ftos(floor(random() * 8)), ".wav"), vol, ATTN_NORM);\r
                self.predator.punchangle_x -= cvar("g_balance_vore_kick_predator_punchangle");\r
                self.punchangle_x += cvar("g_balance_vore_kick_prey_punchangle");\r
 \r
@@ -541,6 +562,9 @@ void Vore_StomachKick()
                        self.predator.regurgitate_prepare = 0;\r
 \r
                self.stomachkick_delay = time + cvar("g_balance_vore_kick_delay");\r
+               if(cvar("g_balance_vore_kick_repress"))\r
+               if not(clienttype(self) == CLIENTTYPE_BOT) // not for bots, to prevent an issue\r
+                       self.kick_pressed = TRUE;\r
        }\r
 }\r
 \r
@@ -639,12 +663,6 @@ void Vore()
 {\r
        // main vore code, this is where it all happens\r
 \r
-       if(!cvar("g_vore")) // the vore system is disabled\r
-       {\r
-               Vore_Disconnect();\r
-               return;\r
-       }\r
-\r
        Vore_AutoTaunt();\r
 \r
        // wash the goo away from players once they leave the stomach\r
@@ -724,6 +742,11 @@ void Vore()
        }\r
 \r
        // apply delays and skip the vore system under some circumstances\r
+       if(!cvar("g_vore")) // the vore system is disabled\r
+       {\r
+               Vore_Disconnect();\r
+               return;\r
+       }\r
        if(time < game_starttime || (time < warmup && !inWarmupStage)) // don't allow vore before a round begins\r
        {\r
                Vore_Disconnect();\r
@@ -842,8 +865,13 @@ void Vore()
                Vore_Teamheal();\r
 \r
        // execute prey commands\r
-       if(self.BUTTON_ATCK && cvar("g_vore_kick"))\r
-               Vore_StomachKick();\r
+       if(self.BUTTON_ATCK)\r
+       {\r
+               if(cvar("g_vore_kick"))\r
+                       Vore_StomachKick();\r
+       }\r
+       else\r
+               self.kick_pressed = FALSE;\r
        if(self.BUTTON_JUMP)\r
                Vore_StomachLeave();\r
 \r