]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/controlpoint.qc
Merge branch 'master' into TimePath/effectinfo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / controlpoint.qc
index c01835c9f86da5d3a7cdb177143b312afc5f25b2..a83260b1049c7dfcabcb04926e9b6c817fe1dd23 100644 (file)
@@ -1,8 +1,13 @@
-float cpicon_precached;
-.float count;
+#include "controlpoint.qh"
+#include "gibs.qh"
+#include "teamradar.qh"
+#include "../common/movetypes/movetypes.qh"
+
+.float alpha;
+.int count;
 .float pain_finished;
 
-.float iscaptured;
+.bool iscaptured;
 
 .vector cp_origin, cp_bob_origin;
 .float cp_bob_spd;
@@ -15,21 +20,8 @@ float cpicon_precached;
 
 .entity icon_realmodel;
 
-void cpicon_precache()
-{
-       if(cpicon_precached)
-               return; // already precached
-
-       precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
-       precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
-       precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
-       precache_model("models/onslaught/controlpoint_icon.md3");
-
-       cpicon_precached = TRUE;
-}
-
 void cpicon_draw()
-{
+{SELFPARAM();
        if(time < self.move_time) { return; }
 
        if(self.cp_bob_dmg_z > 0)
@@ -39,9 +31,9 @@ void cpicon_draw()
        self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd));
        self.cp_bob_spd = self.cp_bob_spd + 1.875 * frametime;
        self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
-       
+
        if(!self.iscaptured) self.alpha = self.health / self.max_health;
-       
+
        if(self.iscaptured)
        {
                if (self.punchangle_x > 0)
@@ -88,23 +80,23 @@ void cpicon_draw()
                self.angles_z = self.punchangle_z;
                self.move_angles_y = self.move_angles_y + 45 * frametime;
        }
-       
+
        setorigin(self, self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg);
 }
 
 void cpicon_damage(float hp)
-{
+{SELFPARAM();
        if(!self.iscaptured) { return; }
 
        if(hp < self.max_health * 0.25)
-               setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
+               setmodel(self, MDL_ONS_CP3);
        else if(hp < self.max_health * 0.50)
-               setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
+               setmodel(self, MDL_ONS_CP2);
        else if(hp < self.max_health * 0.75)
-               setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
+               setmodel(self, MDL_ONS_CP1);
        else if(hp <= self.max_health || hp >= self.max_health)
-               setmodel(self, "models/onslaught/controlpoint_icon.md3");
-               
+               setmodel(self, MDL_ONS_CP);
+
        self.punchangle = (2 * randomvec() - '1 1 1') * 45;
 
        self.cp_bob_dmg_z = (2 * random() - 1) * 15;
@@ -115,23 +107,23 @@ void cpicon_damage(float hp)
 }
 
 void cpicon_construct()
-{
+{SELFPARAM();
        self.netname = "Control Point Icon";
 
-       setmodel(self, "models/onslaught/controlpoint_icon.md3");
+       setmodel(self, MDL_ONS_CP);
        setsize(self, CPICON_MIN, CPICON_MAX);
-       
+
        if(self.icon_realmodel == world)
        {
                self.icon_realmodel = spawn();
-               setmodel(self.icon_realmodel, "null");
+               setmodel(self.icon_realmodel, MDL_Null);
                setorigin(self.icon_realmodel, self.origin);
                setsize(self.icon_realmodel, CPICON_MIN, CPICON_MAX);
                self.icon_realmodel.movetype = MOVETYPE_NOCLIP;
                self.icon_realmodel.solid = SOLID_NOT;
                self.icon_realmodel.move_origin = self.icon_realmodel.origin;
        }
-       
+
        if(self.iscaptured) { self.icon_realmodel.solid = SOLID_BBOX; }
 
        self.move_movetype      = MOVETYPE_NOCLIP;
@@ -149,7 +141,7 @@ void cpicon_construct()
 
 .vector glowmod;
 void cpicon_changeteam()
-{
+{SELFPARAM();
        if(self.team)
        {
                self.glowmod = Team_ColorRGB(self.team - 1);
@@ -165,9 +157,8 @@ void cpicon_changeteam()
 }
 
 void ent_cpicon()
-{
-       float sf;
-       sf = ReadByte();
+{SELFPARAM();
+       int sf = ReadByte();
 
        if(sf & CPSF_SETUP)
        {
@@ -186,14 +177,12 @@ void ent_cpicon()
                        self.count = (self.health - self.max_health) * frametime;
 
                cpicon_changeteam();
-               cpicon_precache();
                cpicon_construct();
        }
 
        if(sf & CPSF_STATUS)
        {
-               float _tmp;
-               _tmp = ReadByte();
+               int _tmp = ReadByte();
                if(_tmp != self.team)
                {
                        self.team = _tmp;