1 #include "cl_controlpoint.qh"
10 .vector cp_origin, cp_bob_origin;
19 .entity icon_realmodel;
21 void cpicon_draw(entity this)
23 if(time < this.move_time) { return; }
25 if(this.cp_bob_dmg_z > 0)
26 this.cp_bob_dmg_z = this.cp_bob_dmg_z - 3 * frametime;
28 this.cp_bob_dmg_z = 0;
29 this.cp_bob_origin_z = 4 * PI * (1 - cos(this.cp_bob_spd));
30 this.cp_bob_spd = this.cp_bob_spd + 1.875 * frametime;
31 this.colormod = '1 1 1' * (2 - bound(0, (this.pain_finished - time) / 10, 1));
33 if(!this.iscaptured) this.alpha = this.health / this.max_health;
37 if (this.punchangle_x > 0)
39 this.punchangle_x = this.punchangle_x - 60 * frametime;
40 if (this.punchangle_x < 0)
41 this.punchangle_x = 0;
43 else if (this.punchangle_x < 0)
45 this.punchangle_x = this.punchangle_x + 60 * frametime;
46 if (this.punchangle_x > 0)
47 this.punchangle_x = 0;
50 if (this.punchangle_y > 0)
52 this.punchangle_y = this.punchangle_y - 60 * frametime;
53 if (this.punchangle_y < 0)
54 this.punchangle_y = 0;
56 else if (this.punchangle_y < 0)
58 this.punchangle_y = this.punchangle_y + 60 * frametime;
59 if (this.punchangle_y > 0)
60 this.punchangle_y = 0;
63 if (this.punchangle_z > 0)
65 this.punchangle_z = this.punchangle_z - 60 * frametime;
66 if (this.punchangle_z < 0)
67 this.punchangle_z = 0;
69 else if (this.punchangle_z < 0)
71 this.punchangle_z = this.punchangle_z + 60 * frametime;
72 if (this.punchangle_z > 0)
73 this.punchangle_z = 0;
76 this.angles_x = this.punchangle_x;
77 this.angles_y = this.punchangle_y + this.angles_y;
78 this.angles_z = this.punchangle_z;
79 this.angles_y = this.angles_y + 45 * frametime;
82 setorigin(this, this.cp_origin + this.cp_bob_origin + this.cp_bob_dmg);
85 void cpicon_damage(entity this, float hp)
87 if(!this.iscaptured) { return; }
89 if(hp < this.max_health * 0.25)
90 setmodel(this, MDL_ONS_CP3);
91 else if(hp < this.max_health * 0.50)
92 setmodel(this, MDL_ONS_CP2);
93 else if(hp < this.max_health * 0.75)
94 setmodel(this, MDL_ONS_CP1);
95 else if(hp <= this.max_health || hp >= this.max_health)
96 setmodel(this, MDL_ONS_CP);
98 this.punchangle = (2 * randomvec() - '1 1 1') * 45;
100 this.cp_bob_dmg_z = (2 * random() - 1) * 15;
101 this.pain_finished = time + 1;
102 this.colormod = '2 2 2';
104 setsize(this, CPICON_MIN, CPICON_MAX);
107 void cpicon_construct(entity this, bool isnew)
109 this.netname = "Control Point Icon";
111 setmodel(this, MDL_ONS_CP);
112 setsize(this, CPICON_MIN, CPICON_MAX);
114 if(this.icon_realmodel == NULL)
116 this.icon_realmodel = spawn();
117 setmodel(this.icon_realmodel, MDL_Null);
118 setorigin(this.icon_realmodel, this.origin);
119 setsize(this.icon_realmodel, CPICON_MIN, CPICON_MAX);
120 set_movetype(this.icon_realmodel, MOVETYPE_NOCLIP);
121 this.icon_realmodel.solid = SOLID_NOT;
124 if(this.iscaptured) { this.icon_realmodel.solid = SOLID_BBOX; }
126 set_movetype(this, MOVETYPE_NOCLIP);
127 this.solid = SOLID_NOT;
128 set_movetype(this, MOVETYPE_NOCLIP);
129 this.move_time = time;
130 this.drawmask = MASK_NORMAL;
132 this.draw = cpicon_draw;
133 this.cp_origin = this.origin;
134 this.cp_bob_origin = '0 0 0.1';
138 IL_PUSH(g_drawables, this);
142 void cpicon_changeteam(entity this)
146 this.glowmod = Team_ColorRGB(this.team - 1);
147 this.teamradar_color = Team_ColorRGB(this.team - 1);
148 this.colormap = 1024 + (this.team - 1) * 17;
152 this.colormap = 1024;
153 this.glowmod = '1 1 0';
154 this.teamradar_color = '1 1 0';
158 NET_HANDLE(ENT_CLIENT_CONTROLPOINT_ICON, bool isnew)
165 this.origin_x = ReadCoord();
166 this.origin_y = ReadCoord();
167 this.origin_z = ReadCoord();
168 setorigin(this, this.origin);
170 this.health = ReadByte();
171 this.max_health = ReadByte();
172 this.count = ReadByte();
173 this.team = ReadByte();
174 this.iscaptured = ReadByte();
177 this.count = (this.health - this.max_health) * frametime;
179 cpicon_changeteam(this);
180 cpicon_construct(this, isnew);
185 int _tmp = ReadByte();
186 if(_tmp != this.team)
189 cpicon_changeteam(this);
194 if(_tmp != this.health)
195 cpicon_damage(this, _tmp);