]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc
Clear out .health and .armorvalue from the client side
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / onslaught / cl_generator.qc
index f5b61117d15234155ff37c7b4645da227665ad38..9d12c5548e6d4eafd4abdb336b6aa7208274bda3 100644 (file)
@@ -7,24 +7,25 @@
 
 void ons_generator_ray_draw(entity this)
 {
 
 void ons_generator_ray_draw(entity this)
 {
-       if(time < self.move_time)
+       if(time < this.move_time)
                return;
 
                return;
 
-       self.move_time = time + 0.05;
+       this.move_time = time + 0.05;
 
 
-       if(self.count > 10)
+       if(this.count > 10)
        {
        {
-               remove(self);
+               IL_REMOVE(g_drawables, this);
+               delete(this);
                return;
        }
 
                return;
        }
 
-       if(self.count > 5)
-               self.alpha -= 0.1;
+       if(this.count > 5)
+               this.alpha -= 0.1;
        else
        else
-               self.alpha += 0.1;
+               this.alpha += 0.1;
 
 
-       self.scale += 0.2;
-       self.count +=1;
+       this.scale += 0.2;
+       this.count +=1;
 }
 
 void ons_generator_ray_spawn(vector org)
 }
 
 void ons_generator_ray_spawn(vector org)
@@ -33,149 +34,154 @@ void ons_generator_ray_spawn(vector org)
        setmodel(e, MDL_ONS_RAY);
        setorigin(e, org);
        e.angles = randomvec() * 360;
        setmodel(e, MDL_ONS_RAY);
        setorigin(e, org);
        e.angles = randomvec() * 360;
-       e.move_origin = org;
-       e.movetype = MOVETYPE_NONE;
+       set_movetype(e, MOVETYPE_NONE);
        e.alpha = 0;
        e.scale = random() * 5 + 8;
        e.move_time = time + 0.05;
        e.drawmask = MASK_NORMAL;
        e.draw = ons_generator_ray_draw;
        e.alpha = 0;
        e.scale = random() * 5 + 8;
        e.move_time = time + 0.05;
        e.drawmask = MASK_NORMAL;
        e.draw = ons_generator_ray_draw;
