precache_model("models/onslaught/generator.md3");
precache_model("models/onslaught/generator_dead.md3");
precache_sound("onslaught/generator_underattack.wav");
+
+ precache_model("models/onslaught/generator_dmg1.md3");
+ precache_model("models/onslaught/generator_dmg2.md3");
+ precache_model("models/onslaught/generator_dmg3.md3");
+ precache_model("models/onslaught/generator_dmg4.md3");
+ precache_model("models/onslaught/generator_dmg5.md3");
+ precache_model("models/onslaught/generator_dmg6.md3");
+ precache_model("models/onslaught/generator_dmg7.md3");
+ precache_model("models/onslaught/generator_dmg8.md3");
+ precache_model("models/onslaught/generator_dmg9.md3");
+ precache_model("models/onslaught/generator_dead.md3");
}
-void generator_die()
+void generator_draw() { } // TODO
+
+.float max_health;
+void generator_damage(float hp)
{
- setmodel(self, "models/onslaught/generator_dead.md3");
+ if(hp <= 0)
+ setmodel(self, "models/onslaught/generator_dead.md3");
+ else if(hp < self.max_health * 0.10)
+ setmodel(self, "models/onslaught/generator_dmg9.md3");
+ else if(hp < self.max_health * 0.20)
+ setmodel(self, "models/onslaught/generator_dmg8.md3");
+ else if(hp < self.max_health * 0.30)
+ setmodel(self, "models/onslaught/generator_dmg7.md3");
+ else if(hp < self.max_health * 0.40)
+ setmodel(self, "models/onslaught/generator_dmg6.md3");
+ else if(hp < self.max_health * 0.50)
+ setmodel(self, "models/onslaught/generator_dmg5.md3");
+ else if(hp < self.max_health * 0.60)
+ setmodel(self, "models/onslaught/generator_dmg4.md3");
+ else if(hp < self.max_health * 0.70)
+ setmodel(self, "models/onslaught/generator_dmg3.md3");
+ else if(hp < self.max_health * 0.80)
+ setmodel(self, "models/onslaught/generator_dmg2.md3");
+ else if(hp < self.max_health * 0.90)
+ setmodel(self, "models/onslaught/generator_dmg1.md3");
+
+ setsize(self, GENERATOR_MIN, GENERATOR_MAX);
}
-void generator_draw() { } // TODO
-
void generator_construct()
{
self.netname = "Generator";
setsize(self, GENERATOR_MIN, GENERATOR_MAX);
self.move_movetype = MOVETYPE_NOCLIP;
- self.health = 255;
self.solid = SOLID_BBOX;
self.movetype = MOVETYPE_NOCLIP;
self.move_origin = self.origin;
self.origin_z = ReadCoord();
setorigin(self, self.origin);
+ self.health = ReadByte();
+ self.max_health = ReadByte();
+
generator_precache();
generator_construct();
self.colormap = 1024;
_tmp = ReadByte();
- if(_tmp == 0 && self.health != 0)
- generator_die();
+ if(_tmp != self.health)
+ generator_damage(_tmp);
+
+ //if(_tmp == 0 && self.health != 0)
+ //generator_die();
self.health = _tmp;
}
WriteCoord(MSG_ENTITY, self.origin_x);
WriteCoord(MSG_ENTITY, self.origin_y);
WriteCoord(MSG_ENTITY, self.origin_z);
+
+ WriteByte(MSG_ENTITY, self.health);
+ WriteByte(MSG_ENTITY, self.max_health);
}
if(sf & GSF_STATUS)