From 2598a016abe420c3081e498a72abae1a944e5727 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sun, 10 Jul 2011 02:03:37 +0300 Subject: [PATCH 1/1] Properly set and update the swallow model --- data/qcsrc/server/vore.qc | 55 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index e2898098..01c58f37 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -204,6 +204,7 @@ void Vore_SwallowModel_Think() //update the necessary angles to match our view self.angles_x = self.owner.angles_x; self.view_ofs = self.owner.view_ofs; + self.alpha = self.owner.cvar_cl_vore_stomachmodel; // if our swallow progress is gone, the swallow model must also go /*if(!self.owner.swallow_progress_prey) @@ -218,28 +219,35 @@ void Vore_SwallowModel_Think() } .entity swallow_model; -void Vore_SwallowModel_Spawn(entity prey) +void Vore_SwallowModel_Update(entity prey) { - entity e; - e = spawn(); - - e.movetype = MOVETYPE_FOLLOW; - e.solid = SOLID_NOT; - e.alpha = prey.cvar_cl_vore_stomachmodel; + // if we don't have a swallow model already, spawn one + if(!prey.swallow_model) + { + prey.swallow_model = spawn(); + + prey.swallow_model.movetype = MOVETYPE_FOLLOW; + prey.swallow_model.solid = SOLID_NOT; - // apply the properties of the predator - setmodel(e, strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_swallow.md3")); // 4 is the extension length - //e.skin = self.skin; - e.scale = self.scale; + prey.swallow_model.skin = self.skin; + prey.swallow_model.scale = self.scale; - // apply the properties of the prey - e.angles_x = prey.angles_x; - e.aiment = prey; + // apply the properties of the prey + prey.swallow_model.aiment = prey; - e.owner = prey; // owned by the prey - e.enemy = self; // enemy is the predator - e.think = Vore_SwallowModel_Think; - e.nextthink = time; + prey.swallow_model.owner = prey; // owned by the prey + prey.swallow_model.enemy = self; // enemy is the predator + prey.swallow_model.think = Vore_SwallowModel_Think; + prey.swallow_model.nextthink = time; + } + + // if the model or skin of the prey's swallow model don't match those of our current predator, change them + string swallow_mdl; + swallow_mdl = strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_swallow.md3"); // 4 is the extension length + if(prey.swallow_model.model != swallow_mdl) + setmodel(prey.swallow_model, swallow_mdl); + if(prey.swallow_model.skin != self.skin) + prey.swallow_model.skin = self.skin; } .entity pusher; @@ -298,16 +306,7 @@ void Vore_SwallowStep(entity e) return; } - // if the predator swallowing me has changed, remove the swallow model - if(e.swallow_model != world && e.swallow_model.enemy != self) - { - e.swallow_model.nextthink = 0; - remove(e.swallow_model); - e.swallow_model = world; - } - //set the swallow model for the prey - if(e.swallow_model == world) - Vore_SwallowModel_Spawn(e); + Vore_SwallowModel_Update(e); // increase the progress value until it reaches 1, then swallow the player if(e.swallow_progress_prey < 1) -- 2.39.2