1 #include "controlpoint.qh"
3 #include "teamradar.qh"
11 .vector cp_origin, cp_bob_origin;
20 .entity icon_realmodel;
22 void cpicon_precache()
25 return; // already precached
27 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
28 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
29 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
30 precache_model("models/onslaught/controlpoint_icon.md3");
32 cpicon_precached = true;
37 if(time < self.move_time) { return; }
39 if(self.cp_bob_dmg_z > 0)
40 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 3 * frametime;
42 self.cp_bob_dmg_z = 0;
43 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd));
44 self.cp_bob_spd = self.cp_bob_spd + 1.875 * frametime;
45 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
47 if(!self.iscaptured) self.alpha = self.health / self.max_health;
51 if (self.punchangle_x > 0)
53 self.punchangle_x = self.punchangle_x - 60 * frametime;
54 if (self.punchangle_x < 0)
55 self.punchangle_x = 0;
57 else if (self.punchangle_x < 0)
59 self.punchangle_x = self.punchangle_x + 60 * frametime;
60 if (self.punchangle_x > 0)
61 self.punchangle_x = 0;
64 if (self.punchangle_y > 0)
66 self.punchangle_y = self.punchangle_y - 60 * frametime;
67 if (self.punchangle_y < 0)
68 self.punchangle_y = 0;
70 else if (self.punchangle_y < 0)
72 self.punchangle_y = self.punchangle_y + 60 * frametime;
73 if (self.punchangle_y > 0)
74 self.punchangle_y = 0;
77 if (self.punchangle_z > 0)
79 self.punchangle_z = self.punchangle_z - 60 * frametime;
80 if (self.punchangle_z < 0)
81 self.punchangle_z = 0;
83 else if (self.punchangle_z < 0)
85 self.punchangle_z = self.punchangle_z + 60 * frametime;
86 if (self.punchangle_z > 0)
87 self.punchangle_z = 0;
90 self.angles_x = self.punchangle_x;
91 self.angles_y = self.punchangle_y + self.move_angles_y;
92 self.angles_z = self.punchangle_z;
93 self.move_angles_y = self.move_angles_y + 45 * frametime;
96 setorigin(self, self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg);
99 void cpicon_damage(float hp)
101 if(!self.iscaptured) { return; }
103 if(hp < self.max_health * 0.25)
104 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
105 else if(hp < self.max_health * 0.50)
106 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
107 else if(hp < self.max_health * 0.75)
108 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
109 else if(hp <= self.max_health || hp >= self.max_health)
110 setmodel(self, "models/onslaught/controlpoint_icon.md3");
112 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
114 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
115 self.pain_finished = time + 1;
116 self.colormod = '2 2 2';
118 setsize(self, CPICON_MIN, CPICON_MAX);
121 void cpicon_construct()
123 self.netname = "Control Point Icon";
125 setmodel(self, "models/onslaught/controlpoint_icon.md3");
126 setsize(self, CPICON_MIN, CPICON_MAX);
128 if(self.icon_realmodel == world)
130 self.icon_realmodel = spawn();
131 setmodel(self.icon_realmodel, "null");
132 setorigin(self.icon_realmodel, self.origin);
133 setsize(self.icon_realmodel, CPICON_MIN, CPICON_MAX);
134 self.icon_realmodel.movetype = MOVETYPE_NOCLIP;
135 self.icon_realmodel.solid = SOLID_NOT;
136 self.icon_realmodel.move_origin = self.icon_realmodel.origin;
139 if(self.iscaptured) { self.icon_realmodel.solid = SOLID_BBOX; }
141 self.move_movetype = MOVETYPE_NOCLIP;
142 self.solid = SOLID_NOT;
143 self.movetype = MOVETYPE_NOCLIP;
144 self.move_origin = self.origin;
145 self.move_time = time;
146 self.drawmask = MASK_NORMAL;
148 self.draw = cpicon_draw;
149 self.cp_origin = self.origin;
150 self.cp_bob_origin = '0 0 0.1';
155 void cpicon_changeteam()
159 self.glowmod = Team_ColorRGB(self.team - 1);
160 self.teamradar_color = Team_ColorRGB(self.team - 1);
161 self.colormap = 1024 + (self.team - 1) * 17;
165 self.colormap = 1024;
166 self.glowmod = '1 1 0';
167 self.teamradar_color = '1 1 0';
177 self.origin_x = ReadCoord();
178 self.origin_y = ReadCoord();
179 self.origin_z = ReadCoord();
180 setorigin(self, self.origin);
182 self.health = ReadByte();
183 self.max_health = ReadByte();
184 self.count = ReadByte();
185 self.team = ReadByte();
186 self.iscaptured = ReadByte();
189 self.count = (self.health - self.max_health) * frametime;
198 int _tmp = ReadByte();
199 if(_tmp != self.team)
207 if(_tmp != self.health)