1 #include "controlpoint.qh"
3 #include "teamradar.qh"
4 #include "../common/movetypes/movetypes.qh"
13 .vector cp_origin, cp_bob_origin;
22 .entity icon_realmodel;
24 void cpicon_precache()
27 return; // already precached
29 precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
30 precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
31 precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
32 precache_model("models/onslaught/controlpoint_icon.md3");
34 cpicon_precached = true;
39 if(time < self.move_time) { return; }
41 if(self.cp_bob_dmg_z > 0)
42 self.cp_bob_dmg_z = self.cp_bob_dmg_z - 3 * frametime;
44 self.cp_bob_dmg_z = 0;
45 self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd));
46 self.cp_bob_spd = self.cp_bob_spd + 1.875 * frametime;
47 self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
49 if(!self.iscaptured) self.alpha = self.health / self.max_health;
53 if (self.punchangle_x > 0)
55 self.punchangle_x = self.punchangle_x - 60 * frametime;
56 if (self.punchangle_x < 0)
57 self.punchangle_x = 0;
59 else if (self.punchangle_x < 0)
61 self.punchangle_x = self.punchangle_x + 60 * frametime;
62 if (self.punchangle_x > 0)
63 self.punchangle_x = 0;
66 if (self.punchangle_y > 0)
68 self.punchangle_y = self.punchangle_y - 60 * frametime;
69 if (self.punchangle_y < 0)
70 self.punchangle_y = 0;
72 else if (self.punchangle_y < 0)
74 self.punchangle_y = self.punchangle_y + 60 * frametime;
75 if (self.punchangle_y > 0)
76 self.punchangle_y = 0;
79 if (self.punchangle_z > 0)
81 self.punchangle_z = self.punchangle_z - 60 * frametime;
82 if (self.punchangle_z < 0)
83 self.punchangle_z = 0;
85 else if (self.punchangle_z < 0)
87 self.punchangle_z = self.punchangle_z + 60 * frametime;
88 if (self.punchangle_z > 0)
89 self.punchangle_z = 0;
92 self.angles_x = self.punchangle_x;
93 self.angles_y = self.punchangle_y + self.move_angles_y;
94 self.angles_z = self.punchangle_z;
95 self.move_angles_y = self.move_angles_y + 45 * frametime;
98 setorigin(self, self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg);
101 void cpicon_damage(float hp)
103 if(!self.iscaptured) { return; }
105 if(hp < self.max_health * 0.25)
106 setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
107 else if(hp < self.max_health * 0.50)
108 setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
109 else if(hp < self.max_health * 0.75)
110 setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
111 else if(hp <= self.max_health || hp >= self.max_health)
112 setmodel(self, "models/onslaught/controlpoint_icon.md3");
114 self.punchangle = (2 * randomvec() - '1 1 1') * 45;
116 self.cp_bob_dmg_z = (2 * random() - 1) * 15;
117 self.pain_finished = time + 1;
118 self.colormod = '2 2 2';
120 setsize(self, CPICON_MIN, CPICON_MAX);
123 void cpicon_construct()
125 self.netname = "Control Point Icon";
127 setmodel(self, "models/onslaught/controlpoint_icon.md3");
128 setsize(self, CPICON_MIN, CPICON_MAX);
130 if(self.icon_realmodel == world)
132 self.icon_realmodel = spawn();
133 setmodel(self.icon_realmodel, "null");
134 setorigin(self.icon_realmodel, self.origin);
135 setsize(self.icon_realmodel, CPICON_MIN, CPICON_MAX);
136 self.icon_realmodel.movetype = MOVETYPE_NOCLIP;
137 self.icon_realmodel.solid = SOLID_NOT;
138 self.icon_realmodel.move_origin = self.icon_realmodel.origin;
141 if(self.iscaptured) { self.icon_realmodel.solid = SOLID_BBOX; }
143 self.move_movetype = MOVETYPE_NOCLIP;
144 self.solid = SOLID_NOT;
145 self.movetype = MOVETYPE_NOCLIP;
146 self.move_origin = self.origin;
147 self.move_time = time;
148 self.drawmask = MASK_NORMAL;
150 self.draw = cpicon_draw;
151 self.cp_origin = self.origin;
152 self.cp_bob_origin = '0 0 0.1';
157 void cpicon_changeteam()
161 self.glowmod = Team_ColorRGB(self.team - 1);
162 self.teamradar_color = Team_ColorRGB(self.team - 1);
163 self.colormap = 1024 + (self.team - 1) * 17;
167 self.colormap = 1024;
168 self.glowmod = '1 1 0';
169 self.teamradar_color = '1 1 0';
179 self.origin_x = ReadCoord();
180 self.origin_y = ReadCoord();
181 self.origin_z = ReadCoord();
182 setorigin(self, self.origin);
184 self.health = ReadByte();
185 self.max_health = ReadByte();
186 self.count = ReadByte();
187 self.team = ReadByte();
188 self.iscaptured = ReadByte();
191 self.count = (self.health - self.max_health) * frametime;
200 int _tmp = ReadByte();
201 if(_tmp != self.team)
209 if(_tmp != self.health)