]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/onslaught/sv_generator.qc
Onslaught: move controlpoint + generator to mutator module
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / onslaught / sv_generator.qc
diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_generator.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_generator.qc
new file mode 100644 (file)
index 0000000..cf8d234
--- /dev/null
@@ -0,0 +1,37 @@
+#include "sv_generator.qh"
+
+bool generator_send(entity this, entity to, int sf)
+{
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_GENERATOR);
+       WriteByte(MSG_ENTITY, sf);
+       if(sf & GSF_SETUP)
+       {
+               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);
+               WriteByte(MSG_ENTITY, self.count);
+               WriteByte(MSG_ENTITY, self.team);
+       }
+
+       if(sf & GSF_STATUS)
+       {
+               WriteByte(MSG_ENTITY, self.team);
+
+               if(self.health <= 0)
+                       WriteByte(MSG_ENTITY, 0);
+               else
+                       WriteByte(MSG_ENTITY, ceil((self.health / self.max_health) * 255));
+       }
+
+       return true;
+}
+
+void generator_link(void() spawnproc)
+{SELFPARAM();
+       Net_LinkEntity(self, true, 0, generator_send);
+       self.think              = spawnproc;
+       self.nextthink  = time;
+}