]> de.git.xonotic.org Git - voretournament/voretournament.git/commitdiff
Properly set and update the swallow model
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 9 Jul 2011 23:03:37 +0000 (02:03 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 9 Jul 2011 23:03:37 +0000 (02:03 +0300)
data/qcsrc/server/vore.qc

index e289809838accf5d41a7504e9fbf3f44bf7a468a..01c58f3704a90593f6dcecfeb29a3cf136ff2ded 100644 (file)
@@ -204,6 +204,7 @@ void Vore_SwallowModel_Think()
        //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
+       self.alpha = self.owner.cvar_cl_vore_stomachmodel;\r
 \r
        // if our swallow progress is gone, the swallow model must also go\r
        /*if(!self.owner.swallow_progress_prey)\r
@@ -218,28 +219,35 @@ void Vore_SwallowModel_Think()
 }\r
 \r
 .entity swallow_model;\r
-void Vore_SwallowModel_Spawn(entity prey)\r
+void Vore_SwallowModel_Update(entity prey)\r
 {\r
-       entity e;\r
-       e = spawn();\r
-       \r
-       e.movetype = MOVETYPE_FOLLOW;\r
-       e.solid = SOLID_NOT;\r
-       e.alpha = prey.cvar_cl_vore_stomachmodel;\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
+               prey.swallow_model.movetype = MOVETYPE_FOLLOW;\r
+               prey.swallow_model.solid = SOLID_NOT;\r
 \r
-       // apply the properties of the predator\r
-       setmodel(e, strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_swallow.md3")); // 4 is the extension length\r
-       //e.skin = self.skin;\r
-       e.scale = self.scale;\r
+               prey.swallow_model.skin = self.skin;\r
+               prey.swallow_model.scale = self.scale;\r
 \r
-       // apply the properties of the prey\r
-       e.angles_x = prey.angles_x;\r
-       e.aiment = prey;\r
+               // apply the properties of the prey\r
+               prey.swallow_model.aiment = prey;\r
 \r
-       e.owner = prey; // owned by the prey\r
-       e.enemy = self; // enemy is the predator\r
-       e.think = Vore_SwallowModel_Think;\r
-       e.nextthink = time;\r
+               prey.swallow_model.owner = prey; // owned by the prey\r
+               prey.swallow_model.enemy = self; // enemy is the predator\r
+               prey.swallow_model.think = Vore_SwallowModel_Think;\r
+               prey.swallow_model.nextthink = time;\r
+       }\r
+\r
+       // if the model or skin of the prey's swallow model don't match those of our current predator, change them\r
+       string swallow_mdl;\r
+       swallow_mdl = strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_swallow.md3"); // 4 is the extension length\r
+       if(prey.swallow_model.model != swallow_mdl)\r
+               setmodel(prey.swallow_model, swallow_mdl);\r
+       if(prey.swallow_model.skin != self.skin)\r
+               prey.swallow_model.skin = self.skin;\r
 }\r
 \r
 .entity pusher;\r
@@ -298,16 +306,7 @@ void Vore_SwallowStep(entity e)
                return;\r
        }\r
 \r
-       // if the predator swallowing me has changed, remove the swallow model\r
-       if(e.swallow_model != world && e.swallow_model.enemy != self)\r
-       {\r
-               e.swallow_model.nextthink = 0;\r
-               remove(e.swallow_model);\r
-               e.swallow_model = world;\r
-       }\r
-       //set the swallow model for the prey\r
-       if(e.swallow_model == world)\r
-               Vore_SwallowModel_Spawn(e);\r
+       Vore_SwallowModel_Update(e);\r
 \r
        // increase the progress value until it reaches 1, then swallow the player\r
        if(e.swallow_progress_prey < 1)\r