+       IL_PUSH(g_drawables, e);
 }
 
 void generator_draw(entity this)
 {
 }
 
 void generator_draw(entity this)
 {
-       if(time < self.move_time)
+       if(time < this.move_time)
                return;
 
                return;
 
-       if(self.health > 0)
+       if(GetResourceAmount(this, RESOURCE_HEALTH) > 0)
        {
                // damaged fx (less probable the more damaged is the generator)
        {
                // damaged fx (less probable the more damaged is the generator)
-               if(random() < 0.9 - self.health / self.max_health)
+               if(random() < 0.9 - GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health)
                if(random() < 0.01)
                {
                if(random() < 0.01)
                {
-                       pointparticles(EFFECT_ELECTRO_BALLEXPLODE, self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
-                       sound(self, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
+                       pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
+                       sound(this, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
                }
                else
                }
                else
-                       pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
+                       pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, this.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
 
 
-               self.move_time = time + 0.1;
+               this.move_time = time + 0.1;
 
                return;
        }
 
 
                return;
        }
 
-       if(self.count <= 0)
+       if(this.count <= 0)
                return;
 
        vector org;
        int i;
 
        // White shockwave
                return;
 
        vector org;
        int i;
 
        // White shockwave
-       if(self.count==40||self.count==20)
+       if(this.count==40||this.count==20)
        {
        {
-               sound(self, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
-               pointparticles(EFFECT_ELECTRO_COMBO, self.origin, '0 0 0', 6);
+               sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
+               pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
        }
 
        // rays
        if(random() > 0.25)
        {
        }
 
        // rays
        if(random() > 0.25)
        {
-               ons_generator_ray_spawn(self.origin);
+               ons_generator_ray_spawn(this.origin);
        }
 
        // Spawn fire balls
        for(i=0;i < 10;++i)
        {
        }
 
        // Spawn fire balls
        for(i=0;i < 10;++i)
        {
-               org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
+               org = this.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
                pointparticles(EFFECT_ONS_GENERATOR_GIB, org, '0 0 0', 1);
        }
 
        // Short explosion sound + small explosion
        if(random() < 0.25)
        {
                pointparticles(EFFECT_ONS_GENERATOR_GIB, org, '0 0 0', 1);
        }
 
        // Short explosion sound + small explosion
        if(random() < 0.25)
        {
-               te_explosion(self.origin);
-               sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
+               te_explosion(this.origin);
+               sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
        }
 
        // Particles
        }
 
        // Particles
-       org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
+       org = this.origin + randompos(this.mins + '8 8 8', this.maxs + '-8 -8 -8');
        pointparticles(EFFECT_ONS_GENERATOR_EXPLODE, org, '0 0 0', 1);
 
        // Final explosion
        pointparticles(EFFECT_ONS_GENERATOR_EXPLODE, org, '0 0 0', 1);
 
        // Final explosion
-       if(self.count==1)
+       if(this.count==1)
        {
        {
-               org = self.origin;
+               org = this.origin;
                te_explosion(org);
                pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
                te_explosion(org);
                pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
-               sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+               sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        }
 
        }
 
-       self.move_time = time + 0.05;
+       this.move_time = time + 0.05;
 
 
-       self.count -= 1;
+       this.count -= 1;
 }
 
 }
 
-void generator_damage(float hp)
-{SELFPARAM();
+void generator_damage(entity this, float hp)
+{
        if(hp <= 0)
        if(hp <= 0)
-               setmodel(self, MDL_ONS_GEN_DEAD);
-       else if(hp < self.max_health * 0.10)
-               setmodel(self, MDL_ONS_GEN9);
-       else if(hp < self.max_health * 0.20)
-               setmodel(self, MDL_ONS_GEN8);
-       else if(hp < self.max_health * 0.30)
-               setmodel(self, MDL_ONS_GEN7);
-       else if(hp < self.max_health * 0.40)
-               setmodel(self, MDL_ONS_GEN6);
-       else if(hp < self.max_health * 0.50)
-               setmodel(self, MDL_ONS_GEN5);
-       else if(hp < self.max_health * 0.60)
-               setmodel(self, MDL_ONS_GEN4);
-       else if(hp < self.max_health * 0.70)
-               setmodel(self, MDL_ONS_GEN3);
-       else if(hp < self.max_health * 0.80)
-               setmodel(self, MDL_ONS_GEN2);
-       else if(hp < self.max_health * 0.90)
-               setmodel(self, MDL_ONS_GEN1);
-       else if(hp <= self.max_health || hp >= self.max_health)
-               setmodel(self, MDL_ONS_GEN);
-
-       setsize(self, GENERATOR_MIN, GENERATOR_MAX);
+               setmodel(this, MDL_ONS_GEN_DEAD);
+       else if(hp < this.max_health * 0.10)
+               setmodel(this, MDL_ONS_GEN9);
+       else if(hp < this.max_health * 0.20)
+               setmodel(this, MDL_ONS_GEN8);
+       else if(hp < this.max_health * 0.30)
+               setmodel(this, MDL_ONS_GEN7);
+       else if(hp < this.max_health * 0.40)
+               setmodel(this, MDL_ONS_GEN6);
+       else if(hp < this.max_health * 0.50)
+               setmodel(this, MDL_ONS_GEN5);
+       else if(hp < this.max_health * 0.60)
+               setmodel(this, MDL_ONS_GEN4);
+       else if(hp < this.max_health * 0.70)
+               setmodel(this, MDL_ONS_GEN3);
+       else if(hp < this.max_health * 0.80)
+               setmodel(this, MDL_ONS_GEN2);
+       else if(hp < this.max_health * 0.90)
+               setmodel(this, MDL_ONS_GEN1);
+       else if(hp <= this.max_health || hp >= this.max_health)
+               setmodel(this, MDL_ONS_GEN);
+
+       setsize(this, GENERATOR_MIN, GENERATOR_MAX);
 }
 
 }
 
-void generator_construct()
-{SELFPARAM();
-       self.netname = "Generator";
-       self.classname = "onslaught_generator";
-
-       setorigin(self, self.origin);
-       setmodel(self, MDL_ONS_GEN);
-       setsize(self, GENERATOR_MIN, GENERATOR_MAX);
-
-       self.move_movetype      = MOVETYPE_NOCLIP;
-       self.solid                      = SOLID_BBOX;
-       self.movetype           = MOVETYPE_NOCLIP;
-       self.move_origin        = self.origin;
-       self.move_time          = time;
-       self.drawmask           = MASK_NORMAL;
-       self.alpha                      = 1;
-       self.draw                       = generator_draw;
+void generator_construct(entity this, bool isnew)
+{
+       this.netname = "Generator";
+       this.classname = "onslaught_generator";
+
+       if(isnew)
+       {
+               IL_PUSH(g_onsgenerators, this);
+               IL_PUSH(g_drawables, this);
+       }
+
+       setorigin(this, this.origin);
+       setmodel(this, MDL_ONS_GEN);
+       setsize(this, GENERATOR_MIN, GENERATOR_MAX);
+
+       set_movetype(this, MOVETYPE_NOCLIP);
+       this.solid                      = SOLID_BBOX;
+       set_movetype(this, MOVETYPE_NOCLIP);
+       this.move_time          = time;
+       this.drawmask           = MASK_NORMAL;
+       this.alpha                      = 1;
+       this.draw                       = generator_draw;
 }
 
 .vector glowmod;
 }
 
 .vector glowmod;
-void generator_changeteam()
-{SELFPARAM();
-       if(self.team)
+void generator_changeteam(entity this)
+{
+       if(this.team)
        {
        {
-               self.glowmod = Team_ColorRGB(self.team - 1);
-               self.teamradar_color = Team_ColorRGB(self.team - 1);
-               self.colormap = 1024 + (self.team - 1) * 17;
+               this.glowmod = Team_ColorRGB(this.team - 1);
+               this.teamradar_color = Team_ColorRGB(this.team - 1);
+               this.colormap = 1024 + (this.team - 1) * 17;
        }
        else
        {
        }
        else
        {
-               self.colormap = 1024;
-               self.glowmod = '1 1 0';
-               self.teamradar_color = '1 1 0';
+               this.colormap = 1024;
+               this.glowmod = '1 1 0';
+               this.teamradar_color = '1 1 0';
        }
 }
 
        }
 }
 
@@ -186,38 +192,36 @@ NET_HANDLE(ENT_CLIENT_GENERATOR, bool isnew)
 
        if(sf & GSF_SETUP)
        {
 
        if(sf & GSF_SETUP)
        {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-               setorigin(self, self.origin);
+               this.origin = ReadVector();
+               setorigin(this, this.origin);
 
 
-               self.health = ReadByte();
-               self.max_health = ReadByte();
-               self.count = ReadByte();
-               self.team = ReadByte();
+               SetResourceAmountExplicit(this, RESOURCE_HEALTH, ReadByte());
+               this.max_health = ReadByte();
+               this.count = ReadByte();
+               this.team = ReadByte();
 
 
-               if(!self.count)
-                       self.count = 40;
+               if(!this.count)
+                       this.count = 40;
 
 
-               generator_changeteam();
-               generator_construct();
+               generator_changeteam(this);
+               generator_construct(this, isnew);
        }
 
        if(sf & GSF_STATUS)
        {
                int _tmp;
                _tmp = ReadByte();
        }
 
        if(sf & GSF_STATUS)
        {
                int _tmp;
                _tmp = ReadByte();
-               if(_tmp != self.team)
+               if(_tmp != this.team)
                {
                {
-                       self.team = _tmp;
-                       generator_changeteam();
+                       this.team = _tmp;
+                       generator_changeteam(this);
                }
 
                _tmp = ReadByte();
 
                }
 
                _tmp = ReadByte();
 
-               if(_tmp != self.health)
-                       generator_damage(_tmp);
+               if(_tmp != GetResourceAmount(this, RESOURCE_HEALTH))
+                       generator_damage(this, _tmp);
 
 
-               self.health = _tmp;
+               SetResourceAmountExplicit(this, RESOURCE_HEALTH, _tmp);
        }
 }
        }
 }